wine.inf: Add some dll stub dll to the system directory.
[wine/multimedia.git] / dlls / mshtml / nsservice.c
blob62e5a27d54e87029904f22271eca910d5ae551e4
1 /*
2 * Copyright 2005 Jacek Caban
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include "config.h"
21 #include <stdarg.h>
23 #define COBJMACROS
25 #include "windef.h"
26 #include "winbase.h"
27 #include "winuser.h"
28 #include "winreg.h"
29 #include "ole2.h"
31 #include "wine/debug.h"
32 #include "wine/unicode.h"
34 #include "mshtml_private.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
38 #define NS_PROMPTSERVICE_CONTRACTID "@mozilla.org/embedcomp/prompt-service;1"
39 #define NS_WINDOWWATCHER_CONTRACTID "@mozilla.org/embedcomp/window-watcher;1"
41 static const nsIID NS_PROMPTSERVICE_CID =
42 {0xa2112d6a,0x0e28,0x421f,{0xb4,0x6a,0x25,0xc0,0xb3,0x8,0xcb,0xd0}};
44 static nsresult NSAPI nsWindowCreator_QueryInterface(nsIWindowCreator2 *iface, nsIIDRef riid,
45 nsQIResult result)
47 *result = NULL;
49 if(IsEqualGUID(&IID_nsISupports, riid)) {
50 TRACE("(IID_nsISupports %p)\n", result);
51 *result = iface;
52 }else if(IsEqualGUID(&IID_nsIWindowCreator, riid)) {
53 TRACE("(IID_nsIWindowCreator %p)\n", result);
54 *result = iface;
55 }else if(IsEqualGUID(&IID_nsIWindowCreator2, riid)) {
56 TRACE("(IID_nsIWindowCreator2 %p)\n", result);
57 *result = iface;
60 if(*result) {
61 nsIWindowCreator_AddRef(iface);
62 return NS_OK;
65 WARN("(%s %p)\n", debugstr_guid(riid), result);
66 return NS_NOINTERFACE;
69 static nsrefcnt NSAPI nsWindowCreator_AddRef(nsIWindowCreator2 *iface)
71 return 2;
74 static nsrefcnt NSAPI nsWindowCreator_Release(nsIWindowCreator2 *iface)
76 return 1;
79 static nsresult NSAPI nsWindowCreator_CreateChromeWindow(nsIWindowCreator2 *iface,
80 nsIWebBrowserChrome *parent, PRUint32 chromeFlags, nsIWebBrowserChrome **_retval)
82 TRACE("(%p %08lx %p)\n", parent, chromeFlags, _retval);
83 return nsIWindowCreator2_CreateChromeWindow2(iface, parent, chromeFlags, 0, NULL,
84 NULL, _retval);
87 static nsresult NSAPI nsWindowCreator_CreateChromeWindow2(nsIWindowCreator2 *iface,
88 nsIWebBrowserChrome *parent, PRUint32 chromeFlags, PRUint32 contextFlags,
89 nsIURI *uri, PRBool *cancel, nsIWebBrowserChrome **_retval)
91 TRACE("(%p %08lx %08lx %p %p %p)\n", parent, chromeFlags, contextFlags, uri,
92 cancel, _retval);
94 if(cancel)
95 *cancel = FALSE;
97 *_retval = NSWBCHROME(NSContainer_Create(NULL, (NSContainer*)parent));
98 return NS_OK;
101 static const nsIWindowCreator2Vtbl nsWindowCreatorVtbl = {
102 nsWindowCreator_QueryInterface,
103 nsWindowCreator_AddRef,
104 nsWindowCreator_Release,
105 nsWindowCreator_CreateChromeWindow,
106 nsWindowCreator_CreateChromeWindow2
109 static nsIWindowCreator2 nsWindowCreator = { &nsWindowCreatorVtbl };
111 static nsresult NSAPI nsPromptService_QueryInterface(nsIPromptService *iface,
112 nsIIDRef riid, nsQIResult result)
114 *result = NULL;
116 if(IsEqualGUID(&IID_nsISupports, riid)) {
117 TRACE("(IID_nsISupports %p)\n", result);
118 *result = iface;
119 }else if(IsEqualGUID(&IID_nsIPromptService, riid)) {
120 TRACE("(IID_nsIPromptService %p)\n", result);
121 *result = iface;
124 if(*result)
125 return NS_OK;
127 TRACE("(%s %p)\n", debugstr_guid(riid), result);
128 return NS_NOINTERFACE;
131 static nsrefcnt NSAPI nsPromptService_AddRef(nsIPromptService *iface)
133 return 2;
136 static nsrefcnt NSAPI nsPromptService_Release(nsIPromptService *iface)
138 return 1;
141 static nsresult NSAPI nsPromptService_Alert(nsIPromptService *iface, nsIDOMWindow *aParent,
142 const PRUnichar *aDialogTitle, const PRUnichar *aText)
144 FIXME("(%p %s %s)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText));
145 return NS_ERROR_NOT_IMPLEMENTED;
148 static nsresult NSAPI nsPromptService_AlertCheck(nsIPromptService *iface,
149 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
150 const PRUnichar *aText, const PRUnichar *aCheckMsg, PRBool *aCheckState)
152 FIXME("(%p %s %s %s %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
153 debugstr_w(aCheckMsg), aCheckState);
154 return NS_ERROR_NOT_IMPLEMENTED;
157 static nsresult NSAPI nsPromptService_Confirm(nsIPromptService *iface,
158 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle, const PRUnichar *aText,
159 PRBool *_retval)
161 FIXME("(%p %s %s %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText), _retval);
162 return NS_ERROR_NOT_IMPLEMENTED;
165 static nsresult NSAPI nsPromptService_ConfirmCheck(nsIPromptService *iface,
166 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
167 const PRUnichar *aText, const PRUnichar *aCheckMsg, PRBool *aCheckState,
168 PRBool *_retval)
170 FIXME("(%p %s %s %s %p %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
171 debugstr_w(aCheckMsg), aCheckState, _retval);
172 return NS_ERROR_NOT_IMPLEMENTED;
175 static nsresult NSAPI nsPromptService_ConfirmEx(nsIPromptService *iface,
176 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
177 const PRUnichar *aText, PRUint32 aButtonFlags, const PRUnichar *aButton0Title,
178 const PRUnichar *aButton1Title, const PRUnichar *aButton2Title,
179 const PRUnichar *aCheckMsg, PRBool *aCheckState, PRInt32 *_retval)
181 static const PRUnichar wszContinue[] = {'C','o','n','t','i','n','u','e',0};
183 FIXME("(%p %s %s %08lx %s %s %s %s %p %p) hack!\n", aParent, debugstr_w(aDialogTitle),
184 debugstr_w(aText), aButtonFlags, debugstr_w(aButton0Title),
185 debugstr_w(aButton1Title), debugstr_w(aButton2Title), debugstr_w(aCheckMsg),
186 aCheckState, _retval);
189 * FIXME:
190 * This is really very very ugly hack!!!
193 if(aButton0Title && !memcmp(aButton0Title, wszContinue, sizeof(wszContinue)))
194 *_retval = 0;
195 else if(aButton1Title && !memcmp(aButton1Title, wszContinue, sizeof(wszContinue)))
196 *_retval = 1;
197 else if(aButton2Title && !memcmp(aButton2Title, wszContinue, sizeof(wszContinue)))
198 *_retval = 2;
199 /* else
200 * let's hope that _retval is set to the default value */
202 return NS_OK;
205 static nsresult NSAPI nsPromptService_Prompt(nsIPromptService *iface,
206 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
207 const PRUnichar *aText, PRUnichar **aValue, const PRUnichar *aCheckMsg,
208 PRBool *aCheckState, PRBool *_retval)
210 FIXME("(%p %s %s %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
211 aValue, debugstr_w(aCheckMsg), aCheckState, _retval);
212 return NS_ERROR_NOT_IMPLEMENTED;
215 static nsresult NSAPI nsPromptService_PromptUsernameAndPassword(nsIPromptService *iface,
216 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
217 const PRUnichar *aText, PRUnichar **aUsername, PRUnichar **aPassword,
218 const PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval)
220 FIXME("(%p %s %s %p %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle),
221 debugstr_w(aText), aUsername, aPassword, debugstr_w(aCheckMsg), aCheckState,
222 _retval);
223 return NS_ERROR_NOT_IMPLEMENTED;
226 static nsresult NSAPI nsPromptService_PromptPassword(nsIPromptService *iface,
227 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
228 const PRUnichar *aText, PRUnichar **aPassword, const PRUnichar *aCheckMsg,
229 PRBool *aCheckState, PRBool *_retval)
231 FIXME("(%p %s %s %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle),
232 debugstr_w(aText), aPassword, debugstr_w(aCheckMsg), aCheckState, _retval);
233 return NS_ERROR_NOT_IMPLEMENTED;
236 static nsresult NSAPI nsPromptService_Select(nsIPromptService *iface,
237 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
238 const PRUnichar *aText, PRUint32 aCount, const PRUnichar **aSelectList,
239 PRInt32 *aOutSelection, PRBool *_retval)
241 FIXME("(%p %s %s %ld %p %p %p)\n", aParent, debugstr_w(aDialogTitle),
242 debugstr_w(aText), aCount, aSelectList, aOutSelection, _retval);
243 return NS_ERROR_NOT_IMPLEMENTED;
246 static const nsIPromptServiceVtbl PromptServiceVtbl = {
247 nsPromptService_QueryInterface,
248 nsPromptService_AddRef,
249 nsPromptService_Release,
250 nsPromptService_Alert,
251 nsPromptService_AlertCheck,
252 nsPromptService_Confirm,
253 nsPromptService_ConfirmCheck,
254 nsPromptService_ConfirmEx,
255 nsPromptService_Prompt,
256 nsPromptService_PromptUsernameAndPassword,
257 nsPromptService_PromptPassword,
258 nsPromptService_Select
261 static nsIPromptService nsPromptService = { &PromptServiceVtbl };
263 typedef struct {
264 const nsIFactoryVtbl *lpFactoryVtbl;
265 nsISupports *service;
266 } nsServiceFactory;
268 #define NSFACTORY(x) ((nsIFactory*) &(x)->lpFactoryVtbl)
270 #define NSFACTORY_THIS(iface) DEFINE_THIS(nsServiceFactory, Factory, iface)
272 static nsresult NSAPI nsServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
273 nsQIResult result)
275 nsServiceFactory *This = NSFACTORY_THIS(iface);
277 *result = NULL;
279 if(IsEqualGUID(&IID_nsISupports, riid)) {
280 TRACE("(%p)->(IID_nsISupoprts %p)\n", This, result);
281 *result = NSFACTORY(This);
282 }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
283 TRACE("(%p)->(IID_nsIFactory %p)\n", This, result);
284 *result = NSFACTORY(This);
287 if(*result)
288 return NS_OK;
290 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
291 return NS_NOINTERFACE;
294 static nsrefcnt NSAPI nsServiceFactory_AddRef(nsIFactory *iface)
296 return 2;
299 static nsrefcnt NSAPI nsServiceFactory_Release(nsIFactory *iface)
301 return 1;
304 static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface,
305 nsISupports *aOuter, const nsIID *iid, void **result)
307 nsServiceFactory *This = NSFACTORY_THIS(iface);
309 TRACE("(%p)->(%p %s %p)\n", This, aOuter, debugstr_guid(iid), result);
311 return nsISupports_QueryInterface(This->service, iid, result);
314 static nsresult NSAPI nsServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
316 nsServiceFactory *This = NSFACTORY_THIS(iface);
317 WARN("(%p)->(%x)\n", This, lock);
318 return NS_OK;
321 #undef NSFACTORY_THIS
323 static const nsIFactoryVtbl nsServiceFactoryVtbl = {
324 nsServiceFactory_QueryInterface,
325 nsServiceFactory_AddRef,
326 nsServiceFactory_Release,
327 nsServiceFactory_CreateInstance,
328 nsServiceFactory_LockFactory
331 static nsServiceFactory nsPromptServiceFactory = {
332 &nsServiceFactoryVtbl,
333 (nsISupports*)&nsPromptService
336 void register_nsservice(nsIComponentRegistrar *registrar, nsIServiceManager *service_manager)
338 nsIWindowWatcher *window_watcher;
339 nsresult nsres;
341 nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_PROMPTSERVICE_CID,
342 "Prompt Service", NS_PROMPTSERVICE_CONTRACTID, NSFACTORY(&nsPromptServiceFactory));
343 if(NS_FAILED(nsres))
344 ERR("RegisterFactory failed: %08lx\n", nsres);
346 nsres = nsIServiceManager_GetServiceByContactID(service_manager, NS_WINDOWWATCHER_CONTRACTID,
347 &IID_nsIWindowWatcher, (void**)&window_watcher);
348 if(NS_SUCCEEDED(nsres)) {
349 nsres = nsIWindowWatcher_SetWindowCreator(window_watcher,
350 (nsIWindowCreator*)&nsWindowCreator);
351 if(NS_FAILED(nsres))
352 ERR("SetWindowCreator failed: %08lx\n", nsres);
353 nsIWindowWatcher_Release(window_watcher);
354 }else {
355 ERR("Could not get WindowWatcher object: %08lx\n", nsres);