1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
|
-
|
|
!
-
|
-
|
!
|
#module
#deffunc toggle_button str v1, var v2
#uselib "user32"
#func SetWindowLong "SetWindowLongA" int, int, int
chkbox v1, v2
SetWindowLong objinfo (stat, 2), -16, $50001003
return
#uselib "kernel32.dll"
#func __saveini "WritePrivateProfileStringA" sptr,sptr,sptr,sptr
#func __loadini "GetPrivateProfileStringA" sptr,sptr,sptr,var,int,sptr
#deffunc _saveini str appname,str keyname,str string
__saveini appname,keyname,string,iniinifile@
return
#deffunc _loadini str appname,str keyname,var rstring,int rstringsize
__loadini appname,keyname,"",rstring,rstringsize,iniinifile@
return
#define global fileini(%1) iniinifile@=%1
#define global saveini(%1,%2,%3) _saveini %1,%2,%3
#define global loadini(%1,%2,%3,%4=64) _loadini %1,%2,%3,%4
#global
#define DOUBLE_CHECK_MODE 2
#uselib "kernel32.dll" #func CreateMutexA "CreateMutexA" sptr,int,sptr
#func CloseHandle "CloseHandle" sptr
#func GetLastError "GetLastError"
#define ERROR_ALREADY_EXISTS 183
caption="2重起動防止機能サンプル"
if DOUBLE_CHECK_MODE!1 : title caption
switch DOUBLE_CHECK_MODE
case 2 : goto *mutexobj : swbreak default : dialog "不正な値です",1
swend
end
*mutexobj
CreateMutexA 0,0,caption
mutex_handle=stat
GetLastError
if stat=ERROR_ALREADY_EXISTS {
end
}
onexit *mutex_end goto *go
stop
*mutex_end
if mutex_handle!0 : CloseHandle mutex_handle
end
*go
#define WM_ACTIVATE 6
#define ctype LOWORD(%1) ((%1)&0xFFFF)
#uselib "user32"
#cfunc GetWindowLong "GetWindowLongA" int, int
#func SetWindowLong "SetWindowLongA" int, int, int
#define CLSID_IaxClient "{D87BE747-157C-49BD-A392-A68B75A54947}"
#define CLDID_IaxClientEvent "{940F9DBC-D92D-434E-9A2C-B78A61AE0BDA}"
bgscr 3,320,240,2
bgscr 2,320,240,2
bgscr 1,320,240,2
screen 0,320,200,1,ginfo(0),ginfo(1)
cls 1
title "HSPIAX2 Softphone"
cmdline = dir_cmdline
if cmdline != "" : dialog cmdline,0
axobj iax, CLSID_IaxClient ,0,0
comevent iax_event, iax, CLDID_IaxClientEvent, *event
sdim PhoneNumber,32
sdim UserID,32
sdim Password,32
sdim HostName,32
sdim CLIIDName,32
sdim CLIIDNum,32
sdim cfgAGC,1
sdim cfgNoiseReduce,1
sdim cfgEchoCancel,1
sdim cfgAAGC,1
sdim cfgCN,1
fileini ".\\config.ini"
gosub *ConfigLoadini
gosub *UpdateVariables
gosub *form
gosub *jump1
*main
stop
*UpdateVariables
iax ("Debug") = 0
iax ("UserID") = UserID
iax ("Password") = Password
iax ("PhoneNumber") = PhoneNumber
iax ("HostName") = HostName
iax -> "SetCLIID" CLIIDName, CLIIDNum
iax -> "ApplyFilter" AGC, NoiseReduce, 0, AAGC, CN
return
*jump1
iax -> "initIAX"
return
*jump2
gosub *UpdateVariables
iax -> "SelectLine" 0
iax -> "HangUp"
iax -> "silencethreshold" "-99"
iax -> "Codec" 2 iax -> "Dial"
stop
*jump3
iax -> "SelectLine" 0
iax -> "Hangup"
stop
*jump4
iax -> "Shutdown"
end
*jump5
iax -> "AudioWizard"
iax -> "AboutBox"
stop
*register
masterpos_x = ginfo(4) masterpos_y = ginfo(5) gsel 1,2
screen 1,320,240,,masterpos_x,masterpos_y
title "Server Registration"
pos 10,10
mes "UserID"
mes "Password"
mes "HostName"
mes "CLIIDName"
mes "CLIIDNum"
pos 100,10
input UserID,200,20
input Password,200,20
input HostName,200,20
input CLIIDName,200,20
input CLIIDNum,200,20
button gosub "OK",*j1
stop
*j1
gosub *UpdateVariables
gosub *ConfigSaveini
iax -> "Register"
gsel 1,-1
return
*configure
masterpos_x = ginfo(4) masterpos_y = ginfo(5) gsel 2,2
screen 2,320,240,,masterpos_x,masterpos_y
title "Codec Configuration"
pos 10,10
chkbox "ulaw",ulaw
sendmsg objinfo (stat, 2), $F4, $9
ulaw_sel = stat
chkbox "GSM",GSM
sendmsg objinfo (stat, 2), $F4, $9
GSM_sel = stat
chkbox "ilbc",ilbc
sendmsg objinfo (stat, 2), $F4, $9
ilbc_sel = stat
chkbox "speex",speex
sendmsg objinfo (stat, 2), $F4, $9
speex_sel = stat
chkbox "alaw",alaw
sendmsg objinfo (stat, 2), $F4, $9
alaw_sel = stat
chkbox "g729",g729
sendmsg objinfo (stat, 2), $F4, $9
g729_sel = stat
button gosub "OK",*j2
stop
*j2
if ck1_sel = 1 {
mes "check button 1 selected"
} else {
mes "check button 2 selected"
}
gosub *ConfigSaveini
gosub *UpdateVariables
gsel 2,-1
return
*Applyfilter
masterpos_x = ginfo(4) masterpos_y = ginfo(5) gsel 3,2
screen 3,320,240,,masterpos_x,masterpos_y
title "Voice filter"
pos 10,10
objsize 120, 20
chkbox "AGC",AGC
chkbox "NoiseReduce",NoiseReduce
chkbox "EchoCancel",EchoCancel
chkbox "AAGC",AAGC
chkbox "CN",CN
button gosub "OK",*j3
stop
*j3
gosub *ConfigSaveini
gosub *UpdateVariables
gsel 3,-1
return
*ConfigLoadini
loadini "default","PhoneNumber",PhoneNumber
loadini "default","UserID",UserID
loadini "default","Password",Password
loadini "default","HostName",HostName
loadini "default","CLIIDName",CLIIDName
loadini "default","CLIIDNum",CLIIDNum
loadini "default","AGC",cfgAGC
loadini "default","NoiseReduce",cfgNoiseReduce
loadini "default","EchoCancel",cfgEchoCancel
loadini "default","AAGC",cfgAAGC
loadini "default","CN",cfgCN
AGC = int(cfgAGC)
NoiseReduce = int(cfgNoiseReduce)
EchoCancel = int(cfgEchoCancel)
AAGC = int(cfgAAGC)
CN = int(cfgCN)
return
*ConfigSaveini
saveini "default","PhoneNumber",PhoneNumber
saveini "default","UserID",UserID
saveini "default","Password",Password
saveini "default","HostName",HostName
saveini "default","CLIIDName",CLIIDName
saveini "default","CLIIDNum",CLIIDNum
saveini "default","AGC", str(AGC)
saveini "default","NoiseReduce",str(NoiseReduce)
saveini "default","EchoCancel", str(EchoCancel)
saveini "default","AAGC", str(AAGC)
saveini "default","CN", str(CN)
return
*hold
iax -> "Hold"
stop
*transfer
iax -> "BlindTransfer" 2,fwdnum
stop
*event
gsel 0
dispid = comevdisp(iax_event)
if dispid == 1 : gosub *notify1
if dispid == 2 : gosub *notify2
if dispid == 3 : gosub *notify3
if dispid == 4 : gosub *notify4
if dispid == 5 : gosub *notify5
if dispid == 6 : gosub *notify6
if dispid == 7 : gosub *notify7
return
*notify1
comevarg levelsInput,iax_event,0,1
comevarg levelsOutput,iax_event,1,1
objprm STobj,"levels: " + levelsInput + " : " + levelsOutput
return
*notify2
objprm STobj,"GetAudioDevices"
return
*notify3
comevarg CallNo,iax_event,0,1
comevarg state,iax_event,1,1
comevarg sRemote,iax_event,2,1
comevarg sRemoteName,iax_event,3,1
comevarg sLocal,iax_event,4,1
comevarg sLocalContext,iax_event,5,1
objprm STobj,"StateEvents: " + CallNo + "!" + state +"!"+ sRemote + "!" + sRemoteName + "!" + sLocal + "!" + sLocalContext
return
*notify4
comevarg Message,iax_event,0,1
objprm STobj,"StateMessages: " + Message
return
*notify5
comevarg Message,iax_event,0,1
comevarg eventType,iax_event,1,1
objprm STobj,"Messages: " + Message + ":" + eventType
return
*notify6
comevarg Caller,iax_event,0,1
comevarg MsgCounts,iax_event,1,1
objprm VMobj,"VM: " + Caller + ":" + MsgCounts + "Msg(s)"
return
*notify7
comevarg RegId,iax_event,0,1
comevarg RegReply,iax_event,1,1
objprm STobj,"RegistrationEvent: " + RegId + ":" + RegReply
return
*form
objsize 100, 20
button "Register", *register
button "Codec Config", *configure
button "VoiceFilter", *Applyfilter
button "Shutdown", *jump4
button "AudioWizard", *jump5
pos 120,0
objsize 20,20
button "1",*dtmf1
pos 140,0
button "2",*dtmf2
pos 160,0
button "3",*dtmf3
pos 120,20
button "4",*dtmf4
pos 140,20
button "5",*dtmf5
pos 160,20
button "6",*dtmf6
pos 120,40
button "7",*dtmf7
pos 140,40
button "8",*dtmf8
pos 160,40
button "9",*dtmf9
pos 120,60
button "*",*dtmfAst
pos 140,60
button "0",*dtmf0
pos 160,60
button "#",*dtmfPound
objsize 20, 20
pos 120,100
button "D", *jump2
pos 140,100
button "H", *jump3
pos 160,100
button "HL", *hold
pos 180,100
button "T", *transfer
pos 40,120
mes "Call to"
pos 120,120
input PhoneNumber,200,20
PNobj = stat
pos 40,140
mes "Status"
pos 120,140
input Status1,200,20
STobj = stat
pos 40,160
mes "Voicemail"
pos 120,160
input VMStatus1,200,20
VMobj = stat
pos 200,40
objsize 20,20
pos 200,0
ActLine1 = 1
chkbox "", ActLine1
sendmsg objinfo (stat, 2), $F4, $9
chkbox "", ActLine2
sendmsg objinfo (stat, 2), $F4, $9
chkbox "", ActLine3
sendmsg objinfo (stat, 2), $F4, $9
chkbox "", ActLine4
sendmsg objinfo (stat, 2), $F4, $9
chkbox "", FwdSet
SetWindowLong objinfo (stat, 2), -16, $50000003 | $20
pos 220,0
objsize 100,20
DndLine1 = 1
toggle_button "Line1", Dndline1
toggle_button "Line2", Dndline2
toggle_button "Line3", Dndline3
toggle_button "Line4", Dndline4
pos 220,80
fwdnum = "0427013260"
input fwdnum
return
*dtmf1
iax -> "SendDTMF" "1"
stop
*dtmf2
iax -> "SendDTMF" "2"
stop
*dtmf3
iax -> "SendDTMF" "3"
stop
*dtmf4
iax -> "SendDTMF" "4"
stop
*dtmf5
iax -> "SendDTMF" "5"
stop
*dtmf6
iax -> "SendDTMF" "6"
stop
*dtmf7
iax -> "SendDTMF" "7"
stop
*dtmf8
iax -> "SendDTMF" "8"
stop
*dtmf9
iax -> "SendDTMF" "9"
stop
*dtmfAst
iax -> "SendDTMF" "*"
stop
*dtmf0
iax -> "SendDTMF" "0"
stop
*dtmfPound
iax -> "SendDTMF" "#"
stop
|