libpurple/options.c

Fri, 01 May 2020 12:13:35 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 01 May 2020 12:13:35 -0500
changeset 40439
e9838d634d5e
parent 39024
3338d8afcad6
child 40441
f23c7e772667
permissions
-rw-r--r--

Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h

38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /* purple
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Purple is the legal property of its developers, whose names are too numerous
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * to list here. Please refer to the COPYRIGHT file distributed with this
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * source distribution.
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * (at your option) any later version.
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * GNU General Public License for more details.
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 */
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 #include "internal.h"
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "options.h"
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
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
26 #include "debug.h"
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
27 #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
28 #include "util.h"
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
29
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 /******************************************************************************
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 * Callbacks
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 *****************************************************************************/
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 static gboolean
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
34 debug_cb(const gchar *option_name, const gchar *value,
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 gpointer data, GError **error)
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 purple_debug_set_enabled(TRUE);
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 if (purple_strequal(value, "colored")) {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 purple_debug_set_colored(TRUE);
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 }
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 return TRUE;
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 }
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
46 static gboolean
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
47 force_online_cb(const gchar *option_name, const gchar *value,
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
48 gpointer data, GError **error)
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
49 {
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
50 purple_network_force_online();
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
51
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
52 return TRUE;
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
53 }
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
54
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 /******************************************************************************
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 * API
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 *****************************************************************************/
38805
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
58
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
59 /**
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
60 * purple_get_option_group:
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
61 *
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
62 * Returns a #GOptionGroup for the commandline arguments recognized by
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
63 * LibPurple. You should add this option group to your #GOptionContext with
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
64 * g_option_context_add_group(), if you are using g_option_context_parse() to
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
65 * parse your commandline arguments.
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
66 *
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
67 * Return Value: (transfer full): a #GOptionGroup for the commandline arguments
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
68 * recognized by LibPurple.
872e6924336e Update docs!
Gary Kramlich <grim@reaperworld.com>
parents: 38803
diff changeset
69 */
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 GOptionGroup *
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 purple_get_option_group(void) {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 GOptionGroup *group = NULL;
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 GOptionEntry entries[] = {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 {
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
76 G_OPTION_ARG_CALLBACK, &debug_cb,
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 _("print debugging messages to stdout"),
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 _("[colored]")
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
79 }, {
39024
3338d8afcad6 options: Fix flags for force-online
Mike Ruprecht <cmaiku@gmail.com>
parents: 38973
diff changeset
80 "force-online", 'f', G_OPTION_FLAG_NO_ARG,
3338d8afcad6 options: Fix flags for force-online
Mike Ruprecht <cmaiku@gmail.com>
parents: 38973
diff changeset
81 G_OPTION_ARG_CALLBACK, &force_online_cb,
38803
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
82 _("force online, regardless of network status"),
60c745a9e06d Move the force online option into the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents: 38802
diff changeset
83 NULL
38973
b4ebaec25764 libpurple/options.c: NULL terminate GOptionEntry array
Mike Ruprecht <cmaiku@gmail.com>
parents: 38805
diff changeset
84 }, {
b4ebaec25764 libpurple/options.c: NULL terminate GOptionEntry array
Mike Ruprecht <cmaiku@gmail.com>
parents: 38805
diff changeset
85 NULL
38802
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 },
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 };
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 group = g_option_group_new(
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 "libpurple",
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 _("LibPurple options"),
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 _("Show LibPurple Options"),
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 NULL,
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 NULL
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 );
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 g_option_group_add_entries(group, entries);
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 return group;
afb1c8302e49 The start of the libpurple option group
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 }

mercurial