14266
|
1 /*
|
|
2 * Contact Availability Prediction plugin for Gaim
|
|
3 *
|
|
4 * Copyright (C) 2006 Geoffrey Foster.
|
|
5 *
|
|
6 * This program is free software; you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU General Public License as
|
|
8 * published by the Free Software Foundation; either version 2 of the
|
|
9 * License, or (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful, but
|
|
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
14 * General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
19 * 02111-1307, USA.
|
|
20 */
|
|
21
|
|
22 #include "cap.h"
|
|
23
|
|
24 static char * quote_string(const char *str) {
|
|
25 gchar *quoted_str = NULL;
|
|
26 quoted_str = g_strdup(str);
|
|
27 dbi_driver_quote_string(_driver, "ed_str);
|
|
28 return quoted_str;
|
|
29 }
|
|
30
|
|
31 static void generate_minute_stats(CapStatistics *statistics) {
|
|
32 gchar *buddy_name = quote_string(statistics->buddy->name);
|
|
33 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(statistics->buddy->account));
|
|
34 gchar *account_id = quote_string(gaim_account_get_username(statistics->buddy->account));
|
|
35 dbi_result result = dbi_conn_queryf(_conn, "select minute_val, success_count, failed_count from cap_msg_count where buddy=%s account=%s and protocol=%s;", buddy_name, account_id, protocol_id);
|
|
36
|
|
37 while(dbi_result_next_row(result)) {
|
|
38 int minute_val = dbi_result_get_int(result, "minute_val");
|
|
39 int success_count = dbi_result_get_int(result, "success_count");
|
|
40 int failed_count = dbi_result_get_int(result, "failed_count");
|
|
41 double ratio = ((double)success_count/(double)(success_count + failed_count));
|
|
42 statistics->minute_stats[minute_val] = ratio;
|
|
43 }
|
|
44 dbi_result_free(result);
|
|
45 }
|
|
46
|
|
47 static void generate_prediction(CapStatistics *statistics) {
|
|
48 if(statistics->buddy) {
|
|
49 if(statistics->prediction == NULL)
|
|
50 statistics->prediction = g_malloc(sizeof(CapPrediction));
|
|
51 statistics->prediction->probability = generate_prediction_for(statistics->buddy);
|
|
52 statistics->prediction->generated_at = time(NULL);
|
|
53 }
|
|
54 }
|
|
55
|
|
56 static double generate_prediction_for(GaimBuddy *buddy) {
|
|
57 double prediction = 1.0f;
|
|
58 gboolean generated = FALSE;
|
|
59 gchar *buddy_name = quote_string(buddy->name);
|
|
60 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(buddy->account));
|
|
61 gchar *account_id = quote_string(gaim_account_get_username(buddy->account));
|
|
62 gchar *status_id = quote_string(gaim_status_get_id(get_status_for(buddy)));
|
|
63 time_t t = time(NULL);
|
|
64 struct tm *current_time = localtime(&t);
|
|
65 int current_minute = current_time->tm_min + current_time->tm_hour * 60;
|
|
66 int threshold = gaim_prefs_get_int("/plugins/gtk/cap/threshold");
|
|
67 int min_minute = (current_minute - threshold) % 1440;
|
|
68 int max_minute = (current_minute + threshold) % 1440;
|
|
69 dbi_result result;
|
|
70
|
|
71 result = dbi_conn_queryf(_conn, "select success_count, failed_count from cap_msg_count where buddy=%s and account=%s and protocol=%s and minute_val>=%d and minute_val<=%d;", buddy_name, account_id, protocol_id, min_minute, max_minute);
|
|
72 if(result) {
|
|
73 int successes = 0;
|
|
74 int failures = 0;
|
|
75 while(dbi_result_next_row(result)) {
|
|
76 if(!dbi_result_field_is_null(result, "success_count"))
|
|
77 successes += dbi_result_get_int(result, "success_count");
|
|
78
|
|
79 if(!dbi_result_field_is_null(result, "failed_count"))
|
|
80 failures += dbi_result_get_int(result, "failed_count");
|
|
81 }
|
|
82 if(failures + successes > 0) {
|
|
83 prediction *= ((double)successes/((double)(successes + failures)));
|
|
84 generated = TRUE;
|
|
85 }
|
|
86 dbi_result_free(result);
|
|
87 }
|
|
88
|
|
89
|
|
90 /*
|
|
91 * Note to self: apparently when using a function like sum results in not being able to get
|
|
92 * the values for fields using libdbi...why? the way I'm doing it above sucks, find a fix.
|
|
93 result = dbi_conn_queryf(_conn, "select sum(success_count) as successes, sum(failed_count) as failures from cap_msg_count where buddy=%s and account=%s and protocol=%s and minute_val>=%d and minute_val<=%d;", buddy_name, account_id, protocol_id, min_minute, max_minute);
|
|
94 gaim_debug_info("cap", "select sum(success_count) as successes, sum(failed_count) as failures from cap_msg_count where buddy=%s and account=%s and protocol=%s and minute_val>=%d and minute_val<=%d;\n", buddy_name, account_id, protocol_id, min_minute, max_minute);
|
|
95
|
|
96 if(result) {
|
|
97 int failures;
|
|
98 int successes;
|
|
99 int rc = dbi_result_get_numrows(result);
|
|
100 dbi_result_next_row(result);
|
|
101 gaim_debug_info("cap", "Result code: %d\n", rc);
|
|
102 failures = dbi_result_get_int_idx(result, 1);//"failures");
|
|
103 successes = dbi_result_get_int_idx(result, 2); //"successes");
|
|
104 gaim_debug_info("cap", "Successes = %d; Failures = %d\n", successes, failures);
|
|
105 dbi_result_get_fields(result, "successes.%i failures.%i", &successes, &failures);
|
|
106 gaim_debug_info("cap", "Successes = %d; Failures = %d\n", successes, failures);
|
|
107 if(failures + successes > 0.0)
|
|
108 prediction *= ((double)successes/((double)(successes + failures)));
|
|
109 gaim_debug_info("cap", "After message value prediction is %0.4f.\n", prediction);
|
|
110 dbi_result_free(result);
|
|
111 }
|
|
112 */
|
|
113
|
|
114 result = dbi_conn_queryf(_conn, "select success_count, failed_count from cap_status_count where buddy=%s and account=%s and protocol=%s and status=%s;", buddy_name, account_id, protocol_id, status_id);
|
|
115 if(result) {
|
|
116 int successes = 0;
|
|
117 int failures = 0;
|
|
118
|
|
119 dbi_result_next_row(result);
|
|
120
|
|
121 if(!dbi_result_field_is_null(result, "success_count"))
|
|
122 successes = dbi_result_get_int(result, "success_count");
|
|
123
|
|
124 if(!dbi_result_field_is_null(result, "failed_count"))
|
|
125 failures = dbi_result_get_int(result, "failed_count");
|
|
126
|
|
127 if(successes + failures > 0) {
|
|
128 prediction *= ((double)successes/(double)(successes + failures));
|
|
129 generated = TRUE;
|
|
130 }
|
|
131 dbi_result_free(result);
|
|
132 }
|
|
133
|
|
134 free(buddy_name);
|
|
135 free(account_id);
|
|
136 free(protocol_id);
|
|
137 free(status_id);
|
|
138
|
|
139 if(strcmp(gaim_status_get_id(get_status_for(buddy)), "offline") == 0) {
|
|
140 //This is kind of stupid, change it.
|
|
141 if(prediction == 1.0f)
|
|
142 prediction = 0.0f;
|
|
143 }
|
|
144
|
|
145 if(generated)
|
|
146 return prediction;
|
|
147 else
|
|
148 return -1;
|
|
149 }
|
|
150
|
|
151 static CapStatistics * get_stats_for(GaimBuddy *buddy) {
|
|
152 gchar *buddy_name;
|
|
153 gchar *q_buddy_name = quote_string(buddy->name);
|
|
154 CapStatistics *stats;
|
|
155 buddy_name = g_strdup(buddy->name);
|
|
156 stats = g_hash_table_lookup(_buddy_stats, buddy_name);
|
|
157 if(!stats) {
|
|
158 dbi_result result;
|
|
159 stats = g_malloc(sizeof(CapStatistics));
|
|
160 stats->last_message = -1;
|
|
161 stats->last_message_status_id = NULL;
|
|
162 stats->last_status_id = NULL;
|
|
163 stats->prediction = NULL;
|
|
164 g_hash_table_insert(_buddy_stats, buddy_name, stats);
|
|
165 stats->buddy = buddy;
|
|
166 /* Setup the last seen online time from database or -1 if no time available. */
|
|
167 result = dbi_conn_queryf(_conn,
|
|
168 //"select max(event_time) as last_event_time from cap_status where buddy=\'%s\' and status!=\'offline\';",
|
|
169 "select event_time from cap_status where buddy=\'%s\' and status!=\'offline\' order by event_time desc;",
|
|
170 q_buddy_name);
|
|
171 if(result && dbi_result_get_numrows(result) > 0) {
|
|
172 dbi_result_next_row(result);
|
|
173 stats->last_seen = dbi_result_get_datetime(result, "event_time");
|
|
174 } else {
|
|
175 stats->last_seen = -1;
|
|
176 }
|
|
177 dbi_result_free(result);
|
|
178 /* Setup the last messaged time to be a 'useable' value for comparisons. */
|
|
179 //result = dbi_conn_queryf(conn, "", );
|
|
180 /* Setup the last status id to nothing */
|
|
181 // --> Better approach would be to get the last status available in db and use it.
|
|
182 result = dbi_conn_queryf(_conn,
|
|
183 "select status, max(event_time) from cap_status where buddy=\'%s\' group by status;",
|
|
184 buddy->name);
|
|
185 if(result && dbi_result_get_numrows(result) > 0) {
|
|
186 dbi_result_next_row(result);
|
|
187 stats->last_status_id = dbi_result_get_string_copy(result, "status");
|
|
188 } else {
|
|
189 stats->last_status_id = "";
|
|
190 }
|
|
191 dbi_result_free(result);
|
|
192 //TODO: populate stats from database
|
|
193 } else {
|
|
194 g_free(buddy_name);
|
|
195 }
|
|
196 free(q_buddy_name);
|
|
197 generate_prediction(stats);
|
|
198 return stats;
|
|
199 }
|
|
200
|
|
201 static void destroy_stats(gpointer data) {
|
|
202 CapStatistics *stats = data;
|
|
203 g_free(stats->prediction);
|
|
204 //g_free(stats->hourly_usage);
|
|
205 //g_free(stats->daily_usage);
|
|
206 g_free(stats);
|
|
207 }
|
|
208
|
|
209 static gboolean remove_stats_for(GaimBuddy *buddy) {
|
|
210 gboolean success = TRUE;
|
|
211 //GString *buddy_name = g_string_new(buddy->name);
|
|
212 gchar *buddy_name = g_strdup(buddy->name);
|
|
213 success = g_hash_table_remove(_buddy_stats, buddy_name);
|
|
214 g_free(buddy_name);
|
|
215 return success;
|
|
216 }
|
|
217
|
|
218 static dbi_result insert_cap_msg_count_success(const char *buddy_name, const char *account, const char *protocol, int minute) {
|
|
219 gaim_debug_info("cap", "Insert cap_msg_count success: %s %s %s %d\n", buddy_name, account, protocol, minute);
|
|
220 return dbi_conn_queryf(_conn, "insert into cap_msg_count (buddy, account, protocol, minute_val, success_count, failed_count) values (%s, %s, %s, %d, %d, %d) on duplicate key update success_count=success_count+1;", buddy_name, account, protocol, minute, 1, 0);
|
|
221 }
|
|
222
|
|
223 static dbi_result insert_cap_status_count_success(const char *buddy_name, const char *account, const char *protocol, const char *status_id) {
|
|
224 gaim_debug_info("cap", "Insert cap_status_count success: %s %s %s %s\n", buddy_name, account, protocol, status_id);
|
|
225 return dbi_conn_queryf(_conn, "insert into cap_status_count (buddy, account, protocol, status, success_count, failed_count) values(%s, %s, %s, %s, %d, %d) on duplicate key update success_count=success_count+1;", buddy_name, account, protocol, status_id, 1, 0);
|
|
226 }
|
|
227
|
|
228 static dbi_result insert_cap_msg_count_failed(const char *buddy_name, const char *account, const char *protocol, int minute) {
|
|
229 gaim_debug_info("cap", "Insert cap_msg_count failed: %s %s %s %d\n", buddy_name, account, protocol, minute);
|
|
230 return dbi_conn_queryf(_conn, "insert into cap_msg_count (buddy, account, protocol, minute_val, success_count, failed_count) values (%s, %s, %s, %d, %d, %d) on duplicate key update failed_count=failed_count+1;", buddy_name, account, protocol, minute, 0, 1);
|
|
231 }
|
|
232
|
|
233 static dbi_result insert_cap_status_count_failed(const char *buddy_name, const char *account, const char *protocol, const char *status_id) {
|
|
234 gaim_debug_info("cap", "Insert cap_status_count failed: %s %s %s %s\n", buddy_name, account, protocol, status_id);
|
|
235 return dbi_conn_queryf(_conn, "insert into cap_status_count (buddy, account, protocol, status, success_count, failed_count) values(%s, %s, %s, %s, %d, %d) on duplicate key update failed_count=failed_count+1;", buddy_name, account, protocol, status_id, 0, 1);
|
|
236 }
|
|
237
|
|
238 static void insert_cap_success(CapStatistics *stats) {
|
|
239 dbi_result result;
|
|
240 gchar *buddy_name = quote_string(stats->buddy->name);
|
|
241 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(stats->buddy->account));
|
|
242 gchar *account_id = quote_string(gaim_account_get_username(stats->buddy->account));
|
|
243 gchar *status_id = (stats->last_message_status_id) ?
|
|
244 quote_string(stats->last_message_status_id) :
|
|
245 quote_string(gaim_status_get_id(get_status_for(stats->buddy)));
|
|
246 struct tm *current_time;
|
|
247 int minute;
|
|
248
|
|
249 if(stats->last_message == -1) {
|
|
250 time_t now = time(NULL);
|
|
251 current_time = localtime(&now);
|
|
252 } else {
|
|
253 current_time = localtime(&stats->last_message);
|
|
254 }
|
|
255 minute = current_time->tm_min + current_time->tm_hour * 60;
|
|
256
|
|
257 result = insert_cap_msg_count_success(buddy_name, account_id, protocol_id, minute);
|
|
258 if(result)
|
|
259 dbi_result_free(result);
|
|
260
|
|
261 result = insert_cap_status_count_success(buddy_name, account_id, protocol_id, status_id);
|
|
262 if(result)
|
|
263 dbi_result_free(result);
|
|
264
|
|
265 stats->last_message = -1;
|
|
266 stats->last_message_status_id = NULL;
|
|
267
|
|
268 free(status_id);
|
|
269 free(protocol_id);
|
|
270 free(account_id);
|
|
271 free(buddy_name);
|
|
272 }
|
|
273
|
|
274 static void insert_cap_failure(CapStatistics *stats) {
|
|
275 dbi_result result;
|
|
276 gchar *buddy_name = quote_string(stats->buddy->name);
|
|
277 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(stats->buddy->account));
|
|
278 gchar *account_id = quote_string(gaim_account_get_username(stats->buddy->account));
|
|
279 gchar *status_id = (stats->last_message_status_id) ?
|
|
280 quote_string(stats->last_message_status_id) :
|
|
281 quote_string(gaim_status_get_id(get_status_for(stats->buddy)));
|
|
282 struct tm *current_time = localtime(&stats->last_message);
|
|
283 int minute = current_time->tm_min + current_time->tm_hour * 60;
|
|
284
|
|
285 result = insert_cap_msg_count_failed(buddy_name, account_id, protocol_id, minute);
|
|
286 if(result)
|
|
287 dbi_result_free(result);
|
|
288
|
|
289 result = insert_cap_status_count_failed(buddy_name, account_id, protocol_id, status_id);
|
|
290 if(result)
|
|
291 dbi_result_free(result);
|
|
292
|
|
293 stats->last_message = -1;
|
|
294 stats->last_message_status_id = NULL;
|
|
295
|
|
296 free(status_id);
|
|
297 free(protocol_id);
|
|
298 free(account_id);
|
|
299 free(buddy_name);
|
|
300 }
|
|
301
|
|
302 static gboolean max_message_difference_cb(gpointer data) {
|
|
303 CapStatistics *stats = data;
|
|
304 gaim_debug_info("cap", "Max Message Difference timeout occured\n");
|
|
305 insert_cap_failure(stats);
|
|
306 stats->timeout_source_id = 0;
|
|
307 return FALSE;
|
|
308 }
|
|
309
|
|
310 /* Gaim Signal Handlers */
|
|
311
|
|
312 //sent-im-msg
|
|
313 static void sent_im_msg(GaimAccount *account, const char *receiver, const char *message) {
|
|
314 GaimBuddy *buddy = gaim_find_buddy(account, receiver);
|
|
315 guint interval = gaim_prefs_get_int("/plugins/gtk/cap/max_msg_difference") * 1000 * 60;
|
|
316 guint words = word_count(message);
|
|
317 CapStatistics *stats = get_stats_for(buddy);
|
|
318
|
|
319 insert_word_count(gaim_account_get_username(account), receiver, words);
|
|
320 stats->last_message = time(NULL);
|
|
321 stats->last_message_status_id = gaim_status_get_id(get_status_for(buddy));
|
|
322 if(stats->timeout_source_id != 0)
|
|
323 g_source_remove(stats->timeout_source_id);
|
|
324
|
|
325 stats->timeout_source_id = g_timeout_add(interval, max_message_difference_cb, stats);
|
|
326 }
|
|
327
|
|
328 //received-im-msg
|
|
329 static void received_im_msg(GaimAccount *account, char *sender, char *message,
|
|
330 GaimConversation *conv, GaimMessageFlags flags) {
|
|
331 GaimBuddy *buddy = gaim_find_buddy(account, sender);
|
|
332 guint words = word_count(message);
|
|
333 CapStatistics *stats = get_stats_for(buddy);
|
|
334
|
|
335 //insert_word_count(sender, buddy_name, words);
|
|
336
|
|
337 //If we are waiting for a response from a prior message
|
|
338 // then cancel the timeout callback.
|
|
339 if(stats->timeout_source_id != 0) {
|
|
340 gaim_debug_info("cap", "Cancelling timeout callback\n");
|
|
341 g_source_remove(stats->timeout_source_id);
|
|
342 stats->timeout_source_id = 0;
|
|
343 }
|
|
344
|
|
345 insert_cap_success(stats);
|
|
346
|
|
347 stats->last_message = -1; //Reset the last_message value
|
|
348 stats->last_message_status_id = NULL; //Reset the last status id value
|
|
349 }
|
|
350
|
|
351 //buddy-status-changed
|
|
352 static void buddy_status_changed(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *status) {
|
|
353 CapStatistics *stats = get_stats_for(buddy);
|
|
354 insert_status_change_from_gaim_status(stats, status);
|
|
355 }
|
|
356
|
|
357 //buddy-signed-on
|
|
358 static void buddy_signed_on(GaimBuddy *buddy) {
|
|
359 CapStatistics *stats = get_stats_for(buddy);
|
|
360
|
|
361 /* If the statistic object existed but doesn't have a buddy pointer associated
|
|
362 * with it then reassociate one with it. The pointer being null is a result
|
|
363 * of a buddy with existing stats signing off and Gaim sticking around.
|
|
364 */
|
|
365 if(!stats->buddy) {
|
|
366 stats->buddy = buddy;
|
|
367 }
|
|
368
|
|
369 insert_status_change(stats);
|
|
370 }
|
|
371
|
|
372 //buddy-signed-off
|
|
373 static void buddy_signed_off(GaimBuddy *buddy) {
|
|
374 CapStatistics *stats = get_stats_for(buddy);
|
|
375
|
|
376 /* We don't necessarily want to delete a buddies generated statistics every time they go offline.
|
|
377 * Instead we just set the buddy pointer to null so that when they come back online we can look
|
|
378 * them up again and continue using their statistics.
|
|
379 */
|
|
380 insert_status_change(stats);
|
|
381 //stats->buddy = NULL;
|
|
382 stats->last_seen = time(NULL);
|
|
383 }
|
|
384
|
|
385 static void buddy_idle(GaimBuddy *buddy, gboolean old_idle, gboolean idle) {
|
|
386 }
|
|
387
|
|
388 static void blist_node_extended_menu(GaimBlistNode *node, GList **menu) {
|
|
389 GaimBuddy *buddy;
|
|
390 GaimMenuAction *menu_action;
|
|
391 gaim_debug_info("cap", "got extended blist menu\n");
|
|
392 gaim_debug_info("cap", "is buddy: %d\n", GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
393 gaim_debug_info("cap", "is contact: %d\n", GAIM_BLIST_NODE_IS_CONTACT(node));
|
|
394 gaim_debug_info("cap", "is group: %d\n", GAIM_BLIST_NODE_IS_GROUP(node));
|
|
395 /* Probably only concerned with buddy/contact types. Contacts = meta-buddies (grouped msn/jabber/etc.) */
|
|
396 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
397 buddy = (GaimBuddy *)node;
|
|
398 menu_action = gaim_menu_action_new(_("Display Statistics"),
|
|
399 GAIM_CALLBACK(display_statistics_action_cb), NULL, NULL);
|
|
400 *menu = g_list_append(*menu, menu_action);
|
|
401 }
|
|
402
|
|
403 //drawing-tooltip
|
|
404 static void drawing_tooltip(GaimBlistNode *node, GString *text, gboolean full) {
|
|
405 if(node->type == GAIM_BLIST_BUDDY_NODE) {
|
|
406 GaimBuddy *buddy = (GaimBuddy *)node;
|
|
407 CapStatistics *stats = get_stats_for(buddy);
|
|
408 // get the probability that this buddy will respond and add to the tooltip
|
|
409 if(stats->prediction->probability >= 0.0) {
|
|
410 g_string_append_printf(text, "\n<b>%s</b> %0.4f", _("Response Probability:"), stats->prediction->probability);
|
|
411 } else {
|
|
412 g_string_append_printf(text, "\n<b>%s</b> ???", _("Response Probability:"));
|
|
413 }
|
|
414 }
|
|
415 }
|
|
416
|
|
417 //signed-on
|
|
418 static void signed_on(GaimConnection *gc) {
|
|
419 GaimAccount *account = gaim_connection_get_account(gc);
|
|
420 const char *my_gaim_name = gaim_account_get_username(account);
|
|
421 gchar *my_name = g_strdup(my_gaim_name);
|
|
422 time_t *last_offline = g_hash_table_lookup(_my_offline_times, my_name);
|
|
423
|
|
424 gchar *account_id = quote_string(gaim_account_get_username(account));
|
|
425 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(account));
|
|
426 dbi_result result;
|
|
427
|
|
428 result = dbi_conn_queryf(_conn, "insert into cap_my_usage values(%s, %s, %d, now());", account_id, protocol_id, 1);
|
14350
|
429 if(result)
|
14266
|
430 dbi_result_free(result);
|
|
431
|
|
432 if(last_offline) {
|
|
433 if(difftime(*last_offline, time(NULL)) > gaim_prefs_get_int("/plugins/gtk/cap/max_seen_difference") * 60) {
|
|
434 //reset all of the last_message times to -1
|
|
435 g_hash_table_foreach(_my_offline_times, reset_all_last_message_times, NULL);
|
|
436 }
|
|
437 g_hash_table_remove(_my_offline_times, my_name);
|
|
438 }
|
|
439 g_free(my_name);
|
|
440 }
|
|
441
|
|
442 //signed-off
|
|
443 static void signed_off(GaimConnection *gc) {
|
|
444 /* Here we record the time you (the user) sign off of an account.
|
|
445 * The account username is the key in the hashtable and the sign off time_t
|
|
446 * (equal to the sign off time) is the value. */
|
|
447 GaimAccount *account = gaim_connection_get_account(gc);
|
|
448 const char *my_gaim_name = gaim_account_get_username(account);
|
|
449 gchar *my_name = g_strdup(my_gaim_name);
|
|
450 time_t *offline_time = g_malloc(sizeof(time_t));
|
|
451 gchar *account_id = quote_string(gaim_account_get_username(account));
|
|
452 gchar *protocol_id = quote_string(gaim_account_get_protocol_id(account));
|
|
453 dbi_result result;
|
|
454
|
|
455 result = dbi_conn_queryf(_conn, "insert into cap_my_usage values(%s, %s, %d, now());", account_id, protocol_id, 0);
|
14350
|
456 if(result)
|
14266
|
457 dbi_result_free(result);
|
|
458
|
|
459 time(offline_time);
|
|
460 g_hash_table_insert(_my_offline_times, my_name, offline_time);
|
|
461 }
|
|
462
|
|
463 static const gchar * get_error_msg() {
|
|
464 if(error_msg)
|
|
465 return error_msg->str;
|
|
466 else
|
|
467 return NULL;
|
|
468 }
|
|
469
|
|
470 static void set_error_msg(const gchar *msg) {
|
|
471 if(!error_msg)
|
|
472 error_msg = g_string_new(msg);
|
|
473 else
|
|
474 g_string_assign(error_msg, msg);
|
|
475 }
|
|
476
|
|
477 static void append_error_msg(const gchar *msg) {
|
|
478 if(!error_msg)
|
|
479 set_error_msg(msg);
|
|
480 else
|
|
481 g_string_append(error_msg, msg);
|
|
482 }
|
|
483
|
|
484 static void reset_all_last_message_times(gpointer key, gpointer value, gpointer user_data) {
|
|
485 CapStatistics *stats = value;
|
|
486 stats->last_message = -1;
|
|
487 }
|
|
488
|
|
489 static GaimStatus * get_status_for(GaimBuddy *buddy) {
|
|
490 GaimPresence *presence = gaim_buddy_get_presence(buddy);
|
|
491 GaimStatus *status = gaim_presence_get_active_status(presence);
|
|
492 return status;
|
|
493 }
|
|
494
|
|
495 static void create_tables() {
|
|
496 }
|
|
497
|
|
498 static gboolean create_database_connection() {
|
|
499 int rc;
|
|
500 int driver_type;
|
14350
|
501
|
|
502 if(_conn)
|
|
503 return TRUE;
|
|
504
|
14266
|
505 //make database connection here
|
|
506 _conn = dbi_conn_new(gaim_prefs_get_string("/plugins/gtk/cap/db_driver"));
|
14350
|
507 if(!_conn)
|
|
508 return FALSE;
|
|
509
|
14266
|
510 _driver = dbi_conn_get_driver(_conn);
|
|
511 gaim_debug_info("cap", "Using driver: %s\n", gaim_prefs_get_string("/plugins/gtk/cap/db_driver"));
|
|
512 if(strcmp(gaim_prefs_get_string("/plugins/gtk/cap/db_driver"), "mysql") == 0) {
|
|
513 driver_type = MYSQL;
|
|
514 dbi_conn_set_option(_conn, "host", gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_host"));
|
|
515 dbi_conn_set_option(_conn, "username", gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_user"));
|
|
516 dbi_conn_set_option(_conn, "password", gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_password"));
|
|
517 dbi_conn_set_option(_conn, "dbname", gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_name"));
|
|
518 dbi_conn_set_option(_conn, "encoding", "auto");
|
|
519 dbi_conn_set_option_numeric(_conn, "port", gaim_prefs_get_int("/plugins/gtk/cap/mysql/db_port"));
|
|
520 }
|
|
521 if(dbi_conn_connect(_conn) < 0) {
|
|
522 const char *err_msg = "";
|
|
523 //rc = dbi_conn_error(_conn, &err_msg);
|
|
524 rc = dbi_conn_error(_conn, NULL);
|
|
525 gaim_debug_error("cap", "CAP could not create database connection. %d\n", rc);
|
|
526 //set_error_msg(_("Could not create database connection. Reason: "));
|
|
527 //append_error_msg(err_msg);
|
14350
|
528 _conn = NULL;
|
14266
|
529 return FALSE;
|
|
530 } else {
|
|
531 //Add tables here
|
|
532 create_tables();
|
|
533 }
|
|
534 gaim_debug_info("cap", "Database connection successfully made.\n");
|
|
535 return TRUE;
|
|
536 }
|
14350
|
537 static void destroy_database_connection() {
|
|
538 if(_conn)
|
|
539 dbi_conn_close(_conn);
|
|
540
|
|
541 _conn = NULL;
|
|
542 }
|
14266
|
543
|
|
544 static guint word_count(const gchar *string) {
|
|
545 //TODO: doesn't really work, should use regex instead (#include <regex.h>)
|
|
546 gchar **result = g_strsplit_set(string, " ", -1);
|
|
547 guint count = g_strv_length(result);
|
|
548
|
|
549 g_strfreev(result);
|
|
550
|
|
551 return count;
|
|
552 }
|
|
553
|
|
554 /* If the difference in time between the present time and the time that
|
|
555 * you last sent a message to a buddy is less than some value then return
|
|
556 * true, otherwise return false.
|
|
557 * The difference can either be + or - the max_difference.
|
|
558 * max_difference is in seconds
|
|
559 */
|
|
560 static gboolean last_message_time_in_range(CapStatistics *statistics, gdouble max_difference) {
|
|
561 time_t now = time(NULL);
|
|
562 gdouble difference = 0.0;
|
|
563 //If there is no last_message time then it is considered in range
|
|
564 if(statistics->last_message == -1) {
|
|
565 return TRUE;
|
|
566 }
|
|
567 //Compute the difference between now and the last_message
|
|
568 difference = difftime(statistics->last_message, now);
|
|
569 //Absolute value
|
|
570 difference = (difference < 0.0) ? -difference : difference;
|
|
571 //If the difference is less than the maximum then we are good and its in range, otherwise not
|
|
572 if(difference <= max_difference)
|
|
573 return TRUE;
|
|
574 else
|
|
575 return FALSE;
|
|
576 }
|
|
577
|
|
578 static gboolean last_seen_time_in_range(CapStatistics *statistics, gdouble max_difference) {
|
|
579 time_t now = time(NULL);
|
|
580 gdouble difference = 0.0;
|
|
581 if(statistics->last_seen == -1)
|
|
582 return FALSE;
|
|
583 difference = difftime(statistics->last_seen, now);
|
|
584 difference = (difference < 0.0) ? -difference : difference;
|
|
585 if(difference < max_difference)
|
|
586 return TRUE;
|
|
587 else
|
|
588 return FALSE;
|
|
589 }
|
|
590
|
|
591 static void insert_status_change(CapStatistics *statistics) {
|
|
592 insert_status_change_from_gaim_status(statistics, get_status_for(statistics->buddy));
|
|
593 }
|
|
594
|
|
595 static void insert_status_change_from_gaim_status(CapStatistics *statistics, GaimStatus *status) {
|
|
596 dbi_result result;
|
14350
|
597 gchar *status_id;
|
|
598 gchar *buddy_name;
|
|
599 gchar *protocol_id;
|
|
600 gchar *account_id;
|
|
601
|
|
602 /* It would seem that some protocols receive periodic updates of the buddies status.
|
|
603 * Check to make sure the last status is not the same as current status to prevent
|
|
604 * to many duplicated useless database entries. */
|
|
605 if(strcmp(statistics->last_status_id, gaim_status_get_id(status)) == 0)
|
|
606 return;
|
|
607
|
|
608 status_id = quote_string(gaim_status_get_id(status));
|
|
609 buddy_name = quote_string(statistics->buddy->name);
|
|
610 protocol_id = quote_string(gaim_account_get_protocol_id(statistics->buddy->account));
|
|
611 account_id = quote_string(gaim_account_get_username(statistics->buddy->account));
|
14266
|
612
|
|
613 statistics->last_status_id = gaim_status_get_id(status);
|
|
614 gaim_debug_info("cap", "Executing: insert into cap_status (buddy, account, protocol, status, event_time) values(%s, %s, %s, %s, now());\n", buddy_name, account_id, protocol_id, status_id);
|
|
615
|
|
616 result = dbi_conn_queryf(_conn, "insert into cap_status (buddy, account, protocol, status, event_time) values(%s, %s, %s, %s, now());", buddy_name, account_id, protocol_id, status_id);
|
|
617 if(result)
|
|
618 dbi_result_free(result);
|
|
619 else {
|
|
620 const char *err = "";
|
|
621 dbi_conn_error(_conn, &err);
|
|
622 gaim_debug_error("cap", "Could not insert status change event into database. %s\n", err);
|
|
623 }
|
|
624
|
|
625 free(status_id);
|
|
626 free(buddy_name);
|
|
627 free(protocol_id);
|
|
628 free(account_id);
|
|
629 }
|
|
630
|
|
631 static void insert_word_count(const char *sender, const char *receiver, guint count) {
|
|
632 //TODO!
|
|
633 //dbi_result result;
|
|
634 //result = dbi_conn_queryf(_conn, "insert into cap_message values(\'%s\', \'%s\', %d, now());", sender, receiver, count);
|
|
635 }
|
|
636
|
|
637 /* Callbacks */
|
|
638 void display_statistics_action_cb(GaimBlistNode *node, gpointer data) {
|
|
639 GaimBuddy *buddy;
|
|
640
|
|
641 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
|
|
642 buddy = (GaimBuddy *)node;
|
|
643 gaim_debug_info("cap", "Statistics for %s requested.\n", buddy->name);
|
|
644 }
|
|
645
|
|
646 /* Gaim plugin specific code */
|
|
647
|
|
648 static gboolean plugin_load(GaimPlugin *plugin) {
|
|
649 _plugin_pointer = plugin;
|
|
650 _signals_connected = FALSE;
|
|
651
|
14350
|
652 /* buddy_stats is a hashtable where strings are keys
|
|
653 * and the keys are a buddies account id (GaimBuddy.name).
|
|
654 * keys/values are automatically deleted */
|
|
655 _buddy_stats = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, destroy_stats);
|
14266
|
656
|
14350
|
657 /* ? - Can't remember at the moment
|
|
658 */
|
|
659 _my_offline_times = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
|
660
|
|
661 if(gaim_prefs_exists("/plugins/gtk/cap/libdbi_drivers"))
|
|
662 _num_drivers = dbi_initialize(gaim_prefs_get_string("/plugins/gtk/cap/libdbi_drivers"));
|
|
663 else
|
|
664 _num_drivers = dbi_initialize(NULL);
|
|
665
|
|
666 if(_num_drivers == -1) {
|
|
667 gaim_debug_error("cap", "Error initializing dbi.\n");
|
|
668 gaim_prefs_set_bool("/plugins/gtk/cap/configured", FALSE);
|
|
669 _dbi_initialized = FALSE;
|
|
670 } else {
|
|
671 _dbi_initialized = TRUE;
|
14266
|
672 }
|
|
673
|
|
674
|
14350
|
675 if(gaim_prefs_get_bool("/plugins/gtk/cap/configured") && gaim_prefs_get_bool("/plugins/gtk/cap/connected")) {
|
|
676 if(create_database_connection()) {
|
|
677 add_plugin_functionality(plugin);
|
14266
|
678 }
|
|
679 }
|
|
680 return TRUE;
|
|
681 }
|
|
682
|
14350
|
683 static void add_plugin_functionality(GaimPlugin *plugin) {
|
14266
|
684 if(_signals_connected)
|
14350
|
685 return;
|
|
686
|
|
687 gaim_debug_info("cap", "Adding plugin functionality.\n");
|
14266
|
688
|
|
689 /* Connect all the signals */
|
|
690 gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", plugin,
|
|
691 GAIM_CALLBACK(sent_im_msg), NULL);
|
|
692
|
|
693 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", plugin,
|
|
694 GAIM_CALLBACK(received_im_msg), NULL);
|
|
695
|
|
696 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", plugin,
|
|
697 GAIM_CALLBACK(buddy_status_changed), NULL);
|
|
698
|
|
699 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", plugin,
|
|
700 GAIM_CALLBACK(buddy_signed_on), NULL);
|
|
701
|
|
702 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", plugin,
|
|
703 GAIM_CALLBACK(buddy_signed_off), NULL);
|
|
704
|
|
705 //gaim_signal_connect(gaim_blist_get_handle(), "blist-node-extended-menu", plugin,
|
|
706 // GAIM_CALLBACK(blist_node_extended_menu), NULL);
|
|
707
|
|
708 gaim_signal_connect(gaim_gtk_blist_get_handle(), "drawing-tooltip", plugin,
|
|
709 GAIM_CALLBACK(drawing_tooltip), NULL);
|
|
710
|
|
711 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", plugin,
|
|
712 GAIM_CALLBACK(signed_on), NULL);
|
|
713
|
|
714 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", plugin,
|
|
715 GAIM_CALLBACK(signed_off), NULL);
|
|
716
|
|
717 gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", plugin,
|
|
718 GAIM_CALLBACK(buddy_idle), NULL);
|
|
719
|
|
720 _signals_connected = TRUE;
|
14350
|
721 }
|
14266
|
722
|
14350
|
723 static void cancel_conversation_timeouts(gpointer key, gpointer value, gpointer user_data) {
|
|
724 CapStatistics *stats = value;
|
|
725 if(stats->timeout_source_id != 0) {
|
|
726 g_source_remove(stats->timeout_source_id);
|
|
727 stats->timeout_source_id = 0;
|
|
728 }
|
|
729 }
|
|
730
|
|
731 static void remove_plugin_functionality(GaimPlugin *plugin) {
|
|
732 if(!_signals_connected)
|
|
733 return;
|
|
734
|
|
735 gaim_debug_info("cap", "Removing plugin functionality.\n");
|
|
736
|
|
737 /* If there are any timeouts waiting to be processed then cancel them */
|
|
738 g_hash_table_foreach(_buddy_stats, cancel_conversation_timeouts, NULL);
|
|
739
|
|
740 /* Connect all the signals */
|
|
741 gaim_signal_disconnect(gaim_conversations_get_handle(), "sent-im-msg", plugin,
|
|
742 GAIM_CALLBACK(sent_im_msg));
|
|
743
|
|
744 gaim_signal_disconnect(gaim_conversations_get_handle(), "received-im-msg", plugin,
|
|
745 GAIM_CALLBACK(received_im_msg));
|
|
746
|
|
747 gaim_signal_disconnect(gaim_blist_get_handle(), "buddy-status-changed", plugin,
|
|
748 GAIM_CALLBACK(buddy_status_changed));
|
|
749
|
|
750 gaim_signal_disconnect(gaim_blist_get_handle(), "buddy-signed-on", plugin,
|
|
751 GAIM_CALLBACK(buddy_signed_on));
|
|
752
|
|
753 gaim_signal_disconnect(gaim_blist_get_handle(), "buddy-signed-off", plugin,
|
|
754 GAIM_CALLBACK(buddy_signed_off));
|
|
755
|
|
756 //gaim_signal_disconnect(gaim_blist_get_handle(), "blist-node-extended-menu", plugin,
|
|
757 // GAIM_CALLBACK(blist_node_extended_menu));
|
|
758
|
|
759 gaim_signal_disconnect(gaim_gtk_blist_get_handle(), "drawing-tooltip", plugin,
|
|
760 GAIM_CALLBACK(drawing_tooltip));
|
|
761
|
|
762 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", plugin,
|
|
763 GAIM_CALLBACK(signed_on));
|
|
764
|
|
765 gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", plugin,
|
|
766 GAIM_CALLBACK(signed_off));
|
|
767
|
|
768 gaim_signal_disconnect(gaim_blist_get_handle(), "buddy-idle-changed", plugin,
|
|
769 GAIM_CALLBACK(buddy_idle));
|
|
770
|
|
771 _signals_connected = FALSE;
|
14266
|
772 }
|
|
773
|
|
774 static void write_stats_on_unload(gpointer key, gpointer value, gpointer user_data) {
|
|
775 CapStatistics *stats = value;
|
|
776 if(stats->last_message != -1 && stats->buddy != NULL) {
|
|
777 insert_cap_failure(stats);
|
|
778 }
|
|
779 }
|
|
780
|
|
781 static gboolean plugin_unload(GaimPlugin *plugin) {
|
|
782 gaim_debug_info("cap", "CAP plugin unloading\n");
|
14350
|
783
|
14266
|
784 //clean up memory allocations
|
14350
|
785 if(_buddy_stats) {
|
|
786 g_hash_table_foreach(_buddy_stats, write_stats_on_unload, NULL);
|
14266
|
787 g_hash_table_destroy(_buddy_stats);
|
14350
|
788 }
|
14266
|
789
|
|
790 //close database connection
|
|
791 dbi_conn_close(_conn);
|
14350
|
792 _conn = NULL;
|
14266
|
793 dbi_shutdown();
|
|
794
|
|
795 return TRUE;
|
|
796 }
|
|
797
|
|
798 static GtkWidget * get_config_frame(GaimPlugin *plugin) {
|
14350
|
799 CapPrefsUI *ui = create_cap_prefs_ui();
|
|
800
|
|
801 /* Since we are editing the database setup we will disable the plugin.
|
|
802 * This will prevent database updates from occuring while there is potentially
|
|
803 * no connection to the database.
|
|
804 */
|
|
805 remove_plugin_functionality(_plugin_pointer);
|
|
806
|
|
807 return ui->ret;
|
|
808 }
|
14266
|
809
|
14350
|
810 static void cap_prefs_ui_destroy_cb(GtkObject *object, gpointer user_data) {
|
|
811 CapPrefsUI *ui = user_data;
|
|
812 if(_conn) {
|
|
813 add_plugin_functionality(_plugin_pointer);
|
|
814 }
|
|
815 g_free(ui);
|
|
816 }
|
14266
|
817
|
14350
|
818 static CapPrefsUI * create_cap_prefs_ui() {
|
|
819 CapPrefsUI *ui = g_malloc(sizeof(CapPrefsUI));
|
|
820
|
|
821 ui->ret = gtk_vbox_new(FALSE, 18);
|
|
822 gtk_container_set_border_width(GTK_CONTAINER(ui->ret), 10);
|
|
823 ui->db_vbox = gaim_gtk_make_frame(ui->ret, _("Database Configuration"));
|
|
824 ui->cap_vbox = gaim_gtk_make_frame(ui->ret, _("Statistics Configuration"));
|
14266
|
825
|
14350
|
826 /* dbd path input folder selector button */
|
|
827 ui->dbd_label = gtk_label_new(_("libdbi driver path:"));
|
|
828 gtk_misc_set_alignment(GTK_MISC(ui->dbd_label), 0, 0.5);
|
|
829 ui->dbd_input = gtk_file_chooser_button_new(_("libdbi Drivers Path"), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
|
|
830 ui->dbd_button = gtk_button_new_with_label(_("Verify"));
|
|
831 ui->dbd_hbox = gtk_hbox_new(FALSE, 18);
|
|
832 gtk_box_pack_start(GTK_BOX(ui->dbd_hbox), ui->dbd_label, FALSE, FALSE, 0);
|
|
833 gtk_box_pack_start(GTK_BOX(ui->dbd_hbox), ui->dbd_input, FALSE, FALSE, 0);
|
|
834 gtk_box_pack_start(GTK_BOX(ui->dbd_hbox), ui->dbd_button, FALSE, FALSE, 0);
|
14266
|
835
|
14350
|
836 /* Setup the driver selection widget */
|
|
837 ui->driver_choice = gtk_combo_box_new_text();
|
14266
|
838
|
14350
|
839 ui->driver_vbox = gtk_vbox_new(FALSE, 18);
|
|
840 ui->driver_label = gtk_label_new(_("Driver:"));
|
|
841 gtk_misc_set_alignment(GTK_MISC(ui->driver_label), 0, 0.5);
|
|
842 ui->driver_select_hbox = gtk_hbox_new(FALSE, 18);
|
|
843 ui->driver_connect_button = gtk_toggle_button_new_with_label(_("Connected"));
|
|
844
|
|
845 gtk_box_pack_start(GTK_BOX(ui->driver_select_hbox), ui->driver_label, FALSE, FALSE, 0);
|
|
846 gtk_box_pack_start(GTK_BOX(ui->driver_select_hbox), ui->driver_choice, FALSE, FALSE, 0);
|
|
847 gtk_box_pack_start(GTK_BOX(ui->driver_select_hbox), ui->driver_connect_button, FALSE, FALSE, 0);
|
|
848
|
|
849 ui->driver_config = gtk_expander_new_with_mnemonic(_("Configure"));
|
|
850 ui->driver_config_hbox = gtk_hbox_new(FALSE, 18);
|
|
851 gtk_box_pack_start(GTK_BOX(ui->driver_config_hbox), ui->driver_config, FALSE, FALSE, 0);
|
|
852
|
|
853 gtk_box_pack_start(GTK_BOX(ui->driver_vbox), ui->driver_select_hbox, FALSE, FALSE, 0);
|
|
854 gtk_box_pack_start(GTK_BOX(ui->driver_vbox), ui->driver_config_hbox, FALSE, FALSE, 0);
|
|
855
|
|
856 /* msg_difference spinner */
|
|
857 ui->msg_difference_label = gtk_label_new(_("Maximum response timeout:"));
|
|
858 gtk_misc_set_alignment(GTK_MISC(ui->msg_difference_label), 0, 0.5);
|
|
859 ui->msg_difference_input = gtk_spin_button_new_with_range(1, 1440, 1);
|
|
860 ui->msg_difference_minutes_label = gtk_label_new(_("minutes"));
|
|
861 gtk_misc_set_alignment(GTK_MISC(ui->msg_difference_minutes_label), 0, 0.5);
|
14266
|
862
|
14350
|
863 /* last_seen spinner */
|
|
864 ui->last_seen_label = gtk_label_new(_("Maximum last-seen difference:"));
|
|
865 gtk_misc_set_alignment(GTK_MISC(ui->last_seen_label), 0, 0.5);
|
|
866 ui->last_seen_input = gtk_spin_button_new_with_range(1, 1440, 1);
|
|
867 ui->last_seen_minutes_label = gtk_label_new(_("minutes"));
|
|
868 gtk_misc_set_alignment(GTK_MISC(ui->last_seen_minutes_label), 0, 0.5);
|
|
869
|
|
870 /* threshold spinner */
|
|
871 ui->threshold_label = gtk_label_new(_("Threshold:"));
|
|
872 gtk_misc_set_alignment(GTK_MISC(ui->threshold_label), 0, 0.5);
|
|
873 ui->threshold_input = gtk_spin_button_new_with_range(1, 1440, 1);
|
|
874 ui->threshold_minutes_label = gtk_label_new(_("minutes"));
|
|
875 gtk_misc_set_alignment(GTK_MISC(ui->threshold_minutes_label), 0, 0.5);
|
|
876
|
|
877 /* Layout threshold/last-seen/response-timeout input items */
|
|
878 ui->table_layout = gtk_table_new(3, 3, FALSE);
|
|
879 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->threshold_label, 0, 1, 0, 1,
|
|
880 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
881 (GtkAttachOptions) (0), 0, 0);
|
|
882
|
|
883 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->threshold_input, 1, 2, 0, 1,
|
|
884 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
885 (GtkAttachOptions) (0), 0, 0);
|
|
886
|
|
887 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->threshold_minutes_label, 2, 3, 0, 1,
|
|
888 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
889 (GtkAttachOptions) (0), 0, 0);
|
|
890
|
|
891 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->msg_difference_label, 0, 1, 1, 2,
|
|
892 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
893 (GtkAttachOptions) (0), 0, 0);
|
|
894
|
|
895 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->msg_difference_input, 1, 2, 1, 2,
|
|
896 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
897 (GtkAttachOptions) (0), 0, 0);
|
|
898
|
|
899 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->msg_difference_minutes_label, 2, 3, 1, 2,
|
|
900 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
901 (GtkAttachOptions) (0), 0, 0);
|
|
902
|
|
903 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->last_seen_label, 0, 1, 2,3,
|
|
904 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
905 (GtkAttachOptions) (0), 0, 0);
|
|
906
|
|
907 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->last_seen_input, 1, 2, 2, 3,
|
|
908 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
909 (GtkAttachOptions) (0), 0, 0);
|
|
910
|
|
911 gtk_table_attach(GTK_TABLE(ui->table_layout), ui->last_seen_minutes_label, 2, 3, 2, 3,
|
|
912 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
913 (GtkAttachOptions) (0), 0, 0);
|
|
914
|
|
915
|
|
916 /* Config window - lay it out */
|
|
917 gtk_box_pack_start(GTK_BOX(ui->db_vbox), ui->dbd_hbox, FALSE, FALSE, 0);
|
|
918 gtk_box_pack_start(GTK_BOX(ui->db_vbox), ui->driver_vbox, FALSE, FALSE, 0);
|
|
919 gtk_box_pack_start(GTK_BOX(ui->cap_vbox), ui->table_layout, FALSE, FALSE, 0);
|
|
920
|
|
921 /* Set the input areas to contain the configuration values from
|
|
922 * gaim prefs.
|
|
923 */
|
|
924 if(gaim_prefs_exists("/plugins/gtk/cap/libdbi_drivers")) {
|
|
925 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(ui->dbd_input), gaim_prefs_get_string("/plugins/gtk/cap/libdbi_drivers"));
|
14266
|
926 }
|
|
927 if(gaim_prefs_exists("/plugins/gtk/cap/max_msg_difference")) {
|
|
928 int max_msg_diff = gaim_prefs_get_int("/plugins/gtk/cap/max_msg_difference");
|
14350
|
929 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->msg_difference_input), max_msg_diff);
|
14266
|
930 }
|
|
931 if(gaim_prefs_exists("/plugins/gtk/cap/max_seen_difference")) {
|
|
932 int max_seen_diff = gaim_prefs_get_int("/plugins/gtk/cap/max_seen_difference");
|
14350
|
933 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->last_seen_input), max_seen_diff);
|
14266
|
934 }
|
|
935 if(gaim_prefs_exists("/plugins/gtk/cap/threshold")) {
|
|
936 int threshold = gaim_prefs_get_int("/plugins/gtk/cap/threshold");
|
14350
|
937 gtk_spin_button_set_value(GTK_SPIN_BUTTON(ui->threshold_input), threshold);
|
14266
|
938 }
|
14350
|
939
|
|
940 /* Add the signals */
|
|
941 g_signal_connect(G_OBJECT(ui->ret), "destroy",
|
|
942 G_CALLBACK(cap_prefs_ui_destroy_cb), ui);
|
|
943
|
|
944 g_signal_connect(G_OBJECT(ui->driver_choice), "changed",
|
|
945 G_CALLBACK(driver_choice_changed_cb), ui);
|
|
946
|
|
947 g_signal_connect(G_OBJECT(ui->driver_config), "notify::expanded",
|
|
948 G_CALLBACK(driver_config_expanded_cb), ui);
|
|
949
|
|
950 g_signal_connect(G_OBJECT(ui->driver_connect_button), "toggled",
|
|
951 G_CALLBACK(connect_toggled_cb), ui);
|
|
952
|
|
953 g_signal_connect(G_OBJECT(ui->msg_difference_input), "value-changed",
|
|
954 G_CALLBACK(numeric_spinner_prefs_cb), "/plugins/gtk/cap/max_msg_difference");
|
|
955
|
|
956 g_signal_connect(G_OBJECT(ui->last_seen_input), "value-changed",
|
|
957 G_CALLBACK(numeric_spinner_prefs_cb), "/plugins/gtk/cap/max_seen_difference");
|
|
958
|
|
959 g_signal_connect(G_OBJECT(ui->threshold_input), "value-changed",
|
14266
|
960 G_CALLBACK(numeric_spinner_prefs_cb), "/plugins/gtk/cap/threshold");
|
14350
|
961
|
|
962 g_signal_connect(G_OBJECT(ui->dbd_button), "clicked",
|
|
963 G_CALLBACK(driver_location_verify_cb), ui);
|
|
964
|
|
965 /* libdbi was not successfully initialized so disable the driver selection.
|
|
966 * Also disable the configuration for the database.
|
|
967 */
|
|
968 if(!_dbi_initialized || _num_drivers <= 0) {
|
|
969 /* Since DBI is not available disable database configuration */
|
|
970 gtk_widget_set_sensitive(ui->driver_choice, FALSE);
|
|
971 gtk_widget_set_sensitive(ui->driver_config, FALSE);
|
|
972 gtk_widget_set_sensitive(ui->driver_connect_button, FALSE);
|
|
973 } else {
|
|
974 set_driver_choice_options(GTK_COMBO_BOX(ui->driver_choice));
|
|
975 }
|
|
976
|
|
977 if(_conn) {
|
|
978 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->driver_connect_button), TRUE);
|
|
979 gtk_widget_set_sensitive(ui->driver_choice, FALSE);
|
|
980 gtk_widget_set_sensitive(ui->driver_config, FALSE);
|
|
981 } else {
|
|
982 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui->driver_connect_button), FALSE);
|
14266
|
983 }
|
14350
|
984
|
|
985 return ui;
|
|
986 }
|
|
987
|
|
988 static void driver_choice_changed_cb(GtkComboBox *widget, gpointer user_data) {
|
|
989 CapPrefsUI *ui = user_data;
|
|
990 if(strcmp(gtk_combo_box_get_active_text(GTK_COMBO_BOX(ui->driver_choice)), "mysql") == 0) {
|
|
991 gtk_widget_set_sensitive(ui->driver_config, TRUE);
|
|
992 gtk_widget_set_sensitive(ui->driver_connect_button, TRUE);
|
|
993 } else {
|
|
994 gtk_widget_set_sensitive(ui->driver_config, FALSE);
|
|
995 gtk_widget_set_sensitive(ui->driver_connect_button, FALSE);
|
|
996 }
|
|
997 }
|
14266
|
998
|
14350
|
999 static void driver_config_expanded_cb(GObject *object, GParamSpec *param_spec, gpointer user_data) {
|
|
1000 CapPrefsUI *ui = user_data;
|
|
1001 GtkExpander *expander;
|
|
1002 gchar *driver = gtk_combo_box_get_active_text(GTK_COMBO_BOX(ui->driver_choice));
|
|
1003 expander = GTK_EXPANDER(object);
|
|
1004 if(gtk_expander_get_expanded(expander)) {
|
|
1005 if(strcmp(driver, "mysql") == 0) {
|
|
1006 gtk_container_add(GTK_CONTAINER(expander), get_mysql_config());
|
|
1007 }
|
|
1008 } else {
|
|
1009 gtk_container_remove(GTK_CONTAINER(expander), gtk_bin_get_child(GTK_BIN(expander)));
|
|
1010 }
|
|
1011 }
|
14266
|
1012
|
14350
|
1013 static void connect_toggled_cb(GtkToggleButton *togglebutton, gpointer user_data) {
|
|
1014 CapPrefsUI *ui = user_data;
|
|
1015 if(gtk_toggle_button_get_active(togglebutton)) {
|
|
1016 //connect
|
|
1017 if(create_database_connection()) {
|
|
1018 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_choice), FALSE);
|
|
1019 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_config), FALSE);
|
|
1020 gtk_widget_set_sensitive(GTK_WIDGET(ui->dbd_input), FALSE);
|
|
1021 gtk_widget_set_sensitive(GTK_WIDGET(ui->dbd_button), FALSE);
|
|
1022 gaim_prefs_set_bool("/plugins/gtk/cap/connected", TRUE);
|
|
1023 } else {
|
|
1024 gtk_toggle_button_set_active(togglebutton, FALSE);
|
|
1025 }
|
|
1026 } else {
|
|
1027 //disconnect
|
|
1028 destroy_database_connection();
|
|
1029 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_choice), TRUE);
|
|
1030 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_config), TRUE);
|
|
1031 gtk_widget_set_sensitive(GTK_WIDGET(ui->dbd_input), TRUE);
|
|
1032 gtk_widget_set_sensitive(GTK_WIDGET(ui->dbd_button), TRUE);
|
|
1033 gaim_prefs_set_bool("/plugins/gtk/cap/connected", FALSE);
|
|
1034 }
|
14266
|
1035 }
|
|
1036
|
|
1037 static void numeric_spinner_prefs_cb(GtkSpinButton *spinbutton, gpointer user_data) {
|
|
1038 gaim_prefs_set_int(user_data, gtk_spin_button_get_value_as_int(spinbutton));
|
|
1039 }
|
|
1040
|
14350
|
1041 static void driver_location_verify_cb(GtkButton *button, gpointer user_data) {
|
|
1042 CapPrefsUI *ui = user_data;
|
|
1043 gchar *path = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(ui->dbd_input));
|
|
1044
|
|
1045 if(_dbi_initialized)
|
|
1046 dbi_shutdown();
|
|
1047
|
|
1048 gaim_prefs_set_string("/plugins/gtk/cap/libdbi_drivers", path);
|
|
1049 _num_drivers = dbi_initialize(path);
|
|
1050 if(_num_drivers == -1) {
|
|
1051 _dbi_initialized = FALSE;
|
|
1052 } else {
|
|
1053 _dbi_initialized = TRUE;
|
|
1054 }
|
|
1055 if(_num_drivers > 0) {
|
|
1056 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_choice), TRUE);
|
|
1057 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_config), TRUE);
|
|
1058 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_connect_button), TRUE);
|
|
1059 set_driver_choice_options(GTK_COMBO_BOX(ui->driver_choice));
|
|
1060 } else {
|
|
1061 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_choice), FALSE);
|
|
1062 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_config), FALSE);
|
|
1063 gtk_expander_set_expanded(GTK_EXPANDER(ui->driver_config), FALSE);
|
|
1064 gtk_widget_set_sensitive(GTK_WIDGET(ui->driver_connect_button), FALSE);
|
|
1065 }
|
|
1066 }
|
|
1067
|
14266
|
1068 static gboolean text_entry_prefs_cb(GtkWidget *widget, GdkEventFocus *event, gpointer user_data) {
|
|
1069 gaim_prefs_set_string(user_data, gtk_entry_get_text(GTK_ENTRY(widget)));
|
|
1070 return FALSE;
|
|
1071 }
|
|
1072
|
14350
|
1073 void set_driver_choice_options(GtkComboBox *chooser) {
|
|
1074 dbi_driver driver = NULL;
|
|
1075 GtkListStore *list_store;
|
|
1076 gint index = 0;
|
|
1077 gint selected = 0;
|
|
1078
|
|
1079 list_store = GTK_LIST_STORE(gtk_combo_box_get_model(chooser));
|
|
1080 gtk_list_store_clear(list_store);
|
14266
|
1081
|
14350
|
1082 if(!_dbi_initialized)
|
|
1083 return;
|
|
1084
|
|
1085 while((driver = dbi_driver_list(driver)) != NULL) {
|
|
1086 gtk_combo_box_append_text(chooser, dbi_driver_get_name(driver));
|
|
1087 if(strcmp(dbi_driver_get_name(driver), gaim_prefs_get_string("/plugins/gtk/cap/db_driver")) == 0) {
|
|
1088 selected = index;
|
14266
|
1089 }
|
14350
|
1090 ++index;
|
14266
|
1091 }
|
14350
|
1092 gtk_combo_box_set_active(chooser, selected);
|
14266
|
1093 }
|
|
1094
|
|
1095 static GtkWidget * get_mysql_config() {
|
14350
|
1096 GtkWidget *config_area = gtk_table_new(5, 2, FALSE);
|
14266
|
1097 GtkWidget *username_label = gtk_label_new(_("Username:"));
|
|
1098 GtkWidget *username_input = gtk_entry_new();
|
|
1099 GtkWidget *password_label = gtk_label_new(_("Password:"));
|
|
1100 GtkWidget *password_input = gtk_entry_new();
|
|
1101 GtkWidget *host_label = gtk_label_new(_("Host:"));
|
|
1102 GtkWidget *host_input = gtk_entry_new();
|
|
1103 GtkWidget *db_label = gtk_label_new(_("Database:"));
|
|
1104 GtkWidget *db_input = gtk_entry_new();
|
|
1105 GtkWidget *port_label = gtk_label_new(_("Port:"));
|
|
1106 GtkWidget *port_input = gtk_spin_button_new_with_range(0, 10000, 1);
|
|
1107
|
|
1108 gtk_entry_set_visibility(GTK_ENTRY(password_input), FALSE);
|
|
1109
|
14350
|
1110 gtk_misc_set_alignment(GTK_MISC(username_label), 0, 0.5);
|
|
1111 gtk_misc_set_padding(GTK_MISC(username_label), 10, 0);
|
|
1112
|
|
1113 gtk_misc_set_alignment(GTK_MISC(password_label), 0, 0.5);
|
|
1114 gtk_misc_set_padding(GTK_MISC(password_label), 10, 0);
|
|
1115
|
|
1116 gtk_misc_set_alignment(GTK_MISC(host_label), 0, 0.5);
|
|
1117 gtk_misc_set_padding(GTK_MISC(host_label), 10, 0);
|
|
1118
|
|
1119 gtk_misc_set_alignment(GTK_MISC(db_label), 0, 0.5);
|
|
1120 gtk_misc_set_padding(GTK_MISC(db_label), 10, 0);
|
|
1121
|
|
1122 gtk_misc_set_alignment(GTK_MISC(port_label), 0, 0.5);
|
|
1123 gtk_misc_set_padding(GTK_MISC(port_label), 10, 0);
|
|
1124
|
|
1125 gtk_table_attach(GTK_TABLE(config_area), host_label, 0, 1, 0, 1,
|
|
1126 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1127 (GtkAttachOptions) (0), 0, 0);
|
|
1128 gtk_table_attach(GTK_TABLE(config_area), host_input, 1, 2, 0, 1,
|
|
1129 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1130 (GtkAttachOptions) (0), 0, 0);
|
|
1131 gtk_table_attach(GTK_TABLE(config_area), port_label, 0, 1, 1, 2,
|
|
1132 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1133 (GtkAttachOptions) (0), 0, 0);
|
|
1134 gtk_table_attach(GTK_TABLE(config_area), port_input, 1, 2, 1, 2,
|
|
1135 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1136 (GtkAttachOptions) (0), 0, 0);
|
|
1137 gtk_table_attach(GTK_TABLE(config_area), db_label, 0, 1, 2, 3,
|
|
1138 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1139 (GtkAttachOptions) (0), 0, 0);
|
|
1140 gtk_table_attach(GTK_TABLE(config_area), db_input, 1, 2, 2, 3,
|
|
1141 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1142 (GtkAttachOptions) (0), 0, 0);
|
|
1143 gtk_table_attach(GTK_TABLE(config_area), username_label, 0, 1, 3, 4,
|
|
1144 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1145 (GtkAttachOptions) (0), 0, 0);
|
|
1146 gtk_table_attach(GTK_TABLE(config_area), username_input, 1, 2, 3, 4,
|
|
1147 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1148 (GtkAttachOptions) (0), 0, 0);
|
|
1149 gtk_table_attach(GTK_TABLE(config_area), password_label, 0, 1, 4, 5,
|
|
1150 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1151 (GtkAttachOptions) (0), 0, 0);
|
|
1152 gtk_table_attach(GTK_TABLE(config_area), password_input, 1, 2, 4, 5,
|
|
1153 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
|
|
1154 (GtkAttachOptions) (0), 0, 0);
|
14266
|
1155
|
|
1156 //Initialize with data
|
|
1157 if(gaim_prefs_exists("/plugins/gtk/cap/mysql/db_host")) {
|
|
1158 gtk_entry_set_text(GTK_ENTRY(host_input), gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_host"));
|
|
1159 } else {
|
|
1160 gtk_entry_set_text(GTK_ENTRY(host_input), "localhost");
|
|
1161 }
|
|
1162 if(gaim_prefs_exists("/plugins/gtk/cap/mysql/db_port")) {
|
|
1163 gtk_spin_button_set_value(GTK_SPIN_BUTTON(port_input), gaim_prefs_get_int("/plugins/gtk/cap/mysql/db_port"));
|
|
1164 } else {
|
|
1165 gtk_spin_button_set_value(GTK_SPIN_BUTTON(port_input), 3306);
|
|
1166 }
|
|
1167 if(gaim_prefs_exists("/plugins/gtk/cap/mysql/db_user")) {
|
|
1168 gtk_entry_set_text(GTK_ENTRY(username_input), gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_user"));
|
|
1169 } else {
|
|
1170 gtk_entry_set_text(GTK_ENTRY(username_input), "root");
|
|
1171 }
|
|
1172 if(gaim_prefs_exists("/plugins/gtk/cap/mysql/db_password")) {
|
|
1173 gtk_entry_set_text(GTK_ENTRY(password_input), gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_password"));
|
|
1174 } else {
|
|
1175 gtk_entry_set_text(GTK_ENTRY(password_input), "");
|
|
1176 }
|
|
1177 if(gaim_prefs_exists("/plugins/gtk/cap/mysql/db_name")) {
|
|
1178 gtk_entry_set_text(GTK_ENTRY(db_input), gaim_prefs_get_string("/plugins/gtk/cap/mysql/db_name"));
|
|
1179 } else {
|
|
1180 gtk_entry_set_text(GTK_ENTRY(db_input), "cap");
|
|
1181 }
|
|
1182
|
|
1183 //Add callbacks
|
|
1184 g_signal_connect(G_OBJECT(host_input), "focus-out-event",
|
|
1185 G_CALLBACK(text_entry_prefs_cb), "/plugins/gtk/cap/mysql/db_host");
|
|
1186 g_signal_connect(G_OBJECT(port_input), "value-changed",
|
|
1187 G_CALLBACK(numeric_spinner_prefs_cb), "/plugins/gtk/cap/mysql/db_port");
|
|
1188 g_signal_connect(G_OBJECT(username_input), "focus-out-event",
|
|
1189 G_CALLBACK(text_entry_prefs_cb), "/plugins/gtk/cap/mysql/db_user");
|
|
1190 g_signal_connect(G_OBJECT(password_input), "focus-out-event",
|
|
1191 G_CALLBACK(text_entry_prefs_cb), "/plugins/gtk/cap/mysql/db_password");
|
|
1192 g_signal_connect(G_OBJECT(db_input), "focus-out-event",
|
|
1193 G_CALLBACK(text_entry_prefs_cb), "/plugins/gtk/cap/mysql/db_name");
|
|
1194
|
|
1195 gtk_widget_show_all(config_area);
|
|
1196
|
|
1197 return config_area;
|
|
1198 }
|
|
1199
|
|
1200 static GaimGtkPluginUiInfo ui_info = {
|
|
1201 get_config_frame,
|
|
1202 0 /* page_num (reserved) */
|
|
1203 };
|
|
1204
|
|
1205 static GaimPluginInfo info = {
|
|
1206 GAIM_PLUGIN_MAGIC,
|
|
1207 GAIM_MAJOR_VERSION,
|
|
1208 GAIM_MINOR_VERSION,
|
|
1209 GAIM_PLUGIN_STANDARD, /**< type */
|
|
1210 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
|
|
1211 0, /**< flags */
|
|
1212 NULL, /**< dependencies */
|
|
1213 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1214 CAP_PLUGIN_ID, /**< id */
|
|
1215 "Contact Availability Prediction", /**< name */
|
|
1216 VERSION, /**< version */
|
|
1217 N_("Contact Availability Prediction plugin."), /** summary */
|
|
1218 N_("The contact availability plugin (cap) is used to display statistical information about buddies in a users contact list."),
|
|
1219 /** description */
|
|
1220 "Geoffrey Foster <geoffrey.foster@gmail.com>", /**< author */
|
|
1221 GAIM_WEBSITE, /**< homepage */
|
|
1222 plugin_load, /**< load */
|
|
1223 plugin_unload, /**< unload */
|
|
1224 NULL, /**< destroy */
|
|
1225 &ui_info, /**< ui_info */
|
|
1226 NULL, /**< extra_info */
|
|
1227 NULL, /**< prefs_info */
|
|
1228 NULL
|
|
1229 };
|
|
1230
|
|
1231 static void init_plugin(GaimPlugin *plugin) {
|
|
1232 gaim_prefs_add_none("/plugins/gtk/cap");
|
|
1233 gaim_prefs_add_int("/plugins/gtk/cap/max_seen_difference", 1);
|
|
1234 gaim_prefs_add_int("/plugins/gtk/cap/max_msg_difference", 10);
|
|
1235 gaim_prefs_add_int("/plugins/gtk/cap/threshold", 5);
|
|
1236 gaim_prefs_add_bool("/plugins/gtk/cap/configured", FALSE);
|
|
1237 gaim_prefs_add_string("/plugins/gtk/cap/db_driver", "mysql");
|
|
1238 gaim_prefs_add_none("/plugins/gtk/cap/mysql");
|
|
1239 gaim_prefs_add_string("/plugins/gtk/cap/mysql/db_host", "localhost");
|
|
1240 gaim_prefs_add_int("/plugins/gtk/cap/mysql/db_port", 3306);
|
|
1241 gaim_prefs_add_string("/plugins/gtk/cap/mysql/db_user", "root");
|
|
1242 gaim_prefs_add_string("/plugins/gtk/cap/mysql/db_password", "");
|
|
1243 gaim_prefs_add_string("/plugins/gtk/cap/mysql/db_name", "cap");
|
|
1244 }
|
|
1245
|
|
1246 GAIM_INIT_PLUGIN(cap, init_plugin, info);
|