Minor code optimization and Disabling debug output
authorChristophe Dumez <dchris@gmail.com>
Mon, 28 Jun 2010 17:29:59 +0000 (19:29 +0200)
committerChristophe Dumez <dchris@gmail.com>
Mon, 28 Jun 2010 17:31:11 +0000 (19:31 +0200)
TimedSilencer.pro
TimedSilencer.pro.user
alarmd_backend.h

index 0c37c2d..f1b145e 100644 (file)
@@ -30,6 +30,8 @@ TRANSLATIONS = $$LANG_PATH/timedsilencer_en.ts \
 
 RESOURCES = lang.qrc
 
+DEFINES += QT_NO_DEBUG_OUTPUT
+
 #CONFIG += mobility
 #MOBILITY =
 
index 74689fc..ca09c68 100644 (file)
      <value key="192.168.1.4" type="QDateTime">2010-06-26T16:09:16</value>
      <value key="localhost" type="QDateTime">2010-06-26T16:55:11</value>
     </valuemap>
-    <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">8</value>
+    <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">16</value>
     <valuemap key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployed" type="QVariantMap">
      <value key="192.168.1.4" type="QDateTime">2010-06-27T15:34:11</value>
-     <value key="localhost" type="QDateTime">2010-06-27T15:12:49</value>
+     <value key="localhost" type="QDateTime">2010-06-28T19:25:15</value>
     </valuemap>
    </valuemap>
    <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
index fe77b53..68b7fe9 100644 (file)
@@ -32,7 +32,7 @@
 class AlarmdBackend : public QObject {
   Q_OBJECT
 private:
-  static time_t toTime_t(QTime t) {
+  static time_t toTime_t(const QTime &t) {
     int time_diff = QTime::currentTime().secsTo(t);
     if(time_diff < 0) {
       // Add 24 hours
@@ -46,19 +46,19 @@ public:
   static void deleteEvents() {
     // Get events cookies
     QSettings settings("TimedSilencer", "TimedSilencer");
-    cookie_t silent_cookie = settings.value("silencing_cookie", 0).toLongLong();
+    const cookie_t silent_cookie = settings.value("silencing_cookie", 0).toLongLong();
     if(silent_cookie != 0) {
       qDebug("Deleting silent profile event with cookie %ld", (long) silent_cookie);
       alarmd_event_del(silent_cookie);
     }
-    cookie_t general_cookie = settings.value("unsilencing_cookie", 0).toLongLong();
+    const cookie_t general_cookie = settings.value("unsilencing_cookie", 0).toLongLong();
     if(general_cookie != 0) {
       qDebug("Deleting general profile event with cookie %ld", (long) general_cookie);
       alarmd_event_del(general_cookie);
     }
   }
 
-  static void setProfileEvent(Profile p, QTime event_time) {
+  static void setProfileEvent(Profile p, const QTime &event_time) {
     // Get event cookie
     QSettings settings("TimedSilencer", "TimedSilencer");
     cookie_t cookie;
@@ -80,7 +80,7 @@ public:
   }
 
 protected:
-  static void newProfileEvent(Profile p, QTime event_time) {
+  static void newProfileEvent(Profile p, const QTime &event_time) {
     // Create the default alarm struct.
     alarm_event_t *newEvent = alarm_event_create();
     // Set the APP ID
@@ -116,16 +116,16 @@ protected:
     }
 
     // Finally with everything setup, try to add your event to the alarm queue
-    cookie_t cookie = alarmd_event_add(newEvent);
+    const cookie_t &cookie = alarmd_event_add(newEvent);
     if(cookie != 0) {
       // Save cookie
       QSettings settings("TimedSilencer", "TimedSilencer");
       if(p == SILENT) {
         qDebug("Saving silent profile event cookie: %ld", (long)cookie);
-        settings.setValue("silencing_cookie", static_cast<qlonglong>(cookie));
+        settings.setValue("silencing_cookie", static_cast<const qlonglong>(cookie));
       } else {
         qDebug("Saving silent general event cookie: %ld", (long)cookie);
-        settings.setValue("unsilencing_cookie", static_cast<qlonglong>(cookie));
+        settings.setValue("unsilencing_cookie", static_cast<const qlonglong>(cookie));
       }
       return;
     }