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>
14 #include "dbusutility.h"
15 #include <QDBusMetaType>
16 #include <QDBusConnection>
17 #include <QCryptographicHash> //DEBUG
20 #include <QDBusInterface>
21 #include <QDBusObjectPath>
22 #include <QDBusArgument>
24 #define AM_SERVICE "org.freedesktop.Telepathy.AccountManager"
25 #define AM_OBJ_PATH "/org/freedesktop/Telepathy/AccountManager"
26 #define AM_INTERFACE "org.freedesktop.Telepathy.AccountManager"
27 #define RING_CONN_SERVICE "org.freedesktop.Telepathy.Connection.ring.tel.ring"
28 #define RING_CONN_PATH "/org/freedesktop/Telepathy/Connection/ring/tel/ring"
29 #define DBUS_SERVICE "org.freedesktop.DBus.Properties"
30 #define DBUS_OBJ_PATH "/org/freedesktop/DBus/Properties"
31 #define DBUS_PROPS_IFACE "org.freedesktop.DBus.Properties"
33 int main(int argc, char *argv[])
36 QCoreApplication app(argc,argv);
38 qDBusRegisterMetaType<org::freedesktop::Telepathy::SimplePresence>();
39 //From Connection Interface Requests
40 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetails>();
41 qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetailsList>();
42 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
43 qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
44 //From Vicar Profile Types
45 //qDBusRegisterMetaType<org::maemo::vicar::Profile>();
46 //qDBusRegisterMetaType<org::maemo::vicar::ProfileList>();
48 TelepathyUtility *tpUtility = new TelepathyUtility();
49 DatabaseUtility *databaseUtility = new DatabaseUtility();
50 HarmattanAccountUtility *accountUtility = new HarmattanAccountUtility();
52 if (argc > 1 && argv[1]){
53 QString instruction = QString(argv[1]);
54 if (instruction == "INSTALL"){
55 //Check if Account already exists
56 if (!tpUtility->accountExists()){
57 qDebug() << "VICaR account not found. Creating ..";
58 bool result = tpUtility->createAccount();
62 qDebug() << "VICaR account found.";
65 else if (instruction == "REMOVE"){
66 bool result = tpUtility->deleteAccount();
69 else if (instruction == "TESTING"){
70 tpUtility->callNumberWithRing(argv[2]);
72 else if (instruction == "TPACCOUNTSTATUS"){
73 QString status = tpUtility->getAccountStatus();
74 qDebug() << "Account Status is "<< status;
76 #if defined(Q_WS_MAEMO_5)
77 else if (instruction == "CREATEDB"){
78 bool result = databaseUtility->openDatabase();
80 qDebug() <<"Error creating vicar database. "
81 <<databaseUtility->lastError();
85 qDebug() << "VICaR database opened.";
86 qDebug() << "Preparing VICaR tables..";
87 result = databaseUtility->prepareTables();
89 qDebug() <<"Error creating tables. "
90 <<databaseUtility->lastError();
94 databaseUtility->closeDatabase();
96 else if (instruction == "DROPDB"){
97 bool result = databaseUtility->deleteDatabase();
99 qDebug() <<"Error deleting vicar database. "
100 <<databaseUtility->lastError();
103 qDebug() << "VICaR database deleted.";
105 #elif defined(Q_WS_MAEMO_6)
106 else if (instruction == "--create-account"){
107 qDebug() << "Creating account";
108 accountUtility->addAccount();
110 else if (instruction == "--delete-account"){
111 qDebug() << "Deleting account";
112 accountUtility->removeAccount();
116 qDebug() << "This command is not recognized";
121 qDebug() << QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex();
125 delete (databaseUtility);
126 delete (accountUtility);