-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSeInit.c
553 lines (472 loc) · 17.7 KB
/
SeInit.c
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
/*
* This file is part of the Seyon, Copyright (c) 1992-1993 by Muhammad M.
* Saggaf. All rights reserved.
*
* See the file COPYING (1-COPYING) or the manual page seyon(1) for a full
* statement of rights and permissions for this program.
*/
/* -*- Mode: C -*-
* SeInit.c --- Initialization routines
* Author : Muhammad M. Saggaf
* Created On : sometime in 1992
* Last Modified By: system admin
* Last Modified On: Fri Jun 4 16:17:39 1993
* Update Count : 8
* Status : Mostly OK, needs some cleaning up
*/
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
#include <X11/Xaw/Label.h>
#include <X11/Xaw/Dialog.h>
#include <signal.h>
#include <fcntl.h>
#include "seyon.h"
#include "SeDecl.h"
#include "version.h"
#ifndef HELPFILE
#define HELPFILE "/usr/lib/X11/seyon.help"
#endif
extern void TopAbout(),
TopHelp(),
TopSet(),
TopTransfer(),
TopMisc(),
SetNewlineTrMode(),
FunMessage();
extern void upload_acc_ok(),
setVal_action_ok(),
manual_dial_action_ok(),
divert_action_ok();
extern Boolean CvtStringToStringArray();
void HangupConfirm(),
ExecHangup(),
ExitConfirm(),
ExitAction(),
test();
Boolean inhibit_child = False;
Widget w_exit,
w_kill,
statusMessage;
Widget dialWidget, genericWidget;
pid_t w_child_pid = 0;
Pixmap progIcon;
#include "progIcon.h"
void
InitVariables(topLevel)
Widget topLevel;
{
char buffer[REG_BUF];
sprintf(captureFile, "%s/%s", expand_fname(qres.defaultDirectory, buffer),
qres.captureFile);
SetNewlineTrMode(qres.newlineTranslation);
}
void
SetIcon(topLevelWidget)
Widget topLevelWidget;
{
progIcon =
XCreateBitmapFromData(XtDisplay(topLevelWidget),
DefaultRootWindow(XtDisplay(topLevelWidget)),
progIcon_bits, progIcon_width,
progIcon_height);
XtVaSetValues(topLevelWidget, XtNiconPixmap, progIcon, NULL);
}
void
CreateCommandCenter()
{
void GetQuickKeyResources(),
GetValueByPopupOKAction(),
DispatchActionsCallback();
void TopShell();
void KillChildProc();
Widget mainBox,
menuBox,
statusBox,
messageBox,
quickKeyBox;
static Widget status[NUM_MDM_STAT];
static Atom wm_delete_window;
Dimension menuBoxWidth;
struct _quickKeyRes quickKeyRes;
Widget quickKeyW;
char qKBuf[REG_BUF];
int i, n = 0;
static XtActionsRec actionTable[] = {
{"UploadOk", upload_acc_ok},
{"SetValOk", setVal_action_ok},
{"ManualDialOk", manual_dial_action_ok},
{"DivertOk", divert_action_ok},
{"Exit", ExitAction},
{"GetValueByPopupOK", GetValueByPopupOKAction},
};
XtAppAddActions(XtWidgetToApplicationContext(topLevel), actionTable,
XtNumber(actionTable));
mainBox = SeAddPaned("mainBox", topLevel);
statusBox = AddBox("statusBox", mainBox);
messageBox = SeAddForm("messageBox", mainBox);
quickKeyBox = AddBox("quickKeyBox", mainBox);
menuBox = AddBox("menuBox", mainBox);
status[0] = SeAddToggle("dcd", statusBox, NULL);
status[1] = SeAddToggle("dtr", statusBox, NULL);
status[2] = SeAddToggle("dsr", statusBox, NULL);
status[3] = SeAddToggle("rts", statusBox, NULL);
status[4] = SeAddToggle("cts", statusBox, NULL);
status[5] = SeAddToggle("rng", statusBox, NULL);
statusMessage = SeAddLabel("message", messageBox);
AddButton("about", menuBox, TopAbout, NULL);
AddButton("help", menuBox, TopHelp, NULL);
AddButton("set", menuBox, TopSet, NULL);
genericWidget = dialWidget = AddButton("dial", menuBox, TopDial, NULL);
AddButton("transfer", menuBox, TopTransfer, NULL);
AddButton("shellCommand", menuBox, TopShell, NULL);
AddButton("misc", menuBox, TopMisc, NULL);
AddButton("hangup", menuBox, HangupConfirm, NULL);
w_exit = AddButton("exit", menuBox, ExitConfirm, NULL);
w_kill = AddButton("kill", menuBox, KillChildProc, NULL);
for (i = 0; i < MAX_SEQUICKKEYS; i++) {
sprintf(qKBuf, "quickKey%d", i+1);
GetQuickKeyResources(qKBuf, &quickKeyRes);
if (quickKeyRes.visible) {
n++;
quickKeyW =
AddButton(qKBuf, quickKeyBox, DispatchActionsCallback, NULL);
}
}
if (n == 0) XtDestroyWidget(quickKeyBox);
XtOverrideTranslations(topLevel,
XtParseTranslationTable("<Message>WM_PROTOCOLS: Exit()"));
/* Call UpdateStatusBox() before realizing the top-level widget so that
the status widget array in that function would be properly initialized
before the user is able to call hangup(), since the latter passes NULL
to UpdateStatusBox() */
UpdateStatusBox((XtPointer)status);
XtSetMappedWhenManaged(topLevel, False);
XtRealizeWidget(topLevel);
XtVaGetValues(menuBox, XtNwidth, &menuBoxWidth, NULL);
XtVaSetValues(statusBox, XtNwidth, menuBoxWidth, NULL);
if (n) XtVaSetValues(quickKeyBox, XtNwidth, menuBoxWidth, NULL);
/*
* (ideally one should not assume any fixed numbers, but this will do
* for now).
*
* width of message box = label width
* + 2*border width (2*1)
* + defaultDistance (right) (1)
* + horizDistance (left) (4)
*
* desired width of label = width of menu box
* - hSpace of menu box (2*4) (to align with buttons)
* - border with of label (2*1)
* = width of menu box - 10
*
* => width of message box = width of menu box - 10 + 7
* => width of message box < width of menu box
* => menu box width is the controlling factor in deciding the widnow
* width, as desired.
*/
XtVaSetValues(statusMessage, XtNresizable, True, NULL);
XtVaSetValues(statusMessage, XtNwidth, menuBoxWidth - 10, NULL);
XtVaSetValues(statusMessage, XtNresizable, False, NULL);
wm_delete_window = XInternAtom(XtDisplay(topLevel),
"WM_DELETE_WINDOW", False);
XSetWMProtocols(XtDisplay(topLevel), XtWindow(topLevel),
&wm_delete_window, 1);
}
void
TopAbout(parent)
Widget parent;
{
Widget popup,
mBox,
uBox,
lBox,
pic,
msg,
caption;
Pixmap pix;
Dimension width1,
width2;
char msgStr[LRG_BUF];
#include "authPic.h"
popup = SeAddPopup("about", parent);
mBox = SeAddPaned("mBox", popup);
uBox = SeAddBox("uBox", mBox);
lBox = SeAddBox("lBox", mBox);
msg = SeAddLabel("msg", uBox);
pic = SeAddLabel("pic", uBox);
caption = SeAddLabel("caption", uBox);
sprintf(msgStr, "%s %s rev. %s\n%s\n%s\n%s", "Seyon version", VERSION,
REVISION, "Copyright 1992-1993", "(c) Muhammad M. Saggaf",
"All rights reserved");
XtVaSetValues(msg, XtNlabel, msgStr, NULL);
pix = XCreateBitmapFromData(XtDisplay(pic),
DefaultRootWindow(XtDisplay(pic)),
authPic_bits, authPic_width,
authPic_height);
XtVaSetValues(pic, XtNbitmap, pix, NULL);
width1 = SeWidgetWidth(msg);
width2 = SeWidgetWidth(pic);
width1 = width1 > width2 ? width1 : width2;
width2 = SeWidgetWidth(caption);
width1 = width1 > width2 ? width1 : width2;
XtVaSetValues(msg, XtNwidth, width1, NULL);
XtVaSetValues(pic, XtNwidth, width1, NULL);
XtVaSetValues(caption, XtNwidth, width1, NULL);
SeAddButton("dismiss", lBox, DestroyShell);
XtPopupSpringLoaded(popup);
}
/*
* TopHelp: displays the help file.
*/
void
TopHelp(widget)
Widget widget;
{
Widget DoDisplayFile();
Widget displayPopup;
XtVaSetValues(widget, XtNsensitive, False, NULL);
displayPopup = DoDisplayFile(widget, qres.helpFile);
XtAddCallback(displayPopup, XtNdestroyCallback, SetSensitiveOn, widget);
PositionShell(displayPopup, widget, SHELLPOS_HWFH);
XtPopup(displayPopup, XtGrabNone);
}
void
ExecHangup()
{
MdmHangup();
SeyonMessage("Line Disconnected");
}
void
DoHangup(widget)
Widget widget;
{
DestroyShell(widget);
ExecHangup();
}
void
HangupConfirm(widget)
Widget widget;
{
Widget popup,
dialog;
ErrorIfBusy()
if (qres.hangupConfirm) {
popup = AddSimplePopup("hangup", widget);
dialog = SeAddDialog("dialog", popup);
XawDialogAddButton(dialog, "yes", DoHangup, (XtPointer) dialog);
XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
PopupCentered(popup, widget);
}
else
ExecHangup();
}
void
ExitNoHangup(widget)
Widget widget;
{
DestroyShell(widget);
s_exit(widget);
}
void
ExitHangup(widget)
Widget widget;
{
ExecHangup();
ExitNoHangup(widget);
}
void
ExitConfirm(widget)
Widget widget;
{
Widget popup,
dialog;
if (qres.exitConfirm && !qres.ignoreModemDCD && Online()) {
popup = AddSimplePopup("exit", widget);
dialog = SeAddDialog("dialog", popup);
XawDialogAddButton(dialog, "yes", ExitHangup, NULL);
XawDialogAddButton(dialog, "no", ExitNoHangup, NULL);
XawDialogAddButton(dialog, "cancel", DestroyShell, NULL);
PopupCentered(popup, widget);
}
else
s_exit();
}
void
ExitAction(widget)
Widget widget;
{
Boolean wExitButtonStatus;
/* Prevent the user from exiting the program by f.delete if exiting
is not permitted */
XtVaGetValues(w_exit, XtNsensitive, &wExitButtonStatus, NULL);
ReturnIfTrue(!wExitButtonStatus);
s_exit();
}
void
w_exit_up(w_exit_status)
Boolean w_exit_status;
{
XtVaSetValues(w_exit, XtNsensitive, w_exit_status, NULL);
}
void
SetKillButtonSens(killWidgetStatus)
Boolean killWidgetStatus;
{
XtVaSetValues(w_kill, XtNsensitive, killWidgetStatus, NULL);
w_exit_up(!killWidgetStatus);
}
void
w_kill_up(w_kill_status)
Boolean w_kill_status;
{
SetKillButtonSens(w_kill_status);
}
void
KillChildProc()
{
if (w_child_pid == 0) return;
if (kill(w_child_pid, SIGTERM) == 0) w_child_pid = 0;
}
void
GetQuickKeyResources(quickKeyName, quickKeyRes)
String quickKeyName;
struct _quickKeyRes *quickKeyRes;
{
#define offset(field) XtOffsetOf(struct _quickKeyRes, field)
static XtResource resources[] = {
{"visible", "Visible", XtRBoolean, sizeof(Boolean),
offset(visible), XtRImmediate, (XtPointer)False},
{"action", "Action", XtRString, sizeof(String),
offset(action), XtRString, (XtPointer)""},
};
#undef offset
XtGetSubresources(topLevel, (XtPointer)quickKeyRes, quickKeyName, "Command",
resources, XtNumber(resources), NULL, 0);
}
void
GetResources()
{
#define offset(field) XtOffsetOf(struct QueryResources, field)
static XtResource resources[] = {
{"modems", "Modems", XtRString, sizeof(String),
offset(modems), XtRString, (XtPointer)""},
{"script", "Script", XtRString, sizeof(String),
offset(script), XtRString, (XtPointer) NULL},
{"defaultBPS", "DefaultBPS", XtRString, sizeof(String),
offset(defaultBPS), XtRString, (XtPointer) "9600"},
{"defaultBits", "DefaultBits", XtRInt, sizeof(int),
offset(defaultBits), XtRImmediate, (XtPointer) 8},
{"defaultParity", "DefaultParity", XtRInt, sizeof(int),
offset(defaultParity), XtRImmediate, (XtPointer) 0},
{"defaultStopBits", "DefaultStopBits", XtRInt, sizeof(int),
offset(defaultStopBits), XtRImmediate, (XtPointer) 1},
{"stripHighBit", "StripHighBit", XtRBoolean, sizeof(Boolean),
offset(stripHighBit), XtRImmediate, (XtPointer) False},
{"backspaceTranslation", "BackspaceTranslation", XtRBoolean,
sizeof(Boolean), offset(backspaceTranslation), XtRImmediate,
(XtPointer) False},
{"metaKeyTranslation", "MetaKeyTranslation", XtRBoolean,
sizeof(Boolean), offset(metaKeyTranslation), XtRImmediate,
(XtPointer) True},
{"xonxoffFlowControl", "XonxoffFlowControl", XtRBoolean,
sizeof(Boolean), offset(xonxoffFlowControl), XtRImmediate,
(XtPointer) False},
{"rtsctsFlowControl", "RtsctsFlowControl", XtRBoolean,
sizeof(Boolean), offset(rtsctsFlowControl), XtRImmediate,
(XtPointer) False},
{"newlineTranslation", "NewlineTranslation", XtRString,
sizeof(String), offset(newlineTranslation), XtRImmediate,
(XtPointer) "cr"},
{"dialPrefix", "DialPrefix", XtRString, sizeof(String),
offset(dialPrefix), XtRString, (XtPointer) "ATDT"},
{"dialSuffix", "DialSuffix", XtRString, sizeof(String),
offset(dialSuffix), XtRString, (XtPointer) "^M"},
{"dialCancelString", "DialCancelString", XtRString, sizeof(String),
offset(dialCancelString), XtRString, (XtPointer) "^M"},
{"dialTimeOut", "DialTimeOut", XtRInt, sizeof(int),
offset(dialTimeOut), XtRImmediate, (XtPointer) 45},
{"dialDelay", "DialDelay", XtRInt, sizeof(int),
offset(dialDelay), XtRImmediate, (XtPointer) 10},
{"dialRepeat", "DialRepeat", XtRInt, sizeof(int),
offset(dialRepeat), XtRImmediate, (XtPointer) 5},
{"connectString", "ConnectString", XtRString, sizeof(String),
offset(connectString), XtRString, (XtPointer) "CONNECT"},
{"noConnectString1", "NoConnectString1", XtRString, sizeof(String),
offset(noConnectString[0]), XtRString, (XtPointer) "NO CARRIER"},
{"noConnectString2", "NoConnectString2", XtRString, sizeof(String),
offset(noConnectString[1]), XtRString, (XtPointer) "NO DIALTONE"},
{"noConnectString3", "NoConnectString3", XtRString, sizeof(String),
offset(noConnectString[2]), XtRString, (XtPointer) "BUSY"},
{"noConnectString4", "NoConnectString4", XtRString, sizeof(String),
offset(noConnectString[3]), XtRString, (XtPointer) "VOICE"},
{"hangupBeforeDial", "HangupBeforeDial", XtRBoolean, sizeof(Boolean),
offset(hangupBeforeDial), XtRImmediate, (XtPointer)True},
{"dialAutoStart", "DialAutoStart", XtRBoolean, sizeof(Boolean),
offset(dialAutoStart), XtRImmediate, (XtPointer)False},
{"dialDirFormat", "DialDirFormat", XtRString, sizeof(String),
offset(dialDirFormat), XtRString,
(XtPointer)"%-15s %-15s %6s %1c%1c%1c %1c%1c %s"},
{"defaultPhoneEntries", "DefaultPhoneEntries", XtRString, sizeof(String),
offset(defaultPhoneEntries), XtRString, (XtPointer)NULL},
{"startupAction", "StartupAction", XtRString, sizeof(String),
offset(startupAction), XtRString,
(XtPointer)"RunScript(startup);"},
{"postConnectAction", "PostConnectAction", XtRString, sizeof(String),
offset(postConnectAction), XtRString, (XtPointer)"Beep();"},
{"autoZmodem", "AutoZmodem", XtRBoolean, sizeof(Boolean),
offset(autoZmodem), XtRImmediate, (XtPointer)True},
{"autoZmodemAction", "AutoZmodemAction", XtRString, sizeof(String),
offset(autoZmodemAction), XtRString,
(XtPointer)"ShellCommand($rz);"},
{"modemVMin", "ModemVMin", XtRInt, sizeof(int),
offset(modemVMin), XtRImmediate, (XtPointer) 1},
{"ignoreModemDCD", "IgnoreModemDCD", XtRBoolean, sizeof(Boolean),
offset(ignoreModemDCD), XtRImmediate, (XtPointer) False},
{"hangupViaDTR", "HangupViaDTR", XtRBoolean, sizeof(Boolean),
offset(hangupViaDTR), XtRImmediate, (XtPointer)False},
{"modemAttentionString", "ModemAttentionString", XtRString, sizeof(String),
offset(modemAttentionString), XtRString, (XtPointer)"+++"},
{"modemHangupString", "ModemHangupString", XtRString, sizeof(String),
offset(modemHangupString), XtRString, (XtPointer)"ATH^M"},
{"hangupConfirm", "HangupConfirm", XtRBoolean, sizeof(Boolean),
offset(hangupConfirm), XtRImmediate, (XtPointer) True},
{"exitConfirm", "ExitConfirm", XtRBoolean, sizeof(Boolean),
offset(exitConfirm), XtRImmediate, (XtPointer) True},
{"neverBeep", "NeverBeep", XtRBoolean, sizeof(Boolean),
offset(neverBeep), XtRImmediate, (XtPointer)False},
{"defaultDirectory", "DefaultDirectory", XtRString, sizeof(String),
offset(defaultDirectory), XtRString, (XtPointer) "~/.seyon"},
{"scriptDirectory", "scriptDirectory", XtRString, sizeof(String),
offset(scriptDirectory), XtRString, (XtPointer) NULL},
{"startupFile", "StartupFile", XtRString, sizeof(String),
offset(startupFile), XtRString, (XtPointer) "startup"},
{"phoneFile", "PhoneFile", XtRString, sizeof(String),
offset(phoneFile), XtRString, (XtPointer) "phonelist"},
{"protocolsFile", "ProtocolsFile", XtRString, sizeof(String),
offset(protocolsFile), XtRString, (XtPointer) "protocols"},
{"captureFile", "CaptureFile", XtRString, sizeof(String),
offset(captureFile), XtRString, (XtPointer) "capture"},
{"helpFile", "HelpFile", XtRString, sizeof(String),
offset(helpFile), XtRString, (XtPointer) HELPFILE},
{"modemStatusInterval", "ModemStatusInterval", XtRInt, sizeof(int),
offset(modemStatusInterval), XtRImmediate, (XtPointer) 5},
{"idleGuard", "IdleGuard", XtRBoolean, sizeof(Boolean),
offset(idleGuard), XtRImmediate, (XtPointer) False},
{"idleGuardInterval", "IdleGuardInterval", XtRInt, sizeof(int),
offset(idleGuardInterval), XtRImmediate, (XtPointer) 300},
{"idleGuardString", "IdleGuardString", XtRString, sizeof(String),
offset(idleGuardString), XtRImmediate, (XtPointer) " ^H"},
{"showFunMessages", "ShowFunMessages", XtRBoolean, sizeof(Boolean),
offset(showFunMessages), XtRImmediate, (XtPointer) True},
{"funMessagesInterval", "FunMessagesInterval", XtRInt, sizeof(int),
offset(funMessagesInterval), XtRImmediate, (XtPointer) 15},
{"funMessages", "FunMessages", XtRStringArray, sizeof(String*),
offset(funMessages), XtRStringArray, (XtPointer) NULL},
};
#undef offset
XtSetTypeConverter(XtRString, XtRStringArray, CvtStringToStringArray,
NULL, 0, XtCacheNone, NULL);
XtGetApplicationResources(topLevel, (XtPointer)&qres, resources,
XtNumber(resources), NULL, 0);
}