first release
[groupsms] / sms / tpsession / tpsession.h
1 /*
2  * This file is part of TpSession
3  *
4  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
5  * Contact Kate Alhola  kate.alholanokia.com
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20  */
21 #ifndef TPSESSION_H
22 #define TPSESSION_H
23
24 #include <TelepathyQt4/Types>
25 #include <TelepathyQt4/Account>
26 #include <TelepathyQt4/Types>
27 #include <TelepathyQt4/PendingChannelRequest>
28 #include <TelepathyQt4/ChannelRequest>
29 #include <TelepathyQt4/PendingChannel>
30 #include <TelepathyQt4/Channel>
31 #include <TelepathyQt4/TextChannel>
32 #include <TelepathyQt4/AccountManager>
33 #include <TelepathyQt4/PendingOperation>
34 #include <TelepathyQt4/PendingReady>
35 #include <TelepathyQt4/ClientRegistrar>
36 #include <TelepathyQt4/Debug>
37
38 #include <QString>
39 #include <QVector>
40 #include <QObject>
41
42 #include "tpsessionaccount.h"
43 #include "tpsessionobserver.h"
44
45 class TpSession:public QObject
46 {
47        Q_OBJECT
48 public:
49     TpSession(QString cmname=QString(),bool synchronous=FALSE);
50
51
52     static TpSession* instance(bool synchronous=TRUE);
53     void sendMessageToAddress(QString connectionMgr,QString address,QString message);
54     TpSessionAccount* getAccount(const  QString cm, const QString protocol=QString());
55     void createChannelListener(const QString &channelType,
56                                const Tp::MethodInvocationContextPtr<> &context,
57                                const Tp::AccountPtr &account,
58                                const Tp::ChannelPtr &channel);
59     void createObserver();
60
61 Q_SIGNALS:
62     void amReady(TpSession *);
63     void accountReady(TpSessionAccount *);
64     void channeReady(TpSessionAccount *);
65     void messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
66
67     // Tom add
68     void messageSent(const Tp::Message &,TpSessionAccount *);
69     // Tom end
70 private Q_SLOTS:
71     void onAMReady(Tp::PendingOperation *);
72     void onAccountCreated(const QString &);
73     void onReady(Tp::PendingOperation *);
74     void onAccountReady(TpSessionAccount *tpacc);
75     void onMessageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
76
77     // Tom add
78     void onMessageSent(const Tp::Message &,TpSessionAccount *);
79     // Tom end
80 public:
81     QVector<TpSessionAccount*> accounts;
82
83 private:
84     static TpSession *instancePtr;
85     //TpSession *instancePtr;
86     QString reqCm;
87     QString reqAddress;
88     QString reqMsg;
89
90     bool sync;  // Synchronous initialization
91     QEventLoop loop;
92     Tp::AccountManagerPtr mAM;
93     QStringList channels;
94     Tp::ClientRegistrarPtr registrar;
95 };
96
97
98
99 #endif // TPSESSION_H