[gaim-migrate @ 2949]
[pidgin-git.git] / plugins / gaiminc.c
blobf3ec28cfaf5927175be097d92533b7a6e48da4f6
1 #define GAIM_PLUGINS
3 #include <gtk/gtk.h>
4 #include <time.h>
5 #include <stdio.h>
6 #include <fcntl.h>
7 #include <string.h>
8 #include "gaim.h"
10 void echo_hi(void *m) {
11 /* this doesn't do much, just lets you know who we are :) */
12 show_about(NULL, NULL);
15 void reverse(struct gaim_connection *gc, char **who, char **message, void *m) {
16 /* this will drive you insane. whenever you receive a message,
17 * the text of the message (HTML and all) will be reversed. */
18 int i, l;
19 char tmp;
21 /* this check is necessary in case bad plugins do bad things */
22 if (message == NULL || *message == NULL)
23 return;
25 l = strlen(*message);
27 if (!strcmp(*who, gc->username))
28 return;
30 for (i = 0; i < l/2; i++) {
31 tmp = (*message)[i];
32 (*message)[i] = (*message)[l - i - 1];
33 (*message)[l - i - 1] = tmp;
37 void bud(struct gaim_connection *gc, char *who, void *m) {
38 /* 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 */
40 serv_send_im(gc, who, "Hello!", 0);
43 char *gaim_plugin_init(GModule *handle) {
44 /* this is for doing something fun when we sign on */
45 gaim_signal_connect(handle, event_signon, echo_hi, NULL);
47 /* this is for doing something fun when we get a message */
48 gaim_signal_connect(handle, event_im_recv, reverse, NULL);
50 /* this is for doing something fun when a buddy comes online */
51 gaim_signal_connect(handle, event_buddy_signon, bud, NULL);
53 return NULL;
56 char *name() {
57 return "Gaim Demonstration Plugin";
60 char *description() {
61 return "This is a really cool plugin that does a lot of stuff:\n"
62 "- It tells you who wrote the program when you log in\n"
63 "- It reverses all incoming text\n"
64 "- It sends a message to people on your list immediately"
65 " when they sign on";