Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/presence.c @ 17563:95affacf6f82
Added the ability to define extensions to caps
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Wed, 06 Jun 2007 01:19:49 +0000 |
parents | 3919c68eb5b7 |
children | ac1ee71efd89 |
comparison
equal
deleted
inserted
replaced
17562:6ab1089e2101 | 17563:95affacf6f82 |
---|---|
116 js = gc->proto_data; | 116 js = gc->proto_data; |
117 | 117 |
118 purple_status_to_jabber(status, &state, &stripped, &priority); | 118 purple_status_to_jabber(status, &state, &stripped, &priority); |
119 | 119 |
120 | 120 |
121 presence = jabber_presence_create(state, stripped, priority); | 121 presence = jabber_presence_create_js(js, state, stripped, priority); |
122 g_free(stripped); | 122 g_free(stripped); |
123 | 123 |
124 if(js->avatar_hash) { | 124 if(js->avatar_hash) { |
125 x = xmlnode_new_child(presence, "x"); | 125 x = xmlnode_new_child(presence, "x"); |
126 xmlnode_set_namespace(x, "vcard-temp:x:update"); | 126 xmlnode_set_namespace(x, "vcard-temp:x:update"); |
135 | 135 |
136 jabber_presence_fake_to_self(js, status); | 136 jabber_presence_fake_to_self(js, status); |
137 } | 137 } |
138 | 138 |
139 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) | 139 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority) |
140 { | |
141 return jabber_presence_create_js(NULL, state, msg, priority); | |
142 } | |
143 | |
144 xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority) | |
140 { | 145 { |
141 xmlnode *show, *status, *presence, *pri, *c; | 146 xmlnode *show, *status, *presence, *pri, *c; |
142 const char *show_string = NULL; | 147 const char *show_string = NULL; |
143 | 148 |
144 presence = xmlnode_new("presence"); | 149 presence = xmlnode_new("presence"); |
170 /* JEP-0115 */ | 175 /* JEP-0115 */ |
171 c = xmlnode_new_child(presence, "c"); | 176 c = xmlnode_new_child(presence, "c"); |
172 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); | 177 xmlnode_set_namespace(c, "http://jabber.org/protocol/caps"); |
173 xmlnode_set_attrib(c, "node", CAPS0115_NODE); | 178 xmlnode_set_attrib(c, "node", CAPS0115_NODE); |
174 xmlnode_set_attrib(c, "ver", VERSION); | 179 xmlnode_set_attrib(c, "ver", VERSION); |
180 | |
181 if(js != NULL) { | |
182 /* add the extensions */ | |
183 char extlist[1024]; | |
184 unsigned remaining = 1023; /* one less for the \0 */ | |
185 GSList *feature; | |
186 | |
187 extlist[0] = '\0'; | |
188 for(feature = js->features; feature && remaining > 0; feature = feature->next) { | |
189 JabberFeature *feat = (JabberFeature*)feature->data; | |
190 unsigned featlen = strlen(feat->shortname); | |
191 | |
192 /* cut off when we don't have any more space left in our buffer (too bad) */ | |
193 if(featlen > remaining) | |
194 break; | |
195 | |
196 strncat(extlist,feat->shortname,remaining); | |
197 remaining -= featlen; | |
198 strncat(extlist," ",remaining); | |
199 --remaining; | |
200 } | |
201 /* did we add anything? */ | |
202 if(remaining < 1023) | |
203 xmlnode_set_attrib(c, "ext", extlist); | |
204 } | |
175 | 205 |
176 return presence; | 206 return presence; |
177 } | 207 } |
178 | 208 |
179 struct _jabber_add_permit { | 209 struct _jabber_add_permit { |