summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorTingPing <tingping@tingping.se>2013-07-01 13:43:58 -0400
committerTingPing <tingping@tingping.se>2013-07-01 13:43:58 -0400
commitaab55d8cffc577a7aec4f43d5157c7e3f498c0f5 (patch)
tree9daed407f233e1ae2c85212735350dd1dc8ca5d8
parent73c9321361b38e75d442780280175d5298893c8f (diff)
Handle extraneous cli args as urls
-rw-r--r--share/misc/hexchat.desktop3
-rw-r--r--src/common/hexchat.c23
-rw-r--r--src/common/hexchatc.h1
-rw-r--r--src/fe-gtk/fe-gtk.c1
4 files changed, 22 insertions, 6 deletions
diff --git a/share/misc/hexchat.desktop b/share/misc/hexchat.desktop
index ce573af1..f82465c7 100644
--- a/share/misc/hexchat.desktop
+++ b/share/misc/hexchat.desktop
@@ -21,10 +21,11 @@ Comment[fr]=Discutez avec tout le monde sur l'Internet Relay Chat
 Comment[de]=Sich über Internet Relay Chat mit andern Leuten unterhalten
 Comment[it]=Chiacchierare con la gente sull'Internet Relay Chat
 Comment[nb]=Snakk med mennesker på Internet Relay Chat
-Exec=hexchat
+Exec=hexchat %U
 Icon=hexchat
 Terminal=false
 Type=Application
 Categories=GTK;Network;IRCClient;
 StartupNotify=true
 X-GNOME-UsesNotifications=true
+MimeType=x-scheme-handler/irc;x-scheme-handler/ircs;
diff --git a/src/common/hexchat.c b/src/common/hexchat.c
index aece9ff3..17309dee 100644
--- a/src/common/hexchat.c
+++ b/src/common/hexchat.c
@@ -105,6 +105,7 @@ int hexchat_is_quitting = FALSE;
 int arg_dont_autoconnect = FALSE;
 int arg_skip_plugins = FALSE;
 char *arg_url = NULL;
+char **arg_urls = NULL;
 char *arg_command = NULL;
 gint arg_existing = FALSE;
 
@@ -400,6 +401,7 @@ irc_init (session *sess)
 {
 	static int done_init = FALSE;
 	char *buf;
+	int i;
 
 	if (done_init)
 		return;
@@ -431,6 +433,17 @@ irc_init (session *sess)
 		handle_command (sess, buf, FALSE);
 		g_free (buf);
 	}
+	
+	if (arg_urls != NULL)
+	{
+		for (i = 0; i < g_strv_length(arg_urls); i++)
+		{
+			buf = g_strdup_printf ("%s %s", i==0? "server" : "newserver", arg_urls[i]);
+			handle_command (sess, buf, FALSE);
+			g_free (buf);
+		}
+		g_strfreev (arg_urls);
+	}
 
 	if (arg_command != NULL)
 	{
@@ -924,17 +937,17 @@ xchat_init (void)
 	servlist_init ();							/* load server list */
 
 	/* if we got a URL, don't open the server list GUI */
-	if (!prefs.hex_gui_slist_skip && !arg_url)
+	if (!prefs.hex_gui_slist_skip && !arg_url && !arg_urls)
 		fe_serverlist_open (NULL);
 
-	/* turned OFF via -a arg */
-	if (!arg_dont_autoconnect)
+	/* turned OFF via -a arg or by passing urls */
+	if (!arg_dont_autoconnect && !arg_urls)
 	{
 		/* do any auto connects */
 		if (!servlist_have_auto ())	/* if no new windows open .. */
 		{
 			/* and no serverlist gui ... */
-			if (prefs.hex_gui_slist_skip || arg_url)
+			if (prefs.hex_gui_slist_skip || arg_url || arg_urls)
 				/* we'll have to open one. */
 				new_ircwindow (NULL, NULL, SESS_SERVER, 0);
 		} else
@@ -943,7 +956,7 @@ xchat_init (void)
 		}
 	} else
 	{
-		if (prefs.hex_gui_slist_skip || arg_url)
+		if (prefs.hex_gui_slist_skip || arg_url || arg_urls)
 			new_ircwindow (NULL, NULL, SESS_SERVER, 0);
 	}
 }
diff --git a/src/common/hexchatc.h b/src/common/hexchatc.h
index 774f4dd9..a999dcf2 100644
--- a/src/common/hexchatc.h
+++ b/src/common/hexchatc.h
@@ -26,6 +26,7 @@ extern int hexchat_is_quitting;
 extern gint arg_skip_plugins;	/* command-line args */
 extern gint arg_dont_autoconnect;
 extern char *arg_url;
+extern char **arg_urls;
 extern char *arg_command;
 extern gint arg_existing;
 
diff --git a/src/fe-gtk/fe-gtk.c b/src/fe-gtk/fe-gtk.c
index 6890286f..08f10f8a 100644
--- a/src/fe-gtk/fe-gtk.c
+++ b/src/fe-gtk/fe-gtk.c
@@ -131,6 +131,7 @@ static const GOptionEntry gopt_entries[] =
 #endif
  {"minimize",	 0,  0, G_OPTION_ARG_INT,	&arg_minimize, N_("Begin minimized. Level 0=Normal 1=Iconified 2=Tray"), N_("level")},
  {"version",	'v', 0, G_OPTION_ARG_NONE,	&arg_show_version, N_("Show version information"), NULL},
+ {G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &arg_urls, NULL, NULL},
  {NULL}
 };