Mercurial > pidgin
comparison libpurple/protocols/jabber/iq.c @ 27106:add3989f682e
Remove obsoleted XEP-0090 (Legacy Entity Time)
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 11 Jun 2009 22:50:29 +0000 |
parents | 10c91922bc1e |
children | e502112a03e7 |
comparison
equal
deleted
inserted
replaced
27105:ea9cbfcbfd19 | 27106:add3989f682e |
---|---|
166 | 166 |
167 jabber_iq_send(iq); | 167 jabber_iq_send(iq); |
168 } | 168 } |
169 } | 169 } |
170 | 170 |
171 static void jabber_iq_time_parse(JabberStream *js, const char *from, | 171 static void jabber_time_parse(JabberStream *js, const char *from, |
172 JabberIqType type, const char *id, | 172 JabberIqType type, const char *id, |
173 xmlnode *child) | 173 xmlnode *child) |
174 { | 174 { |
175 const char *xmlns; | |
176 JabberIq *iq; | 175 JabberIq *iq; |
177 time_t now_t; | 176 time_t now_t; |
178 struct tm now_local; | 177 struct tm *tm; |
179 struct tm now_utc; | |
180 struct tm *now; | |
181 | 178 |
182 time(&now_t); | 179 time(&now_t); |
183 now = localtime(&now_t); | |
184 memcpy(&now_local, now, sizeof(struct tm)); | |
185 now = gmtime(&now_t); | |
186 memcpy(&now_utc, now, sizeof(struct tm)); | |
187 | |
188 xmlns = xmlnode_get_namespace(child); | |
189 | 180 |
190 if(type == JABBER_IQ_GET) { | 181 if(type == JABBER_IQ_GET) { |
191 xmlnode *utc; | 182 xmlnode *tzo, *utc; |
192 const char *date, *tz, *display; | 183 const char *date, *tz; |
193 | 184 |
194 iq = jabber_iq_new(js, JABBER_IQ_RESULT); | 185 iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
195 jabber_iq_set_id(iq, id); | 186 jabber_iq_set_id(iq, id); |
196 if (from) | 187 if (from) |
197 xmlnode_set_attrib(iq->node, "to", from); | 188 xmlnode_set_attrib(iq->node, "to", from); |
198 | 189 |
199 child = xmlnode_new_child(iq->node, child->name); | 190 child = xmlnode_new_child(iq->node, child->name); |
200 xmlnode_set_namespace(child, xmlns); | 191 xmlnode_set_namespace(child, "urn:xmpp:time"); |
192 | |
193 /* <tzo>-06:00</tzo> */ | |
194 tm = localtime(&now_t); | |
195 tz = purple_get_tzoff_str(tm, TRUE); | |
196 tzo = xmlnode_new_child(child, "tzo"); | |
197 xmlnode_insert_data(tzo, tz, -1); | |
198 | |
199 /* <utc>2006-12-19T17:58:35Z</utc> */ | |
200 tm = gmtime(&now_t); | |
201 date = purple_utf8_strftime("%FT%TZ", tm); | |
201 utc = xmlnode_new_child(child, "utc"); | 202 utc = xmlnode_new_child(child, "utc"); |
202 | 203 xmlnode_insert_data(utc, date, -1); |
203 if(!strcmp("urn:xmpp:time", xmlns)) { | |
204 tz = purple_get_tzoff_str(&now_local, TRUE); | |
205 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1); | |
206 | |
207 date = purple_utf8_strftime("%FT%TZ", &now_utc); | |
208 xmlnode_insert_data(utc, date, -1); | |
209 } else { /* jabber:iq:time */ | |
210 tz = purple_utf8_strftime("%Z", &now_local); | |
211 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1); | |
212 | |
213 date = purple_utf8_strftime("%Y%m%dT%T", &now_utc); | |
214 xmlnode_insert_data(utc, date, -1); | |
215 | |
216 display = purple_utf8_strftime("%d %b %Y %T", &now_local); | |
217 xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1); | |
218 } | |
219 | 204 |
220 jabber_iq_send(iq); | 205 jabber_iq_send(iq); |
206 } else { | |
207 /* TODO: Errors */ | |
221 } | 208 } |
222 } | 209 } |
223 | 210 |
224 static void jabber_iq_version_parse(JabberStream *js, const char *from, | 211 static void jabber_iq_version_parse(JabberStream *js, const char *from, |
225 JabberIqType type, const char *id, | 212 JabberIqType type, const char *id, |
486 jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse); | 473 jabber_iq_register_handler("query", "jabber:iq:oob", jabber_oob_parse); |
487 jabber_iq_register_handler("query", "jabber:iq:register", | 474 jabber_iq_register_handler("query", "jabber:iq:register", |
488 jabber_register_parse); | 475 jabber_register_parse); |
489 jabber_iq_register_handler("query", "jabber:iq:roster", | 476 jabber_iq_register_handler("query", "jabber:iq:roster", |
490 jabber_roster_parse); | 477 jabber_roster_parse); |
491 jabber_iq_register_handler("query", "jabber:iq:time", jabber_iq_time_parse); | |
492 jabber_iq_register_handler("query", "jabber:iq:version", | 478 jabber_iq_register_handler("query", "jabber:iq:version", |
493 jabber_iq_version_parse); | 479 jabber_iq_version_parse); |
494 #ifdef USE_VV | 480 #ifdef USE_VV |
495 jabber_iq_register_handler("session", "http://www.google.com/session", | 481 jabber_iq_register_handler("session", "http://www.google.com/session", |
496 jabber_google_session_parse); | 482 jabber_google_session_parse); |
497 #endif | 483 #endif |
498 jabber_iq_register_handler("block", "urn:xmpp:blocking", jabber_blocklist_parse_push); | 484 jabber_iq_register_handler("block", "urn:xmpp:blocking", jabber_blocklist_parse_push); |
499 jabber_iq_register_handler("unblock", "urn:xmpp:blocking", jabber_blocklist_parse_push); | 485 jabber_iq_register_handler("unblock", "urn:xmpp:blocking", jabber_blocklist_parse_push); |
500 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_iq_time_parse); | 486 jabber_iq_register_handler("time", "urn:xmpp:time", jabber_time_parse); |
501 | 487 |
502 } | 488 } |
503 | 489 |
504 void jabber_iq_uninit(void) | 490 void jabber_iq_uninit(void) |
505 { | 491 { |