# HG changeset patch # User Mikael Berthe # Date 1128288999 -7200 # Node ID fa49ac0bb8f30e5b0068aaf9484ba12c43a84173 # Parent 27efa1e2671ac32ab423403c6d681244028529ae Add "/room topic", and display topic changes diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/doc/mcabber.1 --- a/mcabber/doc/mcabber.1 Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/doc/mcabber.1 Sun Oct 02 23:36:39 2005 +0200 @@ -200,7 +200,7 @@ .TP -\fB/room\fR join|leave|names|remove|unlock +\fB/room\fR join|leave|names|remove|topic|unlock The room command handles Multi\-User Chat room actions\&. \fBjoin\fR room nick join "room", using "nick" as nickname @@ -208,6 +208,7 @@ \fBnames\fR display members of the current room \fBnick\fR nick change your nickname in the current room \fBremove\fR remove the current room from the roster (you must have left this room before) + \fBtopic\fR set topic for current room \fBunlock\fR unlock current room (if you are the owner) .TP diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/doc/mcabber.1.html --- a/mcabber/doc/mcabber.1.html Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/doc/mcabber.1.html Sun Oct 02 23:36:39 2005 +0200 @@ -438,7 +438,7 @@ the buddies to another group with the "/move" command).
-/room join|leave|names|nick|remove|unlock +/room join|leave|names|nick|remove|topic|unlock
The room command handles Multi-User Chat room actions. @@ -485,6 +485,14 @@ +topic + + +set topic for current room + + + + unlock @@ -645,7 +653,7 @@ diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/doc/mcabber.1.txt --- a/mcabber/doc/mcabber.1.txt Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/doc/mcabber.1.txt Sun Oct 02 23:36:39 2005 +0200 @@ -176,7 +176,7 @@ This command does not work for groups, at the moment (but you can move the buddies to another group with the "/move" command). -/room join|leave|names|nick|remove|unlock:: +/room join|leave|names|nick|remove|topic|unlock:: The 'room' command handles Multi-User Chat room actions. 'join' room nick;; join "room", using "nick" as nickname @@ -184,6 +184,7 @@ 'names';; display members of the current room 'nick' nick;; change your nickname in the current room 'remove';; remove the current room from the roster (you must have left this room before) + 'topic';; set topic for current room 'unlock';; unlock current room (if you are the owner) /roster bottom|top|hide_offline|show_offline|toggle_offline:: diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/src/commands.c --- a/mcabber/src/commands.c Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/src/commands.c Sun Oct 02 23:36:39 2005 +0200 @@ -156,6 +156,7 @@ compl_add_category_word(COMPL_ROOM, "names"); compl_add_category_word(COMPL_ROOM, "nick"); compl_add_category_word(COMPL_ROOM, "remove"); + compl_add_category_word(COMPL_ROOM, "topic"); compl_add_category_word(COMPL_ROOM, "unlock"); } @@ -253,7 +254,7 @@ } // Network part - jb_send_msg(jid, msg, buddy_gettype(BUDDATA(current_buddy))); + jb_send_msg(jid, msg, buddy_gettype(BUDDATA(current_buddy)), NULL); } // process_command(line) @@ -1082,6 +1083,22 @@ return; } jb_room_unlock(buddy_getjid(bud)); + } else if (!strncasecmp(arg, "topic", 5)) { + gchar *msg; + arg += 5; + if (*arg++ != ' ') { + scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter"); + return; + } + for (; *arg && *arg == ' '; arg++) + ; + if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) { + scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom"); + return; + } + msg = g_strdup_printf("/me has set the topic to: %s", arg); + jb_send_msg(buddy_getjid(bud), msg, ROSTER_TYPE_ROOM, arg); + g_free(msg); } else { scr_LogPrint(LPRINT_NORMAL, "Unrecognized parameter!"); } diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/src/jabglue.c --- a/mcabber/src/jabglue.c Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/src/jabglue.c Sun Oct 02 23:36:39 2005 +0200 @@ -340,8 +340,10 @@ mystatus = st; } -void jb_send_msg(const char *jid, const char *text, int type) +void jb_send_msg(const char *jid, const char *text, int type, + const char *subject) { + xmlnode x; gchar *strtype; gchar *buffer = to_utf8(text); @@ -352,7 +354,14 @@ else strtype = TMSG_CHAT; - xmlnode x = jutil_msgnew(strtype, (char*)jid, 0, (char*)buffer); + x = jutil_msgnew(strtype, (char*)jid, 0, (char*)buffer); + if (subject) { + xmlnode y; + char *bs = to_utf8(subject); + y = xmlnode_insert_tag(x, "subject"); + xmlnode_insert_cdata(y, bs, (unsigned) -1); + if (bs) g_free(bs); + } jab_send(jc, x); xmlnode_free(x); g_free(buffer); @@ -838,9 +847,22 @@ p = xmlnode_get_tag_data(packet->x, "subject"); if (p != NULL) { - if (type && !strcmp(type, "groupchat")) { - // That's a room topic - } else { + if (type && !strcmp(type, TMSG_GROUPCHAT)) { // Room topic + gchar *mbuf; + gchar *subj_noutf8 = from_utf8(p); + // Get the room (s) and the nickname (r) + s = g_strdup(from); + r = strchr(s, '/'); + if (r) *r++ = 0; + else r = s; + // Display inside the room window + mbuf = g_strdup_printf("%s has set the topic to: %s", r, + (subj_noutf8 ? subj_noutf8 : "(?)")); + scr_WriteIncomingMessage(s, mbuf, 0, HBB_PREFIX_INFO); + if (subj_noutf8) g_free(subj_noutf8); + g_free(s); + g_free(mbuf); + } else { // Chat message tmp = g_new(char, (body ? strlen(body) : 0) + strlen(p) + 4); *tmp = '['; strcpy(tmp+1, p); diff -r 27efa1e2671a -r fa49ac0bb8f3 mcabber/src/jabglue.h --- a/mcabber/src/jabglue.h Sun Oct 02 23:29:01 2005 +0200 +++ b/mcabber/src/jabglue.h Sun Oct 02 23:36:39 2005 +0200 @@ -48,7 +48,8 @@ void jb_updatebuddy(const char *jid, const char *name, const char *group); inline enum imstatus jb_getstatus(); void jb_setstatus(enum imstatus st, const char *recipient, const char *msg); -void jb_send_msg(const char *jid, const char *text, int type); +void jb_send_msg(const char *jid, const char *text, int type, + const char *subject); void jb_send_raw(const char *str); void jb_keepalive(); inline void jb_reset_keepalive();