user: Fix return type and argument type for GetDlgItemText{A,W}.
[wine/multimedia.git] / dlls / urlmon / session.c
blobe4ea06127ac4a59798c82aa5a34bfc0d818f41ec
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 <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "winreg.h"
27 #include "ole2.h"
28 #include "urlmon.h"
29 #include "urlmon_main.h"
31 #include "wine/debug.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
35 HRESULT get_protocol_iface(LPCWSTR url, IUnknown **ret)
37 WCHAR schema[64], str_clsid[64];
38 HKEY hkey = NULL;
39 DWORD res, type, size, schema_len;
40 CLSID clsid;
41 LPWSTR wszKey;
42 HRESULT hres;
44 static const WCHAR wszProtocolsKey[] =
45 {'P','R','O','T','O','C','O','L','S','\\','H','a','n','d','l','e','r','\\'};
46 static const WCHAR wszCLSID[] = {'C','L','S','I','D',0};
48 hres = CoInternetParseUrl(url, PARSE_SCHEMA, 0, schema, sizeof(schema)/sizeof(schema[0]),
49 &schema_len, 0);
50 if(FAILED(hres) || !schema_len)
51 return E_FAIL;
53 wszKey = HeapAlloc(GetProcessHeap(), 0, sizeof(wszProtocolsKey)+(schema_len+1)*sizeof(WCHAR));
54 memcpy(wszKey, wszProtocolsKey, sizeof(wszProtocolsKey));
55 memcpy(wszKey + sizeof(wszProtocolsKey)/sizeof(WCHAR), schema, (schema_len+1)*sizeof(WCHAR));
57 res = RegOpenKeyW(HKEY_CLASSES_ROOT, wszKey, &hkey);
58 HeapFree(GetProcessHeap(), 0, wszKey);
59 if(res != ERROR_SUCCESS) {
60 TRACE("Could not open key %s\n", debugstr_w(wszKey));
61 return E_FAIL;
64 size = sizeof(str_clsid);
65 res = RegQueryValueExW(hkey, wszCLSID, NULL, &type, (LPBYTE)str_clsid, &size);
66 RegCloseKey(hkey);
67 if(res != ERROR_SUCCESS || type != REG_SZ) {
68 WARN("Could not get protocol CLSID res=%ld\n", res);
69 return E_FAIL;
72 hres = CLSIDFromString(str_clsid, &clsid);
73 if(FAILED(hres)) {
74 WARN("CLSIDFromString failed: %08lx\n", hres);
75 return hres;
78 return CoGetClassObject(&clsid, CLSCTX_INPROC_SERVER, NULL, &IID_IUnknown, (void**)ret);
81 static HRESULT WINAPI InternetSession_QueryInterface(IInternetSession *iface,
82 REFIID riid, void **ppv)
84 TRACE("(%s %p)\n", debugstr_guid(riid), ppv);
86 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetSession, riid)) {
87 *ppv = iface;
88 IInternetSession_AddRef(iface);
89 return S_OK;
92 *ppv = NULL;
93 return E_NOINTERFACE;
96 static ULONG WINAPI InternetSession_AddRef(IInternetSession *iface)
98 TRACE("()\n");
99 URLMON_LockModule();
100 return 2;
103 static ULONG WINAPI InternetSession_Release(IInternetSession *iface)
105 TRACE("()\n");
106 URLMON_UnlockModule();
107 return 1;
110 static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
111 IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns,
112 const LPCWSTR *ppwzPatterns, DWORD dwReserved)
114 FIXME("(%p %s %s %ld %p %ld)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol),
115 cPatterns, ppwzPatterns, dwReserved);
116 return E_NOTIMPL;
119 static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface,
120 IClassFactory *pCF, LPCWSTR pszProtocol)
122 FIXME("(%p %s)\n", pCF, debugstr_w(pszProtocol));
123 return E_NOTIMPL;
126 static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface,
127 IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType)
129 FIXME("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType));
130 return E_NOTIMPL;
133 static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface,
134 IClassFactory *pCF, LPCWSTR pwzType)
136 FIXME("(%p %s)\n", pCF, debugstr_w(pwzType));
137 return E_NOTIMPL;
140 static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
141 LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk,
142 IInternetProtocol **ppOInetProt, DWORD dwOption)
144 FIXME("(%p %s %p %p %p %08lx)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk,
145 ppOInetProt, dwOption);
146 return E_NOTIMPL;
149 static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface,
150 DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)
152 FIXME("(%08lx %p %ld %ld)\n", dwOption, pBuffer, dwBufferLength, dwReserved);
153 return E_NOTIMPL;
156 static const IInternetSessionVtbl InternetSessionVtbl = {
157 InternetSession_QueryInterface,
158 InternetSession_AddRef,
159 InternetSession_Release,
160 InternetSession_RegisterNameSpace,
161 InternetSession_UnregisterNameSpace,
162 InternetSession_RegisterMimeFilter,
163 InternetSession_UnregisterMimeFilter,
164 InternetSession_CreateBinding,
165 InternetSession_SetSessionOption
168 static IInternetSession InternetSession = { &InternetSessionVtbl };
170 /***********************************************************************
171 * CoInternetGetSession (URLMON.@)
173 * Create a new internet session and return an IInternetSession interface
174 * representing it.
176 * PARAMS
177 * dwSessionMode [I] Mode for the internet session
178 * ppIInternetSession [O] Destination for creates IInternetSession object
179 * dwReserved [I] Reserved, must be 0.
181 * RETURNS
182 * Success: S_OK. ppIInternetSession contains the IInternetSession interface.
183 * Failure: E_INVALIDARG, if any argument is invalid, or
184 * E_OUTOFMEMORY if memory allocation fails.
186 HRESULT WINAPI CoInternetGetSession(DWORD dwSessionMode, IInternetSession **ppIInternetSession,
187 DWORD dwReserved)
189 TRACE("(%ld %p %ld)\n", dwSessionMode, ppIInternetSession, dwReserved);
191 if(dwSessionMode)
192 ERR("dwSessionMode=%ld\n", dwSessionMode);
193 if(dwReserved)
194 ERR("dwReserved=%ld\n", dwReserved);
196 *ppIInternetSession = &InternetSession;
197 return S_OK;