annotate src/browser.c @ 5437:0031a613a87d

[gaim-migrate @ 5819] These are important. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Sun, 18 May 2003 19:59:43 +0000
parents ad445074d239
children d1524728d491
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * some code: (most in this file)
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * Copyright (C) 1996 Netscape Communications Corporation, all rights reserved.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * Created: Jamie Zawinski <jwz@netscape.com>, 24-Dec-94.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
23 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 * This code is mainly taken from Netscape's sample implementation of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 * their protocol. Nifty.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 79
diff changeset
30 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2077
diff changeset
31 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 79
diff changeset
32 #endif
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
33 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
34 #include <gdk/gdkwin32.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
35 #else
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
36 #include <unistd.h>
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
37 #ifndef HOST_NAME_MAX
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
38 #define HOST_NAME_MAX 255
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
39 #endif
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
40 #include <gdk/gdkx.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
41 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 #include <stdlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #include <gtk/gtk.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 #include <gdk/gdkprivate.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 #include "gaim.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
52 #include "notify.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 #ifndef _WIN32
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
55
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
56
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
57
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
58
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
59 #include <X11/Xlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 #include <X11/Xatom.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 static const char *progname = "gaim";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 static const char *expected_mozilla_version = "1.1";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
66 #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69 #define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
70
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
71 static GdkAtom GDKA_MOZILLA_VERSION = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
72 static GdkAtom GDKA_MOZILLA_LOCK = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
73 static GdkAtom GDKA_MOZILLA_COMMAND = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
74 static GdkAtom GDKA_MOZILLA_RESPONSE = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
75
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
76 static char *window_check_mozilla_version(Window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
77 static const char *get_lock_data();
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
78 static GdkFilterReturn netscape_response_cb(XEvent *, GdkEvent *, GdkWindow *);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
79 static gboolean netscape_command(const char *);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 static int netscape_lock;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
84 static Window VirtualRootWindowOfScreen(screen)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
85 Screen *screen;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
86 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
87 static Screen *save_screen = (Screen *) 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
88 static Window root = (Window) 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
90 if (screen != save_screen) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
91 Display *dpy = DisplayOfScreen(screen);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
92 Atom __SWM_VROOT = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
93 unsigned int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
94 Window rootReturn, parentReturn, *children;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
95 unsigned int numChildren;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
96
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
97 root = RootWindowOfScreen(screen);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
98
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
99 /* go look for a virtual root */
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
100 __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
101 if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
102 for (i = 0; i < numChildren; i++) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
103 Atom actual_type;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
104 int actual_format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
105 unsigned long nitems, bytesafter;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
106 Window *newRoot = (Window *) 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
108 if (XGetWindowProperty(dpy, children[i],
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
109 __SWM_VROOT, 0, 1, False, XA_WINDOW,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
110 &actual_type, &actual_format,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
111 &nitems, &bytesafter,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
112 (unsigned char **)&newRoot) == Success
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
113 && newRoot) {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
114 root = *newRoot;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
115 break;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
116 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
117 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
118 if (children)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
119 XFree((char *)children);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
120 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
121
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
122 save_screen = screen;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
123 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
124
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
125 return root;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
126 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
127
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
128 /* The following code is Copyright (C) 1989 X Consortium */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
129
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
130 static Window TryChildren();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
131
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
132 /* Find a window with WM_STATE, else return win itself, as per ICCCM */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
133
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
134 static Window GClientWindow(dpy, win)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
135 Display *dpy;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
136 Window win;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
137 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
138 Atom WM_STATE;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
139 Atom type = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
140 int format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
141 unsigned long nitems, after;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
142 unsigned char *data;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
143 Window inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
144
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
145 WM_STATE = XInternAtom(dpy, "WM_STATE", True);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
146 if (!WM_STATE)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
147 return win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
148 XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
149 &type, &format, &nitems, &after, &data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
150 if (type) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
151 XFree(data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
152 return win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
153 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
154
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
155 inf = TryChildren(dpy, win, WM_STATE);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
156 if (!inf)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
157 inf = win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
158
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
159 XFree(data);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
160
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
161 return inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
162 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 static
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
165 Window TryChildren(dpy, win, WM_STATE)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
166 Display *dpy;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
167 Window win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
168 Atom WM_STATE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
169 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
170 Window root, parent;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
171 Window *children;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
172 unsigned int nchildren;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
173 unsigned int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
174 Atom type = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
175 int format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
176 unsigned long nitems, after;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
177 unsigned char *data;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
178 Window inf = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
180 if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
181 return 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
182 for (i = 0; !inf && (i < nchildren); i++) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
183 XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
184 AnyPropertyType, &type, &format, &nitems, &after, &data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
185 if (type)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
186 inf = children[i];
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
187
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
188 XFree(data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
189 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
190 for (i = 0; !inf && (i < nchildren); i++)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
191 inf = TryChildren(dpy, children[i], WM_STATE);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
192 if (children)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
193 XFree((char *)children);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
194 return inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 /* END X Consortium code */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 static void mozilla_remote_init_atoms()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 {
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
203 if (!GDKA_MOZILLA_VERSION)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
204 GDKA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
205 if (!GDKA_MOZILLA_LOCK)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
206 GDKA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
207 if (!GDKA_MOZILLA_COMMAND)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
208 GDKA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
209 if (!GDKA_MOZILLA_RESPONSE)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
210 GDKA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
213 static char *window_check_mozilla_version(Window window) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
214
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
215 Atom type;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
216 int format;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
217 unsigned long nitems, bytesafter;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
218 unsigned char *version = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
219 gchar *retval = NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
220
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
221 if (XGetWindowProperty(gdk_display, window,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
222 gdk_x11_atom_to_xatom(GDKA_MOZILLA_VERSION),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
223 0, (65536 / sizeof(long)),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
224 False, XA_STRING,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
225 &type, &format, &nitems, &bytesafter,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
226 &version) != Success) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
227 return NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
228 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
229
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
230 if (!version) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
231 return NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
232 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
233
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
234 retval = g_strdup(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
235 XFree(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
236
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
237 return retval;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
238 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
239
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
240 static GdkWindow *mozilla_remote_find_window()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
241 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
242 int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
243 Window root = VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display));
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
244 Window root2, parent, *kids;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
245 unsigned int nkids;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
246 Window result = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
247 Window tenative = 0;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
248 unsigned char *tenative_version = 0, *version = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
249 static GdkWindow *remote_window = NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
250
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
251 if (remote_window != NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
252 version = window_check_mozilla_version(GDK_WINDOW_XID(remote_window));
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
253
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
254 if (version != NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
255 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
256 return remote_window;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
257 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
258 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
259
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
260 gdk_window_destroy(remote_window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
261 remote_window = NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
262 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
263
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
264 if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
265 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
266 "%s: XQueryTree failed on display %s\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
267 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
268 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
269 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
270
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
271 /* root != root2 is possible with virtual root WMs. */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
272
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
273 if (!(kids && nkids)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
274 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
275 "%s: root window has no children on display %s\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
276 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
277 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
278 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
279
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
280 for (i = nkids - 1; i >= 0; i--) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
281 Window w = GClientWindow(gdk_display, kids[i]);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
282
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
283 version = window_check_mozilla_version(w);
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
284
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
285 if (version == NULL) {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
286 continue;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
287 }
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
288
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
289 if (strcmp((char *)version, expected_mozilla_version) && !tenative) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
290 tenative = w;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
291 tenative_version = version;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
292 continue;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
293 }
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
294
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
295 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
296
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
297 result = w;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
298 break;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
299 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
300
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
301 XFree(kids);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
302
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
303 if (result && tenative) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
304 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
305 "%s: both version %s (0x%x) and version %s (%0x%x) "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
306 "are running. Using version %s.\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
307 progname, tenative_version, (unsigned int)tenative,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
308 expected_mozilla_version, (unsigned int)result,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
309 expected_mozilla_version);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
310 XFree(tenative_version);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
311 return gdk_window_foreign_new(result);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
312 } else if (tenative) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
313 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
314 "%s: expected version %s but found version %s (0x%x) "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
315 "instead.\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
316 progname, expected_mozilla_version,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
317 tenative_version, (unsigned int)tenative);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
318 XFree(tenative_version);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
319 return gdk_window_foreign_new(tenative);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
320 } else if (result) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
321 return gdk_window_foreign_new(result);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
322 } else {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
323 gaim_debug(GAIM_DEBUG_ERROR, "%s: not running on display %s\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
324 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
325 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
326 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
327 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
328
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
329
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
330 static const char *get_lock_data() {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
331 static char *lock_data = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
332
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
333 if (lock_data == NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
334 char hostname[HOST_NAME_MAX + 1] = {0};
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
335
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
336 if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
337 lock_data = g_strdup_printf("pid%d@%s", getpid(), hostname);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
338 } else {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
339 lock_data = g_strdup_printf("pid%d", getpid());
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
340 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
341 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
342
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
343 return lock_data;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
344 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
345
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5213
diff changeset
346 #if 0
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
347 static void mozilla_remote_obtain_lock(GdkWindow * window)
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
348 {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
349 gboolean locked = False;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
350 const char *lock_data = get_lock_data();
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
351 GdkAtom actual_type;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
352 gint actual_format;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
353 gint nitems;
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
354 unsigned char *data = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
355
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
356 gdk_x11_grab_server();
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
357 if (!gdk_property_get(window, GDKA_MOZILLA_LOCK,
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
358 gdk_x11_xatom_to_atom (XA_STRING), 0,
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
359 (65536 / sizeof(long)), 0,
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
360 &actual_type, &actual_format, &nitems, &data)) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
361
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
362 /* It's not now locked - lock it. */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
363 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
364 "%s: writing " MOZILLA_LOCK_PROP " \"%s\" to 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
365 progname, lock_data, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
367 gdk_property_change(window, GDKA_MOZILLA_LOCK,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
368 gdk_x11_xatom_to_atom (XA_STRING),
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
369 8, PropModeReplace,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
370 (unsigned char *)lock_data, strlen(lock_data));
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
371 locked = True;
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
372 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
373
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
374 if (data)
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
375 g_free(data);
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
376
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
377 gdk_x11_ungrab_server();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 }
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5213
diff changeset
379 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
380
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
381 static void mozilla_remote_free_lock(GdkWindow * window)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
382 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
383 int result = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
384 GdkAtom actual_type;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
385 gint actual_format;
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
386 gint nitems;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
387 unsigned char *data = 0;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
388 const char *lock_data = get_lock_data();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
389
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
390 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
391 "%s: deleting " MOZILLA_LOCK_PROP " \"%s\" from 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
392 progname, lock_data, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
394 result = gdk_property_get(window, GDKA_MOZILLA_LOCK,
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
395 gdk_x11_xatom_to_atom (XA_STRING),
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
396 0, (65536 / sizeof(long)),
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
397 1, &actual_type, &actual_format, &nitems, &data);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
398
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
399 if (result != TRUE) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
400 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
401 "%s: Unable to read and delete " MOZILLA_LOCK_PROP
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
402 " property\n", progname);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
403 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
404 } else if (!data || !*data) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
405 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
406 "%s: Invalid data on " MOZILLA_LOCK_PROP
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
407 " of wnidow 0x%x\n", progname, (unsigned int)window);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
408 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
409 } else if (strcmp((char *)data, lock_data)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
410 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
411 "%s: " MOZILLA_LOCK_PROP " was stolen! Expected \"%s\", "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
412 "saw \"%s\"!\n", progname, lock_data, data);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
413 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
414 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
415
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
416 XFree(data);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
417 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
418
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
419 static GdkFilterReturn netscape_response_cb(XEvent *event, GdkEvent *translated, GdkWindow *window)
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
420 {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
421 Atom actual_type, mozilla_response;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
422 Window xid;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
423 int actual_format;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
424 unsigned long nitems, bytes_after;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
425 unsigned char *data = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
426
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
427 if (window == NULL || GDK_WINDOW_OBJECT(window)->destroyed) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
428 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
429 _("Communication with the browser failed. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
430 "Please close all windows and try again."), NULL);
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
431 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
432 "netscape_response_cb called with NULL window.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
433 return GDK_FILTER_CONTINUE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
434 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
435
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
436 mozilla_response = gdk_x11_atom_to_xatom(GDKA_MOZILLA_RESPONSE);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
437 xid = GDK_WINDOW_XID(window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
438
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
439 /* If the event isn't what we want then let gtk handle it */
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
440 if (event->xany.type != PropertyNotify ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
441 event->xproperty.state != PropertyNewValue ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
442 event->xproperty.window != xid ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
443 event->xproperty.atom != mozilla_response) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
444 return GDK_FILTER_CONTINUE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
445 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
446
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
447 if (XGetWindowProperty (gdk_display, xid, mozilla_response,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
448 0, (65536 / sizeof (long)),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
449 True,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
450 XA_STRING,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
451 &actual_type, &actual_format,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
452 &nitems, &bytes_after,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
453 &data) != Success
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
454 || data == NULL || (data[0] != '1' && data[0] != '2')) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
455
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
456 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
457 _("Communication with the browser failed. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
458 "Please close all windows and try again."), NULL);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
459 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
460
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
461 if (data[0] == '1') {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
462 /* Netscape isn't ready yet */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
463 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
464 "Remote Netscape window isn't ready yet.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
465 return GDK_FILTER_REMOVE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
466 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
467
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
468 if (data[0] == '2') {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
469 /* Yay! It worked */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
470 gaim_debug(GAIM_DEBUG_INFO, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
471 "Successfully sent command to remote Netscape window.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
472 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
473
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
474 gdk_window_remove_filter(window, (GdkFilterFunc) netscape_response_cb, window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
475 mozilla_remote_free_lock(window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
476 netscape_lock = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
477 return GDK_FILTER_REMOVE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
478 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
479
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
480 static void mozilla_remote_command(GdkWindow * window, const char *command, Bool raise_p)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
481 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
482 char *new_command = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
483
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
484 /* The -noraise option is implemented by passing a "noraise" argument
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
485 to each command to which it should apply.
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
486 */
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
487 if (!raise_p) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
488 char *close;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
489 new_command = g_malloc(strlen(command) + 20);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
490 strcpy(new_command, command);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
491 close = strrchr(new_command, ')');
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
492 if (close)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
493 strcpy(close, ", noraise)");
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
494 else
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
495 strcat(new_command, "(noraise)");
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
496 command = new_command;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
497 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
498
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
499 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
500 "%s: Writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
501 progname, command, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
503 gdk_property_change(window, GDKA_MOZILLA_COMMAND,
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
504 gdk_x11_xatom_to_atom (XA_STRING),
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
505 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
506
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
507 gdk_window_add_filter(window, (GdkFilterFunc) netscape_response_cb, window);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
508 }
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
509
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
510 static gboolean netscape_command(const char *command)
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
511 {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
512 GdkWindow *window = NULL;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
513
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
514 if (netscape_lock) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
515 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
516 "netscape_command() is currently in use.\n");
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
517 return FALSE;
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
518 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
519
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
520 netscape_lock = 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
521
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
522 mozilla_remote_init_atoms();
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
523 window = mozilla_remote_find_window();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
524
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
525 if (window == NULL || (GDK_WINDOW_OBJECT(window)->destroyed == TRUE)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
526 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
527 "Remote window absent or unsuitable.\n");
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
528 netscape_lock = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
529 return FALSE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
530 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
531
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
532 mozilla_remote_command(window, command, False);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
533
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
534 netscape_lock = 0;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
535 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
537
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
538 void open_url(GtkWidget *w, char *url)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
539 {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
540 char *command = NULL;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
541 GError *error = NULL;
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
542
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
543 switch (web_browser) {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
544 case BROWSER_NETSCAPE: {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
545 char *args = NULL;
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
546
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
547 if (misc_options & OPT_MISC_BROWSER_POPUP)
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
548 args = g_strdup_printf("OpenURL(%s, new-window)", url);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
549 else
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
550 args = g_strdup_printf("OpenURL(%s)", url);
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
552 if (netscape_command(args)) {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
553 g_free(args);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
554 return;
2827
51999a36c0b1 [gaim-migrate @ 2840]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2781
diff changeset
555 }
2566
6d00c0f8bfc5 [gaim-migrate @ 2579]
Rob Flynn <gaim@robflynn.com>
parents: 2478
diff changeset
556
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
557 /* if netscape is running ...
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
558 command = g_strdup_printf("netscape -remote %s", args); */
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
559
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
560 command = g_strdup_printf("netscape \"%s\"", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
561 g_free(args);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
562 } break;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
563
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
564 case BROWSER_OPERA:
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
565 if (misc_options & OPT_MISC_BROWSER_POPUP)
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
566 command = g_strdup_printf("opera -newwindow \"%s\"", url);
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
567 else
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
568 command = g_strdup_printf("opera \"%s\"", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
569 break;
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
570
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
571 case BROWSER_KONQ:
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
572 command = g_strdup_printf("kfmclient openURL \"%s\"", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
573 break;
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
574
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
575 case BROWSER_GALEON:
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
576 if (misc_options & OPT_MISC_BROWSER_POPUP)
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
577 command = g_strdup_printf("galeon -w \"%s\"", url);
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
578 else
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
579 command = g_strdup_printf("galeon \"%s\"", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
580 break;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
581
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
582 case BROWSER_MOZILLA:
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
583 command = g_strdup_printf("mozilla \"%s\"", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
584 break;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
585
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
586 case BROWSER_MANUAL: {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
587 char *space_free_url = NULL;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
588
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
589 if (!web_command[0]) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
590 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
591 _("Unable to launch your browser because "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
592 "the 'Manual' browser command has been "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
593 "chosen, but no command has been set."),
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
594 NULL);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
595 return;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
596 }
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
597
4580
3fef2d45dce0 [gaim-migrate @ 4861]
Luke Schierer <lschiere@pidgin.im>
parents: 4551
diff changeset
598 space_free_url = g_strdup(url);
3fef2d45dce0 [gaim-migrate @ 4861]
Luke Schierer <lschiere@pidgin.im>
parents: 4551
diff changeset
599 g_strdelimit(space_free_url, " ", '+');
4885
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
600 if(strstr(web_command, "%s"))
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
601 command = g_strdup_printf(web_command, space_free_url);
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
602 else
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
603 command = g_strdup_printf("%s %s", web_command, space_free_url);
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
604 g_free(space_free_url);
1bf59e3ac4ff [gaim-migrate @ 5215]
Nathan Walp <nwalp@pidgin.im>
parents: 4580
diff changeset
605 } break;
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
606 }
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
607
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
608 if (g_spawn_command_line_async(command, &error) == FALSE) {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
609 char *tmp = g_strdup_printf(_("There was an error launching your chosen browser: %s"), error->message);
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
610 gaim_notify_error(NULL, NULL, tmp, NULL);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
611 g_free(tmp);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
612 g_error_free(error);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
613 }
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
614
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
615 g_free(command);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
616 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
617
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
618 void add_bookmark(GtkWidget *w, char *url)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
619 {
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
620 if (web_browser == BROWSER_NETSCAPE) {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
621 char *command = g_strdup_printf("AddBookmark(%s)", url);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
622
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
623 netscape_command(command);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624 g_free(command);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
625 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
626 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
627
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
628 #else
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
629
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
630 /* Sooner or later, I shall support Windows clicking! */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
631
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
632 void add_bookmark(GtkWidget *w, char *url)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
633 {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
634 }
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
635 void open_url(GtkWidget *w, char *url)
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
636 {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
637 ShellExecute(NULL, NULL, url, NULL, ".\\", 0);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
638 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
639
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
640
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
641 #endif /* _WIN32 */