- Added IHttpNegotiate2 interface.
[wine] / dlls / urlmon / session.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
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.
8  *
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.
13  *
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
17  */
18
19 #include <stdarg.h>
20
21 #define COBJMACROS
22
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "urlmon.h"
28 #include "urlmon_main.h"
29
30 #include "wine/debug.h"
31
32 WINE_DEFAULT_DEBUG_CHANNEL(urlmon);
33
34 static HRESULT WINAPI InternetSession_QueryInterface(IInternetSession *iface,
35         REFIID riid, void **ppv)
36 {
37     TRACE("(%s %p)\n", debugstr_guid(riid), ppv);
38
39     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IInternetSession, riid)) {
40         *ppv = iface;
41         IInternetSession_AddRef(iface);
42         return S_OK;
43     }
44
45     *ppv = NULL;
46     return E_NOINTERFACE;
47 }
48
49 static ULONG WINAPI InternetSession_AddRef(IInternetSession *iface)
50 {
51     TRACE("()\n");
52     URLMON_LockModule();
53     return 2;
54 }
55
56 static ULONG WINAPI InternetSession_Release(IInternetSession *iface)
57 {
58     TRACE("()\n");
59     URLMON_UnlockModule();
60     return 1;
61 }
62
63 static HRESULT WINAPI InternetSession_RegisterNameSpace(IInternetSession *iface,
64         IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzProtocol, ULONG cPatterns,
65         const LPCWSTR *ppwzPatterns, DWORD dwReserved)
66 {
67     FIXME("(%p %s %s %ld %p %ld)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzProtocol),
68             cPatterns, ppwzPatterns, dwReserved);
69     return E_NOTIMPL;
70 }
71
72 static HRESULT WINAPI InternetSession_UnregisterNameSpace(IInternetSession *iface,
73         IClassFactory *pCF, LPCWSTR pszProtocol)
74 {
75     FIXME("(%p %s)\n", pCF, debugstr_w(pszProtocol));
76     return E_NOTIMPL;
77 }
78
79 static HRESULT WINAPI InternetSession_RegisterMimeFilter(IInternetSession *iface,
80         IClassFactory *pCF, REFCLSID rclsid, LPCWSTR pwzType)
81 {
82     FIXME("(%p %s %s)\n", pCF, debugstr_guid(rclsid), debugstr_w(pwzType));
83     return E_NOTIMPL;
84 }
85
86 static HRESULT WINAPI InternetSession_UnregisterMimeFilter(IInternetSession *iface,
87         IClassFactory *pCF, LPCWSTR pwzType)
88 {
89     FIXME("(%p %s)\n", pCF, debugstr_w(pwzType));
90     return E_NOTIMPL;
91 }
92
93 static HRESULT WINAPI InternetSession_CreateBinding(IInternetSession *iface,
94         LPBC pBC, LPCWSTR szUrl, IUnknown *pUnkOuter, IUnknown **ppUnk,
95         IInternetProtocol **ppOInetProt, DWORD dwOption)
96 {
97     FIXME("(%p %s %p %p %p %08lx)\n", pBC, debugstr_w(szUrl), pUnkOuter, ppUnk,
98             ppOInetProt, dwOption);
99     return E_NOTIMPL;
100 }
101
102 static HRESULT WINAPI InternetSession_SetSessionOption(IInternetSession *iface,
103         DWORD dwOption, LPVOID pBuffer, DWORD dwBufferLength, DWORD dwReserved)
104 {
105     FIXME("(%08lx %p %ld %ld)\n", dwOption, pBuffer, dwBufferLength, dwReserved);
106     return E_NOTIMPL;
107 }
108
109 static const IInternetSessionVtbl InternetSessionVtbl = {
110     InternetSession_QueryInterface,
111     InternetSession_AddRef,
112     InternetSession_Release,
113     InternetSession_RegisterNameSpace,
114     InternetSession_UnregisterNameSpace,
115     InternetSession_RegisterMimeFilter,
116     InternetSession_UnregisterMimeFilter,
117     InternetSession_CreateBinding,
118     InternetSession_SetSessionOption
119 };
120
121 static IInternetSession InternetSession = { &InternetSessionVtbl };
122
123 /***********************************************************************
124  *           CoInternetGetSession (URLMON.@)
125  *
126  * Create a new internet session and return an IInternetSession interface
127  * representing it.
128  *
129  * PARAMS
130  *    dwSessionMode      [I] Mode for the internet session
131  *    ppIInternetSession [O] Destination for creates IInternetSession object
132  *    dwReserved         [I] Reserved, must be 0.
133  *
134  * RETURNS
135  *    Success: S_OK. ppIInternetSession contains the IInternetSession interface.
136  *    Failure: E_INVALIDARG, if any argument is invalid, or
137  *             E_OUTOFMEMORY if memory allocation fails.
138  */
139 HRESULT WINAPI CoInternetGetSession(DWORD dwSessionMode, IInternetSession **ppIInternetSession,
140         DWORD dwReserved)
141 {
142     TRACE("(%ld %p %ld)\n", dwSessionMode, ppIInternetSession, dwReserved);
143
144     if(dwSessionMode)
145         ERR("dwSessionMode=%ld\n", dwSessionMode);
146     if(dwReserved)
147         ERR("dwReserved=%ld\n", dwReserved);
148
149     *ppIInternetSession = &InternetSession;
150     return S_OK;
151 }