mark PurpleImageClass as private
[pidgin-git.git] / pidgin / plugins / pidgininc.c
blobda5610fece9d9b27dbda4aefff8c8455cff9ea6b
1 /* When writing a third-party plugin, do not include libpurple's internal.h
2 * included below. This file is for internal libpurple use only. We're including
3 * it here for our own convenience. */
4 #include "internal.h"
6 /* This file includes all the libpurple headers */
7 #include <purple.h>
9 /* include UI for pidgin_dialogs_about() */
10 #include "gtkplugin.h"
11 #include "gtkdialogs.h"
13 #define PURPLEINC_PLUGIN_ID "core-purpleinc"
15 static void
16 echo_hi(PurpleConnection *gc)
18 /* this doesn't do much, just lets you know who we are :) */
19 pidgin_dialogs_about();
22 static gboolean
23 reverse(PurpleAccount *account, char **who, char **message,
24 PurpleConversation *conv, int *flags)
26 /* this will drive you insane. whenever you receive a message,
27 * the text of the message (HTML and all) will be reversed. */
28 int i, l;
29 char tmp;
31 /* this check is necessary in case bad plugins do bad things */
32 if (message == NULL || *message == NULL)
33 return FALSE;
35 l = strlen(*message);
37 if (purple_strequal(*who, purple_account_get_username(account)))
38 return FALSE;
40 for (i = 0; i < l/2; i++) {
41 tmp = (*message)[i];
42 (*message)[i] = (*message)[l - i - 1];
43 (*message)[l - i - 1] = tmp;
45 return FALSE;
48 static void
49 bud(PurpleBuddy *who)
51 PurpleAccount *acct = purple_buddy_get_account(who);
52 PurpleIMConversation *im = purple_im_conversation_new(acct,
53 purple_buddy_get_name(who));
55 purple_conversation_send(PURPLE_CONVERSATION(im), "Hello!");
59 * EXPORTED FUNCTIONS
62 static PidginPluginInfo *
63 plugin_query(GError **error)
65 const gchar * const authors[] = {
66 "Eric Warmenhoven <eric@warmenhoven.org>",
67 NULL
70 return pidgin_plugin_info_new(
71 "id", PURPLEINC_PLUGIN_ID,
72 "name", N_("Pidgin Demonstration Plugin"),
73 "version", DISPLAY_VERSION,
74 "category", N_("Example"),
75 "summary", N_("An example plugin that does stuff - see the description."),
76 "description", N_("This is a really cool plugin that does a lot of stuff:\n"
77 "- It tells you who wrote the program when you log in\n"
78 "- It reverses all incoming text\n"
79 "- It sends a message to people on your list immediately"
80 " when they sign on"),
81 "authors", authors,
82 "website", PURPLE_WEBSITE,
83 "abi-version", PURPLE_ABI_VERSION,
84 NULL
88 static gboolean
89 plugin_load(PurplePlugin *plugin, GError **error)
91 /* this is for doing something fun when we sign on */
92 purple_signal_connect(purple_connections_get_handle(), "signed-on",
93 plugin, PURPLE_CALLBACK(echo_hi), NULL);
95 /* this is for doing something fun when we get a message */
96 purple_signal_connect(purple_conversations_get_handle(), "receiving-im-msg",
97 plugin, PURPLE_CALLBACK(reverse), NULL);
99 /* this is for doing something fun when a buddy comes online */
100 purple_signal_connect(purple_blist_get_handle(), "buddy-signed-on",
101 plugin, PURPLE_CALLBACK(bud), NULL);
103 return TRUE;
106 static gboolean
107 plugin_unload(PurplePlugin *plugin, GError **error)
109 return TRUE;
112 PURPLE_PLUGIN_INIT(purpleinc, plugin_query, plugin_load, plugin_unload);