3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
7 #include "telepathyutility.h"
8 #include "databaseutility.h"
9 #include "vicarprofiletypes.h"
10 #include "connectioninterfacerequeststypes.h"
11 #include "harmattanaccountutility.h"
13 #include <QCoreApplication> //DEBUG - Delete this
14 #include "dbusutility.h"
15 #include <QDBusMetaType>
16 #include <QDBusConnection>
18 int main(int argc, char *argv[])
21 QCoreApplication app(argc,argv);
23 qDBusRegisterMetaType<org::freedesktop::Telepathy::SimplePresence>();
24 //From Connection Interface Requests
25 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetails>();
26 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetailsList>();
27 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
28 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
29 //From Vicar Profile Types
30 //qDBusRegisterMetaType<org::maemo::vicar::Profile>();
31 //qDBusRegisterMetaType<org::maemo::vicar::ProfileList>();
33 TelepathyUtility *tpUtility = new TelepathyUtility();
34 DatabaseUtility *databaseUtility = new DatabaseUtility();
35 HarmattanAccountUtility *accountUtility = new HarmattanAccountUtility();
37 if (argc > 1 && argv[1]){
38 QString instruction = QString(argv[1]);
39 if (instruction == "INSTALL"){
40 //Check if Account already exists
41 if (!tpUtility->accountExists()){
42 qDebug() << "VICaR account not found. Creating ..";
43 bool result = tpUtility->createAccount();
47 qDebug() << "VICaR account found.";
50 else if (instruction == "REMOVE"){
51 bool result = tpUtility->deleteAccount();
55 else if (instruction == "CREATEDB"){
56 bool result = databaseUtility->openDatabase();
58 qDebug() <<"Error creating profiles database. "
59 <<databaseUtility->lastError();
62 qDebug() << "VICaR profiles database opened.";
64 if (!databaseUtility->tableExists("profiles")){
65 qDebug() << "Creating VICaR profiles table..";
66 result = databaseUtility->createProfilesTable();
68 qDebug() <<"Error creating profiles table. "
69 <<databaseUtility->lastError();
74 qDebug()<<"Profiles table exists";
76 databaseUtility->closeDatabase();
78 else if (instruction == "DROPDB"){
79 bool result = databaseUtility->deleteDatabase();
81 qDebug() <<"Error deleting profiles database. "
82 <<databaseUtility->lastError();
85 qDebug() << "VICaR profiles database deleted.";
87 else if (instruction == "TPACCOUNTSTATUS"){
88 QString status = tpUtility->getAccountStatus();
89 qDebug() << "Account Status is "<< status;
91 else if (instruction == "--create-account"){
92 #if defined(Q_WS_MAEMO_6)
93 qDebug() << "Creating account";
94 accountUtility->addAccount();
96 qDebug() << "This command is applicable only in harmattan";
99 else if (instruction == "--delete-account"){
100 #if defined(Q_WS_MAEMO_6)
101 qDebug() << "Deleting account";
102 accountUtility->removeAccount();
104 qDebug() << "This command is applicable only in harmattan";
107 else if (instruction == "TESTING"){
108 tpUtility->callNumberWithRing(argv[2]);
113 qDebug() << "Sending Introspect method call";
115 DbusUtility dbusUtility(&app);
116 QList<QVariant> argsToSend;
119 bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.Connection.ring.tel.ring",
120 "/org/freedesktop/Telepathy/Connection/ring/tel/ring",
121 "org.freedesktop.DBus.Introspectable",
122 "Introspect",argsToSend,false);
124 success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.ConnectionManager.ring",
125 "/org/freedesktop/Telepathy/ConnectionManager/ring",
126 "org.freedesktop.DBus.Introspectable",
127 "Introspect",argsToSend,false);
131 bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.AccountManager",
132 "/org/freedesktop/Telepathy/Account/ring/tel/ring",
133 "org.freedesktop.Telepathy.Account",
134 "Reconnect",argsToSend,false);
138 qDebug() << dbusUtility.getErrorMessage();
141 qDebug() << "Method call executed successfully";
147 delete (databaseUtility);
148 delete (accountUtility);