X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=src%2Fvicar-utils%2Fcpp%2Fmain.cpp;fp=src%2Fvicar-utils%2Fcpp%2Fmain.cpp;h=a5a19da01012ccc93f498a104c937be4a109d8f3;hb=74800375ecf7f41e290cf7cc7fa9ee8b230be68e;hp=0000000000000000000000000000000000000000;hpb=89f0017e6a73945ea83247472a6fa07d6ee536b5;p=vicar diff --git a/src/vicar-utils/cpp/main.cpp b/src/vicar-utils/cpp/main.cpp new file mode 100755 index 0000000..a5a19da --- /dev/null +++ b/src/vicar-utils/cpp/main.cpp @@ -0,0 +1,152 @@ +/* +@version: 0.6 +@author: Sudheer K. +@license: GNU General Public License +*/ + +#include "telepathyutility.h" +#include "databaseutility.h" +#include "vicarprofiletypes.h" +#include "connectioninterfacerequeststypes.h" +#include "harmattanaccountutility.h" +#include +#include //DEBUG - Delete this +#include "dbusutility.h" +#include +#include + +int main(int argc, char *argv[]) +{ + + QCoreApplication app(argc,argv); + + qDBusRegisterMetaType(); + //From Connection Interface Requests + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + //From Vicar Profile Types + //qDBusRegisterMetaType(); + //qDBusRegisterMetaType(); + + TelepathyUtility *tpUtility = new TelepathyUtility(); + DatabaseUtility *databaseUtility = new DatabaseUtility(); + HarmattanAccountUtility *accountUtility = new HarmattanAccountUtility(); + + if (argc > 1 && argv[1]){ + QString instruction = QString(argv[1]); + if (instruction == "INSTALL"){ + //Check if Account already exists + if (!tpUtility->accountExists()){ + qDebug() << "VICaR account not found. Creating .."; + bool result = tpUtility->createAccount(); + if (!result) exit(1); + } + else{ + qDebug() << "VICaR account found."; + } + } + else if (instruction == "REMOVE"){ + bool result = tpUtility->deleteAccount(); + if (!result) exit(2); + } + + else if (instruction == "CREATEDB"){ + bool result = databaseUtility->openDatabase(); + if (!result){ + qDebug() <<"Error creating profiles 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"; + } + databaseUtility->closeDatabase(); + } + else if (instruction == "DROPDB"){ + bool result = databaseUtility->deleteDatabase(); + if (!result){ + qDebug() <<"Error deleting profiles database. " + <lastError(); + exit(5); + } + qDebug() << "VICaR profiles database deleted."; + } + else if (instruction == "TPACCOUNTSTATUS"){ + QString status = tpUtility->getAccountStatus(); + qDebug() << "Account Status is "<< status; + } + 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]); + } + } + else{ + + qDebug() << "Sending Introspect method call"; + + DbusUtility dbusUtility(&app); + QList argsToSend; + + + 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); + tpUtility = 0; + databaseUtility = 0; + accountUtility = 0; +}