libpurple/plugins/codeinline.c

branch
soc.2013.gobjectification.plugins
changeset 37148
50f361d39a1e
parent 36742
5d43951cabc0
parent 36079
2e449140fe0b
child 37482
922720634101
equal deleted inserted replaced
37147:6037d5c3a06c 37148:50f361d39a1e
26 #include "util.h" 26 #include "util.h"
27 #include "version.h" 27 #include "version.h"
28 28
29 PurplePlugin *plugin_handle = NULL; 29 PurplePlugin *plugin_handle = NULL;
30 30
31 static gboolean outgoing_msg_cb(PurpleAccount *account, const char *who, char **message, 31 static char *
32 PurpleConversation *conv, PurpleMessageFlags flags, gpointer null) 32 outgoing_msg_common(const char *message)
33 { 33 {
34 char *m; 34 char *m;
35 char **ms = g_strsplit(*message, "<u>", -1); 35 char **ms = g_strsplit(message, "<u>", -1);
36 m = g_strjoinv("<font face=\"monospace\" color=\"#00b025\">", ms); 36 m = g_strjoinv("<font face=\"monospace\" color=\"#00b025\">", ms);
37 g_strfreev(ms); 37 g_strfreev(ms);
38 38
39 ms = g_strsplit(m, "</u>", -1); 39 ms = g_strsplit(m, "</u>", -1);
40 g_free(m); 40 g_free(m);
41 m = g_strjoinv("</font>", ms); 41 return g_strjoinv("</font>", ms);
42 g_free(*message); 42 }
43 *message = m; 43
44 return FALSE; 44 static gboolean outgoing_msg_cb1(PurpleAccount *account, const char *who, char **message,
45 PurpleConversation *conv, PurpleMessageFlags flags, gpointer null)
46 {
47 char *m;
48
49 m = outgoing_msg_common(*message);
50 g_free(*message);
51 *message = m;
52
53 return FALSE;
54 }
55
56 static void
57 outgoing_msg_cb2(PurpleAccount *account, PurpleMessage *msg,
58 PurpleConversation *conv, PurpleMessageFlags flags, gpointer null)
59 {
60 purple_message_set_contents(msg,
61 outgoing_msg_common(purple_message_get_contents(msg)));
45 } 62 }
46 63
47 static PurplePluginInfo * 64 static PurplePluginInfo *
48 plugin_query(GError **error) 65 plugin_query(GError **error)
49 { 66 {
72 plugin_load(PurplePlugin *plugin, GError **error) 89 plugin_load(PurplePlugin *plugin, GError **error)
73 { 90 {
74 void *handle = purple_conversations_get_handle(); 91 void *handle = purple_conversations_get_handle();
75 plugin_handle = plugin; 92 plugin_handle = plugin;
76 purple_signal_connect(handle, "writing-im-msg", plugin, 93 purple_signal_connect(handle, "writing-im-msg", plugin,
77 PURPLE_CALLBACK(outgoing_msg_cb), NULL); 94 PURPLE_CALLBACK(outgoing_msg_cb1), NULL);
78 purple_signal_connect(handle, "sending-im-msg", plugin, 95 purple_signal_connect(handle, "sending-im-msg", plugin,
79 PURPLE_CALLBACK(outgoing_msg_cb), NULL); 96 PURPLE_CALLBACK(outgoing_msg_cb2), NULL);
80 97
81 return TRUE; 98 return TRUE;
82 } 99 }
83 100
84 static gboolean 101 static gboolean

mercurial