bool LoadSessionData( IN MRABase& _db, IN MAKFC_CString databaseKey, OUT MAKFC_CString& sDevId, OUT MAKFC_CString& sA, OUT MAKFC_CString& sSessionKey, OUT MAKFC_CString& ts) { gigabase::dbArray<gigabase::byte> data; if ( !_db.ReadRawData( tstring(databaseKey.NetStrW()), L"", ICQ_PARTNERS_LOGIN_DATA, data ) ) { return false; } MAKFC_CString sCookies = (LPCWSTR) data.get(); if ( !sCookies.Len() ) return false; int iStart1 = 0; MAKFC_CString sToken1; while ( ( sToken1 = sCookies.Tokenize( L";", iStart1 ) ).GetLength() ) { int iStart2 = 0; MAKFC_CString sLeft = sToken1.Tokenize( L"=", iStart2 ); MAKFC_CString sRight = sToken1.Mid( iStart2 ); if ( sLeft == L"k" ) sDevId = sRight; else if ( sLeft == L"a" ) sA = sRight; else if ( sLeft == L"session_key" ) sSessionKey = sRight; else if ( sLeft == L"time_offset" ) { __int64 offset = _wtoi64( sRight ); time_t tt = 0; FileTimeToUnixTime( &tt, CFileTime( CFileTime::GetCurrentTime().GetTime() - offset ) ); ts.Format( L"%d", (DWORD) tt ); } } return true; }
DWORD CCpDialog::UpdateFolder(LPCSTR strSrcFolder, LPCSTR strDstFolder, bool bIncludeSubFolders) { CString strSrcPath = strSrcFolder + CString("*.*"); DWORD dwFileCount = 0; CFileFind FileFind; BOOL bFound = FileFind.FindFile(strSrcPath); while (bFound) { bFound = FileFind.FindNextFile(); if (FileFind.IsDots()) continue; CString strSrcFilePath = FileFind.GetFilePath(); CString strSrcFileName = FileFind.GetFileName(); if (FileFind.IsDirectory()) { if (!bIncludeSubFolders) continue; CString strNewDstFolder = CString(strDstFolder) + strSrcFileName + "\\"; bool bCreated = !!::CreateDirectory(strNewDstFolder, NULL); if (bCreated) dwFileCount++; CString strNewSrcFolder = strSrcFilePath + "\\"; dwFileCount += UpdateFolder(strNewSrcFolder, strNewDstFolder); continue; } FILETIME SrcCreationTime; FILETIME SrcAccessedTime; FILETIME SrcModfiedTime; FileFind.GetCreationTime(&SrcCreationTime); FileFind.GetLastAccessTime(&SrcAccessedTime); FileFind.GetLastWriteTime(&SrcModfiedTime); CString strDstFilePath = CString(strDstFolder) + strSrcFileName; if (FileExists(strDstFilePath)) { FILETIME DstCreationTime; FILETIME DstAccessedTime; FILETIME DstModfiedTime; bool bOK = GetFileTimes(strDstFilePath, DstCreationTime, DstAccessedTime, DstModfiedTime); if (CFileTime(SrcModfiedTime) <= CFileTime(DstModfiedTime)) continue; DWORD dwFileAttributes = ::GetFileAttributes(strDstFilePath); if (dwFileAttributes && FILE_ATTRIBUTE_READONLY) ::SetFileAttributes(strDstFilePath, dwFileAttributes & ~FILE_ATTRIBUTE_READONLY); } bool bCopied = !!::CopyFile(strSrcFilePath, strDstFilePath, false/*bFailIfExists*/); if (bCopied) { dwFileCount++; SetFileTimes(strDstFilePath, SrcCreationTime, SrcAccessedTime, SrcModfiedTime); } } FileFind.Close(); return dwFileCount; }