X-Git-Url: http://git.maemo.org/git/?p=vicar;a=blobdiff_plain;f=src%2Fvicar-utils%2Fcpp%2Fmain.cpp;h=545cb0327d6db35d8e0a0da8440ab128b93a27ad;hp=a5a19da01012ccc93f498a104c937be4a109d8f3;hb=f8710fc521c8941fc417018999806695ace8a2cb;hpb=38440679f13b8dc528a9aff93cbf4935011fdb22 diff --git a/src/vicar-utils/cpp/main.cpp b/src/vicar-utils/cpp/main.cpp index a5a19da..545cb03 100755 --- a/src/vicar-utils/cpp/main.cpp +++ b/src/vicar-utils/cpp/main.cpp @@ -10,10 +10,25 @@ #include "connectioninterfacerequeststypes.h" #include "harmattanaccountutility.h" #include -#include //DEBUG - Delete this +#include #include "dbusutility.h" #include #include +#include //DEBUG + + +#include +#include +#include + +#define AM_SERVICE "org.freedesktop.Telepathy.AccountManager" +#define AM_OBJ_PATH "/org/freedesktop/Telepathy/AccountManager" +#define AM_INTERFACE "org.freedesktop.Telepathy.AccountManager" +#define RING_CONN_SERVICE "org.freedesktop.Telepathy.Connection.ring.tel.ring" +#define RING_CONN_PATH "/org/freedesktop/Telepathy/Connection/ring/tel/ring" +#define DBUS_SERVICE "org.freedesktop.DBus.Properties" +#define DBUS_OBJ_PATH "/org/freedesktop/DBus/Properties" +#define DBUS_PROPS_IFACE "org.freedesktop.DBus.Properties" int main(int argc, char *argv[]) { @@ -37,7 +52,7 @@ int main(int argc, char *argv[]) if (argc > 1 && argv[1]){ QString instruction = QString(argv[1]); if (instruction == "INSTALL"){ - //Check if Account already exists + //Check if Account already exists if (!tpUtility->accountExists()){ qDebug() << "VICaR account not found. Creating .."; bool result = tpUtility->createAccount(); @@ -51,98 +66,61 @@ int main(int argc, char *argv[]) bool result = tpUtility->deleteAccount(); if (!result) exit(2); } - + else if (instruction == "TESTING"){ + tpUtility->callNumberWithRing(argv[2]); + } + else if (instruction == "TPACCOUNTSTATUS"){ + QString status = tpUtility->getAccountStatus(); + qDebug() << "Account Status is "<< status; + } +#if defined(Q_WS_MAEMO_5) else if (instruction == "CREATEDB"){ bool result = databaseUtility->openDatabase(); if (!result){ - qDebug() <<"Error creating profiles database. " + qDebug() <<"Error creating vicar database. " <lastError(); exit(3); } - qDebug() << "VICaR profiles database opened."; - if (!databaseUtility->tableExists("profiles")){ - qDebug() << "Creating VICaR profiles table.."; - result = databaseUtility->createProfilesTable(); - if (!result){ - qDebug() <<"Error creating profiles table. " - <lastError(); - exit(4); - } - } - else{ - qDebug()<<"Profiles table exists"; + qDebug() << "VICaR database opened."; + qDebug() << "Preparing VICaR tables.."; + result = databaseUtility->prepareTables(); + if (!result){ + qDebug() <<"Error creating tables. " + <lastError(); + exit(4); } + databaseUtility->closeDatabase(); } else if (instruction == "DROPDB"){ bool result = databaseUtility->deleteDatabase(); if (!result){ - qDebug() <<"Error deleting profiles database. " + qDebug() <<"Error deleting vicar database. " <lastError(); exit(5); } - qDebug() << "VICaR profiles database deleted."; - } - else if (instruction == "TPACCOUNTSTATUS"){ - QString status = tpUtility->getAccountStatus(); - qDebug() << "Account Status is "<< status; - } + qDebug() << "VICaR database deleted."; + } +#elif defined(Q_WS_MAEMO_6) else if (instruction == "--create-account"){ -#if defined(Q_WS_MAEMO_6) qDebug() << "Creating account"; accountUtility->addAccount(); -#else - qDebug() << "This command is applicable only in harmattan"; -#endif } else if (instruction == "--delete-account"){ -#if defined(Q_WS_MAEMO_6) qDebug() << "Deleting account"; accountUtility->removeAccount(); -#else - qDebug() << "This command is applicable only in harmattan"; -#endif } - else if (instruction == "TESTING"){ - tpUtility->callNumberWithRing(argv[2]); +#endif + else { + qDebug() << "This command is not recognized"; } } else{ - qDebug() << "Sending Introspect method call"; - - DbusUtility dbusUtility(&app); - QList argsToSend; + qDebug() << QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex(); - - bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.Connection.ring.tel.ring", - "/org/freedesktop/Telepathy/Connection/ring/tel/ring", - "org.freedesktop.DBus.Introspectable", - "Introspect",argsToSend,false); - - success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.ConnectionManager.ring", - "/org/freedesktop/Telepathy/ConnectionManager/ring", - "org.freedesktop.DBus.Introspectable", - "Introspect",argsToSend,false); - - /* - - bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.AccountManager", - "/org/freedesktop/Telepathy/Account/ring/tel/ring", - "org.freedesktop.Telepathy.Account", - "Reconnect",argsToSend,false); - */ - - if (!success){ - qDebug() << dbusUtility.getErrorMessage(); - } - else{ - qDebug() << "Method call executed successfully"; - } - app.exec(); } - delete (tpUtility); delete (databaseUtility); delete (accountUtility);