Mercurial > pidgin.yaz
annotate plugins/gaiminc.c @ 6982:083d1e4a9c78
[gaim-migrate @ 7538]
This is Mr. Holland's Opus. And by Mr. Holland I mean Robot101. He
rewrote the coreish IM image support so that the binary data gets
ripped out in the prpl and put in an imgstore instead of just being
passed in the same huge as char string as the actual message. This
is good because it's prpl agnostic, or something. It also means
we don't have a silly length of "-1" with pretty much every send or
receive IM function.
It should be crash free, bug free, and memleak free, but additional
testing is always a good thing.
If you like good stuff then you'll love this patch. But don't take
my word for it--ba dun dunt!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 27 Sep 2003 19:17:21 +0000 |
parents | 70d5122bc3ff |
children | d7fd01f7bdcb |
rev | line source |
---|---|
5255 | 1 //#include <gtk/gtk.h> |
91 | 2 #include <time.h> |
3 #include <stdio.h> | |
4 #include <fcntl.h> | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
5 #include <string.h> |
91 | 6 #include "gaim.h" |
7 | |
5255 | 8 #define GAIMINC_PLUGIN_ID "core-gaiminc" |
9 | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 static void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
11 echo_hi(void *m) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
12 { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
13 /* this doesn't do much, just lets you know who we are :) */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
14 show_about(NULL, NULL); |
91 | 15 } |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
91
diff
changeset
|
16 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
17 static void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
18 reverse(struct gaim_connection *gc, char **who, char **message, void *m) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
19 { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
20 /* this will drive you insane. whenever you receive a message, |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
21 * the text of the message (HTML and all) will be reversed. */ |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
22 int i, l; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
23 char tmp; |
99
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
24 |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
25 /* this check is necessary in case bad plugins do bad things */ |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
26 if (message == NULL || *message == NULL) |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
27 return; |
f810fc7d423f
[gaim-migrate @ 109]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
28 |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
29 l = strlen(*message); |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
30 |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
99
diff
changeset
|
31 if (!strcmp(*who, gc->username)) |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
32 return; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
33 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
34 for (i = 0; i < l/2; i++) { |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
35 tmp = (*message)[i]; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
36 (*message)[i] = (*message)[l - i - 1]; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
37 (*message)[l - i - 1] = tmp; |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
38 } |
92
f3c6cf79f651
[gaim-migrate @ 102]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
91
diff
changeset
|
39 } |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
40 |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
41 static void |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
42 bud(struct gaim_connection *gc, char *who, void *m) |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
43 { |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
44 /* whenever someone comes online, it sends them a message. if i |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
45 * cared more, i'd make it so it popped up on your screen too */ |
6982 | 46 serv_send_im(gc, who, "Hello!", 0); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
47 } |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
48 |
5255 | 49 /* |
50 * EXPORTED FUNCTIONS | |
51 */ | |
52 | |
53 static gboolean | |
54 plugin_load(GaimPlugin *plugin) | |
55 { | |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
56 /* this is for doing something fun when we sign on */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
57 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
58 plugin, GAIM_CALLBACK(echo_hi), NULL); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
59 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
60 /* this is for doing something fun when we get a message */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
61 gaim_signal_connect(gaim_conversations_get_handle(), "received-im", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
62 plugin, GAIM_CALLBACK(reverse), NULL); |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
63 |
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
64 /* this is for doing something fun when a buddy comes online */ |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
65 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", |
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
66 plugin, GAIM_CALLBACK(bud), NULL); |
1047
ece2d1543b20
[gaim-migrate @ 1057]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
99
diff
changeset
|
67 |
5255 | 68 return TRUE; |
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
92
diff
changeset
|
69 } |
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
70 |
5255 | 71 static GaimPluginInfo info = |
72 { | |
73 2, /**< api_version */ | |
74 GAIM_PLUGIN_STANDARD, /**< type */ | |
75 NULL, /**< ui_requirement */ | |
76 0, /**< flags */ | |
77 NULL, /**< dependencies */ | |
78 GAIM_PRIORITY_DEFAULT, /**< priority */ | |
79 | |
80 GAIMINC_PLUGIN_ID, /**< id */ | |
81 N_("Gaim Demonstration Plugin"), /**< name */ | |
82 VERSION, /**< version */ | |
83 /** summary */ | |
84 N_("An example plugin that does stuff - see the description."), | |
85 /** description */ | |
86 N_("This is a really cool plugin that does a lot of stuff:\n" | |
87 "- It tells you who wrote the program when you log in\n" | |
88 "- It reverses all incoming text\n" | |
89 "- It sends a message to people on your list immediately" | |
90 " when they sign on"), | |
91 "Eric Warmenhoven <eric@warmenhoven.org>", /**< author */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
92 GAIM_WEBSITE, /**< homepage */ |
5255 | 93 |
94 plugin_load, /**< load */ | |
6485
70d5122bc3ff
[gaim-migrate @ 6999]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
95 NULL, /**< unload */ |
5255 | 96 NULL, /**< destroy */ |
97 | |
98 NULL, /**< ui_info */ | |
99 NULL /**< extra_info */ | |
100 }; | |
101 | |
102 static void | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5255
diff
changeset
|
103 init_plugin(GaimPlugin *plugin) |
5255 | 104 { |
3551 | 105 } |
106 | |
6063 | 107 GAIM_INIT_PLUGIN(gaiminc, init_plugin, info) |