📄 adlibmdm.pas
字号:
SupportsCCITTBellToggle : Boolean;
SupportsSetSpeedNegotiation : Boolean;
SupportsSetTonePulse : Boolean;
SupportsBlindDial : Boolean;
SupportsSetV21V23 : Boolean;
SupportsModemDiagnostics : Boolean;
MaxDTERate : Integer;
MaxDCERate : Integer;
CurrentCountry : string;
MaximumPortSpeed : Integer;
PowerDelay : Integer;
ConfigDelay : Integer;
BaudRate : Integer;
Responses : TLmResponses;
Answer : TList;
Fax : TList;
FaxDetails : TLmFaxDetails;
Voice : TLmVoiceSettings;
Hangup : TList;
Init : TList;
Monitor : TList;
Settings : TLmModemSettings;
Hardware : TLmModemHardware;
BaudRates : TStringList;
Options : TStringList;
end;
TApdModemLoadState = (mlsGeneral, mlsResponses, mlsAnswer, mlsFax,
mlsFaxDetails, mlsVoice, mlsHangup, mlsInit,
mlsMonitor, mlsSettings, mlsHardware, mlsBaudRates,
mlsOptions, mlsISDN, mlsGSM, mlsNone);
TApdResponseLoadState = (rlsOK, rlsNegotiationProgress, rlsConnect,
rlsError, rlsNoCarrier, rlsNoDialTone, rlsBusy,
rlsNoAnswer, rlsRing, rlsVoiceView1, rlsVoiceView2,
rlsVoiceView3, rlsVoiceView4, rlsVoiceView5,
rlsVoiceView6, rlsVoiceView7, rlsVoiceView8,
rlsRingDuration, rlsRingBreak, rlsDate, rlsTime,
rlsNumber, rlsName, rlsMessage, rlsSingleRing,
rlsDoubleRing, rlsTripleRing, rlsVoice, rlsFax,
rlsData, rlsOther, rlsNone);
TApdVoiceLoadState = (vlsCloseHandset, vlsEnableCallerID,
vlsEnableDistinctiveRing, vlsGenerateDigit,
vlsHandsetPlayFormat, vlsHandsetRecordFormat,
vlsLineSetPlayFormat, vlsLineSetRecordFormat,
vlsOpenHandset, vlsSpeakerPhoneDisable,
vlsSpeakerPhoneEnable, vlsSpeakerPhoneMute,
vlsSpeakerPhoneSetVolumeGain, vlsSpeakerPhoneUnMute,
vlsStartPlay, vlsStartRecord, vlsStopPlay,
vlsStopRecord, vlsVoiceAnswer, vlsVoiceDialNumberSetup,
vlsVoiceToDataAnswer, vlsWaveDriver, vlsWaveFormat,
vlsNone);
TApdFaxLoadState = (flsClass1, flsClass2, flsClass2_0, flsClass1Answer,
flsClass2Answer, flsClass2_0Answer, flsNone);
{ loose wrapper around TLmModem so it can be easily referenced from a TStringList }
TLmModemClass = class
LmModem : TLmModem;
end;
{ loose wrapper around the TLmModemName record for use in our TStringLists }
TApdLmModemNameClass = class(TObject)
ModemName : string;
Manufacturer : string;
Model : string;
ModemFile : string;
end;
TApdLmModemCollectionItem = class(TCollectionItem)
private
FModemName : string;
FManufacturer : string;
FModel : string;
FModemFile : string;
published
property ModemName : string
read FModemName write FModemName;
property Manufacturer : string
read FManufacturer write FManufacturer;
property Model : string
read FModel write FModel;
property ModemFile : string
read FModemFile write FModemFile;
end;
TApdLmModemCollection = class(TCollection)
private
function GetItem(Index: Integer): TApdLmModemCollectionItem;
procedure SetItem(Index: Integer; const Value: TApdLmModemCollectionItem);
public
function Add : TApdLmModemCollectionItem;
property Items[Index: Integer] : TApdLmModemCollectionItem
read GetItem write SetItem; default;
end;
TApdLibModem = class (TComponent)
private
FLibModemPath : string;
FCompleteDbs : Boolean;
FReadingAttributes : Boolean;
FModemList : TList; { contains the modemcap records }
FModem : TList; { contains the modem details }
FCurIndex : Integer;
FModemLoadState : TApdModemLoadState;
FResponseLoadState : TApdResponseLoadState;
FVoiceLoadState : TApdVoiceLoadState;
FFaxLoadState : TApdFaxLoadState;
FCurModemIdx : Integer;
FOnLoadModemRecord : TApdLoadModemRecord;
FOnLoadModem : TApdLoadModem;
FLastSeq : Integer;
protected
procedure SetLibModemPath (v : string);
procedure LoadModemListAttribute (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadModemListElementBegin (oOwner : TObject;
sValue : DOMString);
procedure LoadModemListElementStart (oOwner : TObject;
sValue : DOMString);
procedure LoadModemListElementEnd (oOwner : TObject;
sValue : DOMString);
procedure AddCommand (CmdList : TList; sValue : DOMString);
procedure LoadModemGeneral (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadVoiceSettings (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadModemSettings (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadHardwareSettings (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadFaxClassDetails (FaxClass : TLmFaxClassDetails;
sName,
sValue : DOMString);
procedure LoadFaxDetails (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadModemResponses (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadModemAttribute (oOwner : TObject;
sName,
sValue : DOMString;
bSpecified : Boolean);
procedure LoadModemBeginElement (oOwner : TObject;
sValue : DOMString);
procedure CharData (oOwner : TObject; sValue : DOMString);
procedure LoadModemElementEnd (oOwner : TObject;
sValue : DOMString);
function GetXMLInteger (Value : string; Default : Integer) : Integer;
function GetXMLBoolean (Value : string; Default : Boolean) : Boolean;
procedure LoadModemList;
procedure FreeModemList;
function CreateModem : PLmModem;
procedure FreeModemEntry (Value : Integer);
procedure FreeModem;
procedure LoadModem (FileName : string; Append : Boolean);
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
{ loads a specific modem detail structure from modemcap, shows }
{ a dialog when appropriate }
function SelectModem(var ModemFile, ModemManufacturer, ModemName: string;
var LmModem : TLmModem) : Boolean;
{ returns True if the specified modem is in modemcap }
function IsModemValid(ModemFile, ModemName : string) : Boolean; {!!.04}
{ these methods manage the modem detail files }
{ create a new modem detail file with appropriate headers }
function CreateNewDetailFile(const ModemDetailFile : string) : Integer;
{ adds a modem to the modem detail file }
function AddModem(const ModemDetailFile : string; Modem : TLmModem) : Integer;
{ deletes a modem from the modem detail file }
function DeleteModem(const ModemDetailFile, ModemName : string) : Integer;
{ retrieves a specific modem from the modem detail file }
function GetModem(const ModemDetailFile, ModemName : string;
var Modem : TLmModem) : Integer;
{ retrieves all modems from a modem detail file }
function GetModems(const ModemDetailFile : string) : TStringList;
{ these methods manage the modemcap index }
{ add a modem record to modemcap }
function AddModemRecord(ModemRecord : TLmModemName) : Integer;
{ delete a modem record from modemcap }
function DeleteModemRecord(ModemRecord : TLmModemName) : Integer;
{ retrieves all modem records from modemcap }
function GetModemRecords : TApdLmModemCollection;
{ the last modem detail loaded }
property Modem : TList read FModem write FModem;
published
property LibModemPath : string read FLibModemPath write SetLibModemPath;
property CompleteDbs : Boolean read FCompleteDbs;
property OnLoadModemRecord : TApdLoadModemRecord
read FOnLoadModemRecord write FOnLoadModemRecord;
property OnLoadModem : TApdLoadModem
read FOnLoadModem write FOnLoadModem;
end;
{ the modem selection dialog }
TApdModemSelectionDialog = class(TForm)
btnOK: TButton;
btnCancel: TButton;
cbxManufacturer: TComboBox;
cbxName: TComboBox;
lblText: TLabel;
lblManufacturer: TLabel;
lblModemName: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure cbxManufacturerSelect(Sender: TObject);
procedure btnOKClick(Sender: TObject);
procedure cbxNameChange(Sender: TObject);
private
{ Private declarations }
Activated : Boolean; {!!.02}
ModemList : TApdLibModem;
AvailableModems : TStringList;
OldOnLoadModem : TApdLoadModem;
OldOnLoadModemRecord : TApdLoadModemRecord;
procedure LoadModemEvent (ModemName, Manufacturer, Model : string;
var CanLoad : Boolean);
procedure LoadModemRecordEvent (ModemName, Manufacturer, Model, ModemFile : string;
var CanLoad : Boolean);
public
{ Public declarations }
LmModem : TLmModem;
SelectedModemName,
SelectedModemManufacturer,
SelectedModemFile : string;
end;
implementation
{$R *.dfm}
uses
{$IFDEF TRIALRUN}
{$I TRIAL08.INC}
{$ENDIF}
AdXLbMdm;
{$IFDEF TRIALRUN}
{$I TRIAL03.INC}
{$I TRIAL01.INC}
{$ENDIF}
{ TApdLibModem }
constructor TApdLibModem.Create (AOwner : TComponent);
{$IFDEF TRIALRUN}
{$I TRIAL04.INC}
{$ENDIF}
begin
inherited Create (AOwner);
{$IFDEF TRIALRUN}
TC;
{$ENDIF}
FLibModemPath := '/etc/modemcap';
FCompleteDbs := False;
FReadingAttributes := False;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -