comparison plugins/gaiminc.c @ 7746:d7fd01f7bdcb

[gaim-migrate @ 8391] " These patches fix the raw plugin and the gaiminc plugins so that they compile and function correctly." --Paul A (darkrain) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 04 Dec 2003 12:12:11 +0000
parents 083d1e4a9c78
children d7b8eb1f0a18
comparison
equal deleted inserted replaced
7745:9cc221f68107 7746:d7fd01f7bdcb
1 //#include <gtk/gtk.h> 1 #include "internal.h"
2 #include <time.h> 2 #include "plugin.h"
3 #include <stdio.h> 3
4 #include <fcntl.h> 4 #include "account.h"
5 #include <string.h> 5 #include "connection.h"
6 #include "gaim.h" 6 #include "conversation.h"
7
8 /* include UI for show_about() */
9 #include "gtkplugin.h"
10 #include "ui.h"
7 11
8 #define GAIMINC_PLUGIN_ID "core-gaiminc" 12 #define GAIMINC_PLUGIN_ID "core-gaiminc"
9 13
10 static void 14 static void
11 echo_hi(void *m) 15 echo_hi(GaimConnection *gc)
12 { 16 {
13 /* this doesn't do much, just lets you know who we are :) */ 17 /* this doesn't do much, just lets you know who we are :) */
14 show_about(NULL, NULL); 18 show_about(NULL, NULL);
15 } 19 }
16 20
17 static void 21 static gboolean
18 reverse(struct gaim_connection *gc, char **who, char **message, void *m) 22 reverse(GaimAccount *account, char **who, char **message, int *flags)
19 { 23 {
20 /* this will drive you insane. whenever you receive a message, 24 /* this will drive you insane. whenever you receive a message,
21 * the text of the message (HTML and all) will be reversed. */ 25 * the text of the message (HTML and all) will be reversed. */
22 int i, l; 26 int i, l;
23 char tmp; 27 char tmp;
24 28
25 /* this check is necessary in case bad plugins do bad things */ 29 /* this check is necessary in case bad plugins do bad things */
26 if (message == NULL || *message == NULL) 30 if (message == NULL || *message == NULL)
27 return; 31 return FALSE;
28 32
29 l = strlen(*message); 33 l = strlen(*message);
30 34
31 if (!strcmp(*who, gc->username)) 35 if (!strcmp(*who, gaim_account_get_username(account)))
32 return; 36 return FALSE;
33 37
34 for (i = 0; i < l/2; i++) { 38 for (i = 0; i < l/2; i++) {
35 tmp = (*message)[i]; 39 tmp = (*message)[i];
36 (*message)[i] = (*message)[l - i - 1]; 40 (*message)[i] = (*message)[l - i - 1];
37 (*message)[l - i - 1] = tmp; 41 (*message)[l - i - 1] = tmp;
38 } 42 }
43 return FALSE;
39 } 44 }
40 45
41 static void 46 static void
42 bud(struct gaim_connection *gc, char *who, void *m) 47 bud(GaimBuddy *who)
43 { 48 {
44 /* whenever someone comes online, it sends them a message. if i 49 GaimAccount *acct = who->account;
45 * cared more, i'd make it so it popped up on your screen too */ 50 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_IM, acct, who->name);
46 serv_send_im(gc, who, "Hello!", 0); 51
52 gaim_conv_im_send(GAIM_CONV_IM(conv), "Hello!");
47 } 53 }
48 54
49 /* 55 /*
50 * EXPORTED FUNCTIONS 56 * EXPORTED FUNCTIONS
51 */ 57 */
56 /* this is for doing something fun when we sign on */ 62 /* this is for doing something fun when we sign on */
57 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", 63 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
58 plugin, GAIM_CALLBACK(echo_hi), NULL); 64 plugin, GAIM_CALLBACK(echo_hi), NULL);
59 65
60 /* this is for doing something fun when we get a message */ 66 /* this is for doing something fun when we get a message */
61 gaim_signal_connect(gaim_conversations_get_handle(), "received-im", 67 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg",
62 plugin, GAIM_CALLBACK(reverse), NULL); 68 plugin, GAIM_CALLBACK(reverse), NULL);
63 69
64 /* this is for doing something fun when a buddy comes online */ 70 /* this is for doing something fun when a buddy comes online */
65 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", 71 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on",
66 plugin, GAIM_CALLBACK(bud), NULL); 72 plugin, GAIM_CALLBACK(bud), NULL);