Mercurial > pidgin
annotate src/win32/win32dep.c @ 10868:4a56b48dbaa6
[gaim-migrate @ 12555]
Don't try to send if charset conversion isn't successful. This is entirely untested.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 25 Apr 2005 03:41:16 +0000 |
parents | 179b0245a2f7 |
children | 2b772e7094ef |
rev | line source |
---|---|
3630 | 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 | 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 | 24 */ |
25 #include <windows.h> | |
6425
26b739bc9f1a
[gaim-migrate @ 6933]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6423
diff
changeset
|
26 #include <io.h> |
3630 | 27 #include <stdlib.h> |
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 | 32 #include <glib.h> |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
33 #if GLIB_CHECK_VERSION(2,6,0) |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
34 # include <glib/gstdio.h> |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
35 #else |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
36 # define g_fopen fopen |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
37 # define g_unlink unlink |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
38 #endif |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
39 #include <gdk/gdkwin32.h> |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
40 |
3630 | 41 #include "gaim.h" |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
42 #include "debug.h" |
6929
906567be99b2
[gaim-migrate @ 7476]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6890
diff
changeset
|
43 #include "notify.h" |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
44 |
3630 | 45 #include "stdafx.h" |
46 #include "resource.h" | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
47 #include "MinimizeToTray.h" |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
48 #include "winuser_extra.h" |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
49 #include "idletrack.h" |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
50 #include "zlib.h" |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
51 #include "untar.h" |
3630 | 52 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
53 #include <libintl.h> |
5913
9657e243d001
[gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5854
diff
changeset
|
54 |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
55 #include "win32dep.h" |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
56 |
3630 | 57 /* |
58 * DEFINES & MACROS | |
59 */ | |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
60 #define _(x) gettext(x) |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
61 |
3630 | 62 /* |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
63 * DATA STRUCTS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
64 */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
65 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
66 /* For shfolder.dll */ |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
67 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
68 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
69 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
70 typedef enum { |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
71 SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
72 SHGFP_TYPE_DEFAULT = 1, // default value, may not exist |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
73 } SHGFP_TYPE; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
74 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
75 /* flash info */ |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
76 typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
77 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
78 struct _WGAIM_FLASH_INFO { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
79 guint t_handle; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
80 guint sig_handler; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
81 }; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
82 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
83 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
84 /* |
3630 | 85 * LOCALS |
86 */ | |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
87 static char *app_data_dir; |
3630 | 88 static char install_dir[MAXPATHLEN]; |
89 static char lib_dir[MAXPATHLEN]; | |
90 static char locale_dir[MAXPATHLEN]; | |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
91 static gboolean blink_turned_on = TRUE; |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
92 |
3630 | 93 /* |
94 * GLOBALS | |
95 */ | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
96 HINSTANCE gaimexe_hInstance = 0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
97 HINSTANCE gaimdll_hInstance = 0; |
3630 | 98 |
99 /* | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
100 * PROTOS |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
101 */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
102 LPFNFLASHWINDOWEX MyFlashWindowEx = NULL; |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
103 |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
104 FARPROC wgaim_find_and_loadproc(char*, char*); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
105 extern void wgaim_gtkspell_init(); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
106 char* wgaim_data_dir(void); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
107 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
108 /* |
3630 | 109 * STATIC CODE |
110 */ | |
111 | |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
112 /* Window flasher */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
113 static gboolean flash_window_cb(gpointer data) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
114 FlashWindow((HWND)data, TRUE); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
115 return TRUE; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
116 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
117 |
8147 | 118 static int halt_flash_filter(GtkWidget *widget, GdkEventFocus *event, gpointer data) { |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
119 if(MyFlashWindowEx) { |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
120 HWND hWnd = data; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
121 FLASHWINFO info; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
122 |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
123 if(!IsWindow(hWnd)) |
8147 | 124 return 0; |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
125 memset(&info, 0, sizeof(FLASHWINFO)); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
126 info.cbSize = sizeof(FLASHWINFO); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
127 info.hwnd = hWnd; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
128 info.dwFlags = FLASHW_STOP; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
129 info.dwTimeout = 0; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
130 MyFlashWindowEx(&info); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
131 } |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
132 else { |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
133 WGAIM_FLASH_INFO *finfo = data; |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
134 /* Stop flashing and remove filter */ |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
135 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n"); |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
136 gaim_timeout_remove(finfo->t_handle); |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
137 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n"); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
138 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
139 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n"); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
140 g_free(finfo); |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
141 } |
8147 | 142 return 0; |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
143 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
144 |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
145 static void load_winver_specific_procs(void) { |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
146 /* Used for Win98+ and WinNT5+ */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
147 MyFlashWindowEx = (LPFNFLASHWINDOWEX)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" ); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
148 } |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
149 |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
150 static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) { |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
151 char *str = NULL; |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
152 if (args != NULL) { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
153 str = g_strdup_vprintf(format, args); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
154 } else { |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
155 str = g_strdup(format); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
156 } |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
157 printf("%s%s%s", category?category:"", category?": ":"",str); |
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
158 g_free(str); |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
159 } |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
160 |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
161 static GaimDebugUiOps ops = { |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
162 wgaim_debug_print |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
163 }; |
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
164 |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
165 /* |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
166 * PUBLIC CODE |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
167 */ |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
168 |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
169 HINSTANCE wgaim_hinstance(void) { |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
170 return gaimexe_hInstance; |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
171 } |
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
172 |
4406
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
173 /* Escape windows dir separators. This is needed when paths are saved, |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
174 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
|
175 Returns an allocated string which needs to be freed. |
4406
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
176 */ |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
177 char* wgaim_escape_dirsep( char* filename ) { |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
178 int sepcount=0; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
179 char* ret=NULL; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
180 int cnt=0; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
181 |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
182 ret = filename; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
183 while(*ret) { |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
184 if(*ret == '\\') |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
185 sepcount++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
186 ret++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
187 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
188 ret = g_malloc0(strlen(filename) + sepcount + 1); |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
189 while(*filename) { |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
190 ret[cnt] = *filename; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
191 if(*filename == '\\') |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
192 ret[++cnt] = '\\'; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
193 filename++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
194 cnt++; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
195 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
196 ret[cnt] = '\0'; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
197 return ret; |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
198 } |
217572342740
[gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4168
diff
changeset
|
199 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
200 /* Determine whether the specified dll contains the specified procedure. |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
201 If so, load it (if not already loaded). */ |
4097
929d23ef2ded
[gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4042
diff
changeset
|
202 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) { |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
203 HMODULE hmod; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
204 int did_load=0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
205 FARPROC proc = 0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
206 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
207 if(!(hmod=GetModuleHandle(dllname))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
208 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
|
209 if(!(hmod = LoadLibrary(dllname))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
210 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
|
211 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
212 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
213 else |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
214 did_load = 1; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
215 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
216 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
217 if((proc=GetProcAddress(hmod, procedure))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
218 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
|
219 dllname, procedure); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
220 return proc; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
221 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
222 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
223 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
|
224 procedure, dllname); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
225 if(did_load) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
226 /* unload dll */ |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
227 FreeLibrary(hmod); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
228 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
229 return NULL; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
230 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
231 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
232 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
233 /* Determine Gaim Paths during Runtime */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
234 |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
235 /* Get paths to special Windows folders. */ |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
236 char *wgaim_get_special_folder(int folder_type) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
237 static LPFNSHGETFOLDERPATHA MySHGetFolderPathA = NULL; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
238 char *retval = NULL; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
239 #if GLIB_CHECK_VERSION(2,6,0) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
240 static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
241 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
242 if (!MySHGetFolderPathW) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
243 MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
244 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
245 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
246 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
247 if (MySHGetFolderPathW) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
248 wchar_t utf_16_dir[MAX_PATH + 1]; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
249 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
250 if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL, |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
251 SHGFP_TYPE_CURRENT, utf_16_dir))) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
252 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
253 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
254 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
255 #endif |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
256 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
257 if (!retval) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
258 if (!MySHGetFolderPathA) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
259 MySHGetFolderPathA = (LPFNSHGETFOLDERPATHA) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
260 wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
261 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
262 if (MySHGetFolderPathA) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
263 char locale_dir[MAX_PATH + 1]; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
264 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
265 if (SUCCEEDED(MySHGetFolderPathA(NULL, folder_type, NULL, |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
266 SHGFP_TYPE_CURRENT, locale_dir))) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
267 #if GLIB_CHECK_VERSION(2,6,0) |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
268 retval = g_locale_to_utf8(locale_dir, -1, NULL, NULL, NULL); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
269 #else |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
270 retval = g_strdup(locale_dir); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
271 #endif |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
272 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
273 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
274 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
275 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
276 return retval; |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
277 } |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
278 |
3630 | 279 char* wgaim_install_dir(void) { |
280 HMODULE hmod; | |
281 char* buf; | |
282 | |
283 hmod = GetModuleHandle(NULL); | |
284 if( hmod == 0 ) { | |
285 buf = g_win32_error_message( GetLastError() ); | |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
286 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleHandle error: %s\n", buf); |
7606 | 287 g_free(buf); |
3630 | 288 return NULL; |
289 } | |
290 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) { | |
291 buf = g_win32_error_message( GetLastError() ); | |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
292 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleFileName error: %s\n", buf); |
7606 | 293 g_free(buf); |
3630 | 294 return NULL; |
295 } | |
296 buf = g_path_get_dirname( install_dir ); | |
297 strcpy( (char*)&install_dir, buf ); | |
7606 | 298 g_free( buf ); |
3630 | 299 |
300 return (char*)&install_dir; | |
301 } | |
302 | |
303 char* wgaim_lib_dir(void) { | |
304 strcpy(lib_dir, wgaim_install_dir()); | |
9916 | 305 g_strlcat(lib_dir, G_DIR_SEPARATOR_S "plugins", sizeof(lib_dir)); |
3630 | 306 return (char*)&lib_dir; |
307 } | |
308 | |
309 char* wgaim_locale_dir(void) { | |
310 strcpy(locale_dir, wgaim_install_dir()); | |
9916 | 311 g_strlcat(locale_dir, G_DIR_SEPARATOR_S "locale", sizeof(locale_dir)); |
3630 | 312 return (char*)&locale_dir; |
313 } | |
314 | |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
315 char* wgaim_data_dir(void) { |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
316 return app_data_dir; |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
317 } |
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
318 |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
319 /* Miscellaneous */ |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
320 |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
321 gboolean wgaim_read_reg_string(HKEY key, char* sub_key, char* val_name, LPBYTE data, LPDWORD data_len) { |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
322 HKEY hkey; |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
323 gboolean ret = FALSE; |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
324 |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
325 if(ERROR_SUCCESS == RegOpenKeyEx(key, |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
326 sub_key, |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
327 0, KEY_QUERY_VALUE, &hkey)) { |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
328 if(ERROR_SUCCESS == RegQueryValueEx(hkey, val_name, 0, NULL, data, data_len)) |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
329 ret = TRUE; |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
330 RegCloseKey(key); |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
331 } |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
332 return ret; |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
333 } |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
334 |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
335 /* FlashWindowEx is only supported by Win98+ and WinNT5+. If its |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
336 not supported we do it our own way */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6929
diff
changeset
|
337 void wgaim_conv_im_blink(GtkWidget *window) { |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
338 if(!blink_turned_on) |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
339 return; |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
340 if(MyFlashWindowEx) { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
341 FLASHWINFO info; |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
342 if(GetForegroundWindow() == GDK_WINDOW_HWND(window->window)) |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
343 return; |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
344 memset(&info, 0, sizeof(FLASHWINFO)); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
345 info.cbSize = sizeof(FLASHWINFO); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
346 info.hwnd = GDK_WINDOW_HWND(window->window); |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
347 info.dwFlags = FLASHW_ALL | FLASHW_TIMER; |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
348 info.dwTimeout = 0; |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
349 MyFlashWindowEx(&info); |
7803
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
350 /* Stop flashing when window receives focus */ |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
351 g_signal_connect(G_OBJECT(window), |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
352 "focus-in-event", |
ec291c2cad6a
[gaim-migrate @ 8449]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7606
diff
changeset
|
353 G_CALLBACK(halt_flash_filter), info.hwnd); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
354 } |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
355 else { |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
356 WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1); |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
357 |
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
358 /* Start Flashing window */ |
8273
f24172f53650
[gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents:
8147
diff
changeset
|
359 finfo->t_handle = gaim_timeout_add(1000, |
4555
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
360 flash_window_cb, |
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
361 GDK_WINDOW_HWND(window->window)); |
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
362 finfo->sig_handler = g_signal_connect(G_OBJECT(window), |
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
363 "focus-in-event", |
75f75ef235e4
[gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4535
diff
changeset
|
364 G_CALLBACK(halt_flash_filter), finfo); |
3983
a1245dcf7b31
[gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3973
diff
changeset
|
365 } |
3973
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
366 } |
d9287e87ba56
[gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3950
diff
changeset
|
367 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6929
diff
changeset
|
368 void wgaim_conv_im_blink_state(gboolean val) { |
6437
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
369 blink_turned_on = val; |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
370 } |
ae4c3abbaac1
[gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6425
diff
changeset
|
371 |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
372 int wgaim_gz_decompress(const char* in, const char* out) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
373 gzFile fin; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
374 FILE *fout; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
375 char buf[1024]; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
376 int ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
377 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
378 if((fin = gzopen(in, "rb"))) { |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
379 if(!(fout = g_fopen(out, "wb"))) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
380 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
|
381 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
382 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
383 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
384 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
385 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
386 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
|
387 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
388 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
389 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
390 while((ret=gzread(fin, buf, 1024))) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
391 if(fwrite(buf, 1, ret, fout) < ret) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
392 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
|
393 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
394 fclose(fout); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
395 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
396 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
397 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
398 fclose(fout); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
399 gzclose(fin); |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
400 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
401 if(ret < 0) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
402 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
|
403 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
404 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
405 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
406 return 1; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
407 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
408 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
409 int wgaim_gz_untar(const char* filename, const char* destdir) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
410 char tmpfile[_MAX_PATH]; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
411 char template[]="wgaimXXXXXX"; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
412 |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
413 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
|
414 if(wgaim_gz_decompress(filename, tmpfile)) { |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
415 int ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
416 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET)) |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
417 ret=1; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
418 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
419 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
|
420 ret=0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
421 } |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
422 g_unlink(tmpfile); |
5008
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
423 return ret; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
424 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
425 else { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
426 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
|
427 return 0; |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
428 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
429 } |
89a5b0e23ea4
[gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4984
diff
changeset
|
430 |
6083
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
431 /* Moved over from old systray.c */ |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
432 void wgaim_systray_minimize( GtkWidget *window ) { |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
433 MinimizeWndToTray(GDK_WINDOW_HWND(window->window)); |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
434 } |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
435 |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
436 void wgaim_systray_maximize( GtkWidget *window ) { |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
437 RestoreWndFromTray(GDK_WINDOW_HWND(window->window)); |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
438 } |
65fad4831077
[gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5913
diff
changeset
|
439 |
10240
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
440 void wgaim_notify_uri(const char *uri) { |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
441 SHELLEXECUTEINFO sinfo; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
442 |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
443 memset(&sinfo, 0, sizeof(sinfo)); |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
444 sinfo.cbSize = sizeof(sinfo); |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
445 sinfo.fMask = SEE_MASK_CLASSNAME; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
446 sinfo.lpVerb = "open"; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
447 sinfo.lpFile = uri; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
448 sinfo.nShow = SW_SHOWNORMAL; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
449 sinfo.lpClass = "http"; |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
450 |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
451 /* We'll allow whatever URI schemes are supported by the |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
452 default http browser. |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
453 */ |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
454 if(!ShellExecuteEx(&sinfo)) |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
455 gaim_debug_error("wgaim", "Error opening URI: %s error: %d\n", uri, (int)sinfo.hInstApp); |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
456 } |
95ca0db2d01d
[gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
10213
diff
changeset
|
457 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
458 void wgaim_init(HINSTANCE hint) { |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
459 WORD wVersionRequested; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
460 WSADATA wsaData; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
461 char *perlenv; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
462 char *newenv; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
463 |
7526
77727178a1df
[gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7523
diff
changeset
|
464 gaim_debug_set_ui_ops(&ops); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
465 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init start\n"); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
466 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
467 gaimexe_hInstance = hint; |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
468 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
469 load_winver_specific_procs(); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
470 |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
471 /* Winsock init */ |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
472 wVersionRequested = MAKEWORD( 2, 2 ); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
473 WSAStartup( wVersionRequested, &wsaData ); |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
474 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
475 /* Confirm that the winsock DLL supports 2.2 */ |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
476 /* Note that if the DLL supports versions greater than |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
477 2.2 in addition to 2.2, it will still return 2.2 in |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
478 wVersion since that is the version we requested. */ |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
479 if ( LOBYTE( wsaData.wVersion ) != 2 || |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
480 HIBYTE( wsaData.wVersion ) != 2 ) { |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
481 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "Could not find a usable WinSock DLL. Oh well.\n"); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
482 WSACleanup(); |
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
483 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
484 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
485 /* Set Environmental Variables */ |
6816
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
486 /* Tell perl where to find Gaim's perl modules */ |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
487 perlenv = (char*)g_getenv("PERL5LIB"); |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
488 newenv = g_strdup_printf("PERL5LIB=%s%s%s%s", |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
489 perlenv ? perlenv : "", |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
490 perlenv ? ";" : "", |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
491 wgaim_install_dir(), |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
492 "\\perlmod;"); |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
493 if(putenv(newenv)<0) |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
494 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n"); |
5aeba37b303c
[gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6437
diff
changeset
|
495 g_free(newenv); |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
496 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
497 /* Set app data dir, used by gaim_home_dir */ |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
498 newenv = (char*) g_getenv("GAIMHOME"); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
499 if (newenv) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
500 app_data_dir = g_strdup(newenv); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
501 } else { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
502 app_data_dir = wgaim_get_special_folder(CSIDL_APPDATA); |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
503 if (!app_data_dir) { |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
504 app_data_dir = g_strdup("C:"); |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10335
diff
changeset
|
505 } |
6848
060aa79a733e
[gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
6816
diff
changeset
|
506 } |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
507 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
508 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Gaim settings dir: %s\n", app_data_dir); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
509 |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
510 /* IdleTracker Initialization */ |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
511 if(!wgaim_set_idlehooks()) |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
512 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
|
513 |
6cb8b0686e46
[gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4728
diff
changeset
|
514 wgaim_gtkspell_init(); |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
515 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n"); |
3630 | 516 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
517 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
518 /* Windows Cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
519 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
520 void wgaim_cleanup(void) { |
5854
14891982dbee
[gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5472
diff
changeset
|
521 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n"); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
522 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
523 /* winsock cleanup */ |
7523
7c3db2b2a790
[gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
7350
diff
changeset
|
524 WSACleanup(); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
525 |
4535
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
526 /* Idle tracker cleanup */ |
de9f45c815df
[gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4411
diff
changeset
|
527 wgaim_remove_idlehooks(); |
10673
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
528 |
179b0245a2f7
[gaim-migrate @ 12213]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10589
diff
changeset
|
529 g_free(app_data_dir); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
530 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
531 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
532 /* DLL initializer */ |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
533 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
534 gaimdll_hInstance = hinstDLL; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
535 return TRUE; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
536 } |