plugins/autorecon.c

changeset 5205
242b8aa81328
parent 4590
6d79d7b29bcd
child 5227
6b44f7901f94
equal deleted inserted replaced
5204:deed98aa3181 5205:242b8aa81328
1 #include "config.h" 1 #include "config.h"
2 2
3 #if 0
3 #ifndef GAIM_PLUGINS 4 #ifndef GAIM_PLUGINS
4 #define GAIM_PLUGINS 5 #define GAIM_PLUGINS
6 #endif
5 #endif 7 #endif
6 8
7 #include "gaim.h" 9 #include "gaim.h"
8 #include "prpl.h" 10 #include "prpl.h"
9 11
10 #ifdef _WIN32 12 #ifdef _WIN32
11 #include "win32dep.h" 13 #include "win32dep.h"
12 #endif 14 #endif
15
16 #define AUTORECON_PLUGIN_ID "core-autorecon"
13 17
14 G_MODULE_IMPORT GSList *gaim_accounts; 18 G_MODULE_IMPORT GSList *gaim_accounts;
15 19
16 #define INITIAL 8000 20 #define INITIAL 8000
17 #define MAXTIME 2048000 21 #define MAXTIME 2048000
46 } else { 50 } else {
47 g_hash_table_remove(hash, gc->account); 51 g_hash_table_remove(hash, gc->account);
48 } 52 }
49 } 53 }
50 54
51 /* 55 static gboolean
52 * EXPORTED FUNCTIONS 56 plugin_load(GaimPlugin *plugin)
53 */ 57 {
58 hash = g_hash_table_new(g_int_hash, g_int_equal);
54 59
55 struct gaim_plugin_description desc; 60 gaim_signal_connect(plugin, event_signoff, reconnect, NULL);
56 G_MODULE_EXPORT struct gaim_plugin_description *gaim_plugin_desc() { 61
57 desc.api_version = PLUGIN_API_VERSION; 62 return TRUE;
58 desc.name = g_strdup(_("Autoreconnect"));
59 desc.version = g_strdup(VERSION);
60 desc.description = g_strdup(_("When you are kicked offline, this reconnects you."));
61 desc.authors = g_strdup("Eric Warmenhoven <eric@warmenhoven.org>");
62 desc.url = g_strdup(WEBSITE);
63 return &desc;
64 } 63 }
65 64
66 G_MODULE_EXPORT char *name() { 65 static gboolean
67 return _("Auto Reconnect"); 66 plugin_unload(GaimPlugin *plugin)
67 {
68 if (tim)
69 g_source_remove(tim);
70
71 gaim_signal_disconnect(plugin, event_signoff, reconnect);
72
73 g_hash_table_destroy(hash);
74
75 hash = NULL;
76 tim = 0;
77
78 return TRUE;
68 } 79 }
69 80
70 G_MODULE_EXPORT char *description() { 81 static GaimPluginInfo info =
71 return _("When you are kicked offline, this reconnects you."); 82 {
83 2, /**< api_version */
84 GAIM_PLUGIN_STANDARD, /**< type */
85 NULL, /**< ui_requirement */
86 0, /**< flags */
87 NULL, /**< dependencies */
88 GAIM_PRIORITY_DEFAULT, /**< priority */
89
90 AUTORECON_PLUGIN_ID, /**< id */
91 N_("Auto-Reconnect"), /**< name */
92 VERSION, /**< version */
93 /** summary */
94 N_("When you are kicked offline, this reconnects you."),
95 /** description */
96 N_("When you are kicked offline, this reconnects you."),
97 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */
98 WEBSITE, /**< homepage */
99
100 plugin_load, /**< load */
101 plugin_unload, /**< unload */
102 NULL, /**< destroy */
103
104 NULL, /**< ui_info */
105 NULL /**< extra_info */
106 };
107
108 static void
109 __init_plugin(GaimPlugin *plugin)
110 {
72 } 111 }
73 112
74 G_MODULE_EXPORT char *gaim_plugin_init(GModule *handle) { 113 GAIM_INIT_PLUGIN(autorecon, __init_plugin, info);
75 hash = g_hash_table_new(g_int_hash, g_int_equal);
76
77 gaim_signal_connect(handle, event_signoff, reconnect, NULL);
78
79 return NULL;
80 }
81
82 G_MODULE_EXPORT void gaim_plugin_remove() {
83 if (tim)
84 g_source_remove(tim);
85 g_hash_table_destroy(hash);
86 hash = NULL;
87 tim = 0;
88 }

mercurial