Mercurial > pidgin
comparison gtk/plugins/cap/cap.h @ 14266:63ef6342db05
[gaim-migrate @ 16948]
* Initial commit of the Contact Availability Prediction plugin
* Located in trunk/gtk/plugins/cap
* Check README for further information and requirements for build
committer: Tailor Script <tailor@pidgin.im>
author | Geoff Foster <g-off_> |
---|---|
date | Mon, 21 Aug 2006 07:44:31 +0000 |
parents | |
children | eec3ce357b70 |
comparison
equal
deleted
inserted
replaced
14265:584cbd1628d0 | 14266:63ef6342db05 |
---|---|
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 <dbi/dbi.h> | |
43 #include <glib.h> | |
44 #include <time.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 dbi_conn _conn; /**< The database connection */ | |
52 dbi_driver _driver; /**< The database driver */ | |
53 GHashTable *_buddy_stats = NULL; | |
54 GHashTable *_my_offline_times = NULL; | |
55 GString *error_msg = NULL; | |
56 gboolean _signals_connected; | |
57 | |
58 enum driver_types {MYSQL}; | |
59 | |
60 /* Function definitions */ | |
61 static char * quote_string(const char *str); | |
62 static gboolean plugin_load(GaimPlugin *plugin); | |
63 static gboolean add_plugin_functionality(GaimPlugin *plugin); | |
64 static gboolean plugin_unload(GaimPlugin *plugin); | |
65 static GtkWidget * get_config_frame(GaimPlugin *plugin); | |
66 static void numeric_spinner_prefs_cb(GtkSpinButton *spinbutton, gpointer user_data); | |
67 static gboolean text_entry_prefs_cb(GtkWidget *widget, GdkEventFocus *event, gpointer user_data); | |
68 static void combobox_prefs_cb(GtkComboBox *widget, gpointer user_data); | |
69 static void prefs_closed_cb(GtkObject *widget, gpointer user_data); | |
70 static GtkWidget * get_mysql_config(); | |
71 static void driver_config_expanded(GObject *object, GParamSpec *param_spec, gpointer user_data); | |
72 static void init_plugin(GaimPlugin *plugin); | |
73 static void generate_prediction(CapStatistics *statistics); | |
74 static double generate_prediction_for(GaimBuddy *buddy); | |
75 static CapStatistics * get_stats_for(GaimBuddy *buddy); | |
76 static void destroy_stats(gpointer data); | |
77 static gboolean remove_stats_for(GaimBuddy *buddy); | |
78 static dbi_result insert_cap_msg_count_success(const char *buddy_name, const char *account, const char *protocol, int minute); | |
79 static dbi_result insert_cap_status_count_success(const char *buddy_name, const char *account, const char *protocol, const char *status_id); | |
80 static dbi_result insert_cap_msg_count_failed(const char *buddy_name, const char *account, const char *protocol, int minute); | |
81 static dbi_result insert_cap_status_count_failed(const char *buddy_name, const char *account, const char *protocol, const char *status_id); | |
82 static void insert_cap_success(CapStatistics *stats); | |
83 static void insert_cap_failure(CapStatistics *stats); | |
84 static gboolean max_message_difference_cb(gpointer data); | |
85 | |
86 /* Various CAP helper functions */ | |
87 static const gchar * get_error_msg(); | |
88 static void set_error_msg(const gchar *msg); | |
89 static void reset_all_last_message_times(gpointer key, gpointer value, gpointer user_data); | |
90 static GaimStatus * get_status_for(GaimBuddy *buddy); | |
91 static void create_tables(); | |
92 static gboolean create_database_connection(); | |
93 static guint word_count(const gchar *string); | |
94 static gboolean last_message_time_in_range(CapStatistics *statistics, gdouble max_difference); | |
95 static gboolean last_seen_time_in_range(CapStatistics *statistics, gdouble max_difference); | |
96 static void insert_status_change(CapStatistics *statistics); | |
97 static void insert_status_change_from_gaim_status(CapStatistics *statistics, GaimStatus *status); | |
98 static void insert_word_count(const char *sender, const char *receiver, guint count); | |
99 | |
100 /* Gaim Signal Handlers */ | |
101 static void sent_im_msg(GaimAccount *account, const char *receiver, const char *message); | |
102 static void received_im_msg(GaimAccount *account, char *sender, char *message, | |
103 GaimConversation *conv, GaimMessageFlags flags); | |
104 static void buddy_status_changed(GaimBuddy *buddy, GaimStatus *old_status, GaimStatus *status); | |
105 static void buddy_signed_on(GaimBuddy *buddy); | |
106 static void buddy_signed_off(GaimBuddy *buddy); | |
107 static void buddy_idle(GaimBuddy *buddy, gboolean old_idle, gboolean idle); | |
108 static void blist_node_extended_menu(GaimBlistNode *node, GList **menu); | |
109 static void drawing_tooltip(GaimBlistNode *node, GString *text, gboolean full); | |
110 static void signed_on(GaimConnection *gc); | |
111 static void signed_off(GaimConnection *gc); | |
112 | |
113 /* Call backs */ | |
114 void display_statistics_action_cb(GaimBlistNode *node, gpointer data); | |
115 | |
116 #endif |