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/
| 15230 | 1 | /* |
| 2 | * BuddyNote - Store notes on particular buddies | |
| 3 | * Copyright (C) 2004 Stu Tomlinson <stu@nosnilmot.com> | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU General Public License | |
| 7 | * as published by the Free Software Foundation; either version 2 | |
| 8 | * of the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This program is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 | * GNU General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU General Public License | |
| 16 | * 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:
17708
diff
changeset
|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301, USA. |
| 15230 | 18 | */ |
|
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:
39959
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
| 15230 | 20 | |
|
39959
e47fcffd061b
migrate the libpurple plugins to using purple.h only
Gary Kramlich <grim@reaperworld.com>
parents:
39483
diff
changeset
|
21 | #include <purple.h> |
| 15230 | 22 | |
| 23 | static void | |
| 15884 | 24 | dont_do_it_cb(PurpleBlistNode *node, const char *note) |
| 15230 | 25 | { |
| 26 | } | |
| 27 | ||
| 28 | static void | |
| 15884 | 29 | do_it_cb(PurpleBlistNode *node, const char *note) |
| 15230 | 30 | { |
| 15884 | 31 | purple_blist_node_set_string(node, "notes", note); |
| 15230 | 32 | } |
| 33 | ||
| 34 | static void | |
| 15884 | 35 | buddynote_edit_cb(PurpleBlistNode *node, gpointer data) |
| 15230 | 36 | { |
| 37 | const char *note; | |
| 38 | ||
| 15884 | 39 | note = purple_blist_node_get_string(node, "notes"); |
| 15230 | 40 | |
|
21175
c6d76b49c206
disapproval of revision '8ba833993a115415727bb1b70362e0bd1603c169'
Richard Laager <rlaager@pidgin.im>
parents:
21174
diff
changeset
|
41 | purple_request_input(node, _("Notes"), |
| 15230 | 42 | _("Enter your notes below..."), |
| 43 | NULL, | |
| 44 | note, TRUE, FALSE, "html", | |
| 45 | _("Save"), G_CALLBACK(do_it_cb), | |
| 46 | _("Cancel"), G_CALLBACK(dont_do_it_cb), | |
|
34329
ddbc1337332c
Request API refactoring: introduce PurpleRequestCommonParameters and switch purple_request_input to it
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
21630
diff
changeset
|
47 | NULL, node); |
| 15230 | 48 | } |
| 49 | ||
| 50 | static void | |
| 15884 | 51 | buddynote_extended_menu_cb(PurpleBlistNode *node, GList **m) |
| 15230 | 52 | { |
|
39481
4db28449567d
Rename PurpleMenuAction to PurpleActionMenu
Gary Kramlich <grim@reaperworld.com>
parents:
39479
diff
changeset
|
53 | PurpleActionMenu *bna = NULL; |
| 15230 | 54 | |
|
34865
764a33b41ac7
Renamed blist node's dont_save to transient.
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
55 | if (purple_blist_node_is_transient(node)) |
|
17708
0f23250ae460
Prevent the Buddy Notes plugin from offering to edit notes on a buddy list
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16745
diff
changeset
|
56 | return; |
|
0f23250ae460
Prevent the Buddy Notes plugin from offering to edit notes on a buddy list
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16745
diff
changeset
|
57 | |
| 15230 | 58 | *m = g_list_append(*m, bna); |
|
39483
ab4728087d87
Rename purple_menu_action_* to purple_action_menu_*
Gary Kramlich <grim@reaperworld.com>
parents:
39481
diff
changeset
|
59 | bna = purple_action_menu_new(_("Edit Notes..."), PURPLE_CALLBACK(buddynote_edit_cb), NULL, NULL); |
| 15230 | 60 | *m = g_list_append(*m, bna); |
| 61 | } | |
| 62 | ||
| 36742 | 63 | static PurplePluginInfo * |
| 64 | plugin_query(GError **error) | |
| 65 | { | |
| 66 | const gchar * const authors[] = { | |
| 67 | "Stu Tomlinson <stu@nosnilmot.com>", | |
| 68 | NULL | |
| 69 | }; | |
| 70 | ||
| 71 | return purple_plugin_info_new( | |
| 72 | "id", "core-plugin_pack-buddynote", | |
| 73 | "name", N_("Buddy Notes"), | |
| 74 | "version", DISPLAY_VERSION, | |
| 75 | "category", N_("Utility"), | |
| 76 | "summary", N_("Store notes on particular buddies."), | |
| 77 | "description", N_("Adds the option to store notes for buddies on your " | |
| 78 | "buddy list."), | |
| 79 | "authors", authors, | |
| 80 | "website", PURPLE_WEBSITE, | |
| 81 | "abi-version", PURPLE_ABI_VERSION, | |
| 82 | NULL | |
| 83 | ); | |
| 84 | } | |
| 85 | ||
| 15230 | 86 | static gboolean |
| 36742 | 87 | plugin_load(PurplePlugin *plugin, GError **error) |
| 15230 | 88 | { |
| 89 | ||
| 15884 | 90 | purple_signal_connect(purple_blist_get_handle(), "blist-node-extended-menu", |
| 91 | plugin, PURPLE_CALLBACK(buddynote_extended_menu_cb), NULL); | |
| 15230 | 92 | |
| 93 | return TRUE; | |
| 94 | } | |
| 95 | ||
| 36742 | 96 | static gboolean |
| 97 | plugin_unload(PurplePlugin *plugin, GError **error) | |
| 15230 | 98 | { |
| 36742 | 99 | return TRUE; |
| 15230 | 100 | } |
| 101 | ||
| 36742 | 102 | PURPLE_PLUGIN_INIT(buddynote, plugin_query, plugin_load, plugin_unload); |