annotate src/win32/win32dep.c @ 7606:08c9d0dcf906

[gaim-migrate @ 8229] " Some things allocated with g_malloc() were being free()'d instead of g_free()'d This patch fixes the ones I managed to find." --Stu Tomlinson (nosnilmot) committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 23 Nov 2003 15:32:25 +0000
parents 77727178a1df
children ec291c2cad6a
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"
6929
906567be99b2 [gaim-migrate @ 7476]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6890
diff changeset
37 #include "notify.h"
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
38
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 #include "stdafx.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 #include "resource.h"
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
41 #include "MinimizeToTray.h"
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
42 #include "winuser_extra.h"
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
43 #include "idletrack.h"
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
44 #include "zlib.h"
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
45 #include "untar.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
47 #include <libintl.h>
5913
9657e243d001 [gaim-migrate @ 6345]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5854
diff changeset
48
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50 * DEFINES & MACROS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
52 #define _(x) gettext(x)
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
53
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
54 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
55 * DATA STRUCTS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
56 */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
57
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
58 /* For shfolder.dll */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
59 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATH)(HWND, int, HANDLE, DWORD, LPTSTR);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
60
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
61 typedef enum {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
62 SHGFP_TYPE_CURRENT = 0, // current value for user, verify it exists
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
63 SHGFP_TYPE_DEFAULT = 1, // default value, may not exist
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
64 } SHGFP_TYPE;
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 #define CSIDL_APPDATA 0x001a
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
67 #define CSIDL_FLAG_CREATE 0x8000
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
68
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
69 /* flash info */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
70 typedef BOOL (CALLBACK* LPFNFLASHWINDOWEX)(PFLASHWINFO);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
71
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
72 struct _WGAIM_FLASH_INFO {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
73 guint t_handle;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
74 guint sig_handler;
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 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
77
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
78 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
79 * LOCALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
80 */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
81 static char app_data_dir[MAX_PATH] = "C:";
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
82 static char install_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
83 static char lib_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
84 static char locale_dir[MAXPATHLEN];
6437
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
85 static gboolean blink_turned_on = TRUE;
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
86
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
87 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
88 * GLOBALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
89 */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
90 HINSTANCE gaimexe_hInstance = 0;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
91 HINSTANCE gaimdll_hInstance = 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
92
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
93 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
94 * PROTOS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
95 */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
96 LPFNFLASHWINDOWEX MyFlashWindowEx = NULL;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
97 LPFNSHGETFOLDERPATH MySHGetFolderPath = NULL;
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
98
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
99 FARPROC wgaim_find_and_loadproc(char*, char*);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
100 extern void wgaim_gtkspell_init();
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
101 char* wgaim_data_dir(void);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
102
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
103 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
104 * STATIC CODE
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
105 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
106
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
107 /* Window flasher */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
108 static gboolean flash_window_cb(gpointer data) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
109 FlashWindow((HWND)data, TRUE);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
110 return TRUE;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
111 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
112
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
113 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
114 /* Stop flashing and remove filter */
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
115 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Removing timeout\n");
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 4106
diff changeset
116 g_source_remove(finfo->t_handle);
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
117 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Disconnecting signal handler\n");
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
118 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler);
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
119 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "done\n");
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
120 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
121
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
122 static void load_winver_specific_procs(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
123 /* Used for Win98+ and WinNT5+ */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
124 MyFlashWindowEx = (LPFNFLASHWINDOWEX)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" );
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
125 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
126
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
127 static char* base_name(char* path) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
128 char *tmp = path;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
129 char *prev = NULL;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
130
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
131 while((tmp=strchr(tmp, '\\'))) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
132 prev = tmp;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
133 tmp += 1;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
134 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
135 if(prev)
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
136 return ++prev;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
137 else
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
138 return NULL;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
139 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
140
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
141 BOOL folder_exists(char *folder) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
142 BOOL ret = FALSE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
143 WIN32_FIND_DATA fileinfo;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
144 HANDLE fh;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
145
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
146 memset(&fileinfo, 0, sizeof(WIN32_FIND_DATA));
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
147 if((fh=FindFirstFile(folder, &fileinfo))) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
148 if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
149 ret = TRUE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
150 SetLastError(ERROR_SUCCESS);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
151 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
152 else
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
153 SetLastError(ERROR_FILE_EXISTS);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
154 FindClose(fh);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
155 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
156 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
157 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
158
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
159 /* Recursively create directories in the dest path */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
160 static BOOL CreateDirectoryR(char *dest) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
161 static BOOL start = TRUE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
162 BOOL ret = FALSE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
163
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
164 if(!dest)
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
165 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
166
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
167 if(start) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
168 char *str = g_strdup(dest);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
169 start = FALSE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
170 ret = CreateDirectoryR(str);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
171 g_free(str);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
172 start = TRUE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
173 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
174 else {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
175 char *tmp1 = dest;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
176 char *tmp=NULL;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
177
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
178 while((tmp1=strchr(tmp1, '\\'))) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
179 tmp = tmp1;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
180 tmp1+=1;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
181 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
182
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
183 if(tmp) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
184 tmp[0] = '\0';
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
185 CreateDirectoryR(dest);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
186 tmp[0] = '\\';
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
187 if(CreateDirectory(dest, NULL) == 0 && GetLastError() != ERROR_ALREADY_EXISTS) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
188 gaim_debug(GAIM_DEBUG_ERROR, "wgaim",
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
189 "Error creating directory: %s. Errno: %u\n",
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
190 dest, (UINT)GetLastError());
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
191 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
192 else
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
193 ret = TRUE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
194 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
195 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
196 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
197 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
198
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
199 static BOOL move_folder(char *src, char* dest, char* copytitle, BOOL overwrite) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
200 char *tsrc, *tdest;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
201 SHFILEOPSTRUCT dirmove;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
202 BOOL ret = FALSE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
203
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
204 g_return_val_if_fail(src!=NULL, ret);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
205 g_return_val_if_fail(dest!=NULL, ret);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
206
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
207 if(!folder_exists(src)) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
208 gaim_debug(GAIM_DEBUG_WARNING, "wgaim",
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
209 "move_folder: Source folder %s, does not exist\n", src);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
210 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
211 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
212 if(!overwrite) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
213 char *dstpath = g_strdup_printf("%s\\%s", dest, base_name(src));
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
214
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
215 if(folder_exists(dstpath)) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
216 gaim_debug(GAIM_DEBUG_WARNING, "wgaim",
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
217 "move_folder: Destination Folder %s, already exists\n", dstpath);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
218 g_free(dstpath);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
219 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
220 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
221 g_free(dstpath);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
222 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
223
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
224 /* Create dest folder if it doesn't exist */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
225 if(!CreateDirectoryR(dest)) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
226 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "Error creating directory: %s\n", dest);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
227 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
228 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
229
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
230 tsrc = g_strdup_printf("%s%c", src, '\0');
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
231 tdest = g_strdup_printf("%s%c", dest, '\0');
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
232
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
233 memset(&dirmove, 0, sizeof(SHFILEOPSTRUCT));
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
234 dirmove.wFunc = FO_MOVE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
235 dirmove.pFrom = tsrc;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
236 dirmove.pTo = tdest;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
237 dirmove.fFlags = FOF_NOCONFIRMATION | FOF_SIMPLEPROGRESS;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
238 dirmove.hNameMappings = 0;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
239 dirmove.lpszProgressTitle = copytitle;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
240
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
241 if(SHFileOperation(&dirmove)==0)
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
242 ret = TRUE;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
243
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
244 g_free(tsrc);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
245 g_free(tdest);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
246 return ret;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
247 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
248
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
249 static void move_settings_dir() {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
250 char *old_home = g_strdup_printf("%s%s", g_get_home_dir() ? g_get_home_dir() : "C:", "\\.gaim");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
251 char *new_home = g_strdup_printf("%s%s", wgaim_data_dir(), "\\.gaim");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
252
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
253 if(folder_exists(old_home) && !folder_exists(new_home)) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
254 if(move_folder(old_home, wgaim_data_dir(), _("Moving Gaim Settings.."), FALSE)) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
255 char *locenc, *locenc1, *str;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
256 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "Success moving '.gaim' directory\n");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
257 str = g_strdup_printf("%s%s", _("Moving Gaim user settings to: "), new_home);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
258 locenc=g_locale_from_utf8(str, -1, NULL, NULL, NULL);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
259 locenc1=g_locale_from_utf8(_("Notification"), -1, NULL, NULL, NULL);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
260 MessageBox(NULL, locenc, locenc1, MB_OK | MB_TOPMOST);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
261 g_free(locenc);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
262 g_free(locenc1);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
263 g_free(str);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
264 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
265 else
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
266 gaim_debug(GAIM_DEBUG_ERROR, "wgaim",
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
267 "Failed to move '.gaim' directory to %s.\n", wgaim_data_dir());
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
268 }
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
269 g_free(new_home);
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
270 g_free(old_home);
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
271 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
272
7526
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
273 static void wgaim_debug_print(GaimDebugLevel level, const char *category, const char *format, va_list args) {
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
274 char *str = g_strdup_vprintf(format, args);
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
275 printf("%s%s%s", category?category:"", category?": ":"",str);
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
276 g_free(str);
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
277 }
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
278
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
279 static GaimDebugUiOps ops =
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
280 {
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
281 wgaim_debug_print
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
282 };
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
283
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
284 /*
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
285 * PUBLIC CODE
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
286 */
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
287
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
288 HINSTANCE wgaim_hinstance(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
289 return gaimexe_hInstance;
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
290 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
291
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
292 /* Escape windows dir separators. This is needed when paths are saved,
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
293 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
294 Returns an allocated string which needs to be freed.
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
295 */
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
296 char* wgaim_escape_dirsep( char* filename ) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
297 int sepcount=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
298 char* ret=NULL;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
299 int cnt=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
300
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
301 ret = filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
302 while(*ret) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
303 if(*ret == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
304 sepcount++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
305 ret++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
306 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
307 ret = g_malloc0(strlen(filename) + sepcount + 1);
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
308 while(*filename) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
309 ret[cnt] = *filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
310 if(*filename == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
311 ret[++cnt] = '\\';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
312 filename++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
313 cnt++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
314 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
315 ret[cnt] = '\0';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
316 return ret;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
317 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
318
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
319 /* Determine whether the specified dll contains the specified procedure.
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
320 If so, load it (if not already loaded). */
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
321 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) {
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
322 HMODULE hmod;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
323 int did_load=0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
324 FARPROC proc = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
325
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
326 if(!(hmod=GetModuleHandle(dllname))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
327 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
328 if(!(hmod = LoadLibrary(dllname))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
329 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
330 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
331 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
332 else
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
333 did_load = 1;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
334 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
335
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
336 if((proc=GetProcAddress(hmod, procedure))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
337 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
338 dllname, procedure);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
339 return proc;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
340 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
341 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
342 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
343 procedure, dllname);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
344 if(did_load) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
345 /* unload dll */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
346 FreeLibrary(hmod);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
347 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
348 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
349 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
350 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
351
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
352 /* Determine Gaim Paths during Runtime */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
353
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
354 char* wgaim_install_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
355 HMODULE hmod;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
356 char* buf;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
357
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
358 hmod = GetModuleHandle(NULL);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
359 if( hmod == 0 ) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
360 buf = g_win32_error_message( GetLastError() );
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
361 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleHandle error: %s\n", buf);
7606
08c9d0dcf906 [gaim-migrate @ 8229]
Luke Schierer <lschiere@pidgin.im>
parents: 7526
diff changeset
362 g_free(buf);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
363 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
364 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
365 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
366 buf = g_win32_error_message( GetLastError() );
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
367 gaim_debug(GAIM_DEBUG_ERROR, "wgaim", "GetModuleFileName error: %s\n", buf);
7606
08c9d0dcf906 [gaim-migrate @ 8229]
Luke Schierer <lschiere@pidgin.im>
parents: 7526
diff changeset
368 g_free(buf);
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
369 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
370 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
371 buf = g_path_get_dirname( install_dir );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
372 strcpy( (char*)&install_dir, buf );
7606
08c9d0dcf906 [gaim-migrate @ 8229]
Luke Schierer <lschiere@pidgin.im>
parents: 7526
diff changeset
373 g_free( buf );
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
374
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
375 return (char*)&install_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
376 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
377
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
378 char* wgaim_lib_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
379 strcpy(lib_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
380 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
381 return (char*)&lib_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
382 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
383
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
384 char* wgaim_locale_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
385 strcpy(locale_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
386 strcat(locale_dir, G_DIR_SEPARATOR_S "locale");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
387 return (char*)&locale_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
388 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
389
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
390 char* wgaim_data_dir(void) {
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
391 return (char*)&app_data_dir;
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
392 }
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
393
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
394 /* Miscellaneous */
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
395
6437
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
396 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
397 HKEY hkey;
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
398 gboolean ret = FALSE;
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
399
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
400 if(ERROR_SUCCESS == RegOpenKeyEx(key,
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
401 sub_key,
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
402 0, KEY_QUERY_VALUE, &hkey)) {
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
403 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
404 ret = TRUE;
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
405 RegCloseKey(key);
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
406 }
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
407 return ret;
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
408 }
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
409
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
410 /* FlashWindowEx is only supported by Win98+ and WinNT5+. If its
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
411 not supported we do it our own way */
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6929
diff changeset
412 void wgaim_conv_im_blink(GtkWidget *window) {
6437
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
413 if(!blink_turned_on)
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
414 return;
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
415 if(MyFlashWindowEx) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
416 FLASHWINFO info;
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
417 memset(&info, 0, sizeof(FLASHWINFO));
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
418 info.cbSize = sizeof(FLASHWINFO);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
419 info.hwnd = GDK_WINDOW_HWND(window->window);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
420 info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
421 info.dwTimeout = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
422 MyFlashWindowEx(&info);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
423 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
424 else {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
425 WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
426
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
427 /* Start Flashing window */
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
428 finfo->t_handle = g_timeout_add(1000,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
429 flash_window_cb,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
430 GDK_WINDOW_HWND(window->window));
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
431 finfo->sig_handler = g_signal_connect(G_OBJECT(window),
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
432 "focus-in-event",
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
433 G_CALLBACK(halt_flash_filter), finfo);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
434 }
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
435 }
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
436
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6929
diff changeset
437 void wgaim_conv_im_blink_state(gboolean val) {
6437
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
438 blink_turned_on = val;
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
439 }
ae4c3abbaac1 [gaim-migrate @ 6945]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6425
diff changeset
440
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
441 int wgaim_gz_decompress(const char* in, const char* out) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
442 gzFile fin;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
443 FILE *fout;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
444 char buf[1024];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
445 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
446
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
447 if((fin = gzopen(in, "rb"))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
448 if(!(fout = fopen(out, "wb"))) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
449 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
450 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
451 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
452 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
453 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
454 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
455 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
456 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
457 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
458
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
459 while((ret=gzread(fin, buf, 1024))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
460 if(fwrite(buf, 1, ret, fout) < ret) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
461 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
462 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
463 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
464 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
465 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
466 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
467 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
468 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
469
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
470 if(ret < 0) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
471 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
472 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
473 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
474
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
475 return 1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
476 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
477
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
478 int wgaim_gz_untar(const char* filename, const char* destdir) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
479 char tmpfile[_MAX_PATH];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
480 char template[]="wgaimXXXXXX";
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
481
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
482 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
483 if(wgaim_gz_decompress(filename, tmpfile)) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
484 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
485 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET))
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
486 ret=1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
487 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
488 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
489 ret=0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
490 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
491 unlink(tmpfile);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
492 return ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
493 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
494 else {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
495 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
496 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
497 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
498 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
499
6083
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
500 /* Moved over from old systray.c */
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
501 void wgaim_systray_minimize( GtkWidget *window ) {
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
502 MinimizeWndToTray(GDK_WINDOW_HWND(window->window));
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
503 }
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
504
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
505 void wgaim_systray_maximize( GtkWidget *window ) {
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
506 RestoreWndFromTray(GDK_WINDOW_HWND(window->window));
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
507 }
65fad4831077 [gaim-migrate @ 6542]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5913
diff changeset
508
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
509 void wgaim_init(HINSTANCE hint) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
510 WORD wVersionRequested;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
511 WSADATA wsaData;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
512 char *perlenv;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
513 char *newenv;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
514
7526
77727178a1df [gaim-migrate @ 8139]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7523
diff changeset
515 gaim_debug_set_ui_ops(&ops);
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
516 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init start\n");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
517
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
518 gaimexe_hInstance = hint;
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
519
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
520 load_winver_specific_procs();
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
521
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
522 /* Winsock init */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
523 wVersionRequested = MAKEWORD( 2, 2 );
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
524 WSAStartup( wVersionRequested, &wsaData );
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
525
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
526 /* Confirm that the winsock DLL supports 2.2 */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
527 /* Note that if the DLL supports versions greater than
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
528 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
529 wVersion since that is the version we requested. */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
530 if ( LOBYTE( wsaData.wVersion ) != 2 ||
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
531 HIBYTE( wsaData.wVersion ) != 2 ) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
532 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
533 WSACleanup();
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
534 }
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
535
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
536 /* Set Environmental Variables */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
537 /* Disable PANGO UNISCRIBE (for GTK 2.2.0). This may not be necessary in the
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
538 future because there will most likely be a check to see if we need this.
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
539 For now we need to set this in order to avoid poor performance for some
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
540 windows machines.
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
541 */
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
542 newenv = g_strdup("PANGO_WIN32_NO_UNISCRIBE=1");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
543 if(putenv(newenv)<0)
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
544 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
545 g_free(newenv);
6816
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
546
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
547 /* Tell perl where to find Gaim's perl modules */
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
548 perlenv = (char*)g_getenv("PERL5LIB");
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
549 newenv = g_strdup_printf("PERL5LIB=%s%s%s%s",
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
550 perlenv ? perlenv : "",
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
551 perlenv ? ";" : "",
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
552 wgaim_install_dir(),
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
553 "\\perlmod;");
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
554 if(putenv(newenv)<0)
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
555 gaim_debug(GAIM_DEBUG_WARNING, "wgaim", "putenv failed\n");
5aeba37b303c [gaim-migrate @ 7356]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6437
diff changeset
556 g_free(newenv);
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
557
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
558 /* Set app data dir, used by gaim_home_dir */
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
559 newenv = (char*)g_getenv("HOME");
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
560 if(!newenv) {
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
561 if((MySHGetFolderPath = (LPFNSHGETFOLDERPATH)wgaim_find_and_loadproc("shfolder.dll", "SHGetFolderPathA"))) {
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
562 MySHGetFolderPath(NULL,
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
563 CSIDL_APPDATA,
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
564 NULL, SHGFP_TYPE_CURRENT, app_data_dir);
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
565 }
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
566 else
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
567 strcpy(app_data_dir, "C:");
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
568 /* As of 0.69, using SHGetFolderPath to determine app settings directory.
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
569 Move app settings to new location if need be. */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
570 move_settings_dir();
6848
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
571 }
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
572 else {
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
573 strcpy(app_data_dir, newenv);
060aa79a733e [gaim-migrate @ 7393]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 6816
diff changeset
574 }
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
575 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
576
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
577 /* IdleTracker Initialization */
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
578 if(!wgaim_set_idlehooks())
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
579 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
580
6cb8b0686e46 [gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4728
diff changeset
581 wgaim_gtkspell_init();
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
582 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_init end\n");
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
583 }
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
584
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
585 /* Windows Cleanup */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
586
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
587 void wgaim_cleanup(void) {
5854
14891982dbee [gaim-migrate @ 6285]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 5472
diff changeset
588 gaim_debug(GAIM_DEBUG_INFO, "wgaim", "wgaim_cleanup\n");
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
589
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
590 /* winsock cleanup */
7523
7c3db2b2a790 [gaim-migrate @ 8136]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 7350
diff changeset
591 WSACleanup();
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
592
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
593 /* Idle tracker cleanup */
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
594 wgaim_remove_idlehooks();
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
595 }
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
596
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
597 /* DLL initializer */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
598 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
599 gaimdll_hInstance = hinstDLL;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
600 return TRUE;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
601 }