/soc/2012/sanket/statscollector-2.x.y: 900862dcedf8: Add last se...

sanket sanket at soc.pidgin.im
Tue Aug 14 13:18:47 EDT 2012


Changeset: 900862dcedf8007137b3929f1215052de9891b70
Author:	 sanket <sanket at soc.pidgin.im>
Date:	 2012-08-14 10:18 +0530
Branch:	 soc.2012.statscollector
URL: http://hg.pidgin.im/soc/2012/sanket/statscollector-2.x.y/rev/900862dcedf8

Description:

Add last sent time in Plugin Preference UI

The time is currently displayed with local timezone being detected
by C. This can be a problem if C (gcc?) cannot determine the TZ
in which case it'll fallback to some default timezone.

Though I am not too much worried about the fallback, the lure of
having localtime information is exciting :-)

diffstat:

 libpurple/plugins/statscollector.c |  21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diffs (49 lines):

diff --git a/libpurple/plugins/statscollector.c b/libpurple/plugins/statscollector.c
--- a/libpurple/plugins/statscollector.c
+++ b/libpurple/plugins/statscollector.c
@@ -76,6 +76,15 @@ static gboolean send_stats();
 static gboolean plugin_load(PurplePlugin *);
 static gboolean plugin_unload(PurplePlugin *plugin);
 
+static char *
+epoch_to_str(time_t epoch){
+  struct tm  ts;
+  char  *buf= g_new0(char, 80);
+  ts = *localtime(&epoch); // Best effort estimation.
+  strftime(buf, 80, "%a %Y-%m-%d %H:%M:%S %Z", &ts);
+  return buf;
+}
+
 static void
 confirm_allow(){
 
@@ -1187,11 +1196,13 @@ static PurplePluginPrefFrame *
 get_plugin_pref_frame(PurplePlugin *plugin)
 {
 	PurplePluginPrefFrame *frame;
-	PurplePluginPref *pref;
+	PurplePluginPref *pref, *ts;
+    char *ts_str;
 
 	frame = purple_plugin_pref_frame_new();
 
 
+    /* Allow sending of stats */
 	pref = purple_plugin_pref_new_with_name_and_label(PREF_ALLOW, \
 					_("Allow anonymous collection and sending of stats"));
 	purple_plugin_pref_set_type(pref, PURPLE_PLUGIN_PREF_CHOICE);
@@ -1200,6 +1211,14 @@ get_plugin_pref_frame(PurplePlugin *plug
 	purple_plugin_pref_add_choice(pref, _("Later"), GINT_TO_POINTER(ASK));
 	purple_plugin_pref_frame_add(frame, pref);
 
+    /* Last updated time of sending stats */
+    ts_str = g_strdup_printf("Last time of stats update: %s",\
+      epoch_to_str(purple_prefs_get_int\
+        ("/plugins/core/statscollector/last-sent")));
+    ts = purple_plugin_pref_new_with_label(ts_str);
+    purple_plugin_pref_set_type(ts, PURPLE_PLUGIN_PREF_INFO);
+    purple_plugin_pref_frame_add(frame, ts);
+
 	return frame;
 }
 



More information about the Commits mailing list