Initial Import
[profile/ivi/hfdialer.git] / src / main.cpp
1 /*
2  * hfdialer - Hands Free Voice Call Manager
3  * Copyright (c) 2012, Intel Corporation.
4  *
5  * This program is licensed under the terms and conditions of the
6  * Apache License, version 2.0.  The full text of the Apache License is at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  */
10
11 #include "dialercontext.h"
12 #include "dialerapplication.h"
13 #include "qmlmainwindow.h"
14 #include "common.h"
15
16 #include <QtGui>
17 #include <QApplication>
18 #include <QDeclarativeView>
19 #include <QFile>
20
21 int main(int argc, char *argv[])
22 {
23     TRACE;
24     QDBusConnection bus = QDBusConnection::systemBus();
25     QStringList serviceNames = bus.interface()->registeredServiceNames();
26         
27     if (serviceNames.contains("com.hfdialer"))
28     {
29         QDBusMessage message = QDBusMessage::createMethodCall("com.hfdialer","/com/dialer","com.hfdialer", "raise");
30         bus.call(message,QDBus::NoBlock);
31         
32         return 0;
33     }
34
35     DialerApplication app(argc, argv);  
36
37     QMLMainWindow *qmw = QMLMainWindow::instance();
38     
39     QString argString(argv[1]); 
40
41     if (argString != "noshow")
42        qmw->tryToShow();
43
44     return app.exec();
45 }
46
47 QString stripLineID(QString lineid)
48 {
49     TRACE;
50     static QRegExp rx = QRegExp("([^0-9*#])");
51
52     if (lineid.indexOf('+') == 0) {
53         lineid.replace(rx, "");
54         return lineid.insert(0,"+");
55     } else {
56         return lineid.replace(rx, "");
57     }
58 }
59
60 /* Local Variables:      */
61 /* mode:c++              */
62 /* c-basic-offset:4      */
63 /* indent-tabs-mode: nil */
64 /* End:                  */