some UI changes for usability
[makneto-zunavac1.git] / src / backend / telepathy-client.h
blobace1bc5bb0f2a27daa0c4ffadc918c312ec937c2
1 /*
2 * Telepathy client is a class for communication via Telepathy
4 * Copyright (C) 2011 Vojta Kulicka <vojtechkulicka@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef MAKNETO_TELEPATHY_CLIENT
23 #define MAKNETO_TELEPATHY_CLIENT
25 #include <QObject>
26 #include <QMap>
28 #include <TelepathyQt4/Debug>
29 #include <TelepathyQt4/Constants>
30 #include <TelepathyQt4/Types>
31 #include <TelepathyQt4/Global>
33 #include <TelepathyQt4/AccountManager>
34 #include <TelepathyQt4/ClientRegistrar>
35 #include <TelepathyQt4/TextChannel>
36 #include <TelepathyQt4/AbstractClientHandler>
37 #include "session.h"
38 #include "makneto-backend.h"
40 class QString;
41 class QModelIndex;
43 namespace Tp {
44 class PendingOperation;
45 class StreamedMediaChannel;
48 namespace MaknetoBackend {
50 class AccountsModel;
52 class MAKNETO_EXPORT TelepathyClient : public QObject, public Tp::AbstractClientHandler {
53 Q_OBJECT;
54 public:
56 enum {
57 Available,
58 Away,
59 Busy,
60 Invisible,
61 Offline
64 static TelepathyClient* Instance();
65 static TelepathyClient* Instance(const Tp::ChannelClassSpecList &channelFilter,
66 Tp::AccountManagerPtr AM,
67 AccountsModel *accountsModel,
68 const QString &clientName = QString(),
69 QObject *parent = 0);
71 ~TelepathyClient();
73 //TELEPATHY HANDLER CLIENT CODE START
74 virtual void handleChannels(const Tp::MethodInvocationContextPtr<> &context,
75 const Tp::AccountPtr & account,
76 const Tp::ConnectionPtr & connection,
77 const QList< Tp::ChannelPtr > & channels,
78 const QList< Tp::ChannelRequestPtr > & requestsSatisfied,
79 const QDateTime & userActionTime,
80 const Tp::AbstractClientHandler::HandlerInfo & handlerInfo
83 bool bypassApproval() const;
84 //TELEPATHY HANDLER CLIENT CODE END
86 void setAccountManager(const Tp::AccountManagerPtr &);
87 AccountsModel* accountsModel();
88 Tp::AccountManagerPtr accountManager();
89 QString sessionIdforIndex(const QModelIndex &);
90 Tp::AccountPtr getAccountforChannel(const Tp::ChannelPtr &);
91 QString getPreferredHandler();
94 Q_SIGNALS:
95 void sessionCreated(MaknetoBackend::Session *, bool extendExisting, bool requested);
96 void sessionAlreadyExists(MaknetoBackend::Session *);
97 //void incomingCall(MaknetoBackend::Session *); // TODO: it is used? remove...
99 public
100 Q_SLOTS:
101 void onNewTextChatRoomRequested(const QModelIndex &, const QString &);
102 void setAccountPresence(QModelIndex, int, const QString & = QString());
104 void onSessionEnded(const QString &name) {
105 Q_UNUSED(name);
106 }//TODO
107 void onMediaChannelReady(Tp::PendingOperation *);
108 void onSessionRequested(const QModelIndex &, MaknetoBackend::Session::SessionType);
109 void onSessionRequested(const QString &accountId, const QString &contactId, MaknetoBackend::Session::SessionType);
111 private:
113 TelepathyClient(const Tp::ChannelClassSpecList &channelFilter,
114 Tp::AccountManagerPtr AM,
115 AccountsModel *accountsModel,
116 const QString &clientName = QString(),
117 QObject* parent = 0);
119 Q_DISABLE_COPY(TelepathyClient);
120 static TelepathyClient *m_instance;
123 Session* findSession(const QString &);
124 //QString sessionNameForChannel(const Tp::ChannelPtr &);
126 Tp::AccountManagerPtr m_AM;
127 AccountsModel *m_accountsModel;
128 QMap<QString, Session *> *m_sessions;
129 QString clientName;
133 #endif