comparison plugins/gaiminc.c @ 6485:70d5122bc3ff

[gaim-migrate @ 6999] Removed the old event system and replaced it with a much better signal system. There will most likely be some bugs in this, but it seems to be working for now. Plugins can now generate their own signals, and other plugins can find those plugins and connect to them. This could give plugins a form of IPC. It's also useful for other things. It's rather flexible, except for the damn marshalling, but there's no way around that that I or the glib people can see. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Mon, 18 Aug 2003 01:03:43 +0000
parents 8f94cce8faa5
children 083d1e4a9c78
comparison
equal deleted inserted replaced
6484:5ced8e111473 6485:70d5122bc3ff
5 #include <string.h> 5 #include <string.h>
6 #include "gaim.h" 6 #include "gaim.h"
7 7
8 #define GAIMINC_PLUGIN_ID "core-gaiminc" 8 #define GAIMINC_PLUGIN_ID "core-gaiminc"
9 9
10 void echo_hi(void *m) { 10 static void
11 echo_hi(void *m)
12 {
11 /* this doesn't do much, just lets you know who we are :) */ 13 /* this doesn't do much, just lets you know who we are :) */
12 show_about(NULL, NULL); 14 show_about(NULL, NULL);
13 } 15 }
14 16
15 void reverse(struct gaim_connection *gc, char **who, char **message, void *m) { 17 static void
18 reverse(struct gaim_connection *gc, char **who, char **message, void *m)
19 {
16 /* this will drive you insane. whenever you receive a message, 20 /* this will drive you insane. whenever you receive a message,
17 * the text of the message (HTML and all) will be reversed. */ 21 * the text of the message (HTML and all) will be reversed. */
18 int i, l; 22 int i, l;
19 char tmp; 23 char tmp;
20 24
32 (*message)[i] = (*message)[l - i - 1]; 36 (*message)[i] = (*message)[l - i - 1];
33 (*message)[l - i - 1] = tmp; 37 (*message)[l - i - 1] = tmp;
34 } 38 }
35 } 39 }
36 40
37 void bud(struct gaim_connection *gc, char *who, void *m) { 41 static void
42 bud(struct gaim_connection *gc, char *who, void *m)
43 {
38 /* whenever someone comes online, it sends them a message. if i 44 /* whenever someone comes online, it sends them a message. if i
39 * cared more, i'd make it so it popped up on your screen too */ 45 * cared more, i'd make it so it popped up on your screen too */
40 serv_send_im(gc, who, "Hello!", -1, 0); 46 serv_send_im(gc, who, "Hello!", -1, 0);
41 } 47 }
42 48
46 52
47 static gboolean 53 static gboolean
48 plugin_load(GaimPlugin *plugin) 54 plugin_load(GaimPlugin *plugin)
49 { 55 {
50 /* this is for doing something fun when we sign on */ 56 /* this is for doing something fun when we sign on */
51 gaim_signal_connect(plugin, event_signon, echo_hi, NULL); 57 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
58 plugin, GAIM_CALLBACK(echo_hi), NULL);
52 59
53 /* this is for doing something fun when we get a message */ 60 /* this is for doing something fun when we get a message */
54 gaim_signal_connect(plugin, event_im_recv, reverse, NULL); 61 gaim_signal_connect(gaim_conversations_get_handle(), "received-im",
62 plugin, GAIM_CALLBACK(reverse), NULL);
55 63
56 /* this is for doing something fun when a buddy comes online */ 64 /* this is for doing something fun when a buddy comes online */
57 gaim_signal_connect(plugin, event_buddy_signon, bud, NULL); 65 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on",
66 plugin, GAIM_CALLBACK(bud), NULL);
58 67
59 return TRUE; 68 return TRUE;
60 } 69 }
61 70
62 static GaimPluginInfo info = 71 static GaimPluginInfo info =
78 "- It tells you who wrote the program when you log in\n" 87 "- It tells you who wrote the program when you log in\n"
79 "- It reverses all incoming text\n" 88 "- It reverses all incoming text\n"
80 "- It sends a message to people on your list immediately" 89 "- It sends a message to people on your list immediately"
81 " when they sign on"), 90 " when they sign on"),
82 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ 91 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */
83 GAIM_WEBSITE, /**< homepage */ 92 GAIM_WEBSITE, /**< homepage */
84 93
85 plugin_load, /**< load */ 94 plugin_load, /**< load */
86 NULL, /**< unload */ 95 NULL, /**< unload */
87 NULL, /**< destroy */ 96 NULL, /**< destroy */
88 97
89 NULL, /**< ui_info */ 98 NULL, /**< ui_info */
90 NULL /**< extra_info */ 99 NULL /**< extra_info */
91 }; 100 };