Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/jabglue.c @ 521:cc8c969ab6e5
"/status" changes
- No hardcoded status message
- If there is no user-defined status message, the current message is kept
- "/status $status -" clears the status message
- Auto-away improvement
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 19 Nov 2005 16:30:49 +0100 |
parents | 5c338d31de56 |
children | fc6bc26f891e |
comparison
equal
deleted
inserted
replaced
520:c60175268eb5 | 521:cc8c969ab6e5 |
---|---|
319 snprintf(strprio, 8, "%u", prio); | 319 snprintf(strprio, 8, "%u", prio); |
320 xmlnode_insert_cdata(xmlnode_insert_tag(x, "priority"), | 320 xmlnode_insert_cdata(xmlnode_insert_tag(x, "priority"), |
321 strprio, (unsigned) -1); | 321 strprio, (unsigned) -1); |
322 } | 322 } |
323 | 323 |
324 if (!msg) | 324 if (msg) { |
325 msg = settings_get_status_msg(st); | 325 // The status message has been specified. We'll use it, unless it is |
326 // "-" which is a special case (option meaning "no status message"). | |
327 if (!strcmp(msg, "-")) | |
328 msg = ""; | |
329 } else { | |
330 // No status message specified; we'll use: | |
331 // a) the default status message (if provided by the user); | |
332 // b) the current status message; | |
333 // c) no status message (i.e. an empty one). | |
334 msg = settings_get_status_msg(st); | |
335 if (!msg) { | |
336 if (mystatusmsg) | |
337 msg = mystatusmsg; | |
338 else | |
339 msg = ""; | |
340 } | |
341 } | |
326 | 342 |
327 utf8_msg = to_utf8(msg); | 343 utf8_msg = to_utf8(msg); |
328 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), utf8_msg, | 344 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), utf8_msg, |
329 (unsigned) -1); | 345 (unsigned) -1); |
330 | 346 |
331 jab_send(jc, x); | 347 jab_send(jc, x); |
348 g_free(utf8_msg); | |
332 xmlnode_free(x); | 349 xmlnode_free(x); |
333 g_free(utf8_msg); | |
334 | 350 |
335 // If we didn't change our _global_ status, we are done | 351 // If we didn't change our _global_ status, we are done |
336 if (recipient) return; | 352 if (recipient) return; |
337 | 353 |
338 // Buddy per buddy invisibility handling | 354 // Buddy per buddy invisibility handling |
343 if (mystatus == offline || st == offline) | 359 if (mystatus == offline || st == offline) |
344 update_roster = TRUE; | 360 update_roster = TRUE; |
345 | 361 |
346 hk_mystatuschange(0, mystatus, st, msg); | 362 hk_mystatuschange(0, mystatus, st, msg); |
347 mystatus = st; | 363 mystatus = st; |
348 if (mystatusmsg) g_free(mystatusmsg); | 364 if (msg != mystatusmsg) { |
349 if (msg) mystatusmsg = g_strdup(msg); | 365 if (mystatusmsg) |
350 else mystatusmsg = NULL; | 366 g_free(mystatusmsg); |
367 if (*msg) | |
368 mystatusmsg = g_strdup(msg); | |
369 else | |
370 mystatusmsg = NULL; | |
371 } | |
351 } | 372 } |
352 | 373 |
353 void jb_send_msg(const char *jid, const char *text, int type, | 374 void jb_send_msg(const char *jid, const char *text, int type, |
354 const char *subject) | 375 const char *subject) |
355 { | 376 { |