Mercurial > pidgin.yaz
comparison gtk/win32/gtkwin32dep.c @ 14224:ab8a105eff62
[gaim-migrate @ 16905]
First step of getting wingaim working again.
libgaim and gtk are compiling.
The protocols aren't compiling yet.
There are a number of things that are compiling, but should be cleaned up.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Sun, 20 Aug 2006 16:49:37 +0000 |
parents | |
children | 14933d9055a0 |
comparison
equal
deleted
inserted
replaced
14223:7c560c01b8f9 | 14224:ab8a105eff62 |
---|---|
1 /* | |
2 * gaim | |
3 * | |
4 * File: gtkwin32dep.c | |
5 * Date: June, 2002 | |
6 * Description: Windows dependant code for Gaim | |
7 * | |
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com> | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * This program is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
23 * | |
24 */ | |
25 #define _WIN32_IE 0x500 | |
26 #include <windows.h> | |
27 #include <io.h> | |
28 #include <stdlib.h> | |
29 #include <stdio.h> | |
30 #include <winuser.h> | |
31 | |
32 #include <glib.h> | |
33 #include <glib/gstdio.h> | |
34 #include <gtk/gtk.h> | |
35 | |
36 #include "gaim.h" | |
37 #include "debug.h" | |
38 #include "notify.h" | |
39 | |
40 #include "resource.h" | |
41 #include "idletrack.h" | |
42 #include "zlib.h" | |
43 #include "untar.h" | |
44 | |
45 #include <libintl.h> | |
46 | |
47 #include "gtkwin32dep.h" | |
48 | |
49 #include "wspell.h" | |
50 | |
51 /* | |
52 * GLOBALS | |
53 */ | |
54 HINSTANCE gaimexe_hInstance = 0; | |
55 HINSTANCE gtkgaimdll_hInstance = 0; | |
56 | |
57 /* | |
58 * PUBLIC CODE | |
59 */ | |
60 | |
61 HINSTANCE gtkwgaim_hinstance(void) { | |
62 return gaimexe_hInstance; | |
63 } | |
64 | |
65 int gtkwgaim_gz_decompress(const char* in, const char* out) { | |
66 gzFile fin; | |
67 FILE *fout; | |
68 char buf[1024]; | |
69 int ret; | |
70 | |
71 if((fin = gzopen(in, "rb"))) { | |
72 if(!(fout = g_fopen(out, "wb"))) { | |
73 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out); | |
74 gzclose(fin); | |
75 return 0; | |
76 } | |
77 } | |
78 else { | |
79 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in); | |
80 return 0; | |
81 } | |
82 | |
83 while((ret = gzread(fin, buf, 1024))) { | |
84 if(fwrite(buf, 1, ret, fout) < ret) { | |
85 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret); | |
86 gzclose(fin); | |
87 fclose(fout); | |
88 return 0; | |
89 } | |
90 } | |
91 fclose(fout); | |
92 gzclose(fin); | |
93 | |
94 if(ret < 0) { | |
95 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in); | |
96 return 0; | |
97 } | |
98 | |
99 return 1; | |
100 } | |
101 | |
102 int gtkwgaim_gz_untar(const char* filename, const char* destdir) { | |
103 char tmpfile[_MAX_PATH]; | |
104 char template[]="wgaimXXXXXX"; | |
105 | |
106 sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template)); | |
107 if(gtkwgaim_gz_decompress(filename, tmpfile)) { | |
108 int ret; | |
109 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) | |
110 ret = 1; | |
111 else { | |
112 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile); | |
113 ret = 0; | |
114 } | |
115 g_unlink(tmpfile); | |
116 return ret; | |
117 } | |
118 else { | |
119 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename); | |
120 return 0; | |
121 } | |
122 } | |
123 | |
124 void gtkwgaim_notify_uri(const char *uri) { | |
125 | |
126 /* We'll allow whatever URI schemes are supported by the | |
127 * default http browser. | |
128 */ | |
129 | |
130 if (G_WIN32_HAVE_WIDECHAR_API()) { | |
131 SHELLEXECUTEINFOW wsinfo; | |
132 wchar_t *w_uri; | |
133 | |
134 w_uri = g_utf8_to_utf16(uri, -1, NULL, NULL, NULL); | |
135 | |
136 memset(&wsinfo, 0, sizeof(wsinfo)); | |
137 wsinfo.cbSize = sizeof(wsinfo); | |
138 wsinfo.fMask = SEE_MASK_CLASSNAME; | |
139 wsinfo.lpVerb = L"open"; | |
140 wsinfo.lpFile = w_uri; | |
141 wsinfo.nShow = SW_SHOWNORMAL; | |
142 wsinfo.lpClass = L"http"; | |
143 | |
144 gaim_debug(GAIM_DEBUG_INFO, "wgaim_notify_uri", "The wide uri is %s\n", uri); | |
145 if(!ShellExecuteExW(&wsinfo)) | |
146 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", | |
147 uri, (int) wsinfo.hInstApp); | |
148 | |
149 g_free(w_uri); | |
150 } else { | |
151 SHELLEXECUTEINFOA sinfo; | |
152 gchar *locale_uri; | |
153 | |
154 locale_uri = g_locale_from_utf8(uri, -1, NULL, NULL, NULL); | |
155 | |
156 memset(&sinfo, 0, sizeof(sinfo)); | |
157 sinfo.cbSize = sizeof(sinfo); | |
158 sinfo.fMask = SEE_MASK_CLASSNAME; | |
159 sinfo.lpVerb = "open"; | |
160 sinfo.lpFile = locale_uri; | |
161 sinfo.nShow = SW_SHOWNORMAL; | |
162 sinfo.lpClass = "http"; | |
163 | |
164 if(!ShellExecuteExA(&sinfo)) | |
165 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", | |
166 uri, (int) sinfo.hInstApp); | |
167 | |
168 g_free(locale_uri); | |
169 } | |
170 } | |
171 | |
172 void gtkwgaim_init(HINSTANCE hint) { | |
173 gaim_debug_info("gtkwgaim", "gtkwgaim_init start\n"); | |
174 | |
175 gaimexe_hInstance = hint; | |
176 | |
177 /* IdleTracker Initialization */ | |
178 if(!wgaim_set_idlehooks()) | |
179 gaim_debug(GAIM_DEBUG_ERROR, "gtkwgaim", "Failed to initialize idle tracker\n"); | |
180 | |
181 wgaim_gtkspell_init(); | |
182 gaim_debug_info("gtkwgaim", "GTK+ :%u.%u.%u\n", | |
183 gtk_major_version, gtk_minor_version, gtk_micro_version); | |
184 | |
185 gaim_debug(GAIM_DEBUG_INFO, "gtkwgaim", "gtkwgaim_init end\n"); | |
186 } | |
187 | |
188 /* Windows Cleanup */ | |
189 | |
190 void gtkwgaim_cleanup(void) { | |
191 gaim_debug(GAIM_DEBUG_INFO, "gtkwgaim", "gtkwgaim_cleanup\n"); | |
192 | |
193 /* Idle tracker cleanup */ | |
194 wgaim_remove_idlehooks(); | |
195 | |
196 } | |
197 | |
198 /* DLL initializer */ | |
199 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { | |
200 gtkgaimdll_hInstance = hinstDLL; | |
201 return TRUE; | |
202 } |