17596
|
1 |
diff -urN xagent.orig/gnome-session/xagent.c xagent.new/gnome-session/xagent.c
|
|
2 |
--- xagent.orig/gnome-session/xagent.c 2010-02-18 15:48:09.702503615 +0000
|
|
3 |
+++ xagent.new/gnome-session/xagent.c 2010-02-25 11:58:53.341643955 +0000
|
|
4 |
@@ -93,25 +93,33 @@
|
|
5 |
exit (2);
|
|
6 |
}
|
|
7 |
|
|
8 |
-static void
|
|
9 |
-parse_exec_string (char *exec, int *screen, char **command)
|
|
10 |
-{
|
|
11 |
- gchar **tokens = g_strsplit (exec, ":", 2);
|
|
12 |
-
|
|
13 |
- if (tokens[0]) {
|
|
14 |
- *screen = atoi (tokens[0]);
|
|
15 |
- } else {
|
|
16 |
- *screen = 0;
|
|
17 |
- }
|
|
18 |
+enum {
|
|
19 |
+ PIPE_MESSAGE_PARSE_ERROR = 0,
|
|
20 |
+ PIPE_MESSAGE_COMMAND,
|
|
21 |
+ PIPE_MESSAGE_URI,
|
|
22 |
+};
|
|
23 |
|
|
24 |
- if (tokens[1]) {
|
|
25 |
- *command = g_strdup (tokens[1]);
|
|
26 |
- } else {
|
|
27 |
- *command = g_strdup (exec);
|
|
28 |
- }
|
|
29 |
+static int
|
|
30 |
+parse_message_string (char *str, int *screen, char **message)
|
|
31 |
+{
|
|
32 |
+ gchar *p = NULL;
|
|
33 |
|
|
34 |
- g_strfreev (tokens);
|
|
35 |
+ if (!(p = strchr (str, ':')) || (p == str))
|
|
36 |
+ return PIPE_MESSAGE_PARSE_ERROR;
|
|
37 |
|
|
38 |
+ if (*(p+1) != '\0')
|
|
39 |
+ *message = g_strdup (p+1);
|
|
40 |
+ else
|
|
41 |
+ return PIPE_MESSAGE_PARSE_ERROR;
|
|
42 |
+
|
|
43 |
+ *p = '\0';
|
|
44 |
+ *screen = atoi (str); /* defaults to 0 on error */
|
|
45 |
+ *p = ':';
|
|
46 |
+
|
|
47 |
+ if (strncmp (*message, "[URI]", 5) == 0)
|
|
48 |
+ return PIPE_MESSAGE_URI;
|
|
49 |
+ else
|
|
50 |
+ return PIPE_MESSAGE_COMMAND;
|
|
51 |
}
|
|
52 |
|
|
53 |
static gboolean
|
|
54 |
@@ -125,7 +133,8 @@
|
|
55 |
GError *error = NULL;
|
|
56 |
GIOStatus status=0;
|
|
57 |
int screen_num;
|
|
58 |
- gchar *real_cmd;
|
|
59 |
+ int message_type;
|
|
60 |
+ gchar *message = NULL;
|
|
61 |
GdkDisplay *gdk_dpy;
|
|
62 |
|
|
63 |
if (condition & G_IO_ERR) return FALSE;
|
|
64 |
@@ -139,11 +148,23 @@
|
|
65 |
{
|
|
66 |
case G_IO_STATUS_NORMAL:
|
|
67 |
str[pos] = '\0';
|
|
68 |
- parse_exec_string (str, &screen_num, &real_cmd);
|
|
69 |
gdk_dpy = gdk_display_get_default ();
|
|
70 |
- gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy,
|
|
71 |
- screen_num), real_cmd, &error);
|
|
72 |
- g_free (real_cmd);
|
|
73 |
+ message_type = parse_message_string (str, &screen_num, &message);
|
|
74 |
+ switch (message_type)
|
|
75 |
+ {
|
|
76 |
+ case PIPE_MESSAGE_URI:
|
|
77 |
+ gtk_show_uri (gdk_display_get_screen (gdk_dpy, screen_num),
|
|
78 |
+ message + 5, GDK_CURRENT_TIME, &error);
|
|
79 |
+ break;
|
|
80 |
+ case PIPE_MESSAGE_COMMAND:
|
|
81 |
+ gdk_spawn_command_line_on_screen (gdk_display_get_screen (gdk_dpy,
|
|
82 |
+ screen_num), message, &error);
|
|
83 |
+ break;
|
|
84 |
+ case PIPE_MESSAGE_PARSE_ERROR:
|
|
85 |
+ default:
|
|
86 |
+ break;
|
|
87 |
+ }
|
|
88 |
+ if (message) g_free (message);
|
|
89 |
return TRUE;
|
|
90 |
case G_IO_STATUS_AGAIN:
|
|
91 |
return FALSE;
|