Wed, 28 Aug 2024 01:02:07 -0500
Update Purple.AddContactRequest to use a PurpleContact
Previous this was using an account, username, and alias, all of which exist in
PurpleContact.
Testing Done:
Called in the turtles and used the add contact action in the demo protocol plugin.
Reviewed at https://reviews.imfreedom.org/r/3446/
|
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, |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
40 | const char *tick_str, |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
41 | const char *tick_plural_str, |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
42 | const char *disconnect_str) |
|
41459
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); |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
46 | char *message = NULL; |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
47 | int timeout = 0; |
|
41459
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, |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
104 | const char *tick_str, |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
105 | const char *tick_plural_str, |
|
41459
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 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
192 | 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
|
193 | PurpleRequestPage *page) |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
194 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
195 | PurpleAccount *account = NULL; |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
196 | 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
|
197 | GList *list = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
198 | 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
|
199 | GString *info = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
200 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
201 | 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
|
202 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
203 | 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
|
204 | 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
|
205 | 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
|
206 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
207 | "multiline-string")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
208 | 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
|
209 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
210 | "masked-string")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
211 | 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
|
212 | purple_request_page_get_string(page, |
|
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
213 | "alphanumeric")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | 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
|
218 | 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
|
219 | 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
|
220 | _("TRUE") : _("FALSE")); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
221 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
222 | 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
|
223 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
224 | 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
|
225 | 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
|
226 | |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
227 | 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
|
228 | "list")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
229 | 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
|
230 | if(list != NULL) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
231 | 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
|
232 | } else { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
233 | tmp = _("(unset)"); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
234 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
235 | 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
|
236 | |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
237 | 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
|
238 | "multilist")); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
239 | 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
|
240 | 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
|
241 | while(list != NULL) { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
242 | 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
|
243 | 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
|
244 | list->next != NULL ? ", " : ""); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
245 | list = list->next; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
246 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
247 | 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
|
248 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
249 | 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
|
250 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
251 | 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
|
252 | if(PURPLE_IS_ACCOUNT(account)) { |
|
42803
984f8dfabb47
Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42752
diff
changeset
|
253 | PurpleContactInfo *info = NULL; |
|
984f8dfabb47
Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42752
diff
changeset
|
254 | |
|
984f8dfabb47
Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42752
diff
changeset
|
255 | info = purple_account_get_contact_info(account); |
|
984f8dfabb47
Update the protocols to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42752
diff
changeset
|
256 | tmp = purple_contact_info_get_name_for_display(info); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
257 | } else { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
258 | tmp = _("(unset)"); |
|
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_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
|
261 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
262 | 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
|
263 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
264 | 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
|
265 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
266 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
267 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
268 | 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
|
269 | 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
|
270 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
271 | 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
|
272 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
273 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
274 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
275 | 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
|
276 | GVariant *parameter, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
277 | 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
|
278 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
279 | PurpleConnection *connection = NULL; |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
280 | const char *account_id = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
281 | PurpleAccountManager *manager = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
282 | PurpleAccount *account = NULL; |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
283 | PurpleRequestPage *page = NULL; |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
284 | 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
|
285 | 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
|
286 | PurpleRequestField *field = NULL; |
|
42139
c053558f1236
Make PurpleRequestFieldChoice into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42135
diff
changeset
|
287 | PurpleRequestFieldChoice *choice_field = NULL; |
|
42140
beba61bbdf19
Convert PurpleRequestFieldList into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42139
diff
changeset
|
288 | 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
|
289 | GBytes *icon = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
290 | 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
|
291 | 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
|
292 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
293 | 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
|
294 | 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
|
295 | 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
|
296 | return; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
297 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
298 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
299 | 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
|
300 | 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
|
301 | 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
|
302 | 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
|
303 | |
|
42128
118067ca0367
Convert PurpleRequestPage into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42127
diff
changeset
|
304 | 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
|
305 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
306 | /* 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
|
307 | 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
|
308 | 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
|
309 | |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
310 | 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
|
311 | 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
|
312 | _("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
|
313 | 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
|
314 | |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
315 | 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
|
316 | _("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
|
317 | 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
|
318 | 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
|
319 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
320 | 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
|
321 | _("default"), FALSE); |
|
42154
2557742988dc
Remove tracking of required fields
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42149
diff
changeset
|
322 | 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
|
323 | 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
|
324 | 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
|
325 | 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
|
326 | _("A multiline string"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
327 | _("default"), TRUE); |
|
42127
18acb99a0fa6
Convert PurpleRequestGroup into a GObject
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42105
diff
changeset
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | _("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
|
332 | FALSE); |
|
42135
1a89a067a0d5
Add a PurpleRequestFieldString subclass
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42128
diff
changeset
|
333 | 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
|
334 | TRUE); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
335 | 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
|
336 | 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
|
337 | 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
|
338 | _("An alphanumeric string"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
339 | _("default"), FALSE); |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
340 | 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
|
341 | 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
|
342 | NULL, NULL); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
343 | 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
|
344 | 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
|
345 | 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
|
346 | _("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
|
347 | 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
|
348 | 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
|
349 | NULL, NULL); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
350 | 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
|
351 | 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
|
352 | 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
|
353 | 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
|
354 | 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
|
355 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
356 | /* 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
|
357 | 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
|
358 | 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
|
359 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
360 | 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
|
361 | _("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
|
362 | 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
|
363 | 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
|
364 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
365 | 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
|
366 | 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
|
367 | 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
|
368 | 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
|
369 | 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
|
370 | 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
|
371 | 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
|
372 | 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
|
373 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
374 | 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
|
375 | 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
|
376 | 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
|
377 | 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
|
378 | 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
|
379 | 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
|
380 | 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
|
381 | 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
|
382 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
383 | 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
|
384 | 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
|
385 | 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
|
386 | 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
|
387 | 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
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
393 | /* 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
|
394 | 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
|
395 | 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
|
396 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
397 | 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
|
398 | _("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
|
399 | 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
|
400 | 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
|
401 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
402 | 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
|
403 | "/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
|
404 | 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
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | 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
|
409 | 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
|
410 | 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
|
411 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
412 | 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
|
413 | account); |
|
42157
a4b3376be353
demo: Toggle sensitivity of fields in requests demo
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42154
diff
changeset
|
414 | 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
|
415 | 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
|
416 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
417 | 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
|
418 | _("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
|
419 | _("OK"), |
|
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_ok_cb), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
421 | _("Cancel"), |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
422 | 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
|
423 | 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
|
424 | NULL); |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
425 | |
|
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
426 | 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
|
427 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
428 | |
|
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 | * Contact action implementations |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
431 | *****************************************************************************/ |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
432 | static const char *contact_ids[] = {"alice", "bob", "carlos", "erin" }; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
433 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
434 | static void |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
435 | 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
|
436 | GVariant *parameter, |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
437 | 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
|
438 | { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
439 | PurpleAccount *account = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
440 | 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
|
441 | PurpleAddContactRequest *request = NULL; |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
442 | PurpleContact *contact = NULL; |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
443 | PurpleContactManager *contact_manager = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
444 | PurpleNotification *notification = NULL; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
445 | PurpleNotificationManager *notification_manager = NULL; |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
446 | const char *account_id = NULL; |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
447 | 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
|
448 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
449 | 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
|
450 | 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
|
451 | 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
|
452 | |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
453 | contact_manager = purple_contact_manager_get_default(); |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
454 | contact = purple_contact_manager_find_with_id(contact_manager, account, |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
455 | contact_ids[counter]); |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
456 | |
|
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
457 | request = purple_add_contact_request_new(contact); |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
458 | 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
|
459 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
460 | 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
|
461 | 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
|
462 | |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
463 | counter++; |
|
42914
27c407608b6b
Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents:
42881
diff
changeset
|
464 | if(counter >= G_N_ELEMENTS(contact_ids)) { |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
465 | counter = 0; |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
466 | } |
|
42291
a86b7bcbb471
Make the purple_account_manager_find functions return transfer full.
Gary Kramlich <grim@reaperworld.com>
parents:
42204
diff
changeset
|
467 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42635
diff
changeset
|
468 | 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
|
469 | 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
|
470 | } |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
471 | |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
472 | 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
|
473 | "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
|
474 | "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
|
475 | "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
|
476 | "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
|
477 | "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
|
478 | }; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
479 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
480 | static void |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
481 | 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
|
482 | GVariant *parameter, |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
483 | 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
|
484 | { |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
485 | 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
|
486 | 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
|
487 | 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
|
488 | 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
|
489 | 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
|
490 | 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
|
491 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
492 | 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
|
493 | 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
|
494 | 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
|
495 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
496 | notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, |
|
42828
fbfb9dbdb87c
Make the demo notifications look a bit better
Gary Kramlich <grim@reaperworld.com>
parents:
42803
diff
changeset
|
497 | account, NULL, NULL); |
|
fbfb9dbdb87c
Make the demo notifications look a bit better
Gary Kramlich <grim@reaperworld.com>
parents:
42803
diff
changeset
|
498 | purple_notification_set_title(notification, puns[counter]); |
|
fbfb9dbdb87c
Make the demo notifications look a bit better
Gary Kramlich <grim@reaperworld.com>
parents:
42803
diff
changeset
|
499 | purple_notification_set_icon_name(notification, "im-purple-demo"); |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
500 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
501 | 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
|
502 | 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
|
503 | |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
504 | counter++; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
505 | 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
|
506 | counter = 0; |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
507 | } |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
508 | |
|
42638
81ef32d85e5a
Fix transfer annotation of purple_notification_manager_add
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42635
diff
changeset
|
509 | 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
|
510 | 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
|
511 | } |
|
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
512 | |
|
42101
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
513 | /****************************************************************************** |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
514 | * Helpers |
|
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 | static GActionGroup * |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
517 | purple_demo_protocol_get_action_group(void) { |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
518 | GSimpleActionGroup *group = NULL; |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
519 | GActionEntry entries[] = { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
520 | { |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
521 | .name = "temporary-failure", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
522 | .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
|
523 | .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
|
524 | }, { |
|
41459
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
525 | .name = "fatal-failure", |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
526 | .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
|
527 | .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
|
528 | }, { |
|
42635
8bc965216427
Add a protocol action to the demo protocol to add generic notifications
Gary Kramlich <grim@reaperworld.com>
parents:
42291
diff
changeset
|
529 | .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
|
530 | .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
|
531 | .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
|
532 | }, { |
|
41517
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
533 | .name = "remote-add", |
|
5bafe75d3907
Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
41463
diff
changeset
|
534 | .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
|
535 | .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
|
536 | }, { |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
537 | .name = "request-fields", |
|
f22bea74160d
Add demo of requests API to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42004
diff
changeset
|
538 | .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
|
539 | .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
|
540 | } |
|
41459
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 | 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
|
543 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
544 | 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
|
545 | 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
|
546 | NULL); |
|
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 | return G_ACTION_GROUP(group); |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
549 | } |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
550 | |
|
53a9d24d5be2
Add some protocol actions to demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
551 | static GMenu * |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
552 | purple_demo_protocol_get_menu(void) { |
|
41459
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 | |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
595 | /****************************************************************************** |
|
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
596 | * Internal API |
|
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
597 | *****************************************************************************/ |
|
42878
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
598 | BirbActionMenu * |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
599 | purple_demo_protocol_get_action_menu(G_GNUC_UNUSED PurpleProtocol *protocol, |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
600 | G_GNUC_UNUSED PurpleAccount *account) |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
601 | { |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
602 | BirbActionMenu *action_menu = NULL; |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
603 | GActionGroup *group = NULL; |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
604 | GMenu *menu = NULL; |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
605 | GMenu *section = NULL; |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
606 | |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
607 | action_menu = birb_action_menu_new(); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
608 | |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
609 | group = purple_demo_protocol_get_action_group(); |
|
42878
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
610 | birb_action_menu_add_action_group(action_menu, "prpl-demo", group); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
611 | g_clear_object(&group); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
612 | |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
613 | menu = birb_action_menu_get_menu(action_menu); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
614 | |
|
42881
f501f1a0ca6e
Remove the Purple.ProtocolActions implementation from the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42878
diff
changeset
|
615 | section = purple_demo_protocol_get_menu(); |
|
42878
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
616 | g_menu_append_section(menu, NULL, G_MENU_MODEL(section)); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
617 | g_clear_object(§ion); |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
618 | |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
619 | return action_menu; |
|
5183064bcc28
Implement Purple.Protocol.get_action_menu in the Demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42828
diff
changeset
|
620 | } |