diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2017-04-30 03:00:00 +0300 |
---|---|---|
committer | Kornel <kornel@geekhood.net> | 2017-05-05 20:56:20 +0300 |
commit | 2efa10565ac395d2ce9a679ead46e70fb2f963eb (patch) | |
tree | 84c8df4deb69ec44ea15af9378f24347db55c357 /CPP/7zip/UI/Far | |
parent | 603abd5528c97346e9448c0ff47949f818fe558c (diff) |
17.0017.00
Diffstat (limited to 'CPP/7zip/UI/Far')
-rw-r--r-- | CPP/7zip/UI/Far/ExtractEngine.cpp | 15 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/Far.cpp | 21 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/FarUtils.cpp | 63 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/FarUtils.h | 24 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/OverwriteDialogFar.cpp | 59 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/Plugin.cpp | 42 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/PluginDelete.cpp | 2 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/PluginRead.cpp | 12 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/PluginWrite.cpp | 35 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/ProgressBox.cpp | 13 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/ProgressBox.h | 2 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/UpdateCallbackFar.cpp | 33 | ||||
-rw-r--r-- | CPP/7zip/UI/Far/UpdateCallbackFar.h | 20 |
13 files changed, 203 insertions, 138 deletions
diff --git a/CPP/7zip/UI/Far/ExtractEngine.cpp b/CPP/7zip/UI/Far/ExtractEngine.cpp index c21655fd..04bad724 100644 --- a/CPP/7zip/UI/Far/ExtractEngine.cpp +++ b/CPP/7zip/UI/Far/ExtractEngine.cpp @@ -6,7 +6,6 @@ #include "../../../Windows/Synchronization.h" #endif -#include "../../../Common/IntToString.h" #include "../../../Common/StringConvert.h" #include "ExtractEngine.h" @@ -128,9 +127,9 @@ STDMETHODIMP CExtractCallbackImp::AskOverwrite( return CheckBreak2(); } -static const char *kTestString = "Testing"; -static const char *kExtractString = "Extracting"; -static const char *kSkipString = "Skipping"; +static const char * const kTestString = "Testing"; +static const char * const kExtractString = "Extracting"; +static const char * const kSkipString = "Skipping"; STDMETHODIMP CExtractCallbackImp::PrepareOperation(const wchar_t *name, Int32 /* isFolder */, Int32 askExtractMode, const UInt64 * /* position */) { @@ -161,7 +160,7 @@ STDMETHODIMP CExtractCallbackImp::MessageError(const wchar_t *message) { MT_LOCK - AString s = UnicodeStringToMultiByte(message, CP_OEMCP); + AString s (UnicodeStringToMultiByte(message, CP_OEMCP)); if (g_StartupInfo.ShowErrorMessage((const char *)s) == -1) return E_ABORT; @@ -198,7 +197,7 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s) if (messageID != 0) { s = g_StartupInfo.GetMsgString(messageID); - s.Replace(" '%s'", ""); + s.Replace((AString)" '%s'", AString()); } else if (opRes == NArchive::NExtract::NOperationResult::kUnavailable) s = "Unavailable data"; @@ -212,10 +211,8 @@ void SetExtractErrorMessage(Int32 opRes, Int32 encrypted, AString &s) s = "kHeaders Error"; else { - char temp[16]; - ConvertUInt32ToString(opRes, temp); s = "Error #"; - s += temp; + s.Add_UInt32(opRes); } } } diff --git a/CPP/7zip/UI/Far/Far.cpp b/CPP/7zip/UI/Far/Far.cpp index 7c0876dd..cec4af52 100644 --- a/CPP/7zip/UI/Far/Far.cpp +++ b/CPP/7zip/UI/Far/Far.cpp @@ -25,10 +25,10 @@ using namespace NFar; static const DWORD kShowProgressTime_ms = 100; -static const char *kCommandPrefix = "7-zip"; -static const TCHAR *kRegisrtryMainKeyName = TEXT(""); -static const TCHAR *kRegisrtryValueNameEnabled = TEXT("UsedByDefault3"); -static const char *kHelpTopicConfig = "Config"; +static const char * const kCommandPrefix = "7-zip"; +static const char * const kRegisrtryMainKeyName = NULL; // "" +static LPCTSTR const kRegisrtryValueNameEnabled = TEXT("UsedByDefault3"); +static const char * const kHelpTopicConfig = "Config"; static bool kPluginEnabledDefault = true; HINSTANCE g_hInstance; @@ -67,7 +67,7 @@ static struct COptions bool Enabled; } g_Options; -static const TCHAR *kPliginNameForRegestry = TEXT("7-ZIP"); +static const char * const kPliginNameForRegistry = "7-ZIP"; EXTERN_C void WINAPI ExitFAR() { @@ -84,7 +84,7 @@ EXTERN_C void WINAPI ExitFAR() EXTERN_C void WINAPI SetStartupInfo(const PluginStartupInfo *info) { MY_TRY_BEGIN; - g_StartupInfo.Init(*info, kPliginNameForRegestry); + g_StartupInfo.Init(*info, kPliginNameForRegistry); g_Options.Enabled = g_StartupInfo.QueryRegKeyValue( HKEY_CURRENT_USER, kRegisrtryMainKeyName, kRegisrtryValueNameEnabled, kPluginEnabledDefault); @@ -299,8 +299,7 @@ HRESULT GetPassword(UString &password) if (g_StartupInfo.ShowDialog(76, 6, NULL, dialogItems, kNumItems) < 0) return E_ABORT; - AString oemPassword = dialogItems[2].Data; - password = MultiByteToUnicodeString(oemPassword, CP_OEMCP); + password = MultiByteToUnicodeString(dialogItems[2].Data, CP_OEMCP); return S_OK; } @@ -449,7 +448,7 @@ EXTERN_C HANDLE WINAPI OpenPlugin(int openFrom, INT_PTR item) if (openFrom == OPEN_COMMANDLINE) { - AString fileName = (const char *)item; + AString fileName ((const char *)item); if (fileName.IsEmpty()) return INVALID_HANDLE_VALUE; if (fileName.Len() >= 2 @@ -522,9 +521,9 @@ EXTERN_C int WINAPI GetFindData(HANDLE plugin, struct PluginPanelItem **panelIte EXTERN_C void WINAPI FreeFindData(HANDLE plugin, struct PluginPanelItem *panelItems, int itemsNumber) { - MY_TRY_BEGIN; + // MY_TRY_BEGIN; ((CPlugin *)plugin)->FreeFindData(panelItems, itemsNumber); - MY_TRY_END1("FreeFindData"); + // MY_TRY_END1("FreeFindData"); } EXTERN_C int WINAPI GetFiles(HANDLE plugin, struct PluginPanelItem *panelItems, diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp index cc058ef9..ddca3cab 100644 --- a/CPP/7zip/UI/Far/FarUtils.cpp +++ b/CPP/7zip/UI/Far/FarUtils.cpp @@ -2,7 +2,7 @@ #include "StdAfx.h" -#include "../../../Common/IntToString.h" +// #include "../../../Common/IntToString.h" #include "../../../Common/StringConvert.h" #ifndef UNDER_CE @@ -19,13 +19,15 @@ namespace NFar { CStartupInfo g_StartupInfo; +const char kRegistryKeyDelimiter = '\\'; + void CStartupInfo::Init(const PluginStartupInfo &pluginStartupInfo, - const CSysString &pluginNameForRegestry) + const char *pluginNameForRegistry) { m_Data = pluginStartupInfo; - m_RegistryPath = GetSystemString(pluginStartupInfo.RootKey); - m_RegistryPath += TEXT('\\'); - m_RegistryPath += pluginNameForRegestry; + m_RegistryPath = pluginStartupInfo.RootKey; + m_RegistryPath += kRegistryKeyDelimiter; + m_RegistryPath += pluginNameForRegistry; } const char *CStartupInfo::GetMsgString(int messageId) @@ -114,7 +116,7 @@ static void SplitString(const AString &src, AStringVector &destStrings) int CStartupInfo::ShowErrorMessage(const char *message) { AStringVector strings; - SplitString(message, strings); + SplitString((AString)message, strings); const unsigned kNumStringsMax = 20; const char *items[kNumStringsMax + 1]; unsigned pos = 0; @@ -209,28 +211,31 @@ void CStartupInfo::RestoreScreen(HANDLE handle) m_Data.RestoreScreen(handle); } -const TCHAR kRegestryKeyDelimiter = TEXT('\''); - -CSysString CStartupInfo::GetFullKeyName(const CSysString &keyName) const +CSysString CStartupInfo::GetFullKeyName(const char *keyName) const { - return (keyName.IsEmpty()) ? m_RegistryPath: - (m_RegistryPath + kRegestryKeyDelimiter + keyName); + AString s = m_RegistryPath; + if (keyName && *keyName) + { + s += kRegistryKeyDelimiter; + s += keyName; + } + return (CSysString)s; } LONG CStartupInfo::CreateRegKey(HKEY parentKey, - const CSysString &keyName, NRegistry::CKey &destKey) const + const char *keyName, NRegistry::CKey &destKey) const { return destKey.Create(parentKey, GetFullKeyName(keyName)); } LONG CStartupInfo::OpenRegKey(HKEY parentKey, - const CSysString &keyName, NRegistry::CKey &destKey) const + const char *keyName, NRegistry::CKey &destKey) const { return destKey.Open(parentKey, GetFullKeyName(keyName)); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, LPCTSTR value) const { NRegistry::CKey regKey; @@ -238,7 +243,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, regKey.SetValue(valueName, value); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, UInt32 value) const { NRegistry::CKey regKey; @@ -246,7 +251,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, regKey.SetValue(valueName, value); } -void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, +void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, bool value) const { NRegistry::CKey regKey; @@ -254,7 +259,7 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const CSysString &keyName, regKey.SetValue(valueName, value); } -CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, +CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, const CSysString &valueDefault) const { NRegistry::CKey regKey; @@ -268,7 +273,7 @@ CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyN return value; } -UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, +UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, UInt32 valueDefault) const { NRegistry::CKey regKey; @@ -282,7 +287,7 @@ UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, return value; } -bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, +bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, bool valueDefault) const { NRegistry::CKey regKey; @@ -390,7 +395,7 @@ int CStartupInfo::Menu( unsigned int flags, const char *title, const char *helpTopic, - const CSysStringVector &items, + const AStringVector &items, int selectedItem) { CRecordVector<FarMenuItem> farMenuItems; @@ -400,8 +405,8 @@ int CStartupInfo::Menu( item.Checked = 0; item.Separator = 0; item.Selected = ((int)i == selectedItem); - CSysString reducedString = items[i].Left(ARRAY_SIZE(item.Text) - 1); - MyStringCopy(item.Text, (const char *)GetOemString(reducedString)); + const AString reducedString (items[i].Left(ARRAY_SIZE(item.Text) - 1)); + MyStringCopy(item.Text, reducedString); farMenuItems.Add(item); } return Menu(flags, title, helpTopic, &farMenuItems.Front(), farMenuItems.Size()); @@ -434,11 +439,9 @@ void CScreenRestorer::Restore() int PrintErrorMessage(const char *message, unsigned code) { - AString s = message; + AString s (message); s += " #"; - char temp[16]; - ConvertUInt32ToString((UInt32)code, temp); - s += temp; + s.Add_UInt32((UInt32)code); return g_StartupInfo.ShowErrorMessage(s); } @@ -479,10 +482,10 @@ int ShowLastErrorMessage() int ShowSysErrorMessage(DWORD errorCode, const wchar_t *name) { - UString s = NError::MyFormatMessage(errorCode); - AString s1 = UnicodeStringToMultiByte(s, CP_OEMCP); - AString s2 = UnicodeStringToMultiByte(name, CP_OEMCP); - return g_StartupInfo.ShowErrorMessage2(s1, s2); + const UString s = NError::MyFormatMessage(errorCode); + return g_StartupInfo.ShowErrorMessage2( + UnicodeStringToMultiByte(s, CP_OEMCP), + UnicodeStringToMultiByte(name, CP_OEMCP)); } diff --git a/CPP/7zip/UI/Far/FarUtils.h b/CPP/7zip/UI/Far/FarUtils.h index 5617c6c8..38f64f98 100644 --- a/CPP/7zip/UI/Far/FarUtils.h +++ b/CPP/7zip/UI/Far/FarUtils.h @@ -47,17 +47,17 @@ struct CInitDialogItem class CStartupInfo { PluginStartupInfo m_Data; - CSysString m_RegistryPath; + AString m_RegistryPath; - CSysString GetFullKeyName(const CSysString &keyName) const; + CSysString GetFullKeyName(const char *keyName) const; LONG CreateRegKey(HKEY parentKey, - const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const; + const char *keyName, NWindows::NRegistry::CKey &destKey) const; LONG OpenRegKey(HKEY parentKey, - const CSysString &keyName, NWindows::NRegistry::CKey &destKey) const; + const char *keyName, NWindows::NRegistry::CKey &destKey) const; public: void Init(const PluginStartupInfo &pluginStartupInfo, - const CSysString &pluginNameForRegestry); + const char *pluginNameForRegistry); const char *GetMsgString(int messageId); int ShowMessage(unsigned int flags, const char *helpTopic, @@ -82,20 +82,20 @@ public: HANDLE SaveScreen(); void RestoreScreen(HANDLE handle); - void SetRegKeyValue(HKEY parentKey, const CSysString &keyName, + void SetRegKeyValue(HKEY parentKey, const char *keyName, const LPCTSTR valueName, LPCTSTR value) const; - void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, + void SetRegKeyValue(HKEY hRoot, const char *keyName, const LPCTSTR valueName, UInt32 value) const; - void SetRegKeyValue(HKEY hRoot, const CSysString &keyName, + void SetRegKeyValue(HKEY hRoot, const char *keyName, const LPCTSTR valueName, bool value) const; - CSysString QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, + CSysString QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, const CSysString &valueDefault) const; - UInt32 QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, + UInt32 QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, UInt32 valueDefault) const; - bool QueryRegKeyValue(HKEY parentKey, const CSysString &keyName, + bool QueryRegKeyValue(HKEY parentKey, const char *keyName, LPCTSTR valueName, bool valueDefault) const; bool Control(HANDLE plugin, int command, void *param); @@ -131,7 +131,7 @@ public: unsigned int flags, const char *title, const char *helpTopic, - const CSysStringVector &items, + const AStringVector &items, int selectedItem); int Editor(const char *fileName, const char *title, diff --git a/CPP/7zip/UI/Far/OverwriteDialogFar.cpp b/CPP/7zip/UI/Far/OverwriteDialogFar.cpp index e950f695..1171453e 100644 --- a/CPP/7zip/UI/Far/OverwriteDialogFar.cpp +++ b/CPP/7zip/UI/Far/OverwriteDialogFar.cpp @@ -43,23 +43,31 @@ void SetFileInfoStrings(const CFileInfo &fileInfo, fileInfoStrings.Size = ""; } - FILETIME localFileTime; fileInfoStrings.Time.Empty(); if (fileInfo.TimeIsDefined) { - if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime)) - throw 4190402; char timeString[32]; - ConvertFileTimeToString(localFileTime, timeString); + ConvertUtcFileTimeToString(fileInfo.Time, timeString); fileInfoStrings.Time = g_StartupInfo.GetMsgString(NMessageID::kOverwriteModifiedOn); fileInfoStrings.Time += ' '; fileInfoStrings.Time += timeString; } } +static void ReduceString2(UString &s, unsigned size) +{ + if (!s.IsEmpty() && s.Back() == ' ') + { + // s += (wchar_t)(0x2423); + s.InsertAtFront(L'\"'); + s += L'\"'; + } + ReduceString(s, size); +} + NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInfo) { - const int kYSize = 20; + const int kYSize = 22; const int kXSize = 76; CFileInfoStrings oldFileInfoStrings; @@ -68,17 +76,30 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf SetFileInfoStrings(oldFileInfo, oldFileInfoStrings); SetFileInfoStrings(newFileInfo, newFileInfoStrings); - UString oldName2 = oldFileInfo.Name; - UString newName2 = newFileInfo.Name; + const UString &oldName2 = oldFileInfo.Name; + const UString &newName2 = newFileInfo.Name; + + int slashPos = oldName2.ReverseFind_PathSepar(); + UString pref1 = oldName2.Left(slashPos + 1); + UString name1 = oldName2.Ptr(slashPos + 1); + + slashPos = newName2.ReverseFind_PathSepar(); + UString pref2 = newName2.Left(slashPos + 1); + UString name2 = newName2.Ptr(slashPos + 1); + const unsigned kNameOffset = 2; { const unsigned maxNameLen = kXSize - 9 - 2; - ReduceString(oldName2, maxNameLen); - ReduceString(newName2, maxNameLen); + ReduceString(pref1, maxNameLen); + ReduceString(pref2, maxNameLen); + ReduceString2(name1, maxNameLen - kNameOffset); + ReduceString2(name2, maxNameLen - kNameOffset); } - AString oldName = UnicodeStringToMultiByte(oldName2); - AString newName = UnicodeStringToMultiByte(newName2); + AString pref1A (UnicodeStringToMultiByte(pref1, CP_OEMCP)); + AString pref2A (UnicodeStringToMultiByte(pref2, CP_OEMCP)); + AString name1A (UnicodeStringToMultiByte(name1, CP_OEMCP)); + AString name2A (UnicodeStringToMultiByte(name2, CP_OEMCP)); struct CInitDialogItem initItems[]={ { DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kOverwriteTitle, NULL, NULL }, @@ -88,15 +109,17 @@ NResult::EEnum Execute(const CFileInfo &oldFileInfo, const CFileInfo &newFileInf { DI_TEXT, 5, 4, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWouldYouLike, NULL, NULL }, - { DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, oldName, NULL }, - { DI_TEXT, 7, 7, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL }, - { DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL }, + { DI_TEXT, 7, 6, 0, 0, false, false, 0, false, -1, pref1A, NULL }, + { DI_TEXT, 7 + kNameOffset, 7, 0, 0, false, false, 0, false, -1, name1A, NULL }, + { DI_TEXT, 7, 8, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Size, NULL }, + { DI_TEXT, 7, 9, 0, 0, false, false, 0, false, -1, oldFileInfoStrings.Time, NULL }, - { DI_TEXT, 5, 10, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL }, + { DI_TEXT, 5, 11, 0, 0, false, false, 0, false, NMessageID::kOverwriteMessageWithtTisOne, NULL, NULL }, - { DI_TEXT, 7, 12, 0, 0, false, false, 0, false, -1, newName, NULL }, - { DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL }, - { DI_TEXT, 7, 14, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL }, + { DI_TEXT, 7, 13, 0, 0, false, false, 0, false, -1, pref2A, NULL }, + { DI_TEXT, 7 + kNameOffset, 14, 0, 0, false, false, 0, false, -1, name2A, NULL }, + { DI_TEXT, 7, 15, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Size, NULL }, + { DI_TEXT, 7, 16, 0, 0, false, false, 0, false, -1, newFileInfoStrings.Time, NULL }, { DI_TEXT, 3, kYSize - 5, 0, 0, false, false, DIF_BOXCOLOR|DIF_SEPARATOR, false, -1, "", NULL }, diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index 607cdfe3..72f81ac9 100644 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp @@ -30,7 +30,8 @@ int CompareFileNames_ForFolderList(const wchar_t *s1, const wchar_t *s2) CPlugin::CPlugin(const FString &fileName, CAgent *agent, UString archiveTypeName): _agent(agent), m_FileName(fileName), - _archiveTypeName(archiveTypeName) + _archiveTypeName(archiveTypeName), + PasswordIsDefined(false) { m_ArchiveHandler = agent; if (!m_FileInfo.Find(m_FileName)) @@ -82,7 +83,7 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) if (prop.vt != VT_BSTR) throw 272340; - AString oemString = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); + AString oemString (UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP)); if (oemString == "..") oemString = kDotsReplaceString; @@ -193,7 +194,7 @@ void CPlugin::EnterToDirectory(const UString &dirName) CMyComPtr<IFolderFolder> newFolder; UString s = dirName; if (dirName == kDotsReplaceStringU) - s = L".."; + s = ".."; _folder->BindToFolder(s, &newFolder); if (!newFolder) if (dirName.IsEmpty()) @@ -281,7 +282,7 @@ void CPlugin::SetCurrentDirVar() } } -static const char *kPluginFormatName = "7-ZIP"; +static const char * const kPluginFormatName = "7-ZIP"; static int FindPropNameID(PROPID propID) @@ -371,17 +372,17 @@ static AString GetNameOfProp(PROPID propID, const wchar_t *name) { int farID = FindPropNameID(propID); if (farID >= 0) - return g_StartupInfo.GetMsgString(farID); + return (AString)g_StartupInfo.GetMsgString(farID); if (name) - return UnicodeStringToMultiByte((const wchar_t *)name, CP_OEMCP); + return UnicodeStringToMultiByte(name, CP_OEMCP); char s[16]; ConvertUInt32ToString(propID, s); - return s; + return (AString)s; } static AString GetNameOfProp2(PROPID propID, const wchar_t *name) { - AString s = GetNameOfProp(propID, name); + AString s (GetNameOfProp(propID, name)); if (s.Len() > (kInfoPanelLineSize - 1)) s.DeleteFrom(kInfoPanelLineSize - 1); return s; @@ -403,14 +404,14 @@ static AString ConvertSizeToString(UInt64 value) } while (i > 0) s[--pos] = s[--i]; - return s + pos; + return (AString)(s + pos); } static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID) { if (prop.vt == VT_BSTR) { - AString s = UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP); + AString s (UnicodeStringToMultiByte(prop.bstrVal, CP_OEMCP)); s.Replace((char)0xA, ' '); s.Replace((char)0xD, ' '); return s; @@ -419,7 +420,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID) { int messageID = VARIANT_BOOLToBool(prop.boolVal) ? NMessageID::kYes : NMessageID::kNo; - return g_StartupInfo.GetMsgString(messageID); + return (AString)g_StartupInfo.GetMsgString(messageID); } if (prop.vt != VT_EMPTY) { @@ -441,8 +442,8 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID) } { char sz[64]; - ConvertPropertyToShortString(sz, prop, propID); - return sz; + ConvertPropertyToShortString2(sz, prop, propID); + return (AString)sz; } } return AString(); @@ -450,7 +451,7 @@ static AString PropToString(const NCOM::CPropVariant &prop, PROPID propID) static AString PropToString2(const NCOM::CPropVariant &prop, PROPID propID) { - AString s = PropToString(prop, propID); + AString s (PropToString(prop, propID)); if (s.Len() > (kInfoPanelLineSize - 1)) s.DeleteFrom(kInfoPanelLineSize - 1); return s; @@ -461,7 +462,7 @@ static void AddPropertyString(InfoPanelLine *lines, int &numItems, PROPID propID { if (prop.vt != VT_EMPTY) { - AString val = PropToString2(prop, propID); + AString val (PropToString2(prop, propID)); if (!val.IsEmpty()) { InfoPanelLine &item = lines[numItems++]; @@ -504,9 +505,9 @@ void CPlugin::GetOpenPluginInfo(struct OpenPluginInfo *info) name = fs2us(fileName); } - m_PannelTitle = L' '; + m_PannelTitle = ' '; m_PannelTitle += _archiveTypeName; - m_PannelTitle += L':'; + m_PannelTitle += ':'; m_PannelTitle += name; m_PannelTitle.Add_Space(); if (!m_CurrentDir.IsEmpty()) @@ -748,8 +749,7 @@ HRESULT CPlugin::ShowAttributesWindow() NCOM::CPropVariant prop; RINOK(_folder->GetProperty(itemIndex, property.ID, &prop)); - AString s = PropToString(prop, property.ID); - values.Add(s); + values.Add(PropToString(prop, property.ID)); { const CInitDialogItem idi = @@ -803,10 +803,8 @@ HRESULT CPlugin::ShowAttributesWindow() const UInt32 kMaxDataSize = 64; if (dataSize > kMaxDataSize) { - char temp[64]; s += "data:"; - ConvertUInt32ToString(dataSize, temp); - s += temp; + s.Add_UInt32(dataSize); } else { diff --git a/CPP/7zip/UI/Far/PluginDelete.cpp b/CPP/7zip/UI/Far/PluginDelete.cpp index e1a103ac..95584341 100644 --- a/CPP/7zip/UI/Far/PluginDelete.cpp +++ b/CPP/7zip/UI/Far/PluginDelete.cpp @@ -84,6 +84,8 @@ int CPlugin::DeleteFiles(PluginPanelItem *panelItems, int numItems, int opMode) CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec); updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer); + updateCallbackSpec->PasswordIsDefined = PasswordIsDefined; + updateCallbackSpec->Password = Password; /* outArchive->SetFolder(_folder); diff --git a/CPP/7zip/UI/Far/PluginRead.cpp b/CPP/7zip/UI/Far/PluginRead.cpp index 433e8140..9df4a09f 100644 --- a/CPP/7zip/UI/Far/PluginRead.cpp +++ b/CPP/7zip/UI/Far/PluginRead.cpp @@ -21,11 +21,11 @@ using namespace NFile; using namespace NDir; using namespace NFar; -static const char *kHelpTopicExtrFromSevenZip = "Extract"; +static const char * const kHelpTopicExtrFromSevenZip = "Extract"; -static const char kDirDelimiter = '\\'; +static const char kDirDelimiter = CHAR_PATH_SEPARATOR; -static const char *kExractPathHistoryName = "7-ZipExtractPath"; +static const char * const kExractPathHistoryName = "7-ZipExtractPath"; HRESULT CPlugin::ExtractFiles( bool decompressAllItems, @@ -95,7 +95,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa return NFileOperationReturnCode::kError; } - AString destPath = destPathLoc; + AString destPath (destPathLoc); UString destPathU = GetUnicodeString(destPath, CP_OEMCP); NName::NormalizeDirPathPrefix(destPathU); destPath = UnicodeStringToMultiByte(destPathU, CP_OEMCP); @@ -127,7 +127,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa const int kXMid = kXSize / 2; - AString oemPassword = UnicodeStringToMultiByte(password, CP_OEMCP); + AString oemPassword (UnicodeStringToMultiByte(password, CP_OEMCP)); struct CInitDialogItem initItems[]={ { DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, NMessageID::kExtractTitle, NULL, NULL }, @@ -196,7 +196,7 @@ NFileOperationReturnCode::EEnum CPlugin::GetFilesReal(struct PluginPanelItem *pa if (destPathU.IsEmpty()) { #ifdef UNDER_CE - destPathU = L"\\"; + destPathU = "\\"; #else FString destPathF = us2fs(destPathU); if (!GetCurrentDir(destPathF)) diff --git a/CPP/7zip/UI/Far/PluginWrite.cpp b/CPP/7zip/UI/Far/PluginWrite.cpp index b22577af..ec0f119b 100644 --- a/CPP/7zip/UI/Far/PluginWrite.cpp +++ b/CPP/7zip/UI/Far/PluginWrite.cpp @@ -27,9 +27,9 @@ using namespace NFar; using namespace NUpdateArchive; -static const char *kHelpTopic = "Update"; +static const char * const kHelpTopic = "Update"; -static const char *kArchiveHistoryKeyName = "7-ZipArcName"; +static const char * const kArchiveHistoryKeyName = "7-ZipArcName"; static const UInt32 g_MethodMap[] = { 0, 1, 3, 5, 7, 9 }; @@ -38,13 +38,18 @@ static HRESULT SetOutProperties(IOutFolderArchive *outArchive, UInt32 method) CMyComPtr<ISetProperties> setProperties; if (outArchive->QueryInterface(IID_ISetProperties, (void **)&setProperties) == S_OK) { + /* UStringVector realNames; - realNames.Add(UString(L"x")); + realNames.Add(UString("x")); NCOM::CPropVariant value = (UInt32)method; CRecordVector<const wchar_t *> names; FOR_VECTOR (i, realNames) names.Add(realNames[i]); RINOK(setProperties->SetProperties(&names.Front(), &value, names.Size())); + */ + NCOM::CPropVariant value = (UInt32)method; + const wchar_t *name = L"x"; + RINOK(setProperties->SetProperties(&name, &value, 1)); } return S_OK; } @@ -219,6 +224,8 @@ NFileOperationReturnCode::EEnum CPlugin::PutFiles( CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec ); updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer); + updateCallbackSpec->PasswordIsDefined = PasswordIsDefined; + updateCallbackSpec->Password = Password; if (SetOutProperties(outArchive, compressionInfo.Level) != S_OK) return NFileOperationReturnCode::kError; @@ -287,7 +294,7 @@ struct CParsedPath UString MergePath() const; }; -static const wchar_t kDirDelimiter = WCHAR_PATH_SEPARATOR; +static const char kDirDelimiter = CHAR_PATH_SEPARATOR; static const wchar_t kDiskDelimiter = L':'; namespace NPathType @@ -322,7 +329,7 @@ void CParsedPath::ParsePath(const UString &path) case NPathType::kUNC: { // the bug was fixed: - curPos = path.Find(kDirDelimiter, 2); + curPos = path.Find((wchar_t)kDirDelimiter, 2); if (curPos < 0) curPos = path.Len(); else @@ -355,7 +362,7 @@ static void SetArcName(UString &arcName, const CArcInfoEx &arcInfo) if (dotPos > slashPos + 1) arcName.DeleteFrom(dotPos); } - arcName += L'.'; + arcName += '.'; arcName += arcInfo.GetMainExt(); } @@ -444,7 +451,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) for (;;) { - AString archiveNameA = UnicodeStringToMultiByte(arcName, CP_OEMCP); + AString archiveNameA (UnicodeStringToMultiByte(arcName, CP_OEMCP)); const int kYSize = 16; const int kXMid = 38; @@ -456,7 +463,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) char updateAddToArchiveString[512]; { const CArcInfoEx &arcInfo = codecs->Formats[archiverIndex]; - const AString s = UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP); + const AString s (UnicodeStringToMultiByte(arcInfo.Name, CP_OEMCP)); sprintf(updateAddToArchiveString, g_StartupInfo.GetMsgString(NMessageID::kUpdateAddToArchive), (const char *)s); } @@ -530,14 +537,14 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) if (askCode == kSelectarchiverButtonIndex) { CIntVector indices; - CSysStringVector archiverNames; + AStringVector archiverNames; FOR_VECTOR (k, codecs->Formats) { const CArcInfoEx &arc = codecs->Formats[k]; if (arc.UpdateEnabled) { indices.Add(k); - archiverNames.Add(GetSystemString(arc.Name, CP_OEMCP)); + archiverNames.Add(GetOemString(arc.Name)); } } @@ -704,7 +711,7 @@ HRESULT CompressFiles(const CObjectVector<PluginPanelItem> &pluginPanelItems) } -static const char *k_CreateFolder_History = "NewFolder"; // we use default FAR folder name +static const char * const k_CreateFolder_History = "NewFolder"; // we use default FAR folder name HRESULT CPlugin::CreateFolder() { @@ -720,7 +727,7 @@ HRESULT CPlugin::CreateFolder() const int kYSize = 8; const int kPathIndex = 2; - AString destPath = "New Folder"; + AString destPath ("New Folder"); const struct CInitDialogItem initItems[]={ { DI_DOUBLEBOX, 3, 1, kXSize - 4, kYSize - 2, false, false, 0, false, @@ -773,6 +780,8 @@ HRESULT CPlugin::CreateFolder() CMyComPtr<IFolderArchiveUpdateCallback> updateCallback(updateCallbackSpec); updateCallbackSpec->Init(/* m_ArchiveHandler, */ progressBoxPointer); + updateCallbackSpec->PasswordIsDefined = PasswordIsDefined; + updateCallbackSpec->Password = Password; HRESULT result; { @@ -797,7 +806,7 @@ HRESULT CPlugin::CreateFolder() if (g_StartupInfo.ControlGetActivePanelInfo(panelInfo)) { - AString destPath = GetOemString(destPathU); + const AString destPath (GetOemString(destPathU)); for (int i = 0; i < panelInfo.ItemsNumber; i++) { diff --git a/CPP/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp index 75467864..6efb132a 100644 --- a/CPP/7zip/UI/Far/ProgressBox.cpp +++ b/CPP/7zip/UI/Far/ProgressBox.cpp @@ -18,7 +18,7 @@ void CPercentPrinterState::ClearCurState() FileName.Empty(); } -void CProgressBox::Init(const AString &title) +void CProgressBox::Init(const char *title) { _title = title; _wasPrinted = false; @@ -218,14 +218,13 @@ void CProgressBox::Print() unsigned filled = 0; if (total != (UInt64)(Int64)-1 && total != 0) filled = (unsigned)(cur * numChars / total); + if (filled > numChars) + filled = numChars; unsigned i = 0; - if (filled < numChars) - { - for (i = 0; i < filled; i++) - _perc += '='; - } + for (i = 0; i < filled; i++) + _perc += (char)(Byte)0xDB; // '='; for (; i < numChars; i++) - _perc += '.'; + _perc += (char)(Byte)0xB0; // '.'; } _perc.Add_Space(); diff --git a/CPP/7zip/UI/Far/ProgressBox.h b/CPP/7zip/UI/Far/ProgressBox.h index 83731b38..54bdb4f1 100644 --- a/CPP/7zip/UI/Far/ProgressBox.h +++ b/CPP/7zip/UI/Far/ProgressBox.h @@ -76,7 +76,7 @@ public: MaxLen(60) {} - void Init(const AString &title); + void Init(const char *title); void Print(); }; diff --git a/CPP/7zip/UI/Far/UpdateCallbackFar.cpp b/CPP/7zip/UI/Far/UpdateCallbackFar.cpp index 18d1a2c9..3f0f206b 100644 --- a/CPP/7zip/UI/Far/UpdateCallbackFar.cpp +++ b/CPP/7zip/UI/Far/UpdateCallbackFar.cpp @@ -62,6 +62,20 @@ STDMETHODIMP CUpdateCallback100Imp::SetNumFiles(UInt64 numFiles) return CheckBreak2(); } + +STDMETHODIMP CUpdateCallback100Imp::SetTotal(const UInt64 * /* files */, const UInt64 * /* bytes */) +{ + return S_OK; +} + +STDMETHODIMP CUpdateCallback100Imp::SetCompleted(const UInt64 * /* files */, const UInt64 * /* bytes */) +{ + MT_LOCK + return CheckBreak2(); +} + + + STDMETHODIMP CUpdateCallback100Imp::SetTotal(UInt64 size) { MT_LOCK @@ -203,10 +217,21 @@ STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword(BSTR *password) MT_LOCK *password = NULL; - if (!m_PasswordIsDefined) + if (!PasswordIsDefined) { - RINOK(GetPassword(m_Password)); - m_PasswordIsDefined = true; + RINOK(GetPassword(Password)); + PasswordIsDefined = true; } - return StringToBstr(m_Password, password); + return StringToBstr(Password, password); +} + +STDMETHODIMP CUpdateCallback100Imp::CryptoGetTextPassword2(Int32 *passwordIsDefined, BSTR *password) +{ + MT_LOCK + + *password = NULL; + *passwordIsDefined = BoolToInt(PasswordIsDefined); + if (!PasswordIsDefined) + return S_OK; + return StringToBstr(Password, password); } diff --git a/CPP/7zip/UI/Far/UpdateCallbackFar.h b/CPP/7zip/UI/Far/UpdateCallbackFar.h index a2328669..d2c2c8ed 100644 --- a/CPP/7zip/UI/Far/UpdateCallbackFar.h +++ b/CPP/7zip/UI/Far/UpdateCallbackFar.h @@ -15,35 +15,45 @@ class CUpdateCallback100Imp: public IFolderArchiveUpdateCallback, public IFolderArchiveUpdateCallback2, public IFolderScanProgress, + public ICryptoGetTextPassword2, public ICryptoGetTextPassword, + public IArchiveOpenCallback, public CMyUnknownImp { // CMyComPtr<IInFolderArchive> _archiveHandler; CProgressBox *_percent; UInt64 _total; - bool m_PasswordIsDefined; - UString m_Password; public: - MY_UNKNOWN_IMP4( + + bool PasswordIsDefined; + UString Password; + + MY_UNKNOWN_IMP6( IFolderArchiveUpdateCallback, IFolderArchiveUpdateCallback2, IFolderScanProgress, - ICryptoGetTextPassword) + ICryptoGetTextPassword2, + ICryptoGetTextPassword, + IArchiveOpenCallback + ) INTERFACE_IProgress(;) INTERFACE_IFolderArchiveUpdateCallback(;) INTERFACE_IFolderArchiveUpdateCallback2(;) INTERFACE_IFolderScanProgress(;) + INTERFACE_IArchiveOpenCallback(;) STDMETHOD(CryptoGetTextPassword)(BSTR *password); + STDMETHOD(CryptoGetTextPassword2)(Int32 *passwordIsDefined, BSTR *password); CUpdateCallback100Imp(): _total(0) {} void Init(/* IInFolderArchive *archiveHandler, */ CProgressBox *progressBox) { // _archiveHandler = archiveHandler; _percent = progressBox; - m_PasswordIsDefined = false; + PasswordIsDefined = false; + Password.Empty(); } }; |