Esempio n. 1
0
void ClientHandler::OnAddressChange(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, const CefString& url)
{
	REQUIRE_UI_THREAD();

	// The frame window will be the parent of the browser window
	HWND hWindow = GetParent( browser->GetHost()->GetWindowHandle() );

	LPCTSTR pszURL(url.c_str());
	::SendMessage( hWindow, WM_APP_CEF_ADDRESS_CHANGE, (WPARAM)pszURL, NULL );

	// call parent
	CefDisplayHandler::OnAddressChange(browser, frame, url);
}
Esempio n. 2
0
bool ClientHandler::OnBeforeBrowse(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, bool is_redirect)
{
	// The frame window will be the parent of the browser window
	HWND hWindow = GetParent( browser->GetHost()->GetWindowHandle() );

	// get URL requested
	CefString newURL = request->GetURL();

	LPCTSTR pszURL(newURL.c_str());
	if( ::SendMessage( hWindow, WM_APP_CEF_BEFORE_BROWSE, (WPARAM)pszURL, (LPARAM)is_redirect ) == S_FALSE )
	{
		// cancel navigation
		return TRUE;
	}

	// call parent
	return CefRequestHandler::OnBeforeBrowse(browser, frame, request, is_redirect);
}
Esempio n. 3
0
bool COublietteImportPlugin::ImportOublietteFile(LPCTSTR name)
{
    OublietteFile file(name);
    if (!file) {
        MessageBox(
            m_PluginAPI->GetMainWindowHandle()
        ,   file.getLastErrorMessage().c_str()
        ,   PLUGIN_NAME
        ,   MB_OK|MB_ICONWARNING
        );
        return false;
    }

    // TODO: Maybe use m_PluginAPI->ShowDialog() here in the future, when it is
    // implemented.

    // Switch to the DLL's resources.
    AFX_MANAGE_STATE(AfxGetStaticModuleState())

    CPasswordDialog dialog;
    if (dialog.DoModal()!=IDOK) {
        return false;
    }

    // Try to decrypt the file with the specified password.
    CT2CA password(dialog.GetPassword());
    OublietteFile::CipherTextHeader const* header=file.decryptData(password.m_psz);
    if (!header) {
        MessageBox(
            m_PluginAPI->GetMainWindowHandle()
        ,   file.getLastErrorMessage().c_str()
        ,   PLUGIN_NAME
        ,   MB_OK|MB_ICONWARNING
        );
        return false;
    }

    // Create a top-level group to import to.
    PW_GROUP g;
    ZeroMemory(&g,sizeof(PW_GROUP));

    if (m_Database->GetGroupId(PLUGIN_NAME)==DWORD_MAX) {
        // DWORD uGroupId;
        g.uImageId=49; // Open folder icon.
        g.pszGroupName=PLUGIN_NAME;
        g.tCreation=ConvertDateTime(header->getCreationTime());
        g.tLastMod=ConvertDateTime(header->getModificationTime());
        g.tLastAccess=ConvertDateTime(header->getModificationTime());
        m_PluginAPI->GetNeverExpireTime(&g.tExpire);
        // USHORT usLevel;

        m_Database->AddGroup(&g);
    }

    // Try to find Oubliette's path in the registry to read category names.
    TCHAR buffer[256];
    ULONG size;
    CString ini;

    ZeroMemory(buffer,sizeof(buffer));

    CRegKey r;
    if (r.Open(HKEY_LOCAL_MACHINE,_T("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Oubliette_is1"),KEY_READ)==ERROR_SUCCESS) {
        size=_countof(buffer);
        r.QueryStringValue(_T("Inno Setup: App Path"),buffer,&size);
        ini=buffer;
        ini+=_T("\\Oubliette.ini");
    }

    g.usLevel=1;

    // Loop over all entries and add them to KeePass.
    PW_ENTRY e;
    for (int i=0;i<header->getCount();++i) {
        OublietteFile::Account account=file.processNext();
        g.uImageId=account.category;

        // Add a "Subgroup" for every used Oubliette category.
        CString category=file.getCategoryName(account.category).c_str();
        if (category.IsEmpty()) {
            category.Format(_T("Category%i"),account.category+1);
            GetPrivateProfileString("Categories",category,category,buffer,size,ini);
            g.pszGroupName=buffer;
        }
        g.pszGroupName=category.GetBuffer();

        // Create each category only once; empty categories are not created.
        DWORD dwGroupId=m_Database->GetGroupId(g.pszGroupName);
        if (dwGroupId==DWORD_MAX) {
            m_Database->AddGroup(&g);
            dwGroupId=m_Database->GetGroupId(g.pszGroupName);
        }

        ZeroMemory(&e,sizeof(PW_ENTRY));
        // BYTE uuid[16];
        e.uGroupId=dwGroupId;
        e.uImageId=g.uImageId;

        CA2CT pszTitle(account.name.c_str());
        e.pszTitle=const_cast<TCHAR*>(pszTitle.m_psz);

        CA2CT pszURL(account.url.c_str());
        e.pszURL=const_cast<TCHAR*>(pszURL.m_psz);

        CA2CT pszUserName(account.username.c_str());
        e.pszUserName=const_cast<TCHAR*>(pszUserName.m_psz);

        CA2CT pszPassword(account.password.c_str());
        e.pszPassword=const_cast<TCHAR*>(pszPassword.m_psz);
        e.uPasswordLen=static_cast<DWORD>(_tcslen(e.pszPassword));

        std::string additional;

        if (!account.email.empty()) {
            additional+="Email:\n"+account.email;
        }

        if (!account.note.empty()) {
            if (!additional.empty()) {
                additional+="\n\n";
            }
            additional+="Note:\n"+account.note;
        }

        if (!account.memo.empty()) {
            if (!additional.empty()) {
                additional+="\n\n";
            }
            additional+="Memo:\n"+account.memo;
        }

        CA2CT pszAdditional(additional.c_str());
        e.pszAdditional=const_cast<TCHAR*>(pszAdditional.m_psz);

        e.tCreation=ConvertDateTime(account.created);
        e.tLastMod=ConvertDateTime(account.created);
        e.tLastAccess=g.tLastAccess;
        if (account.expires.isValid()) {
            e.tExpire=ConvertDateTime(account.expires);
        }
        else {
            m_PluginAPI->GetNeverExpireTime(&e.tExpire);
        }

        // TCHAR *pszBinaryDesc;
        // BYTE *pBinaryData;
        // DWORD uBinaryDataLen;

        m_Database->AddEntry(&e);
    }

    m_PluginAPI->SetFileModified(TRUE);
    m_PluginAPI->UpdateUI();
    m_PluginAPI->UpdateToolBar();

    INT item=m_PluginAPI->GetEntryListItemCount();
    m_PluginAPI->EntryListEnsureVisible(item,FALSE);

    return true;
}