libpurple/purpleoptions.c

Thu, 07 Aug 2025 21:32:18 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 07 Aug 2025 21:32:18 -0500
changeset 43300
0604c6839974
parent 42594
eddde70cedd8
permissions
-rw-r--r--

Clean up and modernize PurpleImage

Testing Done:
Ran the tests under valgrind and called in the turtles.

Reviewed at https://reviews.imfreedom.org/r/4074/

40727
9389ba16cf40 Rename options.[ch] to purpleoptions.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
1 /*
9389ba16cf40 Rename options.[ch] to purpleoptions.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
2 * Purple - Internet Messaging Library
9389ba16cf40 Rename options.[ch] to purpleoptions.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
12 * any later version.
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
17 * more details.
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42478
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24
40727
9389ba16cf40 Rename options.[ch] to purpleoptions.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
25 #include "purpleoptions.h"
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
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: 39024
diff changeset
27 #include "debug.h"
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
28 #include "network.h"
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: 39024
diff changeset
29 #include "util.h"
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
30
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 /******************************************************************************
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 * Callbacks
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 *****************************************************************************/
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 static gboolean
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41127
diff changeset
35 purple_options_force_online_cb(G_GNUC_UNUSED const char *option_name,
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41127
diff changeset
36 G_GNUC_UNUSED const char *value,
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41127
diff changeset
37 G_GNUC_UNUSED gpointer data,
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41127
diff changeset
38 G_GNUC_UNUSED GError **error)
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
39 {
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
40 purple_network_force_online();
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
41
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
42 return TRUE;
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
43 }
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
44
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 /******************************************************************************
40727
9389ba16cf40 Rename options.[ch] to purpleoptions.[ch]
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
46 * Public API
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 *****************************************************************************/
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 GOptionGroup *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 purple_get_option_group(void) {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 GOptionGroup *group = NULL;
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 GOptionEntry entries[] = {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 {
42478
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
53 .long_name = "force-online",
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
54 .short_name = 'f',
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
55 .flags = G_OPTION_FLAG_NO_ARG,
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
56 .arg = G_OPTION_ARG_CALLBACK,
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
57 .arg_data = &purple_options_force_online_cb,
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
58 .description = _("force online, regardless of network status"),
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 },
42478
0f3a16f3ce7f Fix warnings from clang
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41960
diff changeset
60 G_OPTION_ENTRY_NULL,
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 };
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 group = g_option_group_new(
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 "libpurple",
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 _("LibPurple options"),
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 _("Show LibPurple Options"),
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 NULL,
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 NULL
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 );
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 g_option_group_add_entries(group, entries);
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 return group;
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 }

mercurial