channelDestroyed hadling, TPSESSION_DEBUG env
[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 class TpSessionAccount;
41
42 #include "tpsession.h"
43 #include "tpsessionchannel.h"
44
45 class TpSessionAccount:public QObject
46 {
47
48     Q_OBJECT
49 public:
50   TpSessionAccount(Tp::AccountManagerPtr am,const QString &objectPath);
51   bool makeContactFromAddress(QString address);
52   void sendMessageToAddress(QString address,QString message);
53   Tp::ContactPtr getContactFromAddress(QString address);
54   void addOutgoingChannel(const Tp::ContactPtr &contact);
55   void addOutgoingChannel(QString address);
56   TpSessionChannel *getChannelFromPeerAddress(QString id);
57 signals:
58   void accountReady(TpSessionAccount *);
59   void channelReady(TpSessionAccount *);
60   void messageQueued(TpSessionAccount *,bool);
61   void messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
62   void messageSent(const Tp::Message &,TpSessionAccount *);
63   void newChannel(TpSessionAccount *,QString,QString,const Tp::ChannelDetails &);
64   void contactRetrieved(Tp::ContactPtr,bool,bool);
65
66 private slots:
67   void onReady(Tp::PendingOperation *op);
68   void onOutgoingChannelReady(TpSessionChannel *ch);
69   void onChannelDestroyed(TpSessionChannel *ch);
70   void onContactsConnectionReady(Tp::PendingOperation *op);
71   void onNewContactRetrieved(Tp::PendingOperation *op);
72   void onMessageReceived(const Tp::ReceivedMessage &,TpSessionChannel *);
73   void onMessageSent(const Tp::Message &,Tp::MessageSendingFlags, const QString &,TpSessionChannel *);
74   void onNewChannels(const Tp::ChannelDetailsList&);
75 public:
76   bool ready;
77   QString reqContact;
78   QString reqMessage;
79   Tp::AccountPtr mAcc;
80   Tp::Account *acc;
81   Tp::ConnectionPtr contactsConn;
82   QSet<Tp::ContactPtr> myContacts;
83   QSet<TpSessionChannel *> myChannels;
84 };
85
86 #endif // TPSESSIONACCOUNT_H