soc.2007.remotelogging: 0f8d0d37: changed function signature to bring the ...

hajo at h-yo.de hajo at h-yo.de
Thu Nov 13 03:10:32 EST 2008


-----------------------------------------------------------------
Revision: 0f8d0d37caa500d2a7f3d816d24b73af9911908f
Ancestor: 68dd26bad5e2c1937743ecdb1c493135cd96ad52
Author: hajo at h-yo.de
Date: 2007-12-04T09:23:36
Branch: im.pidgin.soc.2007.remotelogging
URL: http://d.pidgin.im/viewmtn/revision/info/0f8d0d37caa500d2a7f3d816d24b73af9911908f

Modified files:
        libpurple/plugins/database_logger.c

ChangeLog: 

changed function signature to bring the sets operation up to date with logging system


-------------- next part --------------
============================================================
--- libpurple/plugins/database_logger.c	015889ac077051ed00826c98f7d6c0145f143ddb
+++ libpurple/plugins/database_logger.c	a92bf935e6c914e09d9592345ab63f214748bd52
@@ -112,10 +112,10 @@ typedef struct {
 
 typedef struct {
 	DatabaseOperationType type;
+	PurpleLogSetCallback set_cb;
 	GHashTable *sets;
 	PurpleLogLoggerHashTableCallback cb;
 	void *data;
-	GHashTable *ret_value;
 } DatabaseSetsOperation;
 
 typedef struct {
@@ -282,18 +282,15 @@ static void database_logger_total_size(P
 	}
 }
 
-static void database_logger_sets(GHashTable *sets, PurpleLogLoggerHashTableCallback cb, void *data)
+static void database_logger_sets(PurpleLogSetCallback set_cb, GHashTable *sets, PurpleLogLoggerHashTableCallback cb, void *data)
 {
-	if (sets != NULL)
-		purple_debug_info("Database Logger", "ERROR wrong arguments: sets = %x\n", sets);
-
 	if (db_thread_func[PURPLE_DATABASE_LOGGER_SETS] != NULL) {
 		DatabaseSetsOperation *op = g_new(DatabaseSetsOperation, 1);
 		op->type = PURPLE_DATABASE_LOGGER_SETS;
+		op->set_cb = set_cb;
 		op->sets = sets;
 		op->cb = cb;
 		op->data = data;
-		op->ret_value = sets;
 
 		db_add_operation(op);
 	} else {
@@ -1037,19 +1034,28 @@ static gpointer db_sets(gpointer data)
 
 	purple_debug_info("Database Logger", "---- XXX ---- db_sets\n");
 
-	dres = dbi_conn_queryf(db_logger->db_conn, "SELECT `name`, `type`, `accountId` FROM `conversations`");
+	dres = dbi_conn_queryf(db_logger->db_conn, "SELECT `buddyId`, `accountId` FROM `conversations`");
 	if (dres) {
 		while(dbi_result_next_row(dres)) {
-			const char *buddy_name;
-			int type;
+			int buddy_id = -1;
 			int account_id = -1;
 			PurpleAccount *account = NULL;
 			PurpleLogSet *set;
 
-			buddy_name = dbi_result_get_string(dres, "name");
-			type = db_result_get_int(dres, "type");
+			buddy_id = db_result_get_int(dres, "buddyId");
 			account_id = db_result_get_int(dres, "accountId");
 
+			char* buddy_name = "";
+			int type = 0;
+			dbi_result dres2;
+			dres2 = dbi_conn_queryf(db_logger->db_conn, "SELECT `name`, `type` FROM `buddies` WHERE `id` = %i", buddy_id);
+			if(dres2) {
+				dbi_result_next_row(dres2);
+				buddy_name = dbi_result_get_string(dres2, "name");
+				type = db_result_get_int(dres2, "type");
+			} else purple_debug_info("Database Logger", "dres2 = null\n");
+			db_process_result(dres2);
+
 			account = db_get_account(account_id);
 			if (account != NULL) {
 				set = g_slice_new(PurpleLogSet);
@@ -1072,7 +1078,7 @@ static gpointer db_sets(gpointer data)
 				set->account = account;
 				set->buddy = (purple_find_buddy(account, buddy_name) != NULL);
 				set->normalized_name = g_strdup(purple_normalize(account, buddy_name));
-				log_add_log_set_to_hash(op->ret_value, set);
+				op->set_cb(op->sets, set);
 			}
 		}
 	}
@@ -1199,9 +1205,8 @@ static gboolean db_main_callback(gpointe
 		for(; op_queue != NULL; op_queue = g_list_delete_link(op_queue, op_queue)) {
 			DatabaseOperation *op = op_queue->data;
 
-			if (db_notify_func[op->type] != NULL) {
-				if (op == NULL)
-					purple_debug_info("Database Logger", "ERROR: db_main_callback op == NULL\n");
+			if (op == NULL) purple_debug_info("Database Logger", "ERROR: db_main_callback op == NULL\n");
+			else if (db_notify_func[op->type] != NULL) {
 				db_notify_func[op->type](op);
 			}
 			g_free(op);


More information about the Commits mailing list