From a0b238e4444b5a027290a4159a9180ea7709e724 Mon Sep 17 00:00:00 2001 From: Jesse van den Kieboom Date: Sun, 6 Nov 2005 16:01:48 +0000 Subject: [PATCH] Fixed encoding conversion fallback, added mcp session --- src/gm-world.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/src/gm-world.c b/src/gm-world.c index 027fca3..d5df56d 100644 --- a/src/gm-world.c +++ b/src/gm-world.c @@ -4,6 +4,7 @@ #include "gm-world.h" #include "gm-app.h" +#include "mcp/gm-mcp-session.h" #include "gm-triggers.h" #include "gm-marshal.h" #include "gm-net.h" @@ -36,7 +37,7 @@ struct _GmWorldPrivate { GmOptions *options; GmTriggers *triggers; GmNet *net; - GmMcp *mcp; + GmMcpSession *mcp; GList *history; GList *editors; GmWorldInfo info; @@ -93,6 +94,8 @@ gm_world_finalize(GObject *object) { g_object_unref(world->priv->triggers); g_object_unref(world->priv->options); g_object_unref(world->priv->net); + g_object_unref(world->priv->mcp); + G_OBJECT_CLASS(gm_world_parent_class)->finalize(object); } @@ -255,7 +258,7 @@ gm_world_init(GmWorld *world) { world->priv->activity = 0; world->priv->triggers = gm_triggers_new(); world->priv->net = gm_net_new(); - world->priv->mcp = gm_mcp_new(world); + world->priv->mcp = gm_mcp_session_new(G_OBJECT(world)); world->priv->buffer = NULL; world->priv->editing_info.is_editing = FALSE; @@ -623,7 +626,7 @@ gm_world_process_line(GmWorld *world, gchar *line) { if (strncasecmp(non_text_start + 3, " edit ", 6) == 0) { gm_world_parse_legacy_editing_start(world, non_text_start + 9); } else { - gm_mcp_handle(world->priv->mcp, non_text_start + 3); + gm_mcp_session_handle_oob(world->priv->mcp, non_text_start + 3); //gm_world_log(world, LOG_MCP_IN, non_text_start); } } else { @@ -713,19 +716,13 @@ gm_world_add_editor(GmWorld *world, GmEditor *editor) { void gm_world_sendln(GmWorld *world, gchar *text) { gchar *normal; - GError *err = NULL; - gint written; // Convert text from utf-8 to the correct locale - normal = g_convert_with_fallback(text, g_utf8_strlen(text, -1), - gm_options_get(world->priv->options, "charset"), "UTF-8", "?", - NULL, &written, &err); + normal = gm_to_utf8_with_fallback(text, -1, + gm_options_get(world->priv->options, "charset"), "?"); if (!normal) { - debug_msg(1, "GmWorld.Send: conversion failed: %s (written %d)!", - err->message, written); - g_error_free(err); - err = NULL; + debug_msg(1, "GmWorld.Send: conversion failed!"); normal = g_strdup(text); } @@ -818,19 +815,13 @@ void on_gm_world_net_bytes_recv(GmNet *net, gchar *text, gint len, GmWorld *world) { gchar *all, *utext, *ptr, *line, *p; - gsize read, written; - GError *err = NULL; gint i; - utext = g_convert_with_fallback(text, len, "UTF-8", - gm_options_get(world->priv->options, "charset"), - NULL, &read, &written, &err); + utext = gm_to_utf8_with_fallback(text, len, + gm_options_get(world->priv->options, "charset"), "?"); if (!utext) { - debug_msg(1, "GmWorld.NetBytesRecv: conversion failed: %s (written %d, " - "read %d)!", err->message, written, read); - g_error_free(err); - err = NULL; + debug_msg(1, "GmWorld.NetBytesRecv: conversion failed!"); utext = g_strndup(text, len); } @@ -853,7 +844,6 @@ on_gm_world_net_bytes_recv(GmNet *net, gchar *text, gint len, line[i] = '\n'; line[i + 1] = '\0'; - gm_world_log(world, LOG_MCP_IN, line); gm_world_process_line(world, line); p = ptr + 1; i = 0;