Thu, 09 May 2024 20:50:45 -0500
Remove the media implementation from the Demo protocol plugin
This API will be rewritten in the future, but keeping the old version around
isn't helping anything.
Testing Done:
Dialed TMNT
Reviewed at https://reviews.imfreedom.org/r/3174/
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
4 | * |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
9 | * |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
14 | * |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
17 | */ |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
18 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
20 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
21 | #include "purpledemoprotocol.h" |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
22 | #include "purpledemoprotocolactions.h" |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
23 | #include "purpledemoresource.h" |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
24 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
25 | /****************************************************************************** |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
26 | * Connection failure action implementations |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
28 | #define REAPER_BUDDY_NAME ("Gary") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
29 | #define DEFAULT_REAP_TIME (5) /* seconds */ |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
30 | #define FATAL_TICK_STR N_("Reaping connection in %d second...") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
31 | #define FATAL_TICK_PLURAL_STR N_("Reaping connection in %d seconds...") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
32 | #define FATAL_DISCONNECT_STR N_("%s reaped the connection") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
33 | #define TEMPORARY_TICK_STR N_("Pruning connection in %d second...") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
34 | #define TEMPORARY_TICK_PLURAL_STR N_("Pruning connection in %d seconds...") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
35 | #define TEMPORARY_DISCONNECT_STR N_("%s pruned the connection") |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
36 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
37 | static gboolean |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
38 | purple_demo_protocol_failure_tick(gpointer data, |
|
41463
6b13615303cc
Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
39 | PurpleConnectionError error_code, |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
40 | const gchar *tick_str, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
41 | const gchar *tick_plural_str, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
42 | const gchar *disconnect_str) |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
43 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
44 | PurpleConnection *connection = PURPLE_CONNECTION(data); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
45 | PurpleAccount *account = purple_connection_get_account(connection); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
46 | gchar *message = NULL; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
47 | gint timeout = 0; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
48 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
49 | timeout = GPOINTER_TO_INT(g_object_steal_data(G_OBJECT(connection), |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
50 | "reaping-time")); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
51 | timeout--; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
52 | if(timeout > 0) { |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
53 | PurpleContact *contact = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
54 | PurpleContactManager *manager = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
55 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
56 | g_object_set_data(G_OBJECT(connection), "reaping-time", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
57 | GINT_TO_POINTER(timeout)); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
58 | |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
59 | manager = purple_contact_manager_get_default(); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
60 | contact = purple_contact_manager_find_with_username(manager, account, |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
61 | REAPER_BUDDY_NAME); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
62 | |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
63 | if(PURPLE_IS_CONTACT(contact)) { |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
64 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
65 | PurplePresence *presence = purple_contact_info_get_presence(info); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
66 | const char *format = ngettext(tick_str, tick_plural_str, timeout); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
67 | |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
68 | message = g_strdup_printf(format, timeout); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
69 | purple_presence_set_message(presence, message); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
70 | g_free(message); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
71 | } |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
72 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
73 | return G_SOURCE_CONTINUE; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
74 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
75 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
76 | message = g_strdup_printf(_(disconnect_str), REAPER_BUDDY_NAME); |
|
41463
6b13615303cc
Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
77 | purple_connection_error(connection, error_code, message); |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
78 | g_free(message); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
79 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
80 | return G_SOURCE_REMOVE; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
81 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
82 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
83 | static gboolean |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
84 | purple_demo_protocol_fatal_failure_cb(gpointer data) { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
85 | return purple_demo_protocol_failure_tick(data, |
|
41463
6b13615303cc
Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
86 | PURPLE_CONNECTION_ERROR_CUSTOM_FATAL, |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
87 | FATAL_TICK_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
88 | FATAL_TICK_PLURAL_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
89 | FATAL_DISCONNECT_STR); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
90 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
91 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
92 | static gboolean |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
93 | purple_demo_protocol_temporary_failure_cb(gpointer data) { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
94 | return purple_demo_protocol_failure_tick(data, |
|
41463
6b13615303cc
Add some custom connection errors
Gary Kramlich <grim@reaperworld.com>
parents:
41460
diff
changeset
|
95 | PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY, |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
96 | TEMPORARY_TICK_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
97 | TEMPORARY_TICK_PLURAL_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
98 | TEMPORARY_DISCONNECT_STR); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
99 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
100 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
101 | static void |
|
41968
2fc2db360044
Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41905
diff
changeset
|
102 | purple_demo_protocol_failure_action_activate(G_GNUC_UNUSED GSimpleAction *action, |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
103 | GVariant *parameter, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
104 | const gchar *tick_str, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
105 | const gchar *tick_plural_str, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
106 | GSourceFunc cb) |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
107 | { |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
108 | PurpleAccountManager *account_manager = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
109 | PurpleAccount *account = NULL; |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
110 | PurpleConnection *connection = NULL; |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
111 | PurpleContact *contact = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
112 | PurpleContactManager *contact_manager = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
113 | const char *account_id = NULL; |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
114 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
115 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
116 | g_critical("Demo failure action parameter is of incorrect type %s", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
117 | g_variant_get_type_string(parameter)); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
118 | return; |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
119 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
120 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
121 | account_id = g_variant_get_string(parameter, NULL); |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
122 | account_manager = purple_account_manager_get_default(); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
123 | account = purple_account_manager_find_by_id(account_manager, account_id); |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
124 | connection = purple_account_get_connection(account); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
125 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
126 | /* Do nothing if disconnected, or already in process of reaping. */ |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
127 | if(!PURPLE_IS_CONNECTION(connection)) { |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
128 | g_clear_object(&account); |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
129 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
130 | return; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
131 | } |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
132 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
133 | if(g_object_get_data(G_OBJECT(connection), "reaping-time")) { |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
134 | g_clear_object(&account); |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
135 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
136 | return; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
137 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
138 | |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
139 | /* Find the reaper. */ |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
140 | contact_manager = purple_contact_manager_get_default(); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
141 | contact = purple_contact_manager_find_with_username(contact_manager, |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
142 | account, |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
143 | REAPER_BUDDY_NAME); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
144 | |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
145 | if(PURPLE_IS_CONTACT(contact)) { |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
146 | PurpleContactInfo *info = PURPLE_CONTACT_INFO(contact); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
147 | PurplePresence *presence = purple_contact_info_get_presence(info); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
148 | const char *format = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
149 | char *message = NULL; |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
150 | |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
151 | format = ngettext(tick_str, tick_plural_str, DEFAULT_REAP_TIME); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
152 | message = g_strdup_printf(format, DEFAULT_REAP_TIME); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
153 | |
|
42747
801025bad2e1
Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
154 | purple_presence_set_idle(presence, FALSE); |
|
42204
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
155 | purple_presence_set_message(presence, message); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
156 | g_free(message); |
|
56b8487d9020
Port the demo protocol's actions to the new status api
Gary Kramlich <grim@reaperworld.com>
parents:
42157
diff
changeset
|
157 | } |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
158 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
159 | g_object_set_data(G_OBJECT(connection), "reaping-time", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
160 | GINT_TO_POINTER(DEFAULT_REAP_TIME)); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
161 | g_timeout_add_seconds(1, cb, connection); |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
162 | |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
163 | g_clear_object(&account); |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
164 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
165 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
166 | static void |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
167 | purple_demo_protocol_temporary_failure_action_activate(GSimpleAction *action, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
168 | GVariant *parameter, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
169 | G_GNUC_UNUSED gpointer data) |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
170 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
171 | purple_demo_protocol_failure_action_activate(action, parameter, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
172 | TEMPORARY_TICK_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
173 | TEMPORARY_TICK_PLURAL_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
174 | purple_demo_protocol_temporary_failure_cb); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
175 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
176 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
177 | static void |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
178 | purple_demo_protocol_fatal_failure_action_activate(GSimpleAction *action, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
179 | GVariant *parameter, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
180 | G_GNUC_UNUSED gpointer data) |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
181 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
182 | purple_demo_protocol_failure_action_activate(action, parameter, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
183 | FATAL_TICK_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
184 | FATAL_TICK_PLURAL_STR, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
185 | purple_demo_protocol_fatal_failure_cb); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
186 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
187 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
188 | /****************************************************************************** |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
189 | * Request API action implementations |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
190 | *****************************************************************************/ |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
191 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
192 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
193 | purple_demo_protocol_request_fields_ok_cb(G_GNUC_UNUSED gpointer data, |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
194 | PurpleRequestPage *page) |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
195 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
196 | PurpleAccount *account = NULL; |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
197 | PurpleRequestFieldList *field = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
198 | GList *list = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
199 | const char *tmp = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
200 | GString *info = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
201 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
202 | info = g_string_new(_("Basic group:\n")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
203 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
204 | g_string_append_printf(info, _("\tString: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
205 | purple_request_page_get_string(page, "string")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
206 | g_string_append_printf(info, _("\tMultiline string: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
207 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
208 | "multiline-string")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
209 | g_string_append_printf(info, _("\tMasked string: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
210 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
211 | "masked-string")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
212 | g_string_append_printf(info, _("\tAlphanumeric string: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
213 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
214 | "alphanumeric")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
215 | g_string_append_printf(info, _("\tEmail string: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
216 | purple_request_page_get_string(page, "email")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
217 | g_string_append_printf(info, _("\tInteger: %d\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
218 | purple_request_page_get_integer(page, "int")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
219 | g_string_append_printf(info, _("\tBoolean: %s\n"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
220 | purple_request_page_get_bool(page, "bool") ? |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
221 | _("TRUE") : _("FALSE")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
222 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
223 | g_string_append(info, _("Multiple-choice group:\n")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
224 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
225 | tmp = (const char *)purple_request_page_get_choice(page, "choice"); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
226 | g_string_append_printf(info, _("\tChoice: %s\n"), tmp); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
227 | |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
228 | field = PURPLE_REQUEST_FIELD_LIST(purple_request_page_get_field(page, |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
229 | "list")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
230 | list = purple_request_field_list_get_selected(field); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
231 | if(list != NULL) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
232 | tmp = (const char *)list->data; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
233 | } else { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
234 | tmp = _("(unset)"); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
235 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
236 | g_string_append_printf(info, _("\tList: %s\n"), tmp); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
237 | |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
238 | field = PURPLE_REQUEST_FIELD_LIST(purple_request_page_get_field(page, |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
239 | "multilist")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
240 | list = purple_request_field_list_get_selected(field); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
241 | g_string_append(info, _("\tMulti-list: [")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
242 | while(list != NULL) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
243 | tmp = (const char *)list->data; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
244 | g_string_append_printf(info, "%s%s", tmp, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
245 | list->next != NULL ? ", " : ""); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
246 | list = list->next; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
247 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
248 | g_string_append(info, _("]\n")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
249 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
250 | g_string_append(info, _("Special group:\n")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
251 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
252 | account = purple_request_page_get_account(page, "account"); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
253 | if(PURPLE_IS_ACCOUNT(account)) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
254 | tmp = purple_contact_info_get_name_for_display(PURPLE_CONTACT_INFO(account)); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
255 | } else { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
256 | tmp = _("(unset)"); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
257 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
258 | g_string_append_printf(info, _("\tAccount: %s\n"), tmp); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
259 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
260 | g_message(_("Successfully requested fields:\n%s"), info->str); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
261 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
262 | g_string_free(info, TRUE); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
263 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
264 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
265 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
266 | purple_demo_protocol_request_fields_cancel_cb(G_GNUC_UNUSED gpointer data, |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
267 | G_GNUC_UNUSED PurpleRequestPage *page) |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
268 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
269 | g_message(_("UI cancelled field request")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
270 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
271 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
272 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
273 | purple_demo_protocol_request_fields_activate(G_GNUC_UNUSED GSimpleAction *action, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
274 | GVariant *parameter, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
275 | G_GNUC_UNUSED gpointer data) |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
276 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
277 | PurpleConnection *connection = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
278 | const gchar *account_id = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
279 | PurpleAccountManager *manager = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
280 | PurpleAccount *account = NULL; |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
281 | PurpleRequestPage *page = NULL; |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
282 | PurpleRequestGroup *group = NULL; |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
283 | PurpleRequestField *boolfield = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
284 | PurpleRequestField *field = NULL; |
|
42139
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
285 | PurpleRequestFieldChoice *choice_field = NULL; |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
286 | PurpleRequestFieldList *list_field = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
287 | GBytes *icon = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
288 | gconstpointer icon_data = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
289 | gsize icon_len = 0; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
290 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
291 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
292 | g_critical("Demo failure action parameter is of incorrect type %s", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
293 | g_variant_get_type_string(parameter)); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
294 | return; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
295 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
296 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
297 | account_id = g_variant_get_string(parameter, NULL); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
298 | manager = purple_account_manager_get_default(); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
299 | account = purple_account_manager_find_by_id(manager, account_id); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
300 | connection = purple_account_get_connection(account); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
301 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
302 | page = purple_request_page_new(); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
303 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
304 | /* This group will contain basic fields. */ |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
305 | group = purple_request_group_new(_("Basic")); |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
306 | purple_request_page_add_group(page, group); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
307 | |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
308 | boolfield = purple_request_field_bool_new("bool", _("Sensitive?"), TRUE); |
|
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
309 | purple_request_field_set_tooltip(boolfield, |
|
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
310 | _("Allow modifying all fields.")); |
|
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
311 | purple_request_group_add_field(group, boolfield); |
|
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
312 | |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
313 | field = purple_request_field_label_new("basic-label", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
314 | _("This group contains basic fields")); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
315 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
316 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
317 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
318 | field = purple_request_field_string_new("string", _("A string"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
319 | _("default"), FALSE); |
|
42154
2557742988dc
Remove tracking of required fields
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42149
diff
changeset
|
320 | purple_request_field_set_required(field, TRUE); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
321 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
322 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
323 | field = purple_request_field_string_new("multiline-string", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
324 | _("A multiline string"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
325 | _("default"), TRUE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
326 | purple_request_group_add_field(group, field); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
327 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
328 | field = purple_request_field_string_new("masked-string", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
329 | _("A masked string"), _("default"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
330 | FALSE); |
|
42135
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
331 | purple_request_field_string_set_masked(PURPLE_REQUEST_FIELD_STRING(field), |
|
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
332 | TRUE); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
333 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
334 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
335 | field = purple_request_field_string_new("alphanumeric", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
336 | _("An alphanumeric string"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
337 | _("default"), FALSE); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
338 | purple_request_field_set_validator(field, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
339 | purple_request_field_alphanumeric_validator, |
|
42149
4de5a514b8ba
Add a PurpleRequestField:valid property and is_valid vfunc
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42140
diff
changeset
|
340 | NULL, NULL); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
341 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
342 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
343 | field = purple_request_field_string_new("email", _("An email"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
344 | _("me@example.com"), FALSE); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
345 | purple_request_field_set_validator(field, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
346 | purple_request_field_email_validator, |
|
42149
4de5a514b8ba
Add a PurpleRequestField:valid property and is_valid vfunc
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42140
diff
changeset
|
347 | NULL, NULL); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
348 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
349 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
350 | field = purple_request_field_int_new("int", _("An integer"), 123, -42, 1337); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
351 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
352 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
353 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
354 | /* This group will contain fields with multiple options. */ |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
355 | group = purple_request_group_new(_("Multiple")); |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
356 | purple_request_page_add_group(page, group); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
357 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
358 | field = purple_request_field_label_new("multiple-label", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
359 | _("This group contains fields with multiple options")); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
360 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
361 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
362 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
363 | field = purple_request_field_choice_new("choice", _("A choice"), "foo"); |
|
42139
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
364 | choice_field = PURPLE_REQUEST_FIELD_CHOICE(field); |
|
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
365 | purple_request_field_choice_add(choice_field, _("foo"), "foo"); |
|
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
366 | purple_request_field_choice_add(choice_field, _("bar"), "bar"); |
|
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
367 | purple_request_field_choice_add(choice_field, _("baz"), "baz"); |
|
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
368 | purple_request_field_choice_add(choice_field, _("quux"), "quux"); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
369 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
370 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
371 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
372 | field = purple_request_field_list_new("list", _("A list")); |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
373 | list_field = PURPLE_REQUEST_FIELD_LIST(field); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
374 | purple_request_field_list_add_icon(list_field, _("foo"), NULL, "foo"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
375 | purple_request_field_list_add_icon(list_field, _("bar"), NULL, "bar"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
376 | purple_request_field_list_add_icon(list_field, _("baz"), NULL, "baz"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
377 | purple_request_field_list_add_icon(list_field, _("quux"), NULL, "quux"); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
378 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
379 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
380 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
381 | field = purple_request_field_list_new("multilist", _("A multi-select list")); |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
382 | list_field = PURPLE_REQUEST_FIELD_LIST(field); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
383 | purple_request_field_list_set_multi_select(list_field, TRUE); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
384 | purple_request_field_list_add_icon(list_field, _("foo"), NULL, "foo"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
385 | purple_request_field_list_add_icon(list_field, _("bar"), NULL, "bar"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
386 | purple_request_field_list_add_icon(list_field, _("baz"), NULL, "baz"); |
|
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
387 | purple_request_field_list_add_icon(list_field, _("quux"), NULL, "quux"); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
388 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
389 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
390 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
391 | /* This group will contain specialized fields. */ |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
392 | group = purple_request_group_new(_("Special")); |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
393 | purple_request_page_add_group(page, group); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
394 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
395 | field = purple_request_field_label_new("special-label", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
396 | _("This group contains specialized fields")); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
397 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
398 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
399 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
400 | icon = g_resource_lookup_data(purple_demo_get_resource(), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
401 | "/im/pidgin/purple/demo/icons/scalable/apps/im-purple-demo.svg", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
402 | G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
403 | icon_data = g_bytes_get_data(icon, &icon_len); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
404 | field = purple_request_field_image_new("image", _("An image"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
405 | icon_data, icon_len); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
406 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
407 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
408 | g_bytes_unref(icon); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
409 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
410 | field = purple_request_field_account_new("account", _("An account"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
411 | account); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
412 | g_object_bind_property(boolfield, "value", field, "sensitive", 0); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
413 | purple_request_group_add_field(group, field); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
414 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
415 | purple_request_fields(connection, _("Request Fields Demo"), |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
416 | _("Please fill out these fields…"), NULL, page, |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
417 | _("OK"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
418 | G_CALLBACK(purple_demo_protocol_request_fields_ok_cb), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
419 | _("Cancel"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
420 | G_CALLBACK(purple_demo_protocol_request_fields_cancel_cb), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
421 | purple_request_cpar_from_connection(connection), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
422 | NULL); |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
423 | |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
424 | g_clear_object(&account); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
425 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
426 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
427 | /****************************************************************************** |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
428 | * Contact action implementations |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
429 | *****************************************************************************/ |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
430 | static const gchar *contacts[] = {"Alice", "Bob", "Carlos", "Erin" }; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
431 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
432 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
433 | purple_demo_protocol_remote_add(G_GNUC_UNUSED GSimpleAction *action, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
434 | GVariant *parameter, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
435 | G_GNUC_UNUSED gpointer data) |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
436 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
437 | PurpleAccount *account = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
438 | PurpleAccountManager *account_manager = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
439 | PurpleAddContactRequest *request = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
440 | PurpleNotification *notification = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
441 | PurpleNotificationManager *notification_manager = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
442 | const gchar *account_id = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
443 | static guint counter = 0; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
444 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
445 | account_id = g_variant_get_string(parameter, NULL); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
446 | account_manager = purple_account_manager_get_default(); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
447 | account = purple_account_manager_find_by_id(account_manager, account_id); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
448 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
449 | request = purple_add_contact_request_new(account, contacts[counter]); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
450 | notification = purple_notification_new_from_add_contact_request(request); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
451 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
452 | notification_manager = purple_notification_manager_get_default(); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
453 | purple_notification_manager_add(notification_manager, notification); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
454 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
455 | counter++; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
456 | if(counter >= G_N_ELEMENTS(contacts)) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
457 | counter = 0; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
458 | } |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
459 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42635
diff
changeset
|
460 | g_clear_object(¬ification); |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
461 | g_clear_object(&account); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
462 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
463 | |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
464 | static const char *puns[] = { |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
465 | "Toucan play at that game!", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
466 | "As long as it's not too much of a birden...", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
467 | "Sounds like a bit of ostrich...", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
468 | "People can't stop raven!", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
469 | "Have you heard about the bird?", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
470 | }; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
471 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
472 | static void |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
473 | purple_demo_protocol_generic_notification(G_GNUC_UNUSED GSimpleAction *action, |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
474 | GVariant *parameter, |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
475 | G_GNUC_UNUSED gpointer data) |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
476 | { |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
477 | PurpleAccount *account = NULL; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
478 | PurpleAccountManager *account_manager = NULL; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
479 | PurpleNotification *notification = NULL; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
480 | PurpleNotificationManager *notification_manager = NULL; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
481 | const char *account_id = NULL; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
482 | static guint counter = 0; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
483 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
484 | account_id = g_variant_get_string(parameter, NULL); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
485 | account_manager = purple_account_manager_get_default(); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
486 | account = purple_account_manager_find_by_id(account_manager, account_id); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
487 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
488 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
489 | account, g_strdup(puns[counter]), |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
490 | g_free); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
491 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
492 | notification_manager = purple_notification_manager_get_default(); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
493 | purple_notification_manager_add(notification_manager, notification); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
494 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
495 | counter++; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
496 | if(counter >= G_N_ELEMENTS(puns)) { |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
497 | counter = 0; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
498 | } |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
499 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42635
diff
changeset
|
500 | g_clear_object(¬ification); |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
501 | g_clear_object(&account); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
502 | } |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
503 | |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
504 | /****************************************************************************** |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
505 | * PurpleProtocolActions Implementation |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
506 | *****************************************************************************/ |
|
41460
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
507 | static const gchar * |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
508 | purple_demo_protocol_get_prefix(G_GNUC_UNUSED PurpleProtocolActions *actions) { |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
509 | return "prpl-demo"; |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
510 | } |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
511 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
512 | static GActionGroup * |
|
41968
2fc2db360044
Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41905
diff
changeset
|
513 | purple_demo_protocol_get_action_group(G_GNUC_UNUSED PurpleProtocolActions *actions, |
|
2fc2db360044
Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41905
diff
changeset
|
514 | G_GNUC_UNUSED PurpleConnection *connection) |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
515 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
516 | GSimpleActionGroup *group = NULL; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
517 | GActionEntry entries[] = { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
518 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
519 | .name = "temporary-failure", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
520 | .activate = purple_demo_protocol_temporary_failure_action_activate, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
521 | .parameter_type = "s", |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
522 | }, { |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
523 | .name = "fatal-failure", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
524 | .activate = purple_demo_protocol_fatal_failure_action_activate, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
525 | .parameter_type = "s", |
|
41517
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
526 | }, { |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
527 | .name = "generic-notification", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
528 | .activate = purple_demo_protocol_generic_notification, |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
529 | .parameter_type = "s", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
530 | }, { |
|
41517
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
531 | .name = "remote-add", |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
532 | .activate = purple_demo_protocol_remote_add, |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
533 | .parameter_type = "s", |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
534 | }, { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
535 | .name = "request-fields", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
536 | .activate = purple_demo_protocol_request_fields_activate, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
537 | .parameter_type = "s", |
|
41517
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
538 | } |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
539 | }; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
540 | gsize nentries = G_N_ELEMENTS(entries); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
541 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
542 | group = g_simple_action_group_new(); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
543 | g_action_map_add_action_entries(G_ACTION_MAP(group), entries, nentries, |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
544 | NULL); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
545 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
546 | return G_ACTION_GROUP(group); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
547 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
548 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
549 | static GMenu * |
|
42004
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41968
diff
changeset
|
550 | purple_demo_protocol_get_menu(G_GNUC_UNUSED PurpleProtocolActions *actions, |
|
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41968
diff
changeset
|
551 | G_GNUC_UNUSED PurpleConnection *connection) |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
552 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
553 | GMenu *menu = NULL; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
554 | GMenuItem *item = NULL; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
555 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
556 | menu = g_menu_new(); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
557 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
558 | item = g_menu_item_new(_("Trigger temporary connection failure..."), |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
559 | "prpl-demo.temporary-failure"); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
560 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
561 | "account"); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
562 | g_menu_append_item(menu, item); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
563 | g_object_unref(item); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
564 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
565 | item = g_menu_item_new(_("Trigger fatal connection failure..."), |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
566 | "prpl-demo.fatal-failure"); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
567 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
568 | "account"); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
569 | g_menu_append_item(menu, item); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
570 | g_object_unref(item); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
571 | |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
572 | item = g_menu_item_new(_("Trigger a generic notification"), |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
573 | "prpl-demo.generic-notification"); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
574 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
575 | "account"); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
576 | g_menu_append_item(menu, item); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
577 | g_object_unref(item); |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
578 | |
|
41517
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
579 | item = g_menu_item_new(_("Trigger a contact adding you"), |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
580 | "prpl-demo.remote-add"); |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
581 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
582 | "account"); |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
583 | g_menu_append_item(menu, item); |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
584 | g_object_unref(item); |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
585 | |
|
42752
cc8312cb5017
Remove all request options except fields from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42747
diff
changeset
|
586 | item = g_menu_item_new(_("Request Fields"), "prpl-demo.request-fields"); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
587 | g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
588 | "account"); |
|
42752
cc8312cb5017
Remove all request options except fields from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42747
diff
changeset
|
589 | g_menu_append_item(menu, item); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
590 | g_object_unref(item); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
591 | |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
592 | return menu; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
593 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
594 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
595 | void |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
596 | purple_demo_protocol_actions_init(PurpleProtocolActionsInterface *iface) { |
|
41460
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41459
diff
changeset
|
597 | iface->get_prefix = purple_demo_protocol_get_prefix; |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
598 | iface->get_action_group = purple_demo_protocol_get_action_group; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
599 | iface->get_menu = purple_demo_protocol_get_menu; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
600 | } |