libpurple/purpleimconversation.c

Wed, 14 Dec 2022 03:36:52 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Wed, 14 Dec 2022 03:36:52 -0600
changeset 41981
e2d8eb34ebe7
parent 41960
c8a4853205e3
child 42001
63635ba9f117
permissions
-rw-r--r--

Remove the icon from PurpleIMConversation

The intent is to move this functionality to PurpleConversation once PurpleAvatar
has laned, so this just moves the exist code out of the way.

Testing Done:
Ran the tests and ran with demo and xmmp accounts. Avatars are busted in the info pane at the moment.

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

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
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 #include <libpurple/purpleimconversation.h>
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
40870
e3397381fd35 Remove includes from protocol.h that weren't used there and deal with the fallout
Gary Kramlich <grim@reaperworld.com>
parents: 40765
diff changeset
24 #include <libpurple/debug.h>
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41007
diff changeset
25 #include <libpurple/conversations.h>
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
26 #include <libpurple/purpleconversationmanager.h>
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40992
diff changeset
27 #include <libpurple/purpleenums.h>
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 #include <libpurple/purpleprivate.h>
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40506
diff changeset
29 #include <libpurple/purpleprotocolclient.h>
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 struct _PurpleIMConversation {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 PurpleConversation parent;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 PurpleIMTypingState typing_state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 guint typing_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 time_t type_again;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 guint send_typed_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 };
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 enum {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_0 = 0,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 PROP_TYPING_STATE,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 N_PROPERTIES,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 };
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 static GParamSpec *properties[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 #define SEND_TYPED_TIMEOUT_SECONDS 5
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 /******************************************************************************
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 * Callbacks
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 static gboolean
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 purple_im_conversation_reset_typing_cb(gpointer data)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(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 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
58 purple_im_conversation_stop_typing_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 return FALSE;
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
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 static gboolean
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 purple_im_conversation_send_typed_cb(gpointer data)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(data);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PurpleConnection *pc = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 const gchar *name;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 g_return_val_if_fail(im != NULL, FALSE);
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 pc = purple_conversation_get_connection(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 name = purple_conversation_get_name(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 if(pc != NULL && name != NULL) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 /* 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
77 * user types anything else.
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 */
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 purple_im_conversation_set_type_again(im, 1);
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_serv_send_typing(pc, name, PURPLE_IM_TYPED);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
40765
a5381c20e802 Use specific purple_debug_* functions
Arkadiy Illarionov <qarkai@gmail.com>
parents: 40634
diff changeset
83 purple_debug_misc("purple-im-conversation", "typed...");
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 return FALSE;
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
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 * PurpleConversation Implementation
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 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 im_conversation_write_message(PurpleConversation *conv, PurpleMessage *msg) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(conv);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 gboolean is_recv = FALSE;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 g_return_if_fail(im != NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 g_return_if_fail(msg != NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 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
101
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 if(is_recv) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 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
104 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 _purple_conversation_write_common(conv, msg);
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
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 * GObject Implementation
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 G_DEFINE_TYPE(PurpleIMConversation, purple_im_conversation,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 PURPLE_TYPE_CONVERSATION);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 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
117 GParamSpec *pspec)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
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 switch (param_id) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 case PROP_TYPING_STATE:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 g_value_set_enum(value,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 purple_im_conversation_get_typing_state(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 default:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 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
128 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
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 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 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
134 const GValue *value, GParamSpec *pspec)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
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 switch (param_id) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 case PROP_TYPING_STATE:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 purple_im_conversation_set_typing_state(im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 g_value_get_enum(value));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 default:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 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
145 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 }
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 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
150 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
151 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 purple_im_conversation_finalize(GObject *obj) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 PurpleIMConversation *im = PURPLE_IM_CONVERSATION(obj);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 PurpleConnection *pc = purple_conversation_get_connection(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 PurpleProtocol *protocol = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 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
159
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 if(pc != NULL) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 /* Still connected */
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 protocol = purple_connection_get_protocol(pc);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 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
165 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
166 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167
40634
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40506
diff changeset
168 purple_protocol_client_convo_closed(PURPLE_PROTOCOL_CLIENT(protocol),
4d3018b00ad4 Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents: 40506
diff changeset
169 pc, name);
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 purple_im_conversation_stop_typing_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 purple_im_conversation_stop_send_typed_timeout(im);
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 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
176 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 static void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 purple_im_conversation_class_init(PurpleIMConversationClass *klass) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 PurpleConversationClass *conv_class = PURPLE_CONVERSATION_CLASS(klass);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 obj_class->get_property = purple_im_conversation_get_property;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 obj_class->set_property = purple_im_conversation_set_property;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 obj_class->finalize = purple_im_conversation_finalize;
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 conv_class->write_message = im_conversation_write_message;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 properties[PROP_TYPING_STATE] = g_param_spec_enum(
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 "typing-state", "Typing state",
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 "Status of the user's typing of a message.",
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 PURPLE_TYPE_IM_TYPING_STATE, PURPLE_IM_NOT_TYPING,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 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
196 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197
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 * Public API
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 *****************************************************************************/
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40870
diff changeset
201 PurpleConversation *
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 purple_im_conversation_new(PurpleAccount *account, const char *name)
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 {
40885
87f6241da196 Update purple_conversations_find_* to return PurpleConversations instead of subclasses
Gary Kramlich <grim@reaperworld.com>
parents: 40870
diff changeset
204 PurpleConversation *im = NULL;
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
205 PurpleConversationManager *manager = NULL;
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 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
208 g_return_val_if_fail(name != NULL, NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 /* Check if this conversation already exists. */
40992
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
211 manager = purple_conversation_manager_get_default();
3a973a9c5a64 migrate libpurple to the ConversationManager API
Gary Kramlich <grim@reaperworld.com>
parents: 40885
diff changeset
212 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
213 if(PURPLE_IS_IM_CONVERSATION(im)) {
40506
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 return g_object_ref(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 im = g_object_new(PURPLE_TYPE_IM_CONVERSATION,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 "account", account,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 "name", name,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 "title", name,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 NULL);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 return im;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 purple_im_conversation_set_typing_state(PurpleIMConversation *im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 PurpleIMTypingState state)
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 PurpleAccount *account = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 const gchar *name = NULL;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 name = purple_conversation_get_name(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 account = purple_conversation_get_account(PURPLE_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 if(im->typing_state != state) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 im->typing_state = state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 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
242
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 switch (state) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 case PURPLE_IM_TYPING:
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 purple_signal_emit(purple_conversations_get_handle(),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 "buddy-typing", account, name);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 break;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 case PURPLE_IM_TYPED:
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-typed", 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_NOT_TYPING:
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-typing-stopped", 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 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 purple_im_conversation_update_typing(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 }
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 PurpleIMTypingState
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 purple_im_conversation_get_typing_state(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 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
265
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 return im->typing_state;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 purple_im_conversation_start_typing_timeout(PurpleIMConversation *im,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 gint timeout)
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 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 if(im->typing_timeout > 0) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 purple_im_conversation_stop_typing_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279 im->typing_timeout =
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 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
281 im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282 }
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 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 purple_im_conversation_stop_typing_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 if(im->typing_timeout == 0) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 return;
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 g_source_remove(im->typing_timeout);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 im->typing_timeout = 0;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 }
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 guint
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 purple_im_conversation_get_typing_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 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
299
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 return im->typing_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 }
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 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 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
305 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 if(val == 0) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 im->type_again = 0;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 } else {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 im->type_again = time(NULL) + val;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 }
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 time_t
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 purple_im_conversation_get_type_again(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 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
317
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 return im->type_again;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 }
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 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 purple_im_conversation_start_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 purple_im_conversation_stop_send_typed_timeout(im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 im->send_typed_timeout =
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 g_timeout_add_seconds(SEND_TYPED_TIMEOUT_SECONDS,
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 purple_im_conversation_send_typed_cb, im);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 purple_im_conversation_stop_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 if(im->send_typed_timeout == 0) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 return;
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
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 g_source_remove(im->send_typed_timeout);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 im->send_typed_timeout = 0;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 guint
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 purple_im_conversation_get_send_typed_timeout(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 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
346
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 return im->send_typed_timeout;
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 }
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 void
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 purple_im_conversation_update_typing(PurpleIMConversation *im) {
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 g_return_if_fail(PURPLE_IS_IM_CONVERSATION(im));
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 purple_conversation_update(PURPLE_CONVERSATION(im),
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 PURPLE_CONVERSATION_UPDATE_TYPING);
cb26b9c6d4d0 Move PurpleIMConversation to its own file
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 }

mercurial