added into billboard info about missed calls, sms, chat, mail from notifications...
[livewp] / applet / src / livewp-actor.c
index cf028bc..25e89f2 100644 (file)
@@ -129,10 +129,67 @@ func_callback(void *user_data, int argc, char **argv, char **azColName)
     }
     return 0;
 }
+int get_notify_count(gchar *notify_type)
+{
+    sqlite3 *db = NULL;
+    sqlite3 *res = NULL;
+    gint rc = 0, result = 0;
+    gchar sql[1024];
+
+    rc = sqlite3_open("/home/user/.config/hildon-desktop/notifications.db", &db);
+    if (rc){
+        fprintf(stderr, "error open db %d %s\n", rc, sqlite3_errmsg(db));
+    }else {
+        snprintf(sql, sizeof(sql)-1, "select count(id) from notifications where icon_name='general_%s'", notify_type);
+        rc = sqlite3_prepare(db, sql, sizeof(sql)-1, &res, NULL);
+        if (rc != SQLITE_OK){
+            fprintf(stderr, "error prepare %d %s\n", rc, sql);
+        }
+        if (sqlite3_step(res) != SQLITE_ROW){
+            fprintf(stderr, "not sqlite_row\n");
+        }
+        result = sqlite3_column_int(res, 0);
+        //fprintf(stderr, "count missing calls = %d\n", call_count);
+        sqlite3_finalize(res);
+
+        sqlite3_close(db);
+    }
+    return result;
+}
+
 void 
 change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {
     GtkWidget *label;
+    gchar *message;
+    PangoFontDescription *pfd = NULL;
+    
+    //fprintf(stderr, "change billboard\n");
+    
+    label = actor->image;
+    message = g_markup_printf_escaped("<span bgcolor=\"%s\" foreground=\"%s\">%s: %d \n%s: %d \n%s: %d \n%s: %d</span>", "#FFFFFF", "#000000", 
+                                      _("Missed calls"),
+                                      get_notify_count("missed"), 
+                                      _("Missed sms"),
+                                      get_notify_count("sms"), 
+                                      _("Missed chat"),
+                                      get_notify_count("chat"), 
+                                      _("Missed mail"),
+                                      get_notify_count("mail"));
+    gtk_label_set_markup(GTK_LABEL(label), message);
+    g_free(message);
+    pfd = pango_font_description_from_string("Sans 14");
+    gtk_widget_modify_font(GTK_WIDGET(label), NULL);
+    gtk_widget_modify_font(GTK_WIDGET(label), pfd);
+    pango_font_description_free(pfd);
+    actor->time_start_animation = time(NULL) + 20;    
+}
+
+
+void 
+change_billboard1(Actor * actor, AWallpaperPlugin *desktop_plugin)
+{
+    GtkWidget *label;
     sqlite3 *db = NULL;
     sqlite3_stmt *res = NULL;
     gchar *errMsg = NULL, *message;