diff mcabber/mcabber/commands.c @ 2128:adcff2d51ecb

Merge shizeeg's branch with main
author Mikael Berthe <mikael@lilotux.net>
date Tue, 24 Jun 2014 19:10:57 +0200
parents 5d6838f40736
children 32f1bbf5917e
line wrap: on
line diff
--- a/mcabber/mcabber/commands.c	Tue Jun 24 18:56:24 2014 +0200
+++ b/mcabber/mcabber/commands.c	Tue Jun 24 19:10:57 2014 +0200
@@ -2074,10 +2074,12 @@
   strncpy(buffer, "Room members:", 127);
   scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
 
+  int cnt = 0;
   resources = buddy_getresources(bud);
   for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) {
     enum imstatus rstatus;
     const char *rst_msg;
+    cnt++;
 
     rstatus = buddy_getstatus(bud, p_res->data);
     rst_msg = buddy_getstatusmsg(bud, p_res->data);
@@ -2124,6 +2126,10 @@
     }
     g_free(p_res->data);
   }
+
+  snprintf(buffer, 4095, "Total: %d", cnt);
+  scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
+
   g_slist_free(resources);
   g_free(buffer);
 }
@@ -2927,10 +2933,32 @@
   }
 
   // If arg is "-", let's clear the topic
-  if (!strcmp(arg, "-"))
+  if (!g_strcmp0(arg, "-"))
     arg = NULL;
 
   arg = to_utf8(arg);
+  // If arg is not NULL & option is set, unescape it
+  if (arg) {
+    char *unescaped_topic = NULL;
+
+    if (!strncmp(arg, "-u ", 3)) {
+      char *tmp;
+      tmp = g_strdup(arg + 3);
+      g_free(arg);
+      arg = tmp;
+      unescaped_topic = ut_unescape_tabs_cr(arg);
+    }
+
+    // We must not free() if the original string was returned
+    if (unescaped_topic == arg)
+      unescaped_topic = NULL;
+
+    if (unescaped_topic != NULL) {
+      g_free(arg);
+      arg = unescaped_topic;
+    }
+  }
+
   // Set the topic
   xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "",
                 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL);