mAM = Tp::AccountManager::create();
reqCm=cmname;
+ sync=synchronous;
connect(mAM->becomeReady(),
SIGNAL(finished(Tp::PendingOperation *)),
SLOT(onAMReady(Tp::PendingOperation *)));
void TpSession::onAMReady(Tp::PendingOperation *op)
{
- qDebug() << "TpSession::onAMReady";
+ // qDebug() << "TpSession::onAMReady";
TpSessionAccount *tpacc;
foreach (const QString &path, mAM->allAccountPaths()) {
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);
}
/**
* 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;
}
}
void TpSession::createObserver()
{
- qDebug() << __PRETTY_FUNCTION__ ;
+ qDebug() << __PRETTY_FUNCTION__ ;
registrar = Tp::ClientRegistrar::create();
Tp::AbstractClientPtr::dynamicCast(Tp::SharedPtr<TpSessionObserver>(observer)),
"TpSessionChannelObserver");
- qDebug() << "TpSession::createObserver" << (registered ? "started" : "failed");
+ // qDebug() << "TpSession::createObserver" << (registered ? "started" : "failed");
}
const Tp::AccountPtr &account,
const Tp::ChannelPtr &channel)
{
- qDebug() << "TpSession::createChannelListener";
+ qDebug() << "TpSession::createChannelListener";
QString channelObjectPath = channel->objectPath();