[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/workspace/powerdevil
From:       Dario Freddi <drf () kde ! org>
Date:       2010-11-10 16:07:16
Message-ID: 20101110160716.B78C6AC89E () svn ! kde ! org
[Download RAW message or body]

SVN commit 1195232 by dafre:

BUG: 218546

Notify when a battery's capacity is below 50% or the battery has been recalled from \
the HW vendor.

 M  +38 -0     daemon/powerdevilcore.cpp  
 M  +1 -0      daemon/powerdevilcore.h  
 M  +7 -0      powerdevil.notifyrc  


--- trunk/KDE/kdebase/workspace/powerdevil/daemon/powerdevilcore.cpp #1195231:1195232
@@ -164,6 +164,9 @@
     m_criticalBatteryTimer->setInterval(30000);
     connect(m_criticalBatteryTimer, SIGNAL(timeout()), this, \
SLOT(onCriticalBatteryTimerExpired()));  
+    // In 30 seconds (so we are sure the user sees eventual notifications), check \
the battery state +    QTimer::singleShot(30000, this, SLOT(checkBatteryStatus()));
+
     // All systems up Houston, let's go!
     refreshStatus();
 
@@ -198,6 +201,41 @@
     connect(globalAction, SIGNAL(triggered(bool)), SLOT(suspendToDisk()));
 }
 
+void Core::checkBatteryStatus()
+{
+    // Any batteries below 50% of capacity?
+    for (QHash< QString, uint >::const_iterator i = \
m_backend->capacities().constBegin(); +         i != \
m_backend->capacities().constEnd(); ++i) { +        if (i.value() < 50) {
+            // Notify, we have a broken battery.
+            emitNotification("brokenbattery", i18np("Your battery capacity is %2%. \
This means your battery is broken " +                                                 \
"and needs a replacement. Please contact your hardware vendor for more details.", +
+                                                    "One of your batteries (ID %3) \
has a capacity of %2%. This means it is broken " +                                    \
"and needs a replacement. Please contact your hardware vendor for more details.", +   \
m_loadedBatteriesUdi.size(), i.value(), i.key()), +                             \
"dialog-warning"); +        }
+    }
+
+    // Any recalled batteries?
+    foreach (const BackendInterface::RecallNotice &notice, \
m_backend->recallNotices()) { +        // Notify, a battery has been recalled
+        emitNotification("brokenbattery", i18np("Your battery might have been \
recalled by %2. Usually, when vendors recall the " +                                  \
"hardware, it is because of factory defects which are usually eligible for a " +      \
"free repair or substitution. Please check <a href=\"%3\">%2's website</a> to" +      \
"verify if your battery is faulted.", +
+                                                "One of your batteries (ID %4) might \
have been recalled by %2. " +                                                \
"Usually, when vendors recall the hardware, it is because of factory defects " +      \
"which are usually eligible for a free repair or substitution. " +                    \
"Please check <a href=\"%3\">%2's website</a> to" +                                   \
"verify if your battery is faulted.", +                                               \
m_loadedBatteriesUdi.size(), notice.vendor, notice.url, notice.batteryId), +          \
"dialog-warning"); +    }
+}
+
 void Core::refreshStatus()
 {
     /* The configuration could have changed if this function was called, so
--- trunk/KDE/kdebase/workspace/powerdevil/daemon/powerdevilcore.h #1195231:1195232
@@ -126,6 +126,7 @@
     void onDeviceAdded(const QString &udi);
     void onDeviceRemoved(const QString &udi);
     void onCriticalBatteryTimerExpired();
+    void checkBatteryStatus();
 };
 
 }
--- trunk/KDE/kdebase/workspace/powerdevil/powerdevil.notifyrc #1195231:1195232
@@ -1816,3 +1816,10 @@
 Contexts=criticalnot
 Sound=KDE-Sys-App-Error-Critical.ogg
 Action=Sound|Popup
+
+[Event/brokenbattery]
+Name=Broken battery notification
+Comment=This notifications will pop up if KDE Power Management System detects some \
troubles with one of your batteries +Contexts=criticalnot
+Sound=KDE-Sys-App-Error-Critical.ogg
+Action=Sound|Popup


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic