started to do info in billboard
[livewp] / applet / src / livewp-actor.c
index ce92008..be02fe1 100644 (file)
@@ -114,6 +114,80 @@ set_actor_position(Actor *actor, gint x, gint y, gint z, AWallpaperPlugin *deskt
                                              z);
 }
 
+int
+func_callback(void *user_data, int argc, char **argv, char **azColName)
+{
+    fprintf(stderr, "callback\n");
+    int i;
+    GtkTreeIter iter;
+    GtkListStore *list = GTK_LIST_STORE(user_data);
+    gtk_list_store_append(list, &iter);
+    for(i = 0; i < argc; i++){
+        fprintf(stderr, "argc=%d, argv=%s, colname=%s\n", argc, argv, azColName[i]);
+        //if(!strcmp(azColName[i], "count"))
+            gtk_list_store_set(list, &iter, 0, atoi(argv[i]), -1);
+    }
+    return 0;
+}
+void 
+change_billboard(Actor * actor, AWallpaperPlugin *desktop_plugin)
+{
+    GtkWidget *label;
+    sqlite3 *db = NULL;
+    sqlite3_stmt *res = NULL;
+    gchar *errMsg = NULL;
+    gchar sql[1024], str[2048];
+    gint call_count=0, sms_count=0, rc=0;
+    GtkListStore *list = NULL;
+    
+    rc = sqlite3_open("/home/user/.rtcom-eventlogger/el.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 Events where event_type_id=%d", 3);
+#if 0
+        gtk_list_store_new(1, G_TYPE_INT);
+        rc = sqlite3_exec(db, sql, func_callback, (void*)list, &errMsg);
+        if (rc != SQLITE_OK){
+            fprintf(stderr, "error %s\n", errMsg);
+
+        }
+        fprintf(stderr, "after exec sql=%s rc= %d err=%d \n", sql, rc, errMsg);
+#endif
+//#if 0
+        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");
+        }
+        call_count = sqlite3_column_int(res, 0);
+        fprintf(stderr, "count missing calls = %d\n", call_count);
+        sqlite3_finalize(res);
+
+        snprintf(sql, sizeof(sql)-1, "select count(id) from Events where event_type_id=%d and is_read=%d", 7, 0);
+        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");
+        }
+        sms_count = sqlite3_column_int(res, 0);
+        fprintf(stderr, "count sms = %d\n", sms_count);
+        sqlite3_finalize(res);
+
+//#endif
+        sqlite3_close(db);
+    }
+    label = actor->image;
+    snprintf(str, sizeof(str)-1, "Missed calls: %d\nUnread sms: %d", call_count, sms_count);
+    gtk_label_set_text(label, str);
+    actor->time_start_animation = time(NULL) + 20;    
+}
+
+
 void 
 change_moon(Actor * actor, AWallpaperPlugin *desktop_plugin)
 {