# HG changeset patch
# User mikael
# Date 1118430186 0
# Node ID 72fd1273f2b7ba35c61ac51fad2782d90cd9d236
# Parent f7f07794d2df7a3c3af88e3e5d02c26c07d6cb91
[/trunk] Changeset 249 by mikael
* Update TODO
* Add /roster parameters "unread_first" and "unread_next"
* Add Ctrl-q as a shortcut for "/roster unread_next"
* Update Documentation (ctrl-q + unread_*)
* Update ChangeLog
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/ChangeLog
--- a/mcabber/ChangeLog Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/ChangeLog Fri Jun 10 19:03:06 2005 +0000
@@ -1,5 +1,13 @@
mcabber (0.6.1)
+ * Fix backspace handling (KEY_BACKSPACE isn't reliable)
+ * Implement Ctrl-q (jump to first/next unread message)
+ * Display a warning when the locale is UTF-8
+ * Display log notice when sending a notification request message
+ * Update INSTALL and mcabberrc.example files for better explanations
+ * Comment out useless code (fix a compilation error with gcc 4)
+ * Add Makefile for the doc subdir; manpage will be installed now
+
-- Mikael, ?
mcabber (0.6.0)
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/doc/mcabber.1
--- a/mcabber/doc/mcabber.1 Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/doc/mcabber.1 Fri Jun 10 19:03:06 2005 +0000
@@ -98,7 +98,7 @@
Ctrl\-t Transpose chars
-Ctrl\-q Jump to the next unread message (Not yet implemented)
+Ctrl\-q Jump to the next unread message
.SH "COMMANDS"
@@ -155,6 +155,8 @@
\fBshow_offline\fR show offline buddies
\fBtop\fR jump to the top of the roster
\fBbottom\fR jump to the bottom of the roster
+ \fIunread_first\fR jump to the first unread message
+ \fIunread_next\fR jump to the next unread message
.TP
\fB/say\fR text
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/doc/mcabber.1.html
--- a/mcabber/doc/mcabber.1.html Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/doc/mcabber.1.html Fri Jun 10 19:03:06 2005 +0000
@@ -220,7 +220,7 @@
-Jump to the next unread message (Not yet implemented)
+Jump to the next unread message
|
@@ -418,6 +418,26 @@
+
+
+unread_first
+ |
+
+
+jump to the first unread message
+
+ |
+
+
+
+unread_next
+ |
+
+
+jump to the next unread message
+
+ |
+
@@ -477,8 +497,8 @@
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/doc/mcabber.1.txt
--- a/mcabber/doc/mcabber.1.txt Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/doc/mcabber.1.txt Fri Jun 10 19:03:06 2005 +0000
@@ -1,7 +1,7 @@
MCABBER(1)
===========
Mikael BERTHE
-v0.6.0, June 2005
+v0.6.1, June 2005
NAME
----
@@ -71,7 +71,7 @@
Ctrl-k:: Delete from the cursor to the end of line
Ctrl-w:: Backward kill word
Ctrl-t:: Transpose chars
-Ctrl-q:: Jump to the next unread message (Not yet implemented)
+Ctrl-q:: Jump to the next unread message
COMMANDS
--------
@@ -125,6 +125,8 @@
'show_offline';; show offline buddies
'top';; jump to the top of the roster
'bottom';; jump to the bottom of the roster
+ 'unread_first';; jump to the first unread message
+ 'unread_next';; jump to the next unread message
/say text::
Send the text message to the currently selected buddy. Can be useful
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/TODO
--- a/mcabber/src/TODO Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/TODO Fri Jun 10 19:03:06 2005 +0000
@@ -9,7 +9,6 @@
TODO:
* Presence notification is always accepted. We should ask...
-* Unread message queue (/roster next_message & Ctrl-q)
* Multi-lines messages
* Resource priority
* UTF-8 support
@@ -23,18 +22,18 @@
(i.e. hide roster window)
* Create .mcabber and .mcabber/histo dirs if needed.
* Search for a user
-* Get info about a user
+* Get info from server about a user
* Publish personal information
* Handle message type "error"
* Show status changes in buddy window (if open)?
* Auto away
+* Ctrl-o
* File transfer? :)
* Conferences
* Commands! :-)
- - /roster
- + next_message (Ctrl-q?)
+ - /roster
+ search jid|name
- /buffer
+ /buffer % 50 (jump to 50 %)
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/commands.c
--- a/mcabber/src/commands.c Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/commands.c Fri Jun 10 19:03:06 2005 +0000
@@ -104,6 +104,8 @@
compl_add_category_word(COMPL_ROSTER, "hide_offline");
compl_add_category_word(COMPL_ROSTER, "show_offline");
compl_add_category_word(COMPL_ROSTER, "top");
+ compl_add_category_word(COMPL_ROSTER, "unread_first");
+ compl_add_category_word(COMPL_ROSTER, "unread_next");
// Roster category
compl_add_category_word(COMPL_BUFFER, "bottom");
@@ -246,6 +248,10 @@
buddylist_set_hide_offline_buddies(FALSE);
buddylist_build();
update_roster = TRUE;
+ } else if (!strcasecmp(arg, "unread_first")) {
+ scr_RosterUnreadMessage(0);
+ } else if (!strcasecmp(arg, "unread_next")) {
+ scr_RosterUnreadMessage(1);
} else
scr_LogPrint("Unrecognized parameter!");
}
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/roster.c
--- a/mcabber/src/roster.c Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/roster.c Fri Jun 10 19:03:06 2005 +0000
@@ -42,14 +42,10 @@
static int hide_offline_buddies;
static GSList *groups;
+static GSList *unread_list;
GList *buddylist;
GList *current_buddy;
-#ifdef MCABBER_TESTUNIT
-// Export groups for testing routines
-GSList **pgroups = &groups;
-#endif
-
/* ### Roster functions ### */
@@ -182,6 +178,9 @@
if (roster_usr->status_msg) g_free((gchar*)roster_usr->status_msg);
g_free(roster_usr);
+ // Remove (if present) from unread messages list
+ unread_list = g_slist_delete_link(unread_list, sl_user);
+
// That's a little complex, we need to dereference twice
sl_group = ((roster*)sl_user->data)->list;
sl_group_listptr = &((roster*)(sl_group->data))->list;
@@ -275,6 +274,7 @@
// roster_msg_setflag()
// Set the ROSTER_FLAG_MSG to the given value for the given jid.
// It will update the buddy's group message flag.
+// Update the unread messages list too.
void roster_msg_setflag(const char *jid, guint value)
{
GSList *sl_user;
@@ -291,10 +291,17 @@
// to TRUE...
roster_usr->flags |= ROSTER_FLAG_MSG;
roster_grp->flags |= ROSTER_FLAG_MSG; // group
+ // Append the roster_usr to unread_list, but avoid duplicates
+ if (!g_slist_find(unread_list, roster_usr))
+ unread_list = g_slist_append(unread_list, roster_usr);
} else {
// Message flag is FALSE.
guint msg = FALSE;
roster_usr->flags &= ~ROSTER_FLAG_MSG;
+ if (unread_list) {
+ GSList *node = g_slist_find(unread_list, roster_usr);
+ if (node) unread_list = g_slist_delete_link(unread_list, node);
+ }
// For the group value we need to watch all buddies in this group;
// if one is flagged, then the group will be flagged.
// I will re-use sl_user and roster_usr here, as they aren't used
@@ -645,3 +652,23 @@
return list;
}
+// unread_msg(rosterdata)
+// Return the next buddy with an unread message. If the parameter is NULL,
+// return the first buddy with an unread message.
+gpointer unread_msg(gpointer rosterdata)
+{
+ GSList *unread, *next_unread;
+
+ if (!unread_list) return NULL;
+ // First unread message
+ if (!rosterdata) return unread_list->data;
+
+ unread = g_slist_find(unread_list, rosterdata);
+ if (!unread) return unread_list->data;
+
+ next_unread = g_slist_next(unread);
+ if (next_unread) return next_unread->data;
+
+ return unread_list->data;
+}
+
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/roster.h
--- a/mcabber/src/roster.h Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/roster.h Fri Jun 10 19:03:06 2005 +0000
@@ -60,6 +60,7 @@
const char *buddy_getstatusmsg(gpointer rosterdata);
void buddy_setflags(gpointer rosterdata, guint flags, guint value);
guint buddy_getflags(gpointer rosterdata);
+gpointer unread_msg(gpointer rosterdata);
GSList *compl_list(guint type);
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/screen.c
--- a/mcabber/src/screen.c Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/screen.c Fri Jun 10 19:03:06 2005 +0000
@@ -841,6 +841,52 @@
scr_ShowBuddyWindow();
}
+// scr_RosterUnreadMessage(next)
+// Go to a new message. If next is not null, try to go to the next new
+// message. If it is not possible or if next is NULL, go to the first new
+// message from unread_list.
+void scr_RosterUnreadMessage(int next)
+{
+ enum imstatus prev_st = imstatus_size; // undef
+
+ if (current_buddy) {
+ gpointer unread_ptr;
+ gpointer refbuddata;
+ gpointer ngroup;
+ GList *nbuddy;
+
+ if (next) refbuddata = BUDDATA(current_buddy);
+ else refbuddata = NULL;
+
+ unread_ptr = unread_msg(refbuddata);
+ if (!unread_ptr) return;
+
+ // If buddy is in a folded group, we need to expand it
+ ngroup = buddy_getgroup(unread_ptr);
+ if (buddy_getflags(ngroup) & ROSTER_FLAG_HIDE) {
+ buddy_setflags(ngroup, ROSTER_FLAG_HIDE, FALSE);
+ buddylist_build();
+ }
+
+ nbuddy = g_list_find(buddylist, unread_ptr);
+ if (nbuddy) {
+ prev_st = buddy_getstatus(BUDDATA(current_buddy));
+ buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, FALSE);
+ current_buddy = nbuddy;
+ if (chatmode)
+ buddy_setflags(BUDDATA(current_buddy), ROSTER_FLAG_LOCK, TRUE);
+ // We should rebuild the buddylist but not everytime
+ // Here we check if we were locking a buddy who is actually offline,
+ // and hide_offline_buddies is TRUE. In which case we need to rebuild.
+ if (prev_st == offline && buddylist_get_hide_offline_buddies())
+ buddylist_build();
+ update_roster = TRUE;
+
+ if (chatmode) scr_ShowBuddyWindow();
+ } else scr_LogPrint("Error: nbuddy == NULL");
+ }
+}
+
// scr_ScrollUp()
// Scroll up the current buddy window, half a screen.
void scr_ScrollUp(void)
@@ -1410,7 +1456,7 @@
scr_ScrollDown();
break;
case 17: // Ctrl-q
- // scr_jump_next_new_message();
+ scr_RosterUnreadMessage(1); // next unread message
break;
case 20: // Ctrl-t
readline_transpose_chars();
diff -r f7f07794d2df -r 72fd1273f2b7 mcabber/src/screen.h
--- a/mcabber/src/screen.h Fri Jun 10 18:42:38 2005 +0000
+++ b/mcabber/src/screen.h Fri Jun 10 19:03:06 2005 +0000
@@ -43,5 +43,6 @@
void scr_BufferTop(void);
void scr_BufferBottom(void);
void scr_Clear(void);
+void scr_RosterUnreadMessage(int);
#endif