File indexing completed on 2023-11-26 08:16:47

0001 /*
0002  * This file is part of telepathy-contactslist-prototype
0003  *
0004  * Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka@gmail.com>
0005  *
0006  * This library is free software; you can redistribute it and/or
0007  * modify it under the terms of the GNU Lesser General Public
0008  * License as published by the Free Software Foundation; either
0009  * version 2.1 of the License, or (at your option) any later version.
0010  *
0011  * This library is distributed in the hope that it will be useful,
0012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014  * Lesser General Public License for more details.
0015  *
0016  * You should have received a copy of the GNU Lesser General Public
0017  * License along with this library; if not, write to the Free Software
0018  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
0019  */
0020 
0021 #ifndef JOINCHATROOMDIALOG_H
0022 #define JOINCHATROOMDIALOG_H
0023 
0024 #include <TelepathyQt/AccountManager>
0025 #include <QDialog>
0026 #include <KTp/Models/rooms-model.h>
0027 
0028 #include <KTp/ktpcommoninternals_export.h>
0029 
0030 namespace Ui {
0031 class JoinChatRoomDialog;
0032 }
0033 
0034 class RoomsModel;
0035 class FavoriteRoomsModel;
0036 class QSortFilterProxyModel;
0037 class QAbstractButton;
0038 
0039 namespace KTp {
0040 
0041 class KTPCOMMONINTERNALS_EXPORT JoinChatRoomDialog : public QDialog
0042 {
0043     Q_OBJECT
0044 
0045 public:
0046     explicit JoinChatRoomDialog(Tp::AccountManagerPtr accountManager, QWidget *parent = nullptr);
0047     ~JoinChatRoomDialog() override;
0048 
0049     Tp::AccountPtr selectedAccount() const;     /** returns selected account */
0050     QString selectedChatRoom() const;           /** returns selected chat room */
0051     void accept() override;
0052 
0053 protected:
0054     void closeEvent(QCloseEvent *e) override;
0055 
0056 private Q_SLOTS:
0057     void onTextChanged(QString newText);
0058     void onAccountSelectionChanged(int newIndex);
0059     void addRecentRoom();
0060     void clearRecentRooms();
0061     void getRoomList();
0062     void stopListing();
0063     void onRoomListChannelReadyForHandling(Tp::PendingOperation *operation);
0064     void onRoomListChannelReady(Tp::PendingOperation *operation);
0065     void onRoomListChannelClosed(Tp::PendingOperation *operation);
0066     void onListing(bool isListing);
0067     void onGotRooms(Tp::RoomInfoList roomInfoList);
0068     void onFavoriteRoomSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
0069     void onFavoriteRoomDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
0070     void onRoomClicked(const QModelIndex &index);
0071     void onAccountManagerReady(Tp::PendingOperation*);
0072     void onStartChatFinished(Tp::PendingOperation *op);
0073 
0074 private:
0075     void sendNotificationToUser(const QString& errorMsg);
0076     void loadFavoriteRooms();
0077     void setJoinInProgress(bool);
0078 
0079     struct Private;
0080     Private * const d;
0081 };
0082 
0083 } //namespace KTp
0084 
0085 
0086 #endif  // JOINCHATROOMDIALOG_H