Mercurial > hg
comparison mcabber/src/commands.c @ 974:36f7753dfb59
Add /roster item_{lock,unlock}
These commands allow us to lock a contact so it stays visible in the roster
when hide_offline_buddies is set.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 30 Sep 2006 22:42:32 +0200 |
parents | d3bfa9e9d88c |
children | 5b01de4ac5e1 |
comparison
equal
deleted
inserted
replaced
973:e693cbe33802 | 974:36f7753dfb59 |
---|---|
149 compl_add_category_word(COMPL_ROSTER, "show"); | 149 compl_add_category_word(COMPL_ROSTER, "show"); |
150 compl_add_category_word(COMPL_ROSTER, "toggle"); | 150 compl_add_category_word(COMPL_ROSTER, "toggle"); |
151 compl_add_category_word(COMPL_ROSTER, "hide_offline"); | 151 compl_add_category_word(COMPL_ROSTER, "hide_offline"); |
152 compl_add_category_word(COMPL_ROSTER, "show_offline"); | 152 compl_add_category_word(COMPL_ROSTER, "show_offline"); |
153 compl_add_category_word(COMPL_ROSTER, "toggle_offline"); | 153 compl_add_category_word(COMPL_ROSTER, "toggle_offline"); |
154 compl_add_category_word(COMPL_ROSTER, "item_lock"); | |
155 compl_add_category_word(COMPL_ROSTER, "item_unlock"); | |
154 compl_add_category_word(COMPL_ROSTER, "alternate"); | 156 compl_add_category_word(COMPL_ROSTER, "alternate"); |
155 compl_add_category_word(COMPL_ROSTER, "search"); | 157 compl_add_category_word(COMPL_ROSTER, "search"); |
156 compl_add_category_word(COMPL_ROSTER, "unread_first"); | 158 compl_add_category_word(COMPL_ROSTER, "unread_first"); |
157 compl_add_category_word(COMPL_ROSTER, "unread_next"); | 159 compl_add_category_word(COMPL_ROSTER, "unread_next"); |
158 | 160 |
417 return 0; | 419 return 0; |
418 } | 420 } |
419 | 421 |
420 /* It is (probably) a command -- except for verbatim multi-line mode */ | 422 /* It is (probably) a command -- except for verbatim multi-line mode */ |
421 return process_command(line); | 423 return process_command(line); |
424 } | |
425 | |
426 // Helper routine for buffer item_{lock,unlock} | |
427 static void roster_buddylock(char *jid, bool lock) | |
428 { | |
429 gpointer bud = NULL; | |
430 bool may_need_refresh = FALSE; | |
431 | |
432 // Allow special jid "" or "." (current buddy) | |
433 if (jid && (!*jid || !strcmp(jid, "."))) | |
434 jid = NULL; | |
435 | |
436 if (jid) { | |
437 // The JID has been specified. Quick check... | |
438 if (check_jid_syntax(jid)) { | |
439 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber ID.", jid); | |
440 } else { | |
441 // Find the buddy | |
442 GSList *roster_elt; | |
443 roster_elt = roster_find(jid, jidsearch, | |
444 ROSTER_TYPE_USER|ROSTER_TYPE_ROOM); | |
445 if (roster_elt) | |
446 bud = roster_elt->data; | |
447 else | |
448 scr_LogPrint(LPRINT_NORMAL, "This jid isn't in the roster."); | |
449 may_need_refresh = TRUE; | |
450 } | |
451 } else { | |
452 // Use the current buddy | |
453 if (current_buddy) | |
454 bud = BUDDATA(current_buddy); | |
455 } | |
456 | |
457 // Update the ROSTER_FLAG_USRLOCK flag | |
458 if (bud) { | |
459 buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); | |
460 if (may_need_refresh) | |
461 buddylist_build(); | |
462 update_roster = TRUE; | |
463 } | |
422 } | 464 } |
423 | 465 |
424 /* Commands callback functions */ | 466 /* Commands callback functions */ |
425 /* All these do_*() functions will be called with a "arg" parameter */ | 467 /* All these do_*() functions will be called with a "arg" parameter */ |
426 /* (with arg not null) */ | 468 /* (with arg not null) */ |
463 update_roster = TRUE; | 505 update_roster = TRUE; |
464 } else if (!strcasecmp(subcmd, "toggle_offline")) { | 506 } else if (!strcasecmp(subcmd, "toggle_offline")) { |
465 buddylist_set_hide_offline_buddies(-1); | 507 buddylist_set_hide_offline_buddies(-1); |
466 buddylist_build(); | 508 buddylist_build(); |
467 update_roster = TRUE; | 509 update_roster = TRUE; |
510 } else if (!strcasecmp(subcmd, "item_lock")) { | |
511 roster_buddylock(arg, TRUE); | |
512 } else if (!strcasecmp(subcmd, "item_unlock")) { | |
513 roster_buddylock(arg, FALSE); | |
468 } else if (!strcasecmp(subcmd, "unread_first")) { | 514 } else if (!strcasecmp(subcmd, "unread_first")) { |
469 scr_RosterUnreadMessage(0); | 515 scr_RosterUnreadMessage(0); |
470 } else if (!strcasecmp(subcmd, "unread_next")) { | 516 } else if (!strcasecmp(subcmd, "unread_next")) { |
471 scr_RosterUnreadMessage(1); | 517 scr_RosterUnreadMessage(1); |
472 } else if (!strcasecmp(subcmd, "alternate")) { | 518 } else if (!strcasecmp(subcmd, "alternate")) { |