home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / x / volume17 / xparty / part03 < prev    next >
Encoding:
Text File  |  1992-03-31  |  50.2 KB  |  2,094 lines

  1. Newsgroups: comp.sources.x
  2. Path: uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!mips!msi!dcmartin
  3. From: peebles@mips.com (Andrew Peebles)
  4. Subject: v17i046: Xparty - multi-person conference call (MOTIF), Part03/04
  5. Message-ID: <1992Apr1.135417.444@msi.com>
  6. Originator: dcmartin@fascet
  7. Sender: dcmartin@msi.com (David C. Martin - Moderator)
  8. Organization: Molecular Simulations, Inc.
  9. References: <csx-17i044-xparty@uunet.UU.NET>
  10. Date: Wed, 1 Apr 1992 13:54:17 GMT
  11. Approved: dcmartin@msi.com
  12.  
  13. Submitted-by: peebles@mips.com (Andrew Peebles)
  14. Posting-number: Volume 17, Issue 46
  15. Archive-name: xparty/part03
  16.  
  17. # this is part.03 (part 3 of a multipart archive)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file message.c continued
  20. #
  21. if test ! -r _shar_seq_.tmp; then
  22.     echo 'Please unpack part 1 first!'
  23.     exit 1
  24. fi
  25. (read Scheck
  26.  if test "$Scheck" != 3; then
  27.     echo Please unpack part "$Scheck" next!
  28.     exit 1
  29.  else
  30.     exit 0
  31.  fi
  32. ) < _shar_seq_.tmp || exit 1
  33. if test ! -f _shar_wnt_.tmp; then
  34.     echo 'x - still skipping message.c'
  35. else
  36. echo 'x - continuing file message.c'
  37. sed 's/^X//' << 'SHAR_EOF' >> 'message.c' &&
  38. X               args, n);
  39. X  XtManageChild (form);
  40. X
  41. X  sprintf (title,"Message from %s",(char *) getenv ("USER"));
  42. X  n = SetArgs (args,
  43. X           XmNlabelString, XmStringCreateLtoR (title,
  44. X                           XmSTRING_DEFAULT_CHARSET),
  45. X           XmNtopAttachment, XmATTACH_FORM,
  46. X           XmNleftAttachment, XmATTACH_FORM,
  47. X           NULL);
  48. X  label = XmCreateLabel (form,
  49. X             "message_label",
  50. X             args, n);
  51. X  XtManageChild (label);
  52. X
  53. X  minfo = (msg_info *) XtMalloc (sizeof(msg_info));
  54. X  minfo->shell = top;
  55. X  minfo->name  = user_name;
  56. X  minfo->display = display;
  57. X  minfo->context = toplevel;
  58. X  label2 = CreateResponseOptions (label, form, minfo, defaults.response);
  59. X
  60. X  n = SetArgs (args,
  61. X           XmNeditable, False,
  62. X               XmNeditMode, XmMULTI_LINE_EDIT,
  63. X               XmNwordWrap, True,
  64. X               XmNautoShowCursorPosition, True,
  65. X               XmNcursorPositionVisible, True,
  66. X               XmNscrollHorizontal, False,
  67. X           XmNrows, 12,
  68. X           XmNcolumns, 40,
  69. X           NULL);
  70. X  text = XmCreateScrolledText (form,
  71. X                   "message_text",
  72. X                   args, n);
  73. X  XtManageChild (text);
  74. X  XmTextSetString (text, message);
  75. X  n = SetArgs (args,
  76. X           XmNleftAttachment, XmATTACH_FORM,
  77. X           XmNtopAttachment, XmATTACH_WIDGET,
  78. X           XmNtopWidget, label2,
  79. X           NULL);
  80. X  XtSetValues (XtParent (text), args, n);
  81. X
  82. X  /*
  83. X   * realize the widget tree, then get the size of the mess 
  84. X   * and calculate where it should go on the center of the remote
  85. X   * display.
  86. X   */
  87. X  XtRealizeWidget (top);
  88. X  if (LIST_WIDGETS)
  89. X    ListWidgetNames (top);
  90. X
  91. X  n = SetArgs (args,
  92. X           XmNwidth, &shell_width,
  93. X           XmNheight, &shell_height,
  94. X           NULL);
  95. X  XtGetValues (top, args, n);
  96. X
  97. X  shell_x = (DisplayWidth (display, screen) - shell_width) / 2;
  98. X  shell_y = (DisplayHeight(display, screen) - shell_height) / 2;
  99. X
  100. X  wm_hints.x = shell_x;
  101. X  wm_hints.y = shell_y;
  102. X  wm_hints.flags = PPosition | USPosition;
  103. X
  104. X  XSetNormalHints (display,
  105. X           XtWindow (top),
  106. X           &wm_hints);
  107. X
  108. X  XtPopup (top, XtGrabNone);
  109. X
  110. X  return (True);
  111. }
  112. X
  113. X
  114. void
  115. message_popdown (w, shelli, call)
  116. Widget    w;
  117. msg_info *shelli;
  118. caddr_t    call;
  119. {
  120. X  char *resp;
  121. X  char mes[128];
  122. X  XtPopdown (shelli->shell);
  123. /**
  124. X  XtDestroyWidget (shelli->context);
  125. X  XtCloseDisplay (shelli->display);
  126. **/
  127. X
  128. X  resp = shelli->responce;
  129. X  sprintf (mes,"Message confirmed\nResponse: %s",resp);
  130. X
  131. X  XpWarning (shelli->name, mes);
  132. X  XtFree (shelli);
  133. }
  134. X
  135. X
  136. Widget
  137. CreateResponseOptions (ref, parent, minfo, rstring)
  138. Widget    ref, parent;
  139. msg_info *minfo;
  140. char    *rstring;
  141. {
  142. X  Widget    *options;
  143. X  int        num_options = 0;
  144. X  char        *opts[50];
  145. X  char        *tok;
  146. X  Widget    menu, top;
  147. X  Arg        args[10];
  148. X  int        n;
  149. X  int        i;
  150. X  msg_info    *mi;
  151. X
  152. X  /*
  153. X   * get all of the options out of rstring
  154. X   */
  155. X  tok = strtok (rstring, "\n\0");
  156. X  do {
  157. X    opts[num_options++] = strdup(tok);
  158. X  } while ((tok = strtok (NULL, "\n\0")) != NULL);
  159. X
  160. X  options = (Widget *) XtMalloc (num_options * sizeof (Widget));
  161. X
  162. X  /*
  163. X   * begin the creation of the option menu
  164. X   */
  165. X  n = 0;
  166. X  menu = XmCreatePulldownMenu (parent,
  167. X                   "Response",
  168. X                   args, n);
  169. X  for (i=0; i<num_options; i++) {
  170. X    n = SetArgs (args,
  171. X         XmNlabelString, xmstr(opts[i]),
  172. X         NULL);
  173. X    options[i] = XmCreatePushButtonGadget (menu,
  174. X                       "responseOption",
  175. X                       args, n);
  176. X    mi = (msg_info *) XtMalloc (sizeof(msg_info));
  177. X    mi->shell = minfo->shell;
  178. X    mi->context = minfo->context;
  179. X    mi->name = strdup(minfo->name);
  180. X    mi->display = minfo->display;
  181. X    mi->responce = strdup(opts[i]);
  182. X    XtAddCallback (options[i],XmNactivateCallback,message_popdown,mi);
  183. X  }
  184. X
  185. X  free(minfo);
  186. X
  187. X  XtManageChildren (options, num_options);
  188. X
  189. X  n = SetArgs (args,
  190. X           XmNleftAttachment, XmATTACH_FORM,
  191. X           XmNtopAttachment, XmATTACH_WIDGET,
  192. X           XmNtopWidget, ref,
  193. X               XmNwhichButton, 1,
  194. X               XmNsubMenuId, menu,
  195. X               XmNmenuHistory, options[0],
  196. X               XmNlabelString, xmstr("Response"),
  197. X           NULL);
  198. X  top = XmCreateOptionMenu (parent,
  199. X                "optionMenu",
  200. X                args, n);
  201. X  XtManageChild(top);
  202. X  return(top);
  203. }
  204. SHAR_EOF
  205. echo 'File message.c is complete' &&
  206. chmod 0644 message.c ||
  207. echo 'restore of message.c failed'
  208. Wc_c="`wc -c < 'message.c'`"
  209. test 6476 -eq "$Wc_c" ||
  210.     echo 'message.c: original size 6476, current size' "$Wc_c"
  211. rm -f _shar_wnt_.tmp
  212. fi
  213. # ============= operator.c ==============
  214. if test -f 'operator.c' -a X"$1" != X"-c"; then
  215.     echo 'x - skipping operator.c (File already exists)'
  216.     rm -f _shar_wnt_.tmp
  217. else
  218. > _shar_wnt_.tmp
  219. echo 'x - extracting operator.c (Text)'
  220. sed 's/^X//' << 'SHAR_EOF' > 'operator.c' &&
  221. /***************************************************************************
  222. X *
  223. X * FILE NAME        : operator.c
  224. X *
  225. X * AUTHOR        : Andrew Peebles
  226. X *
  227. X * DESCRIPTION        : These routines take care of "dialing" a remote
  228. X *              display, providing timeouts when there is no
  229. X *              answer, and logging in a new party when there
  230. X *              is an answer.
  231. X *
  232. X * VERSIONS        : %W%
  233. X *
  234. X ***************************************************************************/
  235. X
  236. /*
  237. X * standard includes
  238. X */
  239. #include <stdio.h>
  240. X
  241. #include <Xm/Form.h>
  242. #include <Xm/Label.h>
  243. #include <Xm/Separator.h>
  244. #include <Xm/PushB.h>
  245. #include <X11/Shell.h>
  246. X
  247. #include "xphone.h"
  248. X
  249. typedef struct _msg_info {
  250. X  Widget        shell;
  251. X  XtIntervalId    tid;
  252. X  Person    *person;
  253. X  Display    *display;
  254. } msg_info;
  255. X
  256. Operator (person)
  257. Person *person;
  258. {
  259. X  Widget    toplevel, top, form, label, sep, yes, no;
  260. X  Arg        args[10];
  261. X  int        n;
  262. X  char        *display_name;
  263. X
  264. X  int        shell_x, shell_y, shell_width, shell_height;
  265. X  XSizeHints    wm_hints;
  266. X  Display    *display;
  267. X  int        screen;
  268. X
  269. X  char        title[128];
  270. X
  271. X  void        yes_cb(), no_cb(), op_timeout();
  272. X
  273. X  int           ac = 1;
  274. X  char          *av[1];
  275. X
  276. X  msg_info      *minfo;
  277. X
  278. X  av[0] = "xparty";
  279. X  display_name = person->host;
  280. X
  281. X  display = XtOpenDisplay (xphone,
  282. X                           display_name,
  283. X                           "xparty",
  284. X                           "XParty",
  285. X                           NULL, 0,
  286. X                           &ac, av);
  287. X  if (!display) {
  288. X    XpWarning (display_name, "Couldn't open display");
  289. X    return (False);
  290. X  }
  291. X
  292. X  screen = DefaultScreen (display);
  293. X
  294. X  toplevel = XtAppCreateShell ("xparty", "XParty",
  295. X                               applicationShellWidgetClass,
  296. X                               display, NULL, 0);
  297. X
  298. X  n = 0;
  299. X  top = XtCreatePopupShell ("xparty",
  300. X                            topLevelShellWidgetClass,
  301. X                            toplevel, args, n);
  302. X
  303. X  n = 0;
  304. X  form = XmCreateForm (top,
  305. X                       "message_form",
  306. X                       args, n);
  307. X  XtManageChild (form);
  308. X
  309. X  sprintf (title,"Collect call from %s,\nwill you accept the charges?",
  310. X       (char *) getenv ("USER"));
  311. X  
  312. X  n = SetArgs (args,
  313. X           XmNtopAttachment, XmATTACH_FORM,
  314. X           XmNleftAttachment, XmATTACH_FORM,
  315. X           XmNlabelString, XmStringCreateLtoR(title,
  316. X                          XmSTRING_DEFAULT_CHARSET),
  317. X           NULL);
  318. X  label = XmCreateLabel (form,
  319. X             "operator_label",
  320. X             args, n);
  321. X  XtManageChild (label);
  322. X
  323. X  n = SetArgs (args,
  324. X           XmNorientation, XmHORIZONTAL,
  325. X           XmNrightAttachment, XmATTACH_FORM,
  326. X           XmNleftAttachment, XmATTACH_FORM,
  327. X           XmNtopAttachment, XmATTACH_WIDGET,
  328. X           XmNtopWidget, label,
  329. X           NULL);
  330. X  sep = XmCreateSeparator (form,
  331. X               "separator",
  332. X               args, n);
  333. X  XtManageChild (sep);
  334. X
  335. X  n = SetArgs (args,
  336. X           XmNtopAttachment, XmATTACH_WIDGET,
  337. X           XmNtopWidget, sep,
  338. X           XmNleftAttachment, XmATTACH_FORM,
  339. X           NULL);
  340. X  yes = XmCreatePushButton (form,
  341. X                "Yes",
  342. X                args, n);
  343. X  XtManageChild (yes);
  344. X
  345. X  n = SetArgs (args,
  346. X           XmNtopAttachment, XmATTACH_WIDGET,
  347. X           XmNtopWidget, sep,
  348. X           XmNrightAttachment, XmATTACH_FORM,
  349. X           NULL);
  350. X  no = XmCreatePushButton (form,
  351. X                "No",
  352. X                args, n);
  353. X  XtManageChild (no);
  354. X
  355. X  minfo = (msg_info *) XtMalloc (sizeof(msg_info));
  356. X  minfo->shell = top;
  357. X  minfo->person = person;
  358. X  minfo->display = display;
  359. X
  360. X  XtAddCallback (yes, XmNactivateCallback, yes_cb, minfo);
  361. X  XtAddCallback (no, XmNactivateCallback, no_cb, minfo);
  362. X
  363. X  /*
  364. X   * realize the widget tree, then get the size of the mess
  365. X   * and calculate where it should go on the center of the remote
  366. X   * display.
  367. X   */
  368. X  XtRealizeWidget (top);
  369. X  if (LIST_WIDGETS)
  370. X    ListWidgetNames (top);
  371. X
  372. X  n = SetArgs (args,
  373. X               XmNwidth, &shell_width,
  374. X               XmNheight, &shell_height,
  375. X               NULL);
  376. X  XtGetValues (top, args, n);
  377. X
  378. X  shell_x = (DisplayWidth (display, screen) - shell_width) / 2;
  379. X  shell_y = (DisplayHeight(display, screen) - shell_height) / 2;
  380. X
  381. X  wm_hints.x = shell_x;
  382. X  wm_hints.y = shell_y;
  383. X  wm_hints.flags = PPosition | USPosition;
  384. X
  385. X  XSetNormalHints (display,
  386. X                   XtWindow (top),
  387. X                   &wm_hints);
  388. X
  389. X  /*
  390. X   * and add a 10 second timeout for the remote user to respond to.
  391. X   * when the timeout expires, the operator window will go away and
  392. X   * the remote user will not be included in the session.
  393. X   */
  394. X  minfo->tid = 
  395. X  XtAppAddTimeOut (xphone, 10000, op_timeout, minfo);
  396. X
  397. X  /*
  398. X   * and beep em to get thier attension
  399. X   */
  400. X  XBell (display, 100);
  401. X
  402. X  XtPopup (top, XtGrabNone);
  403. X
  404. }
  405. X
  406. void
  407. op_timeout (shelli, id)
  408. msg_info    *shelli;
  409. int        *id;
  410. {
  411. X  XtPopdown (shelli->shell);
  412. X  XpWarning (shelli->person->name,"No answer ...");
  413. }
  414. X
  415. void
  416. no_cb (w, shelli, call)
  417. Widget    w;
  418. msg_info *shelli;
  419. caddr_t    call;
  420. {
  421. X  XtPopdown (shelli->shell);
  422. X  XtCloseDisplay (shelli->display);
  423. }
  424. X
  425. void
  426. yes_cb (w, shelli, call)
  427. Widget    w;
  428. msg_info *shelli;
  429. caddr_t    call;
  430. /*
  431. X * Try to find a vancant spot in the parties chain.  If one exists,
  432. X * put the new party there, else add it to the end of the token ring.
  433. X */
  434. {
  435. X  int    n, i;
  436. X  Boolean found = False;
  437. X
  438. X  XtRemoveTimeOut (shelli->tid);
  439. X  XtPopdown (shelli->shell);
  440. X
  441. X  XpOnTheAir (shelli->person->name);
  442. X
  443. X  for (i=1; i<num_parties; i++) {
  444. X    if (parties[i]->dead) {
  445. X      found = True;
  446. X      break;
  447. X    }
  448. X  }
  449. X
  450. X  if (found) {
  451. X    XtFree (parties[i]);
  452. X    parties[i] = XpCreateParty (shelli->person->host,
  453. X                (char *) getenv ("USER"),
  454. X                shelli->person->name,
  455. X                shelli->display);
  456. X  }
  457. X  else {
  458. X    XtFree (parties[num_parties+1]);
  459. X    parties[num_parties++] = XpCreateParty (shelli->person->host,
  460. X                        (char *) getenv ("USER"),
  461. X                        shelli->person->name,
  462. X                        shelli->display);
  463. X  }
  464. }
  465. X
  466. SHAR_EOF
  467. chmod 0644 operator.c ||
  468. echo 'restore of operator.c failed'
  469. Wc_c="`wc -c < 'operator.c'`"
  470. test 5643 -eq "$Wc_c" ||
  471.     echo 'operator.c: original size 5643, current size' "$Wc_c"
  472. rm -f _shar_wnt_.tmp
  473. fi
  474. # ============= orig_disp.c ==============
  475. if test -f 'orig_disp.c' -a X"$1" != X"-c"; then
  476.     echo 'x - skipping orig_disp.c (File already exists)'
  477.     rm -f _shar_wnt_.tmp
  478. else
  479. > _shar_wnt_.tmp
  480. echo 'x - extracting orig_disp.c (Text)'
  481. sed 's/^X//' << 'SHAR_EOF' > 'orig_disp.c' &&
  482. /***************************************************************************
  483. X *
  484. X * FILE NAME        : orig_disp.c
  485. X *
  486. X * AUTHOR        : Andrew Peebles
  487. X *
  488. X * DESCRIPTION        : Creates the originator display widgets and
  489. X *              ties them into parties[0].
  490. X *
  491. X * VERSIONS        : %W%
  492. X *
  493. X ***************************************************************************/
  494. X
  495. /*
  496. X * standard includes
  497. X */
  498. #include <stdio.h>
  499. X
  500. #include <Xm/Form.h>
  501. #include <Xm/PushB.h>
  502. #include <Xm/Text.h>
  503. #include <Xm/RowColumn.h>
  504. #include <Xm/Label.h>
  505. #include <Xm/ToggleB.h>
  506. #include <Xm/Separator.h>
  507. #include <Xm/List.h>
  508. #include <Xm/PanedW.h>
  509. #include <X11/Shell.h>
  510. #include "Table.h"
  511. X
  512. #include "xphone.h"
  513. X
  514. char    *CURRENTLY_SPEAKING;
  515. X
  516. static XtTranslations  trans;
  517. static char trans_string[] = "<Key>F3: PassToken()";
  518. void PassToken();
  519. static XtActionsRec actionsList[] = {
  520. X  { "PassToken", PassToken },
  521. };
  522. X
  523. void LocalModify();
  524. static XtCallbackRec LocalModifyCB[] = {
  525. X  {LocalModify, NULL},
  526. X  {NULL,        NULL},
  527. };
  528. X
  529. X
  530. Boolean    ONE_WAY = False;
  531. extern    Widget    o_toplevel, o_top;
  532. extern    char *progname;
  533. X
  534. Widget    O_DIAL, O_QUIT, O_JERK, O_HANGUP, O_AIR, O_CLEAR;
  535. Widget    O_RC, O_FORM, O_SEP1;
  536. X
  537. /*
  538. X * command line and non-widget resources
  539. X */
  540. typedef struct _res {
  541. X  Boolean    iconic;
  542. X  char        *response;
  543. } res, *resPtr;
  544. res defaults;
  545. X
  546. static XtResource resource_struct[] = {
  547. X  {"iconic", "Iconic",
  548. X     XmRBoolean, sizeof(Boolean),
  549. X     XtOffset (resPtr,iconic),
  550. X     XmRString, "False"},
  551. X  {"response", "Response",
  552. X     XmRString, sizeof(char *),
  553. X     XtOffset (resPtr,response),
  554. X     XmRString, "yes\nno\nget back to you ..."}
  555. };
  556. X
  557. static char    main_layout[] = "\
  558. left          0 0 1 1 ;\
  559. right         1 0 1 1 ;";
  560. X
  561. static char     left_layout[] = "\
  562. Recipients    0 0 1 1 hH  ;\
  563. rc        0 1 1 1     ;\
  564. listlab        0 2 1 1 hH  ;\
  565. list        0 3 1 1 hH  ;\
  566. btns        0 4 1 1 hH  ;";
  567. X
  568. static char    right_layout[] = "\
  569. speaking    0 0 1 1 hH  ;\
  570. vpane        0 1 1 1     ;\
  571. btns        0 2 1 1 hH  ;";
  572. X
  573. static char    left_btn_layout[] = "\
  574. Dial        0 0 1 1 ;\
  575. hangup        1 0 1 1 ;\
  576. jerk        2 0 1 1 ;\
  577. AddR        3 0 1 1 ;\
  578. Quit        4 0 1 1 ;";
  579. X
  580. static char    right_btn_layout[] = "\
  581. one-way        0 0 1 1 ;\
  582. clear        1 0 1 1 ;\
  583. status        2 0 1 1 ;";
  584. X
  585. Widget
  586. MakeOriginatorDisplay (display)
  587. Display    *display;
  588. {
  589. X  Widget    toplevel,
  590. X                top,
  591. X                form, rc, list, vpane, recv, send, talking, status,
  592. X                quit, hang, one_way, go, sep1, sep2, clear, jerk,
  593. X                lab1, lab2, addr;
  594. X  Widget    right, left, right_btns, left_btns;
  595. X  Arg        args[20];
  596. X  int        n;
  597. X  int        qw, rcw, qx, rcx;
  598. X  char        *res_string;
  599. X  void        quit_cb(), clear_cb(), one_way_cb(), dial_cb();
  600. X  void        o_hangup_cb(), o_jerk_cb();
  601. X  void        o_addR_cb();
  602. X
  603. X  o_toplevel = 
  604. X  toplevel = XtAppCreateShell("xparty", "XParty",
  605. X                  applicationShellWidgetClass,
  606. X                  display, NULL, 0);
  607. X
  608. X  XtGetApplicationResources (o_toplevel,
  609. X                 &defaults,
  610. X                 resource_struct,
  611. X                 XtNumber(resource_struct),
  612. X                 NULL,0);
  613. X
  614. X  n = SetArgs (args,
  615. X           XmNiconic, defaults.iconic,
  616. X           NULL);
  617. X  top = XtCreatePopupShell ("xparty", 
  618. X                topLevelShellWidgetClass,
  619. X                toplevel, args, n);
  620. X
  621. X  n = SetArgs (args,
  622. X           XtNlayout, XtTblParseLayout(main_layout),
  623. X           NULL);
  624. X  O_FORM =
  625. X  form = XtCreateTable (top,
  626. X             "form",
  627. X             args, n);
  628. X  XtManageChild (form);
  629. X
  630. X  n = SetArgs (args,
  631. X           XtNlayout, XtTblParseLayout(left_layout),
  632. X           NULL);
  633. X  left = XtCreateTable (form,
  634. X             "left",
  635. X             args, n);
  636. X  XtManageChild (left);
  637. X
  638. X  n = SetArgs (args,
  639. X           XtNlayout, XtTblParseLayout(right_layout),
  640. X           NULL);
  641. X  right = XtCreateTable (form,
  642. X             "right",
  643. X             args, n);
  644. X  XtManageChild (right);
  645. X
  646. X  n = 0;
  647. X  lab1 = XmCreateLabel (left,
  648. X            "Recipients",
  649. X            args, n);
  650. X  XtManageChild (lab1);
  651. X
  652. X  n = 0;
  653. X  O_RC = 
  654. X  rc = XmCreateRowColumn (left,
  655. X              "rc",
  656. X              args, n);
  657. X  XtManageChild (rc);
  658. X
  659. X  AddPeople (rc);
  660. X
  661. X  n = SetArgs (args,    
  662. X           XmNlabelString, XmStringCreateLtoR ("on the air",
  663. X                           XmSTRING_DEFAULT_CHARSET),
  664. X           NULL);
  665. X  lab2 = XmCreateLabel (left,
  666. X            "listlab",
  667. X            args, n);
  668. X  XtManageChild (lab2);
  669. X
  670. X  n = SetArgs (args,
  671. X           XmNvisibleItemCount, 10,
  672. X           XmNitemCount, 0,
  673. X           NULL);
  674. X  list = XmCreateList (left,
  675. X               "list",
  676. X               args, n);
  677. X  XtManageChild (list);
  678. X
  679. X  n = SetArgs (args,
  680. X           XmNbackgroundPixmap, (Pixmap) GetPixmap (list, "list_bg"),
  681. X           NULL);
  682. X  XtSetValues (list, args, n);
  683. X
  684. X
  685. X  n = SetArgs (args,
  686. X           XtNlayout, XtTblParseLayout(right_btn_layout),
  687. X           NULL);
  688. X  right_btns = XtCreateTable (right,
  689. X             "btns",
  690. X             args, n);
  691. X  XtManageChild (right_btns);
  692. X
  693. X  n = SetArgs (args,
  694. X           XtNlayout, XtTblParseLayout(left_btn_layout),
  695. X           NULL);
  696. X  left_btns = XtCreateTable (left,
  697. X             "btns",
  698. X             args, n);
  699. X  XtManageChild (left_btns);
  700. X  
  701. X  n = 0;
  702. X  O_DIAL = 
  703. X  go = XmCreatePushButton (left_btns,
  704. X               "Dial",
  705. X               args, n);
  706. X  XtManageChild (go);
  707. X
  708. X  n = 0;
  709. X  O_HANGUP = 
  710. X  hang = XmCreatePushButton (left_btns,
  711. X                 "hangup",
  712. X                 args, n);
  713. X  XtManageChild (hang); 
  714. X
  715. X  n = 0;
  716. X  O_JERK = 
  717. X  jerk = XmCreatePushButton (left_btns,
  718. X                 "jerk",
  719. X                 args, n);
  720. X  XtManageChild (jerk);
  721. X
  722. X  n = 0;
  723. X  addr = XmCreatePushButton (left_btns,
  724. X                 "AddR",
  725. X                 args, n);
  726. X  XtManageChild (addr);
  727. X
  728. X  n = 0;
  729. X  O_QUIT = 
  730. X  quit = XmCreatePushButton (left_btns,
  731. X                 "Quit",
  732. X                 args, n);
  733. X  XtManageChild (quit);
  734. X
  735. X  /********************************************************************/
  736. X
  737. X  n = SetArgs (args,
  738. X           XmNalignment, XmALIGNMENT_BEGINNING,
  739. X           NULL);
  740. X  talking = XmCreateLabel (right,
  741. X               "speaking",
  742. X               args, n);
  743. X  XtManageChild (talking);
  744. X  n = 0;
  745. X  vpane = XmCreatePanedWindow (right,
  746. X                   "vpane",
  747. X                   args, n);
  748. X  XtManageChild (vpane);
  749. X
  750. X  n = SetArgs (args,
  751. X               XmNeditable, False,
  752. X               XmNeditMode, XmMULTI_LINE_EDIT,
  753. X               XmNwordWrap, True,
  754. X               XmNautoShowCursorPosition, True,
  755. X               XmNcursorPositionVisible, True,
  756. X           XmNscrollHorizontal, False,
  757. X               NULL);
  758. X  recv = XmCreateScrolledText (vpane,
  759. X                   "remote",
  760. X                   args, n);
  761. X  XtManageChild (recv);
  762. X
  763. X  n = SetArgs (args,
  764. X               XmNeditable, False,
  765. X               XmNeditMode, XmMULTI_LINE_EDIT,
  766. X               XmNwordWrap, True,
  767. X               XmNautoShowCursorPosition, True,
  768. X               XmNcursorPositionVisible, True,
  769. X           XmNscrollHorizontal, False,
  770. X
  771. X               XmNmodifyVerifyCallback, LocalModifyCB,
  772. X               NULL);
  773. X  send = XmCreateScrolledText (vpane,
  774. X                   "local",
  775. X                   args, n);
  776. X  XtManageChild (send);
  777. X  XmAddTabGroup (send);
  778. #if 0
  779. X  XmAddTabGroup(recv);
  780. #endif
  781. X  n = 0;
  782. X  O_AIR = 
  783. X  one_way = XmCreateToggleButton (right_btns,
  784. X                  "one-way",
  785. X                  args, n);
  786. X  XtManageChild (one_way);
  787. X
  788. X  n = 0;
  789. X  O_CLEAR = 
  790. X  clear = XmCreatePushButton (right_btns,
  791. X                  "clear",
  792. X                  args, n);
  793. X  XtManageChild (clear);
  794. X
  795. X  n = 0;
  796. X  status = XmCreateLabel (right_btns,
  797. X              "status",
  798. X              args, n);
  799. X  XtManageChild (status);
  800. X
  801. X  XtAddCallback (go, XmNactivateCallback, dial_cb, NULL);
  802. X  XtAddCallback (hang, XmNactivateCallback, o_hangup_cb, NULL);
  803. X  XtAddCallback (jerk, XmNactivateCallback, o_jerk_cb, NULL);
  804. X  XtAddCallback (addr, XmNactivateCallback, o_addR_cb, NULL);
  805. X  XtAddCallback (quit, XmNactivateCallback, quit_cb, NULL);
  806. X  XtAddCallback (clear, XmNactivateCallback, clear_cb, parties[0]);
  807. X  XtAddCallback (one_way, XmNarmCallback, one_way_cb, go);
  808. X
  809. X  XtRealizeWidget (top); 
  810. X  if (LIST_WIDGETS)
  811. X    ListWidgetNames (top);
  812. X
  813. X  if ((res_string = XGetDefault(XtDisplay(form),
  814. X                progname,
  815. X                "tokenKey")))
  816. X    trans = XtParseTranslationTable(res_string);
  817. X  else
  818. X    trans = XtParseTranslationTable(trans_string);
  819. X  XtOverrideTranslations(send, trans);
  820. X
  821. X  parties[0] = (Party *) XtMalloc (sizeof(Party));
  822. X  parties[0]->display = display;
  823. X  parties[0]->hostname = DisplayString (parties[0]->display);
  824. X  parties[0]->username = (char *) getenv ("USER");
  825. X  parties[0]->token = False;
  826. X  parties[0]->dead = False;
  827. X  parties[0]->top = top;
  828. X  parties[0]->box = vpane;
  829. X  parties[0]->talking = talking;
  830. X  parties[0]->status = status;
  831. X  parties[0]->send = send;
  832. X  parties[0]->recv = recv;
  833. X  parties[0]->list = list;
  834. X  parties[0]->list_posted = True;
  835. X
  836. X  InitPartyList();
  837. X  InitOriginator();
  838. X
  839. X  return (top);
  840. }
  841. X
  842. X
  843. InitPartyList()
  844. {
  845. X  int    i;
  846. X  for (i=1; i<MAX_PARTIES; i++) {
  847. X    parties[i] = (Party *) XtMalloc (sizeof(Party));
  848. X    parties[i]->dead = True;
  849. X    parties[i]->token = False;
  850. X  }
  851. X  num_parties = 1;
  852. }
  853. X
  854. /*
  855. X * This routine is called once when the originator screen is first
  856. X * created, and then every time the on_the_air list becomes empty.
  857. X * Any of the command buttons that where made insensitive are made
  858. X * sensitive again, and the talking and status fields get initial
  859. X * values.
  860. X */
  861. InitOriginator()
  862. {
  863. X  char    *speaking_f = "Dial Tone";
  864. X  char    *status_f   = "Off the Hook";
  865. X  Arg    args[5];
  866. X  int    i;
  867. X
  868. X  XtSetArg (args[0], XmNlabelString, XmStringCreateLtoR (speaking_f,
  869. X                             XmSTRING_DEFAULT_CHARSET));
  870. X  XtSetValues (parties[0]->talking, args, 1);
  871. X  XtSetArg (args[0], XmNlabelString, XmStringCreateLtoR (status_f,
  872. X                             XmSTRING_DEFAULT_CHARSET));
  873. X  XtSetValues (parties[0]->status, args, 1);
  874. X  
  875. X  XtSetSensitive (O_DIAL, True);
  876. X  XtSetSensitive (O_QUIT, True);
  877. X  XtSetSensitive (O_JERK, False);
  878. X  XtSetSensitive (O_HANGUP, False); 
  879. X  XtSetSensitive (O_AIR, True);
  880. X  XtSetSensitive (O_CLEAR, True);
  881. X
  882. X  XmTextSetEditable (parties[0]->send, False);
  883. X  parties[0]->token = False;
  884. X  XFlush (XtDisplay(parties[0]->box));
  885. X
  886. X  for (i=1; i<MAX_PARTIES; i++)
  887. X    parties[i]->dead = True;
  888. X  num_parties = 1;
  889. }
  890. X
  891. X
  892. /*
  893. X * utils
  894. X */
  895. X
  896. static char NO_PEOPLE[] = "\
  897. This program is a message sender, and expects to have a list of recipients\n\
  898. to which messages can be sent.  Such a list is kept in $HOME/.xmsg_hosts, \n\
  899. which couldn't be found.  Please create this file and try again.\n\
  900. \n\
  901. The format of the file is a list of hostnames, one name per line, of the\n\
  902. machines you expect to send messages to.  Each line can optionally contain\n\
  903. the user's name on that machine, i.e. peebles@ling.\n\
  904. \n\
  905. An example:\n\
  906. \tpeebles@ling\n\
  907. \tmike@phred\n\
  908. \tjeeves\n\
  909. \n\
  910. Where the first two lines contain person@host, and the last is only host.\n\
  911. ";
  912. X
  913. /*
  914. X * this routine adds the people to the recipient list
  915. X */
  916. AddPeople (w)
  917. Widget    w;
  918. {
  919. X  int    lim;
  920. X  FILE    *fp, *fopen();
  921. X  char    *home = (char *) getenv ("HOME");
  922. X  char    *filename;
  923. X  char    host[80];
  924. X  char    *n, *h;
  925. X
  926. X  filename = (char *) malloc (strlen(home) +
  927. X                  strlen(".xmsg_hosts") + 3);
  928. X  sprintf (filename,"%s/.xmsg_hosts",home);
  929. X
  930. X  if ((fp = fopen (filename,"r")) == NULL) {
  931. X    /*
  932. X     * It doesn't exist, lets make one and initialize it w/
  933. X     * the host display information and user name.
  934. X     */
  935. X    if ((fp = fopen (filename,"w")) == NULL) {
  936. X      fprintf (stderr,"Can't open %s to read recipient list\n",filename);
  937. X      fprintf (stderr,"%s\n",NO_PEOPLE);
  938. X      exit(1);
  939. X    }
  940. X    fprintf (fp, "Me@%s\n",DisplayString(XtDisplay(w)));
  941. X    fclose (fp);
  942. X    fp = fopen (filename,"r");
  943. X  }
  944. X
  945. X  num_people = 0;
  946. X  people = (PersonPtr *) malloc (10*(sizeof(PersonPtr)));
  947. X  lim = 10;
  948. X  while (fgets (host,80,fp) != NULL) {
  949. X    char *label;
  950. X    
  951. X    if (host[0] == '\n') continue;
  952. X
  953. X    people[num_people] = (Person *) malloc (sizeof(Person));
  954. X
  955. X    n = strtok (host,"@\n");
  956. X    h = strtok (NULL," \n");
  957. X
  958. X    if (h == NULL) {
  959. X      people[num_people]->name = NULL;
  960. X      people[num_people]->host = strdup(n);
  961. X      label = n;
  962. X    }
  963. X    else {
  964. X      people[num_people]->name = strdup(n);
  965. X      people[num_people]->host = strdup(h);
  966. X      label = n;
  967. X    }
  968. X
  969. X    people[num_people]->btn = XmCreateToggleButton (w,
  970. X                            label,
  971. X                            NULL, 0);
  972. X    XtManageChild (people[num_people++]->btn);
  973. X    if (num_people == lim) {
  974. X      lim += 10;
  975. X      people = (PersonPtr *) XtRealloc (people,
  976. X                    lim*(sizeof(PersonPtr)));
  977. X    }    
  978. X  }
  979. X  fclose (fp);
  980. }
  981. X
  982. /*
  983. X * for posting one-way messages
  984. X */
  985. Post (cmd, args)
  986. char *cmd;
  987. char **args;
  988. {
  989. X
  990. X  if (fork() == 0) {  
  991. X    int     status, i;
  992. X    int     out;
  993. X
  994. X    /*
  995. X     * close open file discriptors
  996. X     */
  997. X    close(0);
  998. X    close(1);
  999. X    out = dup (stderr);
  1000. X
  1001. X    for (i=3; i<getdtablesize(); i++)
  1002. X      close (i);
  1003. X    
  1004. X    status = execvp (cmd, args); 
  1005. X    fprintf (out,"Exec failed\n");
  1006. X  } 
  1007. X  
  1008. }
  1009. X
  1010. /*
  1011. X * Button callbacks for originator window
  1012. X */
  1013. void
  1014. dial_cb (w, client, call)
  1015. Widget    w;
  1016. caddr_t    client, call;
  1017. {
  1018. X  if (ONE_WAY)
  1019. X    SendMessages();
  1020. X  else
  1021. X    DialRemotes();
  1022. }
  1023. X
  1024. void 
  1025. quit_cb()
  1026. {
  1027. X  exit (0);
  1028. }
  1029. X
  1030. void 
  1031. clear_cb (w, client, call)
  1032. Widget    w;
  1033. caddr_t client;
  1034. caddr_t    call;
  1035. {
  1036. X  XmTextSetString (parties[0]->send,"");
  1037. X  XmTextSetString (parties[0]->recv,"");
  1038. }
  1039. X
  1040. void
  1041. one_way_cb (w, dial, call)
  1042. Widget    w, dial;
  1043. caddr_t    call;
  1044. {
  1045. X  Arg    args[2];
  1046. X
  1047. X  if (ONE_WAY) {
  1048. X    ONE_WAY = False;
  1049. X    XtSetArg (args[0], XmNlabelString,
  1050. X          XmStringCreateLtoR ("Dial", XmSTRING_DEFAULT_CHARSET));
  1051. X    XtSetValues (dial, args, 1);
  1052. X    XmTextSetString (parties[0]->send,"");
  1053. X    XmTextSetEditable (parties[0]->send, False);
  1054. X    parties[0]->token = False;
  1055. X  }
  1056. X  else {
  1057. X    ONE_WAY = True;
  1058. X    XtSetArg (args[0], XmNlabelString,
  1059. X          XmStringCreateLtoR ("Send", XmSTRING_DEFAULT_CHARSET));
  1060. X    XtSetValues (dial, args, 1);
  1061. X    XmTextSetEditable (parties[0]->send, True);
  1062. X    parties[0]->token = True;
  1063. X  }
  1064. }
  1065. X
  1066. void 
  1067. o_jerk_cb (w, client, call)
  1068. Widget    w;
  1069. caddr_t    client, call;
  1070. {
  1071. X  StealToken();
  1072. }
  1073. X
  1074. void 
  1075. o_hangup_cb (w, client, call)
  1076. Widget    w;
  1077. caddr_t    client, call;
  1078. /*
  1079. X * Only needs to be called when a no one answers a "dial".  Under these
  1080. X * circumstances, this is the only way to get the originator back into
  1081. X * a useable state.  We'll not allow the originator to hang up if there
  1082. X * are people on the line.
  1083. X */
  1084. {
  1085. X  Arg    args[5];
  1086. X  int    icount = 0;
  1087. X
  1088. /**
  1089. X  XmListDeleteItem (parties[0]->list,
  1090. X            XmStringCreateLtoR ((char *)getenv("USER"),
  1091. X                    XmSTRING_DEFAULT_CHARSET));
  1092. **/
  1093. X  XtSetArg (args[0], XmNitemCount, &icount);
  1094. X  XtGetValues (parties[0]->list, args, 1);
  1095. X  if (icount != 0) {
  1096. X    XpWarning ("Hangup","There are people on the line!");
  1097. X    return;
  1098. X  }
  1099. X  InitOriginator();
  1100. }
  1101. X
  1102. /************************************************************************/
  1103. X
  1104. /*
  1105. X * SendMessages
  1106. X *
  1107. X *    Send a message contained in the originator's send buffer
  1108. X *    to the selected people.
  1109. X */
  1110. SendMessages()
  1111. {
  1112. X  int    i;
  1113. X  char    *message;
  1114. X  int    set;
  1115. X  Arg    args[2];
  1116. X  Arg    args2[2];
  1117. X
  1118. X  message = XmTextGetString (parties[0]->send);
  1119. X  if ((!message) || (strlen(message) == 0)) {
  1120. X    XpWarning ("Send", "No message to send");
  1121. X    return (False);
  1122. X  }
  1123. X  XtSetArg (args[0], XmNset, &set);
  1124. X  XtSetArg (args2[0], XmNset, False);
  1125. X
  1126. X  for (i=0; i<num_people; i++) {
  1127. X    set = False;
  1128. X    XtGetValues (people[i]->btn, args, 1);
  1129. X    if (!set) continue;
  1130. X    PostMessage (people[i]->host, people[i]->name, message);
  1131. X    XtSetValues (people[i]->btn, args2, 1);
  1132. X  }
  1133. X
  1134. X  XtFree (message);
  1135. X
  1136. }
  1137. X
  1138. /*
  1139. X * DialRemotes()
  1140. X *
  1141. X *    Have the operator dial the remote displays.  The operator
  1142. X *    takes care of the client connection to the current session.
  1143. X */
  1144. DialRemotes()
  1145. {
  1146. X  int    i;
  1147. X  int    set;
  1148. X  Arg    args[2];
  1149. X  Arg    args2[2];
  1150. X  int    count = 0;
  1151. X  char    buf[80];
  1152. X
  1153. X
  1154. X  XtSetSensitive (O_DIAL, True);
  1155. X  XtSetSensitive (O_QUIT, True);
  1156. X  XtSetSensitive (O_JERK, True);
  1157. X  XtSetSensitive (O_HANGUP, True); 
  1158. X  XtSetSensitive (O_AIR, False);
  1159. X  XtSetSensitive (O_CLEAR, False);
  1160. X
  1161. X  /*
  1162. X   * set up the originator for speaking
  1163. X   */
  1164. X  if (num_parties == 1) {
  1165. X    CURRENTLY_SPEAKING = (char *) getenv ("USER");
  1166. X    bzero (buf,80);
  1167. X    sprintf (buf,"Speaking: You");
  1168. X    XtSetArg (args[0], XmNlabelString, XmStringCreateLtoR(buf,
  1169. X                       XmSTRING_DEFAULT_CHARSET));
  1170. X    XtSetValues (parties[0]->talking, args, 1);
  1171. X
  1172. X    bzero(buf,80);
  1173. X    sprintf (buf,"GO!");
  1174. X    XtSetArg (args[0], XmNlabelString, XmStringCreateLtoR(buf,
  1175. X                       XmSTRING_DEFAULT_CHARSET));
  1176. X    XtSetValues (parties[0]->status, args, 1);
  1177. X
  1178. X    parties[0]->token = True;
  1179. X    XmTextSetEditable (parties[0]->send, True);
  1180. X  }
  1181. X
  1182. X  XtSetArg (args[0], XmNset, &set);
  1183. X  XtSetArg (args2[0], XmNset, False);
  1184. X
  1185. X  for (i=0; i<num_people; i++) {
  1186. X    set = False;
  1187. X    XtGetValues (people[i]->btn, args, 1);
  1188. X    if (!set) continue;
  1189. X    XtSetValues (people[i]->btn, args2, 1);
  1190. X    if ((count++) >= MAX_PARTIES)
  1191. X      continue;
  1192. X    Operator (people[i]);
  1193. X  }
  1194. X
  1195. }
  1196. X
  1197. X
  1198. void
  1199. o_addR_cb (w, client, call)
  1200. Widget    w;
  1201. caddr_t    client, call;
  1202. {
  1203. X  void NewPerson();
  1204. X  PromptForString (o_top,
  1205. X           "<label>@<display> :",
  1206. X           "",
  1207. X           NewPerson, NULL);
  1208. }
  1209. X
  1210. void 
  1211. NewPerson (w, info, call)
  1212. Widget    w;
  1213. caddr_t info;
  1214. XXmSelectionBoxCallbackStruct *call;
  1215. {
  1216. X  FILE    *fp, *fopen();
  1217. X  char    *home = (char *) getenv ("HOME");
  1218. X  char    *filename;
  1219. X  char    *host;
  1220. X  char    *n, *h;
  1221. X  char    *save_host;
  1222. X  char    *label;
  1223. X  Arg    args[10];
  1224. X  int    nn, qw, rcw, qx, rcx;
  1225. X
  1226. X  XmStringGetLtoR (call->value,
  1227. X           XmSTRING_DEFAULT_CHARSET,
  1228. X           &host);
  1229. X
  1230. X  if ((!host) || (strlen(host) == 0))
  1231. X    return;
  1232. X
  1233. X  save_host = strdup (host);
  1234. X
  1235. X  people = (PersonPtr *) XtRealloc (people,
  1236. X                 (num_people+1)*sizeof(PersonPtr));
  1237. X
  1238. X  people[num_people] = (Person *) malloc (sizeof(Person));
  1239. X
  1240. X  n = strtok (host,"@\n");
  1241. X  h = strtok (NULL," \n");
  1242. X
  1243. X  if (h == NULL) {
  1244. X    people[num_people]->name = NULL;
  1245. X    people[num_people]->host = strdup(n);
  1246. X    label = n;
  1247. X  }
  1248. X  else {
  1249. X    people[num_people]->name = strdup(n);
  1250. X    people[num_people]->host = strdup(h);
  1251. X    label = n;
  1252. X  }
  1253. X
  1254. X  XtUnmanageChild (O_RC);
  1255. X
  1256. X  people[num_people]->btn = XmCreateToggleButton (O_RC,
  1257. X                          label,
  1258. X                          NULL, 0);
  1259. X  XtManageChild (people[num_people++]->btn);
  1260. X
  1261. X  XtManageChild (O_RC);
  1262. X
  1263. X  filename = (char *) malloc (strlen(home) +
  1264. X                  strlen(".xmsg_hosts") + 3);
  1265. X  sprintf (filename,"%s/.xmsg_hosts",home);
  1266. X  if ((fp = fopen (filename,"a")) == NULL) {
  1267. X    XpWarning (filename, "Couldn't update w/ new recipient.");
  1268. X    return;
  1269. X  }
  1270. X  fprintf (fp, "%s\n",save_host);
  1271. X  fclose (fp);
  1272. }
  1273. SHAR_EOF
  1274. chmod 0644 orig_disp.c ||
  1275. echo 'restore of orig_disp.c failed'
  1276. Wc_c="`wc -c < 'orig_disp.c'`"
  1277. test 17617 -eq "$Wc_c" ||
  1278.     echo 'orig_disp.c: original size 17617, current size' "$Wc_c"
  1279. rm -f _shar_wnt_.tmp
  1280. fi
  1281. # ============= patchlevel.h ==============
  1282. if test -f 'patchlevel.h' -a X"$1" != X"-c"; then
  1283.     echo 'x - skipping patchlevel.h (File already exists)'
  1284.     rm -f _shar_wnt_.tmp
  1285. else
  1286. > _shar_wnt_.tmp
  1287. echo 'x - extracting patchlevel.h (Text)'
  1288. sed 's/^X//' << 'SHAR_EOF' > 'patchlevel.h' &&
  1289. /* Andrew Peebles */
  1290. /* $Header$ */
  1291. X
  1292. X
  1293. #define PATCHLEVEL    0
  1294. SHAR_EOF
  1295. chmod 0644 patchlevel.h ||
  1296. echo 'restore of patchlevel.h failed'
  1297. Wc_c="`wc -c < 'patchlevel.h'`"
  1298. test 59 -eq "$Wc_c" ||
  1299.     echo 'patchlevel.h: original size 59, current size' "$Wc_c"
  1300. rm -f _shar_wnt_.tmp
  1301. fi
  1302. # ============= utils.c ==============
  1303. if test -f 'utils.c' -a X"$1" != X"-c"; then
  1304.     echo 'x - skipping utils.c (File already exists)'
  1305.     rm -f _shar_wnt_.tmp
  1306. else
  1307. > _shar_wnt_.tmp
  1308. echo 'x - extracting utils.c (Text)'
  1309. sed 's/^X//' << 'SHAR_EOF' > 'utils.c' &&
  1310. /***************************************************************************
  1311. X *
  1312. X * FILE NAME        : utils.c
  1313. X *
  1314. X * AUTHOR        : Andrew Peebles
  1315. X *
  1316. X * DESCRIPTION        : Utility functions for xphone
  1317. X *
  1318. X * VERSIONS        : %W%
  1319. X *
  1320. X ***************************************************************************/
  1321. X
  1322. /*
  1323. X * standard includes
  1324. X */
  1325. #include <stdio.h>
  1326. #include <string.h>
  1327. #include <Xm/Text.h>
  1328. #include <Xm/PanedW.h>
  1329. #include <Xm/RowColumn.h>
  1330. #include <Xm/Label.h>
  1331. #include <Xm/PushB.h>
  1332. #include <Xm/Form.h>
  1333. #include <X11/Shell.h>
  1334. #include <Xm/SelectioB.h>
  1335. #include <X11/cursorfont.h>
  1336. X
  1337. #include "xphone.h"
  1338. #include "xmsg.icon"
  1339. X
  1340. extern    Display *o_display;
  1341. X
  1342. XXtTranslations  trans;
  1343. static char trans_string[] = "<Key>F3: PassToken()";
  1344. void PassToken();
  1345. static XtActionsRec actionsList[] = {
  1346. X  { "PassToken", PassToken },
  1347. };
  1348. X
  1349. void LocalModify();
  1350. static XtCallbackRec LocalModifyCB[] = {
  1351. X  {LocalModify, NULL},
  1352. X  {NULL,        NULL},
  1353. };
  1354. X
  1355. extern char *CURRENTLY_SPEAKING;
  1356. extern char *progname;
  1357. Widget    C_VPANE;
  1358. X
  1359. Party *
  1360. XXpCreateParty (display_name,
  1361. X           originator,
  1362. X           username,
  1363. X           rdisplay)
  1364. char    *display_name;
  1365. char    *originator;
  1366. char    *username;
  1367. Display    *rdisplay;
  1368. /*
  1369. X * Create and display a party on a remote display
  1370. X */
  1371. {
  1372. X  int        n;
  1373. X  Arg        args[20];
  1374. X  Widget    toplevel, top;
  1375. X  Party        *party;
  1376. X  char        title[128];
  1377. X  Cursor    cursor;
  1378. X  char        *av[1];
  1379. X  int        ac = 1;
  1380. X  Pixmap      icon_pixmap;
  1381. X  XWMHints     wmhints;
  1382. X  char        *res_string;
  1383. X
  1384. X  av[0] = "xparty";
  1385. X
  1386. X  party = (Party *) XtMalloc (sizeof(Party));
  1387. X
  1388. /***
  1389. X
  1390. X  party->display = XtOpenDisplay (xphone,
  1391. X                  display_name,
  1392. X                  "xparty",
  1393. X                  "XParty",
  1394. X                  NULL, 0,
  1395. X                  &ac, av);
  1396. X
  1397. ***/
  1398. X  party->display = rdisplay;
  1399. X
  1400. X  if (!party->display) {
  1401. X    XpWarning (display_name, "Couldn't open display");
  1402. X    party->dead = True;
  1403. X    return (party);
  1404. X  }
  1405. X
  1406. X  toplevel = XtAppCreateShell("xparty", "XParty",
  1407. X                  applicationShellWidgetClass,
  1408. X                  party->display, NULL, 0);
  1409. X  
  1410. X  sprintf (title, "xphone call from %s", originator);
  1411. X  n = SetArgs (args, XmNtitle, title, NULL);
  1412. X
  1413. X  party->top = 
  1414. X  top = XtCreatePopupShell ("xphone",
  1415. X                topLevelShellWidgetClass,
  1416. X                toplevel, args, n);
  1417. X
  1418. X  party->token = False;
  1419. X  party->dead = False;
  1420. X  party->hostname = DisplayString (party->display);
  1421. X  party->username = username;
  1422. X  party->list_posted = False;
  1423. X
  1424. X  XpMakeDialog (top, party, originator, username);
  1425. X
  1426. X  XtRealizeWidget (top);
  1427. X  if (LIST_WIDGETS)
  1428. X    ListWidgetNames (top);
  1429. X
  1430. X  XtUnmanageChild (party->box);
  1431. X  n = SetArgs (args,
  1432. X           XmNrightAttachment, XmATTACH_FORM,
  1433. X           NULL);
  1434. X  XtSetValues (C_VPANE, args, n);
  1435. X  XtManageChild (party->box);
  1436. X
  1437. X  if ((res_string = XGetDefault(XtDisplay(top),
  1438. X                progname,
  1439. X                "tokenKey")))
  1440. X    trans = XtParseTranslationTable(res_string);
  1441. X  else
  1442. X    trans = XtParseTranslationTable(trans_string);
  1443. X  XtOverrideTranslations(party->send, trans);
  1444. X  
  1445. X  if ((cursor = XCreateFontCursor(party->display, XC_left_ptr)) == -1)
  1446. X    perror ("Screwed up cursor");
  1447. X
  1448. X  /*
  1449. X   * There is some kind of protocol problem with cursors and
  1450. X   * remote displays.  This bit of code seems to help a little.
  1451. X   */
  1452. X  XDefineCursor (party->display, XtWindow (top), cursor);
  1453. X  XDefineCursor (party->display, XtWindow (party->box), None);
  1454. X  XDefineCursor (party->display, XtWindow (party->send), None);
  1455. X  XDefineCursor (party->display, XtWindow (party->recv), None);
  1456. X
  1457. X  XtPopup (top, XtGrabNone);
  1458. X
  1459. X        /*
  1460. X         * A new one for me, supply a default icon in case the user doesn't
  1461. X         */
  1462. X        icon_pixmap = XCreateBitmapFromData (XtDisplay(top),
  1463. X                                             XtWindow(top),
  1464. X                                             xmsg_bits, xmsg_width,
  1465. X                                             xmsg_height);
  1466. X        wmhints.icon_pixmap = icon_pixmap;
  1467. X        wmhints.flags = IconPixmapHint;
  1468. X
  1469. X        XSetWMHints (XtDisplay(top), XtWindow(top), &wmhints);
  1470. X
  1471. X  return (party);
  1472. }
  1473. X
  1474. XXpMakeDialog (top, party, caller, username)
  1475. Widget top;
  1476. Party  *party;
  1477. char   *caller;
  1478. char   *username;
  1479. {
  1480. X  int   n;
  1481. X  Arg   args[20];
  1482. X  Widget btn, rc, vpane, help, post, pop, ota;
  1483. X  void    hangup_cb(), help_cb(), pop_ota();
  1484. X  char    *buf[80];
  1485. X  Widget CreateOTA();
  1486. X
  1487. X  n = 0;
  1488. X  party->box = XmCreateForm (top,
  1489. X                 "form",
  1490. X                 args, n);
  1491. X  XtManageChild (party->box);
  1492. X
  1493. X  n = SetArgs (args,
  1494. X           XmNtopAttachment, XmATTACH_FORM,
  1495. X           XmNleftAttachment, XmATTACH_FORM,
  1496. X           XmNalignment, XmALIGNMENT_BEGINNING,
  1497. X           NULL);
  1498. X  party->talking = XmCreateLabel (party->box,
  1499. X                  "speaking",
  1500. X                  args, n);
  1501. X  XtManageChild (party->talking);
  1502. X
  1503. X  sprintf (buf,"Speaking: %s",CURRENTLY_SPEAKING);
  1504. X  n = SetArgs (args,
  1505. X           XmNlabelString, XmStringCreateLtoR(buf,
  1506. X                          XmSTRING_DEFAULT_CHARSET),
  1507. X           NULL);
  1508. X  XtSetValues (party->talking, args, n);
  1509. X  
  1510. X  n = SetArgs (args,
  1511. X           XmNtopAttachment, XmATTACH_WIDGET,
  1512. X           XmNtopWidget, party->talking,
  1513. X           XmNleftAttachment, XmATTACH_FORM,
  1514. X           NULL);
  1515. X  C_VPANE = 
  1516. X  vpane = XmCreatePanedWindow (party->box,
  1517. X                   "vpane",
  1518. X                   args, n);
  1519. X  XtManageChild (vpane);
  1520. X
  1521. X  n = SetArgs (args,
  1522. X               XmNeditable, False,
  1523. X               XmNeditMode, XmMULTI_LINE_EDIT,
  1524. X               XmNwordWrap, True,
  1525. X               XmNautoShowCursorPosition, True,
  1526. X               XmNcursorPositionVisible, True,
  1527. X           XmNscrollHorizontal, False,
  1528. X           XmNrows,    15,
  1529. X           XmNcolumns, 40,
  1530. X           XmNvalue, "",
  1531. X               NULL);
  1532. X  party->recv = XmCreateScrolledText (vpane,
  1533. X                       "remote",
  1534. X                       args, n);
  1535. X  XtManageChild (party->recv);
  1536. X
  1537. X  bzero (buf,80);
  1538. X  sprintf (buf,"\n%s: ",CURRENTLY_SPEAKING);
  1539. X  XmTextSetString (party->recv, buf);
  1540. X
  1541. X  n = SetArgs (args,
  1542. X               XmNeditable, False,
  1543. X               XmNeditMode, XmMULTI_LINE_EDIT,
  1544. X               XmNwordWrap, True,
  1545. X               XmNautoShowCursorPosition, True,
  1546. X               XmNcursorPositionVisible, True,
  1547. X           XmNscrollHorizontal, False,
  1548. X           XmNrows,    15,
  1549. X           XmNcolumns, 40,
  1550. X           XmNvalue, "",
  1551. X
  1552. X               XmNmodifyVerifyCallback, LocalModifyCB,
  1553. X               NULL);
  1554. X  party->send = XmCreateScrolledText (vpane,
  1555. X                       "local",
  1556. X                       args, n);
  1557. X  XtManageChild (party->send);
  1558. X  XmAddTabGroup (party->send);
  1559. X
  1560. X  n = SetArgs (args,
  1561. X           XmNleftAttachment, XmATTACH_FORM,
  1562. X           XmNtopAttachment, XmATTACH_WIDGET,
  1563. X           XmNtopWidget, vpane,
  1564. X           NULL);
  1565. X  btn = XmCreatePushButton (party->box,
  1566. X                "hangup",
  1567. X                args, n);
  1568. X  XtManageChild (btn);
  1569. X
  1570. X  XtAddCallback (btn, XmNactivateCallback, hangup_cb, party);
  1571. X
  1572. X  n = SetArgs (args,
  1573. X           XmNalignment, XmALIGNMENT_CENTER,
  1574. X           XmNleftAttachment, XmATTACH_WIDGET,
  1575. X           XmNleftWidget, btn,
  1576. X           XmNtopAttachment, XmATTACH_WIDGET,
  1577. X           XmNtopWidget, vpane,
  1578. X           NULL);
  1579. X  party->status = XmCreateLabel (party->box,
  1580. X                 "status",
  1581. X                 args, n);
  1582. X  XtManageChild (party->status);
  1583. X
  1584. X  sprintf (buf,"WAIT ...");
  1585. X  n = SetArgs (args,
  1586. X           XmNlabelString, XmStringCreateLtoR(buf,
  1587. X                          XmSTRING_DEFAULT_CHARSET),
  1588. X           NULL);
  1589. X  XtSetValues (party->status, args, n);
  1590. X
  1591. X  n = SetArgs (args,
  1592. X           XmNtopAttachment, XmATTACH_WIDGET,
  1593. X           XmNtopWidget, vpane,
  1594. X           XmNrightAttachment, XmATTACH_FORM,
  1595. X           NULL);
  1596. X  help = XmCreatePushButton (party->box,
  1597. X                 "help",
  1598. X                 args, n);
  1599. X  XtManageChild (help);
  1600. X  XtAddCallback (help, XmNactivateCallback, help_cb, party->box);
  1601. X
  1602. X  n = SetArgs (args,
  1603. X           XmNtopAttachment, XmATTACH_WIDGET,
  1604. X           XmNtopWidget, vpane,
  1605. X           XmNrightAttachment, XmATTACH_WIDGET,
  1606. X           XmNrightWidget, help,
  1607. X           NULL);
  1608. X  pop = XmCreatePushButton (party->box,
  1609. X                "line",
  1610. X                args, n);
  1611. X  XtManageChild (pop);
  1612. X
  1613. X  ota = CreateOTA (top, party, caller, username);
  1614. X  XtAddCallback (pop, XmNactivateCallback, pop_ota, ota);
  1615. }
  1616. X
  1617. X
  1618. XXpNewPartyStart (party)
  1619. char    *party;
  1620. /*
  1621. X * put the party name into the "text" widget.  This routine is used
  1622. X * when the token gets passed to a new party, this routine is called
  1623. X * for each OTHER party on the line.
  1624. X */
  1625. {
  1626. X  char    *buf;
  1627. X  int    size;
  1628. X  int    i;
  1629. X  Arg    args[5];
  1630. X  Arg    args2[5];
  1631. X  char    title[80];
  1632. X  char    title2[80];
  1633. X
  1634. X  CURRENTLY_SPEAKING = party;
  1635. X
  1636. X  sprintf (title,"Speaking: %s",party);
  1637. X  sprintf (title2,"Speaking: YOU");
  1638. X
  1639. X  SetArgs (args,
  1640. X       XmNlabelString, XmStringCreateLtoR (title,
  1641. X                           XmSTRING_DEFAULT_CHARSET),
  1642. X       NULL);
  1643. X  SetArgs (args2,
  1644. X       XmNlabelString, XmStringCreateLtoR (title2,
  1645. X                           XmSTRING_DEFAULT_CHARSET),
  1646. X       NULL);
  1647. X
  1648. X  for (i=0; i<num_parties; i++) {
  1649. X    if (parties[i]->token) {
  1650. X      XtSetValues (parties[i]->talking, args2, 1);
  1651. X      continue;
  1652. X    }
  1653. X    if (parties[i]->dead)
  1654. X      continue;
  1655. X
  1656. X    buf = XmTextGetString (parties[i]->recv);
  1657. X    size = strlen (buf);
  1658. X
  1659. X    XtFree (buf);
  1660. X  
  1661. X    buf = (char *) XtMalloc (strlen(party) + 5);
  1662. X    sprintf (buf,"\n%s: ",party);
  1663. X
  1664. X    XmTextReplace (parties[i]->recv, size, size, "\n");
  1665. X    ++size;
  1666. X    XmTextReplace (parties[i]->recv, size, size, party);
  1667. X    size += strlen(party);
  1668. X    XmTextReplace (parties[i]->recv, size, size, ":");
  1669. X    ++size;
  1670. X    XmTextReplace (parties[i]->recv, size, size, " ");
  1671. X
  1672. X    XtSetValues (parties[i]->talking, args, 1);
  1673. X  }
  1674. }
  1675. X
  1676. X
  1677. void
  1678. LocalModify(w, call, info)
  1679. Widget  w;
  1680. caddr_t call;
  1681. XXmTextVerifyCallbackStruct *info;
  1682. {
  1683. X  char  *buf;
  1684. X  int   size;
  1685. X  int    i;
  1686. X
  1687. X  for (i=0; i<num_parties; i++) {
  1688. X    if (parties[i]->token)
  1689. X      continue;
  1690. X    if (parties[i]->dead)
  1691. X      continue;
  1692. X    buf = XmTextGetString (parties[i]->recv);
  1693. X    size = strlen (buf);
  1694. X    if (info->text->ptr == NULL) {
  1695. X      buf[size-1] = '\0';
  1696. X      XmTextReplace (parties[i]->recv,size-1,size,"\0");
  1697. X      XmTextSetInsertionPosition (parties[i]->recv,
  1698. X                  (strlen(buf)));
  1699. X    }
  1700. X    else {
  1701. X      info->text->ptr[info->text->length] = '\0';
  1702. X      XmTextReplace (parties[i]->recv,size,size,info->text->ptr);
  1703. X      XmTextSetInsertionPosition (parties[i]->recv,
  1704. X                  (size+info->text->length));
  1705. X    }
  1706. X    XtFree (buf);
  1707. X  }
  1708. }
  1709. X
  1710. static int first = True;
  1711. void
  1712. PassToken (w, call, client)
  1713. Widget    w;
  1714. caddr_t    call;
  1715. caddr_t client;
  1716. /*
  1717. X * The party w/ the token has just decided to pass it along to the
  1718. X * next party.  We'll search the parties array until we find the 
  1719. X * token owner, then perform the junk to pass it along.  We'll check
  1720. X * the passing party's list widget to see if they've selected a
  1721. X * person to pass the token to.
  1722. X */
  1723. {
  1724. X  int    i;
  1725. X  Party *new_party, *FindParty();
  1726. X  int    n;
  1727. X  Arg    args1[5], args2[5], args[5];
  1728. X  char    *go = "GO!";
  1729. X  char    *wait = "WAIT ...";
  1730. X  Boolean found;
  1731. X  int    index;
  1732. X  XmString *selection;
  1733. X  int       num_selection;
  1734. X  char       *sperson;
  1735. X  
  1736. X  XtSetArg (args1[0],
  1737. X        XmNlabelString,
  1738. X        XmStringCreateLtoR(wait,XmSTRING_DEFAULT_CHARSET));
  1739. X  XtSetArg (args2[0],
  1740. X        XmNlabelString,
  1741. X        XmStringCreateLtoR(go,XmSTRING_DEFAULT_CHARSET));
  1742. X
  1743. X  for (i=0; i<num_parties; i++) {
  1744. X    if (parties[i]->send == w) {
  1745. X      if (parties[i]->token == False) {
  1746. X    XBell (parties[i]->display, 100);
  1747. X    first = False;
  1748. X    return;
  1749. X      }
  1750. X      parties[i]->token = False;
  1751. X      XtSetValues (parties[i]->status, args1, 1);
  1752. X      XmTextSetEditable (parties[i]->send, False);
  1753. X
  1754. X      n = SetArgs (args,
  1755. X           XmNselectedItemCount, &num_selection,
  1756. X           XmNselectedItems, &selection,
  1757. X           NULL);
  1758. X      XtGetValues (parties[i]->list, args, n);
  1759. X
  1760. X      if (num_selection == 1) {
  1761. X    XmStringGetLtoR (selection[0],
  1762. X             XmSTRING_DEFAULT_CHARSET,
  1763. X             &sperson);
  1764. X    if ((new_party = FindParty (sperson)) == NULL) {
  1765. X      if (i == (num_parties-1)) {
  1766. X        index = 0;
  1767. X        new_party = parties[0];
  1768. X      }
  1769. X      else {
  1770. X        index = i+1;
  1771. X        new_party = parties[i+1];
  1772. X      }
  1773. X    }
  1774. X    XmListDeselectAllItems (parties[i]->list);
  1775. X      }
  1776. X      else {
  1777. X    if (i == (num_parties-1)) {
  1778. X      index = 0;
  1779. X      new_party = parties[0];
  1780. X    }
  1781. X    else {
  1782. X      index = i+1;
  1783. X      new_party = parties[i+1];
  1784. X    }
  1785. X      }
  1786. X
  1787. X      found = False;
  1788. X      while (!found) {
  1789. X    if (new_party->send == parties[i]->send) {
  1790. X      Warning (parties[i]->top, "No one left on the line.");
  1791. X      return;
  1792. X    }
  1793. X    if (new_party->dead) {
  1794. X      if (index == num_parties-1) {
  1795. X        index = 0;
  1796. X        new_party = parties[index];
  1797. X      }
  1798. X      else {
  1799. X        ++index;
  1800. X        new_party = parties[index];
  1801. X      }
  1802. X    }
  1803. X    else {
  1804. X      found = True;
  1805. X    }
  1806. X      }
  1807. X
  1808. X      new_party->token = True;
  1809. X      XtSetValues (new_party->status, args2, 1);
  1810. X      XBell (new_party->display, 100);
  1811. X      XmTextSetEditable (new_party->send, True);
  1812. X      XpNewPartyStart (new_party->username);
  1813. X      first = False;
  1814. X      return;
  1815. X    }
  1816. X    else if (first) {
  1817. X      XtSetValues (parties[i]->status, args1, 1);
  1818. X    }
  1819. X  }
  1820. X  first = False;
  1821. X
  1822. X  /*
  1823. X   * if we get here, the token was lost.  we'll give it to the 
  1824. X   * originator.
  1825. X   */
  1826. X  XpWarning (parties[0]->hostname, "TOKEN INHERITED");
  1827. X  parties[0]->token = True;
  1828. X  XmTextSetEditable (parties[0]->send, True);
  1829. X  XpNewPartyStart (parties[0]->username);
  1830. }
  1831. X
  1832. Party *
  1833. FindParty (name)
  1834. char    *name;
  1835. {
  1836. X  int     i;
  1837. X
  1838. X  for (i=0; i<num_parties; i++) {
  1839. X    if (strcmp(parties[i]->username,name) == 0) 
  1840. X      return (parties[i]);
  1841. X  }
  1842. X  return (NULL);
  1843. }
  1844. X
  1845. StealToken ()
  1846. /*
  1847. X * The originator wants the token, we'll rip it from under the guy
  1848. X * who's currently got it and give it to the originator, and update
  1849. X * everybody's displays.
  1850. X */
  1851. {
  1852. X  int    i;
  1853. X  Party *new_party;
  1854. X  int    n;
  1855. X  Arg    args1[5], args2[5];
  1856. X  char    *go = "GO!";
  1857. X  char    *wait = "WAIT ...";
  1858. X  Boolean found;
  1859. X  int    index;
  1860. X
  1861. X  XtSetArg (args1[0],
  1862. X        XmNlabelString,
  1863. X        XmStringCreateLtoR(wait,XmSTRING_DEFAULT_CHARSET));
  1864. X  XtSetArg (args2[0],
  1865. X        XmNlabelString,
  1866. X        XmStringCreateLtoR(go,XmSTRING_DEFAULT_CHARSET));
  1867. X
  1868. X  for (i=0; i<num_parties; i++) {
  1869. X    if (parties[i]->token == False) {
  1870. X      continue;
  1871. X    }
  1872. X
  1873. X    parties[i]->token = False;
  1874. X    XtSetValues (parties[i]->status, args1, 1);
  1875. X    XmTextSetEditable (parties[i]->send, False);
  1876. X    break;
  1877. X  }
  1878. X  new_party = parties[0];
  1879. X
  1880. X  new_party->token = True;
  1881. X  XtSetValues (new_party->status, args2, 1);
  1882. X  XBell (new_party->display, 100);
  1883. X  XmTextSetEditable (new_party->send, True);
  1884. X  XpNewPartyStart (new_party->username);
  1885. }
  1886. X      
  1887. XXpSetInitialStatus()
  1888. {
  1889. X  int    i;
  1890. X  Arg    args[5];
  1891. X  char    *wait = "WAIT ...";
  1892. X
  1893. X  XtSetArg (args[0],
  1894. X        XmNlabelString,
  1895. X        XmStringCreateLtoR(wait,XmSTRING_DEFAULT_CHARSET));
  1896. X
  1897. X  for (i=1; i<num_parties; i++)
  1898. X    XtSetValues (parties[i]->status, args, 1);
  1899. }
  1900. X
  1901. XXpWarning (dis, err)
  1902. char    *dis, *err;
  1903. {
  1904. X  extern    Widget o_top;
  1905. X  char        msg[128];
  1906. X
  1907. X  sprintf (msg,"%s : %s",dis, err);
  1908. X  Warning (o_top, msg);
  1909. }
  1910. X
  1911. void
  1912. hangup_cb (w, party, client)
  1913. Widget    w;
  1914. Party    *party;
  1915. caddr_t    client;
  1916. {
  1917. X  XtPopdown (party->top);
  1918. X  party->dead = True;
  1919. X  if (party->token)
  1920. X    PassToken (party->send, NULL, NULL);
  1921. X  XpRemoveFromAir (party->username);
  1922. /**
  1923. X  XtDestroyWidget (party->top);
  1924. X  if (strcmp (o_display->display_name, party->display->display_name) != 0)
  1925. X    XtCloseDisplay (party->display); 
  1926. **/
  1927. }
  1928. X
  1929. XXpRemoveFromAir (user)
  1930. char    *user;
  1931. {
  1932. X  int    i;
  1933. X  Arg    args[5];
  1934. X  int    icount;
  1935. X
  1936. X  for (i=0; i<num_parties; i++) {
  1937. X    if (parties[i]->dead) 
  1938. X      continue;
  1939. X    if (!parties[i]->list_posted)
  1940. X      continue;
  1941. X    XmListDeleteItem (parties[i]->list,
  1942. X              XmStringCreateLtoR(user,XmSTRING_DEFAULT_CHARSET));
  1943. X  }
  1944. X  /*
  1945. X   * Check the originator list, if its empty, then set the originator
  1946. X   * display back to default.
  1947. X   */
  1948. X  XtSetArg (args[0], XmNitemCount, &icount);
  1949. X  XtGetValues (parties[0]->list, args, 1);
  1950. X  if (icount == 0)
  1951. X    InitOriginator();
  1952. }
  1953. X
  1954. XXpOnTheAir (user)
  1955. char    *user;
  1956. {
  1957. X  int i;
  1958. X  extern Widget O_HANGUP;
  1959. X
  1960. X  for (i=0; i<num_parties; i++) {
  1961. X    if (parties[i]->dead)
  1962. X      continue;
  1963. X    if (!parties[i]->list_posted) 
  1964. X      continue;
  1965. X    XmListAddItem (parties[i]->list,
  1966. X           XmStringCreateLtoR(user,XmSTRING_DEFAULT_CHARSET),
  1967. X           0);
  1968. X  }
  1969. X  XtSetSensitive (O_HANGUP, False);
  1970. }
  1971. X
  1972. /*
  1973. X * Called when the help button gets pressed.  
  1974. X */
  1975. static char HELP_STR[] = "\
  1976. You are on a `party line' where you may exchange messages with others\n\
  1977. on the line.  Only one person can speak at a time, and is shown in the\n\
  1978. top of the display.  You may speak when you get the `token', and the status\n\
  1979. line says \"GO!\" by typing in the lower text window.  When you are done\n\
  1980. speaking, hit the F3 key to pass the token on to the next person on the line.\n\
  1981. \n\
  1982. Push the `hangup' button when you wish to leave the conversation.";
  1983. X
  1984. void
  1985. help_cb (w, ref, call)
  1986. Widget    w, ref;
  1987. caddr_t call;
  1988. {
  1989. X  Warning (ref, HELP_STR);
  1990. }
  1991. X
  1992. X
  1993. /*
  1994. X * Routines for the on_the_air popup
  1995. X */
  1996. void 
  1997. pop_ota (w, shell, call)
  1998. Widget    w, shell;
  1999. caddr_t    call;
  2000. {
  2001. X  XtManageChild (shell);
  2002. }
  2003. X
  2004. Widget
  2005. CreateOTA (ref, party, caller, user)
  2006. Widget ref;
  2007. Party *party;
  2008. char  *caller;
  2009. char  *user;
  2010. {
  2011. X  Widget    top, tmp;
  2012. X  XmStringCharSet char_set = (XmStringCharSet) XmSTRING_DEFAULT_CHARSET;
  2013. X  Arg   args[10];
  2014. X  int   n;
  2015. X  XmString     *sl;
  2016. X  int           sc;
  2017. X
  2018. X  n = SetArgs (args,
  2019. X           XmNitems, &sl,
  2020. X           XmNitemCount, &sc,
  2021. X           NULL);
  2022. X  XtGetValues (parties[0]->list, args, n);
  2023. X
  2024. X  n = SetArgs (args,
  2025. X               XmNselectionLabelString, XmStringLtoRCreate ("On The Air",
  2026. X                                char_set),
  2027. X           XmNcancelLabelString, XmStringCreateLtoR ("Hide",
  2028. X                             char_set),
  2029. X           XmNlistItems, sl,
  2030. X           XmNlistItemCount, sc,
  2031. X           NULL);
  2032. X  top = XmCreateSelectionDialog (ref,
  2033. X                    "ota",
  2034. X                    args, n);
  2035. X  tmp = XmSelectionBoxGetChild (top, XmDIALOG_OK_BUTTON);
  2036. X  XtUnmanageChild (tmp);
  2037. X  tmp = XmSelectionBoxGetChild (top, XmDIALOG_HELP_BUTTON);
  2038. X  XtUnmanageChild (tmp);
  2039. X  tmp = XmSelectionBoxGetChild (top, XmDIALOG_LIST);
  2040. X
  2041. X  XmListAddItem (tmp, XmStringCreateLtoR (caller, char_set), 0);
  2042. X  XmListDeleteItem (tmp, XmStringCreateLtoR (user, char_set));
  2043. X
  2044. X  party->list = tmp;
  2045. X  party->list_posted = True;
  2046. X  return (top);
  2047. }
  2048. SHAR_EOF
  2049. chmod 0644 utils.c ||
  2050. echo 'restore of utils.c failed'
  2051. Wc_c="`wc -c < 'utils.c'`"
  2052. test 17408 -eq "$Wc_c" ||
  2053.     echo 'utils.c: original size 17408, current size' "$Wc_c"
  2054. rm -f _shar_wnt_.tmp
  2055. fi
  2056. # ============= xmsg.icon ==============
  2057. if test -f 'xmsg.icon' -a X"$1" != X"-c"; then
  2058.     echo 'x - skipping xmsg.icon (File already exists)'
  2059.     rm -f _shar_wnt_.tmp
  2060. else
  2061. > _shar_wnt_.tmp
  2062. echo 'x - extracting xmsg.icon (Text)'
  2063. sed 's/^X//' << 'SHAR_EOF' > 'xmsg.icon' &&
  2064. #define xmsg_width 50
  2065. #define xmsg_height 50
  2066. static char xmsg_bits[] = {
  2067. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  2068. X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
  2069. X   0xf0, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xc6, 0x00, 0x00, 0x00,
  2070. X   0x00, 0x00, 0x06, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x04, 0x00,
  2071. X   0x00, 0x00, 0x00, 0xe0, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00,
  2072. X   0xc6, 0x01, 0x00, 0x10, 0x00, 0x1c, 0xfe, 0x03, 0x06, 0x00, 0x10, 0x00,
  2073. X   0x87, 0x03, 0x10, 0x0c, 0x00, 0x20, 0xc0, 0xe1, 0x00, 0x31, 0x00, 0x00,
  2074. X   0x20, 0x70, 0x30, 0x00, 0x21, 0x00, 0x00, 0x20, 0x1c, 0x18, 0x80, 0x20,
  2075. X   0x00, 0x00, 0x06, 0x06, 0x0e, 0x40, 0x00, 0x00, 0x00, 0x84, 0xc3, 0x03,
  2076. X   0x60, 0x00, 0x00, 0x00, 0xc0, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
  2077. X   0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0xc0, 0x00, 0x60, 0x00,
  2078. X   0x00, 0x10, 0x20, 0xa0, 0x00, 0x50, 0x00, 0x00, 0x17, 0x30, 0x90, 0xfe,
  2079. X   0x49, 0x00, 0x00, 0x30, 0x18, 0x8a, 0x00, 0x44, 0x01, 0x00, 0xe0, 0x0f,
  2080. X   0x49, 0x00, 0x24, 0x01, 0x00, 0x60, 0x80, 0x28, 0x00, 0x14, 0x01, 0x00,
  2081. SHAR_EOF
  2082. true || echo 'restore of xmsg.icon failed'
  2083. fi
  2084. echo 'End of  part 3'
  2085. echo 'File xmsg.icon is continued in part 4'
  2086. echo 4 > _shar_seq_.tmp
  2087. exit 0
  2088. -- 
  2089. --
  2090. Molecular Simulations, Inc.            mail: dcmartin@msi.com
  2091. 796 N. Pastoria Avenue                uucp: uunet!dcmartin
  2092. Sunnyvale, California 94086            at&t: 408/522-9236
  2093.