static HRESULT WINAPI TaskService_get_Connected(ITaskService *iface, VARIANT_BOOL *connected) { TaskService *task_svc = impl_from_ITaskService(iface); TRACE("%p,%p\n", iface, connected); if (!connected) return E_POINTER; *connected = task_svc->connected ? VARIANT_TRUE : VARIANT_FALSE; return S_OK; }
static ULONG WINAPI TaskService_Release(ITaskService *iface) { TaskService *task_svc = impl_from_ITaskService(iface); LONG ref = InterlockedDecrement(&task_svc->ref); if (!ref) { TRACE("destroying %p\n", iface); heap_free(task_svc); } return ref; }
static HRESULT WINAPI TaskService_GetFolder(ITaskService *iface, BSTR path, ITaskFolder **folder) { TaskService *task_svc = impl_from_ITaskService(iface); TRACE("%p,%s,%p\n", iface, debugstr_w(path), folder); if (!folder) return E_POINTER; if (!task_svc->connected) return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED); return TaskFolder_create(path, NULL, folder, FALSE); }
static HRESULT WINAPI TaskService_get_TargetServer(ITaskService *iface, BSTR *server) { TaskService *task_svc = impl_from_ITaskService(iface); TRACE("%p,%p\n", iface, server); if (!server) return E_POINTER; if (!task_svc->connected) return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED); *server = SysAllocString(task_svc->comp_name); if (!*server) return E_OUTOFMEMORY; return S_OK; }
static HRESULT WINAPI TaskService_NewTask(ITaskService *iface, DWORD flags, ITaskDefinition **definition) { TaskService *task_svc = impl_from_ITaskService(iface); TRACE("%p,%x,%p\n", iface, flags, definition); if (!definition) return E_POINTER; if (!task_svc->connected) return HRESULT_FROM_WIN32(ERROR_ONLY_IF_CONNECTED); if (flags) FIXME("unsupported flags %x\n", flags); return TaskDefinition_create(definition); }
static HRESULT WINAPI TaskService_Connect(ITaskService *iface, VARIANT server, VARIANT user, VARIANT domain, VARIANT password) { TaskService *task_svc = impl_from_ITaskService(iface); WCHAR comp_name[MAX_COMPUTERNAME_LENGTH + 1]; DWORD len; TRACE("%p,%s,%s,%s,%s\n", iface, debugstr_variant(&server), debugstr_variant(&user), debugstr_variant(&domain), debugstr_variant(&password)); if (!is_variant_null(&user) || !is_variant_null(&domain) || !is_variant_null(&password)) FIXME("user/domain/password are ignored\n"); len = sizeof(comp_name)/sizeof(comp_name[0]); if (!GetComputerNameW(comp_name, &len)) return HRESULT_FROM_WIN32(GetLastError()); if (!is_variant_null(&server)) { const WCHAR *server_name; if (V_VT(&server) != VT_BSTR) { FIXME("server variant type %d is not supported\n", V_VT(&server)); return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH); } /* skip UNC prefix if any */ server_name = V_BSTR(&server); if (server_name[0] == '\\' && server_name[1] == '\\') server_name += 2; if (strcmpiW(server_name, comp_name)) { FIXME("connection to remote server %s is not supported\n", debugstr_w(V_BSTR(&server))); return HRESULT_FROM_WIN32(ERROR_BAD_NETPATH); } } strcpyW(task_svc->comp_name, comp_name); task_svc->connected = TRUE; return S_OK; }
static ULONG WINAPI TaskService_AddRef(ITaskService *iface) { TaskService *task_svc = impl_from_ITaskService(iface); return InterlockedIncrement(&task_svc->ref); }