comparison pidgin/plugins/cap/cap.h @ 15374:5fe8042783c1

Rename gtk/ and libgaim/ to pidgin/ and libpurple/
author Sean Egan <seanegan@gmail.com>
date Sat, 20 Jan 2007 02:32:10 +0000
parents
children 760ef6d78d2d
comparison
equal deleted inserted replaced
15373:f79e0f4df793 15374:5fe8042783c1
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 #ifndef _CAP_H_
23 #define _CAP_H_
24
25 #include "internal.h"
26 #include "gtkgaim.h"
27
28 #include "conversation.h"
29
30 #include "gtkconv.h"
31 #include "gtkblist.h"
32 #include "gtkplugin.h"
33 #include "gtkutils.h"
34
35 #include "blist.h"
36 #include "notify.h"
37 #include "version.h"
38 #include "debug.h"
39
40 #include "util.h"
41
42 #include <glib.h>
43 #include <time.h>
44 #include <sqlite3.h>
45 #include "cap_statistics.h"
46
47 #define CAP_PLUGIN_ID "gtk-g-off_-cap"
48
49 /* Variables used throughout lifetime of the plugin */
50 GaimPlugin *_plugin_pointer;
51 sqlite3 *_db; /**< The database */
52
53 GHashTable *_buddy_stats = NULL;
54 GHashTable *_my_offline_times = NULL;
55 gboolean _signals_connected;
56 gboolean _sqlite_initialized;
57
58 /* Prefs UI */
59 typedef struct _CapPrefsUI CapPrefsUI;
60
61 struct _CapPrefsUI {
62 GtkWidget *ret;
63 GtkWidget *cap_vbox;
64 GtkWidget *table_layout;
65
66 GtkWidget *threshold_label;
67 GtkWidget *threshold_input;
68 GtkWidget *threshold_minutes_label;
69
70 GtkWidget *msg_difference_label;
71 GtkWidget *msg_difference_input;
72 GtkWidget *msg_difference_minutes_label;
73
74 GtkWidget *last_seen_label;
75 GtkWidget *last_seen_input;
76 GtkWidget *last_seen_minutes_label;
77 };
78
79 static void generate_prediction(CapStatistics *statistics);
80 static double generate_prediction_for(GaimBuddy *buddy);
81 static CapStatistics * get_stats_for(GaimBuddy *buddy);
82 static void destroy_stats(gpointer data);
83 static void insert_cap_msg_count_success(const char *buddy_name, const char *account, const char *protocol, int minute);
84 static void insert_cap_status_count_success(const char *buddy_name, const char *account, const char *protocol, const char *status_id);
85 static void insert_cap_msg_count_failed(const char *buddy_name, const char *account, const char *protocol, int minute);
86 static void insert_cap_status_count_failed(const char *buddy_name, const char *account, const char *protocol, const char *status_id);
87 static void insert_cap_success(CapStatistics *stats);
88 static void insert_cap_failure(CapStatistics *stats);
89 static gboolean max_message_difference_cb(gpointer data);
90 /* Gaim Signal Handlers */
91 /* sent-im-msg */
92 static void sent_im_msg(GaimAccount *account, const char *receiver, const char *message);
93 /* received-im-msg */
94 static void received_im_msg(GaimAccount *account, char *sender, char *message, GaimConversation *conv, GaimMessageFlags flags);
95 /* buddy-status-changed */
96 static void buddy_status_changed(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *status);
97 /* buddy-signed-on */
98 static void buddy_signed_on(GaimBuddy *buddy);
99 /* buddy-signed-off */
100 static void buddy_signed_off(GaimBuddy *buddy);
101 static void buddy_idle(GaimBuddy *buddy, gboolean old_idle, gboolean idle);
102 static void blist_node_extended_menu(GaimBlistNode *node, GList **menu);
103 /* drawing-tooltip */
104 static void drawing_tooltip(GaimBlistNode *node, GString *text, gboolean full);
105 /* signed-on */
106 static void signed_on(GaimConnection *gc);
107 /* signed-off */
108 static void signed_off(GaimConnection *gc);
109 static void reset_all_last_message_times(gpointer key, gpointer value, gpointer user_data);
110 static GaimStatus * get_status_for(GaimBuddy *buddy);
111 static void create_tables();
112 static gboolean create_database_connection();
113 static void destroy_database_connection();
114 static guint word_count(const gchar *string);
115 static void insert_status_change(CapStatistics *statistics);
116 static void insert_status_change_from_gaim_status(CapStatistics *statistics, GaimStatus *status);
117 static void insert_word_count(const char *sender, const char *receiver, guint count);
118 void display_statistics_action_cb(GaimBlistNode *node, gpointer data);
119 static gboolean plugin_load(GaimPlugin *plugin);
120 static void add_plugin_functionality(GaimPlugin *plugin);
121 static void cancel_conversation_timeouts(gpointer key, gpointer value, gpointer user_data);
122 static void remove_plugin_functionality(GaimPlugin *plugin);
123 static void write_stats_on_unload(gpointer key, gpointer value, gpointer user_data);
124 static gboolean plugin_unload(GaimPlugin *plugin);
125 static CapPrefsUI * create_cap_prefs_ui();
126 static void cap_prefs_ui_destroy_cb(GtkObject *object, gpointer user_data);
127 static void numeric_spinner_prefs_cb(GtkSpinButton *spinbutton, gpointer user_data);
128 static GtkWidget * get_config_frame(GaimPlugin *plugin);
129 static void init_plugin(GaimPlugin *plugin);
130
131 #endif