gnome-mud r736 - in trunk: . src
- From: lharris svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-mud r736 - in trunk: . src
- Date: Tue, 17 Feb 2009 05:19:42 +0000 (UTC)
Author: lharris
Date: Tue Feb 17 05:19:42 2009
New Revision: 736
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=736&view=rev
Log:
(Dis|Re)connect now unrefs and rebuilds connection. Memory leak fixed.
Modified:
trunk/ChangeLog
trunk/src/mud-connection-view.c
trunk/src/mud-telnet.c
trunk/src/mud-telnet.h
Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c (original)
+++ trunk/src/mud-connection-view.c Tue Feb 17 05:19:42 2009
@@ -496,7 +496,7 @@
g_assert(view != NULL);
- if(gnet_conn_is_connected(view->connection))
+ if(view->connection && gnet_conn_is_connected(view->connection))
{
#ifdef ENABLE_GST
if(view->priv->download_queue)
@@ -512,6 +512,8 @@
view->priv->processed = NULL;
gnet_conn_disconnect(view->connection);
+ gnet_conn_unref(view->connection);
+ view->connection = NULL;
if(view->priv->telnet)
g_object_unref(view->priv->telnet);
@@ -523,7 +525,11 @@
void
mud_connection_view_reconnect(MudConnectionView *view)
{
- gchar *buf;
+ gchar *buf, *profile_name, *proxy_host, *version;
+ gchar key[2048];
+ gchar extra_path[512] = "";
+ gboolean use_proxy;
+ GConfClient *client;
#ifdef ENABLE_GST
MudMSPDownloadItem *item;
@@ -531,7 +537,7 @@
g_assert(view != NULL);
- if(gnet_conn_is_connected(view->connection))
+ if(view->connection && gnet_conn_is_connected(view->connection))
{
#ifdef ENABLE_GST
@@ -548,6 +554,8 @@
view->priv->processed = NULL;
gnet_conn_disconnect(view->connection);
+ gnet_conn_unref(view->connection);
+ view->connection = NULL;
g_object_unref(view->priv->telnet);
@@ -555,6 +563,46 @@
_("\n*** Connection closed.\n"), System);
}
+ view->connection = gnet_conn_new(view->priv->hostname, view->priv->port,
+ mud_connection_view_network_event_cb, view);
+ gnet_conn_ref(view->connection);
+ gnet_conn_set_watch_error(view->connection, TRUE);
+
+ profile_name = mud_profile_get_name(view->priv->profile);
+
+ if (strcmp(profile_name, "Default") != 0)
+ {
+ g_snprintf(extra_path, 512, "profiles/%s/", profile_name);
+ }
+
+ g_snprintf(key, 2048, "/apps/gnome-mud/%s%s", extra_path, "functionality/use_proxy");
+ client = gconf_client_get_default();
+ use_proxy = gconf_client_get_bool(client, key, NULL);
+
+ g_snprintf(key, 2048, "/apps/gnome-mud/%s%s", extra_path, "functionality/proxy_hostname");
+ proxy_host = gconf_client_get_string(client, key, NULL);
+
+ g_snprintf(key, 2048, "/apps/gnome-mud/%s%s", extra_path, "functionality/proxy_version");
+ version = gconf_client_get_string(client, key, NULL);
+
+ if(use_proxy)
+ {
+ if(proxy_host && version)
+ {
+ gnet_socks_set_enabled(TRUE);
+ gnet_socks_set_server(gnet_inetaddr_new(proxy_host,GNET_SOCKS_PORT));
+ gnet_socks_set_version((strcmp(version, "4") == 0) ? 4 : 5);
+ }
+ }
+ else
+ gnet_socks_set_enabled(FALSE);
+
+ if(proxy_host)
+ g_free(proxy_host);
+
+ if(version)
+ g_free(version);
+
#ifdef ENABLE_GST
view->priv->download_queue = g_queue_new();
#endif
@@ -579,38 +627,41 @@
GList *commands, *command;
gchar *text;
- if(view->local_echo) // Prevent password from being cached.
+ if(view->connection && gnet_conn_is_connected(view->connection))
{
- gchar *head = g_queue_peek_head(view->priv->history);
+ if(view->local_echo) // Prevent password from being cached.
+ {
+ gchar *head = g_queue_peek_head(view->priv->history);
- if( (head && strcmp(head, data) != 0 && head[0] != '\n')
- || g_queue_is_empty(view->priv->history))
+ if( (head && strcmp(head, data) != 0 && head[0] != '\n')
+ || g_queue_is_empty(view->priv->history))
+ g_queue_push_head(view->priv->history,
+ (gpointer)g_strdup(data));
+ }
+ else
g_queue_push_head(view->priv->history,
- (gpointer)g_strdup(data));
- }
- else
- g_queue_push_head(view->priv->history,
- (gpointer)g_strdup(_("<password removed>")));
+ (gpointer)g_strdup(_("<password removed>")));
- view->priv->current_history_index = 0;
- commands = mud_profile_process_commands(view->priv->profile, data);
+ view->priv->current_history_index = 0;
+ commands = mud_profile_process_commands(view->priv->profile, data);
- for (command = g_list_first(commands); command != NULL; command = command->next)
- {
- text = g_strdup_printf("%s\r\n", (gchar *) command->data);
+ for (command = g_list_first(commands); command != NULL; command = command->next)
+ {
+ text = g_strdup_printf("%s\r\n", (gchar *) command->data);
- // Give plugins first crack at it.
- mud_window_handle_plugins(view->priv->window, view->priv->id,
- (gchar *)text, strlen(text), 0);
+ // Give plugins first crack at it.
+ mud_window_handle_plugins(view->priv->window, view->priv->id,
+ (gchar *)text, strlen(text), 0);
- gnet_conn_write(view->connection, text, strlen(text));
+ gnet_conn_write(view->connection, text, strlen(text));
- if (view->priv->profile->preferences->EchoText && view->local_echo)
- mud_connection_view_add_text(view, text, Sent);
- g_free(text);
- }
+ if (view->priv->profile->preferences->EchoText && view->local_echo)
+ mud_connection_view_add_text(view, text, Sent);
+ g_free(text);
+ }
- g_list_free(commands);
+ g_list_free(commands);
+ }
}
static void
@@ -913,6 +964,12 @@
else
gnet_socks_set_enabled(FALSE);
+ if(proxy_host)
+ g_free(proxy_host);
+
+ if(version)
+ g_free(version);
+
gnet_conn_connect(view->connection);
return view;
Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c (original)
+++ trunk/src/mud-telnet.c Tue Feb 17 05:19:42 2009
@@ -111,7 +111,10 @@
telnet->priv = g_new0(MudTelnetPrivate, 1);
telnet->processed = g_string_new(NULL);
+
+#ifdef ENABLE_GST
telnet->prev_buffer = NULL;
+#endif
}
static void
@@ -132,7 +135,17 @@
if(telnet->processed)
g_string_free(telnet->processed, TRUE);
- g_free(telnet->priv);
+
+ if(telnet->buffer)
+ g_string_free(telnet->buffer, TRUE);
+
+ if(telnet->mud_name)
+ g_free(telnet->mud_name);
+
+#ifdef ENABLE_GST
+ if(telnet->prev_buffer)
+ g_string_free(telnet->prev_buffer, TRUE);
+#endif
#ifdef ENABLE_MCCP
if(telnet->compress_out != NULL)
@@ -144,6 +157,8 @@
}
#endif
+ g_free(telnet->priv);
+
parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
parent_class->finalize(object);
}
Modified: trunk/src/mud-telnet.h
==============================================================================
--- trunk/src/mud-telnet.h (original)
+++ trunk/src/mud-telnet.h Tue Feb 17 05:19:42 2009
@@ -183,9 +183,9 @@
guchar *compress_out_buf;
gboolean mccp;
gboolean mccp_new;
+ GString *prev_buffer;
#endif
- GString *prev_buffer;
GString *processed;
GString *buffer;
size_t pos;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]