comparison src/win32/win32dep.c @ 5854:14891982dbee

[gaim-migrate @ 6285] Update to new prefs api and new debug api. Thanks SimGuy3k committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Fri, 13 Jun 2003 16:49:00 +0000
parents a2acc2b79ff1
children 9657e243d001
comparison
equal deleted inserted replaced
5853:3ed4c7df2f41 5854:14891982dbee
66 return TRUE; 66 return TRUE;
67 } 67 }
68 68
69 static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) { 69 static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) {
70 /* Stop flashing and remove filter */ 70 /* Stop flashing and remove filter */
71 debug_printf("Removing timeout\n"); 71 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n");
72 g_source_remove(finfo->t_handle); 72 g_source_remove(finfo->t_handle);
73 debug_printf("Disconnecting signal handler\n"); 73 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n");
74 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); 74 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler);
75 debug_printf("done\n"); 75 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n");
76 } 76 }
77 77
78 static void load_winver_specific_procs(void) { 78 static void load_winver_specific_procs(void) {
79 /* Used for Win98+ and WinNT5+ */ 79 /* Used for Win98+ and WinNT5+ */
80 MyFlashWindowEx = (void*)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" ); 80 MyFlashWindowEx = (void*)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" );
149 HMODULE hmod; 149 HMODULE hmod;
150 int did_load=0; 150 int did_load=0;
151 FARPROC proc = 0; 151 FARPROC proc = 0;
152 152
153 if(!(hmod=GetModuleHandle(dllname))) { 153 if(!(hmod=GetModuleHandle(dllname))) {
154 debug_printf("%s not found. Loading it..\n", dllname); 154 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not found. Loading it..\n", dllname);
155 if(!(hmod = LoadLibrary(dllname))) { 155 if(!(hmod = LoadLibrary(dllname))) {
156 debug_printf("Could not load: %s\n", dllname); 156 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname);
157 return NULL; 157 return NULL;
158 } 158 }
159 else 159 else
160 did_load = 1; 160 did_load = 1;
161 } 161 }
162 162
163 if((proc=GetProcAddress(hmod, procedure))) { 163 if((proc=GetProcAddress(hmod, procedure))) {
164 debug_printf("This version of %s contains %s\n", 164 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n",
165 dllname, procedure); 165 dllname, procedure);
166 return proc; 166 return proc;
167 } 167 }
168 else { 168 else {
169 debug_printf("Function: %s not found in dll: %s\n", 169 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n",
170 procedure, dllname); 170 procedure, dllname);
171 if(did_load) { 171 if(did_load) {
172 /* unload dll */ 172 /* unload dll */
173 FreeLibrary(hmod); 173 FreeLibrary(hmod);
174 } 174 }
183 char* buf; 183 char* buf;
184 184
185 hmod = GetModuleHandle(NULL); 185 hmod = GetModuleHandle(NULL);
186 if( hmod == 0 ) { 186 if( hmod == 0 ) {
187 buf = g_win32_error_message( GetLastError() ); 187 buf = g_win32_error_message( GetLastError() );
188 debug_printf("GetModuleHandle error: %s\n", buf); 188 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleHandle error: %s\n", buf);
189 free(buf); 189 free(buf);
190 return NULL; 190 return NULL;
191 } 191 }
192 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) { 192 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) {
193 buf = g_win32_error_message( GetLastError() ); 193 buf = g_win32_error_message( GetLastError() );
194 debug_printf("GetModuleFileName error: %s\n", buf); 194 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleFileName error: %s\n", buf);
195 free(buf); 195 free(buf);
196 return NULL; 196 return NULL;
197 } 197 }
198 buf = g_path_get_dirname( install_dir ); 198 buf = g_path_get_dirname( install_dir );
199 strcpy( (char*)&install_dir, buf ); 199 strcpy( (char*)&install_dir, buf );
247 char buf[1024]; 247 char buf[1024];
248 int ret; 248 int ret;
249 249
250 if((fin = gzopen(in, "rb"))) { 250 if((fin = gzopen(in, "rb"))) {
251 if(!(fout = fopen(out, "wb"))) { 251 if(!(fout = fopen(out, "wb"))) {
252 debug_printf("wgaim_gz_decompress: Error opening file: %s\n", out); 252 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out);
253 gzclose(fin); 253 gzclose(fin);
254 return 0; 254 return 0;
255 } 255 }
256 } 256 }
257 else { 257 else {
258 debug_printf("wgaim_gz_decompress: gzopen failed to open: %s\n", in); 258 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in);
259 return 0; 259 return 0;
260 } 260 }
261 261
262 while((ret=gzread(fin, buf, 1024))) { 262 while((ret=gzread(fin, buf, 1024))) {
263 if(fwrite(buf, 1, ret, fout) < ret) { 263 if(fwrite(buf, 1, ret, fout) < ret) {
264 debug_printf("wgaim_gz_decompress: Error writing %d bytes to file\n", ret); 264 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret);
265 gzclose(fin); 265 gzclose(fin);
266 fclose(fout); 266 fclose(fout);
267 return 0; 267 return 0;
268 } 268 }
269 } 269 }
270 fclose(fout); 270 fclose(fout);
271 gzclose(fin); 271 gzclose(fin);
272 272
273 if(ret < 0) { 273 if(ret < 0) {
274 debug_printf("wgaim_gz_decompress: gzread failed while reading: %s\n", in); 274 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in);
275 return 0; 275 return 0;
276 } 276 }
277 277
278 return 1; 278 return 1;
279 } 279 }
286 if(wgaim_gz_decompress(filename, tmpfile)) { 286 if(wgaim_gz_decompress(filename, tmpfile)) {
287 int ret; 287 int ret;
288 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) 288 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET))
289 ret=1; 289 ret=1;
290 else { 290 else {
291 debug_printf("wgaim_gz_untar: Failure untaring %s\n", tmpfile); 291 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile);
292 ret=0; 292 ret=0;
293 } 293 }
294 unlink(tmpfile); 294 unlink(tmpfile);
295 return ret; 295 return ret;
296 } 296 }
297 else { 297 else {
298 debug_printf("wgaim_gz_untar: Failed to gz decompress %s\n", filename); 298 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename);
299 return 0; 299 return 0;
300 } 300 }
301 } 301 }
302 302
303 /* Windows Initializations */ 303 /* Windows Initializations */
307 WSADATA wsaData; 307 WSADATA wsaData;
308 char* locale=0; 308 char* locale=0;
309 char newenv[128]; 309 char newenv[128];
310 char* drmingw; 310 char* drmingw;
311 311
312 debug_printf("wgaim_init\n"); 312 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init\n");
313 313
314 /* Load exception handler if we have it */ 314 /* Load exception handler if we have it */
315 drmingw = g_build_filename(wgaim_install_dir(), "exchndl.dll", NULL); 315 drmingw = g_build_filename(wgaim_install_dir(), "exchndl.dll", NULL);
316 LoadLibrary(drmingw); 316 LoadLibrary(drmingw);
317 g_free(drmingw); 317 g_free(drmingw);
333 2.2 in addition to 2.2, it will still return 2.2 in 333 2.2 in addition to 2.2, it will still return 2.2 in
334 wVersion since that is the version we requested. */ 334 wVersion since that is the version we requested. */
335 335
336 if ( LOBYTE( wsaData.wVersion ) != 2 || 336 if ( LOBYTE( wsaData.wVersion ) != 2 ||
337 HIBYTE( wsaData.wVersion ) != 2 ) { 337 HIBYTE( wsaData.wVersion ) != 2 ) {
338 debug_printf("Could not find a usable WinSock DLL. Oh well.\n"); 338 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n");
339 WSACleanup( ); 339 WSACleanup( );
340 } 340 }
341 341
342 /* get default locale */ 342 /* get default locale */
343 locale = g_win32_getlocale(); 343 locale = g_win32_getlocale();
344 debug_printf("Language profile used: %s\n", locale); 344 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Language profile used: %s\n", locale);
345 345
346 /* Aspell config */ 346 /* Aspell config */
347 sprintf(newenv, "LANG=%s", locale); 347 sprintf(newenv, "LANG=%s", locale);
348 if(putenv(newenv)<0) 348 if(putenv(newenv)<0)
349 debug_printf("putenv failed\n"); 349 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
350 g_free(locale); 350 g_free(locale);
351 351
352 /* Disable PANGO UNISCRIBE (for GTK 2.2.0). This may not be necessary in the 352 /* Disable PANGO UNISCRIBE (for GTK 2.2.0). This may not be necessary in the
353 future because there will most likely be a check to see if we need this, 353 future because there will most likely be a check to see if we need this,
354 but for now we need to set this in order to avoid poor performance for some 354 but for now we need to set this in order to avoid poor performance for some
355 windows machines. 355 windows machines.
356 */ 356 */
357 sprintf(newenv, "PANGO_WIN32_NO_UNISCRIBE=1"); 357 sprintf(newenv, "PANGO_WIN32_NO_UNISCRIBE=1");
358 if(putenv(newenv)<0) 358 if(putenv(newenv)<0)
359 debug_printf("putenv failed\n"); 359 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
360 360
361 /* 361 /*
362 * IdleTracker Initialization 362 * IdleTracker Initialization
363 */ 363 */
364 if(!wgaim_set_idlehooks()) 364 if(!wgaim_set_idlehooks())
365 debug_printf("Failed to initialize idle tracker\n"); 365 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n");
366 366
367 wgaim_gtkspell_init(); 367 wgaim_gtkspell_init();
368 } 368 }
369 369
370 /* Windows Cleanup */ 370 /* Windows Cleanup */
371 371
372 void wgaim_cleanup(void) { 372 void wgaim_cleanup(void) {
373 debug_printf("wgaim_cleanup\n"); 373 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n");
374 374
375 /* winsock cleanup */ 375 /* winsock cleanup */
376 WSACleanup( ); 376 WSACleanup( );
377 377
378 /* Idle tracker cleanup */ 378 /* Idle tracker cleanup */