[/trunk] Changeset 141 by mikael
* /group implementation (shrink/expand)
* Replace scr_DrawRoster() calls with "update_roster = TRUE" in commands.c
An inline function would maybe be better?
* TODO update
--- a/mcabber/src/TODO.txt Thu Apr 28 06:58:47 2005 +0000
+++ b/mcabber/src/TODO.txt Thu Apr 28 10:16:32 2005 +0000
@@ -5,7 +5,10 @@
* Pending message not displayed if buddy outside Contact window
* We should rebuild the buddy list when receiving a message from an offline
buddy (or invisible/just hidden).
-* When adding a user, we do not sent to him any presence notification...
+* Presence notification is always accepted.
+* Messages in hidden (shrunk) groups are not visible.
+ Maybe we should create "*_msg_[gs]etflag()" functions, which
+ would update groups message flags too. (?)
TODO:
--- a/mcabber/src/commands.c Thu Apr 28 06:58:47 2005 +0000
+++ b/mcabber/src/commands.c Thu Apr 28 10:16:32 2005 +0000
@@ -35,6 +35,7 @@
void do_clear(char *arg);
void do_status(char *arg);
void do_add(char *arg);
+void do_group(char *arg);
// Global variable for the commands list
static GSList *Commands;
@@ -63,7 +64,7 @@
cmd_add("add", "Add a jabber user", COMPL_JID, 0, &do_add);
cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear);
//cmd_add("del");
- cmd_add("group", "Change group display settings", COMPL_GROUP, 0, NULL);
+ cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group);
cmd_add("help", "Display some help", COMPL_CMD, 0, NULL);
//cmd_add("info");
//cmd_add("move");
@@ -71,7 +72,8 @@
cmd_add("quit", "Exit the software", 0, 0, NULL);
//cmd_add("rename");
//cmd_add("request_auth");
- cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0, &do_roster);
+ cmd_add("roster", "Manipulate the roster/buddylist", COMPL_ROSTER, 0,
+ &do_roster);
cmd_add("say", "Say something to the selected buddy", 0, 0, NULL);
//cmd_add("search");
//cmd_add("send_auth");
@@ -209,19 +211,19 @@
{
if (!strcasecmp(arg, "top")) {
scr_RosterTop();
- scr_DrawRoster();
+ update_roster = TRUE;
} else if (!strcasecmp(arg, "bottom")) {
scr_RosterBottom();
- scr_DrawRoster();
+ update_roster = TRUE;
} else if (!strcasecmp(arg, "hide_offline")) {
buddylist_set_hide_offline_buddies(TRUE);
if (current_buddy)
buddylist_build();
- scr_DrawRoster();
+ update_roster = TRUE;
} else if (!strcasecmp(arg, "show_offline")) {
buddylist_set_hide_offline_buddies(FALSE);
buddylist_build();
- scr_DrawRoster();
+ update_roster = TRUE;
} else
scr_LogPrint("Unrecognized parameter!");
}
@@ -269,3 +271,35 @@
// 2nd parameter = optional nickname (XXX NULL for now...)
jb_addbuddy(arg, NULL);
}
+
+void do_group(char *arg)
+{
+ gpointer group;
+
+ if (!arg || (*arg == 0)) {
+ scr_LogPrint("Missing parameter");
+ return;
+ }
+
+ if (!current_buddy)
+ return;
+
+ group = BUDDATA(current_buddy);
+ if (!(buddy_gettype(group) & ROSTER_TYPE_GROUP)) {
+ scr_LogPrint("For now you need to select a group "
+ "before using /group");
+ return;
+ }
+ if (!strcmp(arg, "expand")) {
+ buddy_setflags(group, ROSTER_FLAG_HIDE, FALSE);
+ } else if (!strcmp(arg, "shrink")) {
+ buddy_setflags(group, ROSTER_FLAG_HIDE, TRUE);
+ } else {
+ scr_LogPrint("Unrecognized parameter!");
+ return;
+ }
+
+ buddylist_build();
+ update_roster = TRUE;
+}
+
--- a/mcabber/src/roster.c Thu Apr 28 06:58:47 2005 +0000
+++ b/mcabber/src/roster.c Thu Apr 28 10:16:32 2005 +0000
@@ -298,6 +298,7 @@
roster *roster_elt;
roster *roster_current_buddy = NULL;
int pending_group;
+ int shrunk_group;
// We need to remember which buddy is selected.
if (current_buddy)
@@ -323,6 +324,8 @@
else
pending_group = TRUE;
+ shrunk_group = roster_elt->flags & ROSTER_FLAG_HIDE;
+
sl_roster_usrelt = roster_elt->list;
while (sl_roster_usrelt) {
roster_usrelt = (roster*) sl_roster_usrelt->data;
@@ -332,6 +335,7 @@
// - buddy is not offline
// - buddy has a lock (for example the buddy window is currently open)
// - buddy has a pending (non-read) message
+ // - group isn't hidden (shrunk)
if (!hide_offline_buddies ||
(buddy_getstatus((gpointer)roster_usrelt) != offline) ||
(buddy_getflags((gpointer)roster_usrelt) &
@@ -343,7 +347,11 @@
pending_group = FALSE;
}
// Add user
- buddylist = g_list_append(buddylist, roster_usrelt);
+ // XXX Should we add the user if there is a message and
+ // the group is shrunk? If so, we'd need to check LOCK flag too,
+ // perhaps...
+ if (!shrunk_group)
+ buddylist = g_list_append(buddylist, roster_usrelt);
}
sl_roster_usrelt = g_slist_next(sl_roster_usrelt);
@@ -357,6 +365,7 @@
// current_buddy initialization
if (!current_buddy || (g_list_position(buddylist, current_buddy) == -1))
current_buddy = g_list_first(buddylist);
+ // XXX Maybe we should set update_roster to TRUE there?
}
// buddy_hide_group(roster, hide)