comparison 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
comparison
equal deleted inserted replaced
2119:3b26f3a58cb9 2128:adcff2d51ecb
2072 2072
2073 buffer = g_new(char, 4096); 2073 buffer = g_new(char, 4096);
2074 strncpy(buffer, "Room members:", 127); 2074 strncpy(buffer, "Room members:", 127);
2075 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0); 2075 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
2076 2076
2077 int cnt = 0;
2077 resources = buddy_getresources(bud); 2078 resources = buddy_getresources(bud);
2078 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) { 2079 for (p_res = resources ; p_res ; p_res = g_slist_next(p_res)) {
2079 enum imstatus rstatus; 2080 enum imstatus rstatus;
2080 const char *rst_msg; 2081 const char *rst_msg;
2082 cnt++;
2081 2083
2082 rstatus = buddy_getstatus(bud, p_res->data); 2084 rstatus = buddy_getstatus(bud, p_res->data);
2083 rst_msg = buddy_getstatusmsg(bud, p_res->data); 2085 rst_msg = buddy_getstatusmsg(bud, p_res->data);
2084 2086
2085 if (style == style_short) { 2087 if (style == style_short) {
2122 } 2124 }
2123 } 2125 }
2124 } 2126 }
2125 g_free(p_res->data); 2127 g_free(p_res->data);
2126 } 2128 }
2129
2130 snprintf(buffer, 4095, "Total: %d", cnt);
2131 scr_WriteIncomingMessage(bjid, buffer, 0, HBB_PREFIX_INFO, 0);
2132
2127 g_slist_free(resources); 2133 g_slist_free(resources);
2128 g_free(buffer); 2134 g_free(buffer);
2129 } 2135 }
2130 2136
2131 static void move_group_member(gpointer bud, void *groupnamedata) 2137 static void move_group_member(gpointer bud, void *groupnamedata)
2925 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); 2931 scr_LogPrint(LPRINT_NORMAL, "No topic has been set.");
2926 return; 2932 return;
2927 } 2933 }
2928 2934
2929 // If arg is "-", let's clear the topic 2935 // If arg is "-", let's clear the topic
2930 if (!strcmp(arg, "-")) 2936 if (!g_strcmp0(arg, "-"))
2931 arg = NULL; 2937 arg = NULL;
2932 2938
2933 arg = to_utf8(arg); 2939 arg = to_utf8(arg);
2940 // If arg is not NULL & option is set, unescape it
2941 if (arg) {
2942 char *unescaped_topic = NULL;
2943
2944 if (!strncmp(arg, "-u ", 3)) {
2945 char *tmp;
2946 tmp = g_strdup(arg + 3);
2947 g_free(arg);
2948 arg = tmp;
2949 unescaped_topic = ut_unescape_tabs_cr(arg);
2950 }
2951
2952 // We must not free() if the original string was returned
2953 if (unescaped_topic == arg)
2954 unescaped_topic = NULL;
2955
2956 if (unescaped_topic != NULL) {
2957 g_free(arg);
2958 arg = unescaped_topic;
2959 }
2960 }
2961
2934 // Set the topic 2962 // Set the topic
2935 xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", 2963 xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "",
2936 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL); 2964 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL);
2937 g_free(arg); 2965 g_free(arg);
2938 } 2966 }