shell32: Export PathResolve by name.
[wine/dcerpc.git] / dlls / mshtml / nsservice.c
blob68b9de01334e27a63ccfe89f8cac1dbf565c93a2
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"
40 static const nsIID NS_PROMPTSERVICE_CID =
41 {0xa2112d6a,0x0e28,0x421f,{0xb4,0x6a,0x25,0xc0,0xb3,0x8,0xcb,0xd0}};
43 static nsresult NSAPI nsPromptService_QueryInterface(nsIPromptService *iface,
44 nsIIDRef riid, nsQIResult result)
46 *result = NULL;
48 if(IsEqualGUID(&IID_nsISupports, riid)) {
49 TRACE("(IID_nsISupports %p)\n", result);
50 *result = iface;
51 }else if(IsEqualGUID(&IID_nsIPromptService, riid)) {
52 TRACE("(IID_nsIPromptService %p)\n", result);
53 *result = iface;
56 if(*result)
57 return NS_OK;
59 TRACE("(%s %p)\n", debugstr_guid(riid), result);
60 return NS_NOINTERFACE;
63 static nsrefcnt NSAPI nsPromptService_AddRef(nsIPromptService *iface)
65 return 2;
68 static nsrefcnt NSAPI nsPromptService_Release(nsIPromptService *iface)
70 return 1;
73 static nsresult NSAPI nsPromptService_Alert(nsIPromptService *iface, nsIDOMWindow *aParent,
74 const PRUnichar *aDialogTitle, const PRUnichar *aText)
76 FIXME("(%p %s %s)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText));
77 return NS_ERROR_NOT_IMPLEMENTED;
80 static nsresult NSAPI nsPromptService_AlertCheck(nsIPromptService *iface,
81 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
82 const PRUnichar *aText, const PRUnichar *aCheckMsg, PRBool *aCheckState)
84 FIXME("(%p %s %s %s %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
85 debugstr_w(aCheckMsg), aCheckState);
86 return NS_ERROR_NOT_IMPLEMENTED;
89 static nsresult NSAPI nsPromptService_Confirm(nsIPromptService *iface,
90 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle, const PRUnichar *aText,
91 PRBool *_retval)
93 FIXME("(%p %s %s %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText), _retval);
94 return NS_ERROR_NOT_IMPLEMENTED;
97 static nsresult NSAPI nsPromptService_ConfirmCheck(nsIPromptService *iface,
98 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
99 const PRUnichar *aText, const PRUnichar *aCheckMsg, PRBool *aCheckState,
100 PRBool *_retval)
102 FIXME("(%p %s %s %s %p %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
103 debugstr_w(aCheckMsg), aCheckState, _retval);
104 return NS_ERROR_NOT_IMPLEMENTED;
107 static nsresult NSAPI nsPromptService_ConfirmEx(nsIPromptService *iface,
108 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
109 const PRUnichar *aText, PRUint32 aButtonFlags, const PRUnichar *aButton0Title,
110 const PRUnichar *aButton1Title, const PRUnichar *aButton2Title,
111 const PRUnichar *aCheckMsg, PRBool *aCheckState, PRInt32 *_retval)
113 static const PRUnichar wszContinue[] = {'C','o','n','t','i','n','u','e',0};
115 FIXME("(%p %s %s %08lx %s %s %s %s %p %p) hack!\n", aParent, debugstr_w(aDialogTitle),
116 debugstr_w(aText), aButtonFlags, debugstr_w(aButton0Title),
117 debugstr_w(aButton1Title), debugstr_w(aButton2Title), debugstr_w(aCheckMsg),
118 aCheckState, _retval);
121 * FIXME:
122 * This is really very very ugly hack!!!
125 if(!memcmp(aButton0Title, wszContinue, sizeof(wszContinue)))
126 *_retval = 0;
127 else if(!memcmp(aButton1Title, wszContinue, sizeof(wszContinue)))
128 *_retval = 1;
129 else if(!memcmp(aButton2Title, wszContinue, sizeof(wszContinue)))
130 *_retval = 2;
131 else
132 *_retval = 0;
134 return NS_OK;
137 static nsresult NSAPI nsPromptService_Prompt(nsIPromptService *iface,
138 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
139 const PRUnichar *aText, PRUnichar **aValue, const PRUnichar *aCheckMsg,
140 PRBool *aCheckState, PRBool *_retval)
142 FIXME("(%p %s %s %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle), debugstr_w(aText),
143 aValue, debugstr_w(aCheckMsg), aCheckState, _retval);
144 return NS_ERROR_NOT_IMPLEMENTED;
147 static nsresult NSAPI nsPromptService_PromptUsernameAndPassword(nsIPromptService *iface,
148 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
149 const PRUnichar *aText, PRUnichar **aUsername, PRUnichar **aPassword,
150 const PRUnichar *aCheckMsg, PRBool *aCheckState, PRBool *_retval)
152 FIXME("(%p %s %s %p %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle),
153 debugstr_w(aText), aUsername, aPassword, debugstr_w(aCheckMsg), aCheckState,
154 _retval);
155 return NS_ERROR_NOT_IMPLEMENTED;
158 static nsresult NSAPI nsPromptService_PromptPassword(nsIPromptService *iface,
159 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
160 const PRUnichar *aText, PRUnichar **aPassword, const PRUnichar *aCheckMsg,
161 PRBool *aCheckState, PRBool *_retval)
163 FIXME("(%p %s %s %p %s %p %p)\n", aParent, debugstr_w(aDialogTitle),
164 debugstr_w(aText), aPassword, debugstr_w(aCheckMsg), aCheckState, _retval);
165 return NS_ERROR_NOT_IMPLEMENTED;
168 static nsresult NSAPI nsPromptService_Select(nsIPromptService *iface,
169 nsIDOMWindow *aParent, const PRUnichar *aDialogTitle,
170 const PRUnichar *aText, PRUint32 aCount, const PRUnichar **aSelectList,
171 PRInt32 *aOutSelection, PRBool *_retval)
173 FIXME("(%p %s %s %ld %p %p %p)\n", aParent, debugstr_w(aDialogTitle),
174 debugstr_w(aText), aCount, aSelectList, aOutSelection, _retval);
175 return NS_ERROR_NOT_IMPLEMENTED;
178 static const nsIPromptServiceVtbl PromptServiceVtbl = {
179 nsPromptService_QueryInterface,
180 nsPromptService_AddRef,
181 nsPromptService_Release,
182 nsPromptService_Alert,
183 nsPromptService_AlertCheck,
184 nsPromptService_Confirm,
185 nsPromptService_ConfirmCheck,
186 nsPromptService_ConfirmEx,
187 nsPromptService_Prompt,
188 nsPromptService_PromptUsernameAndPassword,
189 nsPromptService_PromptPassword,
190 nsPromptService_Select
193 static nsIPromptService nsPromptService = { &PromptServiceVtbl };
195 typedef struct {
196 const nsIFactoryVtbl *lpFactoryVtbl;
197 nsISupports *service;
198 } nsServiceFactory;
200 #define NSFACTORY(x) ((nsIFactory*) &(x)->lpFactoryVtbl)
202 #define NSFACTORY_THIS(iface) DEFINE_THIS(nsServiceFactory, Factory, iface)
204 static nsresult NSAPI nsServiceFactory_QueryInterface(nsIFactory *iface, nsIIDRef riid,
205 nsQIResult result)
207 nsServiceFactory *This = NSFACTORY_THIS(iface);
209 *result = NULL;
211 if(IsEqualGUID(&IID_nsISupports, riid)) {
212 TRACE("(%p)->(IID_nsISupoprts %p)\n", This, result);
213 *result = NSFACTORY(This);
214 }else if(IsEqualGUID(&IID_nsIFactory, riid)) {
215 TRACE("(%p)->(IID_nsIFactory %p)\n", This, result);
216 *result = NSFACTORY(This);
219 if(*result)
220 return NS_OK;
222 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), result);
223 return NS_NOINTERFACE;
226 static nsrefcnt NSAPI nsServiceFactory_AddRef(nsIFactory *iface)
228 return 2;
231 static nsrefcnt NSAPI nsServiceFactory_Release(nsIFactory *iface)
233 return 1;
236 static nsresult NSAPI nsServiceFactory_CreateInstance(nsIFactory *iface,
237 nsISupports *aOuter, const nsIID *iid, void **result)
239 nsServiceFactory *This = NSFACTORY_THIS(iface);
241 TRACE("(%p)->(%p %s %p)\n", This, aOuter, debugstr_guid(iid), result);
243 return nsISupports_QueryInterface(This->service, iid, result);
246 static nsresult NSAPI nsServiceFactory_LockFactory(nsIFactory *iface, PRBool lock)
248 nsServiceFactory *This = NSFACTORY_THIS(iface);
249 WARN("(%p)->(%x)\n", This, lock);
250 return NS_OK;
253 #undef NSFACTORY_THIS
255 static const nsIFactoryVtbl nsServiceFactoryVtbl = {
256 nsServiceFactory_QueryInterface,
257 nsServiceFactory_AddRef,
258 nsServiceFactory_Release,
259 nsServiceFactory_CreateInstance,
260 nsServiceFactory_LockFactory
263 static nsServiceFactory PromptServiceFactory = {
264 &nsServiceFactoryVtbl,
265 (nsISupports*)&nsPromptService
268 void register_nsservice(nsIComponentRegistrar *registrar)
270 nsresult nsres;
272 nsres = nsIComponentRegistrar_RegisterFactory(registrar, &NS_PROMPTSERVICE_CID,
273 "Prompt Service", NS_PROMPTSERVICE_CONTRACTID, NSFACTORY(&PromptServiceFactory));
274 if(NS_FAILED(nsres))
275 ERR("RegisterFactory failed: %08lx\n", nsres);