Rev 2 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2 | Rev 5 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | library MakeCall; |
1 | library MakeCall; |
2 | 2 | ||
3 | uses |
3 | uses |
4 | SysUtils, |
4 | SysUtils, |
- | 5 | AnsiStrings, |
|
5 | hbTAPI; |
6 | hbTAPI, |
- | 7 | dialogs; |
|
6 | 8 | ||
7 | {$R *.res} |
9 | {$R *.res} |
8 | 10 | ||
9 | function GetTapiDevices(buf: PAnsiChar): integer; stdcall; |
11 | function GetTapiDevicesA(buf: PAnsiChar): integer; stdcall; |
10 | var |
12 | var |
11 | mTapiLine: TTapiLine; |
13 | mTapiLine: ThbTapiLine; |
12 | len: Integer; |
14 | len: Integer; |
13 | s: string; |
15 | s: AnsiString; |
14 | begin |
16 | begin |
15 | mTapiLine := TTapiLine.Create(nil); |
17 | mTapiLine := ThbTapiLine.Create(nil); |
16 | try |
18 | try |
17 | try |
19 | try |
18 | mTapiLine.Active := false; |
20 | mTapiLine.Active := false; |
19 | s := mTapiLine.DeviceList.Text; |
21 | s := AnsiString(mTapiLine.DeviceList.Text); |
20 | len := Length(s); |
22 | len := (Length(s)+1{NUL}) * SizeOf(AnsiChar); |
21 | if buf <> nil then |
23 | if buf <> nil then |
22 | begin |
24 | begin |
23 | FillChar(buf^, len+1{NUL}, 0); |
25 | FillChar(buf^, len, 0); |
- | 26 | AnsiStrings.StrPCopy(buf, s); |
|
- | 27 | end; |
|
- | 28 | result := len; |
|
- | 29 | except |
|
- | 30 | result := -1; |
|
- | 31 | end; |
|
- | 32 | finally |
|
- | 33 | FreeAndNil(mTapiLine); |
|
- | 34 | end; |
|
- | 35 | end; |
|
- | 36 | ||
- | 37 | function GetTapiDevicesW(buf: PWideChar): integer; stdcall; |
|
- | 38 | var |
|
- | 39 | mTapiLine: ThbTapiLine; |
|
- | 40 | len: Integer; |
|
- | 41 | s: WideString; |
|
- | 42 | begin |
|
- | 43 | mTapiLine := ThbTapiLine.Create(nil); |
|
- | 44 | try |
|
- | 45 | try |
|
- | 46 | mTapiLine.Active := false; |
|
- | 47 | s := WideString(mTapiLine.DeviceList.Text); |
|
- | 48 | len := (Length(s)+1{NUL}) * SizeOf(WideChar); |
|
- | 49 | if buf <> nil then |
|
- | 50 | begin |
|
- | 51 | FillChar(buf^, len, 0); |
|
24 | StrPCopy(buf, s); |
52 | StrPCopy(buf, s); |
25 | result := 0; |
- | |
26 | end; |
53 | end; |
27 | result := len+1{NUL}; |
54 | result := len; |
28 | except |
55 | except |
29 | result := -1; |
56 | result := -1; |
30 | end; |
57 | end; |
31 | finally |
58 | finally |
32 | FreeAndNil(mTapiLine); |
59 | FreeAndNil(mTapiLine); |
33 | end; |
60 | end; |
34 | end; |
61 | end; |
35 | 62 | ||
36 | function Call(phoneNumber: PAnsiChar; deviceId: integer): integer; stdcall; |
63 | function MakeCallA(phoneNumber: PAnsiChar; deviceId: integer): integer; stdcall; |
- | 64 | var |
|
- | 65 | mTapiLine: ThbTapiLine; |
|
- | 66 | sPhoneNumber: AnsiString; |
|
- | 67 | begin |
|
- | 68 | mTapiLine := ThbTapiLine.Create(nil); |
|
- | 69 | try |
|
- | 70 | mTapiLine.Active := false; |
|
- | 71 | mTapiLine.CallParams.Flags := 0; |
|
- | 72 | mTapiLine.DeviceID := deviceId; |
|
- | 73 | mTapiLine.Active := true; |
|
- | 74 | if not mTapiLine.Active then |
|
- | 75 | begin |
|
- | 76 | // Usually "TAPI device not available" |
|
- | 77 | result := -1; |
|
- | 78 | exit; |
|
- | 79 | end; |
|
- | 80 | try |
|
- | 81 | sPhoneNumber := phoneNumber; |
|
- | 82 | mTapiLine.MakeCall(String(sPhoneNumber)); |
|
- | 83 | except |
|
- | 84 | // This can tappen when the headset is active, so the line is busy |
|
- | 85 | result := -2; |
|
- | 86 | exit; |
|
- | 87 | end; |
|
- | 88 | result := 0; |
|
- | 89 | finally |
|
- | 90 | FreeAndNil(mTapiLine); |
|
- | 91 | end; |
|
- | 92 | end; |
|
- | 93 | ||
- | 94 | {$IFDEF UNICODE} |
|
- | 95 | function MakeCallW(phoneNumber: PWideChar; deviceId: integer): integer; stdcall; |
|
37 | var |
96 | var |
38 | mTapiLine: TTapiLine; |
97 | mTapiLine: ThbTapiLine; |
- | 98 | sPhoneNumber: WideString; |
|
39 | begin |
99 | begin |
40 | mTapiLine := TTapiLine.Create(nil); |
100 | mTapiLine := ThbTapiLine.Create(nil); |
41 | try |
101 | try |
42 | mTapiLine.Active := false; |
102 | mTapiLine.Active := false; |
43 | mTapiLine.CallParams.Flags := 0; |
103 | mTapiLine.CallParams.Flags := 0; |
44 | mTapiLine.DeviceID := deviceId; |
104 | mTapiLine.DeviceID := deviceId; |
45 | mTapiLine.Active := true; |
105 | mTapiLine.Active := true; |
Line 48... | Line 108... | ||
48 | // Usually "TAPI device not available" |
108 | // Usually "TAPI device not available" |
49 | result := -1; |
109 | result := -1; |
50 | exit; |
110 | exit; |
51 | end; |
111 | end; |
52 | try |
112 | try |
- | 113 | sPhoneNumber := phoneNumber; |
|
53 | mTapiLine.MakeCall(AnsiString(phoneNumber)); |
114 | mTapiLine.MakeCall(String(sPhoneNumber)); |
54 | except |
115 | except |
55 | // This can tappen when the headset is active, so the line is busy |
116 | // This can tappen when the headset is active, so the line is busy |
56 | result := -2; |
117 | result := -2; |
57 | exit; |
118 | exit; |
58 | end; |
119 | end; |
59 | result := 0; |
120 | result := 0; |
60 | finally |
121 | finally |
61 | FreeAndNil(mTapiLine); |
122 | FreeAndNil(mTapiLine); |
62 | end; |
123 | end; |
63 | end; |
124 | end; |
- | 125 | {$ELSE} |
|
- | 126 | function MakeCallW(phoneNumber: PWideChar; deviceId: integer): integer; stdcall; |
|
- | 127 | var |
|
- | 128 | wst: WideString; |
|
- | 129 | ast: AnsiString; |
|
- | 130 | begin |
|
- | 131 | wst := WideString(phoneNumber); |
|
- | 132 | ast := AnsiString(wst); |
|
- | 133 | result := MakeCallA(PAnsiChar(ast), deviceId); |
|
- | 134 | end; |
|
- | 135 | {$ENDIF} |
|
64 | 136 | ||
65 | exports |
137 | exports |
- | 138 | MakeCallA, |
|
66 | Call name 'MakeCall', |
139 | MakeCallW, |
- | 140 | GetTapiDevicesA, |
|
67 | GetTapiDevices; |
141 | GetTapiDevicesW; |
68 | 142 | ||
69 | begin |
143 | begin |
70 | end. |
144 | end. |