# HG changeset patch # User Mikael Berthe # Date 1141494954 -3600 # Node ID b5aa7b7afee82a26c08ee9e0c29fdd5dd829ed48 # Parent e1639629c87bbb129ff562bc789eeb6a6b098d40 Update status lines diff -r e1639629c87b -r b5aa7b7afee8 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Sat Mar 04 18:52:29 2006 +0100 +++ b/mcabber/src/jabglue.c Sat Mar 04 18:55:54 2006 +0100 @@ -382,6 +382,9 @@ else mystatusmsg = NULL; } + + // Update status line + scr_UpdateMainStatus(); } void jb_send_msg(const char *jid, const char *text, int type, diff -r e1639629c87b -r b5aa7b7afee8 mcabber/src/screen.c --- a/mcabber/src/screen.c Sat Mar 04 18:52:29 2006 +0100 +++ b/mcabber/src/screen.c Sat Mar 04 18:55:54 2006 +0100 @@ -525,6 +525,20 @@ } } +// scr_UpdateMainStatus() +// Redraw the main (bottom) status line. +void scr_UpdateMainStatus(void) +{ + const char *sm = jb_getstatusmsg(); + + werase(mainstatusWnd); + mvwprintw(mainstatusWnd, 0, 1, + "[%c] %s", imstatus2char[jb_getstatus()], (sm ? sm : "")); + top_panel(inputPanel); + update_panels(); + doupdate(); +} + // scr_DrawMainWindow() // Set fullinit to TRUE to also create panels. Set it to FALSE for a resize. // @@ -641,6 +655,7 @@ replace_panel(inputPanel, inputWnd); } + scr_UpdateMainStatus(); // We'll need to redraw the roster update_roster = TRUE; return; @@ -701,6 +716,57 @@ scr_ShowBuddyWindow(); } +// update_chat_status_window() +// Redraw the buddy status bar. +static void update_chat_status_window(void) +{ + unsigned short btype, isgrp, ismuc; + const char *fullname; + const char *msg = NULL; + char status; + char *buf; + + btype = buddy_gettype(BUDDATA(current_buddy)); + + isgrp = btype & ROSTER_TYPE_GROUP; + ismuc = btype & ROSTER_TYPE_ROOM; + + // Clear the line + werase(chatstatusWnd); + + if (isgrp) return; + + status = '?'; + + if (ismuc) { + if (buddy_getinsideroom(BUDDATA(current_buddy))) + status = 'C'; + else + status = 'x'; + } else if (jb_getstatus() != offline) { + enum imstatus budstate; + budstate = buddy_getstatus(BUDDATA(current_buddy), NULL); + if (budstate >= 0 && budstate < imstatus_size) + status = imstatus2char[budstate]; + } + + fullname = buddy_getname(BUDDATA(current_buddy)); + + // No status message for groups & MUC rooms + if (!isgrp && !ismuc) { + GSList *resources = buddy_getresources(BUDDATA(current_buddy)); + if (resources) + msg = buddy_getstatusmsg(BUDDATA(current_buddy), resources->data); + } + if (!msg) + msg = ""; + + buf = g_strdup_printf("[%c] Buddy: %s -- %s", status, fullname, msg); + replace_nl_with_dots(buf); + mvwprintw(chatstatusWnd, 0, 1, "%s", buf); + g_free(buf); +} + // scr_DrawRoster() // Display the buddylist (not really the roster) on the screen void scr_DrawRoster(void) @@ -711,6 +777,8 @@ GList *buddy; int i, n; int rOffset; + int cursor_backup; + char status, pending; enum imstatus currentstatus = jb_getstatus(); // We can reset update_roster @@ -719,6 +787,8 @@ getmaxyx(rosterWnd, maxy, maxx); maxx--; // Last char is for vertical border + cursor_backup = curs_set(0); + // Cleanup of roster window werase(rosterWnd); @@ -731,11 +801,14 @@ if (!buddylist) offset = 0; + else + update_chat_status_window(); // Leave now if buddylist is empty or the roster is hidden if (!buddylist || !Roster_Width) { update_panels(); doupdate(); + curs_set(cursor_backup); return; } @@ -753,6 +826,7 @@ if (i == -1) { // This is bad scr_LogPrint(LPRINT_NORMAL, "Doh! Can't find current selected buddy!!"); g_free(name); + curs_set(cursor_backup); return; } else if (i < offset) { offset = i; @@ -766,28 +840,41 @@ rOffset = offset; for (i=0; i 0) { rOffset--; continue; } + status = '?'; + pending = ' '; + // Display message notice if there is a message flag, but not // for unfolded groups. if (ismsg && (!isgrp || ishid)) { pending = '#'; } - budstate = buddy_getstatus(BUDDATA(buddy), NULL); - if (budstate >= 0 && budstate < imstatus_size && currentstatus != offline) - status = imstatus2char[budstate]; + if (ismuc) { + if (buddy_getinsideroom(BUDDATA(buddy))) + status = 'C'; + else + status = 'x'; + } else if (currentstatus != offline) { + enum imstatus budstate; + budstate = buddy_getstatus(BUDDATA(buddy), NULL); + if (budstate >= 0 && budstate < imstatus_size) + status = imstatus2char[budstate]; + } if (buddy == current_buddy) { wattrset(rosterWnd, COLOR_PAIR(COLOR_ROSTERSEL)); // The 3 following lines aim to color the whole line @@ -801,13 +888,6 @@ wattrset(rosterWnd, COLOR_PAIR(COLOR_ROSTER)); } - if (ismuc) { - if (buddy_getinsideroom(BUDDATA(buddy))) - status = 'C'; - else - status = 'x'; - } - if (Roster_Width > 7) strncpy(name, buddy_getname(BUDDATA(buddy)), Roster_Width-7); else @@ -833,6 +913,7 @@ top_panel(inputPanel); update_panels(); doupdate(); + curs_set(cursor_backup); } // scr_RosterVisibility(status) diff -r e1639629c87b -r b5aa7b7afee8 mcabber/src/screen.h --- a/mcabber/src/screen.h Sat Mar 04 18:52:29 2006 +0100 +++ b/mcabber/src/screen.h Sat Mar 04 18:55:54 2006 +0100 @@ -28,6 +28,7 @@ void scr_TerminateCurses(void); void scr_DrawMainWindow(unsigned int fullinit); void scr_DrawRoster(void); +void scr_UpdateMainStatus(void); void scr_RosterVisibility(int status); void scr_WriteIncomingMessage(const char *jidfrom, const char *text, time_t timestamp, guint prefix);