Mercurial > hg
comparison mcabber/src/commands.c @ 1268:dbc907b2d92f
Add configurable colors for info and incoming messages (Michal 'vorner' Vaner)
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Mon, 20 Aug 2007 19:41:31 +0200 |
parents | b4ccc5b2a6de |
children | 033576acac4c |
comparison
equal
deleted
inserted
replaced
1267:c5257cbe6ae4 | 1268:dbc907b2d92f |
---|---|
519 static void display_and_free_note(struct annotation *note, const char *winId) | 519 static void display_and_free_note(struct annotation *note, const char *winId) |
520 { | 520 { |
521 gchar tbuf[128]; | 521 gchar tbuf[128]; |
522 GString *sbuf; | 522 GString *sbuf; |
523 guint msg_flag = HBB_PREFIX_INFO; | 523 guint msg_flag = HBB_PREFIX_INFO; |
524 /* We use the flag prefix_info for the first line, and prefix_none | 524 /* We use the flag prefix_info for the first line, and prefix_cont |
525 for the other lines, for better readability */ | 525 for the other lines, for better readability */ |
526 | 526 |
527 if (!note) | 527 if (!note) |
528 return; | 528 return; |
529 | 529 |
531 | 531 |
532 if (!winId) { | 532 if (!winId) { |
533 // We're writing to the status window, so let's show the jid too. | 533 // We're writing to the status window, so let's show the jid too. |
534 g_string_printf(sbuf, "Annotation on <%s>", note->jid); | 534 g_string_printf(sbuf, "Annotation on <%s>", note->jid); |
535 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); | 535 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
536 msg_flag = HBB_PREFIX_NONE; | 536 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
537 } | 537 } |
538 | 538 |
539 // If we have the creation date, display it | 539 // If we have the creation date, display it |
540 if (note->cdate) { | 540 if (note->cdate) { |
541 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", | 541 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
542 localtime(¬e->cdate)); | 542 localtime(¬e->cdate)); |
543 g_string_printf(sbuf, "Note created %s", tbuf); | 543 g_string_printf(sbuf, "Note created %s", tbuf); |
544 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); | 544 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
545 msg_flag = HBB_PREFIX_NONE; | 545 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
546 } | 546 } |
547 // If we have the modification date, display it | 547 // If we have the modification date, display it |
548 // unless it's the same as the creation date | 548 // unless it's the same as the creation date |
549 if (note->mdate && note->mdate != note->cdate) { | 549 if (note->mdate && note->mdate != note->cdate) { |
550 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", | 550 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", |
551 localtime(¬e->mdate)); | 551 localtime(¬e->mdate)); |
552 g_string_printf(sbuf, "Note modified %s", tbuf); | 552 g_string_printf(sbuf, "Note modified %s", tbuf); |
553 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); | 553 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
554 msg_flag = HBB_PREFIX_NONE; | 554 msg_flag = HBB_PREFIX_INFO | HBB_PREFIX_CONT; |
555 } | 555 } |
556 // Note text | 556 // Note text |
557 g_string_printf(sbuf, "Note: %s", note->text); | 557 g_string_printf(sbuf, "Note: %s", note->text); |
558 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); | 558 scr_WriteIncomingMessage(winId, sbuf->str, 0, msg_flag); |
559 | 559 |
1400 snprintf(buffer, 4095, "Resource: [%c] (%d) %s", imstatus2char[rstatus], | 1400 snprintf(buffer, 4095, "Resource: [%c] (%d) %s", imstatus2char[rstatus], |
1401 rprio, (char*)p_res->data); | 1401 rprio, (char*)p_res->data); |
1402 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); | 1402 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
1403 if (rst_msg) { | 1403 if (rst_msg) { |
1404 snprintf(buffer, 4095, "Status message: %s", rst_msg); | 1404 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1405 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 1405 scr_WriteIncomingMessage(bjid, buffer, |
1406 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
1406 } | 1407 } |
1407 if (rst_time) { | 1408 if (rst_time) { |
1408 char tbuf[128]; | 1409 char tbuf[128]; |
1409 | 1410 |
1410 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); | 1411 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
1411 snprintf(buffer, 127, "Status timestamp: %s", tbuf); | 1412 snprintf(buffer, 127, "Status timestamp: %s", tbuf); |
1412 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 1413 scr_WriteIncomingMessage(bjid, buffer, |
1414 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
1413 } | 1415 } |
1414 #ifdef HAVE_GPGME | 1416 #ifdef HAVE_GPGME |
1415 if (rpgp && rpgp->sign_keyid) { | 1417 if (rpgp && rpgp->sign_keyid) { |
1416 snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid); | 1418 snprintf(buffer, 4095, "PGP key id: %s", rpgp->sign_keyid); |
1417 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 1419 scr_WriteIncomingMessage(bjid, buffer, |
1420 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
1418 if (rpgp->last_sigsum) { | 1421 if (rpgp->last_sigsum) { |
1419 gpgme_sigsum_t ss = rpgp->last_sigsum; | 1422 gpgme_sigsum_t ss = rpgp->last_sigsum; |
1420 snprintf(buffer, 4095, "Last PGP signature: %s", | 1423 snprintf(buffer, 4095, "Last PGP signature: %s", |
1421 (ss & GPGME_SIGSUM_GREEN ? "good": | 1424 (ss & GPGME_SIGSUM_GREEN ? "good": |
1422 (ss & GPGME_SIGSUM_RED ? "bad" : "unknown"))); | 1425 (ss & GPGME_SIGSUM_RED ? "bad" : "unknown"))); |
1423 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 1426 scr_WriteIncomingMessage(bjid, buffer, |
1427 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
1424 } | 1428 } |
1425 } | 1429 } |
1426 #endif | 1430 #endif |
1427 g_free(p_res->data); | 1431 g_free(p_res->data); |
1428 } | 1432 } |
1498 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], | 1502 snprintf(buffer, 4095, "[%c] %s", imstatus2char[rstatus], |
1499 (char*)p_res->data); | 1503 (char*)p_res->data); |
1500 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); | 1504 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
1501 if (rst_msg && style == style_normal) { | 1505 if (rst_msg && style == style_normal) { |
1502 snprintf(buffer, 4095, "Status message: %s", rst_msg); | 1506 snprintf(buffer, 4095, "Status message: %s", rst_msg); |
1503 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 1507 scr_WriteIncomingMessage(bjid, buffer, |
1508 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
1504 } | 1509 } |
1505 } | 1510 } |
1506 g_free(p_res->data); | 1511 g_free(p_res->data); |
1507 } | 1512 } |
1508 g_slist_free(resources); | 1513 g_slist_free(resources); |
2262 | 2267 |
2263 snprintf(buffer, 4095, "Whois [%s]", nick); | 2268 snprintf(buffer, 4095, "Whois [%s]", nick); |
2264 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); | 2269 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO); |
2265 snprintf(buffer, 4095, "Status : [%c] %s", imstatus2char[rstatus], | 2270 snprintf(buffer, 4095, "Status : [%c] %s", imstatus2char[rstatus], |
2266 rst_msg); | 2271 rst_msg); |
2267 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2272 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); |
2268 | 2273 |
2269 if (rst_time) { | 2274 if (rst_time) { |
2270 char tbuf[128]; | 2275 char tbuf[128]; |
2271 | 2276 |
2272 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); | 2277 strftime(tbuf, sizeof(tbuf), "%Y-%m-%d %H:%M:%S", localtime(&rst_time)); |
2273 snprintf(buffer, 127, "Timestamp: %s", tbuf); | 2278 snprintf(buffer, 127, "Timestamp: %s", tbuf); |
2274 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2279 scr_WriteIncomingMessage(bjid, buffer, |
2280 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
2275 } | 2281 } |
2276 | 2282 |
2277 if (realjid) { | 2283 if (realjid) { |
2278 snprintf(buffer, 4095, "JID : <%s>", realjid); | 2284 snprintf(buffer, 4095, "JID : <%s>", realjid); |
2279 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2285 scr_WriteIncomingMessage(bjid, buffer, |
2286 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
2280 } | 2287 } |
2281 | 2288 |
2282 snprintf(buffer, 4095, "Role : %s", strrole[role]); | 2289 snprintf(buffer, 4095, "Role : %s", strrole[role]); |
2283 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2290 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); |
2284 snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); | 2291 snprintf(buffer, 4095, "Affiliat.: %s", straffil[affil]); |
2285 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2292 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); |
2286 snprintf(buffer, 4095, "Priority : %d", rprio); | 2293 snprintf(buffer, 4095, "Priority : %d", rprio); |
2287 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_NONE); | 2294 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); |
2288 | 2295 |
2289 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO); | 2296 scr_WriteIncomingMessage(bjid, "End of WHOIS", 0, HBB_PREFIX_INFO); |
2290 | 2297 |
2291 g_free(buffer); | 2298 g_free(buffer); |
2292 g_free(nick); | 2299 g_free(nick); |
2343 | 2350 |
2344 scr_WriteIncomingMessage(NULL, "List of MUC bookmarks:", 0, HBB_PREFIX_INFO); | 2351 scr_WriteIncomingMessage(NULL, "List of MUC bookmarks:", 0, HBB_PREFIX_INFO); |
2345 | 2352 |
2346 for (bmp = bm; bmp; bmp = g_slist_next(bmp)) { | 2353 for (bmp = bm; bmp; bmp = g_slist_next(bmp)) { |
2347 g_string_printf(sbuf, "<%s>", (char*)bmp->data); | 2354 g_string_printf(sbuf, "<%s>", (char*)bmp->data); |
2348 scr_WriteIncomingMessage(NULL, sbuf->str, 0, HBB_PREFIX_NONE); | 2355 scr_WriteIncomingMessage(NULL, sbuf->str, |
2356 0, HBB_PREFIX_INFO | HBB_PREFIX_CONT); | |
2349 } | 2357 } |
2350 | 2358 |
2351 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); | 2359 scr_setmsgflag_if_needed(SPECIAL_BUFFER_STATUS_ID, TRUE); |
2352 update_roster = TRUE; | 2360 update_roster = TRUE; |
2353 g_string_free(sbuf, TRUE); | 2361 g_string_free(sbuf, TRUE); |