MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "module.h"
#include "channels.h"
#include "nicklist.h"
#include "ignore.h"
-#include "recode.h"
#include "window-items.h"
#include "fe-queries.h"
static char *channel_get_nickmode_rec(NICK_REC *nickrec)
{
char *emptystr;
- static char nickmode[2]; /* FIXME: bad */
+ char *nickmode;
if (!settings_get_bool("show_nickmode"))
- return "";
+ return g_strdup("");
emptystr = settings_get_bool("show_nickmode_empty") ? " " : "";
- if (nickrec != NULL && nickrec->other) {
- nickmode[0] = nickrec->other;
+ if (nickrec == NULL || nickrec->prefixes[0] == '\0')
+ nickmode = g_strdup(emptystr);
+ else {
+ nickmode = g_malloc(2);
+ nickmode[0] = nickrec->prefixes[0];
nickmode[1] = '\0';
- return nickmode;
}
-
- return nickrec == NULL ? emptystr :
- nickrec->op ? "@" :
- nickrec->halfop ? "%" :
- nickrec->voice ? "+" :
- emptystr;
+ return nickmode;
}
char *channel_get_nickmode(CHANNEL_REC *channel, const char *nick)
const char *target, NICK_REC *nickrec)
{
CHANNEL_REC *chanrec;
- const char *nickmode, *printnick;
+ const char *printnick;
int for_me, print_channel, level;
- char *color, *freemsg = NULL;
+ char *nickmode, *color, *freemsg = NULL;
HILIGHT_REC *hilight;
/* NOTE: this may return NULL if some channel is just closed with
printnick, target, msg, nickmode);
}
+ g_free_not_null(nickmode);
g_free_not_null(freemsg);
g_free_not_null(color);
}
{
WINDOW_REC *window;
CHANNEL_REC *channel;
- const char *nickmode;
- char *freemsg = NULL, *recoded;
+ char *nickmode;
+ char *freemsg = NULL;
int print_channel;
channel = channel_find(server, target);
if (channel != NULL)
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) channel, msg);
- /* ugly: recode the sent message back for printing */
- recoded = recode_in(server, msg, target);
-
if (!print_channel) {
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
- TXT_OWN_MSG, server->nick, recoded, nickmode);
+ TXT_OWN_MSG, server->nick, msg, nickmode);
} else {
printformat(server, target, MSGLEVEL_PUBLIC | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
- TXT_OWN_MSG_CHANNEL, server->nick, target, recoded, nickmode);
+ TXT_OWN_MSG_CHANNEL, server->nick, target, msg, nickmode);
}
- g_free(recoded);
+ g_free_not_null(nickmode);
g_free_not_null(freemsg);
}
const char *target, const char *origtarget)
{
QUERY_REC *query;
- char *freemsg = NULL, *recoded;
+ char *freemsg = NULL;
g_return_if_fail(server != NULL);
g_return_if_fail(msg != NULL);
if (settings_get_bool("emphasis"))
msg = freemsg = expand_emphasis((WI_ITEM_REC *) query, msg);
- /* ugly: recode the sent message back for printing */
- recoded = recode_in(server, msg, target);
-
printformat(server, target,
MSGLEVEL_MSGS | MSGLEVEL_NOHILIGHT | MSGLEVEL_NO_ACT,
query == NULL ? TXT_OWN_MSG_PRIVATE :
- TXT_OWN_MSG_PRIVATE_QUERY, target, recoded, server->nick);
+ TXT_OWN_MSG_PRIVATE_QUERY, target, msg, server->nick);
- g_free(recoded);
g_free_not_null(freemsg);
}
WINDOW_REC *window;
GString *chans;
GSList *tmp, *windows;
- char *print_channel, *recoded;
+ char *print_channel;
int once, count;
if (ignore_check(server, nick, address, NULL, reason, MSGLEVEL_QUITS))
print_channel = rec->visible_name;
if (once)
- g_string_sprintfa(chans, "%s,", rec->visible_name);
+ g_string_append_printf(chans, "%s,", rec->visible_name);
else {
window = window_item_window((WI_ITEM_REC *) rec);
if (g_slist_find(windows, window) == NULL) {
windows = g_slist_append(windows, window);
- recoded = recode_in(server, reason, rec->visible_name);
printformat(server, rec->visible_name,
MSGLEVEL_QUITS,
- TXT_QUIT, nick, address, recoded,
+ TXT_QUIT, nick, address, reason,
rec->visible_name);
- g_free(recoded);
}
}
count++;
display the quit there too */
QUERY_REC *query = query_find(server, nick);
if (query != NULL) {
- recoded = recode_in(server, reason, nick);
printformat(server, nick, MSGLEVEL_QUITS,
- TXT_QUIT, nick, address, recoded, "");
- g_free(recoded);
+ TXT_QUIT, nick, address, reason, "");
}
}
if (once || count == 0) {
if (chans->len > 0)
g_string_truncate(chans, chans->len-1);
- /* at least recode_fallback will be used */
- recoded = recode_in(server, reason, nick);
printformat(server, print_channel, MSGLEVEL_QUITS,
count <= 1 ? TXT_QUIT : TXT_QUIT_ONCE,
- nick, address, recoded, chans->str);
- g_free(recoded);
+ nick, address, reason, chans->str);
}
g_string_free(chans, TRUE);
}
msgprint = FALSE;
- /* Print to each channel/query where the nick is.
+ /* Print to each channel where the nick is.
Don't print more than once to the same window. */
windows = NULL;
for (tmp = server->channels; tmp != NULL; tmp = tmp->next) {
newnick = g_string_new(NULL);
n = 2;
do {
- g_string_sprintf(newnick, "%s%d", nickhost, n);
+ g_string_printf(newnick, "%s%d", nickhost, n);
n++;
} while (printnick_exists(firstnick, nick, newnick->str));