Thu, 05 Jan 2023 22:39:17 -0600
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
This is necessary so that protocols can dynamically add menu items for specific
accounts. This could be something like adding administrator actions after the
protocol has determined that you're an administrator for example.
Testing Done:
Connected an xmpp, ircv3, and demo account and verified all of their actions were displayed properly.
Reviewed at https://reviews.imfreedom.org/r/2172/
|
41437
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
4 | * |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
7 | * source distribution. |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
8 | * |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
9 | * This program is free software; you can redistribute it and/or modify |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
10 | * it under the terms of the GNU General Public License as published by |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
11 | * the Free Software Foundation; either version 2 of the License, or |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
12 | * (at your option) any later version. |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
13 | * |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
14 | * This program is distributed in the hope that it will be useful, |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
18 | * |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
20 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
21 | */ |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
22 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
23 | #include "purpleprotocolactions.h" |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
24 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
25 | /****************************************************************************** |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
26 | * GObject Implementation |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
27 | *****************************************************************************/ |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
28 | G_DEFINE_INTERFACE(PurpleProtocolActions, purple_protocol_actions, |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
29 | PURPLE_TYPE_PROTOCOL) |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
30 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
31 | static void |
|
41960
c8a4853205e3
Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41460
diff
changeset
|
32 | purple_protocol_actions_default_init(G_GNUC_UNUSED PurpleProtocolActionsInterface *iface) |
|
c8a4853205e3
Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41460
diff
changeset
|
33 | { |
|
41437
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
34 | } |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
35 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
36 | /****************************************************************************** |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
37 | * Public API |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
38 | *****************************************************************************/ |
|
41460
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
39 | const gchar * |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
40 | purple_protocol_actions_get_prefix(PurpleProtocolActions *actions) { |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
41 | PurpleProtocolActionsInterface *iface = NULL; |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
42 | |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
43 | g_return_val_if_fail(PURPLE_IS_PROTOCOL_ACTIONS(actions), NULL); |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
44 | |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
45 | iface = PURPLE_PROTOCOL_ACTIONS_GET_IFACE(actions); |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
46 | if(iface != NULL) { |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
47 | if(iface->get_prefix != NULL) { |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
48 | return iface->get_prefix(actions); |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
49 | } else { |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
50 | return purple_protocol_get_id(PURPLE_PROTOCOL(actions)); |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
51 | } |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
52 | } |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
53 | |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
54 | return NULL; |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
55 | } |
|
fccbea158b51
Add a get_prefix method to the PurpleProtocolActions interface
Gary Kramlich <grim@reaperworld.com>
parents:
41437
diff
changeset
|
56 | |
|
41437
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
57 | GActionGroup * |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
58 | purple_protocol_actions_get_action_group(PurpleProtocolActions *actions, |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
59 | PurpleConnection *connection) |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
60 | { |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
61 | PurpleProtocolActionsInterface *iface = NULL; |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
62 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
63 | g_return_val_if_fail(PURPLE_IS_PROTOCOL_ACTIONS(actions), NULL); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
64 | g_return_val_if_fail(PURPLE_IS_CONNECTION(connection), NULL); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
65 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
66 | iface = PURPLE_PROTOCOL_ACTIONS_GET_IFACE(actions); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
67 | if(iface != NULL && iface->get_action_group != NULL) { |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
68 | return iface->get_action_group(actions, connection); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
69 | } |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
70 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
71 | return NULL; |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
72 | } |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
73 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
74 | GMenu * |
|
42004
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
75 | purple_protocol_actions_get_menu(PurpleProtocolActions *actions, |
|
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
76 | PurpleConnection *connection) |
|
41437
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
77 | { |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
78 | PurpleProtocolActionsInterface *iface = NULL; |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
79 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
80 | g_return_val_if_fail(PURPLE_IS_PROTOCOL_ACTIONS(actions), NULL); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
81 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
82 | iface = PURPLE_PROTOCOL_ACTIONS_GET_IFACE(actions); |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
83 | if(iface != NULL && iface->get_menu != NULL) { |
|
42004
620d1adf91f2
Add a connection parameter to the PurpleProtocolActions.get_menu virtual function
Gary Kramlich <grim@reaperworld.com>
parents:
41960
diff
changeset
|
84 | return iface->get_menu(actions, connection); |
|
41437
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
85 | } |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
86 | |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
87 | return NULL; |
|
05ac40f0e0c4
Add a protocol actions interface
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
88 | } |