📄 mailbox.pas
字号:
if mbox.Unlocked and (mbox.Password <> '') then
actMailboxPasswordProtect.Caption := _('Remove password protection ...')
else actMailboxPasswordProtect.Caption := _('Password protect ...');
end
else actMailboxPasswordProtect.Enabled := False; //disable it
end;
procedure TfrmMailbox.actAccountPreviewThisExecute(Sender: TObject);
begin
if (FSelectedAccount >= 0) then begin
if not frmTasks.TaskInProgress then
frmTasks.TaskClear;
frmTasks.TaskAdd(FSelectedAccount, [], ttFetchHeaders);
if frmMailbox.Profile.Config.ReadBool('frmTasks', 'showMe', True) then
frmTasks.Show;
end;
end;
procedure TfrmMailbox.actColumnsUnreadMessagesExecute(Sender: TObject);
begin
if coVisible in trMailbox.Header.Columns[1].Options then begin
trMailbox.Header.Columns[1].Options :=
trMailbox.Header.Columns[1].Options - [coVisible];
Profile.Config.WriteBool(Self.Name, 'unreadMessagesColumnVisible', False);
end
else begin
trMailbox.Header.Columns[1].Options :=
trMailbox.Header.Columns[1].Options + [coVisible];
Profile.Config.WriteBool(Self.Name, 'unreadMessagesColumnVisible', True);
end;
end;
procedure TfrmMailbox.actColumnsUnreadMessagesUpdate(Sender: TObject);
begin
if coVisible in trMailbox.Header.Columns[1].Options then
actColumnsUnreadMessages.Checked := True
else
actColumnsUnreadMessages.Checked := False;
end;
procedure TfrmMailbox.actColumnsTotalMessagesExecute(Sender: TObject);
begin
if coVisible in trMailbox.Header.Columns[2].Options then begin
trMailbox.Header.Columns[2].Options :=
trMailbox.Header.Columns[2].Options - [coVisible];
Profile.Config.WriteBool(Self.Name, 'totalMessagesColumnVisible', False);
end
else begin
trMailbox.Header.Columns[2].Options :=
trMailbox.Header.Columns[2].Options + [coVisible];
Profile.Config.WriteBool(Self.Name, 'unreadMessagesColumnVisible', True);
end;
end;
procedure TfrmMailbox.actColumnsTotalMessagesUpdate(Sender: TObject);
begin
if coVisible in trMailbox.Header.Columns[2].Options then
actColumnsTotalMessages.Checked := True
else
actColumnsTotalMessages.Checked := False;
end;
procedure TfrmMailbox.actUsersManageExecute(Sender: TObject);
var i: Integer;
var oldUser: Integer;
begin
frmProfiles.Mode := imManage;
frmProfiles.ShowModal;
end;
procedure TfrmMailbox.actUsersSwitchExecute(Sender: TObject);
begin
frmProfiles.Mode := imSwitch;
frmProfiles.ShowModal;
end;
procedure TfrmMailbox.SetProfile(profileID: Integer);
var tmpStr: String;
var i: Integer;
begin
//lock old profile if needed
if Profile <> nil then begin
if Profile.Password <> '' then
Profile.Unlocked := False;
end;
Profile := nil;
FSelectedAccount := -1;
FSelectedMailbox := -1;
trMailbox.Clear;
frmMaillist.Clear;
if profileID >= 0 then begin
//save old Autocomplete list
if Profile <> nil then
FAutoCompleteList.SaveToFile(frmMailbox.Profile.UserHomeDir + '\AutoComplete.txt');
Profile := Profiles[profileID];
//load auto complete list
if FileExists(Profile.UserHomeDir + '\AutoComplete.txt') then
FAutoCompleteList.LoadFromFile(Profile.UserHomeDir + '\AutoComplete.txt');
defaultExpanded := False;
//try to unlock the profile if it is password protected
unlockProfile;
//free mailbox timers
for i := 0 to FtmrList.Count - 1 do
TTimer(FtmrList.Items[i]).Free;
FtmrList.Clear;
//create mailbox timers
for i := 0 to Profile.Accounts.Count - 1 do begin
CreateCheckTimer;
UpdateCheckTimer(i);
end;
FShowProfileNode := Profile.Config.ReadBool(Self.Name, 'showProfileNode', True);
if FShowProfileNode then
trMailbox.RootNodeCount := 1
else
trMailbox.RootNodeCount := Profile.Accounts.Count;
frmMain.LoadUserSettings;
frmAddressBook.LoadUserSettings;
frmMailView.LoadUserSettings;
UseLanguage(frmMailbox.Profile.Config.ReadString('settings',
'language', GetCurrentLanguage));
frmAddressBook.LoadBook(Profile.Config.ReadInteger(frmAddressBook.Name,
'lastAddressBook',-1), Profile.Config.ReadBool(frmAddressBook.Name,
'wasPrivateBook', True));
frmAddressBook.ClearAddressBookMenues;
frmAddressBook.Books2Menues; //create menues for address books
//set visibility of unread/total columns
if Profile.Config.ReadBool(Self.Name, 'unreadMessagesColumnVisible', True) then
trMailbox.Header.Columns[1].Options :=
trMailbox.Header.Columns[1].Options + [coVisible]
else
trMailbox.Header.Columns[1].Options :=
trMailbox.Header.Columns[1].Options - [coVisible];
if Profile.Config.ReadBool(Self.Name, 'totalMessagesColumnVisible', True) then
trMailbox.Header.Columns[2].Options :=
trMailbox.Header.Columns[2].Options + [coVisible]
else
trMailbox.Header.Columns[2].Options :=
trMailbox.Header.Columns[2].Options - [coVisible];
frmMain.tbxThemes.Theme := Profile.Config.ReadString('settings',
'themeMenu', 'stripes');
SelectedTheme := Integer(frmThemeConfig.cmboxThemeList.Items.Objects[
Max(frmThemeConfig.cmboxThemeList.Items.IndexOf(Profile.Config.ReadString(
'settings', 'themeIcon', '')), 0)]);
LoadTheme(SelectedTheme, Profile.Config.ReadInteger('settings', 'themeSize', 1));
//write last profile
xmlIni.WriteString('general', 'defaultProfile', Profile.UserName);
//
frmMain.tray.MinimizeToTray := not Profile.Config.ReadBool(
'frmMain', 'dontMinimizeToSysTray', False);
try
if not Profile.Config.ReadBool(Self.Name, 'splash', False) then
frmSplash.Timer1.Interval := 1
except
end;
end;
end;
procedure TfrmMailbox.actUsersSwitchUpdate(Sender: TObject);
begin
if Profiles.Count >= 1 then
actUsersSwitch.Enabled := True
else
actUsersSwitch.Enabled := False;
end;
procedure TfrmMailbox.actAccountRenameExecute(Sender: TObject);
var tmpStr: String;
var acc: TAccount;
var node: PVirtualNode;
begin
node := trMailbox.GetFirstSelected;
acc := getAccountFromNode(node);
if acc <> nil then begin
tmpStr := MyInputBox(_('Rename account'),
Format(_('Please write new name for ''%s'' account in the field below.'),
[acc.AccountName]), '', '', notAllowedInFileName);
Trim(tmpStr);
if tmpStr = '' then exit;
if not frmNewAccountWizard.CheckAccount(tmpStr) then begin
//rename account
acc.Rename(tmpStr);
trMailbox.ResetNode(node);
end;
end;
end;
procedure TfrmMailbox.actAccountRenameUpdate(Sender: TObject);
begin
if FSelectedAccount >= 0 then
actAccountRename.Enabled := True
else
actAccountRename.Enabled := False;
end;
procedure TfrmMailbox.actAccountServerPropertiesExecute(Sender: TObject);
begin
frmAccountProperties.ShowModal;
end;
procedure TfrmMailbox.trMailboxPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType);
begin
TargetCanvas.Font.Style := Canvas.Font.Style - [fsBold];
with PTreeMailbox((Sender as TVirtualStringTree).GetNodeData(Node))^ do begin
case id of
cIDAccount:
begin
if TAccount(data).UnreadMessageCount > 0 then
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];
end;
cIDMailbox:
begin
if TMailbox(data).UnreadMessageCount > 0 then
TargetCanvas.Font.Style := TargetCanvas.Font.Style + [fsBold];
end
end;
end;
end;
procedure TfrmMailbox.actAccountFetchMessagesAllExecute(Sender: TObject);
var i: Integer;
begin
if not frmTasks.TaskInProgress then
frmTasks.TaskClear;
for i := 0 to Profile.Accounts.Count - 1 do begin
//add task to list & show task list
//fetch headers if Show message headers for incoming mail is set and
//... but only if message size is over is > 0
if Profile.Accounts[i].IncomingShowHeaders and
( not Profile.Accounts[i].IncomingShowHeadersLarger) then
frmTasks.TaskAdd(i, [], ttFetchHeaders)
else
frmTasks.TaskAdd(i, [], ttFetch);
end;
if frmMain.Visible and (frmMailbox.Profile.Config.ReadBool('frmTasks', 'showMe', True)) then
frmTasks.Show;
end;
procedure TfrmMailbox.actAccountFetchMessagesAllUpdate(Sender: TObject);
begin
if Profile.Accounts.Count > 0 then begin
actAccountFetchMessagesAll.Enabled := True;
frmMain.actTBFetch.Enabled := True;
end;
end;
procedure TfrmMailbox.actAccountServerPropertiesUpdate(Sender: TObject);
begin
if FSelectedAccount >= 0 then
actAccountServerProperties.Enabled := True
else
actAccountServerProperties.Enabled := False;
end;
procedure TfrmMailbox.actAccountSendThisUpdate(Sender: TObject);
var mbox: TMailbox;
var acc: TAccount;
begin
mbox := getMailboxFromNode(trMailbox.GetFirstSelected);
//fetch this menu can be enabled if account or mailbox is selected
if mbox = nil then acc := getAccountFromNode(trMailbox.GetFirstSelected);
if ((mbox <> nil) or (acc <> nil)) and (Profile.Accounts[FSelectedAccount].
Mailboxes[Integer(mboxUnsent) - 1].TotalMessageCount > 0) then begin
actAccountSendThis.Enabled := True;
end
else begin
actAccountSendThis.Enabled := False;
end;
end;
procedure TfrmMailbox.actAccountSendThisExecute(Sender: TObject);
var arr: array of Integer;
var mbox: TMailbox;
var i, c: Integer;
var descr: TMsgDescription;
begin
//build list of messages which needs to be sent
mbox := nil;
mbox := frmMailbox.getMailbox(frmMailbox.SelectedAccount, Integer(mboxUnsent) - 1);
if mbox = nil then exit;
SetLength(arr, mbox.LastMessageIndex);
c := 0;
for i := 0 to High(arr) do begin
descr := mbox.GetMessageDescription(i);
if not descr.deleted then begin
arr[c] := i;
Inc(c);
end;
end;
if not frmTasks.TaskInProgress then
frmTasks.TaskClear;
SetLength(arr, c);
frmTasks.TaskAdd(FSelectedAccount, arr, ttSend);
if frmMailbox.Profile.Config.ReadBool('frmTasks', 'showMe', True) then
frmTasks.Show;
end;
procedure TfrmMailbox.actUsersManageUpdate(Sender: TObject);
begin
(*if Profile.UserName = xmlIni.ReadString('general','defaultProfile','') then
actUsersManage.Enabled:=True
else
actUsersManage.Enabled:=False;*)
end;
procedure TfrmMailbox.actAccountRefreshTotExecute(Sender: TObject);
begin
refreshTotals(FSelectedAccount);
end;
procedure TfrmMailbox.refreshTotals(accountNo: Integer);
var i: Integer;
var tot, un: Integer;
begin
tot := 0; un := 0;
for i := 0 to Profile.Accounts[accountNo].Mailboxes.Count - 1 do begin
tot := tot + Profile.Accounts[accountNo].Mailboxes[i].TotalMessageCount;
un := un + Profile.Accounts[accountNo].Mailboxes[i].UnreadMessageCount;
end;
Profile.Accounts[accountNo].TotalMessageCount := tot;
Profile.Accounts[accountNo].UnreadMessageCount := un;
trMailbox.Refresh;
end;
procedure TfrmMailbox.actAccountRefreshTotUpdate(Sender: TObject);
begin
if FSelectedAccount >= 0 then
actAccountRefreshTot.Enabled := True
else
actAccountRefreshTot.Enabled := False;
end;
procedure TfrmMailbox.FormResize(Sender: TObject);
var i: Integer;
begin
if Profile = nil then exit;
//read sizes and positions maillist columns
for i := 0 to trMailbox.Header.Columns.Count - 1 do begin
trMailbox.Header.Columns[i].Width :=
Trunc(Self.Width * (frmMailbox.Profile.Config.ReadInteger(
Self.Name, Format('mailboxColumnWidth_%s', [IntToHex(i, 2)]), 0) / 10000));
trMailbox.Header.Columns[i].Position :=
frmMailbox.Profile.Config.ReadInteger(Self.Name, Format(
'mailboxColumnPosition_%s', [IntToHex(i, 2)]), trMailbox.Header.Columns[i].Position);
end;
end;
//this code trys to unlck the profile or exits application
//it is not written wery beautiful but I didn't want to
//use goto
procedure TfrmMailbox.unlockProfile;
function tryToUnlock(pwd: String): Boolean;
var i: Integer;
begin
Result := False;
if not Profile.Unlock(pwd) then begin
i := MessageDlg(_('Wrong password.' + #13#10 +
'- press Abort to close si.Mail' + #13#10 +
'- press Retry to enter password again' + #13#10 +
'- press OK to select another user'), mtError ,[mbOk, mbAbort, mbRetry], 0);
case i of
mrAbort: begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -