Skip to content

Commit

Permalink
Use EmptyWideStr constant instead of empty string literal
Browse files Browse the repository at this point in the history
  • Loading branch information
pozitronik committed Nov 2, 2017
1 parent a4c9d4f commit 99c122f
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 67 deletions.
12 changes: 0 additions & 12 deletions Accounts.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,6 @@ object AccountsForm: TAccountsForm
TabOrder = 0
object AccountsTab: TTabSheet
Caption = 'Accounts'
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
DesignSize = (
483
447)
Expand Down Expand Up @@ -386,10 +382,6 @@ object AccountsForm: TAccountsForm
object GlobalTab: TTabSheet
Caption = 'Global settings'
ImageIndex = 1
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object CloudMaxFileSizeLabelBytes: TLabel
Left = 292
Top = 115
Expand Down Expand Up @@ -668,10 +660,6 @@ object AccountsForm: TAccountsForm
object NetworkTab: TTabSheet
Caption = 'Network settings'
ImageIndex = 2
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
object SocketTimeoutLabel: TLabel
Left = 5
Top = 11
Expand Down
24 changes: 12 additions & 12 deletions Accounts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ procedure TAccountsForm.AccountsListClick(Sender: TObject);
EncryptFilesCombo.ItemIndex := CASettings.encrypt_files_mode;
EncryptFilenamesCB.Checked := CASettings.encrypt_filenames;
end else begin
AccountNameEdit.Text := '';
EmailEdit.Text := '';
PasswordEdit.Text := '';
AccountNameEdit.Text := EmptyWideStr;
EmailEdit.Text := EmptyWideStr;
PasswordEdit.Text := EmptyWideStr;
UseTCPwdMngrCB.Checked := false;
end;
PublicAccountCB.OnClick(nil);
Expand All @@ -168,7 +168,7 @@ procedure TAccountsForm.ApplyButtonClick(Sender: TObject);
var
CASettings: TAccountSettings;
begin
if (AccountNameEdit.Text = '') then
if (AccountNameEdit.Text = EmptyWideStr) then
exit();
CASettings.name := AccountNameEdit.Text;
CASettings.email := EmailEdit.Text;
Expand All @@ -187,7 +187,7 @@ procedure TAccountsForm.ApplyButtonClick(Sender: TObject);
case self.CryptHandler(FS_CRYPT_SAVE_PASSWORD, PWideChar(CASettings.name), PWideChar(CASettings.password), SizeOf(CASettings.password)) of
FS_FILE_OK:
begin //TC скушал пароль
CASettings.password := '';
CASettings.password := EmptyWideStr;
end;
FS_FILE_NOTSUPPORTED: //нажали отмену на вводе мастер-пароля
begin //просто выйдем
Expand Down Expand Up @@ -260,8 +260,8 @@ procedure TAccountsForm.ApplySettings;
case self.CryptHandler(FS_CRYPT_SAVE_PASSWORD, PWideChar('proxy' + ProxyUserEdit.Text), PWideChar(ProxyPwd.Text), SizeOf(ProxyPwd.Text)) of
FS_FILE_OK:
begin //TC скушал пароль
ProxyPwd.Text := '';
SetPluginSettingsValue(SettingsIniFilePath, 'ProxyPassword', '');
ProxyPwd.Text := EmptyWideStr;
SetPluginSettingsValue(SettingsIniFilePath, 'ProxyPassword', EmptyWideStr);
end;
FS_FILE_NOTSUPPORTED: //нажали отмену на вводе мастер-пароля
begin //просто выйдем
Expand Down Expand Up @@ -309,7 +309,7 @@ procedure TAccountsForm.DeleteButtonClick(Sender: TObject);

procedure TAccountsForm.FormActivate(Sender: TObject);
begin
ProxyTCPwdMngrCB.Enabled := ProxyUserEdit.Text <> '';
ProxyTCPwdMngrCB.Enabled := ProxyUserEdit.Text <> EmptyWideStr;
CenterWindow(self.parentWindow, self.Handle);
end;

Expand All @@ -319,7 +319,7 @@ procedure TAccountsForm.FormShow(Sender: TObject);
AccountsList.SetFocus;
if AccountsList.Items.Count > 0 then
begin
if (self.SelectedAccount <> '') and (AccountsList.Items.IndexOf(self.SelectedAccount) <> -1) then
if (self.SelectedAccount <> EmptyWideStr) and (AccountsList.Items.IndexOf(self.SelectedAccount) <> -1) then
begin
AccountsList.Selected[AccountsList.Items.IndexOf(self.SelectedAccount)] := true;
end else begin
Expand All @@ -337,7 +337,7 @@ procedure TAccountsForm.GlobalSettingApplyBTNClick(Sender: TObject);

procedure TAccountsForm.ProxyUserEditChange(Sender: TObject);
begin
ProxyTCPwdMngrCB.Enabled := ProxyUserEdit.Text <> '';
ProxyTCPwdMngrCB.Enabled := ProxyUserEdit.Text <> EmptyWideStr;
end;

procedure TAccountsForm.PublicAccountCBClick(Sender: TObject);
Expand All @@ -356,7 +356,7 @@ class procedure TAccountsForm.ShowAccounts(parentWindow: HWND; IniPath, Settings
AccountsForm.IniPath := IniPath;
AccountsForm.SettingsIniFilePath := SettingsIniFilePath;
AccountsForm.CryptHandler := CryptHandler;
AccountsForm.SelectedAccount := '';
AccountsForm.SelectedAccount := EmptyWideStr;
{global settings}
AccountsForm.UseDLLFromPluginDir.Checked := GetPluginSettings(SettingsIniFilePath).LoadSSLDLLOnlyFromPluginDir;
AccountsForm.PreserveFileTimeCB.Checked := GetPluginSettings(SettingsIniFilePath).PreserveFileTime;
Expand Down Expand Up @@ -399,7 +399,7 @@ class procedure TAccountsForm.ShowAccounts(parentWindow: HWND; IniPath, Settings
AccountsForm.ShowInvitesFoldersCB.Checked := GetPluginSettings(SettingsIniFilePath).ShowInvitesFolders;

{global settings}
if Account <> '' then
if Account <> EmptyWideStr then
AccountsForm.SelectedAccount := Account;
RegisterHotKey(AccountsForm.Handle, 1, 0, VK_ESCAPE);
AccountsForm.OptionPages.ActivePageIndex := 0;
Expand Down
2 changes: 1 addition & 1 deletion AskEncryptionPasswords.pas
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class function TAskEncryptionPasswordsForm.AskPassword(ParentWindow: HWND; Accou
FileNamesPassword := AskEncryptionPasswordsForm.EncryptFilenamesPasswordEdit.Text;
end
else
FileNamesPassword := '';
FileNamesPassword := EmptyWideStr;

UseTCPwdMngr := AskEncryptionPasswordsForm.UseTCPwdMngrCB.Checked;
end;
Expand Down
2 changes: 1 addition & 1 deletion CMLJSON.pas
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ function fromJSON_OperationResult(JSON: WideString; var OperationStatus: integer
//Log(MSGTYPE_IMPORTANTERROR, 'Can''t parse server answer: ' + JSON); todo
exit(CLOUD_ERROR_UNKNOWN);
end;
if error = '' then
if error = EmptyWideStr then
error := ((ParserObj.Values['body'] as TJSONObject).Values[nodename] as TJSONObject).Values['error'].Value;
if error = 'exists' then
exit(CLOUD_ERROR_EXISTS);
Expand Down
28 changes: 14 additions & 14 deletions CloudMailRu.pas
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function TCloudMailRu.CloudResultToFsResult(CloudResult: integer; OperationStatu
end;
else
begin //что-то неизвестное
if (ErrorPrefix <> '') then
if (ErrorPrefix <> EmptyWideStr) then
Log(LogLevelError, MSGTYPE_IMPORTANTERROR, ErrorPrefix + self.ErrorCodeText(CloudResult) + ' Status: ' + OperationStatus.ToString());
exit(FS_FILE_WRITEERROR);
end;
Expand Down Expand Up @@ -268,7 +268,7 @@ constructor TCloudMailRu.Create(AccountSettings: TAccountSettings; split_file_si
self.Socks := TIdSocksInfo.Create();
self.Socks.Host := Proxy.Server;
self.Socks.Port := Proxy.Port;
if Proxy.user <> '' then
if Proxy.user <> EmptyWideStr then
begin
self.Socks.Authentication := saUsernamePassword;
self.Socks.Username := Proxy.user;
Expand Down Expand Up @@ -296,7 +296,7 @@ constructor TCloudMailRu.Create(AccountSettings: TAccountSettings; split_file_si
self.crypt_files := AccountSettings.encrypt_files_mode <> EncryptModeNone;
self.crypt_filenames := AccountSettings.encrypt_filenames;
self.shard_override := AccountSettings.shard_override;
if self.public_account and (self.PUBLIC_URL <> '') then
if self.public_account and (self.PUBLIC_URL <> EmptyWideStr) then
begin
self.public_link := self.PUBLIC_URL;
self.PUBLIC_URL := IncludeSlash(self.PUBLIC_URL);
Expand Down Expand Up @@ -692,7 +692,7 @@ function TCloudMailRu.getFileRegular(remotePath, localPath: WideString; LogError
MemoryStream: TMemoryStream;
begin
Result := FS_FILE_NOTSUPPORTED;
if self.Shard = '' then
if self.Shard = EmptyWideStr then
begin
Log(LogLevelDetail, MSGTYPE_DETAILS, 'Current shard is undefined, trying to get one');
if self.getShard(self.Shard) then
Expand Down Expand Up @@ -760,7 +760,7 @@ function TCloudMailRu.getFileShared(remotePath, localPath: WideString; LogErrors
FileStream: TFileStream;
begin
Result := FS_FILE_NOTFOUND;
if (self.public_shard = '') or (self.public_download_token = '') then
if (self.public_shard = EmptyWideStr) or (self.public_download_token = EmptyWideStr) then
exit;
try
FileStream := TFileStream.Create(GetUNCFilePath(localPath), fmCreate);
Expand Down Expand Up @@ -814,7 +814,7 @@ function TCloudMailRu.getShard(var Shard: WideString): Boolean;
OperationResult := fromJSON_OperationResult(JSON, OperationStatus);
case OperationResult of
CLOUD_OPERATION_OK:
Result := fromJSON_Shard(JSON, Shard) and (Shard <> '');
Result := fromJSON_Shard(JSON, Shard) and (Shard <> EmptyWideStr);
else
begin
Result := false;
Expand Down Expand Up @@ -853,9 +853,9 @@ function TCloudMailRu.getSharedToken(): Boolean;
Result := self.HTTPGetPage(self.PUBLIC_URL, PageContent, Progress);
if Result then
begin
PageContent := StringReplace(PageContent, #$A, '', [rfReplaceAll]); //так нам проще ковыряться в тексте
PageContent := StringReplace(PageContent, #$D, '', [rfReplaceAll]);
PageContent := StringReplace(PageContent, #9, '', [rfReplaceAll]);
PageContent := StringReplace(PageContent, #$A, EmptyWideStr, [rfReplaceAll]); //так нам проще ковыряться в тексте
PageContent := StringReplace(PageContent, #$D, EmptyWideStr, [rfReplaceAll]);
PageContent := StringReplace(PageContent, #9, EmptyWideStr, [rfReplaceAll]);
if not self.extractPublicTokenFromText(PageContent, self.public_download_token) then //refresh public download token
begin
Log(LogLevelError, MSGTYPE_IMPORTANTERROR, 'Can''t get public share download token');
Expand Down Expand Up @@ -905,7 +905,7 @@ procedure TCloudMailRu.HTTPInit(var HTTP: TIdHTTP; var SSL: TIdSSLIOHandlerSocke
begin
HTTP.ProxyParams.ProxyServer := self.Proxy.Server;
HTTP.ProxyParams.ProxyPort := self.Proxy.Port;
if self.Proxy.user <> '' then
if self.Proxy.user <> EmptyWideStr then
begin
HTTP.ProxyParams.BasicAuthentication := true;
HTTP.ProxyParams.ProxyUsername := self.Proxy.user;
Expand All @@ -923,7 +923,7 @@ procedure TCloudMailRu.HTTPInit(var HTTP: TIdHTTP; var SSL: TIdSSLIOHandlerSocke
HTTP.ReadTimeout := self.ConnectTimeout;
end;
HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17/TCWFX(' + PlatformX + ')';
HTTP.Request.Connection := '';
HTTP.Request.Connection := EmptyWideStr;
end;

procedure TCloudMailRu.HTTPDestroy(var HTTP: TIdHTTP; var SSL: TIdSSLIOHandlerSocketOpenSSL);
Expand Down Expand Up @@ -968,7 +968,7 @@ function TCloudMailRu.HTTPGetPage(URL: WideString; var Answer: WideString; var P
end;

end;
Result := Answer <> '';
Result := Answer <> EmptyWideStr;
end;

function TCloudMailRu.HTTPGetFile(URL: WideString; FileStream: TStream; LogErrors: Boolean): integer;
Expand Down Expand Up @@ -1056,7 +1056,7 @@ function TCloudMailRu.HTTPPostFile(URL: WideString; FileName: WideString; var An
FileStream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite);
Cipher.CryptStream(FileStream, MemoryStream);
MemoryStream.Position := 0;
PostData.AddFormField('file', 'application/octet-stream', '', MemoryStream, FileName);
PostData.AddFormField('file', 'application/octet-stream', EmptyWideStr, MemoryStream, FileName);
Result := self.HTTPPost(URL, PostData, ResultStream);
MemoryStream.free;
Cipher.free;
Expand Down Expand Up @@ -1335,7 +1335,7 @@ procedure TCloudMailRu.logUserSpaceInfo;
if (US.overquota) then
QuotaInfo := ' Warning: space quota exhausted!'
else
QuotaInfo := '';
QuotaInfo := EmptyWideStr;
Log(LogLevelFileOperation, MSGTYPE_DETAILS, 'Total space: ' + FormatSize(US.total) + ', used: ' + FormatSize(US.used) + ', free: ' + FormatSize(US.total - US.used) + '.' + QuotaInfo);
end else begin
Log(LogLevelDebug, MSGTYPE_IMPORTANTERROR, 'error: getting user space information for ' + self.user + '@' + self.domain);
Expand Down
2 changes: 1 addition & 1 deletion FileSplitter.pas
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unit FileSplitter;
unit FileSplitter;
interface

Expand Down
2 changes: 1 addition & 1 deletion InviteProperty.pas
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class function TInvitePropertyForm.ShowProperties(parentWindow: HWND; Item: TClo
InvitePropertyForm.InviteSizeLB.Caption := FormatSize(Item.size, TYPE_BYTES);
InvitePropertyForm.InviteTokenLB.Caption := Item.invite_token;
InvitePropertyForm.Caption := AccountName + ' invite: ' + Item.name;
if Item.home <> '' then //already mounted item
if Item.home <> EmptyWideStr then //already mounted item
begin
InvitePropertyForm.TokenLB.Caption := 'Mounted as:';
InvitePropertyForm.InviteTokenLB.Caption := Item.home;
Expand Down
20 changes: 10 additions & 10 deletions MRC_Helper.pas
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function Implode(S: TStringList; Delimiter: WideString): WideString;
var
iCount: integer;
begin
Result := '';
Result := EmptyWideStr;
if (S.Count = 0) then
exit;
for iCount := 0 to pred(S.Count) do
Expand Down Expand Up @@ -176,14 +176,14 @@ function ExtractRealPath(VirtualPath: WideString): TRealPath;
var
List: TStringList;
begin
Result.account := '';
Result.path := '';
Result.account := EmptyWideStr;
Result.path := EmptyWideStr;
Result.upDirItem := False;
Result.trashDir := False;
Result.sharedDir := False;
Result.invitesDir := False;

if VirtualPath = '' then
if VirtualPath = EmptyWideStr then
exit; //root
VirtualPath := Copy(VirtualPath, 2, Length(VirtualPath) - 1);

Expand Down Expand Up @@ -222,7 +222,7 @@ function ExtractRealPath(VirtualPath: WideString): TRealPath;
//проверка, находится ли путь внутри аккаунта. ignoreVirtual - не считать виртуальные каталоги облачными
function inAccount(path: TRealPath; ignoreVirtual: boolean = true): boolean;
begin
Result := path.account <> '';
Result := path.account <> EmptyWideStr;
if Result and ignoreVirtual then
Result := not(path.trashDir or path.sharedDir or path.invitesDir);
end;
Expand Down Expand Up @@ -318,7 +318,7 @@ function UrlEncode(URL: WideString): WideString;
UTF8: UTF8String;
begin
UTF8 := UTF8String(URL);
Result := '';
Result := EmptyWideStr;
for I := 1 to Length(UTF8) do
if UTF8[I] in ['a' .. 'z', 'A' .. 'Z', '/', '_', '-', '.', '0' .. '9'] then
Result := Result + WideString(UTF8[I])
Expand Down Expand Up @@ -430,7 +430,7 @@ function ExtractUniversalFileExt(const FileName: string): string;
if (I >= 0) and (FileName.Chars[I] = '.') then
Result := FileName.Substring(I)
else
Result := '';
Result := EmptyWideStr;
end;

function ChangePathFileName(const FilePath, NewFileName: WideString): WideString;
Expand Down Expand Up @@ -459,7 +459,7 @@ function GetWord(command: WideString; WordIndex: integer = 0): WideString;
var
Exploded: TStringList;
begin
Result := '';
Result := EmptyWideStr;
Exploded := Explode(command, ' ');
if Exploded.Count = 0 then
exit;
Expand Down Expand Up @@ -512,7 +512,7 @@ function PathToUrl(path: WideString; RestrictEmptyUrl: boolean = true; DoUrlEnco
if DoUrlEncode then
Result := UrlEncode(Result);

if (Result = '') and RestrictEmptyUrl then
if (Result = EmptyWideStr) and RestrictEmptyUrl then
Result := '/';
end;

Expand Down Expand Up @@ -631,7 +631,7 @@ function LoadPluginIcon(const path: WideString; identifier: WideString): Hicon;
function RetryAttemptsToString(Attempt: integer): WideString;
begin
if Attempt < 0 then
exit('')
exit(EmptyWideStr)
else
exit(' of ' + Attempt.ToString);
end;
Expand Down
1 change: 0 additions & 1 deletion MailRuCloud.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,6 @@ begin
ProxySettings := GetPluginSettings(SettingsIniFilePath).Proxy;

PasswordManager.GetProxyPassword(ProxySettings);
//GetProxyPasswordNow(ProxySettings, @LogHandle, @CryptHandle);

if ProxySettings.use_tc_password_manager then
SetPluginSettingsValue(SettingsIniFilePath, 'ProxyTCPwdMngr', true);
Expand Down
6 changes: 1 addition & 5 deletions RemoteProperty.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,6 @@ object PropertyForm: TPropertyForm
object DescriptionTS: TTabSheet
Caption = 'Description'
ImageIndex = 2
ExplicitLeft = 0
ExplicitTop = 0
ExplicitWidth = 0
ExplicitHeight = 0
DesignSize = (
828
255)
Expand Down Expand Up @@ -293,7 +289,7 @@ object PropertyForm: TPropertyForm
Left = 740
Top = 147
Bitmap = {
494C010104008C00D40020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
494C010104008C00D80020002000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600
0000000000003600000028000000800000004000000001002000000000000080
0000000000000000000000000000000000000000000000000000000000000000
0000000000000000000000000000000000000000000000000000000000000000
Expand Down
Loading

0 comments on commit 99c122f

Please sign in to comment.