2 * hfdialer - Hands Free Voice Call Manager
3 * Copyright (c) 2012, Intel Corporation.
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
11 #include "dialercontext.h"
12 #include "dialerapplication.h"
13 #include "qmlmainwindow.h"
17 #include <QApplication>
18 #include <QDeclarativeView>
21 #define CONFIG_KEY_TARGET_UX "/apps/dialer/ux"
23 #if !defined(CONFIG_DEFAULT_TARGET_UX)
24 # define CONFIG_DEFAULT_TARGET_UX "tizen-ux-components"
27 int main(int argc, char *argv[])
30 DialerApplication app(argc, argv);
32 QMLMainWindow *qmw = QMLMainWindow::instance();
38 QString stripLineID(QString lineid)
41 static QRegExp rx = QRegExp("([^0-9*#])");
43 if (lineid.indexOf('+') == 0) {
44 lineid.replace(rx, "");
45 return lineid.insert(0,"+");
48 return lineid.replace(rx, "");
51 bool currentPageIs(int pagenum)
53 DialerApplication *app = DialerApplication::instance();
57 // Returns a valid QDateTime if parsable as such, otherwise the result
59 QDateTime qDateTimeFromOfono(const QString &val)
67 // NOTE: Ofono formats time to string with the following format spec:
68 // %Y-%m-%dT%H:%M:%S%z (for example: "2001-10-19T10:32:30-05:00")
70 // Start by trying to parse this as an ISODate "YYYY-MM-DDTHH:MM:SSTZD"
71 result = QDateTime::fromString(val,Qt::ISODate);
73 qDebug() << QString("Converted %1 with Qt::ISODate: %2")
75 .arg(result.toString());
78 if (!result.isValid()) {
79 // ISODate conversion has failed, fallback to manual method
80 // NOTE: QDateTime::fromString(val, Qt::ISODate) Fails since the date
81 // format from Ofono is in RFC 822 form, but QDateTime can't parse it
83 QByteArray bytes = val.toAscii();
84 const char *str = bytes.constData();
85 if (strptime(str, "%Y-%m-%dT%H:%M:%S%z", &time_tm) != NULL) {
86 time_t t = mktime(&time_tm);
87 if (t >= (time_t)(0)) {
90 qDebug() << QString("Converted %1 with strptime: %2")
92 .arg(result.toString());
97 if (!result.isValid())
98 qCritical() << QString("Format error, unknown date/time: %1")