77ae7553621d9863ae84ea83d73b3ff24c1d07da
[tpsession] / tpsession-0.1 / tpsession / tpsessionaccount.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 TPSESSIONACCOUNT_H
22 #define TPSESSIONACCOUNT_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/PendingContacts>
31 #include <TelepathyQt4/Channel>
32 #include <TelepathyQt4/TextChannel>
33 #include <TelepathyQt4/AccountManager>
34 #include <TelepathyQt4/PendingReady>
35 #include <TelepathyQt4/ContactManager>
36
37 #include <QString>
38 #include <QVector>
39
40 #include "tpsessionchannel.h"
41
42 class TpSessionAccount:public QObject
43 {
44
45     Q_OBJECT
46 public:
47   TpSessionAccount(Tp::AccountManagerPtr am,const QString &objectPath);
48   void makeContactFromAddress(QString address);
49   void sendMessageToAddress(QString address,QString message);
50   Tp::ContactPtr getContactFromAddress(QString address);
51   void addOutgoingChannel(const Tp::ContactPtr &contact);
52   void addOutgoingChannel(QString address);
53   TpSessionChannel *getChannelFromPeerAddress(QString id);
54 signals:
55   void accountReady(TpSessionAccount *);
56   void channelReady(TpSessionAccount *);
57   void messageQueued(TpSessionAccount *);
58   void messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
59   void messageSent(const Tp::Message &,TpSessionAccount *);
60   void newChannel(TpSessionAccount *,QString,QString,const Tp::ChannelDetails &);
61
62 private slots:
63   void onReady(Tp::PendingOperation *op);
64   void onOutgoingChannelReady(TpSessionChannel *ch);
65   void onContactsConnectionReady(Tp::PendingOperation *op);
66   void onNewContactRetrieved(Tp::PendingOperation *op);
67   void onMessageReceived(const Tp::ReceivedMessage &,TpSessionChannel *);
68   void onMessageSent(const Tp::Message &,Tp::MessageSendingFlags, const QString &);
69   void onNewChannels(const Tp::ChannelDetailsList&);
70 public:
71   bool ready;
72   QString reqContact;
73   QString reqMessage;
74   Tp::AccountPtr mAcc;
75   Tp::Account *acc;
76   Tp::ConnectionPtr contactsConn;
77   QSet<Tp::ContactPtr> myContacts;
78   QSet<TpSessionChannel *> myChannels;
79 };
80
81 #endif // TPSESSIONACCOUNT_H