Home · All Classes · All Namespaces · Modules · Functions · Files

tpsession.h

00001 /*
00002  * This file is part of TpSession
00003  *
00004  * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
00005  * Contact Kate Alhola  kate.alholanokia.com
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 #ifndef TPSESSION_H
00022 #define TPSESSION_H
00023 
00024 #include <TelepathyQt4/Types>
00025 #include <TelepathyQt4/Account>
00026 #include <TelepathyQt4/Types>
00027 #include <TelepathyQt4/PendingChannelRequest>
00028 #include <TelepathyQt4/ChannelRequest>
00029 #include <TelepathyQt4/PendingChannel>
00030 #include <TelepathyQt4/Channel>
00031 #include <TelepathyQt4/TextChannel>
00032 #include <TelepathyQt4/AccountManager>
00033 #include <TelepathyQt4/PendingOperation>
00034 #include <TelepathyQt4/PendingReady>
00035 #include <TelepathyQt4/ClientRegistrar>
00036 #include <TelepathyQt4/Debug>
00037 
00038 #include <QString>
00039 #include <QVector>
00040 #include <QObject>
00041 
00042 #include "tpsessionaccount.h"
00043 #include "tpsessionobserver.h"
00044 
00045 class TpSession:public QObject
00046 {
00047        Q_OBJECT
00048 public:
00049     TpSession(QString cmname=QString(),bool synchronous=FALSE);
00050 
00051 
00052     static TpSession* instance(bool synchronous=TRUE);
00053     void sendMessageToAddress(QString connectionMgr,QString address,QString message);
00054     TpSessionAccount* getAccount(const  QString cm, const QString protocol=QString());
00055     void createChannelListener(const QString &channelType,
00056                                const Tp::MethodInvocationContextPtr<> &context,
00057                                const Tp::AccountPtr &account,
00058                                const Tp::ChannelPtr &channel);
00059     void createObserver();
00060 
00061 signals:
00062     void amReady(TpSession *);
00063     void accountReady(TpSessionAccount *);
00064     void channeReady(TpSessionAccount *);
00065     void messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
00066 private slots:
00067     void onAMReady(Tp::PendingOperation *);
00068     void onAccountCreated(const QString &);
00069     void onReady(Tp::PendingOperation *);
00070     void onAccountReady(TpSessionAccount *tpacc);
00071     void onMessageReceived(const Tp::ReceivedMessage &,TpSessionAccount *);
00072 public:
00073     QVector<TpSessionAccount*> accounts;
00074 
00075 private:
00076     static TpSession *instancePtr;
00077     //TpSession *instancePtr;
00078     QString reqCm;
00079     QString reqAddress;
00080     QString reqMsg;
00081 
00082     bool sync;  // Synchronous initialization
00083     QEventLoop loop;
00084     Tp::AccountManagerPtr mAM;
00085     QStringList channels;
00086     Tp::ClientRegistrarPtr registrar;
00087 };
00088 
00089 
00090 
00091 #endif // TPSESSION_H


Copyright © 2010 Nokia Corporation
TpSession