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;
49 DatabaseUtility databaseUtility;
51 if (argc > 1 && argv[1]){
52 QString instruction = QString(argv[1]);
53 if (instruction == "INSTALL"){
54 //Check if Account already exists
55 if (!tpUtility.accountExists()){
56 qDebug() << "VICaR account not found. Creating ..";
57 bool result = tpUtility.createAccount();
61 qDebug() << "VICaR account found.";
64 else if (instruction == "REMOVE"){
65 bool result = tpUtility.deleteAccount();
68 else if (instruction == "TESTING"){
69 tpUtility.callNumberWithRing(argv[2]);
71 else if (instruction == "TPACCOUNTSTATUS"){
72 QString status = tpUtility.getAccountStatus();
73 qDebug() << "Account Status is "<< status;
75 #if defined(Q_WS_MAEMO_5)
76 else if (instruction == "CREATEDB"){
77 bool result = databaseUtility.openDatabase();
79 qDebug() <<"Error creating vicar database. "
80 <<databaseUtility.lastError();
84 qDebug() << "VICaR database opened.";
85 qDebug() << "Preparing VICaR tables..";
86 result = databaseUtility.prepareTables();
88 qDebug() <<"Error creating tables. "
89 <<databaseUtility.lastError();
93 databaseUtility.closeDatabase();
95 else if (instruction == "DROPDB"){
96 bool result = databaseUtility.deleteDatabase();
98 qDebug() <<"Error deleting vicar database. "
99 <<databaseUtility.lastError();
102 qDebug() << "VICaR database deleted.";
104 #elif defined(Q_WS_MAEMO_6)
105 else if (instruction == "--create-account"){
106 qDebug() << "Creating account";
107 HarmattanAccountUtility accountUtility;
108 accountUtility.addAccount();
110 else if (instruction == "--delete-account"){
111 qDebug() << "Deleting account";
112 HarmattanAccountUtility accountUtility;
113 accountUtility.removeAccount();
117 qDebug() << "This command is not recognized";
122 qDebug() << QCryptographicHash::hash("VICaR",QCryptographicHash::Md5).toHex();