comparison src/protocols/jabber/jutil.c @ 7322:ab828b8c3f22

[gaim-migrate @ 7908] all sorts of stuff including tweaks to logging so it mostly works again for jabber. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 24 Oct 2003 05:46:01 +0000
parents dd4b4a187171
children 82dfe392a773
comparison
equal deleted inserted replaced
7321:c41e522028f2 7322:ab828b8c3f22
19 * 19 *
20 */ 20 */
21 #include "internal.h" 21 #include "internal.h"
22 #include "server.h" 22 #include "server.h"
23 23
24 #include "chat.h"
24 #include "presence.h" 25 #include "presence.h"
25 #include "jutil.h" 26 #include "jutil.h"
26 27
27 time_t str_to_time(const char *timestamp) 28 time_t str_to_time(const char *timestamp)
28 { 29 {
258 char *out; 259 char *out;
259 260
260 if(!jid) 261 if(!jid)
261 return NULL; 262 return NULL;
262 263
263 out = g_strdup_printf("%s@%s", jid->node, jid->domain); 264 out = g_strdup_printf("%s%s%s", jid->node ? jid->node : "",
265 jid->node ? "@" : "", jid->domain);
264 jabber_id_free(jid); 266 jabber_id_free(jid);
265 267
266 return out; 268 return out;
267 } 269 }
268 270
269 const char *jabber_normalize(const char *in) 271 const char *jabber_normalize(const GaimAccount *account, const char *in)
270 { 272 {
271 static char buf[2048]; /* maximum legal length of a jabber jid */ 273 GaimConnection *gc = account ? account->gc : NULL;
272 char *tmp; 274 JabberStream *js = gc ? gc->proto_data : NULL;
273 275 static char buf[3072]; /* maximum legal length of a jabber jid */
274 tmp = jabber_get_bare_jid(in); 276 JabberID *jid;
275 277
276 if(!tmp) 278 jid = jabber_id_new(in);
277 return NULL; 279
278 280 if(!jid)
279 g_snprintf(buf, sizeof(buf), "%s", tmp); 281 return NULL;
280 g_free(tmp); 282
283 if(js && jid->node && jid->resource &&
284 jabber_chat_find(js, jid->node, jid->domain))
285 g_snprintf(buf, sizeof(buf), "%s@%s/%s", jid->node, jid->domain,
286 jid->resource);
287 else
288 g_snprintf(buf, sizeof(buf), "%s%s%s", jid->node ? jid->node : "",
289 jid->node ? "@" : "", jid->domain);
290
281 return buf; 291 return buf;
282 } 292 }
283 293