libpurple/purpleimconversation.c

Fri, 20 Oct 2023 01:09:45 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 20 Oct 2023 01:09:45 -0500
changeset 42375
8e61249e9b10
parent 42338
2548eb61acc9
child 42557
e868bfcc092a
permissions
-rw-r--r--

Implement ProtocolFileTransfer

Testing Done:
Ran the unit tests under valgrind.

Bugs closed: PIDGIN-17833

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

40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * purple
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 *
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * source distribution.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 *
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * (at your option) any later version.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 *
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * GNU General Public License for more details.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 *
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * along with this program; if not, see <https://www.gnu.org/licenses/>.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 */
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21
42338
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
22 #include "purpleimconversation.h"
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
42338
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
24 #include "debug.h"
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
25 #include "conversations.h"
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
26 #include "purpleconversationmanager.h"
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
27 #include "purpleenums.h"
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
28 #include "purpleprivate.h"
2548eb61acc9 Make sure all internal includes use double quotes
Gary Kramlich <grim@reaperworld.com>
parents: 42258
diff changeset
29 #include "purpleprotocolclient.h"
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
42258
a4053066d6ca Some minor include clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
31 #include "server.h"
a4053066d6ca Some minor include clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
32
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 struct _PurpleIMConversation {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PurpleConversation parent;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 PurpleIMTypingState typing_state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 guint typing_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 time_t type_again;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 guint send_typed_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 };
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 enum {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 PROP_0 = 0,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_TYPING_STATE,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 N_PROPERTIES,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 };
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 static GParamSpec *properties[N_PROPERTIES];
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 #define SEND_TYPED_TIMEOUT_SECONDS 5
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 /******************************************************************************
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 * Callbacks
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 *****************************************************************************/
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 static gboolean
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 purple_im_conversation_reset_typing_cb(gpointer data)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(data);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 purple_im_conversation_set_typing_state(im, PURPLE_IM_NOT_TYPING);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 purple_im_conversation_stop_typing_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 return FALSE;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 static gboolean
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 purple_im_conversation_send_typed_cb(gpointer data)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(data);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 PurpleConnection *pc = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 const gchar *name;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 g_return_val_if_fail(im != NULL, FALSE);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 pc = purple_conversation_get_connection(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 name = purple_conversation_get_name(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 if(pc != NULL && name != NULL) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 /* We set this to 1 so that PURPLE_IM_TYPING will be sent if the Purple
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 * user types anything else.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 */
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 purple_im_conversation_set_type_again(im, 1);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 purple_serv_send_typing(pc, name, PURPLE_IM_TYPED);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40634
diff changeset
85 purple_debug_misc("purple-im-conversation", "typed...");
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 return FALSE;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 /******************************************************************************
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 * PurpleConversation Implementation
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 *****************************************************************************/
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 im_conversation_write_message(PurpleConversation *conv, PurpleMessage *msg) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(conv);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 gboolean is_recv = FALSE;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 g_return_if_fail(im != NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 g_return_if_fail(msg != NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 is_recv = (purple_message_get_flags(msg) & PURPLE_MESSAGE_RECV);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 if(is_recv) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 purple_im_conversation_set_typing_state(im, PURPLE_IM_NOT_TYPING);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 _purple_conversation_write_common(conv, msg);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 /******************************************************************************
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 * GObject Implementation
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 *****************************************************************************/
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 G_DEFINE_TYPE(PurpleIMConversation, purple_im_conversation,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 PURPLE_TYPE_CONVERSATION);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 purple_im_conversation_get_property(GObject *obj, guint param_id, GValue *value,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 GParamSpec *pspec)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 switch (param_id) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 case PROP_TYPING_STATE:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_value_set_enum(value,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 purple_im_conversation_get_typing_state(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 default:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 purple_im_conversation_set_property(GObject *obj, guint param_id,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 const GValue *value, GParamSpec *pspec)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 switch (param_id) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 case PROP_TYPING_STATE:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 purple_im_conversation_set_typing_state(im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 g_value_get_enum(value));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 default:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 static void
41960
c8a4853205e3 Bump C standard to C99 for libpurple files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41137
diff changeset
152 purple_im_conversation_init(G_GNUC_UNUSED PurpleIMConversation *im) {
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 purple_im_conversation_finalize(GObject *obj) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 PurpleConnection *pc = purple_conversation_get_connection(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 PurpleProtocol *protocol = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 const gchar *name = purple_conversation_get_name(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 if(pc != NULL) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /* Still connected */
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 protocol = purple_connection_get_protocol(pc);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 if(purple_prefs_get_bool("/purple/conversations/im/send_typing")) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 purple_serv_send_typing(pc, name, PURPLE_IM_NOT_TYPING);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169
42001
63635ba9f117 Make sure a protocol implements PurpleProtocolClient before calling those methods
Gary Kramlich <grim@reaperworld.com>
parents: 41981
diff changeset
170 if(PURPLE_IS_PROTOCOL_CLIENT(protocol)) {
63635ba9f117 Make sure a protocol implements PurpleProtocolClient before calling those methods
Gary Kramlich <grim@reaperworld.com>
parents: 41981
diff changeset
171 purple_protocol_client_convo_closed(PURPLE_PROTOCOL_CLIENT(protocol),
63635ba9f117 Make sure a protocol implements PurpleProtocolClient before calling those methods
Gary Kramlich <grim@reaperworld.com>
parents: 41981
diff changeset
172 pc, name);
63635ba9f117 Make sure a protocol implements PurpleProtocolClient before calling those methods
Gary Kramlich <grim@reaperworld.com>
parents: 41981
diff changeset
173 }
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 purple_im_conversation_stop_typing_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 purple_im_conversation_stop_send_typed_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 G_OBJECT_CLASS(purple_im_conversation_parent_class)->finalize(obj);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 purple_im_conversation_class_init(PurpleIMConversationClass *klass) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 PurpleConversationClass *conv_class = PURPLE_CONVERSATION_CLASS(klass);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 obj_class->get_property = purple_im_conversation_get_property;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 obj_class->set_property = purple_im_conversation_set_property;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 obj_class->finalize = purple_im_conversation_finalize;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 conv_class->write_message = im_conversation_write_message;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 properties[PROP_TYPING_STATE] = g_param_spec_enum(
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 "typing-state", "Typing state",
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 "Status of the user's typing of a message.",
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 PURPLE_TYPE_IM_TYPING_STATE, PURPLE_IM_NOT_TYPING,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 /******************************************************************************
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 * Public API
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 *****************************************************************************/
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40870
diff changeset
205 PurpleConversation *
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 purple_im_conversation_new(PurpleAccount *account, const char *name)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40870
diff changeset
208 PurpleConversation *im = NULL;
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
209 PurpleConversationManager *manager = NULL;
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 g_return_val_if_fail(name != NULL, NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 /* Check if this conversation already exists. */
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
215 manager = purple_conversation_manager_get_default();
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
216 im = purple_conversation_manager_find_im(manager, account, name);
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
217 if(PURPLE_IS_IM_CONVERSATION(im)) {
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 return g_object_ref(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 im = g_object_new(PURPLE_TYPE_IM_CONVERSATION,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "account", account,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 "name", name,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 "title", name,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 return im;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 purple_im_conversation_set_typing_state(PurpleIMConversation *im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 PurpleIMTypingState state)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 PurpleAccount *account = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 const gchar *name = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 name = purple_conversation_get_name(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 account = purple_conversation_get_account(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 if(im->typing_state != state) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 im->typing_state = state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 g_object_notify_by_pspec(G_OBJECT(im), properties[PROP_TYPING_STATE]);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 switch (state) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 case PURPLE_IM_TYPING:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 purple_signal_emit(purple_conversations_get_handle(),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 "buddy-typing", account, name);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 case PURPLE_IM_TYPED:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 purple_signal_emit(purple_conversations_get_handle(),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 "buddy-typed", account, name);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 case PURPLE_IM_NOT_TYPING:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 purple_signal_emit(purple_conversations_get_handle(),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 "buddy-typing-stopped", account, name);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 purple_im_conversation_update_typing(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 PurpleIMTypingState
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 purple_im_conversation_get_typing_state(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 g_return_val_if_fail(PURPLE_IS_IM_CONVERSATION(im), 0);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 return im->typing_state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 purple_im_conversation_start_typing_timeout(PurpleIMConversation *im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 gint timeout)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42001
diff changeset
279 purple_im_conversation_stop_typing_timeout(im);
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 im->typing_timeout =
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 g_timeout_add_seconds(timeout, purple_im_conversation_reset_typing_cb,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 purple_im_conversation_stop_typing_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42001
diff changeset
289 g_clear_handle_id(&im->typing_timeout, g_source_remove);
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 guint
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 purple_im_conversation_get_typing_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 g_return_val_if_fail(PURPLE_IS_IM_CONVERSATION(im), 0);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 return im->typing_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 purple_im_conversation_set_type_again(PurpleIMConversation *im, guint val) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 if(val == 0) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 im->type_again = 0;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 } else {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 im->type_again = time(NULL) + val;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 time_t
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 purple_im_conversation_get_type_again(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 g_return_val_if_fail(PURPLE_IS_IM_CONVERSATION(im), 0);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 return im->type_again;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 purple_im_conversation_start_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 purple_im_conversation_stop_send_typed_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 im->send_typed_timeout =
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 g_timeout_add_seconds(SEND_TYPED_TIMEOUT_SECONDS,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 purple_im_conversation_send_typed_cb, im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42001
diff changeset
331 g_clear_handle_id(&im->typing_timeout, g_source_remove);
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 guint
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 purple_im_conversation_get_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 g_return_val_if_fail(PURPLE_IS_IM_CONVERSATION(im), 0);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 return im->send_typed_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 purple_im_conversation_update_typing(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 purple_conversation_update(PURPLE_CONVERSATION(im),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 PURPLE_CONVERSATION_UPDATE_TYPING);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 }

mercurial