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
24 #define NONAMELESSUNION
31 #include "taskschd_private.h"
33 #include "wine/debug.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(taskschd
);
37 static HINSTANCE schd_instance
;
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
);
65 FIXME("interface %s is not implemented\n", debugstr_guid(riid
));
69 static ULONG WINAPI
factory_AddRef(IClassFactory
*iface
)
74 static ULONG WINAPI
factory_Release(IClassFactory
*iface
)
79 static HRESULT WINAPI
factory_CreateInstance(IClassFactory
*iface
, IUnknown
*outer
, REFIID riid
, void **obj
)
81 TaskScheduler_factory
*factory
= impl_from_IClassFactory(iface
);
85 if (!riid
|| !obj
) return E_INVALIDARG
;
87 TRACE("%p,%s,%p\n", outer
, debugstr_guid(riid
), obj
);
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
);
101 static HRESULT WINAPI
factory_LockServer(IClassFactory
*iface
, BOOL lock
)
103 FIXME("%p,%d: stub\n", iface
, lock
);
107 static const struct IClassFactoryVtbl factory_vtbl
=
109 factory_QueryInterface
,
112 factory_CreateInstance
,
116 static TaskScheduler_factory TaskScheduler_cf
= { { &factory_vtbl
}, TaskService_create
};
118 /******************************************************************
121 BOOL WINAPI
DllMain(HINSTANCE hinst
, DWORD reason
, LPVOID reserved
)
125 case DLL_WINE_PREATTACH
:
126 return FALSE
; /* prefer native version */
128 case DLL_PROCESS_ATTACH
:
129 schd_instance
= hinst
;
130 DisableThreadLibraryCalls(hinst
);
136 /***********************************************************************
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
);
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 /***********************************************************************
163 HRESULT WINAPI
DllCanUnloadNow(void)
168 /***********************************************************************
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)";
195 return wine_dbg_sprintf("{VT_I2: %d}", V_I2(v
));
197 return wine_dbg_sprintf("{VT_I4: %d}", V_I4(v
));
199 return wine_dbg_sprintf("{VT_R8: %lf}", V_R8(v
));
201 return wine_dbg_sprintf("{VT_BSTR: %s}", debugstr_w(V_BSTR(v
)));
203 return wine_dbg_sprintf("{VT_DISPATCH: %p}", V_DISPATCH(v
));
205 return wine_dbg_sprintf("{VT_ERROR: %08x}", V_ERROR(v
));
207 return wine_dbg_sprintf("{VT_BOOL: %x}", V_BOOL(v
));
209 return wine_dbg_sprintf("{VT_UINT: %u}", V_UINT(v
));
211 return wine_dbg_sprintf("{vt %d}", V_VT(v
));