comparison mcabber/src/commands.c @ 1016:4d3c48844746

Add /roster note Implement XEP-0145 (Annotations) Usage: /roster note [-|note_text]
author Mikael Berthe <mikael@lilotux.net>
date Wed, 15 Nov 2006 00:04:57 +0100
parents 579299b1c9b2
children 9d5f6e0ea7b3
comparison
equal deleted inserted replaced
1015:579299b1c9b2 1016:4d3c48844746
155 compl_add_category_word(COMPL_ROSTER, "item_unlock"); 155 compl_add_category_word(COMPL_ROSTER, "item_unlock");
156 compl_add_category_word(COMPL_ROSTER, "alternate"); 156 compl_add_category_word(COMPL_ROSTER, "alternate");
157 compl_add_category_word(COMPL_ROSTER, "search"); 157 compl_add_category_word(COMPL_ROSTER, "search");
158 compl_add_category_word(COMPL_ROSTER, "unread_first"); 158 compl_add_category_word(COMPL_ROSTER, "unread_first");
159 compl_add_category_word(COMPL_ROSTER, "unread_next"); 159 compl_add_category_word(COMPL_ROSTER, "unread_next");
160 compl_add_category_word(COMPL_ROSTER, "note");
160 161
161 // Roster category 162 // Roster category
162 compl_add_category_word(COMPL_BUFFER, "clear"); 163 compl_add_category_word(COMPL_BUFFER, "clear");
163 compl_add_category_word(COMPL_BUFFER, "bottom"); 164 compl_add_category_word(COMPL_BUFFER, "bottom");
164 compl_add_category_word(COMPL_BUFFER, "top"); 165 compl_add_category_word(COMPL_BUFFER, "top");
462 buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock); 463 buddy_setflags(bud, ROSTER_FLAG_USRLOCK, lock);
463 if (may_need_refresh) 464 if (may_need_refresh)
464 buddylist_build(); 465 buddylist_build();
465 update_roster = TRUE; 466 update_roster = TRUE;
466 } 467 }
468 }
469
470 static void roster_note(char *arg)
471 {
472 const char *jid;
473 gchar *msg, *note;
474 guint type;
475
476 if (!current_buddy)
477 return;
478
479 jid = buddy_getjid(BUDDATA(current_buddy));
480 type = buddy_gettype(BUDDATA(current_buddy));
481
482 if (!jid || (type != ROSTER_TYPE_USER &&
483 type != ROSTER_TYPE_ROOM &&
484 type != ROSTER_TYPE_AGENT)) {
485 scr_LogPrint(LPRINT_NORMAL, "This item can't have a note.");
486 return;
487 }
488
489 if (arg && *arg)
490 msg = to_utf8(arg);
491 else
492 msg = NULL;
493
494 if (msg) { // Set a note
495 if (!strcmp(msg, "-"))
496 note = NULL; // delete note
497 else
498 note = msg;
499 jb_set_storage_rosternotes(jid, note);
500 } else { // Display a note
501 note = jb_get_storage_rosternotes(jid);
502 if (note)
503 msg = g_strdup_printf("Note: %s", note);
504 else
505 msg = g_strdup_printf("This item doesn't have a note.");
506 scr_WriteIncomingMessage(jid, msg, 0, HBB_PREFIX_INFO);
507 }
508 g_free(msg);
467 } 509 }
468 510
469 /* Commands callback functions */ 511 /* Commands callback functions */
470 /* All these do_*() functions will be called with a "arg" parameter */ 512 /* All these do_*() functions will be called with a "arg" parameter */
471 /* (with arg not null) */ 513 /* (with arg not null) */
531 update_roster = TRUE; 573 update_roster = TRUE;
532 } else if (!strcasecmp(subcmd, "up")) { 574 } else if (!strcasecmp(subcmd, "up")) {
533 scr_RosterUp(); 575 scr_RosterUp();
534 } else if (!strcasecmp(subcmd, "down")) { 576 } else if (!strcasecmp(subcmd, "down")) {
535 scr_RosterDown(); 577 scr_RosterDown();
578 } else if (!strcasecmp(subcmd, "note")) {
579 roster_note(arg);
536 } else 580 } else
537 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); 581 scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!");
538 free_arg_lst(paramlst); 582 free_arg_lst(paramlst);
539 } 583 }
540 584
1214 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name); 1258 if (name) scr_LogPrint(LPRINT_NORMAL, "Name: %s", name);
1215 scr_LogPrint(LPRINT_NORMAL, "Type: %s", 1259 scr_LogPrint(LPRINT_NORMAL, "Type: %s",
1216 type == ROSTER_TYPE_GROUP ? "group" : 1260 type == ROSTER_TYPE_GROUP ? "group" :
1217 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown")); 1261 (type == ROSTER_TYPE_SPECIAL ? "special" : "unknown"));
1218 } 1262 }
1219
1220 g_free(buffer); 1263 g_free(buffer);
1221 } 1264 }
1222 1265
1223 // room_names() is a variation of do_info(), for chatrooms only 1266 // room_names() is a variation of do_info(), for chatrooms only
1224 static void room_names(gpointer bud, char *arg) 1267 static void room_names(gpointer bud, char *arg)