Esempio n. 1
0
/**
 * Opens the Door! :)
 *
 * Parameters:
 * >szDoor
 * Path to lock device for the door.
 *
 * Returns:
 * N/A.
 */
void perco_exchange::openDoor(_In_ STLADD string_unique_ptr_t&& szDoor)
{
    ATL::CComPtr<PERCo_S20_SDK::IExchangeMain> percoXchg;
    if (SUCCEEDED(percoXchg.CoCreateInstance(__uuidof(PERCo_S20_SDK::CoExchangeMain))))
    {
        if (SUCCEEDED(percoXchg->SetConnect(PERCO_HOST, PERCO_PORT, PERCO_LOGIN, PERCO_PWD)))
        {
            BSTR szDBVersion;
            BSTR szSDKVersion;
            if (!percoXchg->CheckVersion(&szDBVersion, &szSDKVersion))
            {
                ATL::CComPtr<IXMLDOMDocument2> request = getSendCommandsRequest(std::move(szDoor));
                AtlTrace2(ATL::atlTraceGeneral, 0, "Sending the 'sendcommands' request.\r\n");
                if (request && SUCCEEDED(percoXchg->ExecuteCommand(request)))
                {
                    AtlTrace2(ATL::atlTraceGeneral, 0, "PERCo has responded to the 'sendcommands' request.\r\n");
                }
            }
            percoXchg->DisConnect();
        }
    }
    else
    {
        AtlTrace2(ATL::atlTraceCOM, 0, "'PERCo_S20_SDK::IExchangeMain' ain't registered.\r\n");
    }
}
Esempio n. 2
0
void DeleteJumpList(LPCTSTR appID)
{
	ATL::CComPtr<ICustomDestinationList> pcdl;
	HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, nullptr, CLSCTX_INPROC_SERVER);
	if (SUCCEEDED(hr)) {
		pcdl->DeleteList(appID);
	}
}
Esempio n. 3
0
void CTortoiseProcApp::DoInitializeJumpList(const CString& appid)
{
	ATL::CComPtr<ICustomDestinationList> pcdl;
	HRESULT hr = pcdl.CoCreateInstance(CLSID_DestinationList, NULL, CLSCTX_INPROC_SERVER);
	if (FAILED(hr))
		return;

	hr = pcdl->SetAppID(appid);
	if (FAILED(hr))
		return;

	UINT uMaxSlots;
	ATL::CComPtr<IObjectArray> poaRemoved;
	hr = pcdl->BeginList(&uMaxSlots, IID_PPV_ARGS(&poaRemoved));
	if (FAILED(hr))
		return;

	ATL::CComPtr<IObjectCollection> poc;
	hr = poc.CoCreateInstance(CLSID_EnumerableObjectCollection, NULL, CLSCTX_INPROC_SERVER);
	if (FAILED(hr))
		return;

	CString sTemp = CString(MAKEINTRESOURCE(IDS_MENUSETTINGS));
	CStringUtils::RemoveAccelerators(sTemp);

	ATL::CComPtr<IShellLink> psl;
	hr = CreateShellLink(_T("/command:settings"), (LPCTSTR)sTemp, 20, &psl);
	if (SUCCEEDED(hr)) {
		poc->AddObject(psl);
	}
	sTemp = CString(MAKEINTRESOURCE(IDS_MENUHELP));
	CStringUtils::RemoveAccelerators(sTemp);
	psl.Release(); // Need to release the object before calling operator&()
	hr = CreateShellLink(_T("/command:help"), (LPCTSTR)sTemp, 19, &psl);
	if (SUCCEEDED(hr)) {
		poc->AddObject(psl);
	}

	ATL::CComPtr<IObjectArray> poa;
	hr = poc.QueryInterface(&poa);
	if (SUCCEEDED(hr)) {
		pcdl->AppendCategory((LPCTSTR)CString(MAKEINTRESOURCE(IDS_PROC_TASKS)), poa);
		pcdl->CommitList();
	}
}
Esempio n. 4
0
	ProgressTaskBar(__RPC__in HWND hwnd, ULONGLONG Total)
		: hwnd(hwnd)
		, Total(Total)
	{
		if (FAILED(CoInitialize(nullptr)))
			ATL::AtlThrowLastWin32();
		if (FAILED(TaskbarList.CoCreateInstance(CLSID_TaskbarList)))
			ATL::AtlThrowLastWin32();
	}
void ListViewAccServer::ClearProvider( HWND hControl )
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
    if (hr == S_OK && pAccPropSvc)
    {
        MSAAPROPID propid = PROPID_ACC_HELP;
        pAccPropSvc->ClearHwndProps(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1);
    }
}
Esempio n. 6
0
bool CCommonAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, const CString& text)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);

    if (hr == S_OK && pAccPropSvc)
    {
        pAccPropSvc->SetHwndPropStr(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, text);
        return true;
    }
    return false;
}
Esempio n. 7
0
bool CCommonAppUtils::SetAccProperty(HWND hWnd, MSAAPROPID propid, long value)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);

    if (hr == S_OK && pAccPropSvc)
    {
        VARIANT var;
        var.vt = VT_I4;
        var.intVal = value;
        pAccPropSvc->SetHwndProp(hWnd, (DWORD)OBJID_CLIENT, CHILDID_SELF, propid, var);
        return true;
    }
    return false;
}
Esempio n. 8
0
HRESULT CreateShellLink(PCWSTR pszArguments, PCWSTR pszTitle, int iconIndex, IShellLink **ppsl)
{
    ATL::CComPtr<IShellLink> psl;
    HRESULT hr = psl.CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER);
    if (FAILED(hr))
        return hr;

    WCHAR szAppPath[MAX_PATH];
    if (GetModuleFileName(NULL, szAppPath, _countof(szAppPath)) == 0)
    {
        hr = HRESULT_FROM_WIN32(GetLastError());
        return hr;
    }
    hr = psl->SetPath(szAppPath);
    if (FAILED(hr))
        return hr;

    hr = psl->SetArguments(pszArguments);
    if (FAILED(hr))
        return hr;

    hr = psl->SetIconLocation(szAppPath, iconIndex);
    if (FAILED(hr))
        return hr;

    ATL::CComPtr<IPropertyStore> pps;
    hr = psl.QueryInterface(&pps);
    if (FAILED(hr))
        return hr;

    PROPVARIANT propvar;
    hr = InitPropVariantFromString(pszTitle, &propvar);
    if (SUCCEEDED(hr))
    {
        hr = pps->SetValue(PKEY_Title, propvar);
        if (SUCCEEDED(hr))
        {
            hr = pps->Commit();
            if (SUCCEEDED(hr))
            {
                hr = psl.QueryInterface(ppsl);
            }
        }
        PropVariantClear(&propvar);
    }
    return hr;
}
ListViewAccServer * ListViewAccServer::CreateProvider(HWND hControl, ListViewAccProvider * provider)
{
    ATL::CComPtr<IAccPropServices> pAccPropSvc;
    HRESULT hr = pAccPropSvc.CoCreateInstance(CLSID_AccPropServices, NULL, CLSCTX_SERVER);
    if (hr == S_OK && pAccPropSvc)
    {
        ListViewAccServer * pLVServer = new (std::nothrow) ListViewAccServer(pAccPropSvc);
        if (pLVServer)
        {
            pLVServer->m_pAccProvider = provider;

            MSAAPROPID propid = PROPID_ACC_HELP;
            pAccPropSvc->SetHwndPropServer(hControl, (DWORD)OBJID_CLIENT, CHILDID_SELF, &propid, 1, pLVServer, ANNO_CONTAINER);
            pLVServer->Release();
        }
        return pLVServer;
    }
    return NULL;
}
Esempio n. 10
0
/**
 * Create XML document to request 'staff' report from the 'PERCo_S20_SDK::IExchangeMain'.
 *
 * Parameters:
 * None.
 *
 * Returns:
 * XML document instance.
 */
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getStaffRequest() const
{
    ATL::CComPtr<IXMLDOMDocument2> document;
    if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
    {
        ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
        if (SUCCEEDED(document->createProcessingInstruction(
            TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
        {
            document->appendChild(processingInstruction, nullptr);
            // Create root <documentrequest> element.
            ATL::CComPtr<IXMLDOMElement> documentRequest;
            if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
            {
                ATL::CComPtr<IXMLDOMAttribute> attribute;
                if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
                {
                    ATL::CComVariant value(TEXT("staff"));
                    if (SUCCEEDED(attribute->put_value(value)) &&
                        SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
                    {
                        attribute.Release();
                        if (SUCCEEDED(document->createAttribute(TEXT("mode_display"), &attribute)))
                        {
                            value = TEXT("employ_and_dismiss");
                            if (SUCCEEDED(attribute->put_value(value)) &&
                                SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)))
                            {
                                if (FAILED(document->appendChild(documentRequest, nullptr)))
                                {
                                    document.Release();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return document;
}
Esempio n. 11
0
HRESULT CreateSeparatorLink(IShellLink **ppsl)
{
	ATL::CComPtr<IPropertyStore> pps;
	HRESULT hr = pps.CoCreateInstance(CLSID_ShellLink, nullptr, CLSCTX_INPROC_SERVER);
	if (FAILED(hr))
		return hr;

	PROPVARIANT propvar;
	hr = InitPropVariantFromBoolean(TRUE, &propvar);
	if (FAILED(hr))
		return hr;

	hr = pps->SetValue(PKEY_AppUserModel_IsDestListSeparator, propvar);
	if (SUCCEEDED(hr)) {
		hr = pps->Commit();
		if (SUCCEEDED(hr))
		{
			hr = pps.QueryInterface(ppsl);
		}
	}
	PropVariantClear(&propvar);
	return hr;
}
Esempio n. 12
0
/**
* Create XML document to send 'sendcommands' request via the 'PERCo_S20_SDK::IExchangeMain'.
*
* Parameters:
 * >szDoor
 * Path to lock device for the door.
*
* Returns:
* XML document instance.
*/
ATL::CComPtr<IXMLDOMDocument2> perco_exchange::getSendCommandsRequest(_In_ STLADD string_unique_ptr_t&& szDoor) const
{
    ATL::CComPtr<IXMLDOMDocument2> document;
    if (SUCCEEDED(document.CoCreateInstance(CLSID_DOMDocument60, nullptr, CLSCTX_INPROC_SERVER)))
    {
        ATL::CComPtr<IXMLDOMProcessingInstruction> processingInstruction;
        if (SUCCEEDED(document->createProcessingInstruction(
            TEXT("xml"), TEXT("version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\""), &processingInstruction)))
        {
            document->appendChild(processingInstruction, nullptr);
            // Create root <documentrequest> element.
            ATL::CComPtr<IXMLDOMElement> documentRequest;
            if (SUCCEEDED(document->createElement(TEXT("documentrequest"), &documentRequest)))
            {
                ATL::CComPtr<IXMLDOMAttribute> attribute;
                if (SUCCEEDED(document->createAttribute(TEXT("type"), &attribute)))
                {
                    ATL::CComVariant value(TEXT("sendcommands"));
                    if (SUCCEEDED(attribute->put_value(value)) &&
                        SUCCEEDED(documentRequest->setAttributeNode(attribute, nullptr)) &&
                        SUCCEEDED(document->appendChild(documentRequest, nullptr)))
                    {
                        attribute.Release();
                        ATL::CComPtr<IXMLDOMElement> login;
                        if (SUCCEEDED(document->createElement(TEXT("login"), &login)) &&
                            SUCCEEDED(document->createAttribute(TEXT("loginname"), &attribute)))
                        {
                            value = TEXT("login name");
                            if (SUCCEEDED(attribute->put_value(value)) &&
                                SUCCEEDED(login->setAttributeNode(attribute, nullptr)) &&
                                SUCCEEDED(documentRequest->appendChild(login, nullptr)))
                            {
                                ATL::CComPtr<IXMLDOMElement> command;
                                if (SUCCEEDED(document->createElement(TEXT("command"), &command)))
                                {
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandnumber"), &attribute)))
                                    {
                                        // cmd #120 is "unlock device reader".
                                        value = "120";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandname"), &attribute)))
                                    {
//                                        value = L"Открыть (разблокировать) ИУ";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("commandpath"), &attribute)))
                                    {
                                        value = szDoor->c_str();
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("devicename"), &attribute)))
                                    {
//                                        value = L"Считыватель №2";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    attribute.Release();
                                    if (SUCCEEDED(document->createAttribute(TEXT("typename"), &attribute)))
                                    {
//                                        value = L"ReaderTI1_";
                                        value = L"";
                                        if (SUCCEEDED(attribute->put_value(value)))
                                        {
                                            command->setAttributeNode(attribute, nullptr);
                                        }
                                    }
                                    if (SUCCEEDED(login->appendChild(command, nullptr)))
                                    {
                                        ATL::CComPtr<IXMLDOMElement> commandAttributes;
                                        if (SUCCEEDED(
                                            document->createElement(TEXT("command_attributes"), &commandAttributes)) &&
                                            SUCCEEDED(command->appendChild(commandAttributes, nullptr)))
                                        {
                                            ATL::CComPtr<IXMLDOMElement> commandAttribute;
                                            if (SUCCEEDED(
                                                document->createElement(TEXT("command_attribute"), &commandAttribute)))
                                            {
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("displayname"), &attribute)))
                                                {
//                                                    value = L"Время разблокировки";
                                                    value = L"";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(document->createAttribute(TEXT("value"), &attribute)))
                                                {
                                                    value = L"5";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                attribute.Release();
                                                if (SUCCEEDED(
                                                    document->createAttribute(TEXT("rangeindex"), &attribute)))
                                                {
                                                    value = L"1";
                                                    if (SUCCEEDED(attribute->put_value(value)))
                                                    {
                                                        commandAttribute->setAttributeNode(attribute, nullptr);
                                                    }
                                                }
                                                if (FAILED(commandAttributes->appendChild(commandAttribute, nullptr)))
                                                {
                                                    document.Release();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    szDoor.reset();
    return document;
}
Esempio n. 13
0
/**
 * Gets identifiers map.
 *
 * Parameters:
 * None.
 *
 * Returns:
 * Identifiers map.
 */
perco_exchange::ids_t perco_exchange::getIdentifiers()
{
    ids_t ids;
    logger::const_ptr_t pLogger = logger::getInstance();
    ATL::CComPtr<PERCo_S20_SDK::IExchangeMain> percoXchg;
    if (SUCCEEDED(percoXchg.CoCreateInstance(__uuidof(PERCo_S20_SDK::CoExchangeMain))))
    {
        if (SUCCEEDED(percoXchg->SetConnect(PERCO_HOST, PERCO_PORT, PERCO_LOGIN, PERCO_PWD)))
        {
            BSTR szDBVersion;
            BSTR szSDKVersion;
            if (!percoXchg->CheckVersion(&szDBVersion, &szSDKVersion))
            {
                ATL::CComPtr<IXMLDOMDocument2> request = getStaffRequest();
#pragma region log
                pLogger->logNotify(logger::CategoryGeneral, IDS_EVENT_STAFF_REQUEST_SEND);
                AtlTrace2(ATL::atlTraceGeneral, 0, "Sending the 'staff' request.\r\n");
#pragma endregion log the message
                if (request && SUCCEEDED(percoXchg->GetData(request)))
                {
#pragma region log
                    pLogger->logNotify(logger::CategoryGeneral, IDS_EVENT_STAFF_REQUEST_HANDLED);
                    AtlTrace2(ATL::atlTraceGeneral, 0, "PERCo has responded to the 'staff' request.\r\n");
#pragma endregion log the message
                    ids = parseStaffResponse(request);
#pragma region log
                    CStringUtil::const_ptr_t pStringUtil = CStringUtil::getInstance();
                    LPTSTR pszFormat;
                    size_t nLength;
                    if (CStringUtil::ResourceSuccess ==
                        pStringUtil->loadString(IDS_EVENT_T_RESPOND_SIZE, &pszFormat, &nLength))
                    {
                        const STLADD regex_type regex(TEXT("(?:[^%]*)(?:%[[:digit:]]{0,2}u){1,1}(?:[^%]*)"));
                        if (std::regex_match(pszFormat, pszFormat + nLength, regex))
                        {
                            nLength += 15;
                            CMemoryManager::pointer_t pMemoryManager = CMemoryManager::getInstance();
                            LPTSTR pszText = pMemoryManager->mAllocChars<LPTSTR>(nLength);
                            if (pszText)
                            {
                                nLength = _stprintf_s(pszText, nLength, pszFormat, ids.size());
                                pLogger->log(logger::CategoryGeneral, logger::SeverityNotify, pszText, nLength);
                                pMemoryManager->free(pszText);
                            }
                        }
                        pStringUtil->freeString(pszFormat);
                    }
                    AtlTrace2(ATL::atlTraceGeneral, 0, "The respond parsed (%u entries handled).\r\n", ids.size());
#pragma endregion log the message
                }
            }
            percoXchg->DisConnect();
        }
    }
    else
    {
#pragma region log
        pLogger->logError(logger::CategoryCOM, IDS_EVENT_IEXCHANGEMAIN_AINT_REGISTERED);
        AtlTrace2(ATL::atlTraceCOM, 0, "'PERCo_S20_SDK::IExchangeMain' ain't registered.\r\n");
#pragma endregion log the message
    }
    return ids;
}