diff options
author | Robert Manea <gotmor@gmail.com> | 2009-10-13 15:53:19 +0200 |
---|---|---|
committer | Robert Manea <gotmor@gmail.com> | 2009-10-13 15:53:19 +0200 |
commit | 5b1f6a5deed654e651e1de249a81b895d0073313 (patch) | |
tree | b045382fe6aca7fd7e843236e78525902755d46c /uzbl-core.c | |
parent | 19806c1467b71d49881a9d76e28f3c656312e77b (diff) |
handle multiple calls to --conect-socket
Diffstat (limited to 'uzbl-core.c')
-rw-r--r-- | uzbl-core.c | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/uzbl-core.c b/uzbl-core.c index ad224e8..e6f8edf 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -51,7 +51,7 @@ GOptionEntry entries[] = "Path to config file or '-' for stdin", "FILE" }, { "socket", 's', 0, G_OPTION_ARG_INT, &uzbl.state.socket_id, "Socket ID", "SOCKET" }, - { "connect-socket", 0, 0, G_OPTION_ARG_STRING, &uzbl.state.connect_socket_name, + { "connect-socket", 0, 0, G_OPTION_ARG_STRING_ARRAY, &uzbl.state.connect_socket_names, "Socket Name", "CSOCKET" }, { "geometry", 'g', 0, G_OPTION_ARG_STRING, &uzbl.gui.geometry, "Set window geometry (format: WIDTHxHEIGHT+-X+-Y)", "GEOMETRY" }, @@ -1538,23 +1538,37 @@ control_socket(GIOChannel *chan) { } void -init_connect_socket(gchar *name) { - int sockfd; +init_connect_socket() { + int sockfd, replay = 0; struct sockaddr_un local; - - sockfd = socket (AF_UNIX, SOCK_STREAM, 0); - local.sun_family = AF_UNIX; - strcpy (local.sun_path, name); - - if(!connect(sockfd, (struct sockaddr *) &local, sizeof(local))) { - if ((uzbl.comm.connect_chan = g_io_channel_unix_new(sockfd))) { - g_io_channel_set_encoding(uzbl.comm.connect_chan, NULL, NULL); - g_io_add_watch(uzbl.comm.connect_chan, G_IO_IN|G_IO_HUP, - (GIOFunc) control_client_socket, uzbl.comm.connect_chan); - /* replay buffered events */ - send_event_socket(NULL); + GIOChannel *chan; + gchar **name = NULL; + + if(!uzbl.comm.connect_chan) + uzbl.comm.connect_chan = g_ptr_array_new(); + + name = uzbl.state.connect_socket_names; + + while(name && *name) { + sockfd = socket (AF_UNIX, SOCK_STREAM, 0); + local.sun_family = AF_UNIX; + strcpy (local.sun_path, *name); + + if(!connect(sockfd, (struct sockaddr *) &local, sizeof(local))) { + if ((chan = g_io_channel_unix_new(sockfd))) { + g_io_channel_set_encoding(chan, NULL, NULL); + g_io_add_watch(chan, G_IO_IN|G_IO_HUP, + (GIOFunc) control_client_socket, chan); + g_ptr_array_add(uzbl.comm.connect_chan, (gpointer)chan); + replay++; + } } + name++; } + + /* replay buffered events */ + if(replay) + send_event_socket(NULL); } gboolean @@ -1936,8 +1950,8 @@ settings_init () { printf ("No configuration file loaded.\n"); } - if(s->connect_socket_name) - init_connect_socket(s->connect_socket_name); + if(s->connect_socket_names) + init_connect_socket(); g_signal_connect_after(n->soup_session, "request-started", G_CALLBACK(handle_cookies), NULL); } |