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 int main(int argc, char *argv[])
24 DialerApplication app(argc, argv);
26 QMLMainWindow *qmw = QMLMainWindow::instance();
32 QString stripLineID(QString lineid)
35 static QRegExp rx = QRegExp("([^0-9*#])");
37 if (lineid.indexOf('+') == 0) {
38 lineid.replace(rx, "");
39 return lineid.insert(0,"+");
42 return lineid.replace(rx, "");
45 bool currentPageIs(int pagenum)
47 DialerApplication *app = DialerApplication::instance();
51 // Returns a valid QDateTime if parsable as such, otherwise the result
53 QDateTime qDateTimeFromOfono(const QString &val)
61 // NOTE: Ofono formats time to string with the following format spec:
62 // %Y-%m-%dT%H:%M:%S%z (for example: "2001-10-19T10:32:30-05:00")
64 // Start by trying to parse this as an ISODate "YYYY-MM-DDTHH:MM:SSTZD"
65 result = QDateTime::fromString(val,Qt::ISODate);
67 qDebug() << QString("Converted %1 with Qt::ISODate: %2")
69 .arg(result.toString());
72 if (!result.isValid()) {
73 // ISODate conversion has failed, fallback to manual method
74 // NOTE: QDateTime::fromString(val, Qt::ISODate) Fails since the date
75 // format from Ofono is in RFC 822 form, but QDateTime can't parse it
77 QByteArray bytes = val.toAscii();
78 const char *str = bytes.constData();
79 if (strptime(str, "%Y-%m-%dT%H:%M:%S%z", &time_tm) != NULL) {
80 time_t t = mktime(&time_tm);
81 if (t >= (time_t)(0)) {
84 qDebug() << QString("Converted %1 with strptime: %2")
86 .arg(result.toString());
91 if (!result.isValid())
92 qCritical() << QString("Format error, unknown date/time: %1")