X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=tpsession-0.1%2Ftpsession%2Ftpsession.cpp;fp=tpsession-0.1%2Ftpsession%2Ftpsession.cpp;h=1e46b7beaf96ffc4fcfb4fdd8c2708cc14e31acc;hb=79dc2c038f5cce3131df512731e3d32aeaf4d668;hp=903e92beb8f070e12b1ea716b264e8e527841f7a;hpb=186690bd3c929b463daa6b472c9c4adfd7384e87;p=tpsession diff --git a/tpsession-0.1/tpsession/tpsession.cpp b/tpsession-0.1/tpsession/tpsession.cpp index 903e92b..1e46b7b 100644 --- a/tpsession-0.1/tpsession/tpsession.cpp +++ b/tpsession-0.1/tpsession/tpsession.cpp @@ -73,6 +73,7 @@ TpSession::TpSession(QString cmname,bool synchronous) mAM = Tp::AccountManager::create(); reqCm=cmname; + sync=synchronous; connect(mAM->becomeReady(), SIGNAL(finished(Tp::PendingOperation *)), SLOT(onAMReady(Tp::PendingOperation *))); @@ -100,7 +101,7 @@ TpSession* TpSession::instance(bool synchronous) void TpSession::onAMReady(Tp::PendingOperation *op) { - qDebug() << "TpSession::onAMReady"; + // qDebug() << "TpSession::onAMReady"; TpSessionAccount *tpacc; foreach (const QString &path, mAM->allAccountPaths()) { @@ -123,22 +124,23 @@ void TpSession::onAccountCreated(const QString &path) void TpSession::onAccountReady(TpSessionAccount *tpacc) { - qDebug() << "TpSession::onAccountReady:Account " << tpacc->acc->cmName() << "is Ready"; - connect(tpacc,SIGNAL(messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *)), + qDebug() << "TpSession::onAccountReady:Account " << tpacc->acc->cmName() << "is Ready sync=" << sync << "waiting:" << reqCm; + connect(tpacc,SIGNAL(messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *)), SLOT(onMessageReceived(const Tp::ReceivedMessage &,TpSessionAccount *))); - if(!reqCm.isEmpty() && tpacc->acc->cmName()==reqCm) { + if(!reqCm.isEmpty() && tpacc->acc->cmName()==reqCm) { if(sync) { sync=false; loop.quit(); - emit accountReady(tpacc); - if(!reqMsg.isEmpty()) tpacc->sendMessageToAddress(reqAddress,reqMsg); + qDebug() << "sync eventloop exit"; } + emit accountReady(tpacc); + if(!reqMsg.isEmpty()) tpacc->sendMessageToAddress(reqAddress,reqMsg); } } void TpSession::onMessageReceived(const Tp::ReceivedMessage &msg,TpSessionAccount *acc) { - qDebug() << "TestProg::onMessageReceived " << msg.text() << "from " << msg.sender()->id(); + // qDebug() << "TestProg::onMessageReceived " << msg.text() << "from " << msg.sender()->id(); emit messageReceived(msg,acc); } @@ -157,15 +159,15 @@ void TpSession::sendMessageToAddress(QString connectionMgr,QString address,QStri /** * Returns pointer to TpSessionAccout object with specified connection manager or protocol, returns NULL if no match found * - * \param cm Name of the connection manager, if left empty matches every entry + * \param cm Name of the connection manager, or iniqueIdentifier (dbus path to cm) if left empty matches every entry * \param protocol Name of the protocol manager, if left empty matches every entry */ TpSessionAccount* TpSession::getAccount(const QString cm,QString protocol) { - qDebug() << "TpSession::getAccount" << cm << " " << protocol; + // qDebug() << "TpSession::getAccount" << cm << " " << protocol; foreach (TpSessionAccount *tpacc, accounts) { - if((!cm.isEmpty() && tpacc->acc->cmName()==cm) || (!protocol.isEmpty() && tpacc->acc->protocol()==protocol)) { - qDebug() << "TpSession::getAccount found" << tpacc->acc->cmName() << " " << tpacc->acc->protocol(); + if((!cm.isEmpty() && ((tpacc->acc->cmName()==cm) || (tpacc->acc->uniqueIdentifier()==cm))) || (!protocol.isEmpty() && tpacc->acc->protocol()==protocol)) { + // qDebug() << "TpSession::getAccount found" << tpacc->acc->cmName() << " " << tpacc->acc->protocol() << " " << tpacc->acc->uniqueIdentifier(); return tpacc; } } @@ -175,7 +177,7 @@ TpSessionAccount* TpSession::getAccount(const QString cm,QString protocol) void TpSession::createObserver() { - qDebug() << __PRETTY_FUNCTION__ ; + qDebug() << __PRETTY_FUNCTION__ ; registrar = Tp::ClientRegistrar::create(); @@ -200,7 +202,7 @@ void TpSession::createObserver() Tp::AbstractClientPtr::dynamicCast(Tp::SharedPtr(observer)), "TpSessionChannelObserver"); - qDebug() << "TpSession::createObserver" << (registered ? "started" : "failed"); + // qDebug() << "TpSession::createObserver" << (registered ? "started" : "failed"); } @@ -210,7 +212,7 @@ void TpSession::createChannelListener(const QString &channelType, const Tp::AccountPtr &account, const Tp::ChannelPtr &channel) { - qDebug() << "TpSession::createChannelListener"; + qDebug() << "TpSession::createChannelListener"; QString channelObjectPath = channel->objectPath();