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
30 #include "taskschd_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(taskschd
);
36 static HINSTANCE schd_instance
;
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
);
64 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
68 static ULONG WINAPI
factory_AddRef(IClassFactory
*iface
)
73 static ULONG WINAPI
factory_Release(IClassFactory
*iface
)
78 static HRESULT WINAPI
factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
80 TaskScheduler_factory
*factory
= impl_from_IClassFactory(iface
);
84 if (!riid
|| !obj
) return E_INVALIDARG
;
86 TRACE("%p,%s,%p\n", outer
, debugstr_guid(riid
), obj
);
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
);
100 static HRESULT WINAPI
factory_LockServer(IClassFactory
*iface
, BOOL lock
)
102 FIXME("%p,%d: stub\n", iface
, lock
);
106 static const struct IClassFactoryVtbl factory_vtbl
=
108 factory_QueryInterface
,
111 factory_CreateInstance
,
115 static TaskScheduler_factory TaskScheduler_cf
= { { &factory_vtbl
}, TaskService_create
};
117 /******************************************************************
120 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
124 case DLL_WINE_PREATTACH
:
125 return FALSE
; /* prefer native version */
127 case DLL_PROCESS_ATTACH
:
128 schd_instance
= hinst
;
129 DisableThreadLibraryCalls(hinst
);
135 /***********************************************************************
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
);
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 /***********************************************************************
162 HRESULT WINAPI
DllCanUnloadNow(void)
167 /***********************************************************************
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
);