comparison plugins/timestamp.c @ 5205:fefad67de2c7

[gaim-migrate @ 5573] I had a damn good commit message, but it was eaten. Let's try it again. Announcing, Gaim Plugin API version 2.0, or GPAPIV2.0 for short. There are lots'a cool thingies here. Okay now, this isn't as cool as the previous message, but: 1) There's now a single entry function for all plugin types. It returns a detailed information structure on the plugin. This removes a lot of the ugliness from old plugins. Oh yeah, libicq wasn't converted to this, so if you use it, well, you shouldn't have used it anyway, but now you can't! bwahahaha. Use AIM/ICQ. 2) There are now 3 types of plugins: Standard, Loader, and Protocol plugins. Standard plugins are, well, standard, compiled plugins. Loader plugins load other plugins. For example, the perl support is now a loader plugin. It loads perl scripts. In the future, we'll have Ruby and Python loader plugins. Protocol plugins are, well, protocol plugins... yeah... 3) Plugins have unique IDs, so they can be referred to or automatically updated from a plugin database in the future. Neat, huh? 4) Plugins will have dependency support in the future, and can be hidden, so if you have, say, a logging core plugin, it won't have to show up, but then you load the GTK+ logging plugin and it'll auto-load the core plugin. Core/UI split plugins! 5) There will eventually be custom plugin signals and RPC of some sort, for the core/ui split plugins. So, okay, back up .gaimrc. I'd like to thank my parents for their support, javabsp for helping convert a bunch of protocol plugins, and Etan for helping convert a bunch of standard plugins. Have fun. If you have any problems, please let me know, but you probably won't have anything major happen. You will have to convert your plugins, though, and I'm not guaranteeing that all perl scripts will still work. I'll end up changing the perl script API eventually, so I know they won't down the road. Don't worry, though. It'll be mass cool. faceprint wants me to just commit the damn code already. So, here we go!!! .. .. I need a massage. From a young, cute girl. Are there any young, cute girls in the audience? IM me plz k thx. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 25 Apr 2003 06:47:33 +0000
parents c7986b4d182a
children 6d1707dc8c3d
comparison
equal deleted inserted replaced
5204:44de70702205 5205:fefad67de2c7
3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003. 3 * Modified by: Chris J. Friesen <Darth_Sebulba04@yahoo.com> Jan 05, 2003.
4 * <INSERT GPL HERE> */ 4 * <INSERT GPL HERE> */
5 5
6 #include "config.h" 6 #include "config.h"
7 7
8 #ifndef GAIM_PLUGINS
9 #define GAIM_PLUGINS
10 #endif
11
12 #include <time.h> 8 #include <time.h>
13 #include "gaim.h" 9 #include "gaim.h"
14 #include "gtkimhtml.h" 10 #include "gtkimhtml.h"
11 #include "gtkplugin.h"
12
13 #define TIMESTAMP_PLUGIN_ID "gtk-timestamp"
15 14
16 //Set the default to 5 minutes. 15 //Set the default to 5 minutes.
17 int timestamp = 5 * 60 * 1000; 16 static int timestamp = 5 * 60 * 1000;
18 17
19 GModule *handle; 18 static GSList *timestamp_timeouts;
20 GSList *timestamp_timeouts;
21 19
22 gboolean do_timestamp (gpointer data) 20 gboolean do_timestamp (gpointer data)
23 { 21 {
24 struct gaim_conversation *c = (struct gaim_conversation *)data; 22 struct gaim_conversation *c = (struct gaim_conversation *)data;
25 char *buf; 23 char *buf;
57 tm = tm * 60 * 1000; 55 tm = tm * 60 * 1000;
58 56
59 timestamp = tm; 57 timestamp = tm;
60 } 58 }
61 59
62 GtkWidget *gaim_plugin_config_gtk() { 60 static GtkWidget *
61 get_config_frame(GaimPlugin *plugin)
62 {
63 GtkWidget *ret; 63 GtkWidget *ret;
64 GtkWidget *frame, *label; 64 GtkWidget *frame, *label;
65 GtkWidget *vbox, *hbox; 65 GtkWidget *vbox, *hbox;
66 GtkAdjustment *adj; 66 GtkAdjustment *adj;
67 GtkWidget *spinner, *button; 67 GtkWidget *spinner, *button;
95 95
96 gtk_widget_show_all(ret); 96 gtk_widget_show_all(ret);
97 return ret; 97 return ret;
98 } 98 }
99 99
100 static gboolean
101 plugin_load(GaimPlugin *plugin)
102 {
103 GList *cnvs;
104 struct gaim_conversation *c;
100 105
101 char *gaim_plugin_init(GModule *h) { 106 for (cnvs = gaim_get_conversations(); cnvs != NULL; cnvs = cnvs->next) {
102 GList *cnvs = gaim_get_conversations();
103 struct gaim_conversation *c;
104 handle = h;
105
106 while (cnvs) {
107 c = cnvs->data; 107 c = cnvs->data;
108 timestamp_new_convo(c->name); 108 timestamp_new_convo(c->name);
109 cnvs = cnvs->next;
110 } 109 }
111 gaim_signal_connect(handle, event_new_conversation, timestamp_new_convo, NULL);
112 110
113 return NULL; 111 gaim_signal_connect(plugin, event_new_conversation,
112 timestamp_new_convo, NULL);
113
114 return TRUE;
114 } 115 }
115 116
116 void gaim_plugin_remove() { 117 static gboolean
118 plugin_unload(GaimPlugin *plugin)
119 {
117 GSList *to; 120 GSList *to;
118 to = timestamp_timeouts; 121
119 while (to) { 122 for (to = timestamp_timeouts; to != NULL; to = to->next)
120 g_source_remove(GPOINTER_TO_INT(to->data)); 123 g_source_remove(GPOINTER_TO_INT(to->data));
121 to = to->next; 124
122 }
123 g_slist_free(timestamp_timeouts); 125 g_slist_free(timestamp_timeouts);
126
127 return TRUE;
124 } 128 }
125 129
126 struct gaim_plugin_description desc; 130 static GaimGtkPluginUiInfo ui_info =
127 struct gaim_plugin_description *gaim_plugin_desc() { 131 {
128 desc.api_version = PLUGIN_API_VERSION; 132 get_config_frame
129 desc.name = g_strdup(_("Timestamp")); 133 };
130 desc.version = g_strdup(VERSION); 134
131 desc.description = g_strdup(_("Adds iChat-style timestamps to conversations every N minutes.")); 135 static GaimPluginInfo info =
132 desc.authors = g_strdup("Sean Egan &lt;bj91704@binghamton.edu>"); 136 {
133 desc.url = g_strdup(WEBSITE); 137 2, /**< api_version */
134 return &desc; 138 GAIM_PLUGIN_STANDARD, /**< type */
139 GAIM_GTK_PLUGIN_TYPE, /**< ui_requirement */
140 0, /**< flags */
141 NULL, /**< dependencies */
142 GAIM_PRIORITY_DEFAULT, /**< priority */
143
144 TIMESTAMP_PLUGIN_ID, /**< id */
145 N_("Timestamp"), /**< name */
146 VERSION, /**< version */
147 /** summary */
148 N_("Adds iChat-style timestamps to conversations every N minutes."),
149 /** description */
150 N_("Adds iChat-style timestamps to conversations every N minutes."),
151 "Sean Egan <bj91704@binghamton.edu>", /**< author */
152 WEBSITE, /**< homepage */
153
154 plugin_load, /**< load */
155 plugin_unload, /**< unload */
156 NULL, /**< destroy */
157
158 &ui_info, /**< ui_info */
159 NULL /**< extra_info */
160 };
161
162 static void
163 __init_plugin(GaimPlugin *plugin)
164 {
135 } 165 }
166
167 GAIM_INIT_PLUGIN(timestamp, __init_plugin, info);