Tue, 29 Dec 2015 11:56:00 -0600
Fix the writing-im-msg callback in codeinline.c
This is similar to the fix in signals-test.c that I just commited from
Koosha Khajehmoogahi. I haven't tested it, but it's consistent with
the other signal handler in this file.
| 12055 | 1 | /* |
| 15884 | 2 | * purple |
| 12055 | 3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
| 12055 | 5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 6 | * source distribution. | |
| 7 | * | |
| 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. | |
| 12 | * | |
| 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. | |
| 17 | * | |
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
16786
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 12055 | 21 | */ |
| 22 | ||
| 23 | #include "internal.h" | |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
31294
diff
changeset
|
24 | #include "plugins.h" |
| 12055 | 25 | #include "notify.h" |
| 26 | #include "util.h" | |
| 27 | #include "version.h" | |
| 28 | ||
| 15884 | 29 | PurplePlugin *plugin_handle = NULL; |
| 12055 | 30 | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
31 | static char * |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
32 | outgoing_msg_common(const char *message) |
| 12055 | 33 | { |
| 34 | char *m; | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
35 | char **ms = g_strsplit(message, "<u>", -1); |
| 12055 | 36 | m = g_strjoinv("<font face=\"monospace\" color=\"#00b025\">", ms); |
| 37 | g_strfreev(ms); | |
| 38 | ||
| 39 | ms = g_strsplit(m, "</u>", -1); | |
| 40 | g_free(m); | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
41 | return g_strjoinv("</font>", ms); |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
42 | } |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
43 | |
|
37482
922720634101
Fix the writing-im-msg callback in codeinline.c
Richard Laager <rlaager@pidgin.im>
parents:
37148
diff
changeset
|
44 | static gboolean outgoing_msg_cb1(PurpleConversation *conv, PurpleMessage *msg, |
|
922720634101
Fix the writing-im-msg callback in codeinline.c
Richard Laager <rlaager@pidgin.im>
parents:
37148
diff
changeset
|
45 | gpointer null) |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
46 | { |
|
37482
922720634101
Fix the writing-im-msg callback in codeinline.c
Richard Laager <rlaager@pidgin.im>
parents:
37148
diff
changeset
|
47 | purple_message_set_contents(msg, |
|
922720634101
Fix the writing-im-msg callback in codeinline.c
Richard Laager <rlaager@pidgin.im>
parents:
37148
diff
changeset
|
48 | outgoing_msg_common(purple_message_get_contents(msg))); |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
49 | return FALSE; |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
50 | } |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
51 | |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
52 | static void |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
53 | outgoing_msg_cb2(PurpleAccount *account, PurpleMessage *msg, |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
54 | PurpleConversation *conv, PurpleMessageFlags flags, gpointer null) |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
55 | { |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
56 | purple_message_set_contents(msg, |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
57 | outgoing_msg_common(purple_message_get_contents(msg))); |
| 12055 | 58 | } |
| 59 | ||
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
60 | static PurplePluginInfo * |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
61 | plugin_query(GError **error) |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
62 | { |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
63 | const gchar * const authors[] = { |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
64 | "Sean Egan <seanegan@gmail.com>", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
65 | NULL |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
66 | }; |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
67 | |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
68 | return purple_plugin_info_new( |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
69 | "id", "codeinline", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
70 | "name", "Code Inline", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
71 | "version", "1.0", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
72 | "category", "Formatting", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
73 | "summary", "Formats text as code", |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
74 | "description", "Changes the formatting of any outgoing text such " |
| 36742 | 75 | "that anything underlined will be received green and " |
| 76 | "monospace.", | |
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
77 | "authors", authors, |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
78 | "website", PURPLE_WEBSITE, |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
79 | "abi-version", PURPLE_ABI_VERSION, |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
80 | NULL |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
81 | ); |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
82 | } |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
83 | |
| 12055 | 84 | static gboolean |
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
85 | plugin_load(PurplePlugin *plugin, GError **error) |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
86 | { |
| 15884 | 87 | void *handle = purple_conversations_get_handle(); |
| 12055 | 88 | plugin_handle = plugin; |
| 15884 | 89 | purple_signal_connect(handle, "writing-im-msg", plugin, |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
90 | PURPLE_CALLBACK(outgoing_msg_cb1), NULL); |
| 15884 | 91 | purple_signal_connect(handle, "sending-im-msg", plugin, |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
92 | PURPLE_CALLBACK(outgoing_msg_cb2), NULL); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13234
diff
changeset
|
93 | |
| 12055 | 94 | return TRUE; |
| 95 | } | |
| 96 | ||
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
97 | static gboolean |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
98 | plugin_unload(PurplePlugin *plugin, GError **error) |
| 12055 | 99 | { |
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
100 | return TRUE; |
|
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
101 | } |
| 12055 | 102 | |
|
36739
472bef54ba0a
Started refactoring plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
103 | PURPLE_PLUGIN_INIT(codeinline, plugin_query, plugin_load, plugin_unload); |