Thu, 11 Apr 2024 21:32:59 -0500
Remove PurpleConnectionUiOps as they are no longer used
Testing Done:
Checked in with the turtles.
Reviewed at https://reviews.imfreedom.org/r/3090/
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This library is free software; you can redistribute it and/or |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * modify it under the terms of the GNU Lesser General Public |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * License as published by the Free Software Foundation; either |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * version 2 of the License, or (at your option) any later version. |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This library is distributed in the hope that it will be useful, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * Lesser General Public License for more details. |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU Lesser General Public |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
18 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #include <glib/gi18n-lib.h> |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include "purpledemoprotocolconversation.h" |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
42675
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
23 | #include "purpledemoplugin.h" |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
24 | #include "purpledemoprotocol.h" |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
25 | |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | typedef struct { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | PurpleConversation *conversation; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | PurpleMessage *message; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | } PurpleDemoProtocolIMInfo; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
42675
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
31 | /****************************************************************************** |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
32 | * Helpers |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
33 | *****************************************************************************/ |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | static void |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | purple_demo_protocol_im_info_free(PurpleDemoProtocolIMInfo *info) { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | g_clear_object(&info->conversation); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | g_clear_object(&info->message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | g_free(info); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | |
|
42675
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
41 | static gint |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
42 | purple_demo_protocol_contact_sort(gconstpointer a, gconstpointer b, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
43 | G_GNUC_UNUSED gpointer data) |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
44 | { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
45 | return purple_contact_info_compare(PURPLE_CONTACT_INFO((gpointer)a), |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
46 | PURPLE_CONTACT_INFO((gpointer)b)); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
47 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
48 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
49 | static char * |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
50 | purple_demo_protocol_generate_conversation_id(PurpleAccount *account, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
51 | PurpleCreateConversationDetails *details) |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
52 | { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
53 | GChecksum *checksum = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
54 | GListModel *participants = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
55 | GListStore *sorted = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
56 | char *ret = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
57 | const char *id = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
58 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
59 | /* Sort the participants. */ |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
60 | sorted = g_list_store_new(PURPLE_TYPE_CONTACT); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
61 | participants = purple_create_conversation_details_get_participants(details); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
62 | for(guint i = 0; i < g_list_model_get_n_items(participants); i++) { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
63 | PurpleContactInfo *info = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
64 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
65 | info = g_list_model_get_item(participants, i); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
66 | g_list_store_insert_sorted(sorted, info, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
67 | purple_demo_protocol_contact_sort, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
68 | NULL); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
69 | g_clear_object(&info); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
70 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
71 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
72 | /* Build a checksum of the account and the sorted participants. */ |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
73 | checksum = g_checksum_new(G_CHECKSUM_SHA256); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
74 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
75 | id = purple_contact_info_get_id(PURPLE_CONTACT_INFO(account)); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
76 | g_checksum_update(checksum, (guchar *)id, -1); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
77 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
78 | for(guint i = 0; i < g_list_model_get_n_items(G_LIST_MODEL(sorted)); i++) { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
79 | PurpleContactInfo *info = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
80 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
81 | info = g_list_model_get_item(G_LIST_MODEL(sorted), i); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
82 | id = purple_contact_info_get_id(info); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
83 | g_checksum_update(checksum, (guchar *)id, -1); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
84 | g_clear_object(&info); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
85 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
86 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
87 | ret = g_strdup(g_checksum_get_string(checksum)); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
88 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
89 | g_clear_pointer(&checksum, g_checksum_free); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
90 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
91 | return ret; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
92 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
93 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
94 | /****************************************************************************** |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
95 | * Callbacks |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
96 | *****************************************************************************/ |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | static gboolean |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | purple_demo_protocol_echo_im_cb(gpointer data) { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | PurpleDemoProtocolIMInfo *info = data; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | PurpleMessage *message = NULL; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | PurpleMessageFlags flags; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | const char *who = NULL; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | /* Turn outgoing message back incoming. */ |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | who = purple_conversation_get_name(info->conversation); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | flags = purple_message_get_flags(info->message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | flags &= ~PURPLE_MESSAGE_SEND; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | flags |= PURPLE_MESSAGE_RECV; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | message = purple_message_new_incoming(who, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | purple_message_get_contents(info->message), |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | flags, 0); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | purple_conversation_write_message(info->conversation, message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | g_clear_object(&message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | return G_SOURCE_REMOVE; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | |
|
42675
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
121 | /****************************************************************************** |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
122 | * PurpleProtocolConversation Implementation |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
123 | *****************************************************************************/ |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
124 | static PurpleCreateConversationDetails * |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
125 | purple_demo_protocol_get_create_conversation_details(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
126 | G_GNUC_UNUSED PurpleAccount *account) |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
127 | { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
128 | return purple_create_conversation_details_new(9); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
129 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
130 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
131 | static void |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
132 | purple_demo_protocol_create_conversation_async(PurpleProtocolConversation *protocol, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
133 | PurpleAccount *account, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
134 | PurpleCreateConversationDetails *details, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
135 | GCancellable *cancellable, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
136 | GAsyncReadyCallback callback, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
137 | gpointer data) |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
138 | { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
139 | PurpleConversation *conversation = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
140 | PurpleConversationManager *manager = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
141 | PurpleConversationType type = PURPLE_CONVERSATION_TYPE_UNSET; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
142 | GListModel *participants = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
143 | GTask *task = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
144 | char *id = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
145 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
146 | task = g_task_new(protocol, cancellable, callback, data); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
147 | g_task_set_source_tag(task, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
148 | purple_demo_protocol_create_conversation_async); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
149 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
150 | participants = purple_create_conversation_details_get_participants(details); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
151 | if(g_list_model_get_n_items(participants) == 1) { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
152 | type = PURPLE_CONVERSATION_TYPE_DM; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
153 | } else { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
154 | type = PURPLE_CONVERSATION_TYPE_GROUP_DM; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
155 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
156 | id = purple_demo_protocol_generate_conversation_id(account, details); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
157 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
158 | conversation = g_object_new( |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
159 | PURPLE_TYPE_CONVERSATION, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
160 | "account", account, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
161 | "id", id, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
162 | "name", "this is required for some reason", |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
163 | "type", type, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
164 | NULL); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
165 | g_clear_pointer(&id, g_free); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
166 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
167 | for(guint i = 0; i < g_list_model_get_n_items(participants); i++) { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
168 | PurpleContactInfo *info = NULL; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
169 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
170 | info = g_list_model_get_item(participants, i); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
171 | purple_conversation_add_member(conversation, info, FALSE, NULL); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
172 | g_clear_object(&info); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
173 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
174 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
175 | manager = purple_conversation_manager_get_default(); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
176 | if(!purple_conversation_manager_register(manager, conversation)) { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
177 | g_task_return_new_error(task, PURPLE_DEMO_DOMAIN, 0, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
178 | _("This conversation already exists.")); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
179 | g_clear_object(&task); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
180 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
181 | return; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
182 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
183 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
184 | g_task_return_pointer(task, conversation, g_object_unref); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
185 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
186 | g_clear_object(&task); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
187 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
188 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
189 | static PurpleConversation * |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
190 | purple_demo_protocol_create_conversation_finish(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
191 | GAsyncResult *result, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
192 | GError **error) |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
193 | { |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
194 | GTask *task = G_TASK(result); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
195 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
196 | g_return_val_if_fail(g_task_get_source_tag(task) == |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
197 | purple_demo_protocol_create_conversation_async, |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
198 | NULL); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
199 | |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
200 | return g_task_propagate_pointer(task, error); |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
201 | } |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
202 | |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | static void |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | purple_demo_protocol_send_message_async(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | PurpleConversation *conversation, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | PurpleMessage *message, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | GCancellable *cancellable, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | GAsyncReadyCallback callback, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | gpointer data) |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | GTask *task = NULL; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | const char *who = NULL; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | who = purple_conversation_get_name(conversation); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | if(purple_strempty(who)) { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | who = purple_message_get_recipient(message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | if(purple_strequal(who, "Echo")) { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | PurpleDemoProtocolIMInfo *info = g_new(PurpleDemoProtocolIMInfo, 1); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | info->conversation = g_object_ref(conversation); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | info->message = g_object_ref(message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
224 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | purple_demo_protocol_echo_im_cb, info, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | (GDestroyNotify)purple_demo_protocol_im_info_free); |
|
42598
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
228 | } else if(purple_strequal(who, "Aegina")) { |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
229 | PurpleDemoProtocolIMInfo *info = g_new(PurpleDemoProtocolIMInfo, 1); |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
230 | const char *author = purple_message_get_author(message); |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
231 | const char *contents = NULL; |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
232 | |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
233 | if(purple_strequal(author, "Hades")) { |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
234 | contents = "🫥️"; |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
235 | } else { |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
236 | /* TRANSLATORS: This is a reference to the Cap of Invisibility owned by |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
237 | * various Greek gods, such as Hades, as mentioned. */ |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
238 | contents = _("Don't tell Hades I have his Cap"); |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
239 | } |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
240 | |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
241 | info->conversation = g_object_ref(conversation); |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
242 | info->message = purple_message_new_outgoing(author, who, contents, |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
243 | PURPLE_MESSAGE_SEND); |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
244 | |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
245 | g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, purple_demo_protocol_echo_im_cb, |
|
5e42cba3e8ad
Add an offline contact in the Demo protocol
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
42323
diff
changeset
|
246 | info, (GDestroyNotify)purple_demo_protocol_im_info_free); |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | purple_conversation_write_message(conversation, message); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | task = g_task_new(protocol, cancellable, callback, data); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | g_task_return_boolean(task, TRUE); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | g_clear_object(&task); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | static gboolean |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | purple_demo_protocol_send_message_finish(G_GNUC_UNUSED PurpleProtocolConversation *protocol, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
259 | GAsyncResult *result, |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
260 | GError **error) |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
261 | { |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
262 | g_return_val_if_fail(G_IS_TASK(result), FALSE); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
263 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | return g_task_propagate_boolean(G_TASK(result), error); |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | } |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | void |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | purple_demo_protocol_conversation_init(PurpleProtocolConversationInterface *iface) { |
|
42675
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
269 | iface->get_create_conversation_details = |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
270 | purple_demo_protocol_get_create_conversation_details; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
271 | iface->create_conversation_async = |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
272 | purple_demo_protocol_create_conversation_async; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
273 | iface->create_conversation_finish = |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
274 | purple_demo_protocol_create_conversation_finish; |
|
69e078981440
Implement conversation create for the demo protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42652
diff
changeset
|
275 | |
|
42323
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | iface->send_message_async = purple_demo_protocol_send_message_async; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | iface->send_message_finish = purple_demo_protocol_send_message_finish; |
|
119cc14f9c12
Port the Demo protocol plugin to PurpleProtocolConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | } |