mapi32: Add the Polish translation.
[wine] / dlls / mapi32 / mapi32_main.c
1 /*
2  *             MAPI basics
3  *
4  * Copyright 2001, 2009 CodeWeavers Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20
21 #include <stdarg.h>
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winerror.h"
26 #include "objbase.h"
27 #include "initguid.h"
28 #include "mapix.h"
29 #include "mapiform.h"
30 #include "mapi.h"
31 #include "wine/debug.h"
32 #include "util.h"
33
34 WINE_DEFAULT_DEBUG_CHANNEL(mapi);
35
36 LONG MAPI_ObjectCount = 0;
37 HINSTANCE hInstMAPI32;
38
39 /***********************************************************************
40  *              DllMain (MAPI32.init)
41  */
42 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
43 {
44     TRACE("(%p,%d,%p)\n", hinstDLL, fdwReason, fImpLoad);
45
46     switch (fdwReason)
47     {
48     case DLL_PROCESS_ATTACH:
49         hInstMAPI32 = hinstDLL;
50         DisableThreadLibraryCalls(hinstDLL);
51         load_mapi_providers();
52         break;
53     case DLL_PROCESS_DETACH:
54         TRACE("DLL_PROCESS_DETACH: %d objects remaining\n", MAPI_ObjectCount);
55         unload_mapi_providers();
56         break;
57     }
58     return TRUE;
59 }
60
61 /***********************************************************************
62  *              DllGetClassObject (MAPI32.27)
63  */
64 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID iid, LPVOID *ppv)
65 {
66     if (mapiFunctions.DllGetClassObject)
67     {
68         HRESULT ret = mapiFunctions.DllGetClassObject(rclsid, iid, ppv);
69
70         TRACE("ret: %x\n", ret);
71         return ret;
72     }
73
74     FIXME("\n\tCLSID:\t%s,\n\tIID:\t%s\n", debugstr_guid(rclsid), debugstr_guid(iid));
75
76     *ppv = NULL;
77     return CLASS_E_CLASSNOTAVAILABLE;
78 }
79
80 /***********************************************************************
81  * DllCanUnloadNow (MAPI32.28)
82  *
83  * Determine if this dll can be unloaded from the callers address space.
84  *
85  * PARAMS
86  *  None.
87  *
88  * RETURNS
89  *  S_OK, if the dll can be unloaded,
90  *  S_FALSE, otherwise.
91  */
92 HRESULT WINAPI DllCanUnloadNow(void)
93 {
94     HRESULT ret = S_OK;
95
96     if (mapiFunctions.DllCanUnloadNow)
97     {
98         ret = mapiFunctions.DllCanUnloadNow();
99         TRACE("(): provider returns %d\n", ret);
100     }
101
102     return MAPI_ObjectCount == 0 ? ret : S_FALSE;
103 }
104
105 /***********************************************************************
106  * MAPIInitialize
107  *
108  * Initialises the MAPI library. In our case, we pass through to the
109  * loaded Extended MAPI provider.
110  */
111 HRESULT WINAPI MAPIInitialize(LPVOID init)
112 {
113     TRACE("(%p)\n", init);
114
115     if (mapiFunctions.MAPIInitialize)
116         return mapiFunctions.MAPIInitialize(init);
117
118     return MAPI_E_NOT_INITIALIZED;
119 }
120
121 /***********************************************************************
122  * MAPILogon
123  *
124  * Logs on to a MAPI provider. If available, we pass this through to a
125  * Simple MAPI provider. Otherwise, we maintain basic functionality
126  * ourselves.
127  */
128 ULONG WINAPI MAPILogon(ULONG_PTR uiparam, LPSTR profile, LPSTR password,
129     FLAGS flags, ULONG reserved, LPLHANDLE session)
130 {
131     TRACE("(0x%08lx %s %p 0x%08x 0x%08x %p)\n", uiparam,
132           debugstr_a(profile), password, flags, reserved, session);
133
134     if (mapiFunctions.MAPILogon)
135         return mapiFunctions.MAPILogon(uiparam, profile, password, flags, reserved, session);
136
137     if (session) *session = 1;
138     return SUCCESS_SUCCESS;
139 }
140
141 /***********************************************************************
142  * MAPILogoff
143  *
144  * Logs off from a MAPI provider. If available, we pass this through to a
145  * Simple MAPI provider. Otherwise, we maintain basic functionality
146  * ourselves.
147  */
148 ULONG WINAPI MAPILogoff(LHANDLE session, ULONG_PTR uiparam, FLAGS flags,
149     ULONG reserved )
150 {
151     TRACE("(0x%08lx 0x%08lx 0x%08x 0x%08x)\n", session,
152           uiparam, flags, reserved);
153
154     if (mapiFunctions.MAPILogoff)
155         return mapiFunctions.MAPILogoff(session, uiparam, flags, reserved);
156
157     return SUCCESS_SUCCESS;
158 }
159
160 /***********************************************************************
161  * MAPILogonEx
162  *
163  * Logs on to a MAPI provider. If available, we pass this through to an
164  * Extended MAPI provider. Otherwise, we return an error.
165  */
166 HRESULT WINAPI MAPILogonEx(ULONG_PTR uiparam, LPWSTR profile,
167     LPWSTR password, ULONG flags, LPMAPISESSION *session)
168 {
169     TRACE("(0x%08lx %s %p 0x%08x %p)\n", uiparam,
170           debugstr_w(profile), password, flags, session);
171
172     if (mapiFunctions.MAPILogonEx)
173         return mapiFunctions.MAPILogonEx(uiparam, profile, password, flags, session);
174
175     return E_FAIL;
176 }
177
178 HRESULT WINAPI MAPIOpenLocalFormContainer(LPVOID *ppfcnt)
179 {
180     if (mapiFunctions.MAPIOpenLocalFormContainer)
181         return mapiFunctions.MAPIOpenLocalFormContainer(ppfcnt);
182
183     FIXME("(%p) Stub\n", ppfcnt);
184     return E_FAIL;
185 }
186
187 /***********************************************************************
188  * MAPIUninitialize
189  *
190  * Uninitialises the MAPI library. In our case, we pass through to the
191  * loaded Extended MAPI provider.
192  *
193  */
194 VOID WINAPI MAPIUninitialize(void)
195 {
196     TRACE("()\n");
197
198     /* Try to uninitialise the Extended MAPI library */
199     if (mapiFunctions.MAPIUninitialize)
200         mapiFunctions.MAPIUninitialize();
201 }
202
203 HRESULT WINAPI MAPIAdminProfiles(ULONG ulFlags,  LPPROFADMIN *lppProfAdmin)
204 {
205     if (mapiFunctions.MAPIAdminProfiles)
206         return mapiFunctions.MAPIAdminProfiles(ulFlags, lppProfAdmin);
207
208     FIXME("(%u, %p): stub\n", ulFlags, lppProfAdmin);
209     *lppProfAdmin = NULL;
210     return E_FAIL;
211 }
212
213 ULONG WINAPI MAPIAddress(LHANDLE session, ULONG_PTR uiparam, LPSTR caption,
214     ULONG editfields, LPSTR labels, ULONG nRecips, lpMapiRecipDesc lpRecips,
215     FLAGS flags, ULONG reserved, LPULONG newRecips, lpMapiRecipDesc * lppNewRecips)
216 {
217     if (mapiFunctions.MAPIAddress)
218         return mapiFunctions.MAPIAddress(session, uiparam, caption, editfields, labels,
219             nRecips, lpRecips, flags, reserved, newRecips, lppNewRecips);
220
221     return MAPI_E_NOT_SUPPORTED;
222 }
223
224 ULONG WINAPI MAPIDeleteMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
225     FLAGS flags, ULONG reserved)
226 {
227     if (mapiFunctions.MAPIDeleteMail)
228         return mapiFunctions.MAPIDeleteMail(session, uiparam, msg_id, flags, reserved);
229
230     return MAPI_E_NOT_SUPPORTED;
231 }
232
233 ULONG WINAPI MAPIDetails(LHANDLE session, ULONG_PTR uiparam, lpMapiRecipDesc recip,
234     FLAGS flags, ULONG reserved)
235 {
236     if (mapiFunctions.MAPIDetails)
237         return mapiFunctions.MAPIDetails(session, uiparam, recip, flags, reserved);
238
239     return MAPI_E_NOT_SUPPORTED;
240 }
241
242 ULONG WINAPI MAPIFindNext(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_type,
243     LPSTR seed_msg_id, FLAGS flags, ULONG reserved, LPSTR msg_id)
244 {
245     if (mapiFunctions.MAPIFindNext)
246         return mapiFunctions.MAPIFindNext(session, uiparam, msg_type, seed_msg_id, flags, reserved, msg_id);
247
248     return MAPI_E_NOT_SUPPORTED;
249 }
250
251 ULONG WINAPI MAPIReadMail(LHANDLE session, ULONG_PTR uiparam, LPSTR msg_id,
252     FLAGS flags, ULONG reserved, lpMapiMessage msg)
253 {
254     if (mapiFunctions.MAPIReadMail)
255         return mapiFunctions.MAPIReadMail(session, uiparam, msg_id, flags, reserved, msg);
256
257     return MAPI_E_NOT_SUPPORTED;
258 }
259
260 ULONG WINAPI MAPIResolveName(LHANDLE session, ULONG_PTR uiparam, LPSTR name,
261     FLAGS flags, ULONG reserved, lpMapiRecipDesc *recip)
262 {
263     if (mapiFunctions.MAPIResolveName)
264         return mapiFunctions.MAPIResolveName(session, uiparam, name, flags, reserved, recip);
265
266     return MAPI_E_NOT_SUPPORTED;
267 }
268
269 ULONG WINAPI MAPISaveMail(LHANDLE session, ULONG_PTR uiparam, lpMapiMessage msg,
270     FLAGS flags, ULONG reserved, LPSTR msg_id)
271 {
272     if (mapiFunctions.MAPISaveMail)
273         return mapiFunctions.MAPISaveMail(session, uiparam, msg, flags, reserved, msg_id);
274
275     return MAPI_E_NOT_SUPPORTED;
276 }