Fri, 10 Mar 2023 01:16:40 -0600
Add a PurpleRequestFieldString subclass
This also does an `hg cp`, though with all the renaming of the parameter names, maybe that wasn't as useful for tracking the diff.
Note, I didn't bother re-indenting some of the blocks, because they'll all eventually be moved when everything is subclassed.
Testing Done:
Compiled and opened Request Fields from the Demo protocol.
Reviewed at https://reviews.imfreedom.org/r/2324/
|
41284
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
1 | /* |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
4 | * |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
9 | * |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
14 | * |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
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/>. |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
17 | */ |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
18 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
20 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
21 | #include "purpledemoprotocol.h" |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
22 | #include "purpledemoprotocolim.h" |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
23 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
24 | /****************************************************************************** |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
25 | * PurpleProtocolIM Implementation |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
26 | *****************************************************************************/ |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
27 | typedef struct { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
28 | PurpleConnection *connection; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
29 | PurpleMessage *message; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
30 | } PurpleDemoProtocolIMInfo; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
31 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
32 | static void |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
33 | purple_demo_protocol_im_info_free(PurpleDemoProtocolIMInfo *info) { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
34 | g_object_unref(info->message); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
35 | g_free(info); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
36 | } |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
37 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
38 | static gboolean |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
39 | purple_demo_protocol_echo_im_cb(gpointer data) |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
40 | { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
41 | PurpleDemoProtocolIMInfo *info = data; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
42 | const char *who = NULL; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
43 | PurpleMessageFlags flags; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
44 | GDateTime *timestamp = NULL; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
45 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
46 | /* Turn outgoing message back incoming. */ |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
47 | who = purple_message_get_recipient(info->message); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
48 | flags = purple_message_get_flags(info->message); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
49 | flags &= ~PURPLE_MESSAGE_SEND; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
50 | flags |= PURPLE_MESSAGE_RECV; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
51 | timestamp = purple_message_get_timestamp(info->message); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
52 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
53 | purple_serv_got_im(info->connection, who, |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
54 | purple_message_get_contents(info->message), flags, |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
55 | g_date_time_to_unix(timestamp)); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
56 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
57 | return FALSE; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
58 | } |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
59 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
60 | static gint |
|
41968
2fc2db360044
Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41284
diff
changeset
|
61 | purple_demo_protocol_send_im(G_GNUC_UNUSED PurpleProtocolIM *im, |
|
2fc2db360044
Bump C standard to C99 for Demo protocol and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41284
diff
changeset
|
62 | PurpleConnection *conn, PurpleMessage *msg) |
|
41284
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
63 | { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
64 | const gchar *who = purple_message_get_recipient(msg); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
65 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
66 | if(purple_strequal(who, "Echo")) { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
67 | PurpleDemoProtocolIMInfo *info = g_new(PurpleDemoProtocolIMInfo, 1); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
68 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
69 | info->connection = conn; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
70 | info->message = g_object_ref(msg); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
71 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
72 | g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
73 | purple_demo_protocol_echo_im_cb, info, |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
74 | (GDestroyNotify)purple_demo_protocol_im_info_free); |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
75 | } |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
76 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
77 | return 1; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
78 | } |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
79 | |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
80 | void |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
81 | purple_demo_protocol_im_init(PurpleProtocolIMInterface *iface) { |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
82 | iface->send = purple_demo_protocol_send_im; |
|
7b29786ffdc7
Split apart the demo's PurpleProtocolIM implementation
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
diff
changeset
|
83 | } |