Cleaning up dead code from main.cpp and common.h, and moving global
authorRusty Lynch <rusty.lynch@intel.com>
Wed, 4 Apr 2012 20:46:56 +0000 (13:46 -0700)
committerRusty Lynch <rusty.lynch@intel.com>
Wed, 4 Apr 2012 20:46:56 +0000 (13:46 -0700)
methods that are only used once to the file that needs it and marking
the method as static

src/callproxy.cpp
src/common.h
src/dialerapplication.cpp
src/main.cpp

index 870ce73..6770fbe 100644 (file)
@@ -8,10 +8,58 @@
  *
  */
 
+#include <QDateTime>
 #include "common.h"
 #include "callproxy.h"
 #include "managerproxy.h"
-//#include "resourceproxy.h"
+
+// Returns a valid QDateTime if parsable as such, otherwise the result
+// will be !isValid()
+static QDateTime qDateTimeFromOfono(const QString &val)
+{
+    TRACE
+    QDateTime result;
+
+    if (val.isEmpty())
+        return result;
+
+    // NOTE: Ofono formats time to string with the following format spec:
+    //       %Y-%m-%dT%H:%M:%S%z (for example: "2001-10-19T10:32:30-05:00")
+
+    // Start by trying to parse this as an ISODate "YYYY-MM-DDTHH:MM:SSTZD"
+    result = QDateTime::fromString(val,Qt::ISODate);
+#ifdef VERBOSE
+    qDebug() << QString("Converted %1 with Qt::ISODate: %2")
+                       .arg(val)
+                       .arg(result.toString());
+#endif
+
+    if (!result.isValid()) {
+    // ISODate conversion has failed, fallback to manual method
+    // NOTE: QDateTime::fromString(val, Qt::ISODate) Fails since the date
+    //       format from Ofono is in RFC 822 form, but QDateTime can't parse it
+        struct tm time_tm;
+        QByteArray  bytes = val.toAscii();
+        const char *str = bytes.constData();
+        if (strptime(str, "%Y-%m-%dT%H:%M:%S%z", &time_tm) != NULL) {
+            time_t t = mktime(&time_tm);
+            if (t >= (time_t)(0)) {
+                result.setTime_t(t);
+#ifdef VERBOSE 
+                qDebug() << QString("Converted %1 with strptime: %2")
+                                   .arg(val)
+                                   .arg(result.toString());
+#endif
+            }
+        }
+
+        if (!result.isValid())
+            qCritical() << QString("Format error, unknown date/time: %1")
+                                  .arg(str);
+    }
+
+    return result;
+}
 
 CallProxy::CallProxy(const QString &callPath)
     : org::ofono::VoiceCall(OFONO_SERVICE,
index f6b9f8a..a4a9f45 100644 (file)
 #define TRACE
 #endif
 
-/*
- * Commonly used QRegExp expressions
- */
-#include <QRegExp>
-#define MATCH_ANY(p) QRegExp(p,Qt::CaseInsensitive,QRegExp::FixedString)
-#define MATCH_ALL QRegExp()
-
-/*
- * Commonly used values for MNotifications
- */
-#define DEFAULT_AVATAR_ICON "icon-m-content-avatar-placeholder"
-#define NOTIFICATION_CALL_EVENT "x-nokia.call"
-
-/*
- * Convienence macro for showing TBD message
- */
-#define SHOW_TBD \
-    MainWindow *w = dynamic_cast<MainWindow *>(DialerApplication::instance()->activeApplicationWindow()); \
-    if (w) \
-       w->showTBD();
-
-/*
- * Convience macro for checking available dialer modes
- */
-#define CONFIG_KEY_TARGET_MODE "/apps/dialer/mode"
-#define MODE_HFP_STR "hfp"
-#define MODE_HANDSET_STR "handset"
-#define MODE_HFP_ENABLED DC->modes().contains(MODE_HFP_STR)
-#define MODE_HANDSET_ENABLED DC->modes().contains(MODE_HANDSET_STR)
 QString stripLineID(QString lineid);
 
-bool currentPageIs(int pagenum);
-
-#include <QDateTime>
-QDateTime qDateTimeFromOfono(const QString &val);
-
 #endif // COMMON_H
index dd4fd89..7fead80 100644 (file)
@@ -82,13 +82,9 @@ void DialerApplication::connectAll()
                                           SLOT(onCallsChanged()));
         connect(m_manager->voicemail(), SIGNAL(messagesWaitingChanged()), this,
                                           SLOT(messagesWaitingChanged()));
-        if (!MODE_HANDSET_ENABLED)
-        {
-            PAControl* paControl = PAControl::instance();
-            connect(m_manager->callManager(), SIGNAL(callsChanged()), paControl,
-                                              SLOT(onCallsChanged()));
-     
-        }
+        PAControl* paControl = PAControl::instance();
+        connect(m_manager->callManager(), SIGNAL(callsChanged()), paControl,
+                SLOT(onCallsChanged()));
     }
 }
 
@@ -175,29 +171,6 @@ void DialerApplication::init()
         qCritical() << "Error registering dbus object:" <<
                        QDBusConnection::sessionBus().lastError().message();
     }
-  /*
-    m_seasideModel = new SeasideSyncModel();
-    m_seasideProxy = new SeasideProxyModel();
-    m_seasideProxy->setSourceModel(m_seasideModel);
-    m_seasideProxy->setDynamicSortFilter(true);
-    m_seasideProxy->setFilterKeyColumn(-1);
-    m_seasideProxy->setFilterRegExp(MATCH_ALL);
-    m_seasideProxy->sort(Seaside::ColumnLastName, Qt::AscendingOrder);
-  */
-    //m_historyModel = new HistoryTableModel();
-  //  m_historyProxy = new QSortFilterProxyModel();
-   // m_historyProxy->setSourceModel(m_historyModel);
-   // m_historyProxy->setDynamicSortFilter(true);
-  //  m_historyProxy->setFilterKeyColumn(HistoryTableModel::COLUMN_LINEID);
-  //  m_historyProxy->sort(HistoryTableModel::COLUMN_CALLSTART,
-  //                       Qt::DescendingOrder);
-
-   /*
-    connect(m_manager->modem(), SIGNAL(connected()),
-                                SLOT(modemConnected()));
-    connect(m_manager->modem(), SIGNAL(disconnected()),
-                                SLOT(modemDisconnected()));
-   */
    connect(m_manager, SIGNAL(modemChanged()),
                                 SLOT(modemChanged()));
 
index fc60ac8..a3032d5 100644 (file)
@@ -42,56 +42,3 @@ QString stripLineID(QString lineid)
         return lineid.replace(rx, "");
 }
 
-bool currentPageIs(int pagenum)
-{
-    DialerApplication *app = DialerApplication::instance();
-     return true;
-}
-
-// Returns a valid QDateTime if parsable as such, otherwise the result
-// will be !isValid()
-QDateTime qDateTimeFromOfono(const QString &val)
-{
-    TRACE
-    QDateTime result;
-
-    if (val.isEmpty())
-        return result;
-
-    // NOTE: Ofono formats time to string with the following format spec:
-    //       %Y-%m-%dT%H:%M:%S%z (for example: "2001-10-19T10:32:30-05:00")
-
-    // Start by trying to parse this as an ISODate "YYYY-MM-DDTHH:MM:SSTZD"
-    result = QDateTime::fromString(val,Qt::ISODate);
-#ifdef VERBOSE
-    qDebug() << QString("Converted %1 with Qt::ISODate: %2")
-                       .arg(val)
-                       .arg(result.toString());
-#endif
-
-    if (!result.isValid()) {
-    // ISODate conversion has failed, fallback to manual method
-    // NOTE: QDateTime::fromString(val, Qt::ISODate) Fails since the date
-    //       format from Ofono is in RFC 822 form, but QDateTime can't parse it
-        struct tm time_tm;
-        QByteArray  bytes = val.toAscii();
-        const char *str = bytes.constData();
-        if (strptime(str, "%Y-%m-%dT%H:%M:%S%z", &time_tm) != NULL) {
-            time_t t = mktime(&time_tm);
-            if (t >= (time_t)(0)) {
-                result.setTime_t(t);
-#ifdef VERBOSE 
-                qDebug() << QString("Converted %1 with strptime: %2")
-                                   .arg(val)
-                                   .arg(result.toString());
-#endif
-            }
-        }
-
-        if (!result.isValid())
-            qCritical() << QString("Format error, unknown date/time: %1")
-                                  .arg(str);
-    }
-
-    return result;
-}