merge of 'd03c32ee4bd5625c28af8c8b33920944d499eef6'
[pidgin-git.git] / libpurple / plugins / codeinline.c
blob7493e0fdb27fce1c9a053cb4859d3fce9c9b73f6
1 /*
2 * purple
4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include "internal.h"
24 #include "plugin.h"
25 #include "notify.h"
26 #include "util.h"
27 #include "version.h"
29 PurplePlugin *plugin_handle = NULL;
31 static gboolean outgoing_msg_cb(PurpleAccount *account, const char *who, char **message,
32 PurpleConversation *conv, PurpleMessageFlags flags, gpointer null)
34 char *m;
35 char **ms = g_strsplit(*message, "<u>", -1);
36 m = g_strjoinv("<font face=\"monospace\" color=\"#00b025\">", ms);
37 g_strfreev(ms);
39 ms = g_strsplit(m, "</u>", -1);
40 g_free(m);
41 m = g_strjoinv("</font>", ms);
42 g_free(*message);
43 *message = m;
44 return FALSE;
47 static gboolean
48 plugin_load(PurplePlugin *plugin)
50 void *handle = purple_conversations_get_handle();
51 plugin_handle = plugin;
52 purple_signal_connect(handle, "writing-im-msg", plugin,
53 PURPLE_CALLBACK(outgoing_msg_cb), NULL);
54 purple_signal_connect(handle, "sending-im-msg", plugin,
55 PURPLE_CALLBACK(outgoing_msg_cb), NULL);
57 return TRUE;
61 static PurplePluginInfo info =
63 PURPLE_PLUGIN_MAGIC,
64 PURPLE_MAJOR_VERSION,
65 PURPLE_MINOR_VERSION,
66 PURPLE_PLUGIN_STANDARD,
67 NULL,
69 NULL,
70 PURPLE_PRIORITY_DEFAULT,
71 "codeinline",
72 "Code Inline",
73 "1.0",
74 "Formats text as code",
75 "Changes the formatting of any outgoing text such that "
76 "anything underlined will be received green and monospace.",
77 "Sean Egan <seanegan@gmail.com>",
78 PURPLE_WEBSITE,
79 plugin_load,
80 NULL,
81 NULL,
82 NULL,
83 NULL,
84 NULL,
85 NULL,
86 /* padding */
87 NULL,
88 NULL,
89 NULL,
90 NULL
93 static void
94 init_plugin(PurplePlugin *plugin)
98 PURPLE_INIT_PLUGIN(codeinline, init_plugin, info)