Mercurial > hg
comparison mcabber/src/screen.c @ 1058:c0d44a9a99bc
Code cleanup
Cosmetics. Mostly get rid of "jid" variables, as it is a structure pointer
defined in libjabber/jabber.h.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Thu, 30 Nov 2006 19:51:09 +0100 |
parents | 5b3ecae91c95 |
children | 875d2c9d399c |
comparison
equal
deleted
inserted
replaced
1057:4cdf19d9c74e | 1058:c0d44a9a99bc |
---|---|
489 } | 489 } |
490 } | 490 } |
491 return NULL; | 491 return NULL; |
492 } | 492 } |
493 | 493 |
494 int scr_BuddyBufferExists(const char *jid) | 494 int scr_BuddyBufferExists(const char *bjid) |
495 { | 495 { |
496 return (scr_SearchWindow(jid, FALSE) != NULL); | 496 return (scr_SearchWindow(bjid, FALSE) != NULL); |
497 } | 497 } |
498 | 498 |
499 // scr_UpdateWindow() | 499 // scr_UpdateWindow() |
500 // (Re-)Display the given chat window. | 500 // (Re-)Display the given chat window. |
501 static void scr_UpdateWindow(winbuf *win_entry) | 501 static void scr_UpdateWindow(winbuf *win_entry) |
566 dir = '<'; | 566 dir = '<'; |
567 else if (line->flags & HBB_PREFIX_OUT) | 567 else if (line->flags & HBB_PREFIX_OUT) |
568 dir = '>'; | 568 dir = '>'; |
569 wprintw(win_entry->win, "%.11s #%c# ", date, dir); | 569 wprintw(win_entry->win, "%.11s #%c# ", date, dir); |
570 } else if (line->flags & HBB_PREFIX_IN) { | 570 } else if (line->flags & HBB_PREFIX_IN) { |
571 char crypt = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '='; | 571 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '='; |
572 wprintw(win_entry->win, "%.11s <%c= ", date, crypt); | 572 wprintw(win_entry->win, "%.11s <%c= ", date, cryptflag); |
573 } else if (line->flags & HBB_PREFIX_OUT) { | 573 } else if (line->flags & HBB_PREFIX_OUT) { |
574 char crypt = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-'; | 574 char cryptflag = line->flags & HBB_PREFIX_PGPCRYPT ? '~' : '-'; |
575 wprintw(win_entry->win, "%.11s -%c> ", date, crypt); | 575 wprintw(win_entry->win, "%.11s -%c> ", date, cryptflag); |
576 } else if (line->flags & HBB_PREFIX_SPECIAL) { | 576 } else if (line->flags & HBB_PREFIX_SPECIAL) { |
577 strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp)); | 577 strftime(date, 30, "%m-%d %H:%M:%S", localtime(&line->timestamp)); |
578 wprintw(win_entry->win, "%.14s ", date); | 578 wprintw(win_entry->win, "%.14s ", date); |
579 } else { | 579 } else { |
580 wprintw(win_entry->win, "%.11s ", date); | 580 wprintw(win_entry->win, "%.11s ", date); |
637 | 637 |
638 // scr_ShowBuddyWindow() | 638 // scr_ShowBuddyWindow() |
639 // Display the chat window buffer for the current buddy. | 639 // Display the chat window buffer for the current buddy. |
640 void scr_ShowBuddyWindow(void) | 640 void scr_ShowBuddyWindow(void) |
641 { | 641 { |
642 const gchar *jid; | 642 const gchar *bjid; |
643 | 643 |
644 if (!current_buddy) { | 644 if (!current_buddy) { |
645 jid = NULL; | 645 bjid = NULL; |
646 } else { | 646 } else { |
647 jid = CURRENT_JID; | 647 bjid = CURRENT_JID; |
648 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { | 648 if (buddy_gettype(BUDDATA(current_buddy)) & ROSTER_TYPE_SPECIAL) { |
649 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); | 649 scr_ShowWindow(buddy_getname(BUDDATA(current_buddy)), TRUE); |
650 return; | 650 return; |
651 } | 651 } |
652 } | 652 } |
653 | 653 |
654 if (!jid) { | 654 if (!bjid) { |
655 top_panel(chatPanel); | 655 top_panel(chatPanel); |
656 top_panel(inputPanel); | 656 top_panel(inputPanel); |
657 currentWindow = NULL; | 657 currentWindow = NULL; |
658 return; | 658 return; |
659 } | 659 } |
660 | 660 |
661 scr_ShowWindow(jid, FALSE); | 661 scr_ShowWindow(bjid, FALSE); |
662 } | 662 } |
663 | 663 |
664 // scr_UpdateBuddyWindow() | 664 // scr_UpdateBuddyWindow() |
665 // (Re)Display the current window. | 665 // (Re)Display the current window. |
666 // If chatmode is enabled, call scr_ShowBuddyWindow(), | 666 // If chatmode is enabled, call scr_ShowBuddyWindow(), |
1334 scr_Resize(); | 1334 scr_Resize(); |
1335 redrawwin(stdscr); | 1335 redrawwin(stdscr); |
1336 } | 1336 } |
1337 } | 1337 } |
1338 | 1338 |
1339 inline void scr_WriteMessage(const char *jid, const char *text, | 1339 inline void scr_WriteMessage(const char *bjid, const char *text, |
1340 time_t timestamp, guint prefix_flags) | 1340 time_t timestamp, guint prefix_flags) |
1341 { | 1341 { |
1342 char *xtext; | 1342 char *xtext; |
1343 | 1343 |
1344 if (!timestamp) timestamp = time(NULL); | 1344 if (!timestamp) timestamp = time(NULL); |
1345 | 1345 |
1346 xtext = ut_expand_tabs(text); // Expand tabs | 1346 xtext = ut_expand_tabs(text); // Expand tabs |
1347 | 1347 |
1348 // XXX Are there other special chars we should filter out? | 1348 // XXX Are there other special chars we should filter out? |
1349 | 1349 |
1350 scr_WriteInWindow(jid, xtext, timestamp, prefix_flags, FALSE); | 1350 scr_WriteInWindow(bjid, xtext, timestamp, prefix_flags, FALSE); |
1351 | 1351 |
1352 if (xtext != (char*)text) | 1352 if (xtext != (char*)text) |
1353 g_free(xtext); | 1353 g_free(xtext); |
1354 } | 1354 } |
1355 | 1355 |
1568 set_current_buddy(buddy_search(str)); | 1568 set_current_buddy(buddy_search(str)); |
1569 if (chatmode) | 1569 if (chatmode) |
1570 scr_ShowBuddyWindow(); | 1570 scr_ShowBuddyWindow(); |
1571 } | 1571 } |
1572 | 1572 |
1573 // scr_RosterJumpJid(jid) | 1573 // scr_RosterJumpJid(bjid) |
1574 // Jump to buddy jid. | 1574 // Jump to buddy bjid. |
1575 // NOTE: With this function, the buddy is added to the roster if doesn't exist. | 1575 // NOTE: With this function, the buddy is added to the roster if doesn't exist. |
1576 void scr_RosterJumpJid(char *barejid) | 1576 void scr_RosterJumpJid(char *barejid) |
1577 { | 1577 { |
1578 GSList *roster_elt; | 1578 GSList *roster_elt; |
1579 // Look for an existing buddy | 1579 // Look for an existing buddy |
1928 return multimode; | 1928 return multimode; |
1929 } | 1929 } |
1930 | 1930 |
1931 // scr_setmsgflag_if_needed(jid) | 1931 // scr_setmsgflag_if_needed(jid) |
1932 // Set the message flag unless we're already in the jid buffer window | 1932 // Set the message flag unless we're already in the jid buffer window |
1933 void scr_setmsgflag_if_needed(const char *jid, int special) | 1933 void scr_setmsgflag_if_needed(const char *bjid, int special) |
1934 { | 1934 { |
1935 const char *current_id; | 1935 const char *current_id; |
1936 bool iscurrentlocked = FALSE; | 1936 bool iscurrentlocked = FALSE; |
1937 | 1937 |
1938 if (!jid) | 1938 if (!bjid) |
1939 return; | 1939 return; |
1940 | 1940 |
1941 if (current_buddy) { | 1941 if (current_buddy) { |
1942 if (special) | 1942 if (special) |
1943 current_id = buddy_getname(BUDDATA(current_buddy)); | 1943 current_id = buddy_getname(BUDDATA(current_buddy)); |
1949 iscurrentlocked = win_entry->lock; | 1949 iscurrentlocked = win_entry->lock; |
1950 } | 1950 } |
1951 } else { | 1951 } else { |
1952 current_id = NULL; | 1952 current_id = NULL; |
1953 } | 1953 } |
1954 if (!chatmode || !current_id || strcmp(jid, current_id) || iscurrentlocked) | 1954 if (!chatmode || !current_id || strcmp(bjid, current_id) || iscurrentlocked) |
1955 roster_msg_setflag(jid, special, TRUE); | 1955 roster_msg_setflag(bjid, special, TRUE); |
1956 } | 1956 } |
1957 | 1957 |
1958 // scr_set_multimode() | 1958 // scr_set_multimode() |
1959 // Public function to (un)set multimode... | 1959 // Public function to (un)set multimode... |
1960 // Convention: | 1960 // Convention: |
2500 memset(kcode, 0, sizeof(keycode)); | 2500 memset(kcode, 0, sizeof(keycode)); |
2501 memset(ks, 0, sizeof(ks)); | 2501 memset(ks, 0, sizeof(ks)); |
2502 | 2502 |
2503 kcode->value = wgetch(inputWnd); | 2503 kcode->value = wgetch(inputWnd); |
2504 if (utf8_mode) { | 2504 if (utf8_mode) { |
2505 bool meta = (kcode->value == 27); | 2505 bool ismeta = (kcode->value == 27); |
2506 | 2506 |
2507 if (meta) | 2507 if (ismeta) |
2508 ks[0] = wgetch(inputWnd); | 2508 ks[0] = wgetch(inputWnd); |
2509 else | 2509 else |
2510 ks[0] = kcode->value; | 2510 ks[0] = kcode->value; |
2511 | 2511 |
2512 for (i = 0; i < MAX_KEYSEQ_LENGTH - 1; i++) { | 2512 for (i = 0; i < MAX_KEYSEQ_LENGTH - 1; i++) { |
2514 if (match == -1) | 2514 if (match == -1) |
2515 break; | 2515 break; |
2516 if (match > 0) { | 2516 if (match > 0) { |
2517 kcode->value = match; | 2517 kcode->value = match; |
2518 kcode->utf8 = 1; | 2518 kcode->utf8 = 1; |
2519 if (meta) | 2519 if (ismeta) |
2520 kcode->mcode = MKEY_META; | 2520 kcode->mcode = MKEY_META; |
2521 return; | 2521 return; |
2522 } | 2522 } |
2523 ks[i + 1] = wgetch(inputWnd); | 2523 ks[i + 1] = wgetch(inputWnd); |
2524 if (ks[i + 1] == ERR) | 2524 if (ks[i + 1] == ERR) |
2525 break; | 2525 break; |
2526 } | 2526 } |
2527 while (i > 0) | 2527 while (i > 0) |
2528 ungetch(ks[i--]); | 2528 ungetch(ks[i--]); |
2529 if (meta) | 2529 if (ismeta) |
2530 ungetch(ks[0]); | 2530 ungetch(ks[0]); |
2531 memset(ks, 0, sizeof(ks)); | 2531 memset(ks, 0, sizeof(ks)); |
2532 } | 2532 } |
2533 if (kcode->value != 27) | 2533 if (kcode->value != 27) |
2534 return; | 2534 return; |
2588 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); | 2588 g_snprintf(asciikey, 15, "MK%d", kcode.mcode); |
2589 | 2589 |
2590 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); | 2590 boundcmd = settings_get(SETTINGS_TYPE_BINDING, asciikey); |
2591 | 2591 |
2592 if (boundcmd) { | 2592 if (boundcmd) { |
2593 gchar *cmd, *boundcmd_locale; | 2593 gchar *cmdline, *boundcmd_locale; |
2594 boundcmd_locale = from_utf8(boundcmd); | 2594 boundcmd_locale = from_utf8(boundcmd); |
2595 cmd = g_strdup_printf(mkcmdstr("%s"), boundcmd_locale); | 2595 cmdline = g_strdup_printf(mkcmdstr("%s"), boundcmd_locale); |
2596 scr_CheckAutoAway(TRUE); | 2596 scr_CheckAutoAway(TRUE); |
2597 if (process_command(cmd)) | 2597 if (process_command(cmdline)) |
2598 return 255; // Quit | 2598 return 255; // Quit |
2599 g_free(boundcmd_locale); | 2599 g_free(boundcmd_locale); |
2600 g_free(cmd); | 2600 g_free(cmdline); |
2601 return 0; | 2601 return 0; |
2602 } | 2602 } |
2603 | 2603 |
2604 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); | 2604 scr_LogPrint(LPRINT_NORMAL, "Unknown key=%s", asciikey); |
2605 #ifndef UNICODE | 2605 #ifndef UNICODE |