From c4c5668779a26fa614b3511437454e6a2dcc027f Mon Sep 17 00:00:00 2001 From: James Booth Date: Wed, 7 Nov 2012 22:59:48 +0000 Subject: room_chat: add occupants to room roster until roster received --- src/jabber.c | 5 ++++- src/room_chat.c | 24 ++++++++++++++++++++++++ src/room_chat.h | 2 ++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/jabber.c b/src/jabber.c index 21530c7e..336c990b 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -660,9 +660,12 @@ _room_presence_handler(const char * const jid) // handle self presence (means room roster has been sent) if (strcmp(room_get_nick_for_room(room), nick) == 0) { + room_set_roster_received(room); prof_handle_room_roster_complete(room); } else { - room_add_to_roster(room, nick); + if (!room_get_roster_received(room)) { + room_add_to_roster(room, nick); + } } return 1; diff --git a/src/room_chat.c b/src/room_chat.c index 6b560bbf..82f997f7 100644 --- a/src/room_chat.c +++ b/src/room_chat.c @@ -29,6 +29,7 @@ typedef struct _muc_room_t { char *jid; char *nick; GSList *roster; + gboolean roster_received; } muc_room; GHashTable *rooms = NULL; @@ -47,6 +48,7 @@ room_join(const char * const jid, const char * const nick) new_room->jid = strdup(jid); new_room->nick = strdup(nick); new_room->roster = NULL; + new_room->roster_received = FALSE; g_hash_table_insert(rooms, strdup(jid), new_room); } @@ -131,6 +133,28 @@ room_get_roster(const char * const jid) } } +void +room_set_roster_received(const char * const jid) +{ + muc_room *room = g_hash_table_lookup(rooms, jid); + + if (room != NULL) { + room->roster_received = TRUE; + } +} + +gboolean +room_get_roster_received(const char * const jid) +{ + muc_room *room = g_hash_table_lookup(rooms, jid); + + if (room != NULL) { + return room->roster_received; + } else { + return FALSE; + } +} + static void _room_free(muc_room *room) { diff --git a/src/room_chat.h b/src/room_chat.h index 58e309a1..77675fcd 100644 --- a/src/room_chat.h +++ b/src/room_chat.h @@ -30,3 +30,5 @@ gboolean room_parse_room_jid(const char * const room_jid, char **room, char **nick); void room_add_to_roster(const char * const jid, const char * const nick); GSList * room_get_roster(const char * const jid); +void room_set_roster_received(const char * const jid); +gboolean room_get_roster_received(const char * const jid); -- cgit 1.4.1-2-gfad0 href='/akspecs/ranger/plain/Makefile?h=v1.9.0&id=043b7635ed9ef60e6e08453d692685e943fb2a78'>plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119