More galeon 1 crack - useragent changing

Crispin Flowerday <[email protected]>
Newsgroups gmane.comp.web.galeon.devel
Message-ID <1035033357.5797.4.camel@drno>
There is nothing worse than having your online bank not allow access to
mozilla based browsers, so I hacked, and I mean hacked, galeon to have a
menu for changing the user agent. My menu items are full of bugs, which
I dont intend to fix, cos it works fine for what I want it to do :)

While working on that, I worked around the problems with java
complaining about the version in the user agent string, that patch may
be of more use to people.

Both patches are attached.

Crispin
java_fix.patch (text/plain, 2.7 KB)
--- mozilla_prefs.h	12 Sep 2002 14:58:04 -0000	1.5.2.1
+++ mozilla_prefs.h	19 Oct 2002 13:04:43 -0000
@@ -25,6 +25,7 @@
 
 void mozilla_prefs_get_fonts (LanguageFontInfo *info, int lang_enc);
 void mozilla_prefs_set_user_agent (void);
+void mozilla_prefs_set_default_user_agent(void);
 void mozilla_prefs_set_font_size (gchar *key, int size, int lang_enc);
 
 void mozilla_prefs_set_proxy (void);
--- mozilla_prefs.c	12 Sep 2002 14:58:04 -0000	1.71.2.3
+++ mozilla_prefs.c	19 Oct 2002 13:04:43 -0000
@@ -198,12 +198,11 @@
 	mozilla_preference_set_int (key_buf, size);
 }
 
+
 void
-mozilla_prefs_set_user_agent ()
+mozilla_prefs_set_default_user_agent()
 {
 	static gchar *default_user_agent = NULL;
-	gchar *value;
-	gchar *user_agent = NULL;
 	struct utsname name;
 	gchar *system;
 
@@ -228,6 +227,17 @@
 		g_free (system);
 	}
 
+        mozilla_preference_set ("general.useragent.override", 
+                                default_user_agent );
+}
+
+
+
+void
+mozilla_prefs_set_user_agent ()
+{
+	gchar *value;
+
 	value = eel_gconf_get_string (CONF_NETWORK_USER_AGENT);
 	
 	/* now, build a valid user agent string */
@@ -237,20 +247,13 @@
 	 	   || !strcmp (_("Default (recommended)"), value)
 		   || !strcmp ("Default (recommended)", value))
 	{
-		user_agent = g_strdup (default_user_agent);
+		mozilla_prefs_set_default_user_agent();
 	}
 	else
 	{
-		user_agent = g_strdup (value);
-	}
-				
-	if (user_agent)
-	{
 		mozilla_preference_set ("general.useragent.override",
-					user_agent);
-		g_free (user_agent);
+					 value);
 	}
-
 	g_free (value);
 }
 
--- menubar.h	23 Jun 2002 09:26:29 -0000	1.49.2.3
+++ menubar.h	19 Oct 2002 13:04:42 -0000
@@ -215,7 +215,13 @@
 void window_menu_recent_release_cb (GtkMenuItem *menuitem, 
 				    GdkEventButton *event,
 				    gpointer user_data);
-	                    		
+void
+window_menu_set_useragent_default_cb(GtkMenuItem *menuitem, 
+                                     GaleonWindow *window);
+void
+window_menu_set_useragent_msie_cb(GtkMenuItem *menuitem, 
+                                  GaleonWindow *window);
+
 /* from window_callbacks.c */
 gboolean window_delete_cb (GtkWidget *widget, GdkEventAny *event,
                            GaleonWindow *window);
--- embed.c	1 Jul 2002 07:20:10 -0000	1.258.2.32
+++ embed.c	19 Oct 2002 13:04:41 -0000
@@ -431,7 +431,18 @@
 
 		if (window)
 		{
+			/* This is a nasty hack to avoid crashing when
+			 * java is enabled, when the first window is shown */
+			static int done_once = 0;
+			if ( ! done_once ) {
+				mozilla_prefs_set_default_user_agent();
+			}
+
 			window_show_one_embed (window);
+			if ( ! done_once ) {
+				mozilla_prefs_set_user_agent();
+				done_once = 1;
+			}
 		}
 	}
user_agent.patch (text/plain, 3.8 KB)
--- menu_callbacks.c	23 Jun 2002 09:26:29 -0000	1.154.2.11
+++ menu_callbacks.c	19 Oct 2002 13:04:42 -0000
@@ -1460,3 +1460,29 @@
 	
 	gtk_menu_reposition (menu);
 }
+
+void
+window_menu_set_useragent_default_cb(GtkMenuItem *menuitem, 
+                                     GaleonWindow *window)
+{
+	eel_gconf_set_string( CONF_NETWORK_USER_AGENT, "default" );
+
+	return_if_not_window (window);
+	return_if_not_embed (window->active_embed);
+	embed_set_temp_statusbar_message( window->active_embed,
+					  _("Setting default galeon User Agent") );
+}
+
+
+void
+window_menu_set_useragent_msie_cb(GtkMenuItem *menuitem, 
+                                  GaleonWindow *window)
+{
+	eel_gconf_set_string( CONF_NETWORK_USER_AGENT, 
+			      "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Galeon)" );
+	return_if_not_window (window);
+	return_if_not_embed (window->active_embed);
+	embed_set_temp_statusbar_message( window->active_embed,
+					  _("Setting User Agent to MSIE") );
+
+}
--- menubar.c	23 Jun 2002 09:26:29 -0000	1.87.2.7
+++ menubar.c	19 Oct 2002 13:04:42 -0000
@@ -404,6 +404,32 @@
 	GNOMEUIINFO_END
 };
 
+
+GnomeUIInfo useragent_select_uiinfo[] = 
+{
+	{ GNOME_APP_UI_ITEM, N_("_Default"),
+	  N_("Use the default Galeon User Agent"),
+	  window_menu_set_useragent_default_cb, NULL, NULL,
+	  GNOME_APP_PIXMAP_NONE, NULL,
+	  0, 0, NULL },
+	{ GNOME_APP_UI_ITEM, N_("_MSIE XP"),
+	  N_("Use the MS XP 6.0 user agent"),
+	  window_menu_set_useragent_msie_cb, NULL, NULL,
+	  GNOME_APP_PIXMAP_NONE, NULL,
+	  0, 0, NULL },
+	GNOMEUIINFO_END
+};
+
+
+
+GnomeUIInfo useragent_menu_uiinfo[] =
+{
+	{ GNOME_APP_UI_RADIOITEMS, NULL, NULL, useragent_select_uiinfo,
+	  NULL, NULL, 0, NULL, 0, 0, NULL },
+	GNOMEUIINFO_END
+};
+
+
 GnomeUIInfo settings_menu_uiinfo[] =
 {
 	{ GNOME_APP_UI_SUBTREE, N_("_Load images"),
@@ -421,6 +447,11 @@
 	  proxies_menu_uiinfo, NULL, NULL,
 	  GNOME_APP_PIXMAP_NONE, NULL,
 	  0, 0, NULL },
+	{ GNOME_APP_UI_SUBTREE, N_("_User Agent"),
+	  N_("Control which user agent to pass to web sites"),
+	  useragent_menu_uiinfo, NULL, NULL,
+	  GNOME_APP_PIXMAP_NONE, NULL,
+	  0, 0, NULL },
 	GNOMEUIINFO_SEPARATOR,
 	{ GNOME_APP_UI_TOGGLEITEM, N_("Use own _fonts"),
 	  N_("Use default fonts instead of page-requested fonts"),
@@ -631,6 +662,8 @@
 	block_images_menu_uiinfo,
 	proxies_always_uiinfo,
 	proxies_menu_uiinfo,
+        useragent_select_uiinfo,
+        useragent_menu_uiinfo,
 	settings_menu_uiinfo,
 	bookmarks_menu_uiinfo,
 	go_menu_uiinfo,
@@ -654,6 +687,8 @@
 	sizeof(block_images_menu_uiinfo)   / sizeof(GnomeUIInfo),
 	sizeof(proxies_always_uiinfo)      / sizeof(GnomeUIInfo),
 	sizeof(proxies_menu_uiinfo)        / sizeof(GnomeUIInfo),
+	sizeof(useragent_menu_uiinfo)      / sizeof(GnomeUIInfo),
+	sizeof(useragent_select_uiinfo)    / sizeof(GnomeUIInfo),
 	sizeof(settings_menu_uiinfo)       / sizeof(GnomeUIInfo),
 	sizeof(bookmarks_menu_uiinfo)      / sizeof(GnomeUIInfo),
 	sizeof(go_menu_uiinfo)             / sizeof(GnomeUIInfo),
--- window.c	30 Aug 2002 06:33:38 -0000	1.228.2.12
+++ window.c	19 Oct 2002 13:04:44 -0000
@@ -442,11 +442,11 @@
 	window->manual_proxy = proxies_always_uiinfo[1].widget;
 	window->autoproxy = proxies_always_uiinfo[2].widget;
 	  
-	window->use_own_fonts =  settings_menu_uiinfo[4].widget;
-	window->use_own_colors = settings_menu_uiinfo[5].widget;
-	window->enable_java = settings_menu_uiinfo[6].widget;
-	window->enable_javascript = settings_menu_uiinfo[7].widget;
-	window->allow_popups = settings_menu_uiinfo[8].widget;
+	window->use_own_fonts =  settings_menu_uiinfo[5].widget;
+	window->use_own_colors = settings_menu_uiinfo[6].widget;
+	window->enable_java = settings_menu_uiinfo[7].widget;
+	window->enable_javascript = settings_menu_uiinfo[8].widget;
+	window->allow_popups = settings_menu_uiinfo[9].widget;
 
 	/* bookmarks menu */
 	window->add_bookmark = bookmarks_menu_uiinfo[1].widget;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.