Mercurial > pidgin.yaz
annotate src/win32/win32dep.c @ 3950:c25cf0495533
[gaim-migrate @ 4129]
Moved systray functionality to systray.c
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Mon, 11 Nov 2002 21:57:19 +0000 |
parents | 41e7544a9c67 |
children | d9287e87ba56 |
rev | line source |
---|---|
3630 | 1 /* |
2 * win32dep.c | |
3 * | |
4 * Author: Herman Bloggs <hermanator12002@yahoo.com> | |
5 * Date: June, 2002 | |
6 * Description: Windows dependant code for Gaim | |
7 */ | |
8 #include <windows.h> | |
9 #include <stdlib.h> | |
10 #include <stdio.h> | |
11 #include <glib.h> | |
12 #include "gaim.h" | |
13 | |
14 #include "stdafx.h" | |
15 #include "resource.h" | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
16 #include "MinimizeToTray.h" |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
17 #include "systray.h" |
3630 | 18 |
19 /* | |
20 * DEFINES & MACROS | |
21 */ | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
22 |
3630 | 23 |
24 /* | |
25 * LOCALS | |
26 */ | |
27 static char install_dir[MAXPATHLEN]; | |
28 static char lib_dir[MAXPATHLEN]; | |
29 static char locale_dir[MAXPATHLEN]; | |
30 static int bhide_icon; | |
31 | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
32 |
3630 | 33 /* |
34 * GLOBALS | |
35 */ | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
36 HINSTANCE gaimexe_hInstance = 0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
37 HINSTANCE gaimdll_hInstance = 0; |
3630 | 38 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
39 |
3630 | 40 /* |
41 * STATIC CODE | |
42 */ | |
43 | |
44 | |
45 | |
46 /* | |
47 * PUBLIC CODE | |
48 */ | |
49 | |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
50 /* Misc Wingaim functions */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
51 HINSTANCE wgaim_hinstance(void) { |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
52 return gaimexe_hInstance; |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
53 } |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
54 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
55 /* Determine Gaim Paths during Runtime */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
56 |
3630 | 57 char* wgaim_install_dir(void) { |
58 HMODULE hmod; | |
59 char* buf; | |
60 | |
61 hmod = GetModuleHandle(NULL); | |
62 if( hmod == 0 ) { | |
63 buf = g_win32_error_message( GetLastError() ); | |
64 debug_printf("GetModuleHandle error: %s\n", buf); | |
65 free(buf); | |
66 return NULL; | |
67 } | |
68 if(GetModuleFileName( hmod, (char*)&install_dir, MAXPATHLEN ) == 0) { | |
69 buf = g_win32_error_message( GetLastError() ); | |
70 debug_printf("GetModuleFileName error: %s\n", buf); | |
71 free(buf); | |
72 return NULL; | |
73 } | |
74 buf = g_path_get_dirname( install_dir ); | |
75 strcpy( (char*)&install_dir, buf ); | |
76 free( buf ); | |
77 | |
78 return (char*)&install_dir; | |
79 } | |
80 | |
81 char* wgaim_lib_dir(void) { | |
82 strcpy(lib_dir, wgaim_install_dir()); | |
83 strcat(lib_dir, G_DIR_SEPARATOR_S "plugins"); | |
84 return (char*)&lib_dir; | |
85 } | |
86 | |
87 char* wgaim_locale_dir(void) { | |
88 strcpy(locale_dir, wgaim_install_dir()); | |
89 strcat(locale_dir, G_DIR_SEPARATOR_S "locale"); | |
90 return (char*)&locale_dir; | |
91 } | |
92 | |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
93 /* Windows Initializations */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
94 |
3630 | 95 void wgaim_init(void) { |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
96 WORD wVersionRequested; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
97 WSADATA wsaData; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
98 int err; |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
99 char* locale=0; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
100 char newenv[128]; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
101 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
102 debug_printf("wgaim_init\n"); |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
103 |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
104 /* Initialize Wingaim systray icon */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
105 wgaim_systray_init(); |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
106 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
107 /* |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
108 * Winsock init |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
109 */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
110 wVersionRequested = MAKEWORD( 2, 2 ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
111 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
112 err = WSAStartup( wVersionRequested, &wsaData ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
113 if ( err != 0 ) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
114 return 1; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
115 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
116 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
117 /* Confirm that the winsock DLL supports 2.2 */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
118 /* Note that if the DLL supports versions greater than |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
119 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
|
120 wVersion since that is the version we requested. */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
121 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
122 if ( LOBYTE( wsaData.wVersion ) != 2 || |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
123 HIBYTE( wsaData.wVersion ) != 2 ) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
124 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
|
125 WSACleanup( ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
126 return 1; |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
127 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
128 |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
129 /* get default locale */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
130 locale = g_win32_getlocale(); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
131 debug_printf("Language profile used: %s\n", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
132 |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
133 /* |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
134 * Aspell config |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
135 */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
136 /* Set LANG env var */ |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
137 sprintf(newenv, "LANG=%s", locale); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
138 if(putenv(newenv)<0) |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
139 debug_printf("putenv failed\n"); |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
140 g_free(locale); |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
141 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
142 /* |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
143 * IdleTracker Initialization |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
144 */ |
3905
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
145 if(!IdleTrackerInit()) |
3e508dd31b76
[gaim-migrate @ 4058]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3856
diff
changeset
|
146 debug_printf("IdleTracker failed to initialize\n"); |
3630 | 147 } |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
148 |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
149 /* Windows Cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
150 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
151 void wgaim_cleanup(void) { |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
152 debug_printf("wgaim_cleanup\n"); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
153 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
154 /* winsock cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
155 WSACleanup( ); |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
156 |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
157 /* IdleTracker cleanup */ |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
158 IdleTrackerTerm(); |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
159 |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
160 /* Remove systray icon */ |
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
161 wgaim_systray_cleanup(); |
3907
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
162 } |
41e7544a9c67
[gaim-migrate @ 4060]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3905
diff
changeset
|
163 |
3950
c25cf0495533
[gaim-migrate @ 4129]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3907
diff
changeset
|
164 /* DLL initializer */ |
3856
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
165 BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved ) { |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
166 gaimdll_hInstance = hinstDLL; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
167 return TRUE; |
50ac7e205045
[gaim-migrate @ 4008]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
3630
diff
changeset
|
168 } |