Sun, 16 Aug 2020 18:58:39 -0500
Fix some leaks.
Also, expand `g_ascii_dtostr` buffers to `G_ASCII_DTOSTR_BUF_SIZE`.
This is the size it's guaranteed to be under, so might as well have it be that size. It not too much bigger than the existing choice anyway.
Testing Done:
Compile only.
Reviewed at https://reviews.imfreedom.org/r/71/
| 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 | ||
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
39963
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
39959
e47fcffd061b
migrate the libpurple plugins to using purple.h only
Gary Kramlich <grim@reaperworld.com>
parents:
37482
diff
changeset
|
24 | |
|
e47fcffd061b
migrate the libpurple plugins to using purple.h only
Gary Kramlich <grim@reaperworld.com>
parents:
37482
diff
changeset
|
25 | #include <purple.h> |
| 12055 | 26 | |
| 15884 | 27 | PurplePlugin *plugin_handle = NULL; |
| 12055 | 28 | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
29 | static char * |
|
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
30 | outgoing_msg_common(const char *message) |
| 12055 | 31 | { |
| 32 | char *m; | |
|
36079
2e449140fe0b
Switch sending-im-msg to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
31294
diff
changeset
|
33 | char **ms = g_strsplit(message, "<u>", -1); |
| 12055 | 34 | m = g_strjoinv("<font face=\"monospace\" color=\"#00b025\">", ms); |
| 35 | g_strfreev(ms); | |
| 36 | ||
| 37 | ms = g_strsplit(m, "</u>", -1); | |
| 38 | g_free(m); | |
|
40514
30d9cbf04922
Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
39 | m = g_strjoinv("</font>", ms); |
|
30d9cbf04922
Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
40 | g_strfreev(ms); |
|
30d9cbf04922
Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
41 | return m; |
|
36079
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); |