libpurple/purpleaddcontactrequest.c

Tue, 15 Oct 2024 00:47:42 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 15 Oct 2024 00:47:42 -0500
changeset 43011
ce3144e2bc33
parent 42914
27c407608b6b
permissions
-rw-r--r--

Port prefs to AdwSwitchRow

Now that we depend on Adwaita 1.4, we can flip the switch on using these (pun intended).

This also simplifies some extra tracking we needed to do for activations and focus, since the Adwaita widgets do that for us.

Testing Done:
Opened prefs, confirmed all the switches were there, and toggled them all without any warnings.

Also used the mnemonics to toggle the switches from the keyboard.

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

41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
7 * source distribution.
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleaddcontactrequest.h"
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PurpleAddContactRequest {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GObject parent;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
28 PurpleContact *contact;
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
29 char *message;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 /* This tracks whether add has been called. */
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 gboolean handled;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 };
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 enum {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 SIG_ADD,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
37 N_SIGNALS,
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 static guint signals[N_SIGNALS] = {0, };
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 enum {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_0,
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
43 PROP_CONTACT,
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_MESSAGE,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 N_PROPERTIES,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 };
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 /******************************************************************************
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 * Helpers
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 *****************************************************************************/
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static void
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
53 purple_add_contact_request_set_contact(PurpleAddContactRequest *request,
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
54 PurpleContact *contact)
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
58 if(g_set_object(&request->contact, contact)) {
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
59 g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_CONTACT]);
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
60 }
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 /******************************************************************************
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 * GObject Implementation
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 *****************************************************************************/
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
66 G_DEFINE_FINAL_TYPE(PurpleAddContactRequest, purple_add_contact_request,
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
67 G_TYPE_OBJECT)
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
68
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 static void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 purple_add_contact_request_get_property(GObject *obj, guint param_id,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 GValue *value, GParamSpec *pspec)
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 PurpleAddContactRequest *request = PURPLE_ADD_CONTACT_REQUEST(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 switch(param_id) {
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
76 case PROP_CONTACT:
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
77 g_value_set_object(value,
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
78 purple_add_contact_request_get_contact(request));
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
79 break;
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
80 case PROP_MESSAGE:
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
81 g_value_set_string(value,
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
82 purple_add_contact_request_get_message(request));
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
83 break;
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
84 default:
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
85 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
86 break;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 static void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_add_contact_request_set_property(GObject *obj, guint param_id,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 const GValue *value,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 GParamSpec *pspec)
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 PurpleAddContactRequest *request = PURPLE_ADD_CONTACT_REQUEST(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 switch(param_id) {
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
98 case PROP_CONTACT:
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
99 purple_add_contact_request_set_contact(request,
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
100 g_value_get_object(value));
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
101 break;
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
102 case PROP_MESSAGE:
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
103 purple_add_contact_request_set_message(request,
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
104 g_value_get_string(value));
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
105 break;
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
106 default:
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
107 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
108 break;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 static void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 purple_add_contact_request_dispose(GObject *obj) {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 PurpleAddContactRequest *request = PURPLE_ADD_CONTACT_REQUEST(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
116 g_clear_object(&request->contact);
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 G_OBJECT_CLASS(purple_add_contact_request_parent_class)->dispose(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 static void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 purple_add_contact_request_finalize(GObject *obj) {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 PurpleAddContactRequest *request = PURPLE_ADD_CONTACT_REQUEST(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_clear_pointer(&request->message, g_free);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 G_OBJECT_CLASS(purple_add_contact_request_parent_class)->finalize(obj);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 static void
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41646
diff changeset
131 purple_add_contact_request_init(G_GNUC_UNUSED PurpleAddContactRequest *request)
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41646
diff changeset
132 {
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 static void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 purple_add_contact_request_class_init(PurpleAddContactRequestClass *klass)
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 obj_class->get_property = purple_add_contact_request_get_property;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 obj_class->set_property = purple_add_contact_request_set_property;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 obj_class->dispose = purple_add_contact_request_dispose;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 obj_class->finalize = purple_add_contact_request_finalize;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 /**
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
146 * PurpleAddContactRequest:contact:
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
147 *
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
148 * The contact that this request is for.
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
149 *
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
150 * Since: 3.0
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
151 */
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
152 properties[PROP_CONTACT] = g_param_spec_object(
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
153 "contact", NULL, NULL,
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
154 PURPLE_TYPE_CONTACT,
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
155 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
156
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
157 /**
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
158 * PurpleAddContactRequest:message:
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
159 *
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
160 * The optional message sent from the remote user.
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
161 *
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
162 * Since: 3.0
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
163 */
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
164 properties[PROP_MESSAGE] = g_param_spec_string(
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
165 "message", NULL, NULL,
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
166 NULL,
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
167 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
168
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
169 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
170
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
171 /**
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 * PurpleAddContactRequest::add:
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 * @request: The [class@AddContactRequest] instance.
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 *
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 * Emitted when the user has told the ui to add the contact. This is
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 * typically emitted by the user interface calling
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 * [method@AddContactRequest.add].
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 *
42613
780d7efe37c2 Remove the micro version from since tags for libpurple part 2
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
179 * Since: 3.0
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 */
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 signals[SIG_ADD] = g_signal_new_class_handler(
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 "add",
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 G_OBJECT_CLASS_TYPE(klass),
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 G_SIGNAL_RUN_LAST,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 NULL,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 NULL,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 NULL,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 NULL,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 G_TYPE_NONE,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 0);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 /******************************************************************************
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 * Public API
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 *****************************************************************************/
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 PurpleAddContactRequest *
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
197 purple_add_contact_request_new(PurpleContact *contact) {
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
198 g_return_val_if_fail(PURPLE_IS_CONTACT(contact), NULL);
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 return g_object_new(
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 PURPLE_TYPE_ADD_CONTACT_REQUEST,
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
202 "contact", contact,
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 NULL);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
206 PurpleContact *
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
207 purple_add_contact_request_get_contact(PurpleAddContactRequest *request) {
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 g_return_val_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request), NULL);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
42914
27c407608b6b Update Purple.AddContactRequest to use a PurpleContact
Gary Kramlich <grim@reaperworld.com>
parents: 42841
diff changeset
210 return request->contact;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 purple_add_contact_request_set_message(PurpleAddContactRequest *request,
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
215 const char *message)
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
219 if(g_set_str(&request->message, message)) {
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
220 g_object_notify_by_pspec(G_OBJECT(request), properties[PROP_MESSAGE]);
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42613
diff changeset
221 }
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223
42841
fbb5c5cb37f4 Modernize files that start with purplea
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
224 const char *
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 purple_add_contact_request_get_message(PurpleAddContactRequest *request) {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 g_return_val_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request), NULL);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 return request->message;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 void
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 purple_add_contact_request_add(PurpleAddContactRequest *request) {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 g_return_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request));
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 /* Calling this multiple times is a programming error. */
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 g_return_if_fail(request->handled == FALSE);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 request->handled = TRUE;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 g_signal_emit(request, signals[SIG_ADD], 0);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 }

mercurial