home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 11
/
Freelog011.iso
/
BestOf
/
PhoenixMail
/
Source
/
phoenix
/
FMOnline.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1999-02-20
|
8KB
|
254 lines
{*****************************************************************************
*
* FMOnline.pas - Fetch and send mails (12-August-1998)
*
* Copyright (c) 1998-99 Michael Haller
*
* Author: Michael Haller
* E-mail: michael@discountdrive.com
* Homepage: http://www.discountdrive.com/sunrise
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
*----------------------------------------------------------------------------
*
* Revision history:
*
* DATE REV DESCRIPTION
* ----------- --- ----------------------------------------------------------
*
*****************************************************************************}
unit FMOnline;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, LangSup, PXStuff, ExtCtrls, ShellAPI;
type
TOnlineForm = class(TForm)
Panel1: TPanel;
Notebook1: TNotebook;
Label1: TLabel;
Image3: TImage;
Button4: TButton;
Button7: TButton;
GroupBox3: TGroupBox;
Label2: TLabel;
Label6: TLabel;
Image4: TImage;
Button3: TButton;
Button5: TButton;
GroupBox4: TGroupBox;
Label7: TLabel;
Label5: TLabel;
Image5: TImage;
Label16: TLabel;
Button1: TButton;
Button6: TButton;
GroupBox5: TGroupBox;
Label17: TLabel;
Edit1: TEdit;
Label18: TLabel;
Image6: TImage;
GroupBox6: TGroupBox;
Button10: TButton;
Edit2: TEdit;
Button11: TButton;
Label20: TLabel;
Panel2: TPanel;
Label9: TLabel;
Label10: TLabel;
Label13: TLabel;
Label15: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Edit1KeyPress(Sender: TObject; var Key: Char);
procedure FormDestroy(Sender: TObject);
procedure Button5Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
CommandList: TStringList;
OnlineTyp: Byte;
procedure SetCancelOpportunitiesFalse;
procedure ShowStatusMessage;
procedure DialUpNetwork;
end;
var
OnlineForm: TOnlineForm;
implementation
{$R *.DFM}
uses
Main, TDOnline;
procedure TOnlineForm.SetCancelOpportunitiesFalse;
begin
MainForm.StatusBar1.Panels[2].Text := '';
MainForm.StatusBar1.Panels[3].Text := '';
MainForm.Label5.Caption := '';
MainForm.Label4.Caption := '';
MainForm.CancelOnlineOperation1.Enabled := False;
MainForm.SpeedButton12.Enabled := False;
end;
procedure TOnlineForm.ShowStatusMessage;
var
S1, S2: String;
begin
try
SetCancelOpportunitiesFalse;
Screen.Cursor := crDefault;
try if bDUNNormalQuit then MainForm.DialUp1.GoOffline; except end;
if MainForm.Terminating or ((not bAskToGoOffline) and (Abort)) then begin
MainForm.OnlineThreadCounter := 0;
MainForm.OnlineThreadTerminated := True;
Exit;
end;
PlaySound(sSoundFile3);
if bViewStatusAtEnd or bAskToGoOffline then begin
if AvailableMailCount > 0 then begin
MainForm.ListBox1.Items[58];
S1 := Format(MainForm.ListBox1.Items[59], [IntToStr(FetchedMailCount), IntToStr(AvailableMailCount)]);
end else S1 := MainForm.ListBox1.Items[60];
if SendMailCount = 1 then S2 := MainForm.ListBox1.Items[61] else
if SendMailCount > 1 then S2 := Format(MainForm.ListBox1.Items[62], [IntToStr(SendMailCount)]) else
S2 := MainForm.ListBox1.Items[63];
if OnlineTyp = 1 then Label7.Caption := S1;
if OnlineTyp = 2 then Label7.Caption := S2;
if OnlineTyp = 3 then Label7.Caption := S1+' '+S2;
if bAskToGoOffline then begin
Label6.Caption := Label9.Caption;
Label5.Visible := True;
Button5.Visible := True;
Button3.Caption := Label10.Caption;
end else begin
Label6.Caption := Label13.Caption;
Label5.Visible := False;
Button5.Visible := False;
Button3.Caption := Button4.Caption;
end;
NoteBook1.ActivePage := 'Offline';
MainForm.ShowPhoenixMail1Click(Self);
ShowModal;
end;
except end;
MainForm.OnlineThreadCounter := 0;
MainForm.OnlineThreadTerminated := True;
end;
procedure TOnlineForm.DialUpNetwork;
begin
Screen.Cursor := crDefault;
try
OnlineThread.Name := MainForm.ListBox1.Items[80];
if MainForm.DialUp1.PossibleConnections.IndexOf(sDUNConnection) <> -1 then
if MainForm.DialUp1.CurrentConnection = '' then begin //if offline
MainForm.DialUp1.ConnectTo := sDUNConnection;
MainForm.DialUp1.Password := sDUNPassword;
if bDUNAskForPassword then MainForm.DialUp1.Password := '';
MainForm.DialUp1.Username := sDUNUsername;
OnlineThread.AddToLog(1, 'Connecting to Dial Up Network...');
if MainForm.DialUp1.Password = '' then begin
Notebook1.ActivePage := 'DUN';
ActiveControl := Edit2;
MainForm.ShowPhoenixMail1Click(Self);
if ShowModal = mrCancel then begin
MainForm.DialUp1.GoOffline;
OnlineThread.ShowError(MainForm.ListBox1.Items[82]);
Exit;
end else MainForm.DialUp1.Password := Edit1.Text;
end;
MainForm.DialUp1.GoOnline;
repeat
Application.HandleMessage;
if Abort then begin MainForm.DialUp1.GoOffline; Exit; end;
until (MainForm.DialUp1.CurrentConnection <> '');
end;
except
on Error: Exception do begin
MainForm.DialUp1.GoOffline; OnlineThread.ShowError(Error.Message);
end;
end;
end;
procedure TOnlineForm.FormCreate(Sender: TObject);
procedure SetBitmapToImage(var S: TImage; I: Integer);
var
Bitmap: TBitmap;
begin
Bitmap := TBitmap.Create;
MainForm.ImageList3.GetBitmap(I, Bitmap);
S.Picture.Bitmap.Assign(Bitmap);
Bitmap.Free;
end;
begin
AttachLanguageToForm(Self);
if bOfficeFonts then Font.Name := sOfficeFontName;
GroupBox3.Caption := Label15.Caption;
Caption := 'Phoenix Mail - '+MainForm.ListBox1.Items[36];
if ColorScheme or LowColor then begin
SetBitmapToImage(Image3, 12);
SetBitmapToImage(Image4, 10);
SetBitmapToImage(Image5, 11);
Image3.Transparent := True;
Image4.Transparent := True;
Image5.Transparent := True;
Image6.Transparent := True;
end;
Image6.Picture.Bitmap.Assign(Image4.Picture.Bitmap);
Image3.Width := 28;
Image4.Width := 28;
Image5.Width := 28;
Image6.Width := 28;
Edit1.PasswordChar := '*';
Edit2.PasswordChar := '*';
CommandList := TStringList.Create;
end;
procedure TOnlineForm.Button7Click(Sender: TObject);
begin
if FileExists(sProtocolFile) then
ShellExecute(Handle, 'open', PChar(sProtocolFile), '', PChar(ExtractFilePath(sProtocolFile)), SW_SHOWNORMAL);
end;
procedure TOnlineForm.Edit1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then begin Key := #0; ModalResult := mrOK; end;
end;
procedure TOnlineForm.FormDestroy(Sender: TObject);
begin
CommandList.Free;
end;
procedure TOnlineForm.Button5Click(Sender: TObject);
begin
MainForm.DialUp1.GoOffline;
end;
initialization
OnlineForm := nil;
end.