libpurple/purpleconversationmember.c

Thu, 22 Feb 2024 06:03:16 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 22 Feb 2024 06:03:16 -0600
changeset 42596
b64b96f3b781
parent 42594
eddde70cedd8
child 42613
780d7efe37c2
permissions
-rw-r--r--

Add a favorite property to PurpleContactInfo

This will be used in the future for toggling whether or not contacts are
favorited or starred.

Testing Done:
Ran the unit tests under valgrind.

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

42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
7 * source distribution.
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
18 *
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleconversationmember.h"
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
25 #include "purpleenums.h"
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
26
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 struct _PurpleConversationMember {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 GObject parent;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PurpleContactInfo *contact_info;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 PurpleTags *tags;
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
32
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
33 guint typing_timeout;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
34 PurpleTypingState typing_state;
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 };
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 enum {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PROP_0,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 PROP_CONTACT_INFO,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_TAGS,
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
41 PROP_TYPING_STATE,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
42 N_PROPERTIES,
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 };
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
46 G_DEFINE_FINAL_TYPE(PurpleConversationMember, purple_conversation_member,
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 42175
diff changeset
47 G_TYPE_OBJECT)
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 /******************************************************************************
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 * Helpers
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 *****************************************************************************/
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 purple_conversation_member_set_contact_info(PurpleConversationMember *member,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 PurpleContactInfo *contact_info)
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 g_return_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member));
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 g_return_if_fail(PURPLE_IS_CONTACT_INFO(contact_info));
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 if(g_set_object(&member->contact_info, contact_info)) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 g_object_notify_by_pspec(G_OBJECT(member),
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 properties[PROP_CONTACT_INFO]);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 /******************************************************************************
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
66 * Callbacks
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
67 *****************************************************************************/
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
68 static gboolean
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
69 purple_conversation_member_reset_typing_state(gpointer data) {
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
70 PurpleConversationMember *member = data;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
71
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
72 purple_conversation_member_set_typing_state(member,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
73 PURPLE_TYPING_STATE_NONE,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
74 0);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
75
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
76 return G_SOURCE_REMOVE;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
77 }
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
78
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
79 /******************************************************************************
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 * GObject Implementation
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 *****************************************************************************/
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 purple_conversation_member_get_property(GObject *obj, guint param_id,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 GValue *value, GParamSpec *pspec)
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 switch(param_id) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 case PROP_CONTACT_INFO:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 g_value_set_object(value,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_conversation_member_get_contact_info(member));
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 break;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 case PROP_TAGS:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 g_value_set_object(value,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 purple_conversation_member_get_tags(member));
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 break;
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
97 case PROP_TYPING_STATE:
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
98 g_value_set_enum(value,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
99 purple_conversation_member_get_typing_state(member));
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
100 break;
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 default:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 break;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 purple_conversation_member_set_property(GObject *obj, guint param_id,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 const GValue *value, GParamSpec *pspec)
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 switch(param_id) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 case PROP_CONTACT_INFO:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 purple_conversation_member_set_contact_info(member,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_value_get_object(value));
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 break;
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
118 case PROP_TYPING_STATE:
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
119 purple_conversation_member_set_typing_state(member,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
120 g_value_get_enum(value),
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
121 0);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
122 break;
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 default:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 break;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 purple_conversation_member_dispose(GObject *obj) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 g_clear_object(&member->contact_info);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42113
diff changeset
135 g_clear_handle_id(&member->typing_timeout, g_source_remove);
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
136
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 G_OBJECT_CLASS(purple_conversation_member_parent_class)->dispose(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 purple_conversation_member_finalize(GObject *obj) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 PurpleConversationMember *member = PURPLE_CONVERSATION_MEMBER(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 g_clear_object(&member->tags);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 G_OBJECT_CLASS(purple_conversation_member_parent_class)->finalize(obj);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 purple_conversation_member_init(PurpleConversationMember *member) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 member->tags = purple_tags_new();
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 static void
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 purple_conversation_member_class_init(PurpleConversationMemberClass *klass) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 obj_class->dispose = purple_conversation_member_dispose;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 obj_class->finalize = purple_conversation_member_finalize;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 obj_class->get_property = purple_conversation_member_get_property;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 obj_class->set_property = purple_conversation_member_set_property;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 /**
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 * PurpleConversationMember:contact-info:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 * The contact info that this member is for.
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 * Since: 3.0.0
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 */
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 properties[PROP_CONTACT_INFO] = g_param_spec_object(
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 "contact-info", "contact-info",
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 "The contact-info this member is for",
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 PURPLE_TYPE_CONTACT_INFO,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 /**
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 * PurpleConversationMember:tags:
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 * The [class@Purple.Tags] instance for this member.
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 * Since: 3.0.0
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 */
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 properties[PROP_TAGS] = g_param_spec_object(
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 "tags", "tags",
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 "The tags for this member",
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 PURPLE_TYPE_TAGS,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
189 /**
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
190 * PurpleConversationMember:typing-state:
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
191 *
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
192 * The [enum@Purple.TypingState] for this member.
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
193 *
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
194 * Since: 3.0.0
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
195 */
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
196 properties[PROP_TYPING_STATE] = g_param_spec_enum(
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
197 "typing-state", "typing-state",
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
198 "The typing state for this member",
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
199 PURPLE_TYPE_TYPING_STATE,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
200 PURPLE_TYPING_STATE_NONE,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
201 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
202
42080
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 /******************************************************************************
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 * Public API
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 *****************************************************************************/
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 PurpleConversationMember *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 purple_conversation_member_new(PurpleContactInfo *info) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 g_return_val_if_fail(PURPLE_IS_CONTACT_INFO(info), NULL);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 return g_object_new(
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 PURPLE_TYPE_CONVERSATION_MEMBER,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 "contact-info", info,
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 NULL);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 PurpleContactInfo *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 purple_conversation_member_get_contact_info(PurpleConversationMember *member) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member), NULL);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 return member->contact_info;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 }
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 PurpleTags *
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 purple_conversation_member_get_tags(PurpleConversationMember *member) {
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member), NULL);
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 return member->tags;
df47db24cee6 Add PurpleConversationMember to link a PurpleContactInfo to a PurpleConversation
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 }
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
232
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
233 PurpleTypingState
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
234 purple_conversation_member_get_typing_state(PurpleConversationMember *member)
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
235 {
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
236 g_return_val_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member),
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
237 PURPLE_TYPING_STATE_NONE);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
238
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
239 return member->typing_state;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
240 }
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
241
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
242 void
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
243 purple_conversation_member_set_typing_state(PurpleConversationMember *member,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
244 PurpleTypingState state,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
245 guint seconds)
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
246 {
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
247 g_return_if_fail(PURPLE_IS_CONVERSATION_MEMBER(member));
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
248
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
249 /* Remove an existing timeout if necessary. */
42175
4185b4043214 Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42113
diff changeset
250 g_clear_handle_id(&member->typing_timeout, g_source_remove);
42113
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
251
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
252 /* If the state has changed, notify. */
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
253 if(state != member->typing_state) {
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
254 member->typing_state = state;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
255
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
256 g_object_notify_by_pspec(G_OBJECT(member),
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
257 properties[PROP_TYPING_STATE]);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
258 }
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
259
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
260 /* If we got a timeout, add it. */
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
261 if(seconds > 0) {
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
262 guint source = 0;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
263
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
264 source = g_timeout_add_seconds(seconds,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
265 purple_conversation_member_reset_typing_state,
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
266 member);
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
267
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
268 member->typing_timeout = source;
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
269 }
393c2ea6b399 Add PurpleTypingState and add it as a property to PurpleConversationMember
Gary Kramlich <grim@reaperworld.com>
parents: 42080
diff changeset
270 }

mercurial