annotate src/browser.c @ 6092:35560e017fa1

[gaim-migrate @ 6551] This fixes the buddy icon deletion issue, mad props go to Herman for finding the cause of this. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 11 Jul 2003 22:00:01 +0000
parents b77c0feec150
children 8f94cce8faa5
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 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
28 #include "internal.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
30 #include <gdk/gdkprivate.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
32 #include "debug.h"
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
33 #include "notify.h"
5545
7a64114641c3 [gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents: 5515
diff changeset
34 #include "prefs.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5560
diff changeset
35 #include "util.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
36
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
37 #ifndef _WIN32
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 #include <X11/Xlib.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include <X11/Xatom.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 static const char *progname = "gaim";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 static const char *expected_mozilla_version = "1.1";
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44 #define MOZILLA_VERSION_PROP "_MOZILLA_VERSION"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 #define MOZILLA_LOCK_PROP "_MOZILLA_LOCK"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 #define MOZILLA_COMMAND_PROP "_MOZILLA_COMMAND"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 #define MOZILLA_RESPONSE_PROP "_MOZILLA_RESPONSE"
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
49 static GdkAtom GDKA_MOZILLA_VERSION = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
50 static GdkAtom GDKA_MOZILLA_LOCK = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
51 static GdkAtom GDKA_MOZILLA_COMMAND = 0;
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
52 static GdkAtom GDKA_MOZILLA_RESPONSE = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
53
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
54 static char *window_check_mozilla_version(Window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
55 static const char *get_lock_data();
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
56 static GdkFilterReturn netscape_response_cb(XEvent *, GdkEvent *, GdkWindow *);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
57 static gboolean netscape_command(const char *);
1
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 static int netscape_lock;
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
62 static Window VirtualRootWindowOfScreen(screen)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
63 Screen *screen;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
65 static Screen *save_screen = (Screen *) 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
66 static Window root = (Window) 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
68 if (screen != save_screen) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
69 Display *dpy = DisplayOfScreen(screen);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
70 Atom __SWM_VROOT = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
71 unsigned int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
72 Window rootReturn, parentReturn, *children;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
73 unsigned int numChildren;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
74
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
75 root = RootWindowOfScreen(screen);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
76
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
77 /* go look for a virtual root */
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
78 __SWM_VROOT = XInternAtom(dpy, "__SWM_VROOT", False);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
79 if (XQueryTree(dpy, root, &rootReturn, &parentReturn, &children, &numChildren)) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
80 for (i = 0; i < numChildren; i++) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
81 Atom actual_type;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
82 int actual_format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
83 unsigned long nitems, bytesafter;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
84 Window *newRoot = (Window *) 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
85
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
86 if (XGetWindowProperty(dpy, children[i],
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
87 __SWM_VROOT, 0, 1, False, XA_WINDOW,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
88 &actual_type, &actual_format,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
89 &nitems, &bytesafter,
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
90 (unsigned char **)&newRoot) == Success
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
91 && newRoot) {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
92 root = *newRoot;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
93 break;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
94 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
95 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
96 if (children)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
97 XFree((char *)children);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
98 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
99
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
100 save_screen = screen;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
101 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
102
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
103 return root;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106 /* The following code is Copyright (C) 1989 X Consortium */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
107
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
108 static Window TryChildren();
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
109
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
110 /* 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
111
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
112 static Window GClientWindow(dpy, win)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
113 Display *dpy;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
114 Window win;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
115 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
116 Atom WM_STATE;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
117 Atom type = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
118 int format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
119 unsigned long nitems, after;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
120 unsigned char *data;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
121 Window inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
122
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
123 WM_STATE = XInternAtom(dpy, "WM_STATE", True);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
124 if (!WM_STATE)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
125 return win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
126 XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
127 &type, &format, &nitems, &after, &data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
128 if (type) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
129 XFree(data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
130 return win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
131 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
132
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
133 inf = TryChildren(dpy, win, WM_STATE);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
134 if (!inf)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
135 inf = win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
136
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
137 XFree(data);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
138
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
139 return inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
140 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
141
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
142 static
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
143 Window TryChildren(dpy, win, WM_STATE)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
144 Display *dpy;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
145 Window win;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
146 Atom WM_STATE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
147 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
148 Window root, parent;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
149 Window *children;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
150 unsigned int nchildren;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
151 unsigned int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
152 Atom type = None;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
153 int format;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
154 unsigned long nitems, after;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
155 unsigned char *data;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
156 Window inf = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
157
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
158 if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren))
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
159 return 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
160 for (i = 0; !inf && (i < nchildren); i++) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
161 XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False,
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
162 AnyPropertyType, &type, &format, &nitems, &after, &data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
163 if (type)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
164 inf = children[i];
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
165
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
166 XFree(data);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
167 }
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
168 for (i = 0; !inf && (i < nchildren); i++)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
169 inf = TryChildren(dpy, children[i], WM_STATE);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
170 if (children)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
171 XFree((char *)children);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
172 return inf;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
173 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
174
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
175 /* END X Consortium code */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
176
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
177
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179 static void mozilla_remote_init_atoms()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 {
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
181 if (!GDKA_MOZILLA_VERSION)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
182 GDKA_MOZILLA_VERSION = gdk_atom_intern(MOZILLA_VERSION_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
183 if (!GDKA_MOZILLA_LOCK)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
184 GDKA_MOZILLA_LOCK = gdk_atom_intern(MOZILLA_LOCK_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
185 if (!GDKA_MOZILLA_COMMAND)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
186 GDKA_MOZILLA_COMMAND = gdk_atom_intern(MOZILLA_COMMAND_PROP, 0);
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
187 if (!GDKA_MOZILLA_RESPONSE)
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
188 GDKA_MOZILLA_RESPONSE = gdk_atom_intern(MOZILLA_RESPONSE_PROP, 0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
191 static char *window_check_mozilla_version(Window window) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
192
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
193 Atom type;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
194 int format;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
195 unsigned long nitems, bytesafter;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
196 unsigned char *version = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
197 gchar *retval = NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
198
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
199 if (XGetWindowProperty(gdk_display, window,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
200 gdk_x11_atom_to_xatom(GDKA_MOZILLA_VERSION),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
201 0, (65536 / sizeof(long)),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
202 False, XA_STRING,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
203 &type, &format, &nitems, &bytesafter,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
204 &version) != Success) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
205 return NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
206 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
207
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
208 if (!version) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
209 return NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
210 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
211
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
212 retval = g_strdup(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
213 XFree(version);
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 return retval;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
216 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
217
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
218 static GdkWindow *mozilla_remote_find_window()
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
219 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
220 int i;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
221 Window root = VirtualRootWindowOfScreen(DefaultScreenOfDisplay(gdk_display));
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
222 Window root2, parent, *kids;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
223 unsigned int nkids;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
224 Window result = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
225 Window tenative = 0;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
226 unsigned char *tenative_version = 0, *version = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
227 static GdkWindow *remote_window = 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 if (remote_window != NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
230 version = window_check_mozilla_version(GDK_WINDOW_XID(remote_window));
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
231
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
232 if (version != NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
233 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
234 return remote_window;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
235 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
236 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
237
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
238 gdk_window_destroy(remote_window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
239 remote_window = NULL;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
240 }
1
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 if (!XQueryTree(gdk_display, root, &root2, &parent, &kids, &nkids)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
243 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
244 "%s: XQueryTree failed on display %s\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
245 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
246 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
247 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
248
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
249 /* root != root2 is possible with virtual root WMs. */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
250
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
251 if (!(kids && nkids)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
252 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
253 "%s: root window has no children on display %s\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
254 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
255 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
256 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
257
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
258 for (i = nkids - 1; i >= 0; i--) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
259 Window w = GClientWindow(gdk_display, kids[i]);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
260
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
261 version = window_check_mozilla_version(w);
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
262
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
263 if (version == NULL) {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
264 continue;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
265 }
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
266
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
267 if (strcmp((char *)version, expected_mozilla_version) && !tenative) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
268 tenative = w;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
269 tenative_version = version;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
270 continue;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
271 }
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
272
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
273 g_free(version);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
274
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
275 result = w;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
276 break;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
277 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
278
26
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
279 XFree(kids);
b9e90a914e20 [gaim-migrate @ 35]
Rob Flynn <gaim@robflynn.com>
parents: 1
diff changeset
280
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
281 if (result && tenative) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
282 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
283 "%s: both version %s (0x%x) and version %s (%0x%x) "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
284 "are running. Using version %s.\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
285 progname, tenative_version, (unsigned int)tenative,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
286 expected_mozilla_version, (unsigned int)result,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
287 expected_mozilla_version);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
288 XFree(tenative_version);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
289 return gdk_window_foreign_new(result);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
290 } else if (tenative) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
291 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
292 "%s: expected version %s but found version %s (0x%x) "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
293 "instead.\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
294 progname, expected_mozilla_version,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
295 tenative_version, (unsigned int)tenative);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
296 XFree(tenative_version);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
297 return gdk_window_foreign_new(tenative);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
298 } else if (result) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
299 return gdk_window_foreign_new(result);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
300 } else {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
301 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
302 progname, DisplayString(gdk_display));
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
303 return NULL;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
304 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
306
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
307
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
308 static const char *get_lock_data() {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
309 static char *lock_data = NULL;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
310
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
311 if (lock_data == NULL) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
312 char hostname[HOST_NAME_MAX + 1] = {0};
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
313
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
314 if (gethostname(hostname, HOST_NAME_MAX + 1) == 0) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
315 lock_data = g_strdup_printf("pid%d@%s", getpid(), hostname);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
316 } else {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
317 lock_data = g_strdup_printf("pid%d", getpid());
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
318 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
319 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
320
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
321 return lock_data;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
322 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
323
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5213
diff changeset
324 #if 0
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
325 static void mozilla_remote_obtain_lock(GdkWindow * window)
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
326 {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
327 gboolean locked = False;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
328 const char *lock_data = get_lock_data();
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
329 GdkAtom actual_type;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
330 gint actual_format;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
331 gint nitems;
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
332 unsigned char *data = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
333
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
334 gdk_x11_grab_server();
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
335 if (!gdk_property_get(window, GDKA_MOZILLA_LOCK,
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
336 gdk_x11_xatom_to_atom (XA_STRING), 0,
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
337 (65536 / sizeof(long)), 0,
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
338 &actual_type, &actual_format, &nitems, &data)) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
339
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
340 /* It's not now locked - lock it. */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
341 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
342 "%s: writing " MOZILLA_LOCK_PROP " \"%s\" to 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
343 progname, lock_data, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
344
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
345 gdk_property_change(window, GDKA_MOZILLA_LOCK,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
346 gdk_x11_xatom_to_atom (XA_STRING),
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
347 8, PropModeReplace,
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
348 (unsigned char *)lock_data, strlen(lock_data));
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
349 locked = True;
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
350 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
351
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
352 if (data)
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
353 g_free(data);
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
354
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
355 gdk_x11_ungrab_server();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
356 }
5435
a2f26666de42 [gaim-migrate @ 5817]
Mark Doliner <mark@kingant.net>
parents: 5213
diff changeset
357 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
358
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
359 static void mozilla_remote_free_lock(GdkWindow * window)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
360 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
361 int result = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
362 GdkAtom actual_type;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
363 gint actual_format;
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
364 gint nitems;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
365 unsigned char *data = 0;
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
366 const char *lock_data = get_lock_data();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
367
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
368 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
369 "%s: deleting " MOZILLA_LOCK_PROP " \"%s\" from 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
370 progname, lock_data, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
371
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
372 result = gdk_property_get(window, GDKA_MOZILLA_LOCK,
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
373 gdk_x11_xatom_to_atom (XA_STRING),
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
374 0, (65536 / sizeof(long)),
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
375 1, &actual_type, &actual_format, &nitems, &data);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
376
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
377 if (result != TRUE) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
378 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
379 "%s: Unable to read and delete " MOZILLA_LOCK_PROP
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
380 " property\n", progname);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
381 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
382 } else if (!data || !*data) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
383 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
384 "%s: Invalid data on " MOZILLA_LOCK_PROP
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
385 " of wnidow 0x%x\n", progname, (unsigned int)window);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
386 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
387 } else if (strcmp((char *)data, lock_data)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
388 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
389 "%s: " MOZILLA_LOCK_PROP " was stolen! Expected \"%s\", "
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
390 "saw \"%s\"!\n", progname, lock_data, data);
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
391 return;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
392 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
393
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
394 XFree(data);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
395 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
396
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
397 static GdkFilterReturn netscape_response_cb(XEvent *event, GdkEvent *translated, GdkWindow *window)
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 Atom actual_type, mozilla_response;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
400 Window xid;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
401 int actual_format;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
402 unsigned long nitems, bytes_after;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
403 unsigned char *data = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
404
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
405 if (window == NULL || GDK_WINDOW_OBJECT(window)->destroyed) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
406 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
407 _("Communication with the browser failed. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
408 "Please close all windows and try again."), NULL);
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
409 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
410 "netscape_response_cb called with NULL window.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
411 return GDK_FILTER_CONTINUE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
412 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
413
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
414 mozilla_response = gdk_x11_atom_to_xatom(GDKA_MOZILLA_RESPONSE);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
415 xid = GDK_WINDOW_XID(window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
416
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
417 /* 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
418 if (event->xany.type != PropertyNotify ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
419 event->xproperty.state != PropertyNewValue ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
420 event->xproperty.window != xid ||
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
421 event->xproperty.atom != mozilla_response) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
422 return GDK_FILTER_CONTINUE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
423 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
424
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
425 if (XGetWindowProperty (gdk_display, xid, mozilla_response,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
426 0, (65536 / sizeof (long)),
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
427 True,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
428 XA_STRING,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
429 &actual_type, &actual_format,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
430 &nitems, &bytes_after,
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
431 &data) != Success
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
432 || data == NULL || (data[0] != '1' && data[0] != '2')) {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
433
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
434 gaim_notify_error(NULL, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
435 _("Communication with the browser failed. "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5435
diff changeset
436 "Please close all windows and try again."), NULL);
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
437 }
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 (data[0] == '1') {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
440 /* Netscape isn't ready yet */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
441 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
442 "Remote Netscape window isn't ready yet.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
443 return GDK_FILTER_REMOVE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
444 }
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 if (data[0] == '2') {
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
447 /* Yay! It worked */
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
448 gaim_debug(GAIM_DEBUG_INFO, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
449 "Successfully sent command to remote Netscape window.\n");
4428
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
450 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
451
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
452 gdk_window_remove_filter(window, (GdkFilterFunc) netscape_response_cb, window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
453 mozilla_remote_free_lock(window);
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
454 netscape_lock = 0;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
455 return GDK_FILTER_REMOVE;
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
456 }
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
457
b5669740e34c [gaim-migrate @ 4703]
Sean Egan <seanegan@gmail.com>
parents: 4189
diff changeset
458 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
459 {
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
460 char *new_command = 0;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
461
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
462 /* The -noraise option is implemented by passing a "noraise" argument
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
463 to each command to which it should apply.
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
464 */
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
465 if (!raise_p) {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
466 char *close;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
467 new_command = g_malloc(strlen(command) + 20);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
468 strcpy(new_command, command);
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
469 close = strrchr(new_command, ')');
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
470 if (close)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
471 strcpy(close, ", noraise)");
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
472 else
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
473 strcat(new_command, "(noraise)");
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
474 command = new_command;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
475 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
476
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
477 gaim_debug(GAIM_DEBUG_MISC, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
478 "%s: Writing " MOZILLA_COMMAND_PROP " \"%s\" to 0x%x\n",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
479 progname, command, (unsigned int)window);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
480
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
481 gdk_property_change(window, GDKA_MOZILLA_COMMAND,
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
482 gdk_x11_xatom_to_atom (XA_STRING),
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3455
diff changeset
483 8, GDK_PROP_MODE_REPLACE, (unsigned char *)command, strlen(command));
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
484
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
485 gdk_window_add_filter(window, (GdkFilterFunc) netscape_response_cb, window);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
486 }
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
487
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
488 static gboolean netscape_command(const char *command)
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
489 {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
490 GdkWindow *window = NULL;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
491
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
492 if (netscape_lock) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
493 gaim_debug(GAIM_DEBUG_WARNING, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
494 "netscape_command() is currently in use.\n");
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
495 return FALSE;
4430
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
496 }
801830dec409 [gaim-migrate @ 4705]
Luke Schierer <lschiere@pidgin.im>
parents: 4429
diff changeset
497
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
498 netscape_lock = 1;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
499
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
500 mozilla_remote_init_atoms();
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
501 window = mozilla_remote_find_window();
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
502
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
503 if (window == NULL || (GDK_WINDOW_OBJECT(window)->destroyed == TRUE)) {
5213
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
504 gaim_debug(GAIM_DEBUG_ERROR, "browser",
1cf4eb75e3ee [gaim-migrate @ 5583]
Christian Hammond <chipx86@chipx86.com>
parents: 4885
diff changeset
505 "Remote window absent or unsuitable.\n");
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
506 netscape_lock = 0;
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
507 return FALSE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
508 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
509
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
510 mozilla_remote_command(window, command, False);
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 netscape_lock = 0;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
513 return TRUE;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
514 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515
5998
b77c0feec150 [gaim-migrate @ 6446]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
516 void open_url(GtkWidget *w, const char *url)
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
517 {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
518 char *command = NULL;
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
519 GError *error = NULL;
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
520 const char *web_browser;
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
521
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
522 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser");
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
523
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
524 if (!strcmp(web_browser, "netscape")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
525 char *args = NULL;
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
526
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
527 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window"))
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
528 args = g_strdup_printf("OpenURL(%s, new-window)", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
529 else
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
530 args = g_strdup_printf("OpenURL(%s)", url);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
531
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
532 if (netscape_command(args)) {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
533 g_free(args);
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
534 return;
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
535 }
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
536
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
537 /* if netscape is running ...
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
538 command = g_strdup_printf("netscape -remote %s", args); */
4551
f61fb41fd1c4 [gaim-migrate @ 4831]
Nathan Walp <nwalp@pidgin.im>
parents: 4431
diff changeset
539
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
540 command = g_strdup_printf("netscape \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
541 g_free(args);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
542 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
543 else if (!strcmp(web_browser, "opera")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
544 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window"))
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
545 command = g_strdup_printf("opera -newwindow \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
546 else
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
547 command = g_strdup_printf("opera \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
548 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
549 else if (!strcmp(web_browser, "kfmclient")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
550 command = g_strdup_printf("kfmclient openURL \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
551 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
552 else if (!strcmp(web_browser, "galeon")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
553 if (gaim_prefs_get_bool("/gaim/gtk/browsers/new_window"))
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
554 command = g_strdup_printf("galeon -w \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
555 else
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
556 command = g_strdup_printf("galeon \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
557 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
558 else if (!strcmp(web_browser, "mozilla")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
559 command = g_strdup_printf("mozilla \"%s\"", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
560 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
561 else if (!strcmp(web_browser, "custom")) {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
562 const char *web_command;
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
563
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
564
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
565 web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command");
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
566
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
567 if (web_command == NULL || *web_command == '\0') {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
568 gaim_notify_error(NULL, NULL,
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
569 _("Unable to launch your browser because "
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
570 "the 'Manual' browser command has been "
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
571 "chosen, but no command has been set."),
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
572 NULL);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
573 return;
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
574 }
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
575
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
576 if (strstr(web_command, "%s"))
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
577 command = gaim_strreplace(web_command, "%s", url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
578 else {
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
579 /* There is no "%s" in the browser command. Assume the user
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
580 * wanted the URL tacked on to the end of the command. */
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
581 command = g_strdup_printf("%s %s", web_command, url);
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
582 }
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
583 }
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
584
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
585 if (g_spawn_command_line_async(command, &error) == FALSE) {
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
586 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
587 gaim_notify_error(NULL, NULL, tmp, NULL);
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
588 g_free(tmp);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
589 g_error_free(error);
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
590 }
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
591
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
592 g_free(command);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
593 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
594
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
595 void add_bookmark(GtkWidget *w, char *url)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
596 {
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
597 const char *web_browser;
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
598
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
599 web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser");
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
600
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
601 if (!strcmp(web_browser, "netscape")) {
4431
50ef0203fdbf [gaim-migrate @ 4706]
Luke Schierer <lschiere@pidgin.im>
parents: 4430
diff changeset
602 char *command = g_strdup_printf("AddBookmark(%s)", url);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
603
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
604 netscape_command(command);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
605 g_free(command);
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
606 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
607 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
608
5560
b7319c094153 [gaim-migrate @ 5961]
Christian Hammond <chipx86@chipx86.com>
parents: 5545
diff changeset
609 #else /* _WIN32 */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
610
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
611 /* Sooner or later, I shall support Windows clicking! */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
612
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
613 void add_bookmark(GtkWidget *w, char *url)
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
614 {
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
615 }
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
616 void open_url(GtkWidget *w, char *url)
1250
b5783215b245 [gaim-migrate @ 1260]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1181
diff changeset
617 {
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3554
diff changeset
618 ShellExecute(NULL, NULL, url, NULL, ".\\", 0);
1250
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
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2099
diff changeset
621 #endif /* _WIN32 */