rpcrt4: Store all active connections in RpcServerProtseq.
[wine.git] / dlls / taskschd / taskschd.c
blobb68c352824d6545141989e878c26f8f0921acbaf
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
25 #include "windef.h"
26 #include "winbase.h"
27 #include "objbase.h"
28 #include "rpcproxy.h"
29 #include "taskschd.h"
30 #include "taskschd_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(taskschd);
36 static HINSTANCE schd_instance;
38 typedef struct
40 IClassFactory IClassFactory_iface;
41 HRESULT (*constructor)(void **);
42 } TaskScheduler_factory;
44 static inline TaskScheduler_factory *impl_from_IClassFactory(IClassFactory *iface)
46 return CONTAINING_RECORD(iface, TaskScheduler_factory, IClassFactory_iface);
49 static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *obj)
51 if (!riid || !obj) return E_INVALIDARG;
53 TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
55 if (IsEqualIID(riid, &IID_IUnknown) ||
56 IsEqualIID(riid, &IID_IClassFactory))
58 IClassFactory_AddRef(iface);
59 *obj = iface;
60 return S_OK;
63 *obj = NULL;
64 FIXME("interface %s is not implemented\n", debugstr_guid(riid));
65 return E_NOINTERFACE;
68 static ULONG WINAPI factory_AddRef(IClassFactory *iface)
70 return 2;
73 static ULONG WINAPI factory_Release(IClassFactory *iface)
75 return 1;
78 static HRESULT WINAPI factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj)
80 TaskScheduler_factory *factory = impl_from_IClassFactory(iface);
81 IUnknown *unknown;
82 HRESULT hr;
84 if (!riid || !obj) return E_INVALIDARG;
86 TRACE("%p,%s,%p\n", outer, debugstr_guid(riid), obj);
88 *obj = NULL;
89 if (outer) return CLASS_E_NOAGGREGATION;
91 hr = factory->constructor((void **)&unknown);
92 if (hr != S_OK) return hr;
94 hr = IUnknown_QueryInterface(unknown, riid, obj);
95 IUnknown_Release(unknown);
97 return hr;
100 static HRESULT WINAPI factory_LockServer(IClassFactory *iface, BOOL lock)
102 FIXME("%p,%d: stub\n", iface, lock);
103 return S_OK;
106 static const struct IClassFactoryVtbl factory_vtbl =
108 factory_QueryInterface,
109 factory_AddRef,
110 factory_Release,
111 factory_CreateInstance,
112 factory_LockServer
115 static TaskScheduler_factory TaskScheduler_cf = { { &factory_vtbl }, TaskService_create };
117 /******************************************************************
118 * DllMain
120 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
122 switch (reason)
124 case DLL_WINE_PREATTACH:
125 return FALSE; /* prefer native version */
127 case DLL_PROCESS_ATTACH:
128 schd_instance = hinst;
129 DisableThreadLibraryCalls(hinst);
130 break;
132 return TRUE;
135 /***********************************************************************
136 * DllGetClassObject
138 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *obj)
140 IClassFactory *factory = NULL;
142 if (!rclsid || !riid || !obj) return E_INVALIDARG;
144 TRACE("%s,%s,%p\n", debugstr_guid(rclsid), debugstr_guid(riid), obj);
146 *obj = NULL;
148 if (IsEqualGUID(rclsid, &CLSID_TaskScheduler))
150 factory = &TaskScheduler_cf.IClassFactory_iface;
153 if (factory) return IClassFactory_QueryInterface(factory, riid, obj);
155 FIXME("class %s/%s is not implemented\n", debugstr_guid(rclsid), debugstr_guid(riid));
156 return CLASS_E_CLASSNOTAVAILABLE;
159 /***********************************************************************
160 * DllCanUnloadNow
162 HRESULT WINAPI DllCanUnloadNow(void)
164 return S_FALSE;
167 /***********************************************************************
168 * DllRegisterServer
170 HRESULT WINAPI DllRegisterServer(void)
172 return __wine_register_resources(schd_instance);
175 /***********************************************************************
176 * DllUnregisterServer
178 HRESULT WINAPI DllUnregisterServer(void)
180 return __wine_unregister_resources(schd_instance);