X-Git-Url: http://git.maemo.org/git/?p=vicar;a=blobdiff_plain;f=src%2Fvicar-lib%2Fcpp%2Ftelepathyutility.cpp;fp=src%2Fvicar-lib%2Fcpp%2Ftelepathyutility.cpp;h=5290910f22eb34f9893ea34b05c5c57c75f43b77;hp=068f3fe79dc70934505c141ef1def4f93e84a219;hb=f8710fc521c8941fc417018999806695ace8a2cb;hpb=38440679f13b8dc528a9aff93cbf4935011fdb22 diff --git a/src/vicar-lib/cpp/telepathyutility.cpp b/src/vicar-lib/cpp/telepathyutility.cpp index 068f3fe..5290910 100644 --- a/src/vicar-lib/cpp/telepathyutility.cpp +++ b/src/vicar-lib/cpp/telepathyutility.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include using namespace org::freedesktop::Telepathy; @@ -32,32 +33,47 @@ QList TelepathyUtility::getAllAccounts(){ QList objPathList; - QDBusInterface *iface = new QDBusInterface(AM_SERVICE,AM_OBJ_PATH,DBUS_PROPS_IFACE,QDBusConnection::sessionBus(),this); - if (iface->isValid()){ - QDBusReply reply = iface->call(QDBus::AutoDetect,"Get",AM_INTERFACE,"ValidAccounts"); - - if (reply.isValid()){; - QDBusVariant validAccounts = reply.value(); - const QVariant var = validAccounts.variant(); - const QDBusArgument arg = var.value(); - - arg.beginArray(); - while (!arg.atEnd()){ - QDBusObjectPath opath; - arg >> opath; - if (opath.path().contains("tel")){ - qDebug() << opath.path(); + QDBusConnection sessionBus = QDBusConnection::sessionBus(); + + if (sessionBus.isConnected()){ + QDBusInterface *iface = new QDBusInterface(AM_SERVICE,AM_OBJ_PATH,DBUS_PROPS_IFACE,sessionBus,this); + + if (iface->isValid()){ + QDBusReply reply = iface->call(QDBus::AutoDetect,"Get",AM_INTERFACE,"ValidAccounts"); + + if (reply.isValid()){; + QDBusVariant validAccounts = reply.value(); + const QVariant var = validAccounts.variant(); + const QDBusArgument arg = var.value(); + + arg.beginArray(); + while (!arg.atEnd()){ + QDBusObjectPath opath; + arg >> opath; + + if (opath.path().contains("tel")){ + qDebug() << opath.path(); + } + objPathList.append(opath); } - objPathList.append(opath); + arg.endArray(); + } + else{ + qDebug() << "Error occurred while fetching accounts list "< accountsList = this->getAllAccounts(); QDBusObjectPath account; foreach (account,accountsList){ + qDebug() << account.path(); if (account.path().contains("vicar/tel/vicar")){ vicarAccountExists = true; break; @@ -134,17 +151,13 @@ bool TelepathyUtility::createAccount(){ accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Enabled",true); accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.ConnectAutomatically",true); accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.RequestedPresence",QVariant::fromValue(presence)); - accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Service","vicar"); //Required when service can't be determined by the protocol name + //accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Service","vicar"); //Required when service can't be determined by the protocol name accountPropertiesMap.insert("com.nokia.Account.Interface.Compat.Profile","vicar"); QStringList valuesList; valuesList.append("TEL"); accountPropertiesMap.insert("com.nokia.Account.Interface.Compat.SecondaryVCardFields",valuesList); - //QStringList uriSchemeList; - //uriSchemeList.append("tel"); - //accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.Interface.Addressing.DRAFT.URISchemes",uriSchemeList); - QDBusPendingReply reply = amProxy->CreateAccount("vicar","tel","Vicar",connectionParametersMap,accountPropertiesMap); reply.waitForFinished();