1 /* 2 Copyright (C) 2010 David Edmundson <kde@davidedmundson.co.uk> 3 Copyright (C) 2011 Dominik Schmidt <dev@dominik-schmidt.de> 4 Copyright (C) 2011 Francesco Nwokeka <francesco.nwokeka@gmail.com> 5 6 This program is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 21 #ifndef TELEPATHYCHATUI_H 22 #define TELEPATHYCHATUI_H 23 24 #include <TelepathyQt/AbstractClientHandler> 25 #include <TelepathyQt/AccountManager> 26 27 #include <KTp/telepathy-handler-application.h> 28 29 namespace KTp { 30 class AbstractMessageFilter; 31 } 32 33 namespace Tp { 34 class ReceivedMessage; 35 } 36 37 class ChatTab; 38 class ChatWindow; 39 class QEventLoopLocker; 40 41 class TelepathyChatUi : public KTp::TelepathyHandlerApplication, public Tp::AbstractClientHandler 42 { 43 Q_OBJECT 44 public: 45 TelepathyChatUi(int& argc, char* argv[]); 46 ~TelepathyChatUi(); 47 48 virtual void handleChannels(const Tp::MethodInvocationContextPtr<> & context, 49 const Tp::AccountPtr &account, 50 const Tp::ConnectionPtr &connection, 51 const QList<Tp::ChannelPtr> &channels, 52 const QList<Tp::ChannelRequestPtr> &channelRequests, 53 const QDateTime &userActionTime, 54 const Tp::AbstractClientHandler::HandlerInfo &handlerInfo); 55 56 virtual bool bypassApproval() const; 57 58 private Q_SLOTS: 59 void dettachTab(ChatTab *tab); 60 61 void onTabAboutToClose(ChatTab *tab); 62 void onWindowAboutToClose(ChatWindow *window); 63 void onGroupChatMessageReceived(const Tp::ReceivedMessage &msg); 64 void onChannelInvalidated(); 65 void onConnectionStatusChanged(Tp::ConnectionStatus); 66 67 private: 68 void takeChannel(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, bool ref = true); 69 void releaseChannel(const Tp::TextChannelPtr &channel, const Tp::AccountPtr &account, bool unref = true); 70 void connectChannelNotifications(const Tp::TextChannelPtr &textChannel, bool enable); 71 void connectAccountNotifications(const Tp::AccountPtr &account, bool enable); 72 bool isHiddenChannel(const Tp::AccountPtr &account, const Tp::TextChannelPtr &channel, 73 Tp::TextChannelPtr *oldChannel) const; 74 ChatWindow* createWindow(); 75 76 Tp::AccountManagerPtr m_accountManager; 77 QList<ChatWindow*> m_chatWindows; 78 79 QHash<Tp::TextChannelPtr, Tp::AccountPtr> m_channelAccountMap; 80 KTp::AbstractMessageFilter *m_notifyFilter; 81 QEventLoopLocker *m_eventLoopLocker; 82 }; 83 84 #endif // TELEPATHYCHATUI_H 85