Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/commands.c @ 2122:b41719d57dac
reimplement 'unescape_topic' option as '/room topic -u' switch
author | sh!zeeg <shizeeque@gmail.com> |
---|---|
date | Wed, 14 May 2014 10:47:56 +0400 |
parents | 9c791e2a437a |
children | 300e7bf4416a |
comparison
equal
deleted
inserted
replaced
2121:9c791e2a437a | 2122:b41719d57dac |
---|---|
2933 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); | 2933 scr_LogPrint(LPRINT_NORMAL, "No topic has been set."); |
2934 return; | 2934 return; |
2935 } | 2935 } |
2936 | 2936 |
2937 // If arg is "-", let's clear the topic | 2937 // If arg is "-", let's clear the topic |
2938 if (!strcmp(arg, "-")) | 2938 if (!g_strcmp0(arg, "-")) |
2939 arg = NULL; | 2939 arg = NULL; |
2940 | 2940 |
2941 arg = to_utf8(arg); | 2941 arg = to_utf8(arg); |
2942 // if arg is not NULL & option is set, unescape it | 2942 // if arg is not NULL & option is set, unescape it |
2943 if (arg && settings_opt_get_int("unescape_topic")) { | 2943 if (arg) { |
2944 gchar *tmp; | 2944 char *unescaped_topic = NULL; |
2945 tmp = g_strcompress(arg); | 2945 |
2946 g_free(arg); | 2946 if (!strncmp(arg, "-u ", 3)) { |
2947 arg = tmp; | 2947 char *tmp; |
2948 tmp = g_strdup(arg + 3); | |
2949 g_free(arg); | |
2950 arg = tmp; | |
2951 unescaped_topic = ut_unescape_tabs_cr(arg); | |
2952 } | |
2953 | |
2954 // We must not free() if the original string was returned | |
2955 if (unescaped_topic == arg) | |
2956 unescaped_topic = NULL; | |
2957 | |
2958 if (unescaped_topic != NULL) { | |
2959 free(arg); | |
2960 arg = unescaped_topic; | |
2961 } | |
2948 } | 2962 } |
2949 | 2963 |
2950 // Set the topic | 2964 // Set the topic |
2951 xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", | 2965 xmpp_send_msg(buddy_getjid(bud), NULL, ROSTER_TYPE_ROOM, arg ? arg : "", |
2952 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL); | 2966 FALSE, NULL, LM_MESSAGE_SUB_TYPE_NOT_SET, NULL); |