void CPictureInfoTag::SetInfo(int info, const std::string& value)
{
  switch (info)
  {
  case SLIDE_RESOLUTION:
    {
      std::vector<std::string> dimension;
      StringUtils::Tokenize(value, dimension, ",");
      if (dimension.size() == 2)
      {
        m_exifInfo.Width = atoi(dimension[0].c_str());
        m_exifInfo.Height = atoi(dimension[1].c_str());
        m_isInfoSetExternally = true; // Set the internal state to show metadata has been set by call to SetInfo
      }
      break;
    }
  case SLIDE_EXIF_DATE_TIME:
    {
      strcpy(m_exifInfo.DateTime, value.c_str());
      m_isInfoSetExternally = true; // Set the internal state to show metadata has been set by call to SetInfo
      ConvertDateTime();
      break;
    }
  default:
    break;
  }
}
bool CPictureInfoTag::Load(const std::string &path)
{
  m_isLoaded = false;

  if (process_jpeg(path.c_str(), &m_exifInfo, &m_iptcInfo))
    m_isLoaded = true;

  ConvertDateTime();

  return m_isLoaded;
}
示例#3
0
bool CPictureInfoTag::Load(const std::string &path)
{
  m_isLoaded = false;

  DllLibExif exifDll;
  if (path.empty() || !exifDll.Load())
    return false;

  if (exifDll.process_jpeg(path.c_str(), &m_exifInfo, &m_iptcInfo))
    m_isLoaded = true;

  ConvertDateTime();

  return m_isLoaded;
}
示例#4
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;
}