libpurple/purplechatuser.c

Mon, 15 Aug 2022 02:39:09 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 15 Aug 2022 02:39:09 -0500
branch
gtk4
changeset 41561
ac5416e7e4f5
parent 41137
3c1574216aed
child 42576
ab1ca778ddb2
permissions
-rw-r--r--

Port PidginAddBuddyDialog to GTK4

Testing Done:
Compiled

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

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
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with 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
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 *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
5211982886af Move 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 *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 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
17 * GNU General Public License for more details.
5211982886af Move 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 *
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40539
2941deda6d8d Use an https link to gnu.org in the license file headers
Gary Kramlich <grim@reaperworld.com>
parents: 40518
diff changeset
20 * along with this program; 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 **************************************************************************/
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 G_DEFINE_TYPE(PurpleChatUser, purple_chat_user, G_TYPE_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
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
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 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
175 "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
176 "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
177 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
178 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
179
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 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
181 "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
182 "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
183 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
184 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
185
5211982886af Move 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 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
187 "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
188 "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
189 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
190 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
191
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 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
193 "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
194 "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
195 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
196 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
197 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
198
5211982886af Move 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 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
200 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 /******************************************************************************
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 * 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
204 *****************************************************************************/
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 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
206 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
207 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
208 {
5211982886af Move 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 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
210
5211982886af Move 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_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
212 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
213
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 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
215 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
216 "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
217 "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
218 "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
219 "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
220 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
221
5211982886af Move 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 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
223 }
5211982886af Move 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
5211982886af Move 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 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
226 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
227 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
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 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
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
5211982886af Move 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 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
233 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
234 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
235
5211982886af Move 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 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
237 }
5211982886af Move 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 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
240 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
241 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
242 {
5211982886af Move 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 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
244 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
245
5211982886af Move 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 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
247
5211982886af Move 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 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
249 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
250 }
5211982886af Move 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 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
253 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
254
5211982886af Move 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_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
256
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
257 /* 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
258 * 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
259 * 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
260 */
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
261 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
262 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
263 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
264 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
265 }
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
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
5211982886af Move 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_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
269 "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
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
5211982886af Move 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
5211982886af Move 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 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
274 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
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 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
277 }
5211982886af Move 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 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
280 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
281 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
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_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
284
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 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
286 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
287 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 }
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
5211982886af Move PurpleChatUser to it's own file and fix a few issues with the docs and translations
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 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
291 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
292 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
293
5211982886af Move 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 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
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
5211982886af Move 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 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
298 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
299 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
300
5211982886af Move 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 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
302 }
5211982886af Move 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 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
305 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
306 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
307
5211982886af Move 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 /* 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
309 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
310 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
311 }
5211982886af Move 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 /* 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
314 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
315 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
316 } 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
317 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
318 }
5211982886af Move 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
5211982886af Move 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 /* 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
321 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
322 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
323 } 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
324 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
325 }
5211982886af Move 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
5211982886af Move 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 /* 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
328 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
329 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
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 /* 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
333 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
334 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
335 } 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
336 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
337 }
5211982886af Move 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
5211982886af Move 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 /* 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
340 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
341 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
342 } 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
343 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
344 }
5211982886af Move 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
5211982886af Move 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 /* 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
347 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
348 }

mercurial