annotate src/win32/win32dep.c @ 6425:26b739bc9f1a

[gaim-migrate @ 6933] Warnings and gaim_debugs committer: Tailor Script <tailor@pidgin.im>
author Herman Bloggs <hermanator12002@yahoo.com>
date Mon, 11 Aug 2003 18:54:38 +0000
parents 9281be45e046
children ae4c3abbaac1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
2 * gaim
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
3 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
4 * File: win32dep.c
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
5 * Date: June, 2002
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
6 * Description: Windows dependant code for Gaim
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
7 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
8 * Copyright (C) 2002-2003, Herman Bloggs <hermanator12002@yahoo.com>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 *
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
10 * This program is free software; you can redistribute it and/or modify
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
11 * it under the terms of the GNU General Public License as published by
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
13 * (at your option) any later version.
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
14 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
15 * This program is distributed in the hope that it will be useful,
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
18 * GNU General Public License for more details.
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
19 *
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
20 * You should have received a copy of the GNU General Public License
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
21 * along with this program; if not, write to the Free Software
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
23 *
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
24 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
25 #include <windows.h>
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6423
diff changeset
26 #include <io.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 #include <stdlib.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
28 #include <stdio.h>
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
29 #include <winuser.h>
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
30
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
31 #include <gtk/gtk.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <glib.h>
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
33 #include <gdk/gdkwin32.h>
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
34
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include "gaim.h"
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
36 #include "debug.h"
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
37
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
38 #include "stdafx.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include "resource.h"
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
40 #include "MinimizeToTray.h"
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
41 #include "winuser_extra.h"
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
42 #include "idletrack.h"
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
43 #include "zlib.h"
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
44 #include "untar.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
46
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
48 * DEFINES & MACROS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 */
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
50
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
52 * DATA STRUCTS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
53 */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
54 struct _WGAIM_FLASH_INFO {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
55 guint t_handle;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
56 guint sig_handler;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
57 };
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
58 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
59
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
60 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 * LOCALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
63 static char install_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
64 static char lib_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
65 static char locale_dir[MAXPATHLEN];
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
66
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
67 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
68 * GLOBALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
69 */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
70 HINSTANCE gaimexe_hInstance = 0;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
71 HINSTANCE gaimdll_hInstance = 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
72
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
73 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
74 * PROTOS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
75 */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
76 BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL;
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
77 FARPROC wgaim_find_and_loadproc(char*, char*);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
78 extern void wgaim_gtkspell_init();
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
79
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
80 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
81 * STATIC CODE
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
84 /* Window flasher */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
85 static gboolean flash_window_cb(gpointer data) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
86 FlashWindow((HWND)data, TRUE);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
87 return TRUE;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
88 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
89
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
90 static void halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, WGAIM_FLASH_INFO *finfo) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
91 /* Stop flashing and remove filter */
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
92 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n");
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 4106
diff changeset
93 g_source_remove(finfo->t_handle);
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
94 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n");
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
95 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler);
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
96 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n");
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
97 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
98
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
99 static void load_winver_specific_procs(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
100 /* Used for Win98+ and WinNT5+ */
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
101 MyFlashWindowEx = (void*)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" );
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
102 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
103
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
104 /*
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
105 * PUBLIC CODE
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
106 */
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
107
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
108 HINSTANCE wgaim_hinstance(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
109 return gaimexe_hInstance;
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
110 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
111
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
112 /* Escape windows dir separators. This is needed when paths are saved,
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
113 and on being read back have their '\' chars used as an escape char.
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
114 Returns an allocated string which needs to be freed.
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
115 */
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
116 char* wgaim_escape_dirsep( char* filename ) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
117 int sepcount=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
118 char* ret=NULL;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
119 int cnt=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
120
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
121 ret = filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
122 while(*ret) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
123 if(*ret == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
124 sepcount++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
125 ret++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
126 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
127 ret = g_malloc0(strlen(filename) + sepcount + 1);
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
128 while(*filename) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
129 ret[cnt] = *filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
130 if(*filename == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
131 ret[++cnt] = '\\';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
132 filename++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
133 cnt++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
134 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
135 ret[cnt] = '\0';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
136 return ret;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
137 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
138
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
139 /* Determine whether the specified dll contains the specified procedure.
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
140 If so, load it (if not already loaded). */
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
141 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) {
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
142 HMODULE hmod;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
143 int did_load=0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
144 FARPROC proc = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
145
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
146 if(!(hmod=GetModuleHandle(dllname))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
147 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "%s not found. Loading it..\n", dllname);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
148 if(!(hmod = LoadLibrary(dllname))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
149 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Could not load: %s\n", dllname);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
150 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
151 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
152 else
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
153 did_load = 1;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
154 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
155
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
156 if((proc=GetProcAddress(hmod, procedure))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
157 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "This version of %s contains %s\n",
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
158 dllname, procedure);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
159 return proc;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
160 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
161 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
162 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Function %s not found in dll %s\n",
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
163 procedure, dllname);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
164 if(did_load) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
165 /* unload dll */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
166 FreeLibrary(hmod);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
167 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
168 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
169 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
170 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
171
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
172 /* Determine Gaim Paths during Runtime */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
173
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
174 char* wgaim_install_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
175 HMODULE hmod;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
176 char* buf;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
177
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
178 hmod = GetModuleHandle(NULL);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
179 if( hmod == 0 ) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
180 buf = g_win32_error_message( GetLastError() );
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
181 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleHandle error: %s\n", buf);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 free(buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 buf = g_win32_error_message( GetLastError() );
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
187 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleFileName error: %s\n", buf);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 free(buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 buf = g_path_get_dirname( install_dir );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 strcpy( (char*)&install_dir, buf );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 free( buf );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 return (char*)&install_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 char* wgaim_lib_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199 strcpy(lib_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201 return (char*)&lib_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204 char* wgaim_locale_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205 strcpy(locale_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 strcat(locale_dir, G_DIR_SEPARATOR_S "locale");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 return (char*)&locale_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
210 /* Miscellaneous */
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
211
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
212 /* FlashWindowEx is only supported by Win98+ and WinNT5+. If its
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
213 not supported we do it our own way */
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
214 void wgaim_im_blink(GtkWidget *window) {
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
215 if(MyFlashWindowEx) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
216 FLASHWINFO info;
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
217
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
218 info.cbSize = sizeof(FLASHWINFO);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
219 info.hwnd = GDK_WINDOW_HWND(window->window);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
220 info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
221 info.dwTimeout = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
222 MyFlashWindowEx(&info);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
223 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
224 else {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
225 WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
226
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
227 /* Start Flashing window */
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
228 finfo->t_handle = g_timeout_add(1000,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
229 flash_window_cb,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
230 GDK_WINDOW_HWND(window->window));
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
231 finfo->sig_handler = g_signal_connect(G_OBJECT(window),
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
232 "focus-in-event",
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
233 G_CALLBACK(halt_flash_filter), finfo);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
234 }
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
235 }
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
236
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
237 int wgaim_gz_decompress(const char* in, const char* out) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
238 gzFile fin;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
239 FILE *fout;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
240 char buf[1024];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
241 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
242
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
243 if((fin = gzopen(in, "rb"))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
244 if(!(fout = fopen(out, "wb"))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
245 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error opening file: %s\n", out);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
246 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
247 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
248 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
249 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
250 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
251 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzopen failed to open: %s\n", in);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
252 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
253 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
254
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
255 while((ret=gzread(fin, buf, 1024))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
256 if(fwrite(buf, 1, ret, fout) < ret) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
257 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "Error writing %d bytes to file\n", ret);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
258 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
259 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
260 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
261 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
262 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
263 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
264 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
265
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
266 if(ret < 0) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
267 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_decompress", "gzread failed while reading: %s\n", in);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
268 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
269 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
270
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
271 return 1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
272 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
273
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
274 int wgaim_gz_untar(const char* filename, const char* destdir) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
275 char tmpfile[_MAX_PATH];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
276 char template[]="wgaimXXXXXX";
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
277
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
278 sprintf(tmpfile, "%s%s%s", g_get_tmp_dir(), G_DIR_SEPARATOR_S, _mktemp(template));
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
279 if(wgaim_gz_decompress(filename, tmpfile)) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
280 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
281 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET))
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
282 ret=1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
283 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
284 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failure untaring %s\n", tmpfile);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
285 ret=0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
286 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
287 unlink(tmpfile);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
288 return ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
289 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
290 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
291 gaim_debug(GAIM_DEBUG_ERROR, "wgaim_gz_untar", "Failed to gz decompress %s\n", filename);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
292 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
293 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
294 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
295
6083
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
296 /* Moved over from old systray.c */
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
297 void wgaim_systray_minimize( GtkWidget *window ) {
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
298 MinimizeWndToTray(GDK_WINDOW_HWND(window->window));
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
299 }
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
300
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
301 void wgaim_systray_maximize( GtkWidget *window ) {
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
302 RestoreWndFromTray(GDK_WINDOW_HWND(window->window));
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
303 }
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
304
6262
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
305 char* wgaim_lcid_to_posix(LCID lcid) {
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
306 switch(lcid) {
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
307 case 1026: return "bg"; /* bulgarian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
308 case 1027: return "ca"; /* catalan */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
309 case 1050: return "hr"; /* croation */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
310 case 1029: return "cs"; /* czech */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
311 case 1030: return "da"; /* danaish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
312 case 1043: return "nl"; /* dutch - netherlands */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
313 case 1033: return "en"; /* english - us */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
314 case 1035: return "fi"; /* finish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
315 case 1036: return "fr"; /* french - france */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
316 case 1031: return "de"; /* german - germany */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
317 case 1032: return "el"; /* greek */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
318 case 1037: return "he"; /* hebrew */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
319 case 1038: return "hu"; /* hungarian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
320 case 1040: return "it"; /* italian - italy */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
321 case 1041: return "ja"; /* japanese */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
322 case 1042: return "ko"; /* korean */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
323 case 1063: return "lt"; /* lithuanian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
324 case 1071: return "mk"; /* macedonian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
325 case 1045: return "pl"; /* polish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
326 case 2070: return "pt"; /* portuguese - portugal */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
327 case 1046: return "pt_BR"; /* portuguese - brazil */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
328 case 1048: return "ro"; /* romanian - romania */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
329 case 1049: return "ru"; /* russian - russia */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
330 case 2074: return "sr@Latn"; /* serbian - latin */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
331 case 3098: return "sr"; /* serbian - cyrillic */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
332 case 2052: return "zh_CN"; /* chinese - china (simple) */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
333 case 1051: return "sk"; /* slovak */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
334 case 1060: return "sl"; /* slovenian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
335 case 1034: return "es"; /* spanish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
336 case 1053: return "sv"; /* swedish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
337 case 1054: return "th"; /* thai */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
338 case 1028: return "zh_TW"; /* chinese - taiwan (traditional) */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
339 case 1055: return "tr"; /* turkish */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
340 case 1058: return "uk"; /* ukrainian */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
341 default:
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
342 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find posix code for LCID: %d\n", lcid);
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
343 return NULL;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
344 }
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
345 }
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
346
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
347 /* Determine and set Gaim locale as follows (in order of priority):
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
348 - Check LANG env var
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
349 - Check NSIS Installer Language reg value
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
350 - Use default user locale
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
351 */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
352 void wgaim_set_locale() {
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
353 HKEY hkey;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
354 char* locale=NULL;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
355 char envstr[25];
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
356 LCID lcid;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
357
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
358 /* Check if user set LANG env var */
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6423
diff changeset
359 if((locale = (char*)g_getenv("LANG"))) {
6262
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
360 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Using locale set by the LANG env var.\n");
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
361 goto finish;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
362 }
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
363
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
364 /* Check reg key set at install time */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
365 if(ERROR_SUCCESS == RegOpenKeyEx(HKEY_CURRENT_USER,
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
366 "SOFTWARE\\gaim",
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
367 0, KEY_QUERY_VALUE, &hkey)) {
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
368 BYTE data[10];
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
369 DWORD ds = 10;
6425
26b739bc9f1a [gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6423
diff changeset
370 if(ERROR_SUCCESS == RegQueryValueEx(hkey, "Installer Language", 0, NULL, (LPBYTE)&data, &ds)) {
6262
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
371 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Using locale set by the installer\n");
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
372 if((locale = wgaim_lcid_to_posix(atoi(data))))
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
373 goto finish;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
374 }
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
375 }
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
376
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
377 lcid = GetUserDefaultLCID();
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
378 if((locale = wgaim_lcid_to_posix(lcid)))
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
379 goto finish;
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
380
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
381 finish:
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
382 if(!locale)
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
383 locale = "en";
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
384
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
385 sprintf(envstr, "LANG=%s", locale);
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
386 if(putenv(envstr)<0)
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
387 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
388
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
389 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Locale set to: %s\n", locale);
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
390 }
6083
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
391
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
392 /* Windows Initializations */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
393
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
394 void wgaim_init(void) {
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
395 WORD wVersionRequested;
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
396 WSADATA wsaData;
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
397 char newenv[128];
5472
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
398 char* drmingw;
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
399
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
400 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init\n");
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
401
5472
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
402 /* Load exception handler if we have it */
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
403 drmingw = g_build_filename(wgaim_install_dir(), "exchndl.dll", NULL);
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
404 LoadLibrary(drmingw);
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
405 g_free(drmingw);
a2acc2b79ff1 [gaim-migrate @ 5864]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5008
diff changeset
406
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
407 load_winver_specific_procs();
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
408
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
409 /*
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
410 * Winsock init
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
411 */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
412 wVersionRequested = MAKEWORD( 2, 2 );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
413
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
414 WSAStartup( wVersionRequested, &wsaData );
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
415
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
416 /* Confirm that the winsock DLL supports 2.2 */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
417 /* Note that if the DLL supports versions greater than
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
418 2.2 in addition to 2.2, it will still return 2.2 in
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
419 wVersion since that is the version we requested. */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
420
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
421 if ( LOBYTE( wsaData.wVersion ) != 2 ||
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
422 HIBYTE( wsaData.wVersion ) != 2 ) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
423 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n");
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
424 WSACleanup( );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
425 }
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
426
6262
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
427 /* Set locale - determines which translations to user, and which
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
428 aspell dictionary to use */
4fcfe659568a [gaim-migrate @ 6758]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6083
diff changeset
429 wgaim_set_locale();
3905
3e508dd31b76 [gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3856
diff changeset
430
4411
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
431 /* Disable PANGO UNISCRIBE (for GTK 2.2.0). This may not be necessary in the
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
432 future because there will most likely be a check to see if we need this,
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
433 but for now we need to set this in order to avoid poor performance for some
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
434 windows machines.
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
435 */
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
436 sprintf(newenv, "PANGO_WIN32_NO_UNISCRIBE=1");
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
437 if(putenv(newenv)<0)
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
438 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
4411
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
439
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
440 /*
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
441 * IdleTracker Initialization
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
442 */
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
443 if(!wgaim_set_idlehooks())
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
444 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Failed to initialize idle tracker\n");
4861
6cb8b0686e46 [gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4728
diff changeset
445
6cb8b0686e46 [gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4728
diff changeset
446 wgaim_gtkspell_init();
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
447 }
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
448
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
449 /* Windows Cleanup */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
450
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
451 void wgaim_cleanup(void) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
452 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n");
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
453
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
454 /* winsock cleanup */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
455 WSACleanup( );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
456
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
457 /* Idle tracker cleanup */
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
458 wgaim_remove_idlehooks();
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
459 }
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
460
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
461 /* DLL initializer */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
462 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
463 gaimdll_hInstance = hinstDLL;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
464 return TRUE;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
465 }