wbemprox: Implement Win32_CDROMDrive.MediaType.
[wine/wine-gecko.git] / dlls / taskschd / taskschd.c
blobead8c5ae8801d96677296e402c62ed5648ef0a31
1 /*
2 * Task Scheduler
4 * Copyright 2013 Dmitry Timoshkov
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
23 #define COBJMACROS
24 #define NONAMELESSUNION
26 #include "windef.h"
27 #include "winbase.h"
28 #include "objbase.h"
29 #include "rpcproxy.h"
30 #include "taskschd.h"
31 #include "taskschd_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(taskschd);
37 static HINSTANCE schd_instance;
39 typedef struct
41 IClassFactory IClassFactory_iface;
42 HRESULT (*constructor)(void **);
43 } TaskScheduler_factory;
45 static inline TaskScheduler_factory *impl_from_IClassFactory(IClassFactory *iface)
47 return CONTAINING_RECORD(iface, TaskScheduler_factory, IClassFactory_iface);
50 static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *obj)
52 if (!riid || !obj) return E_INVALIDARG;
54 TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
56 if (IsEqualIID(riid, &IID_IUnknown) ||
57 IsEqualIID(riid, &IID_IClassFactory))
59 IClassFactory_AddRef(iface);
60 *obj = iface;
61 return S_OK;
64 *obj = NULL;
65 FIXME("interface %s is not implemented\n", debugstr_guid(riid));
66 return E_NOINTERFACE;
69 static ULONG WINAPI factory_AddRef(IClassFactory *iface)
71 return 2;
74 static ULONG WINAPI factory_Release(IClassFactory *iface)
76 return 1;
79 static HRESULT WINAPI factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj)
81 TaskScheduler_factory *factory = impl_from_IClassFactory(iface);
82 IUnknown *unknown;
83 HRESULT hr;
85 if (!riid || !obj) return E_INVALIDARG;
87 TRACE("%p,%s,%p\n", outer, debugstr_guid(riid), obj);
89 *obj = NULL;
90 if (outer) return CLASS_E_NOAGGREGATION;
92 hr = factory->constructor((void **)&unknown);
93 if (hr != S_OK) return hr;
95 hr = IUnknown_QueryInterface(unknown, riid, obj);
96 IUnknown_Release(unknown);
98 return hr;
101 static HRESULT WINAPI factory_LockServer(IClassFactory *iface, BOOL lock)
103 FIXME("%p,%d: stub\n", iface, lock);
104 return S_OK;
107 static const struct IClassFactoryVtbl factory_vtbl =
109 factory_QueryInterface,
110 factory_AddRef,
111 factory_Release,
112 factory_CreateInstance,
113 factory_LockServer
116 static TaskScheduler_factory TaskScheduler_cf = { { &factory_vtbl }, TaskService_create };
118 /******************************************************************
119 * DllMain
121 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
123 switch (reason)
125 case DLL_WINE_PREATTACH:
126 return FALSE; /* prefer native version */
128 case DLL_PROCESS_ATTACH:
129 schd_instance = hinst;
130 DisableThreadLibraryCalls(hinst);
131 break;
133 return TRUE;
136 /***********************************************************************
137 * DllGetClassObject
139 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *obj)
141 IClassFactory *factory = NULL;
143 if (!rclsid || !riid || !obj) return E_INVALIDARG;
145 TRACE("%s,%s,%p\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
147 *obj = NULL;
149 if (IsEqualGUID(rclsid, &CLSID_TaskScheduler))
151 factory = &TaskScheduler_cf.IClassFactory_iface;
154 if (factory) return IClassFactory_QueryInterface(factory, riid, obj);
156 FIXME("class %s/%s is not implemented\n", debugstr_guid(rclsid), debugstr_guid(riid));
157 return CLASS_E_CLASSNOTAVAILABLE;
160 /***********************************************************************
161 * DllCanUnloadNow
163 HRESULT WINAPI DllCanUnloadNow(void)
165 return S_FALSE;
168 /***********************************************************************
169 * DllRegisterServer
171 HRESULT WINAPI DllRegisterServer(void)
173 return __wine_register_resources(schd_instance);
176 /***********************************************************************
177 * DllUnregisterServer
179 HRESULT WINAPI DllUnregisterServer(void)
181 return __wine_unregister_resources(schd_instance);
184 const char *debugstr_variant(const VARIANT *v)
186 if (!v) return "(null)";
188 switch (V_VT(v))
190 case VT_EMPTY:
191 return "{VT_EMPTY}";
192 case VT_NULL:
193 return "{VT_NULL}";
194 case VT_I2:
195 return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v));
196 case VT_I4:
197 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v));
198 case VT_R8:
199 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v));
200 case VT_BSTR:
201 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v)));
202 case VT_DISPATCH:
203 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v));
204 case VT_ERROR:
205 return wine_dbg_sprintf("{VT_ERROR: %08x}", V_ERROR(v));
206 case VT_BOOL:
207 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v));
208 case VT_UINT:
209 return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v));
210 default:
211 return wine_dbg_sprintf("{vt %d}", V_VT(v));