annotate gtk/win32/gtkwin32dep.c @ 14263:d7b40a686355

[gaim-migrate @ 16945] Don't call gethostbyname in a thread because it's not thread-safe. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 21 Aug 2006 05:49:20 +0000
parents 14933d9055a0
children 333989477bcd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
1 /*
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
2 * gaim
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
3 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
4 * File: gtkwin32dep.c
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
5 * Date: June, 2002
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
6 * Description: Windows dependant code for Gaim
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
7 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
9 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
13 * (at your option) any later version.
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
14 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
18 * GNU General Public License for more details.
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
19 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
23 *
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
24 */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
25 #define _WIN32_IE 0x500
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
26 #include <windows.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
27 #include <io.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
28 #include <stdlib.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
29 #include <stdio.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
30 #include <winuser.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
31
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
32 #include <glib.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
33 #include <glib/gstdio.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
34 #include <gtk/gtk.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
35
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
36 #include "gaim.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
37 #include "debug.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
38 #include "notify.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
39
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
40 #include "resource.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
41 #include "idletrack.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
42 #include "zlib.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
43 #include "untar.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
44
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
45 #include <libintl.h>
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
46
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
47 #include "gtkwin32dep.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
48
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
49 #include "wspell.h"
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
50
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
51 /*
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
52 * GLOBALS
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
53 */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
54 HINSTANCE gaimexe_hInstance = 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
55 HINSTANCE gtkgaimdll_hInstance = 0;
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
56 HWND messagewin_hwnd;
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
57
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
58 /*
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
59 * PUBLIC CODE
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
60 */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
61
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
62 HINSTANCE gtkwgaim_hinstance(void) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
63 return gaimexe_hInstance;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
64 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
65
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
66 int gtkwgaim_gz_decompress(const char* in, const char* out) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
67 gzFile fin;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
68 FILE *fout;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
69 char buf[1024];
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
70 int ret;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
71
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
72 if((fin = gzopen(in, "rb"))) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
73 if(!(fout = g_fopen(out, "wb"))) {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
74 gaim_debug_error("gtkwgaim_gz_decompress", "Error opening file: %s\n", out);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
75 gzclose(fin);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
76 return 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
77 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
78 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
79 else {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
80 gaim_debug_error("gtkwgaim_gz_decompress", "gzopen failed to open: %s\n", in);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
81 return 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
82 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
83
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
84 while((ret = gzread(fin, buf, 1024))) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
85 if(fwrite(buf, 1, ret, fout) < ret) {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
86 gaim_debug_error("wgaim_gz_decompress", "Error writing %d bytes to file\n", ret);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
87 gzclose(fin);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
88 fclose(fout);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
89 return 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
90 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
91 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
92 fclose(fout);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
93 gzclose(fin);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
94
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
95 if(ret < 0) {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
96 gaim_debug_error("gtkwgaim_gz_decompress", "gzread failed while reading: %s\n", in);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
97 return 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
98 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
99
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
100 return 1;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
101 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
102
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
103 int gtkwgaim_gz_untar(const char* filename, const char* destdir) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
104 char tmpfile[_MAX_PATH];
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
105 char template[]="wgaimXXXXXX";
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
106
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
107 sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template));
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
108 if(gtkwgaim_gz_decompress(filename, tmpfile)) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
109 int ret;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
110 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET))
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
111 ret = 1;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
112 else {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
113 gaim_debug_error("gtkwgaim_gz_untar", "Failure untaring %s\n", tmpfile);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
114 ret = 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
115 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
116 g_unlink(tmpfile);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
117 return ret;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
118 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
119 else {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
120 gaim_debug_error("gtkwgaim_gz_untar", "Failed to gz decompress %s\n", filename);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
121 return 0;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
122 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
123 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
124
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
125 void gtkwgaim_notify_uri(const char *uri) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
126
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
127 /* We'll allow whatever URI schemes are supported by the
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
128 * default http browser.
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
129 */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
130
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
131 if (G_WIN32_HAVE_WIDECHAR_API()) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
132 SHELLEXECUTEINFOW wsinfo;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
133 wchar_t *w_uri;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
134
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
135 w_uri = g_utf8_to_utf16(uri, -1, NULL, NULL, NULL);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
136
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
137 memset(&wsinfo, 0, sizeof(wsinfo));
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
138 wsinfo.cbSize = sizeof(wsinfo);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
139 wsinfo.fMask = SEE_MASK_CLASSNAME;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
140 wsinfo.lpVerb = L"open";
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
141 wsinfo.lpFile = w_uri;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
142 wsinfo.nShow = SW_SHOWNORMAL;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
143 wsinfo.lpClass = L"http";
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
144
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
145 if(!ShellExecuteExW(&wsinfo))
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
146 gaim_debug_error("gtkwgaim", "Error opening URI: %s error: %d\n",
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
147 uri, (int) wsinfo.hInstApp);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
148
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
149 g_free(w_uri);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
150 } else {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
151 SHELLEXECUTEINFOA sinfo;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
152 gchar *locale_uri;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
153
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
154 locale_uri = g_locale_from_utf8(uri, -1, NULL, NULL, NULL);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
155
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
156 memset(&sinfo, 0, sizeof(sinfo));
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
157 sinfo.cbSize = sizeof(sinfo);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
158 sinfo.fMask = SEE_MASK_CLASSNAME;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
159 sinfo.lpVerb = "open";
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
160 sinfo.lpFile = locale_uri;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
161 sinfo.nShow = SW_SHOWNORMAL;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
162 sinfo.lpClass = "http";
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
163
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
164 if(!ShellExecuteExA(&sinfo))
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
165 gaim_debug_error("gtkwgaim", "Error opening URI: %s error: %d\n",
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
166 uri, (int) sinfo.hInstApp);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
167
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
168 g_free(locale_uri);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
169 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
170 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
171
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
172 #define WM_FOCUS_REQUEST (WM_APP + 13)
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
173
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
174 static LRESULT CALLBACK message_window_handler(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
175
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
176 if (msg == WM_FOCUS_REQUEST) {
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
177 gaim_debug_info("gtkwgaim", "Got external Buddy List focus request.");
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
178 gaim_blist_set_visible(TRUE);
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
179 return TRUE;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
180 }
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
181
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
182 return DefWindowProc(hwnd, msg, wparam, lparam);
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
183 }
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
184
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
185 static HWND wgaim_message_window_init(void) {
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
186 HWND win_hwnd;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
187 WNDCLASSEX wcx;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
188 LPCTSTR wname;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
189
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
190 wname = TEXT("WingaimMsgWinCls");
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
191
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
192 wcx.cbSize = sizeof(wcx);
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
193 wcx.style = 0;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
194 wcx.lpfnWndProc = message_window_handler;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
195 wcx.cbClsExtra = 0;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
196 wcx.cbWndExtra = 0;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
197 wcx.hInstance = gtkwgaim_hinstance();
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
198 wcx.hIcon = NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
199 wcx.hCursor = NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
200 wcx.hbrBackground = NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
201 wcx.lpszMenuName = NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
202 wcx.lpszClassName = wname;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
203 wcx.hIconSm = NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
204
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
205 RegisterClassEx(&wcx);
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
206
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
207 /* Create the window */
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
208 if(!(win_hwnd = CreateWindow(wname, TEXT("WingaimMsgWin"), 0, 0, 0, 0, 0,
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
209 NULL, NULL, gtkwgaim_hinstance(), 0))) {
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
210 gaim_debug_error("gtkwgaim",
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
211 "Unable to create message window.\n");
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
212 return NULL;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
213 }
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
214
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
215 return win_hwnd;
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
216 }
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
217
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
218
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
219 void gtkwgaim_init(HINSTANCE hint) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
220 gaim_debug_info("gtkwgaim", "gtkwgaim_init start\n");
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
221
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
222 gaimexe_hInstance = hint;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
223
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
224 /* IdleTracker Initialization */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
225 if(!wgaim_set_idlehooks())
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
226 gaim_debug_error("gtkwgaim", "Failed to initialize idle tracker\n");
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
227
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
228 wgaim_gtkspell_init();
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
229 gaim_debug_info("gtkwgaim", "GTK+ :%u.%u.%u\n",
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
230 gtk_major_version, gtk_minor_version, gtk_micro_version);
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
231
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
232 messagewin_hwnd = wgaim_message_window_init();
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
233
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
234 gaim_debug_info("gtkwgaim", "gtkwgaim_init end\n");
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
235 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
236
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
237 /* Windows Cleanup */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
238
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
239 void gtkwgaim_cleanup(void) {
14257
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
240 gaim_debug_info("gtkwgaim", "gtkwgaim_cleanup\n");
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
241
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
242 if(messagewin_hwnd)
14933d9055a0 [gaim-migrate @ 16939]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 14224
diff changeset
243 DestroyWindow(messagewin_hwnd);
14224
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
244
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
245 /* Idle tracker cleanup */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
246 wgaim_remove_idlehooks();
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
247
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
248 }
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
249
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
250 /* DLL initializer */
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
251 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
252 gtkgaimdll_hInstance = hinstDLL;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
253 return TRUE;
ab8a105eff62 [gaim-migrate @ 16905]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
diff changeset
254 }