Mercurial > hg
annotate mcabber/src/roster.c @ 1088:c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Works for hidden groups too.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Wed, 06 Dec 2006 23:18:36 +0100 |
parents | 230dca34dbea |
children | 1ef7572c3096 |
rev | line source |
---|---|
72 | 1 /* |
2 * roster.c -- Local roster implementation | |
393 | 3 * |
699 | 4 * Copyright (C) 2005, 2006 Mikael Berthe <bmikael@lists.lilotux.net> |
72 | 5 * |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or (at | |
9 * your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | |
19 * USA | |
20 */ | |
21 | |
22 #include <string.h> | |
23 | |
24 #include "roster.h" | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
25 #include "utils.h" |
72 | 26 |
27 | |
584 | 28 char *strrole[] = { /* Should match enum in roster.h */ |
29 "none", | |
30 "moderator", | |
31 "participant", | |
32 "visitor" | |
33 }; | |
34 | |
35 char *straffil[] = { /* Should match enum roster.h */ | |
36 "none", | |
37 "owner", | |
38 "admin", | |
39 "memeber", | |
40 "outcast" | |
41 }; | |
42 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
43 /* Resource structure */ |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
44 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
45 typedef struct { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
46 gchar *name; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
47 gchar prio; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
48 enum imstatus status; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
49 gchar *status_msg; |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
50 time_t status_timestamp; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
51 enum imrole role; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
52 enum imaffiliation affil; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
53 gchar *realjid; /* for chatrooms, if buddy's real jid is known */ |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
54 guint events; |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
55 #ifdef JEP0022 |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
56 struct jep0022 jep22; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
57 #endif |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
58 #ifdef JEP0085 |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
59 struct jep0085 jep85; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
60 #endif |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
61 #ifdef HAVE_GPGME |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
62 struct pgp_data pgpdata; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
63 #endif |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
64 } res; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
65 |
72 | 66 /* This is a private structure type for the roster */ |
67 | |
68 typedef struct { | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
69 gchar *name; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
70 gchar *jid; |
72 | 71 guint type; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
72 enum subscr subscription; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
73 GSList *resource; |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
74 |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
75 /* For groupchats */ |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
76 gchar *nickname; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
77 gchar *topic; |
952 | 78 guint inside_room; |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
79 |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
80 /* To keep track of last status message */ |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
81 gchar *offline_status_message; |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
82 |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
83 /* Flag used for the UI */ |
72 | 84 guint flags; |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
85 |
72 | 86 // list: user -> points to his group; group -> points to its users list |
87 GSList *list; | |
88 } roster; | |
89 | |
90 | |
91 /* ### Variables ### */ | |
92 | |
93 static int hide_offline_buddies; | |
94 static GSList *groups; | |
236 | 95 static GSList *unread_list; |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
96 static GHashTable *unread_jids; |
72 | 97 GList *buddylist; |
78 | 98 GList *current_buddy; |
330 | 99 GList *alternate_buddy; |
72 | 100 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
101 static roster roster_special; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
102 |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
103 void unread_jid_add(const char *jid); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
104 int unread_jid_del(const char *jid); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
105 |
72 | 106 |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
107 /* ### Initialization ### */ |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
108 |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
109 void roster_init(void) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
110 { |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
111 roster_special.name = SPECIAL_BUFFER_STATUS_ID; |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
112 roster_special.type = ROSTER_TYPE_SPECIAL; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
113 } |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
114 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
115 /* ### Resources functions ### */ |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
116 |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
117 static inline void free_resource_data(res *p_res) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
118 { |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
119 if (!p_res) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
120 return; |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
121 g_free((gchar*)p_res->status_msg); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
122 g_free((gchar*)p_res->name); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
123 g_free((gchar*)p_res->realjid); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
124 #ifdef JEP0022 |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
125 g_free(p_res->jep22.last_msgid_sent); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
126 g_free(p_res->jep22.last_msgid_rcvd); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
127 #endif |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
128 #ifdef HAVE_GPGME |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
129 g_free(p_res->pgpdata.sign_keyid); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
130 #endif |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
131 g_free(p_res); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
132 } |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
133 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
134 static void free_all_resources(GSList **reslist) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
135 { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
136 GSList *lip; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
137 |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
138 for (lip = *reslist; lip ; lip = g_slist_next(lip)) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
139 free_resource_data((res*)lip->data); |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
140 // Free all nodes but the first (which is static) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
141 g_slist_free(*reslist); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
142 *reslist = NULL; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
143 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
144 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
145 // Resources are sorted in ascending order |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
146 static gint resource_compare_prio(res *a, res *b) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
147 //return (a->prio - b->prio); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
148 if (a->prio < b->prio) return -1; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
149 else return 1; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
150 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
151 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
152 // get_resource(rost, resname) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
153 // Return a pointer to the resource with name resname, in rost's resources list |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
154 // - if rost has no resources, return NULL |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
155 // - if resname is defined, return the match or NULL |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
156 // - if resname is NULL, the last resource is returned, currently |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
157 // This could change in the future, because we should return the best one |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
158 // (priority? last used? and fall back to the first resource) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
159 // |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
160 static res *get_resource(roster *rost, const char *resname) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
161 { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
162 GSList *p; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
163 res *r = NULL; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
164 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
165 for (p = rost->resource; p; p = g_slist_next(p)) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
166 r = p->data; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
167 if (resname && !strcmp(r->name, resname)) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
168 return r; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
169 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
170 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
171 // The last resource is one of the resources with the highest priority, |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
172 // however, we don't know if it is the more-recently-used. |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
173 if (!resname) return r; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
174 return NULL; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
175 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
176 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
177 // get_or_add_resource(rost, resname, priority) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
178 // - if there is a "resname" resource in rost's resources, return a pointer |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
179 // on this resource |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
180 // - if not, add the resource, set the name, and return a pointer on this |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
181 // new resource |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
182 static res *get_or_add_resource(roster *rost, const char *resname, gchar prio) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
183 { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
184 GSList *p; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
185 res *nres; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
186 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
187 if (!resname) return NULL; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
188 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
189 for (p = rost->resource; p; p = g_slist_next(p)) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
190 res *r = p->data; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
191 if (!strcmp(r->name, resname)) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
192 return r; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
193 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
194 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
195 // Resource not found |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
196 nres = g_new0(res, 1); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
197 nres->name = g_strdup(resname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
198 nres->prio = prio; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
199 rost->resource = g_slist_insert_sorted(rost->resource, nres, |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
200 (GCompareFunc)&resource_compare_prio); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
201 return nres; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
202 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
203 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
204 static void del_resource(roster *rost, const char *resname) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
205 { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
206 GSList *p; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
207 GSList *p_res_elt = NULL; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
208 res *p_res; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
209 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
210 if (!resname) return; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
211 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
212 for (p = rost->resource; p; p = g_slist_next(p)) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
213 res *r = p->data; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
214 if (!strcmp(r->name, resname)) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
215 p_res_elt = p; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
216 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
217 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
218 if (!p_res_elt) return; // Resource not found |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
219 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
220 p_res = p_res_elt->data; |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
221 |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
222 // Keep a copy of the status message when a buddy goes offline |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
223 if (g_slist_length(rost->resource) == 1) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
224 g_free(rost->offline_status_message); |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
225 rost->offline_status_message = p_res->status_msg; |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
226 p_res->status_msg = NULL; |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
227 } |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
228 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
229 // Free allocations and delete resource node |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
230 free_resource_data(p_res); |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
231 rost->resource = g_slist_delete_link(rost->resource, p_res_elt); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
232 return; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
233 } |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
234 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
235 |
72 | 236 /* ### Roster functions ### */ |
237 | |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
238 static inline void free_roster_user_data(roster *roster_usr) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
239 { |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
240 if (!roster_usr) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
241 return; |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
242 g_free((gchar*)roster_usr->jid); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
243 g_free((gchar*)roster_usr->name); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
244 g_free((gchar*)roster_usr->nickname); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
245 g_free((gchar*)roster_usr->topic); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
246 g_free((gchar*)roster_usr->offline_status_message); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
247 free_all_resources(&roster_usr->resource); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
248 g_free(roster_usr); |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
249 } |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
250 |
72 | 251 // Comparison function used to search in the roster (compares jids and types) |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
331
diff
changeset
|
252 static gint roster_compare_jid_type(roster *a, roster *b) { |
89 | 253 if (! (a->type & b->type)) |
480 | 254 return -1; // arbitrary (but should be != 0, of course) |
72 | 255 return strcasecmp(a->jid, b->jid); |
256 } | |
257 | |
670
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
258 // Comparison function used to search in the roster (compares names and types) |
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
259 static gint roster_compare_name_type(roster *a, roster *b) { |
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
260 if (! (a->type & b->type)) |
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
261 return -1; // arbitrary (but should be != 0, of course) |
783
25022410f80f
Use case sensitive group names
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
262 return strcmp(a->name, b->name); |
670
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
263 } |
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
264 |
72 | 265 // Comparison function used to sort the roster (by name) |
336
eb994ee40029
Make some functions static
Mikael Berthe <mikael@lilotux.net>
parents:
331
diff
changeset
|
266 static gint roster_compare_name(roster *a, roster *b) { |
783
25022410f80f
Use case sensitive group names
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
267 return strcmp(a->name, b->name); |
72 | 268 } |
269 | |
270 // Finds a roster element (user, group, agent...), by jid or name | |
89 | 271 // If roster_type is 0, returns match of any type. |
72 | 272 // Returns the roster GSList element, or NULL if jid/name not found |
78 | 273 GSList *roster_find(const char *jidname, enum findwhat type, guint roster_type) |
72 | 274 { |
275 GSList *sl_roster_elt = groups; | |
1058 | 276 GSList *resource; |
72 | 277 roster sample; |
278 GCompareFunc comp; | |
279 | |
192 | 280 if (!jidname) return NULL; |
72 | 281 |
89 | 282 if (!roster_type) |
480 | 283 roster_type = ROSTER_TYPE_USER | ROSTER_TYPE_ROOM | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
284 ROSTER_TYPE_AGENT | ROSTER_TYPE_GROUP; |
89 | 285 |
72 | 286 sample.type = roster_type; |
287 if (type == jidsearch) { | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
288 sample.jid = (gchar*)jidname; |
72 | 289 comp = (GCompareFunc)&roster_compare_jid_type; |
290 } else if (type == namesearch) { | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
291 sample.name = (gchar*)jidname; |
670
2cd0805515a4
Fix a bug in roster_find()
Mikael Berthe <mikael@lilotux.net>
parents:
669
diff
changeset
|
292 comp = (GCompareFunc)&roster_compare_name_type; |
72 | 293 } else |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
294 return NULL; // Should not happen... |
72 | 295 |
296 while (sl_roster_elt) { | |
297 roster *roster_elt = (roster*)sl_roster_elt->data; | |
298 if (roster_type & ROSTER_TYPE_GROUP) { | |
783
25022410f80f
Use case sensitive group names
Mikael Berthe <mikael@lilotux.net>
parents:
774
diff
changeset
|
299 if ((type == namesearch) && !strcmp(jidname, roster_elt->name)) |
72 | 300 return sl_roster_elt; |
301 } | |
1058 | 302 resource = g_slist_find_custom(roster_elt->list, &sample, comp); |
303 if (resource) return resource; | |
72 | 304 sl_roster_elt = g_slist_next(sl_roster_elt); |
305 } | |
306 return NULL; | |
307 } | |
308 | |
309 // Returns pointer to new group, or existing group with that name | |
78 | 310 GSList *roster_add_group(const char *name) |
72 | 311 { |
312 roster *roster_grp; | |
669
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
313 GSList *p_group; |
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
314 |
72 | 315 // #1 Check name doesn't already exist |
669
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
316 p_group = roster_find(name, namesearch, ROSTER_TYPE_GROUP); |
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
317 if (!p_group) { |
72 | 318 // #2 Create the group node |
319 roster_grp = g_new0(roster, 1); | |
320 roster_grp->name = g_strdup(name); | |
321 roster_grp->type = ROSTER_TYPE_GROUP; | |
322 // #3 Insert (sorted) | |
323 groups = g_slist_insert_sorted(groups, roster_grp, | |
324 (GCompareFunc)&roster_compare_name); | |
669
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
325 p_group = roster_find(name, namesearch, ROSTER_TYPE_GROUP); |
72 | 326 } |
669
2b87065270f3
roster_add_group(): do not call roster_find() twice
Mikael Berthe <mikael@lilotux.net>
parents:
662
diff
changeset
|
327 return p_group; |
72 | 328 } |
329 | |
330 // Returns a pointer to the new user, or existing user with that name | |
78 | 331 GSList *roster_add_user(const char *jid, const char *name, const char *group, |
603 | 332 guint type, enum subscr esub) |
72 | 333 { |
334 roster *roster_usr; | |
335 roster *my_group; | |
336 GSList *slist; | |
337 | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
338 if ((type != ROSTER_TYPE_USER) && |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
339 (type != ROSTER_TYPE_ROOM) && |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
340 (type != ROSTER_TYPE_AGENT)) { |
72 | 341 // XXX Error message? |
342 return NULL; | |
343 } | |
344 | |
78 | 345 // Let's be arbitrary: default group has an empty name (""). |
346 if (!group) group = ""; | |
347 | |
72 | 348 // #1 Check this user doesn't already exist |
563
b0f1b127bfb6
Prevent from adding a duplicate jid (when types are different)
Mikael Berthe <mikael@lilotux.net>
parents:
562
diff
changeset
|
349 slist = roster_find(jid, jidsearch, 0); |
607 | 350 if (slist) { |
351 char *oldgroupname; | |
352 // That's an update | |
353 roster_usr = slist->data; | |
354 roster_usr->subscription = esub; | |
355 if (name) | |
356 buddy_setname(slist->data, (char*)name); | |
357 // Let's check if the group name has changed | |
358 oldgroupname = ((roster*)((GSList*)roster_usr->list)->data)->name; | |
359 if (group && strcmp(oldgroupname, group)) | |
360 buddy_setgroup(slist->data, (char*)group); | |
361 return slist; | |
362 } | |
72 | 363 // #2 add group if necessary |
364 slist = roster_add_group(group); | |
365 if (!slist) return NULL; | |
366 my_group = (roster*)slist->data; | |
367 // #3 Create user node | |
368 roster_usr = g_new0(roster, 1); | |
369 roster_usr->jid = g_strdup(jid); | |
78 | 370 if (name) { |
371 roster_usr->name = g_strdup(name); | |
372 } else { | |
373 gchar *p, *str = g_strdup(jid); | |
977
5b01de4ac5e1
Cosmetic changes
Alexis Hildebrandt <afh [at] 2drop [dot] net>
parents:
974
diff
changeset
|
374 p = strchr(str, JID_RESOURCE_SEPARATOR); |
78 | 375 if (p) *p = '\0'; |
376 roster_usr->name = g_strdup(str); | |
377 g_free(str); | |
378 } | |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
379 if (unread_jid_del(jid)) { |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
380 roster_usr->flags |= ROSTER_FLAG_MSG; |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
381 // Append the roster_usr to unread_list |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
382 unread_list = g_slist_append(unread_list, roster_usr); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
383 } |
603 | 384 roster_usr->type = type; |
385 roster_usr->subscription = esub; | |
386 roster_usr->list = slist; // (my_group SList element) | |
72 | 387 // #4 Insert node (sorted) |
388 my_group->list = g_slist_insert_sorted(my_group->list, roster_usr, | |
564 | 389 (GCompareFunc)&roster_compare_name); |
72 | 390 return roster_find(jid, jidsearch, type); |
391 } | |
392 | |
393 // Removes user (jid) from roster, frees allocated memory | |
78 | 394 void roster_del_user(const char *jid) |
72 | 395 { |
396 GSList *sl_user, *sl_group; | |
397 GSList **sl_group_listptr; | |
398 roster *roster_usr; | |
246 | 399 GSList *node; |
72 | 400 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
401 sl_user = roster_find(jid, jidsearch, |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
402 ROSTER_TYPE_USER|ROSTER_TYPE_AGENT|ROSTER_TYPE_ROOM); |
89 | 403 if (sl_user == NULL) |
72 | 404 return; |
405 roster_usr = (roster*)sl_user->data; | |
246 | 406 |
407 // Remove (if present) from unread messages list | |
408 node = g_slist_find(unread_list, roster_usr); | |
409 if (node) unread_list = g_slist_delete_link(unread_list, node); | |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
410 // If there is a pending unread message, keep track of it |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
411 if (roster_usr->flags & ROSTER_FLAG_MSG) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
412 unread_jid_add(roster_usr->jid); |
246 | 413 |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
414 // Let's free roster_usr memory (jid, name, status message...) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
415 free_roster_user_data(roster_usr); |
72 | 416 |
417 // That's a little complex, we need to dereference twice | |
418 sl_group = ((roster*)sl_user->data)->list; | |
419 sl_group_listptr = &((roster*)(sl_group->data))->list; | |
420 *sl_group_listptr = g_slist_delete_link(*sl_group_listptr, sl_user); | |
78 | 421 |
422 // We need to rebuild the list | |
423 if (current_buddy) | |
424 buddylist_build(); | |
210 | 425 // TODO What we could do, too, is to check if the deleted node is |
78 | 426 // current_buddy, in which case we could move current_buddy to the |
427 // previous (or next) node. | |
72 | 428 } |
429 | |
210 | 430 // Free all roster data and call buddylist_build() to free the buddylist. |
164 | 431 void roster_free(void) |
432 { | |
433 GSList *sl_grp = groups; | |
434 | |
301
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
435 // Free unread_list |
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
436 if (unread_list) { |
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
437 g_slist_free(unread_list); |
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
438 unread_list = NULL; |
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
439 } |
efcbd3c1ad15
Free unread_list when the roster is freed
Mikael Berthe <mikael@lilotux.net>
parents:
265
diff
changeset
|
440 |
164 | 441 // Walk through groups |
442 while (sl_grp) { | |
443 roster *roster_grp = (roster*)sl_grp->data; | |
444 GSList *sl_usr = roster_grp->list; | |
445 // Walk through this group users | |
446 while (sl_usr) { | |
447 roster *roster_usr = (roster*)sl_usr->data; | |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
448 // If there is a pending unread message, keep track of it |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
449 if (roster_usr->flags & ROSTER_FLAG_MSG) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
450 unread_jid_add(roster_usr->jid); |
1063
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
451 // Free roster_usr data (jid, name, status message...) |
4e62941df777
roster.c: refactor some functions
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
452 free_roster_user_data(roster_usr); |
164 | 453 sl_usr = g_slist_next(sl_usr); |
454 } | |
455 // Free group's users list | |
456 if (roster_grp->list) | |
457 g_slist_free(roster_grp->list); | |
458 // Free group's name and jid | |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
459 g_free((gchar*)roster_grp->jid); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
460 g_free((gchar*)roster_grp->name); |
214 | 461 g_free(roster_grp); |
164 | 462 sl_grp = g_slist_next(sl_grp); |
463 } | |
464 // Free groups list | |
465 if (groups) { | |
466 g_slist_free(groups); | |
467 groups = NULL; | |
468 // Update (i.e. free) buddylist | |
469 if (buddylist) | |
470 buddylist_build(); | |
471 } | |
472 } | |
473 | |
468
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
474 // roster_setstatus() |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
475 // Note: resname, role, affil and realjid are for room members only |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
476 void roster_setstatus(const char *jid, const char *resname, gchar prio, |
468
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
477 enum imstatus bstat, const char *status_msg, |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
478 time_t status_time, |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
479 enum imrole role, enum imaffiliation affil, |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
480 const char *realjid) |
72 | 481 { |
482 GSList *sl_user; | |
483 roster *roster_usr; | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
484 res *p_res; |
72 | 485 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
486 sl_user = roster_find(jid, jidsearch, |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
487 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
92 | 488 // If we can't find it, we add it |
89 | 489 if (sl_user == NULL) |
603 | 490 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none); |
72 | 491 |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
492 // If there is no resource name, we can leave now |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
493 if (!resname) return; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
494 |
72 | 495 roster_usr = (roster*)sl_user->data; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
496 |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
497 // New or updated resource |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
498 p_res = get_or_add_resource(roster_usr, resname, prio); |
494
3f5aa4852684
Fix small bug in roster_setstatus()
Mikael Berthe <mikael@lilotux.net>
parents:
489
diff
changeset
|
499 p_res->prio = prio; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
500 p_res->status = bstat; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
501 if (p_res->status_msg) { |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
502 g_free((gchar*)p_res->status_msg); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
503 p_res->status_msg = NULL; |
221 | 504 } |
505 if (status_msg) | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
506 p_res->status_msg = g_strdup(status_msg); |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
507 if (!status_time) |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
508 time(&status_time); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
509 p_res->status_timestamp = status_time; |
468
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
510 |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
511 p_res->role = role; |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
512 p_res->affil = affil; |
468
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
513 |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
514 if (p_res->realjid) { |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
515 g_free((gchar*)p_res->realjid); |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
516 p_res->realjid = NULL; |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
517 } |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
518 if (realjid) |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
519 p_res->realjid = g_strdup(realjid); |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
520 |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
521 // If bstat is offline, we MUST delete the resource, actually |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
522 if (bstat == offline) { |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
523 del_resource(roster_usr, resname); |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
524 return; |
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
525 } |
72 | 526 } |
527 | |
78 | 528 // roster_setflags() |
529 // Set one or several flags to value (TRUE/FALSE) | |
80 | 530 void roster_setflags(const char *jid, guint flags, guint value) |
78 | 531 { |
532 GSList *sl_user; | |
533 roster *roster_usr; | |
534 | |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
535 sl_user = roster_find(jid, jidsearch, |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
536 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
89 | 537 if (sl_user == NULL) |
78 | 538 return; |
539 | |
540 roster_usr = (roster*)sl_user->data; | |
541 if (value) | |
542 roster_usr->flags |= flags; | |
543 else | |
544 roster_usr->flags &= ~flags; | |
545 } | |
148 | 546 |
547 // roster_msg_setflag() | |
548 // Set the ROSTER_FLAG_MSG to the given value for the given jid. | |
549 // It will update the buddy's group message flag. | |
236 | 550 // Update the unread messages list too. |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
551 void roster_msg_setflag(const char *jid, guint special, guint value) |
148 | 552 { |
553 GSList *sl_user; | |
554 roster *roster_usr, *roster_grp; | |
860
a8fadbd97858
Rebuild buddylist when setting a new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
555 int new_roster_item = FALSE; |
148 | 556 |
889
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
557 if (special) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
558 //sl_user = roster_find(jid, namesearch, ROSTER_TYPE_SPECIAL); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
559 //if (!sl_user) return; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
560 //roster_usr = (roster*)sl_user->data; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
561 roster_usr = &roster_special; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
562 if (value) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
563 roster_usr->flags |= ROSTER_FLAG_MSG; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
564 // Append the roster_usr to unread_list, but avoid duplicates |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
565 if (!g_slist_find(unread_list, roster_usr)) |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
566 unread_list = g_slist_append(unread_list, roster_usr); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
567 } else { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
568 roster_usr->flags &= ~ROSTER_FLAG_MSG; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
569 if (unread_list) { |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
570 GSList *node = g_slist_find(unread_list, roster_usr); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
571 if (node) unread_list = g_slist_delete_link(unread_list, node); |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
572 } |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
573 } |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
574 return; |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
575 } |
ae93e69aaaaf
Fix up pending message flag for the status special buffer
Mikael Berthe <mikael@lilotux.net>
parents:
885
diff
changeset
|
576 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
577 sl_user = roster_find(jid, jidsearch, |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
578 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
678
e175f5d96f04
Fix a small issue in roster_msg_setflag()
Mikael Berthe <mikael@lilotux.net>
parents:
670
diff
changeset
|
579 // If we can't find it, we add it |
e175f5d96f04
Fix a small issue in roster_msg_setflag()
Mikael Berthe <mikael@lilotux.net>
parents:
670
diff
changeset
|
580 if (sl_user == NULL) { |
e175f5d96f04
Fix a small issue in roster_msg_setflag()
Mikael Berthe <mikael@lilotux.net>
parents:
670
diff
changeset
|
581 sl_user = roster_add_user(jid, NULL, NULL, ROSTER_TYPE_USER, sub_none); |
860
a8fadbd97858
Rebuild buddylist when setting a new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
582 new_roster_item = TRUE; |
678
e175f5d96f04
Fix a small issue in roster_msg_setflag()
Mikael Berthe <mikael@lilotux.net>
parents:
670
diff
changeset
|
583 } |
148 | 584 |
585 roster_usr = (roster*)sl_user->data; | |
586 roster_grp = (roster*)roster_usr->list->data; | |
587 if (value) { | |
588 // Message flag is TRUE. This is easy, we just have to set both flags | |
589 // to TRUE... | |
590 roster_usr->flags |= ROSTER_FLAG_MSG; | |
591 roster_grp->flags |= ROSTER_FLAG_MSG; // group | |
236 | 592 // Append the roster_usr to unread_list, but avoid duplicates |
593 if (!g_slist_find(unread_list, roster_usr)) | |
594 unread_list = g_slist_append(unread_list, roster_usr); | |
148 | 595 } else { |
596 // Message flag is FALSE. | |
597 guint msg = FALSE; | |
598 roster_usr->flags &= ~ROSTER_FLAG_MSG; | |
236 | 599 if (unread_list) { |
600 GSList *node = g_slist_find(unread_list, roster_usr); | |
601 if (node) unread_list = g_slist_delete_link(unread_list, node); | |
602 } | |
148 | 603 // For the group value we need to watch all buddies in this group; |
604 // if one is flagged, then the group will be flagged. | |
605 // I will re-use sl_user and roster_usr here, as they aren't used | |
606 // anymore. | |
607 sl_user = roster_grp->list; | |
608 while (sl_user) { | |
609 roster_usr = (roster*)sl_user->data; | |
610 if (roster_usr->flags & ROSTER_FLAG_MSG) { | |
611 msg = TRUE; | |
612 break; | |
613 } | |
614 sl_user = g_slist_next(sl_user); | |
615 } | |
616 if (!msg) | |
617 roster_grp->flags &= ~ROSTER_FLAG_MSG; | |
618 else | |
619 roster_grp->flags |= ROSTER_FLAG_MSG; | |
620 // Actually the "else" part is useless, because the group | |
621 // ROSTER_FLAG_MSG should already be set... | |
622 } | |
860
a8fadbd97858
Rebuild buddylist when setting a new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
623 |
1010
54405d09b15a
Add a call to buddylist_build()
Mikael Berthe <mikael@lilotux.net>
parents:
987
diff
changeset
|
624 if (buddylist && (new_roster_item || !g_list_find(buddylist, roster_usr))) |
860
a8fadbd97858
Rebuild buddylist when setting a new message flag
Mikael Berthe <mikael@lilotux.net>
parents:
848
diff
changeset
|
625 buddylist_build(); |
148 | 626 } |
627 | |
510
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
628 const char *roster_getname(const char *jid) |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
629 { |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
630 GSList *sl_user; |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
631 roster *roster_usr; |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
632 |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
633 sl_user = roster_find(jid, jidsearch, |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
634 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
635 if (sl_user == NULL) |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
636 return NULL; // Not in the roster... |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
637 |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
638 roster_usr = (roster*)sl_user->data; |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
639 return roster_usr->name; |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
640 } |
6c3cd3aa4a91
New 'buddy_format' option
Mikael Berthe <mikael@lilotux.net>
parents:
509
diff
changeset
|
641 |
863
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
642 const char *roster_getnickname(const char *jid) |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
643 { |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
644 GSList *sl_user; |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
645 roster *roster_usr; |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
646 |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
647 sl_user = roster_find(jid, jidsearch, |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
648 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM|ROSTER_TYPE_AGENT); |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
649 if (sl_user == NULL) |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
650 return NULL; // Not in the roster... |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
651 |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
652 roster_usr = (roster*)sl_user->data; |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
653 return roster_usr->nickname; |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
654 } |
4f1a93faffea
Add roster_getnickname()
Mikael Berthe <mikael@lilotux.net>
parents:
860
diff
changeset
|
655 |
89 | 656 void roster_settype(const char *jid, guint type) |
657 { | |
658 GSList *sl_user; | |
659 roster *roster_usr; | |
660 | |
661 if ((sl_user = roster_find(jid, jidsearch, 0)) == NULL) | |
662 return; | |
663 | |
664 roster_usr = (roster*)sl_user->data; | |
665 roster_usr->type = type; | |
666 } | |
667 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
668 enum imstatus roster_getstatus(const char *jid, const char *resname) |
90 | 669 { |
670 GSList *sl_user; | |
671 roster *roster_usr; | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
672 res *p_res; |
90 | 673 |
674 sl_user = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); | |
675 if (sl_user == NULL) | |
676 return offline; // Not in the roster, anyway... | |
677 | |
678 roster_usr = (roster*)sl_user->data; | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
679 p_res = get_resource(roster_usr, resname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
680 if (p_res) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
681 return p_res->status; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
682 return offline; |
90 | 683 } |
684 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
685 const char *roster_getstatusmsg(const char *jid, const char *resname) |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
686 { |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
687 GSList *sl_user; |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
688 roster *roster_usr; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
689 res *p_res; |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
690 |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
691 sl_user = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
692 if (sl_user == NULL) |
425
03f1e37759a6
roster_getstatusmsg() should return a pointer
Mikael Berthe <mikael@lilotux.net>
parents:
393
diff
changeset
|
693 return NULL; // Not in the roster, anyway... |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
694 |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
695 roster_usr = (roster*)sl_user->data; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
696 p_res = get_resource(roster_usr, resname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
697 if (p_res) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
698 return p_res->status_msg; |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
699 return roster_usr->offline_status_message; |
318
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
700 } |
45076d02eeef
The /status command can specify a status message
Mikael Berthe <mikael@lilotux.net>
parents:
301
diff
changeset
|
701 |
89 | 702 guint roster_gettype(const char *jid) |
703 { | |
704 GSList *sl_user; | |
705 roster *roster_usr; | |
706 | |
707 if ((sl_user = roster_find(jid, jidsearch, 0)) == NULL) | |
708 return 0; | |
709 | |
710 roster_usr = (roster*)sl_user->data; | |
711 return roster_usr->type; | |
712 } | |
713 | |
819
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
714 guint roster_getsubscription(const char *jid) |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
715 { |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
716 GSList *sl_user; |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
717 roster *roster_usr; |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
718 |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
719 if ((sl_user = roster_find(jid, jidsearch, 0)) == NULL) |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
720 return 0; |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
721 |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
722 roster_usr = (roster*)sl_user->data; |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
723 return roster_usr->subscription; |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
724 } |
c2d7d9dd4193
New option 'block_unsubscribed'
Mikael Berthe <mikael@lilotux.net>
parents:
792
diff
changeset
|
725 |
610
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
726 // roster_unsubscribed() |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
727 // We have lost buddy's presence updates; this function clears the status |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
728 // message, sets the buddy offline and frees the resources |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
729 void roster_unsubscribed(const char *jid) |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
730 { |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
731 GSList *sl_user; |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
732 roster *roster_usr; |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
733 |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
734 sl_user = roster_find(jid, jidsearch, ROSTER_TYPE_USER|ROSTER_TYPE_AGENT); |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
735 if (sl_user == NULL) |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
736 return; |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
737 |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
738 roster_usr = (roster*)sl_user->data; |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
739 free_all_resources(&roster_usr->resource); |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
740 } |
0e8247cf2bd1
Consider buddies as offline when they have cancelled our subscription
Mikael Berthe <mikael@lilotux.net>
parents:
607
diff
changeset
|
741 |
72 | 742 |
743 /* ### BuddyList functions ### */ | |
744 | |
120 | 745 // buddylist_set_hide_offline_buddies(hide) |
72 | 746 // "hide" values: 1=hide 0=show_all -1=invert |
120 | 747 void buddylist_set_hide_offline_buddies(int hide) |
72 | 748 { |
749 if (hide < 0) // NEG (invert) | |
750 hide_offline_buddies = !hide_offline_buddies; | |
751 else if (hide == 0) // FALSE (don't hide) | |
752 hide_offline_buddies = 0; | |
753 else // TRUE (hide) | |
754 hide_offline_buddies = 1; | |
755 } | |
756 | |
120 | 757 inline int buddylist_get_hide_offline_buddies(void) |
758 { | |
759 return hide_offline_buddies; | |
760 } | |
761 | |
72 | 762 // buddylist_build() |
763 // Creates the buddylist from the roster entries. | |
764 void buddylist_build(void) | |
765 { | |
766 GSList *sl_roster_elt = groups; | |
767 roster *roster_elt; | |
81 | 768 roster *roster_current_buddy = NULL; |
330 | 769 roster *roster_alternate_buddy = NULL; |
128 | 770 int shrunk_group; |
72 | 771 |
81 | 772 // We need to remember which buddy is selected. |
773 if (current_buddy) | |
774 roster_current_buddy = BUDDATA(current_buddy); | |
775 current_buddy = NULL; | |
330 | 776 if (alternate_buddy) |
777 roster_alternate_buddy = BUDDATA(alternate_buddy); | |
778 alternate_buddy = NULL; | |
81 | 779 |
72 | 780 // Destroy old buddylist |
781 if (buddylist) { | |
782 g_list_free(buddylist); | |
783 buddylist = NULL; | |
784 } | |
785 | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
786 buddylist = g_list_append(buddylist, &roster_special); |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
787 |
72 | 788 // Create the new list |
789 while (sl_roster_elt) { | |
790 GSList *sl_roster_usrelt; | |
791 roster *roster_usrelt; | |
147 | 792 guint pending_group = FALSE; |
72 | 793 roster_elt = (roster*) sl_roster_elt->data; |
794 | |
795 // Add the group now unless hide_offline_buddies is set, | |
796 // in which case we'll add it only if an online buddy belongs to it. | |
147 | 797 // We take care to keep the current_buddy in the list, too. |
798 if (!hide_offline_buddies || roster_elt == roster_current_buddy) | |
72 | 799 buddylist = g_list_append(buddylist, roster_elt); |
800 else | |
147 | 801 pending_group = TRUE; |
72 | 802 |
128 | 803 shrunk_group = roster_elt->flags & ROSTER_FLAG_HIDE; |
804 | |
72 | 805 sl_roster_usrelt = roster_elt->list; |
806 while (sl_roster_usrelt) { | |
807 roster_usrelt = (roster*) sl_roster_usrelt->data; | |
808 | |
809 // Buddy will be added if either: | |
810 // - hide_offline_buddies is FALSE | |
811 // - buddy is not offline | |
812 // - buddy has a lock (for example the buddy window is currently open) | |
813 // - buddy has a pending (non-read) message | |
128 | 814 // - group isn't hidden (shrunk) |
147 | 815 // - this is the current_buddy |
816 if (!hide_offline_buddies || roster_usrelt == roster_current_buddy || | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
817 (buddy_getstatus((gpointer)roster_usrelt, NULL) != offline) || |
72 | 818 (buddy_getflags((gpointer)roster_usrelt) & |
974
36f7753dfb59
Add /roster item_{lock,unlock}
Mikael Berthe <mikael@lilotux.net>
parents:
952
diff
changeset
|
819 (ROSTER_FLAG_LOCK | ROSTER_FLAG_USRLOCK | ROSTER_FLAG_MSG))) { |
72 | 820 // This user should be added. Maybe the group hasn't been added yet? |
147 | 821 if (pending_group && |
822 (hide_offline_buddies || roster_usrelt == roster_current_buddy)) { | |
72 | 823 // It hasn't been done yet |
824 buddylist = g_list_append(buddylist, roster_elt); | |
825 pending_group = FALSE; | |
826 } | |
827 // Add user | |
128 | 828 // XXX Should we add the user if there is a message and |
829 // the group is shrunk? If so, we'd need to check LOCK flag too, | |
830 // perhaps... | |
831 if (!shrunk_group) | |
832 buddylist = g_list_append(buddylist, roster_usrelt); | |
72 | 833 } |
834 | |
835 sl_roster_usrelt = g_slist_next(sl_roster_usrelt); | |
836 } | |
837 sl_roster_elt = g_slist_next(sl_roster_elt); | |
838 } | |
78 | 839 |
81 | 840 // Check if we can find our saved current_buddy... |
841 if (roster_current_buddy) | |
842 current_buddy = g_list_find(buddylist, roster_current_buddy); | |
330 | 843 if (roster_alternate_buddy) |
844 alternate_buddy = g_list_find(buddylist, roster_alternate_buddy); | |
78 | 845 // current_buddy initialization |
846 if (!current_buddy || (g_list_position(buddylist, current_buddy) == -1)) | |
81 | 847 current_buddy = g_list_first(buddylist); |
72 | 848 } |
849 | |
850 // buddy_hide_group(roster, hide) | |
851 // "hide" values: 1=hide 0=show_all -1=invert | |
852 void buddy_hide_group(gpointer rosterdata, int hide) | |
853 { | |
207 | 854 roster *roster_usr = rosterdata; |
72 | 855 if (hide > 0) // TRUE (hide) |
207 | 856 roster_usr->flags |= ROSTER_FLAG_HIDE; |
72 | 857 else if (hide < 0) // NEG (invert) |
207 | 858 roster_usr->flags ^= ROSTER_FLAG_HIDE; |
72 | 859 else // FALSE (don't hide) |
207 | 860 roster_usr->flags &= ~ROSTER_FLAG_HIDE; |
72 | 861 } |
862 | |
863 const char *buddy_getjid(gpointer rosterdata) | |
864 { | |
207 | 865 roster *roster_usr = rosterdata; |
866 return roster_usr->jid; | |
867 } | |
868 | |
210 | 869 // buddy_setgroup() |
870 // Change the group of current buddy | |
871 // | |
872 void buddy_setgroup(gpointer rosterdata, char *newgroupname) | |
873 { | |
874 roster *roster_usr = rosterdata; | |
875 GSList **sl_group; | |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
876 GSList *sl_newgroup; |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
877 roster *my_newgroup; |
210 | 878 |
879 // A group has no group :) | |
880 if (roster_usr->type & ROSTER_TYPE_GROUP) return; | |
881 | |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
882 // Add newgroup if necessary |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
883 if (!newgroupname) newgroupname = ""; |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
884 sl_newgroup = roster_add_group(newgroupname); |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
885 if (!sl_newgroup) return; |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
886 my_newgroup = (roster*)sl_newgroup->data; |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
887 |
210 | 888 // Remove the buddy from current group |
889 sl_group = &((roster*)((GSList*)roster_usr->list)->data)->list; | |
890 *sl_group = g_slist_remove(*sl_group, rosterdata); | |
393 | 891 |
621
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
892 // Remove old group if it is empty |
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
893 if (!*sl_group) { |
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
894 roster *roster_grp = (roster*)((GSList*)roster_usr->list)->data; |
774
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
895 g_free((gchar*)roster_grp->jid); |
46304b773a44
Remove useless checks before g_free() calls
Mikael Berthe <mikael@lilotux.net>
parents:
772
diff
changeset
|
896 g_free((gchar*)roster_grp->name); |
621
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
897 g_free(roster_grp); |
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
898 groups = g_slist_remove(groups, roster_grp); |
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
899 } |
f20c1934a8a7
"/move": remove old group if it is empty
Mikael Berthe <mikael@lilotux.net>
parents:
620
diff
changeset
|
900 |
620
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
901 // Add the buddy to its new group |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
902 roster_usr->list = sl_newgroup; // (my_newgroup SList element) |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
903 my_newgroup->list = g_slist_insert_sorted(my_newgroup->list, roster_usr, |
97dd14e22b2a
Rewrite buddy_setgroup()
Mikael Berthe <mikael@lilotux.net>
parents:
610
diff
changeset
|
904 (GCompareFunc)&roster_compare_name); |
212 | 905 |
210 | 906 buddylist_build(); |
907 } | |
908 | |
207 | 909 void buddy_setname(gpointer rosterdata, char *newname) |
910 { | |
911 roster *roster_usr = rosterdata; | |
209 | 912 GSList **sl_group; |
207 | 913 |
914 // TODO For groups, we need to check for unicity | |
915 // However, renaming a group boils down to moving all its buddies to | |
916 // another group, so calling this function is not really necessary... | |
917 if (roster_usr->type & ROSTER_TYPE_GROUP) return; | |
918 | |
919 if (roster_usr->name) { | |
920 g_free((gchar*)roster_usr->name); | |
921 roster_usr->name = NULL; | |
922 } | |
923 if (newname) | |
924 roster_usr->name = g_strdup(newname); | |
209 | 925 |
926 // We need to resort the group list | |
927 sl_group = &((roster*)((GSList*)roster_usr->list)->data)->list; | |
928 *sl_group = g_slist_sort(*sl_group, (GCompareFunc)&roster_compare_name); | |
929 | |
930 buddylist_build(); | |
72 | 931 } |
932 | |
933 const char *buddy_getname(gpointer rosterdata) | |
934 { | |
207 | 935 roster *roster_usr = rosterdata; |
936 return roster_usr->name; | |
937 } | |
938 | |
548
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
939 // buddy_setnickname(buddy, newnickname) |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
940 // Only for chatrooms |
469
a926523d2392
Use UTF8 to handle resources and room nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
468
diff
changeset
|
941 void buddy_setnickname(gpointer rosterdata, const char *newname) |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
942 { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
943 roster *roster_usr = rosterdata; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
944 |
649
3ad6675caaf1
MUC: fix join bug when the conference is in the roster
Mikael Berthe <mikael@lilotux.net>
parents:
644
diff
changeset
|
945 if (!(roster_usr->type & ROSTER_TYPE_ROOM)) return; // XXX Error message? |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
946 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
947 if (roster_usr->nickname) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
948 g_free((gchar*)roster_usr->nickname); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
949 roster_usr->nickname = NULL; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
950 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
951 if (newname) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
952 roster_usr->nickname = g_strdup(newname); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
953 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
954 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
955 const char *buddy_getnickname(gpointer rosterdata) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
956 { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
957 roster *roster_usr = rosterdata; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
958 return roster_usr->nickname; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
959 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
960 |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
961 // buddy_setinsideroom(buddy, inside) |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
962 // Only for chatrooms |
952 | 963 void buddy_setinsideroom(gpointer rosterdata, guint inside) |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
964 { |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
965 roster *roster_usr = rosterdata; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
966 |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
967 if (!(roster_usr->type & ROSTER_TYPE_ROOM)) return; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
968 |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
969 roster_usr->inside_room = inside; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
970 } |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
971 |
952 | 972 guint buddy_getinsideroom(gpointer rosterdata) |
644
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
973 { |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
974 roster *roster_usr = rosterdata; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
975 return roster_usr->inside_room; |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
976 } |
68fb0c1dfb15
MUC: better nickname check when entering a room
Mikael Berthe <mikael@lilotux.net>
parents:
625
diff
changeset
|
977 |
548
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
978 // buddy_settopic(buddy, newtopic) |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
979 // Only for chatrooms |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
980 void buddy_settopic(gpointer rosterdata, const char *newtopic) |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
981 { |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
982 roster *roster_usr = rosterdata; |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
983 |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
984 if (!(roster_usr->type & ROSTER_TYPE_ROOM)) return; |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
985 |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
986 if (roster_usr->topic) { |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
987 g_free((gchar*)roster_usr->topic); |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
988 roster_usr->topic = NULL; |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
989 } |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
990 if (newtopic) |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
991 roster_usr->topic = g_strdup(newtopic); |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
992 } |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
993 |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
994 const char *buddy_gettopic(gpointer rosterdata) |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
995 { |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
996 roster *roster_usr = rosterdata; |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
997 return roster_usr->topic; |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
998 } |
265c50238a48
Add buddy_{get,set}topic()
Mikael Berthe <mikael@lilotux.net>
parents:
539
diff
changeset
|
999 |
207 | 1000 // buddy_getgroupname() |
1001 // Returns a pointer on buddy's group name. | |
1002 const char *buddy_getgroupname(gpointer rosterdata) | |
1003 { | |
1004 roster *roster_usr = rosterdata; | |
1005 | |
1006 if (roster_usr->type & ROSTER_TYPE_GROUP) | |
1007 return roster_usr->name; | |
1008 | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1009 if (roster_usr->type & ROSTER_TYPE_SPECIAL) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1010 return NULL; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1011 |
207 | 1012 // This is a user |
1013 return ((roster*)((GSList*)roster_usr->list)->data)->name; | |
72 | 1014 } |
1015 | |
166 | 1016 // buddy_getgroup() |
1017 // Returns a pointer on buddy's group. | |
1018 gpointer buddy_getgroup(gpointer rosterdata) | |
1019 { | |
207 | 1020 roster *roster_usr = rosterdata; |
166 | 1021 |
207 | 1022 if (roster_usr->type & ROSTER_TYPE_GROUP) |
166 | 1023 return rosterdata; |
1024 | |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1025 if (roster_usr->type & ROSTER_TYPE_SPECIAL) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1026 return NULL; |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1027 |
166 | 1028 // This is a user |
207 | 1029 return (gpointer)((GSList*)roster_usr->list)->data; |
166 | 1030 } |
1031 | |
489
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1032 void buddy_settype(gpointer rosterdata, guint type) |
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1033 { |
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1034 roster *roster_usr = rosterdata; |
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1035 roster_usr->type = type; |
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1036 } |
21ab22a60bcb
Auto-convert a roster item to "room" type when receiving a groupchat message
Mikael Berthe <mikael@lilotux.net>
parents:
483
diff
changeset
|
1037 |
72 | 1038 guint buddy_gettype(gpointer rosterdata) |
1039 { | |
207 | 1040 roster *roster_usr = rosterdata; |
1041 return roster_usr->type; | |
72 | 1042 } |
1043 | |
603 | 1044 guint buddy_getsubscription(gpointer rosterdata) |
1045 { | |
1046 roster *roster_usr = rosterdata; | |
1047 return roster_usr->subscription; | |
1048 } | |
1049 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1050 enum imstatus buddy_getstatus(gpointer rosterdata, const char *resname) |
72 | 1051 { |
207 | 1052 roster *roster_usr = rosterdata; |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1053 res *p_res = get_resource(roster_usr, resname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1054 if (p_res) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1055 return p_res->status; |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1056 return offline; |
72 | 1057 } |
1058 | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1059 const char *buddy_getstatusmsg(gpointer rosterdata, const char *resname) |
221 | 1060 { |
1061 roster *roster_usr = rosterdata; | |
438
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1062 res *p_res = get_resource(roster_usr, resname); |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1063 if (p_res) |
b44be19d6229
Handle multiple resources for the same buddy
Mikael Berthe <mikael@lilotux.net>
parents:
425
diff
changeset
|
1064 return p_res->status_msg; |
843
915a7f17474a
Remember the status message when a buddy goes offline
Mikael Berthe <mikael@lilotux.net>
parents:
819
diff
changeset
|
1065 return roster_usr->offline_status_message; |
221 | 1066 } |
1067 | |
625
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1068 time_t buddy_getstatustime(gpointer rosterdata, const char *resname) |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1069 { |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1070 roster *roster_usr = rosterdata; |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1071 res *p_res = get_resource(roster_usr, resname); |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1072 if (p_res) |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1073 return p_res->status_timestamp; |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1074 return 0; |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1075 } |
028c01940490
Show presence timestamps in "/info" and "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
621
diff
changeset
|
1076 |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1077 gchar buddy_getresourceprio(gpointer rosterdata, const char *resname) |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1078 { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1079 roster *roster_usr = rosterdata; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1080 res *p_res = get_resource(roster_usr, resname); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1081 if (p_res) |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1082 return p_res->prio; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1083 return 0; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1084 } |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1085 |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1086 guint buddy_resource_getevents(gpointer rosterdata, const char *resname) |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1087 { |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1088 roster *roster_usr = rosterdata; |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1089 res *p_res = get_resource(roster_usr, resname); |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1090 if (p_res) |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1091 return p_res->events; |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1092 return ROSTER_EVENT_NONE; |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1093 } |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1094 |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1095 void buddy_resource_setevents(gpointer rosterdata, const char *resname, |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1096 guint events) |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1097 { |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1098 roster *roster_usr = rosterdata; |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1099 res *p_res = get_resource(roster_usr, resname); |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1100 if (p_res) |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1101 p_res->events = events; |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1102 } |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1103 |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1104 struct jep0022 *buddy_resource_jep22(gpointer rosterdata, const char *resname) |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1105 { |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1106 #ifdef JEP0022 |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1107 roster *roster_usr = rosterdata; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1108 res *p_res = get_resource(roster_usr, resname); |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1109 if (p_res) |
987
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1110 return &p_res->jep22; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1111 #endif |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1112 return NULL; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1113 } |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1114 |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1115 struct jep0085 *buddy_resource_jep85(gpointer rosterdata, const char *resname) |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1116 { |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1117 #ifdef JEP0085 |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1118 roster *roster_usr = rosterdata; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1119 res *p_res = get_resource(roster_usr, resname); |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1120 if (p_res) |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1121 return &p_res->jep85; |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1122 #endif |
f47e312560af
Improve JEP22 + JEP85 support
Mikael Berthe <mikael@lilotux.net>
parents:
986
diff
changeset
|
1123 return NULL; |
986
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1124 } |
ed697234bd39
Chat states receival (Alexis Hildebrandt)
Mikael Berthe <mikael@lilotux.net>
parents:
977
diff
changeset
|
1125 |
1043
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1126 struct pgp_data *buddy_resource_pgp(gpointer rosterdata, const char *resname) |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1127 { |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1128 #ifdef HAVE_GPGME |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1129 roster *roster_usr = rosterdata; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1130 res *p_res = get_resource(roster_usr, resname); |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1131 if (p_res) |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1132 return &p_res->pgpdata; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1133 #endif |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1134 return NULL; |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1135 } |
ebbde723614b
Store contacts PGP keys
Mikael Berthe <mikael@lilotux.net>
parents:
1010
diff
changeset
|
1136 |
572
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1137 enum imrole buddy_getrole(gpointer rosterdata, const char *resname) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1138 { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1139 roster *roster_usr = rosterdata; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1140 res *p_res = get_resource(roster_usr, resname); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1141 if (p_res) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1142 return p_res->role; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1143 return role_none; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1144 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1145 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1146 enum imaffiliation buddy_getaffil(gpointer rosterdata, const char *resname) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1147 { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1148 roster *roster_usr = rosterdata; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1149 res *p_res = get_resource(roster_usr, resname); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1150 if (p_res) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1151 return p_res->affil; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1152 return affil_none; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1153 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1154 |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1155 const char *buddy_getrjid(gpointer rosterdata, const char *resname) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1156 { |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1157 roster *roster_usr = rosterdata; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1158 res *p_res = get_resource(roster_usr, resname); |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1159 if (p_res) |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1160 return p_res->realjid; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1161 return NULL; |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1162 } |
afc2bd38b15c
Implement affiliations handling, add "/room whois"
Mikael Berthe <mikael@lilotux.net>
parents:
564
diff
changeset
|
1163 |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1164 // buddy_getresources(roster_data) |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1165 // Return a singly-linked-list of resource names |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1166 // Note: the caller should free the list (and data) after use |
501
7c1ca00070e8
Add COMPL_RESOURCE (resource completion category)
Mikael Berthe <mikael@lilotux.net>
parents:
494
diff
changeset
|
1167 // If roster_data is null, the current buddy is selected |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1168 GSList *buddy_getresources(gpointer rosterdata) |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1169 { |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1170 roster *roster_usr = rosterdata; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1171 GSList *reslist = NULL, *lp; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1172 |
501
7c1ca00070e8
Add COMPL_RESOURCE (resource completion category)
Mikael Berthe <mikael@lilotux.net>
parents:
494
diff
changeset
|
1173 if (!roster_usr) { |
7c1ca00070e8
Add COMPL_RESOURCE (resource completion category)
Mikael Berthe <mikael@lilotux.net>
parents:
494
diff
changeset
|
1174 if (!current_buddy) return NULL; |
7c1ca00070e8
Add COMPL_RESOURCE (resource completion category)
Mikael Berthe <mikael@lilotux.net>
parents:
494
diff
changeset
|
1175 roster_usr = BUDDATA(current_buddy); |
7c1ca00070e8
Add COMPL_RESOURCE (resource completion category)
Mikael Berthe <mikael@lilotux.net>
parents:
494
diff
changeset
|
1176 } |
439
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1177 for (lp = roster_usr->resource; lp; lp = g_slist_next(lp)) |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1178 reslist = g_slist_append(reslist, g_strdup(((res*)lp->data)->name)); |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1179 |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1180 return reslist; |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1181 } |
63562fd409a1
/info can show multiple resources
Mikael Berthe <mikael@lilotux.net>
parents:
438
diff
changeset
|
1182 |
792
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1183 // buddy_getresources_locale(roster_data) |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1184 // Same as buddy_getresources() but names are converted to user's locale |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1185 // Note: the caller should free the list (and data) after use |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1186 GSList *buddy_getresources_locale(gpointer rosterdata) |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1187 { |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1188 GSList *reslist, *lp; |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1189 |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1190 reslist = buddy_getresources(rosterdata); |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1191 // Convert each item to UI's locale |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1192 for (lp = reslist; lp; lp = g_slist_next(lp)) { |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1193 gchar *oldname = lp->data; |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1194 lp->data = from_utf8(oldname); |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1195 if (lp->data) |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1196 g_free(oldname); |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1197 else |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1198 lp->data = oldname; |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1199 } |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1200 return reslist; |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1201 } |
89ad7b530b3c
MUC: Fix completion for UTF-8 nicknames
Mikael Berthe <mikael@lilotux.net>
parents:
783
diff
changeset
|
1202 |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
649
diff
changeset
|
1203 /* |
539 | 1204 // buddy_isresource(roster_data) |
1205 // Return true if there is at least one resource | |
1206 // (which means, for a room, that it isn't empty) | |
1207 int buddy_isresource(gpointer rosterdata) | |
1208 { | |
1209 roster *roster_usr = rosterdata; | |
1210 if (!roster_usr) | |
1211 return FALSE; | |
1212 if (roster_usr->resource) | |
1213 return TRUE; | |
1214 return FALSE; | |
1215 } | |
652
b243d3b3ff1b
We do not need buddy_isresource() anymore
Mikael Berthe <mikael@lilotux.net>
parents:
649
diff
changeset
|
1216 */ |
539 | 1217 |
468
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1218 // buddy_resource_setname(roster_data, oldname, newname) |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1219 // Useful for nickname change in a MUC room |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1220 void buddy_resource_setname(gpointer rosterdata, const char *resname, |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1221 const char *newname) |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1222 { |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1223 roster *roster_usr = rosterdata; |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1224 res *p_res = get_resource(roster_usr, resname); |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1225 if (p_res) { |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1226 if (p_res->name) { |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1227 g_free((gchar*)p_res->name); |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1228 p_res->name = NULL; |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1229 } |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1230 if (newname) |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1231 p_res->name = g_strdup(newname); |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1232 } |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1233 } |
644b8bf9ca4d
Improve MUC presence messages handling
Mikael Berthe <mikael@lilotux.net>
parents:
447
diff
changeset
|
1234 |
447
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1235 // buddy_del_all_resources() |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1236 // Remove all resources from the specified buddy |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1237 void buddy_del_all_resources(gpointer rosterdata) |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1238 { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1239 roster *roster_usr = rosterdata; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1240 |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1241 while (roster_usr->resource) { |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1242 res *r = roster_usr->resource->data; |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1243 del_resource(roster_usr, r->name); |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1244 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1245 } |
03bb57383cea
Initial Multi-User Chat support
Mikael Berthe <mikael@lilotux.net>
parents:
439
diff
changeset
|
1246 |
119 | 1247 // buddy_setflags() |
1248 // Set one or several flags to value (TRUE/FALSE) | |
1249 void buddy_setflags(gpointer rosterdata, guint flags, guint value) | |
1250 { | |
207 | 1251 roster *roster_usr = rosterdata; |
119 | 1252 if (value) |
207 | 1253 roster_usr->flags |= flags; |
119 | 1254 else |
207 | 1255 roster_usr->flags &= ~flags; |
119 | 1256 } |
1257 | |
72 | 1258 guint buddy_getflags(gpointer rosterdata) |
1259 { | |
207 | 1260 roster *roster_usr = rosterdata; |
1261 return roster_usr->flags; | |
72 | 1262 } |
1263 | |
480 | 1264 // buddy_search_jid(jid) |
1265 // Look for a buddy with specified jid. | |
1266 // Search begins at buddylist; if no match is found in the the buddylist, | |
1267 // return NULL; | |
1268 GList *buddy_search_jid(char *jid) | |
1269 { | |
1270 GList *buddy; | |
1271 roster *roster_usr; | |
1272 | |
1273 if (!buddylist) return NULL; | |
1274 | |
1275 for (buddy = buddylist; buddy; buddy = g_list_next(buddy)) { | |
1276 roster_usr = (roster*)buddy->data; | |
1277 if (roster_usr->jid && !strcasecmp(roster_usr->jid, jid)) | |
1278 return buddy; | |
1279 } | |
1280 return NULL; | |
1281 } | |
1282 | |
265 | 1283 // buddy_search(string) |
1284 // Look for a buddy whose name or jid contains string. | |
1285 // Search begins at current_buddy; if no match is found in the the buddylist, | |
1286 // return NULL; | |
1287 GList *buddy_search(char *string) | |
1288 { | |
1289 GList *buddy = current_buddy; | |
1290 roster *roster_usr; | |
1291 if (!buddylist || !current_buddy) return NULL; | |
1292 for (;;) { | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1293 gchar *jid_locale, *name_locale; |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1294 char *found = NULL; |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1295 |
265 | 1296 buddy = g_list_next(buddy); |
1297 if (!buddy) | |
1298 buddy = buddylist; | |
1299 | |
1300 roster_usr = (roster*)buddy->data; | |
772
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1301 |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1302 jid_locale = from_utf8(roster_usr->jid); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1303 if (jid_locale) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1304 found = strcasestr(jid_locale, string); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1305 g_free(jid_locale); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1306 if (found) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1307 return buddy; |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1308 } |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1309 name_locale = from_utf8(roster_usr->name); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1310 if (name_locale) { |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1311 found = strcasestr(name_locale, string); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1312 g_free(name_locale); |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1313 if (found) |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1314 return buddy; |
464be13343a9
Store most data in UTF-8 internally
Mikael Berthe <mikael@lilotux.net>
parents:
699
diff
changeset
|
1315 } |
265 | 1316 |
1317 if (buddy == current_buddy) | |
1318 return NULL; // Back to the beginning, and no match found | |
1319 } | |
1320 } | |
1321 | |
532
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1322 // foreach_buddy(roster_type, pfunction, param) |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1323 // Call pfunction(buddy, param) for each buddy from the roster with |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1324 // type matching roster_type. |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1325 void foreach_buddy(guint roster_type, |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1326 void (*pfunc)(gpointer rosterdata, void *param), |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1327 void *param) |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1328 { |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1329 GSList *sl_roster_elt = groups; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1330 roster *roster_elt; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1331 GSList *sl_roster_usrelt; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1332 roster *roster_usrelt; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1333 |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1334 while (sl_roster_elt) { // group list loop |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1335 roster_elt = (roster*) sl_roster_elt->data; |
848
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1336 if (roster_elt->type & ROSTER_TYPE_SPECIAL) |
a9161d2dc414
Introduce special buffer stuff
Mikael Berthe <mikael@lilotux.net>
parents:
843
diff
changeset
|
1337 continue; // Skip special items |
532
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1338 sl_roster_usrelt = roster_elt->list; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1339 while (sl_roster_usrelt) { // user list loop |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1340 roster_usrelt = (roster*) sl_roster_usrelt->data; |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1341 |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1342 if (roster_usrelt->type & roster_type) |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1343 pfunc(roster_usrelt, param); |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1344 |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1345 sl_roster_usrelt = g_slist_next(sl_roster_usrelt); |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1346 } |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1347 sl_roster_elt = g_slist_next(sl_roster_elt); |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1348 } |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1349 } |
2ac8d8e49e81
Send status changes to chatrooms
Mikael Berthe <mikael@lilotux.net>
parents:
520
diff
changeset
|
1350 |
885
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1351 // foreach_group_member(group, pfunction, param) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1352 // Call pfunction(buddy, param) for each buddy in the specified group. |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1353 void foreach_group_member(gpointer groupdata, |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1354 void (*pfunc)(gpointer rosterdata, void *param), |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1355 void *param) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1356 { |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1357 roster *roster_elt; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1358 GSList *sl_roster_usrelt; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1359 roster *roster_usrelt; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1360 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1361 roster_elt = groupdata; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1362 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1363 if (!(roster_elt->type & ROSTER_TYPE_GROUP)) |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1364 return; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1365 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1366 sl_roster_usrelt = roster_elt->list; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1367 while (sl_roster_usrelt) { // user list loop |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1368 roster_usrelt = (roster*) sl_roster_usrelt->data; |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1369 |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1370 pfunc(roster_usrelt, param); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1371 sl_roster_usrelt = g_slist_next(sl_roster_usrelt); |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1372 } |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1373 } |
afdd81c2c44d
Allow /rename for groups
Mikael Berthe <mikael@lilotux.net>
parents:
863
diff
changeset
|
1374 |
225 | 1375 // compl_list(type) |
1376 // Returns a list of jid's or groups. (For commands completion) | |
1377 // type: ROSTER_TYPE_USER (jid's) or ROSTER_TYPE_GROUP (group names) | |
1378 // The list should be freed by the caller after use. | |
1379 GSList *compl_list(guint type) | |
1380 { | |
1381 GSList *list = NULL; | |
1088
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1382 GSList *sl_roster_elt = groups; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1383 roster *roster_elt; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1384 GSList *sl_roster_usrelt; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1385 roster *roster_usrelt; |
225 | 1386 |
1088
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1387 while (sl_roster_elt) { // group list loop |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1388 roster_elt = (roster*) sl_roster_elt->data; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1389 |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1390 if (roster_elt->type & ROSTER_TYPE_SPECIAL) |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1391 continue; // Skip special items |
225 | 1392 |
1393 if (type == ROSTER_TYPE_GROUP) { // (group names) | |
1088
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1394 if (roster_elt->name && *(roster_elt->name)) |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1395 list = g_slist_append(list, from_utf8(roster_elt->name)); |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1396 } else { // ROSTER_TYPE_USER (jid) (or agent, or chatroom...) |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1397 sl_roster_usrelt = roster_elt->list; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1398 while (sl_roster_usrelt) { // user list loop |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1399 roster_usrelt = (roster*) sl_roster_usrelt->data; |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1400 |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1401 if (roster_usrelt->jid) |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1402 list = g_slist_append(list, from_utf8(roster_usrelt->jid)); |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1403 |
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1404 sl_roster_usrelt = g_slist_next(sl_roster_usrelt); |
225 | 1405 } |
1406 } | |
1088
c55b24818546
Enable jid completion for hidden buddies (e.g. offline contacts)
Mikael Berthe <mikael@lilotux.net>
parents:
1065
diff
changeset
|
1407 sl_roster_elt = g_slist_next(sl_roster_elt); |
225 | 1408 } |
1409 | |
1410 return list; | |
1411 } | |
1412 | |
236 | 1413 // unread_msg(rosterdata) |
1414 // Return the next buddy with an unread message. If the parameter is NULL, | |
1415 // return the first buddy with an unread message. | |
1416 gpointer unread_msg(gpointer rosterdata) | |
1417 { | |
1418 GSList *unread, *next_unread; | |
1419 | |
564 | 1420 if (!unread_list) |
1421 return NULL; | |
1422 | |
236 | 1423 // First unread message |
564 | 1424 if (!rosterdata) |
1425 return unread_list->data; | |
236 | 1426 |
1427 unread = g_slist_find(unread_list, rosterdata); | |
564 | 1428 if (!unread) |
1429 return unread_list->data; | |
236 | 1430 |
1431 next_unread = g_slist_next(unread); | |
564 | 1432 if (next_unread) |
1433 return next_unread->data; | |
236 | 1434 return unread_list->data; |
1435 } | |
576 | 1436 |
662
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1437 |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1438 /* ### "unread_jids" functions ### |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1439 * |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1440 * The unread_jids hash table is used to keep track of the buddies with |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1441 * unread messages when a disconnection occurs. |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1442 * When removing a buddy with an unread message from the roster, the |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1443 * jid should be added to the unread_jids table. When adding a buddy to |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1444 * the roster, we check if (s)he had a pending unread message. |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1445 */ |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1446 |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1447 // unread_jid_add(jid) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1448 // Add jid to the unread_jids hash table |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1449 void unread_jid_add(const char *jid) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1450 { |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1451 if (!unread_jids) { |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1452 // Initialize unread_jids hash table |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1453 unread_jids = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1454 } |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1455 // The 2nd unread_jids is an arbitrary non-null pointer: |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1456 g_hash_table_insert(unread_jids, g_strdup(jid), unread_jids); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1457 } |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1458 |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1459 // unread_jid_del(jid) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1460 // Return TRUE if jid is found in the table (and remove it), FALSE if not |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1461 int unread_jid_del(const char *jid) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1462 { |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1463 if (!unread_jids) |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1464 return FALSE; |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1465 return g_hash_table_remove(unread_jids, jid); |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1466 } |
4111ff4cdd15
Do not loose the unread_message flag when disconnecting from the server
Mikael Berthe <mikael@lilotux.net>
parents:
652
diff
changeset
|
1467 |
580 | 1468 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |