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"
14 #include <QCoreApplication>
15 #include "dbusutility.h"
16 #include <QDBusMetaType>
17 #include <QDBusConnection>
18 #include <QCryptographicHash> //DEBUG
21 #include <QDBusInterface>
22 #include <QDBusObjectPath>
23 #include <QDBusArgument>
25 #define AM_SERVICE "org.freedesktop.Telepathy.AccountManager"
26 #define AM_OBJ_PATH "/org/freedesktop/Telepathy/AccountManager"
27 #define AM_INTERFACE "org.freedesktop.Telepathy.AccountManager"
28 #define RING_CONN_SERVICE "org.freedesktop.Telepathy.Connection.ring.tel.ring"
29 #define RING_CONN_PATH "/org/freedesktop/Telepathy/Connection/ring/tel/ring"
30 #define DBUS_SERVICE "org.freedesktop.DBus.Properties"
31 #define DBUS_OBJ_PATH "/org/freedesktop/DBus/Properties"
32 #define DBUS_PROPS_IFACE "org.freedesktop.DBus.Properties"
34 #include <QCoreApplication> //DEBUG - Delete this
35 #include "dbusutility.h"
36 #include <QDBusMetaType>
37 #include <QDBusConnection>
38 >>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e
40 int main(int argc, char *argv[])
43 QCoreApplication app(argc,argv);
45 qDBusRegisterMetaType<org::freedesktop::Telepathy::SimplePresence>();
46 //From Connection Interface Requests
47 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetails>();
48 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetailsList>();
49 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
50 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
51 //From Vicar Profile Types
52 //qDBusRegisterMetaType<org::maemo::vicar::Profile>();
53 //qDBusRegisterMetaType<org::maemo::vicar::ProfileList>();
55 TelepathyUtility *tpUtility = new TelepathyUtility();
56 DatabaseUtility *databaseUtility = new DatabaseUtility();
57 HarmattanAccountUtility *accountUtility = new HarmattanAccountUtility();
59 if (argc > 1 && argv[1]){
60 QString instruction = QString(argv[1]);
61 if (instruction == "INSTALL"){
62 //Check if Account already exists
63 if (!tpUtility->accountExists()){
64 qDebug() << "VICaR account not found. Creating ..";
65 bool result = tpUtility->createAccount();
69 qDebug() << "VICaR account found.";
72 else if (instruction == "REMOVE"){
73 bool result = tpUtility->deleteAccount();
76 else if (instruction == "TESTING"){
77 tpUtility->callNumberWithRing(argv[2]);
79 else if (instruction == "TPACCOUNTSTATUS"){
80 QString status = tpUtility->getAccountStatus();
81 qDebug() << "Account Status is "<< status;
83 #if defined(Q_WS_MAEMO_5)
84 else if (instruction == "CREATEDB"){
85 bool result = databaseUtility->openDatabase();
87 qDebug() <<"Error creating vicar database. "
88 <<databaseUtility->lastError();
92 qDebug() << "VICaR database opened.";
93 qDebug() << "Preparing VICaR tables..";
94 result = databaseUtility->prepareTables();
96 qDebug() <<"Error creating tables. "
97 <<databaseUtility->lastError();
101 databaseUtility->closeDatabase();
103 else if (instruction == "DROPDB"){
104 bool result = databaseUtility->deleteDatabase();
106 qDebug() <<"Error deleting vicar database. "
107 <<databaseUtility->lastError();
110 qDebug() << "VICaR database deleted.";
112 #elif defined(Q_WS_MAEMO_6)
113 else if (instruction == "--create-account"){
114 qDebug() << "Creating account";
115 accountUtility->addAccount();
118 else if (instruction == "--delete-account"){
119 qDebug() << "Deleting account";
120 accountUtility->removeAccount();
124 qDebug() << "This command is not recognized";
129 else if (instruction == "TPACCOUNTSTATUS"){
130 QString status = tpUtility->getAccountStatus();
131 qDebug() << "Account Status is "<< status;
133 else if (instruction == "--create-account"){
134 #if defined(Q_WS_MAEMO_6)
135 qDebug() << "Creating account";
136 accountUtility->addAccount();
138 qDebug() << "This command is applicable only in harmattan";
141 else if (instruction == "--delete-account"){
142 #if defined(Q_WS_MAEMO_6)
143 qDebug() << "Deleting account";
144 accountUtility->removeAccount();
146 qDebug() << "This command is applicable only in harmattan";
149 else if (instruction == "TESTING"){
150 tpUtility->callNumberWithRing(argv[2]);
155 qDebug() << "Sending Introspect method call";
157 DbusUtility dbusUtility(&app);
158 QList<QVariant> argsToSend;
161 bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.Connection.ring.tel.ring",
162 "/org/freedesktop/Telepathy/Connection/ring/tel/ring",
163 "org.freedesktop.DBus.Introspectable",
164 "Introspect",argsToSend,false);
166 success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.ConnectionManager.ring",
167 "/org/freedesktop/Telepathy/ConnectionManager/ring",
168 "org.freedesktop.DBus.Introspectable",
169 "Introspect",argsToSend,false);
173 bool success = dbusUtility.sendMethodCall("org.freedesktop.Telepathy.AccountManager",
174 "/org/freedesktop/Telepathy/Account/ring/tel/ring",
175 "org.freedesktop.Telepathy.Account",
176 "Reconnect",argsToSend,false);
180 qDebug() << dbusUtility.getErrorMessage();
183 qDebug() << "Method call executed successfully";
187 >>>>>>> 74800375ecf7f41e290cf7cc7fa9ee8b230be68e
189 qDebug() << QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex();
193 delete (databaseUtility);
194 delete (accountUtility);