libpurple/purplechatuser.c

Tue, 09 Apr 2024 21:50:31 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 09 Apr 2024 21:50:31 -0500
changeset 42656
df9aafbae930
parent 42594
eddde70cedd8
child 42706
6039c89f2f5c
permissions
-rw-r--r--

Add a doc-check unit test to libpurple and fix the issues it has found

Testing Done:
Ran ninja turtles

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

40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
2 * Purple - Internet Messaging Library
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
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: 42576
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: 42576
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: 42576
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: 42576
diff changeset
12 * any later version.
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
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: 42576
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: 42576
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: 42576
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: 42576
diff changeset
17 * more details.
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42576
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: 42576
diff changeset
20 * this library; if not, see <https://www.gnu.org/licenses/>.
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purplechatuser.h"
41137
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41007
diff changeset
24
3c1574216aed Now that the History API is here, remove the purple logging api
Gary Kramlich <grim@reaperworld.com>
parents: 41007
diff changeset
25 #include "conversations.h"
41007
90d2dee9b3dc Fix the includes for the purpleenums rename
Gary Kramlich <grim@reaperworld.com>
parents: 40639
diff changeset
26 #include "purpleenums.h"
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 struct _PurpleChatUser {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 GObject parent;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 PurpleChatConversation *chat; /* The chat */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 gchar *name; /* The chat participant's name in the
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 chat. */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 gchar *alias; /* The chat participant's alias, if known;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 NULL otherwise. */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 gboolean buddy; /* TRUE if this chat participant is on
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 the buddy list; FALSE otherwise. */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 PurpleChatUserFlags flags; /* A bitwise OR of flags for this
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 participant, such as whether they
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 are a channel operator. */
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
41
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
42 gboolean constructed;
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 };
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 enum {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PROP_0,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 PROP_CHAT,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_NAME,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PROP_ALIAS,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 PROP_FLAGS,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 N_PROPERTIES,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 };
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 /**************************************************************************
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 * Private Setters
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 **************************************************************************/
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 purple_chat_user_set_name(PurpleChatUser *chat_user, const gchar *name) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 g_return_if_fail(PURPLE_IS_CHAT_USER(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 g_free(chat_user->name);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 chat_user->name = g_strdup(name);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 g_object_notify_by_pspec(G_OBJECT(chat_user), properties[PROP_NAME]);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 purple_chat_user_set_alias(PurpleChatUser *chat_user, const gchar *alias) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 g_return_if_fail(PURPLE_IS_CHAT_USER(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 g_free(chat_user->alias);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 chat_user->alias = g_strdup(alias);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 g_object_notify_by_pspec(G_OBJECT(chat_user), properties[PROP_ALIAS]);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 /**************************************************************************
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 * GObject Implementation
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 **************************************************************************/
42576
ab1ca778ddb2 Make sure all of the final types in libpurple are defined as such
Gary Kramlich <grim@reaperworld.com>
parents: 41137
diff changeset
81 G_DEFINE_FINAL_TYPE(PurpleChatUser, purple_chat_user, G_TYPE_OBJECT)
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 purple_chat_user_set_property(GObject *obj, guint param_id, const GValue *value,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 GParamSpec *pspec)
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 PurpleChatUser *chat_user = PURPLE_CHAT_USER(obj);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 switch (param_id) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 case PROP_CHAT:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 purple_chat_user_set_chat(chat_user, g_value_get_object(value));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 case PROP_NAME:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 purple_chat_user_set_name(chat_user, g_value_get_string(value));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 case PROP_ALIAS:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 purple_chat_user_set_alias(chat_user, g_value_get_string(value));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 case PROP_FLAGS:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 purple_chat_user_set_flags(chat_user, g_value_get_flags(value));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 default:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 purple_chat_user_get_property(GObject *obj, guint param_id, GValue *value,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 GParamSpec *pspec)
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 PurpleChatUser *chat_user = PURPLE_CHAT_USER(obj);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
114 switch (param_id) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 case PROP_CHAT:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_value_set_object(value, purple_chat_user_get_chat(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 case PROP_NAME:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 g_value_set_string(value, purple_chat_user_get_name(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 case PROP_ALIAS:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 g_value_set_string(value, purple_chat_user_get_alias(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 case PROP_FLAGS:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 g_value_set_flags(value, purple_chat_user_get_flags(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 default:
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 break;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 purple_chat_user_init(PurpleChatUser *user) {
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
135 user->constructed = FALSE;
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 purple_chat_user_constructed(GObject *object) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 PurpleChatUser *chat_user = NULL;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 PurpleAccount *account = NULL;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 G_OBJECT_CLASS(purple_chat_user_parent_class)->constructed(object);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 chat_user = PURPLE_CHAT_USER(object);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 account = purple_conversation_get_account(PURPLE_CONVERSATION(chat_user->chat));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 if(purple_blist_find_buddy(account, chat_user->name) != NULL) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 chat_user->buddy = TRUE;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 }
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
151
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
152 chat_user->constructed = TRUE;
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 purple_chat_user_finalize(GObject *object) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 PurpleChatUser *chat_user = PURPLE_CHAT_USER(object);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 g_free(chat_user->alias);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 g_free(chat_user->name);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 G_OBJECT_CLASS(purple_chat_user_parent_class)->finalize(object);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 static void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 purple_chat_user_class_init(PurpleChatUserClass *klass) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 obj_class->constructed = purple_chat_user_constructed;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 obj_class->get_property = purple_chat_user_get_property;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 obj_class->set_property = purple_chat_user_set_property;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 obj_class->finalize = purple_chat_user_finalize;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
174 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
175 * PurpleChatUser:chat:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
176 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
177 * The chat the user is in.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
178 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
179 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
180 */
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 properties[PROP_CHAT] = g_param_spec_object(
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 "chat", "Chat",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 "The chat the buddy belongs to.",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 PURPLE_TYPE_CHAT_CONVERSATION,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
187 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
188 * PurpleChatUser:name:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
189 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
190 * The name of the user.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
191 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
192 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
193 */
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 properties[PROP_NAME] = g_param_spec_string(
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 "name", "Name",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 "Name of the chat user.",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 NULL,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
200 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
201 * PurpleChatUser:alias:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
202 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
203 * The alias of the user.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
204 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
205 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
206 */
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 properties[PROP_ALIAS] = g_param_spec_string(
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 "alias", "Alias",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 "Alias of the chat user.",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 NULL,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212
42656
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
213 /**
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
214 * PurpleChatUser:flags:
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
215 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
216 * The flags for the user.
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
217 *
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
218 * Since: 3.0
df9aafbae930 Add a doc-check unit test to libpurple and fix the issues it has found
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
219 */
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 properties[PROP_FLAGS] = g_param_spec_flags(
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 "flags", "Buddy flags",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 "The flags for the chat user.",
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 PURPLE_TYPE_CHAT_USER_FLAGS,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 PURPLE_CHAT_USER_NONE,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 /******************************************************************************
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 * Public API
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 *****************************************************************************/
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 PurpleChatUser *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 purple_chat_user_new(PurpleChatConversation *chat, const gchar *name,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 const gchar *alias, PurpleChatUserFlags flags)
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 PurpleChatUser *chat_user = NULL;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 g_return_val_if_fail(PURPLE_IS_CHAT_CONVERSATION(chat), NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 g_return_val_if_fail(name != NULL, NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 chat_user = g_object_new(
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 PURPLE_TYPE_CHAT_USER,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 "chat", chat,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 "name", name,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 "alias", alias,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 "flags", flags,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 return chat_user;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 const gchar *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 purple_chat_user_get_alias(PurpleChatUser *chat_user) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 g_return_val_if_fail(PURPLE_IS_CHAT_USER(chat_user), NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 return chat_user->alias;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 const gchar *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 purple_chat_user_get_name(PurpleChatUser *chat_user) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 g_return_val_if_fail(PURPLE_IS_CHAT_USER(chat_user), NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 return chat_user->name;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 purple_chat_user_set_flags(PurpleChatUser *chat_user,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 PurpleChatUserFlags flags)
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
271 PurpleConversationUiOps *ops;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 PurpleChatUserFlags oldflags;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 g_return_if_fail(PURPLE_IS_CHAT_USER(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
276 if(flags == chat_user->flags) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277 return;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
278 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 oldflags = chat_user->flags;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 chat_user->flags = flags;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 g_object_notify_by_pspec(G_OBJECT(chat_user), properties[PROP_FLAGS]);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
285 /* Only update the UI once the object is fully constructed. This avoids an
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
286 * issue where at least with XMPP, user names will be duplicated in the
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
287 * chat user list.
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
288 */
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
289 if(chat_user->constructed) {
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
290 ops = purple_conversation_get_ui_ops(PURPLE_CONVERSATION(chat_user->chat));
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
291 if(ops != NULL && ops->chat_update_user != NULL) {
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
292 ops->chat_update_user(chat_user);
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
293 }
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 purple_signal_emit(purple_conversations_get_handle(),
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 "chat-user-flags", chat_user, oldflags, flags);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 PurpleChatUserFlags
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 purple_chat_user_get_flags(PurpleChatUser *chat_user) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 g_return_val_if_fail(PURPLE_IS_CHAT_USER(chat_user), PURPLE_CHAT_USER_NONE);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 return chat_user->flags;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 void
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 purple_chat_user_set_chat(PurpleChatUser *chat_user,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 PurpleChatConversation *chat)
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 g_return_if_fail(PURPLE_IS_CHAT_USER(chat_user));
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 if(g_set_object(&chat_user->chat, chat)) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 g_object_notify_by_pspec(G_OBJECT(chat_user), properties[PROP_CHAT]);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
316 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 PurpleChatConversation *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 purple_chat_user_get_chat(PurpleChatUser *chat_user) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 g_return_val_if_fail(PURPLE_IS_CHAT_USER(chat_user), NULL);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 return chat_user->chat;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 gboolean
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 purple_chat_user_is_buddy(PurpleChatUser *chat_user) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 g_return_val_if_fail(PURPLE_IS_CHAT_USER(chat_user), FALSE);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 return chat_user->buddy;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
331
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 gint
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 purple_chat_user_compare(PurpleChatUser *a, PurpleChatUser *b) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 gchar *namea = NULL, *nameb = NULL;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 /* NULL is equal to NULL */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 if(a == NULL && b == NULL) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 return 0;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 /* non-NULL sorts before NULL */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 if(a == NULL && b != NULL) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343 return 1;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 } else if(a != NULL && b == NULL) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 return -1;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 /* higher valued flags sort before lower values */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 if(a->flags > b->flags) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 return -1;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 } else if(a->flags < b->flags) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 return 1;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 /* buddies sort before non-buddies */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 if(a->buddy != b->buddy) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 return a->buddy ? -1 : 1;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
360 /* figure out what name we need to check for user a */
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
361 if(a->alias) {
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
362 namea = a->alias;
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 } else if (a->name) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
364 namea = a->name;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 /* figure out what name we need to check for user b */
40639
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
368 if(b->alias) {
732fde496206 Fix a bunch of issues with PurpleChatUser including one that caused user names to be duplicated in XMPP MUCs
Gary Kramlich <grim@reaperworld.com>
parents: 40539
diff changeset
369 nameb = b->alias;
40517
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 } else if(b->name) {
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 nameb = b->name;
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 /* finally we're just sorting names */
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 return purple_utf8_strcasecmp(namea, nameb);
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 }

mercurial