annotate src/win32/win32dep.c @ 5411:2c4188300aba

[gaim-migrate @ 5787] This fixes an i18n thing, I think. I changed some stuff in oscar.c to use _() instead of calling gettext directly. That's ok, right? I like the macro better. I also fixed a compile warning or two. If that function declaration isn't supposed to be there, feel free to move it, or remove it, or lemme know and I'll do it. Viva 0.63! committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 17 May 2003 05:41:18 +0000
parents 89a5b0e23ea4
children a2acc2b79ff1
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 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * win32dep.c
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Author: Herman Bloggs <hermanator12002@yahoo.com>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 * Date: June, 2002
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * Description: Windows dependant code for Gaim
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 #include <windows.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 #include <stdlib.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 #include <stdio.h>
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
11 #include <winuser.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 #include <glib.h>
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
13 #include <gdk/gdkwin32.h>
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
14
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 #include "gaim.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 #include "stdafx.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 #include "resource.h"
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
18 #include "MinimizeToTray.h"
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
19 #include "systray.h"
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
20 #include "winuser_extra.h"
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
21 #include "idletrack.h"
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
22 #include "zlib.h"
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
23 #include "untar.h"
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 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
26 * DEFINES & MACROS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
27 */
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
28
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
29 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
30 * DATA STRUCTS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
31 */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
32 struct _WGAIM_FLASH_INFO {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
33 guint t_handle;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
34 guint sig_handler;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
35 };
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
36 typedef struct _WGAIM_FLASH_INFO WGAIM_FLASH_INFO;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
37
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
38 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
39 * LOCALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
40 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
41 static char install_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
42 static char lib_dir[MAXPATHLEN];
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
43 static char locale_dir[MAXPATHLEN];
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
44
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
45 /*
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 * GLOBALS
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
47 */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
48 HINSTANCE gaimexe_hInstance = 0;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
49 HINSTANCE gaimdll_hInstance = 0;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
50
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
51 /*
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
52 * PROTOS
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
53 */
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
54
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
55 BOOL (*MyFlashWindowEx)(PFLASHWINFO pfwi)=NULL;
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
56 FARPROC wgaim_find_and_loadproc(char*, char*);
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
57 extern void wgaim_gtkspell_init();
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
58
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
59 /*
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
60 * STATIC CODE
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
61 */
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
62
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
63 /* Window flasher */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
64 static gboolean flash_window_cb(gpointer data) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
65 FlashWindow((HWND)data, TRUE);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
66 return TRUE;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
67 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
68
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
69 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
70 /* Stop flashing and remove filter */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
71 debug_printf("Removing timeout\n");
4168
ebfb80bbe1ed [gaim-migrate @ 4397]
Luke Schierer <lschiere@pidgin.im>
parents: 4106
diff changeset
72 g_source_remove(finfo->t_handle);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
73 debug_printf("Disconnecting signal handler\n");
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
74 g_signal_handler_disconnect(G_OBJECT(widget),finfo->sig_handler);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
75 debug_printf("done\n");
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
76 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
77
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
78 static void load_winver_specific_procs(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
79 /* Used for Win98+ and WinNT5+ */
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
80 MyFlashWindowEx = (void*)wgaim_find_and_loadproc("user32.dll", "FlashWindowEx" );
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
81 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
82
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
83 /*
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
84 * PUBLIC CODE
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
85 */
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
86
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
87 HINSTANCE wgaim_hinstance(void) {
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
88 return gaimexe_hInstance;
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
89 }
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
90
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
91 /* Escape windows dir separators. This is needed when paths are saved,
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
92 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
93 Returns an allocated string which needs to be freed.
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
94 */
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
95 char* wgaim_escape_dirsep( char* filename ) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
96 int sepcount=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
97 char* ret=NULL;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
98 int cnt=0;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
99
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
100 ret = filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
101 while(*ret) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
102 if(*ret == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
103 sepcount++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
104 ret++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
105 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
106 ret = g_malloc0(strlen(filename) + sepcount + 1);
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
107 while(*filename) {
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
108 ret[cnt] = *filename;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
109 if(*filename == '\\')
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
110 ret[++cnt] = '\\';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
111 filename++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
112 cnt++;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
113 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
114 ret[cnt] = '\0';
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
115 return ret;
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
116 }
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
117
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
118 /*
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
119 * This is a hack to circumvent the conflict between the
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
120 * windows behaviour of gtk_window_get_pos and gtk_window_move, which
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
121 * exists in GTK+ v2.2.0. GTK+ documentation explains the following
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
122 * should be true for gtk_window_get_pos:
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
123 * This function returns the position you need to pass to
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
124 * gtk_window_move() to keep window in its current position.
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
125 * This is false (for windows). gtk_window_get_pos returns
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
126 * client coords, whereas gtk_window_move accepts non-client coords.
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
127 * Our solution, until this is fixed, is to anticipate the offset and
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
128 * adjust the coordinates passed to gtk_window_move.
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
129 */
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
130 void wgaim_gtk_window_move(GtkWindow *window, gint x, gint y) {
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
131 LONG style, extended_style;
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
132 RECT trect;
4984
b5e52f7e5302 [gaim-migrate @ 5319]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4882
diff changeset
133 HWND hWnd;
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
134
4984
b5e52f7e5302 [gaim-migrate @ 5319]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4882
diff changeset
135 if(!GTK_WIDGET_REALIZED(GTK_WIDGET(window)))
b5e52f7e5302 [gaim-migrate @ 5319]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4882
diff changeset
136 gtk_widget_realize(GTK_WIDGET(window));
b5e52f7e5302 [gaim-migrate @ 5319]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4882
diff changeset
137 hWnd = GDK_WINDOW_HWND(GTK_WIDGET(window)->window);
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
138 style = GetWindowLong(hWnd, GWL_STYLE);
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
139 extended_style = GetWindowLong (hWnd, GWL_EXSTYLE);
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
140 GetClientRect (hWnd, &trect);
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
141 AdjustWindowRectEx (&trect, style, FALSE, extended_style);
4882
8e25dff29859 [gaim-migrate @ 5212]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4861
diff changeset
142 gtk_window_move(window, x + (-1 * trect.left), y + (-1 * trect.top));
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
143 }
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
144
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
145
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
146 /* Determine whether the specified dll contains the specified procedure.
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
147 If so, load it (if not already loaded). */
4097
929d23ef2ded [gaim-migrate @ 4312]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4042
diff changeset
148 FARPROC wgaim_find_and_loadproc( char* dllname, char* procedure ) {
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
149 HMODULE hmod;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
150 int did_load=0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
151 FARPROC proc = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
152
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
153 if(!(hmod=GetModuleHandle(dllname))) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
154 debug_printf("%s not found. Loading it..\n", dllname);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
155 if(!(hmod = LoadLibrary(dllname))) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
156 debug_printf("Could not load: %s\n", dllname);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
157 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
158 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
159 else
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
160 did_load = 1;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
161 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
162
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
163 if((proc=GetProcAddress(hmod, procedure))) {
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
164 debug_printf("This version of %s contains %s\n",
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
165 dllname, procedure);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
166 return proc;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
167 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
168 else {
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
169 debug_printf("Function: %s not found in dll: %s\n",
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
170 procedure, dllname);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
171 if(did_load) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
172 /* unload dll */
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
173 FreeLibrary(hmod);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
174 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
175 return NULL;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
176 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
177 }
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
178
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
179 /* Determine Gaim Paths during Runtime */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
180
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
181 char* wgaim_install_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
182 HMODULE hmod;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
183 char* buf;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
184
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
185 hmod = GetModuleHandle(NULL);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
186 if( hmod == 0 ) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
187 buf = g_win32_error_message( GetLastError() );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
188 debug_printf("GetModuleHandle error: %s\n", buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
189 free(buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
190 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
191 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
192 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
193 buf = g_win32_error_message( GetLastError() );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
194 debug_printf("GetModuleFileName error: %s\n", buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
195 free(buf);
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
196 return NULL;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
197 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
198 buf = g_path_get_dirname( install_dir );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
199 strcpy( (char*)&install_dir, buf );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
200 free( buf );
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
201
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
202 return (char*)&install_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
203 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
204
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
205 char* wgaim_lib_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
206 strcpy(lib_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
207 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
208 return (char*)&lib_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
209 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
210
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
211 char* wgaim_locale_dir(void) {
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
212 strcpy(locale_dir, wgaim_install_dir());
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
213 strcat(locale_dir, G_DIR_SEPARATOR_S "locale");
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
214 return (char*)&locale_dir;
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
215 }
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
216
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
217 /* Miscellaneous */
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
218
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
219 /* FlashWindowEx is only supported by Win98+ and WinNT5+. If its
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
220 not supported we do it our own way */
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
221 void wgaim_im_blink(GtkWidget *window) {
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
222 if(MyFlashWindowEx) {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
223 FLASHWINFO info;
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
224
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
225 info.cbSize = sizeof(FLASHWINFO);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
226 info.hwnd = GDK_WINDOW_HWND(window->window);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
227 info.dwFlags = FLASHW_ALL | FLASHW_TIMERNOFG;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
228 info.dwTimeout = 0;
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
229 MyFlashWindowEx(&info);
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 else {
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
232 WGAIM_FLASH_INFO *finfo = g_new0(WGAIM_FLASH_INFO, 1);
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
233
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
234 /* Start Flashing window */
4555
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
235 finfo->t_handle = g_timeout_add(1000,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
236 flash_window_cb,
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
237 GDK_WINDOW_HWND(window->window));
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
238 finfo->sig_handler = g_signal_connect(G_OBJECT(window),
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
239 "focus-in-event",
75f75ef235e4 [gaim-migrate @ 4835]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4535
diff changeset
240 G_CALLBACK(halt_flash_filter), finfo);
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
241 }
3973
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
242 }
d9287e87ba56 [gaim-migrate @ 4157]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3950
diff changeset
243
5008
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
244 int wgaim_gz_decompress(const char* in, const char* out) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
245 gzFile fin;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
246 FILE *fout;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
247 char buf[1024];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
248 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
249
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
250 if((fin = gzopen(in, "rb"))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
251 if(!(fout = fopen(out, "wb"))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
252 debug_printf("wgaim_gz_decompress: Error opening file: %s\n", out);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
253 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
254 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
255 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
256 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
257 else {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
258 debug_printf("wgaim_gz_decompress: gzopen failed to open: %s\n", in);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
259 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
260 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
261
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
262 while((ret=gzread(fin, buf, 1024))) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
263 if(fwrite(buf, 1, ret, fout) < ret) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
264 debug_printf("wgaim_gz_decompress: Error writing %d bytes to file\n", ret);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
265 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
266 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
267 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
268 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
269 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
270 fclose(fout);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
271 gzclose(fin);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
272
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
273 if(ret < 0) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
274 debug_printf("wgaim_gz_decompress: gzread failed while reading: %s\n", in);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
275 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
276 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
277
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
278 return 1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
279 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
280
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
281 int wgaim_gz_untar(const char* filename, const char* destdir) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
282 char tmpfile[_MAX_PATH];
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
283 char template[]="wgaimXXXXXX";
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
284
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
285 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
286 if(wgaim_gz_decompress(filename, tmpfile)) {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
287 int ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
288 if(untar(tmpfile, destdir, UNTAR_FORCE | UNTAR_QUIET))
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
289 ret=1;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
290 else {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
291 debug_printf("wgaim_gz_untar: Failure untaring %s\n", tmpfile);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
292 ret=0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
293 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
294 unlink(tmpfile);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
295 return ret;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
296 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
297 else {
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
298 debug_printf("wgaim_gz_untar: Failed to gz decompress %s\n", filename);
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
299 return 0;
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
300 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
301 }
89a5b0e23ea4 [gaim-migrate @ 5343]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4984
diff changeset
302
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
303 /* Windows Initializations */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
304
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
305 void wgaim_init(void) {
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
306 WORD wVersionRequested;
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
307 WSADATA wsaData;
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
308 char* locale=0;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
309 char newenv[128];
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
310
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
311 debug_printf("wgaim_init\n");
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
312
3983
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
313 load_winver_specific_procs();
a1245dcf7b31 [gaim-migrate @ 4174]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3973
diff changeset
314
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
315 /* Initialize Wingaim systray icon */
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
316 wgaim_systray_init();
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
317
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
318 /*
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
319 * Winsock init
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
320 */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
321 wVersionRequested = MAKEWORD( 2, 2 );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
322
4406
217572342740 [gaim-migrate @ 4675]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4168
diff changeset
323 WSAStartup( wVersionRequested, &wsaData );
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
324
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
325 /* Confirm that the winsock DLL supports 2.2 */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
326 /* Note that if the DLL supports versions greater than
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
327 2.2 in addition to 2.2, it will still return 2.2 in
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
328 wVersion since that is the version we requested. */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
329
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
330 if ( LOBYTE( wsaData.wVersion ) != 2 ||
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
331 HIBYTE( wsaData.wVersion ) != 2 ) {
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
332 debug_printf("Could not find a usable WinSock DLL. Oh well.\n");
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
333 WSACleanup( );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
334 }
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
335
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
336 /* get default locale */
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
337 locale = g_win32_getlocale();
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
338 debug_printf("Language profile used: %s\n", locale);
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
339
4411
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
340 /* Aspell config */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
341 sprintf(newenv, "LANG=%s", locale);
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
342 if(putenv(newenv)<0)
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
343 debug_printf("putenv failed\n");
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
344 g_free(locale);
3905
3e508dd31b76 [gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3856
diff changeset
345
4411
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
346 /* Disable PANGO UNISCRIBE (for GTK 2.2.0). This may not be necessary in the
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
347 future because there will most likely be a check to see if we need this,
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
348 but for now we need to set this in order to avoid poor performance for some
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
349 windows machines.
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
350 */
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
351 sprintf(newenv, "PANGO_WIN32_NO_UNISCRIBE=1");
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
352 if(putenv(newenv)<0)
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
353 debug_printf("putenv failed\n");
2ad81729c049 [gaim-migrate @ 4684]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4406
diff changeset
354
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
355 /*
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
356 * IdleTracker Initialization
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
357 */
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
358 if(!wgaim_set_idlehooks())
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
359 debug_printf("Failed to initialize idle tracker\n");
4861
6cb8b0686e46 [gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4728
diff changeset
360
6cb8b0686e46 [gaim-migrate @ 5188]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4728
diff changeset
361 wgaim_gtkspell_init();
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
362 }
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
363
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
364 /* Windows Cleanup */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
365
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
366 void wgaim_cleanup(void) {
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
367 debug_printf("wgaim_cleanup\n");
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
368
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
369 /* winsock cleanup */
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
370 WSACleanup( );
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
371
4535
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
372 /* Idle tracker cleanup */
de9f45c815df [gaim-migrate @ 4814]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 4411
diff changeset
373 wgaim_remove_idlehooks();
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
374
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
375 /* Remove systray icon */
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
376 wgaim_systray_cleanup();
3907
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
377 }
41e7544a9c67 [gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3905
diff changeset
378
3950
c25cf0495533 [gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3907
diff changeset
379 /* DLL initializer */
3856
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
380 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) {
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
381 gaimdll_hInstance = hinstDLL;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
382 return TRUE;
50ac7e205045 [gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3630
diff changeset
383 }