gnome-mud r667 - in trunk: . src



Author: lharris
Date: Sun Jun 22 04:49:07 2008
New Revision: 667
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=667&view=rev

Log:
Les Harris: Added telnet support.



Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/gnome-mud.c
   trunk/src/gnome-mud.h
   trunk/src/mud-connection-view.c
   trunk/src/mud-connection-view.h
   trunk/src/mud-window.c
   trunk/src/utils.c
   trunk/src/utils.h

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sun Jun 22 04:49:07 2008
@@ -58,8 +58,9 @@
 VTE_REQUIRED=0.11.00
 PCRE_REQUIRED=6.0.0
 GCONF_REQUIRED=0.20
+GNOMEVFS_REQUIRED=0.16
 
-PKG_CHECK_MODULES(GMUD, gtk+-2.0 >= $GTK_REQUIRED vte >= $VTE_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED libpcre >= $PCRE_REQUIRED gmodule-2.0 >= $GMODULE_REQUIRED gnet-2.0 >= $LIBGNET_REQUIRED gconf-2.0 >= $GCONF_REQUIRED)
+PKG_CHECK_MODULES(GMUD, gtk+-2.0 >= $GTK_REQUIRED vte >= $VTE_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED libpcre >= $PCRE_REQUIRED gmodule-2.0 >= $GMODULE_REQUIRED gnet-2.0 >= $LIBGNET_REQUIRED gconf-2.0 >= $GCONF_REQUIRED gnome-vfs-2.0 >= $GNOMEVFS_REQUIRED)
 AC_SUBST(GMUD_CFLAGS)
 AC_SUBST(GMUD_LIBS)
 
@@ -244,6 +245,6 @@
 	AC_MSG_NOTICE([    * Mapper support is disabled])
 fi
 
-if test -d $srcdir/CVS; then
-	AC_MSG_WARN([You're using a CVS version. Expect problems.])
+if test -d $srcdir/.svn; then
+	AC_MSG_WARN([You're using a svn version. Expect problems.])
 fi

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sun Jun 22 04:49:07 2008
@@ -45,6 +45,8 @@
 	mud-profile.h				\
 	mud-regex.c					\
 	mud-regex.h					\
+    mud-telnet.c                \
+    mud-telnet.h                \
 	mud-tray.c					\
 	mud-tray.h					\
 	mud-window.c				\

Modified: trunk/src/gnome-mud.c
==============================================================================
--- trunk/src/gnome-mud.c	(original)
+++ trunk/src/gnome-mud.c	Sun Jun 22 04:49:07 2008
@@ -24,6 +24,7 @@
 #include <glib/gi18n.h>
 #include <gtk/gtkmain.h>
 #include <gtk/gtkwindow.h>
+#include <gtk/gtkaboutdialog.h>
 #include <stdio.h>
 #include <sys/stat.h>
 #include <gnet.h>
@@ -37,6 +38,7 @@
 #include "mud-window.h"
 #include "mud-profile.h"
 #include "modules.h"
+#include "utils.h"
 
 gboolean gconf_sanity_check_string (GConfClient *client, const gchar* key)
 {
@@ -132,7 +134,8 @@
 	g_snprintf(buf, 500, "%s/.gnome-mud/logs/", g_get_home_dir());
 	if(!g_file_test(buf, G_FILE_TEST_IS_DIR))
 		mkdir(buf, 0777 );	
-	
+
+	gtk_about_dialog_set_url_hook(utils_activate_url, NULL, NULL);	
 	gtk_main();
 	gconf_client_suggest_sync(gconf_client, &err);
 

Modified: trunk/src/gnome-mud.h
==============================================================================
--- trunk/src/gnome-mud.h	(original)
+++ trunk/src/gnome-mud.h	Sun Jun 22 04:49:07 2008
@@ -21,7 +21,6 @@
 
 #include <stdio.h>
 #include <vte/vte.h>
-//#include <libgnetwork/gnetwork.h>
 
 #if TIME_WITH_SYS_TIME
 # include <sys/time.h>

Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c	(original)
+++ trunk/src/mud-connection-view.c	Sun Jun 22 04:49:07 2008
@@ -36,6 +36,7 @@
 #include "mud-tray.h"
 #include "mud-log.h"
 #include "mud-parse-base.h"
+#include "mud-telnet.h"
 
 /* Hack, will refactor with plugin rewrite -lh */
 extern gboolean PluginGag;
@@ -67,6 +68,7 @@
 	GQueue *history;
 	guint current_history_index;
 	
+	MudTelnet *telnet;
 	gchar *hostname;
 	guint port;
 };
@@ -235,53 +237,6 @@
 void
 mud_connection_view_add_text(MudConnectionView *view, gchar *message, enum MudConnectionColorType type)
 {
-	
-	/*GtkWidget *text_widget = cd->window;
-	gint       i;
-
-    if ( message[0] == '\0' )
-    {
-        return;
-    }
-
-	i = gtk_notebook_get_current_page (GTK_NOTEBOOK(main_notebook));
-	if (connections[i]->logging
-		&& colortype != MESSAGE_ERR
-		&& colortype != MESSAGE_SYSTEM)
-	{
-		struct timeval tv;
-		
-		fputs(message, connections[i]->log);
-
-		gettimeofday(&tv, NULL);
-		if ((connections[i]->last_log_flush + (unsigned) prefs.FlushInterval) < tv.tv_sec)
-		{
-			fflush(connections[i]->log);
-			connections[i]->last_log_flush = tv.tv_sec;
-		}
-	}
-
-	switch (colortype)
-    {
-	    case MESSAGE_SENT:
-			terminal_feed(text_widget, "\e[1;33m");
-			break;
-		
-	    case MESSAGE_ERR:
-			terminal_feed(text_widget, "\e[1;31m");
-			break;
-		
-		case MESSAGE_SYSTEM:
-			terminal_feed(text_widget, "\e[1;32m");
-			break;
-		
-		default:
-			break;
-    }
-
- 	terminal_feed(text_widget, message);
-	terminal_feed(text_widget, "\e[0m");*/
-
 	switch (type)
 	{
 		case Sent:
@@ -312,7 +267,6 @@
 	GtkWidget *box;
     
   	connection_view->priv = g_new0(MudConnectionViewPrivate, 1);
-  	//FIXME connection_view->priv->prefs = mud_preferences_new(NULL);
   
     connection_view->priv->history = g_queue_new();
     connection_view->priv->current_history_index = 0;
@@ -380,9 +334,6 @@
     
     gnet_conn_disconnect(connection_view->connection);
     gnet_conn_unref(connection_view->connection);
-    
-	//gnetwork_connection_close(GNETWORK_CONNECTION(connection_view->connection));
-	//g_object_unref(connection_view->connection);
 	
 	g_free(connection_view->priv);
     
@@ -398,96 +349,6 @@
 	view->priv->connect_string = g_strdup(connect_string);
 }
 
-/*static void
-mud_connection_view_received_cb(GNetworkConnection *cxn, gconstpointer data, gulong length, gpointer user_data)
-{
-	gint gag;
-	gint pluggag;
-	
-	MudConnectionView *view = MUD_CONNECTION_VIEW(user_data);
-	g_assert(view != NULL);
-
-	if(!view->priv->connected)
-	{
-		view->priv->connected = TRUE;
-		mud_tray_update_icon(view->priv->tray, online);
-	}
-	
-	gag = mud_parse_base_do_triggers(view->priv->parse, (gchar *)data);
-	mud_window_handle_plugins(view->priv->window, view->priv->id, (gchar *)data, 1);
-	pluggag = PluginGag;
-	PluginGag = FALSE;
-	
-	if(!gag && !pluggag)
-	{
-		vte_terminal_feed(VTE_TERMINAL(view->priv->terminal), (gchar *) data, length);
-		mud_log_write_hook(view->priv->log, (gchar *)data, length);
-	}
-
-	if (view->priv->connect_hook) {
-		mud_connection_view_send (MUD_CONNECTION_VIEW(user_data), view->priv->connect_string);
-		g_free(view->priv->connect_string);
-		view->priv->connect_hook = FALSE;
-	}
-}
-
-static void
-mud_connection_view_send_cb(GNetworkConnection *cxn, gconstpointer data, gulong length, gpointer user_data)
-{
-	// Give plugins first crack at it
-	mud_window_handle_plugins(MUD_CONNECTION_VIEW(user_data)->priv->window, MUD_CONNECTION_VIEW(user_data)->priv->id, (gchar *)data, 0);
-}
-
-static void
-mud_connection_view_notify_cb(GObject *cxn, GParamSpec *pspec, gpointer user_data)
-{
-	GNetworkTcpConnectionStatus status;
-
-	g_object_get (cxn, "tcp-status", &status, NULL);
-
-	switch (status)
-	{
-		case GNETWORK_TCP_CONNECTION_CLOSING:
-			break;
-			
-		case GNETWORK_TCP_CONNECTION_CLOSED:
-			mud_connection_view_add_text(MUD_CONNECTION_VIEW(user_data), _("*** Connection closed.\n"), System);
-	        break;
-
-		case GNETWORK_TCP_CONNECTION_LOOKUP:
-			break;
-			
-		case GNETWORK_TCP_CONNECTION_OPENING:
-			{
-				gchar *buf, *address;
-				gint port;
-
-				g_object_get(GNETWORK_CONNECTION(cxn), "address", &address, "port", &port, NULL);
-				
-				buf = g_strdup_printf(_("*** Making connection to %s, port %d.\n"), address, port);
-				mud_connection_view_add_text(MUD_CONNECTION_VIEW(user_data), buf, System);
-				g_free(buf);
-				break;
-			}
-			
-		case GNETWORK_TCP_CONNECTION_PROXYING:
-			break;
-		
-		case GNETWORK_TCP_CONNECTION_AUTHENTICATING:
-			break;
-
-		case GNETWORK_TCP_CONNECTION_OPEN:
-			break;
-	}
-}
-
-static void
-mud_connection_view_error_cb(GNetworkConnection *cxn, GError *error, gpointer user_data)
-{
-	g_print ("Client Connection: Error:\n\tDomain\t= %s\n\tCode\t= %d\n\tMessage\t= %s\n",
-			 g_quark_to_string (error->domain), error->code, error->message);
-}*/
-
 void
 mud_connection_view_disconnect(MudConnectionView *view)
 {
@@ -495,8 +356,6 @@
 	
 	gnet_conn_disconnect(view->connection);
 	mud_connection_view_add_text(view, _("*** Connection closed.\n"), System);
-	
-	//gnetwork_connection_close(GNETWORK_CONNECTION(view->connection));
 }
 
 void
@@ -514,9 +373,6 @@
 	mud_connection_view_add_text(view, buf, System);
 	
 	gnet_conn_connect(view->connection);
-	
-	//gnetwork_connection_close(GNETWORK_CONNECTION(view->connection));
-	//gnetwork_connection_open(GNETWORK_CONNECTION(view->connection));
 }
 
 void
@@ -540,8 +396,6 @@
 		    
 		gnet_conn_write(view->connection, text, strlen(text));
 		
-		//gnetwork_connection_send(GNETWORK_CONNECTION(view->connection), text, strlen(text));
-		
 		if (view->priv->profile->preferences->EchoText)
 			mud_connection_view_add_text(view, text, Sent);
 		g_free(text);
@@ -768,23 +622,10 @@
 	    mud_connection_view_network_event_cb, view);
 	gnet_conn_ref(view->connection);
 	gnet_conn_set_watch_error(view->connection, TRUE);
-	   
-	/*view->connection = g_object_new(GNETWORK_TYPE_TCP_CONNECTION,
-									"address", hostname,
-									"port", port,
-									"authentication-type", GNETWORK_SSL_AUTH_ANONYMOUS,
-									"proxy-type", GNETWORK_TCP_PROXY_NONE, NULL);
-	g_object_add_weak_pointer(G_OBJECT(view->connection), (gpointer *) &view->connection);
-	g_signal_connect(view->connection, "received", G_CALLBACK(mud_connection_view_received_cb), view);
-	g_signal_connect(view->connection, "sent", G_CALLBACK(mud_connection_view_send_cb), view);
-	g_signal_connect(view->connection, "error", G_CALLBACK(mud_connection_view_error_cb), view);
-	g_signal_connect(view->connection, "notify::tcp-status", G_CALLBACK(mud_connection_view_notify_cb), view);
-	*/
+	
+	view->priv->telnet = mud_telnet_new(view, view->connection);
 
 	mud_connection_view_set_profile(view, mud_profile_new(profile));
-	
-	// FIXME, move this away from here
-	//gnetwork_connection_open(GNETWORK_CONNECTION(view->connection));
 
 	/* Let us resize the gnome-mud window */
 	vte_terminal_get_padding(VTE_TERMINAL(view->priv->terminal), &xpad, &ypad);
@@ -807,7 +648,7 @@
   					GDK_HINT_BASE_SIZE);
 
 	view->priv->tray = MUD_TRAY(tray);
-	
+	 
 	view->priv->log = mud_log_new(name);
 	
 	buf = g_strdup_printf(_("*** Making connection to %s, port %d.\n"), 
@@ -890,6 +731,10 @@
 {
     gint gag;
 	gint pluggag;
+	gint i;
+	MudTelnetBuffer buffer;
+	GString *string;
+	gchar *buf;
     MudConnectionView *view = MUD_CONNECTION_VIEW(pview);
     g_assert(view != NULL);
     
@@ -905,42 +750,53 @@
         break;
         
         case GNET_CONN_CLOSE:
-            mud_connection_view_add_text(view, _("*** Connection closed.\n"), System);
+            mud_connection_view_add_text(view, _("*** Connection unexpectedly closed.\n"), Error);
         break;
         
         case GNET_CONN_TIMEOUT:
         break;
         
         case GNET_CONN_READ:
-        
-            g_message("Buffer: %s\n", event->buffer);
-            
-	        if(!view->priv->connected)
-	        {
-		        view->priv->connected = TRUE;
-		        mud_tray_update_icon(view->priv->tray, online);
-	        }
-	
-	       gag = mud_parse_base_do_triggers(view->priv->parse, 
-	                event->buffer);
-	       mud_window_handle_plugins(view->priv->window, view->priv->id, 
-	                event->buffer, event->length, 1);
+	       if(!view->priv->connected)
+	       {
+		      view->priv->connected = TRUE;
+		      mud_tray_update_icon(view->priv->tray, online);
+	       }
+	       
+	       buffer = mud_telnet_process(view->priv->telnet, (guchar *)event->buffer, event->length);
+	       
+	       if(buffer.len != 0)
+	       {
+	           string = g_string_new(NULL);
+	           for(i = 0; i < buffer.len; i++)
+	                g_string_append_c(string, buffer.buffer[i]);
+	       
+	           buf = string->str;
+	       
+	           gag = mud_parse_base_do_triggers(view->priv->parse, 
+	                    buf);
+	           mud_window_handle_plugins(view->priv->window, view->priv->id, 
+	                    buf, buffer.len, 1);
 	                
-	       pluggag = PluginGag;
-	       PluginGag = FALSE;
+	           pluggag = PluginGag;
+	           PluginGag = FALSE;
 	
-	        if(!gag && !pluggag)
-	        {
+	            if(!gag && !pluggag)
+	            {
 	            
-		        vte_terminal_feed(VTE_TERMINAL(view->priv->terminal), 
-		            event->buffer, event->length);
-		        mud_log_write_hook(view->priv->log, event->buffer, event->length);
-	        }
-
-            if (view->priv->connect_hook) {
-                mud_connection_view_send (view, view->priv->connect_string);
-                g_free(view->priv->connect_string);
-                view->priv->connect_hook = FALSE;
+	    	        vte_terminal_feed(VTE_TERMINAL(view->priv->terminal), 
+	    	            buf, buffer.len);
+	    	        mud_log_write_hook(view->priv->log, buf, buffer.len);
+	            }
+
+                if (view->priv->connect_hook) {
+                    mud_connection_view_send (view, view->priv->connect_string);
+                    g_free(view->priv->connect_string);
+                    view->priv->connect_hook = FALSE;
+               }
+            
+                g_string_free(string, TRUE);
+                buf = NULL;
             }
             
             gnet_conn_read(view->connection);

Modified: trunk/src/mud-connection-view.h
==============================================================================
--- trunk/src/mud-connection-view.h	(original)
+++ trunk/src/mud-connection-view.h	Sun Jun 22 04:49:07 2008
@@ -4,7 +4,6 @@
 G_BEGIN_DECLS
 
 #include <gtk/gtkwidget.h>
-//#include <libgnetwork/gnetwork.h>
 #include <gnet.h>
 
 

Modified: trunk/src/mud-window.c
==============================================================================
--- trunk/src/mud-window.c	(original)
+++ trunk/src/mud-window.c	Sun Jun 22 04:49:07 2008
@@ -175,8 +175,18 @@
 
 	if (window->priv->nr_of_tabs == 0)
 	{
-		window->priv->image = gtk_image_new();
+	    gint w, h;
+	    GdkPixbuf *buf;
+	    GError *gerr = NULL;
+	
+	    gtk_window_get_size(GTK_WINDOW(window->priv->window), &w, &h);
+	
+	    window->priv->image = gtk_image_new();
+		buf = gdk_pixbuf_new_from_file_at_size(GMPIXMAPSDIR "/gnome-mud.svg", w >> 1, h >> 1, &gerr);
+		gtk_image_set_from_pixbuf(GTK_IMAGE(window->priv->image), buf);
+		
 		gtk_widget_show(window->priv->image);
+		
 		gtk_notebook_append_page(GTK_NOTEBOOK(window->priv->notebook), window->priv->image, NULL);
 	}
 }
@@ -857,6 +867,8 @@
 						        g_string_append_c(buf, data[i]);
 						        
 							(*pd->datafunc)(pd->plugin, buf->str, length, mudview->view);
+							
+							g_string_free(buf, FALSE);
 						}
 					}
 				}
@@ -879,6 +891,8 @@
 						        g_string_append_c(buf, data[i]);
 						        
 							(*pd->datafunc)(pd->plugin, buf->str, length, mudview->view);
+							
+							g_string_free(buf, FALSE);
 						}
 					}
 				}

Modified: trunk/src/utils.c
==============================================================================
--- trunk/src/utils.c	(original)
+++ trunk/src/utils.c	Sun Jun 22 04:49:07 2008
@@ -19,6 +19,8 @@
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
+#include <gtk/gtkaboutdialog.h>
+#include <libgnomevfs/gnome-vfs.h>
 
 gchar *
 remove_whitespace(gchar *string)
@@ -68,3 +70,10 @@
   
   return buf;
 }
+
+void
+utils_activate_url(GtkAboutDialog *about, const gchar *url, gpointer data)
+{
+	gnome_vfs_url_show(url);
+}
+

Modified: trunk/src/utils.h
==============================================================================
--- trunk/src/utils.h	(original)
+++ trunk/src/utils.h	Sun Jun 22 04:49:07 2008
@@ -1,7 +1,9 @@
 #ifndef UTILS_H
 #define UTILS_H
 
+#include <gtk/gtkaboutdialog.h>
+
 gchar * remove_whitespace(gchar *string);
 gchar *strip_ansi(const gchar *orig);
-
+void utils_activate_url(GtkAboutDialog *about, const gchar *url, gpointer data);
 #endif // UTILS_H



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]