SIGSEGV Fixed
[vicar] / src / vicar-telepathy / cpp / main.cpp
1 /*
2 @version: 0.6
3 @author: Sudheer K. <scifi1947 at gmail.com>
4 @license: GNU General Public License
5
6 Based on Telepathy-SNOM with copyright notice below.
7 */
8
9 /*
10  * Telepathy SNOM VoIP phone connection manager
11  * Copyright (C) 2006 by basyskom GmbH
12  *  @author Tobias Hunger <info@basyskom.de>
13  *
14  * This library is free software; you can redisQObject::tribute it and/or
15  * modify it under the terms of the GNU Lesser General Public
16  * License version 2.1 as published by the Free Software Foundation.
17  *
18  * This library is disQObject::tributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Lesser General Public License for more details.
22  *
23  * You should have received a copy of the GNU Lesser General Public
24  * License along with this library; if not, write to the
25  * Free Software Foundation, Inc.,
26  * 51 Franklin SQObject::treet, Fifth Floor, Boston, MA  02110-1301  USA
27  */
28
29 #include <QtCore/QCoreApplication>
30 #include <QtCore/QDebug>
31
32 #include <QtDBus/QDBusConnection>
33 #include <QtDBus/QDBusMetaType>
34 #include <QtDBus/QDBusInterface>
35 #include <QDBusError>
36 #include <QDateTime>
37
38 #include "names.h"
39 #include "connectionmanager.h"
40 #include "basetypes.h"
41 #include "connectionmanagertypes.h"
42 #include "connectiontypes.h"
43 #include "connectioninterfacerequeststypes.h"
44 #include "connectioninterfacecapabilitiestypes.h"
45
46
47 using namespace std;
48
49 int main(int argc, char ** argv)
50 {
51
52     QCoreApplication app(argc, argv);
53
54     // register types:
55     qDBusRegisterMetaType<org::freedesktop::Telepathy::ParameterDefinition>();
56     qDBusRegisterMetaType<org::freedesktop::Telepathy::ParameterDefinitionList>();
57     qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelInfo>();
58     qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelInfoList>();
59     qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetails>();
60     qDBusRegisterMetaType<org::freedesktop::Telepathy::ChannelDetailsList>();
61     qDBusRegisterMetaType<org::freedesktop::Telepathy::ContactCapabilities>();
62     qDBusRegisterMetaType<org::freedesktop::Telepathy::ContactCapabilitiesList>();
63     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityPair>();
64     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityPairList>();
65     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityChange>();
66     qDBusRegisterMetaType<org::freedesktop::Telepathy::CapabilityChangeList>();
67     qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClass>();
68     qDBusRegisterMetaType<org::freedesktop::Telepathy::RequestableChannelClassList>();
69
70     QDBusConnection connection = QDBusConnection::sessionBus();
71
72     if (!connection.interface()->isServiceRegistered(cm_service_name))
73     {
74
75         // register CM on D-BUS:
76         bool success = connection.registerService(cm_service_name);
77         if (success){
78             qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Service %1 registered with session bus.").
79                        arg(cm_service_name)));
80         }
81         else{
82
83             QDBusError error = connection.interface()->lastError();
84
85             qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Unable to register service %1 with session bus due to error %2.").
86                        arg(cm_service_name,error.message())));
87         }
88
89     }
90
91     ConnectionManager connection_mgr(&app);
92     if (!connection.registerObject(cm_object_path,&connection_mgr)){
93         qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Unable to register VICaR connection manager at path %1 with session bus.").
94                    arg(cm_object_path)));
95     }
96
97     qDebug(qPrintable(QObject::tr("Vicar-Telepathy: Enternig main loop.")));
98     return app.exec();
99 }