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
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];
39 DWORD res, type, size, schema_len;
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]),
50 if(FAILED(hres) || !schema_len)
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));
64 size = sizeof(str_clsid);
65 res = RegQueryValueExW(hkey, wszCLSID, NULL, &type, (LPBYTE)str_clsid, &size);
67 if(res != ERROR_SUCCESS || type != REG_SZ) {
68 WARN("Could not get protocol CLSID res=%ld\n", res);
72 hres = CLSIDFromString(str_clsid, &clsid);
74 WARN("CLSIDFromString failed: %08lx\n", 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)) {
88 IInternetSession_AddRef(iface);
96 static ULONG WINAPI InternetSession_AddRef(IInternetSession *iface)
103 static ULONG WINAPI InternetSession_Release(IInternetSession *iface)
106 URLMON_UnlockModule();
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);
119 static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface,
120 IClassFactory *pCF, LPCWSTR pszProtocol)
122 FIXME("(%p %s)\n", pCF, debugstr_w(pszProtocol));
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));
133 static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface,
134 IClassFactory *pCF, LPCWSTR pwzType)
136 FIXME("(%p %s)\n", pCF, debugstr_w(pwzType));
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);
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);
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
177 * dwSessionMode [I] Mode for the internet session
178 * ppIInternetSession [O] Destination for creates IInternetSession object
179 * dwReserved [I] Reserved, must be 0.
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,
189 TRACE("(%ld %p %ld)\n", dwSessionMode, ppIInternetSession, dwReserved);
192 ERR("dwSessionMode=%ld\n", dwSessionMode);
194 ERR("dwReserved=%ld\n", dwReserved);
196 *ppIInternetSession = &InternetSession;