X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fvicar-lib%2Fsrc%2Ftelepathyutility.cpp;fp=src%2Fvicar-lib%2Fsrc%2Ftelepathyutility.cpp;h=0000000000000000000000000000000000000000;hb=74800375ecf7f41e290cf7cc7fa9ee8b230be68e;hp=f75681b386f2eaf73ff1cb53b32252c0a913e112;hpb=89f0017e6a73945ea83247472a6fa07d6ee536b5;p=vicar diff --git a/src/vicar-lib/src/telepathyutility.cpp b/src/vicar-lib/src/telepathyutility.cpp deleted file mode 100644 index f75681b..0000000 --- a/src/vicar-lib/src/telepathyutility.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/* -@version: 0.6 -@author: Sudheer K. -@license: GNU General Public License -*/ - -#include "telepathyutility.h" -#include "accountmanagerproxy.h" -#include "accountproxy.h" -#include "accountcompatproxy.h" -#include "connifacereqproxy.h" -#include -#include -#include -#include -#include -#include - -using namespace org::freedesktop::Telepathy; - -TelepathyUtility::TelepathyUtility(QObject *parent) : - QObject(parent) -{ -} - -TelepathyUtility::~TelepathyUtility(){ - -} - -//Get a list of all Telepathy accounts -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(); - } - objPathList.append(opath); - } - arg.endArray(); - } - else{ - qDebug() << "Error occurred while fetching accounts list "< accountsList = this->getAllAccounts(); - QDBusObjectPath account; - foreach (account,accountsList){ - if (account.path().contains("vicar/tel/vicar")){ - vicarAccountExists = true; - break; - } - } - - return vicarAccountExists; -} - -//Get telepathy account status -QString TelepathyUtility::getAccountStatus(){ - - QString status = "Not Available"; - - QList accountsList = this->getAllAccounts(); - QDBusObjectPath account; - foreach (account,accountsList){ - if (account.path().contains("vicar/tel/vicar")){ - AccountProxy *accountProxy = new AccountProxy(AM_SERVICE,account.path(),QDBusConnection::sessionBus(),this); - if (accountProxy->isValid()){ - uint intStatus = accountProxy->property("ConnectionStatus").toUInt(); - //Based on http://telepathy.freedesktop.org/spec/Connection.html#Connection_Status - switch(intStatus){ - case 0: - status = "Connected"; - break; - case 1: - status = "Connecting"; - break; - case 2: - status = "Disconnected"; - break; - } - } - } - } - - return status; -} - -//Create Vicar telepathy account (used during installation) -bool TelepathyUtility::createAccount(){ - - AccountManagerProxy *amProxy = new AccountManagerProxy(AM_SERVICE,AM_OBJ_PATH,QDBusConnection::sessionBus(),this); - - QMap connectionParametersMap; - connectionParametersMap.insert("account","vicar"); - - QList presenceDetails; - uint presenceType(2); //Available = 2 - presenceDetails << presenceType; - presenceDetails << "online"; - presenceDetails << "Available"; - - SimplePresence presence; - presence.type = presenceType; - presence.status = "online"; - presence.statusMessage = "Available"; - - QMap accountPropertiesMap; - accountPropertiesMap.insert("org.freedesktop.Telepathy.Account.AutomaticPresence",QVariant::fromValue(presence)); - 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("com.nokia.Account.Interface.Compat.Profile","vicar"); - - QStringList valuesList; - valuesList.append("TEL"); - accountPropertiesMap.insert("com.nokia.Account.Interface.Compat.SecondaryVCardFields",valuesList); - - QDBusPendingReply reply = amProxy->CreateAccount("vicar","tel","Vicar",connectionParametersMap,accountPropertiesMap); - reply.waitForFinished(); - - if (reply.isValid()){ - QDBusObjectPath account = reply.value(); - qDebug() << account.path() <<" created successfully."; - - AccountCompatProxy *accountCompatProxy = new AccountCompatProxy(AM_SERVICE,account.path(),QDBusConnection::sessionBus(),this); - if (accountCompatProxy->isValid()){ - QDBusPendingReply<> dbusReply = accountCompatProxy->SetHasBeenOnline(); - dbusReply.waitForFinished(); - if (dbusReply.isError()){ - qDebug() << "Error occurred while setting HasBeenOnline property "< accountsList = this->getAllAccounts(); - QDBusObjectPath account; - foreach (account,accountsList){ - if (account.path().contains("vicar/tel/vicar")){ - AccountProxy *accountProxy = new AccountProxy(AM_SERVICE,account.path(),QDBusConnection::sessionBus(),this); - if (accountProxy->isValid()){ - QDBusPendingReply<> dbusReply = accountProxy->Remove(); - dbusReply.waitForFinished(); - if (dbusReply.isError()){ - qDebug() << "Error occurred while removing VICaR account "<isValid()){ - QVariantMap channelRequestDetails; - uint targetHandleType(1); - channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.TargetHandleType",targetHandleType); - channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.TargetID",number); - channelRequestDetails.insert("org.freedesktop.Telepathy.Channel.ChannelType","org.freedesktop.Telepathy.Channel.Type.StreamedMedia"); - QDBusPendingReply dbusReply = requestsProxy->CreateChannel(channelRequestDetails); - dbusReply.waitForFinished(); - if (!dbusReply.isError()){ - QDBusObjectPath objPath = dbusReply.argumentAt<0>(); - QVariantMap channelProperties = dbusReply.argumentAt<1>(); - result = true; - } - else{ - qDebug() << "Error occurred calling "<>(const QDBusArgument &argument, SimplePresence &simplePresence) - { - argument.beginStructure(); - argument >> simplePresence.type >> simplePresence.status >> simplePresence.statusMessage; - argument.endStructure(); - return argument; - }