Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar/0068-Partial-fix-for-GSM-connection-time-see-SL-2992.patch
blob: 41d7eb95121b75f53065a8a19849fd03ff5fab3f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
From 6855cd85421cb8879dd75df324dc940339b9f0ee Mon Sep 17 00:00:00 2001
From: Sascha Silbe <silbe@activitycentral.com>
Date: Mon, 9 Jan 2012 19:45:38 +0100
Subject: [PATCH sugar 68/74] (Partial) fix for GSM connection time (see
 SL#2992)

The connection time has apparently been off by a couple of hours (depending
on the time zone; see SL#2992 [1]) ever since we had this feature
(commit f5daf6e).

This patch addresses the most important use case (controlling the GSM
connection using the Sugar UI) by fixing the time format. If a system
connection is used and brought up before Sugar starts, connection time
calculation will still be off; this seems to be unfixable [1].

[1] http://mail.gnome.org/archives/networkmanager-list/2012-January/thread.html#00022

Signed-off-by: Sascha Silbe <silbe@activitycentral.com>
---
 extensions/deviceicon/network.py |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/extensions/deviceicon/network.py b/extensions/deviceicon/network.py
index 234b06b..c70db70 100644
--- a/extensions/deviceicon/network.py
+++ b/extensions/deviceicon/network.py
@@ -364,11 +364,10 @@ def add_alert(self, error, suggestion):
         self.error_description_label.set_text(message)
         self.error_description_label.show()
 
-    def update_connection_time(self, connection_time=None):
-        if connection_time is not None:
-            formatted_time = connection_time.strftime('%H:%M:%S')
-        else:
-            formatted_time = '00:00:00'
+    def update_connection_time(self, connection_time=0):
+        """Set the time we have been connected for, in seconds"""
+        formatted_time = time.strftime('%H:%M:%S',
+                                       time.gmtime(connection_time))
         text = _('Connected for %s') % (formatted_time, )
         self.props.secondary_text = glib.markup_escape_text(text)
 
@@ -888,8 +887,8 @@ def _update_state(self, state, old_state, reason):
             connection = network.find_gsm_connection()
             if connection is not None:
                 connection.set_connected()
-                self._connection_timestamp = time.time() - \
-                        connection.get_settings().connection.timestamp
+                settings = connection.get_settings()
+                self._connection_timestamp = settings.connection.timestamp
                 self._connection_time_handler = gobject.timeout_add_seconds( \
                         1, self.__connection_timecount_cb)
                 self._palette.update_connection_time()
@@ -932,9 +931,7 @@ def __ppp_stats_changed_cb(self, in_bytes, out_bytes):
         self._palette.update_stats(in_bytes, out_bytes)
 
     def __connection_timecount_cb(self):
-        self._connection_timestamp = self._connection_timestamp + 1
-        connection_time = \
-            datetime.datetime.fromtimestamp(self._connection_timestamp)
+        connection_time = time.time() - self._connection_timestamp
         self._palette.update_connection_time(connection_time)
         return True
 
-- 
1.7.6