home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / comprgs / term232.lha / Source_Code / termSource / DialPanel.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-18  |  30.8 KB  |  1,326 lines

  1. /*
  2. **    $Id: DialPanel.c,v 1.12 92/08/18 16:11:10 olsen Sta Locker: olsen $
  3. **    $Revision: 1.12 $
  4. **    $Date: 92/08/18 16:11:10 $
  5. **
  6. **    The dialing routine as called by the phonebook
  7. **
  8. **    Copyright ⌐ 1990-1992 by Olaf `Olsen' Barthel & MXM
  9. **        All Rights Reserved
  10. */
  11.  
  12. #include "termGlobal.h"
  13.  
  14.     /* Panel gadget IDs. */
  15.  
  16. enum    {    GAD_SKIP,GAD_REMOVE,GAD_ONLINE,GAD_ABORT,
  17.         GADGET_COUNT };
  18.  
  19.     /* Panel box IDs. */
  20.  
  21. enum    {    BOX_CALL_NUMBER_NEXT,BOX_TIME_TRY,BOX_MESSAGE,
  22.         BOX_COUNT };
  23.  
  24.     /* CreateAllGadgets():
  25.      *
  26.      *    Create all gadgets required by the dial panel.
  27.      */
  28.  
  29. STATIC struct Gadget *
  30. CreateAllGadgets(struct TextBox **BoxArray,struct TextBox **BoxList,struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
  31. {
  32.     struct Gadget        *Gadget;
  33.     struct NewGadget     NewGadget;
  34.     UWORD             Counter = 0,BoxCounter = 0;
  35.     struct TextBox        *Box;
  36.  
  37.     memset(&NewGadget,0,sizeof(struct NewGadget));
  38.  
  39.     SZ_SizeSetup(Screen,&UserFont,TRUE);
  40.  
  41.     if(Gadget = CreateContext(GadgetList))
  42.     {
  43.         LONG ButtonWidth;
  44.  
  45.         SZ_AddLeftOffset(SZ_LeftOffsetN(MSG_DIALPANEL_CALLING_TXT,MSG_DIALPANEL_NUMBER_TXT,MSG_DIALPANEL_NEXT_TXT,MSG_DIALPANEL_TIMEOUT_TXT,MSG_DIALPANEL_ATTEMPT_TXT,MSG_DIALPANEL_MESSAGE_TXT,-1));
  46.  
  47.         SZ_ResetMaxWidth();
  48.  
  49.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_DIALPANEL_SKIP_GAD),0,NULL);
  50.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_REMOVE_GAD),0,NULL);
  51.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD),0,NULL);
  52.         SZ_UpdateMaxWidth(BUTTON_KIND,LocaleString(MSG_GLOBAL_ABORT_GAD),0,NULL);
  53.  
  54.         ButtonWidth = SZ_ResetMaxWidth();
  55.  
  56.         if(ButtonWidth * 4 + 3 * InterWidth > SZ_BoxWidth(45))
  57.             SZ_SetWidth(ButtonWidth * 4 + 3 * InterWidth);
  58.         else
  59.             SZ_SetWidth(SZ_BoxWidth(45));
  60.  
  61.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  62.             SZ_Chars,    45,
  63.             SZ_Lines,    3,
  64.             SZ_AutoWidth,    TRUE,
  65.         TAG_DONE);
  66.  
  67.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_CALLING_TXT),LocaleString(MSG_DIALPANEL_NUMBER_TXT),LocaleString(MSG_DIALPANEL_NEXT_TXT),NULL);
  68.  
  69.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  70.             SZ_Chars,    45,
  71.             SZ_Lines,    2,
  72.             SZ_AutoWidth,    TRUE,
  73.         TAG_DONE);
  74.  
  75.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_TIMEOUT_TXT),LocaleString(MSG_DIALPANEL_ATTEMPT_TXT),NULL);
  76.  
  77.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  78.             SZ_Chars,    45,
  79.             SZ_Lines,    1,
  80.             SZ_AutoWidth,    TRUE,
  81.         TAG_DONE);
  82.  
  83.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_MESSAGE_TXT),NULL);
  84.  
  85.         if(!Box)
  86.             return(NULL);
  87.  
  88.         NewGadget . ng_TextAttr        = &UserFont;
  89.         NewGadget . ng_VisualInfo    = VisualInfo;
  90.         NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_SKIP_GAD);
  91.         NewGadget . ng_GadgetID        = Counter;
  92.  
  93.         SZ_SetWidth(ButtonWidth);
  94.  
  95.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  96.             SZ_Adjust,    TRUE,
  97.             SZ_AutoWidth,    TRUE,
  98.             SZ_AlignExtra,    TRUE,
  99.             SZ_AlignBottom,    TRUE,
  100.             SZ_GroupCount,    4,
  101.  
  102.             GT_Underscore,    '_',
  103.         TAG_DONE);
  104.  
  105.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_REMOVE_GAD);
  106.         NewGadget . ng_GadgetID        = Counter;
  107.  
  108.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  109.             SZ_Adjust,    TRUE,
  110.             SZ_AutoWidth,    TRUE,
  111.             SZ_GroupNext,    TRUE,
  112.  
  113.             GT_Underscore,    '_',
  114.         TAG_DONE);
  115.  
  116.         NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD);
  117.         NewGadget . ng_GadgetID        = Counter;
  118.  
  119.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  120.             SZ_Adjust,    TRUE,
  121.             SZ_AutoWidth,    TRUE,
  122.             SZ_GroupNext,    TRUE,
  123.  
  124.             GT_Underscore,    '_',
  125.         TAG_DONE);
  126.  
  127.         NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_ABORT_GAD);
  128.         NewGadget . ng_GadgetID        = Counter;
  129.  
  130.         GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  131.             SZ_Adjust,    TRUE,
  132.             SZ_AutoWidth,    TRUE,
  133.             SZ_GroupNext,    TRUE,
  134.  
  135.             GT_Underscore,    '_',
  136.         TAG_DONE);
  137.     }
  138.  
  139.     return(Gadget);
  140. }
  141.  
  142.     /* DialPanel():
  143.      *
  144.      *    This routine opens a small window in the middle of the
  145.      *    console window and walks down the list of numbers to
  146.      *    dial.
  147.      */
  148.  
  149. BYTE
  150. DialPanel()
  151. {
  152.     STATIC WORD         PositionX = -1,
  153.                  PositionY = -1;
  154.  
  155.     struct Gadget        *GadgetList = NULL;
  156.     struct Gadget        *GadgetArray[GADGET_COUNT];
  157.     struct TextBox        *BoxList = NULL;
  158.     struct TextBox        *BoxArray[BOX_COUNT];
  159.     struct Window        *PanelWindow;
  160.     struct PhoneNode    *DialNode;
  161.     BYTE             Result = FALSE;
  162.  
  163.     ChosenEntry    = NULL;
  164.  
  165.         /* We are dialing. */
  166.  
  167.     Status = STATUS_DIALING;
  168.  
  169.         /* Create the gadgets. */
  170.  
  171.     if(CreateAllGadgets(&BoxArray[0],&BoxList,&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
  172.     {
  173.             /* At last, open the window. */
  174.  
  175.         if(PanelWindow = OpenWindowTags(NULL,
  176.             WA_Left,    (Screen -> Width    - SZ_GetWindowWidth())    / 2,
  177.             WA_Top,        (Screen -> Height    - SZ_GetWindowHeight())    / 2,
  178.             WA_Width,    SZ_GetWindowWidth(),
  179.             WA_Height,    SZ_GetWindowHeight(),
  180.  
  181.             WA_Activate,    TRUE,
  182.             WA_DragBar,    TRUE,
  183.             WA_DepthGadget,    TRUE,
  184.             WA_CloseGadget,    TRUE,
  185.             WA_RMBTrap,    TRUE,
  186.             WA_CustomScreen,Screen,
  187.  
  188.             WA_IDCMP,    IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | BUTTONIDCMP,
  189.  
  190.             WA_Title,    LocaleString(MSG_DIALPANEL_DIALING_TXT),
  191.         TAG_DONE))
  192.         {
  193.             struct IntuiMessage    *Massage;
  194.             ULONG             Class,Code;
  195.             struct Gadget        *Gadget;
  196.             LONG             RedialDelay = 0,DialTimeout,DialRetries,DialAttempt;
  197.             BYTE             Dialing,Terminated = FALSE;
  198.  
  199.             UBYTE             SomeBuffer[300],ExitString[80];
  200.             BYTE             RunCount = 0;
  201.  
  202.             UBYTE             NumberBuffer[40],    *NextNumber    = NULL,
  203.                          InitBuffer[80],    *NextInit    = NULL,
  204.                          ExitBuffer[80],    *NextExit    = NULL,
  205.                          PrefixBuffer[80],    *NextPrefix    = NULL;
  206.  
  207.             ExitString[0] = 0;
  208.  
  209.                 /* Make the current one the active one. */
  210.  
  211.             PushWindow(PanelWindow);
  212.  
  213.                 /* Make a backup of the current configuration. */
  214.  
  215.             CopyMem(&Config,&PrivateConfig,sizeof(struct Configuration));
  216.  
  217.                 /* Add the gadgets and refresh them. */
  218.  
  219.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  220.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  221.             GT_RefreshWindow(PanelWindow,NULL);
  222.  
  223.             SZ_DrawBoxes(PanelWindow -> RPort,BoxList);
  224.  
  225.                 /* Don't echo serial output. */
  226.  
  227.             Quiet        = TRUE;
  228.  
  229.                 /* Perform full sequence check. */
  230.  
  231.             FullCheck    = TRUE;
  232.  
  233.                 /* Reset the number of dial attempts. */
  234.  
  235.             DialAttempt    = 0;
  236.  
  237.                 /* Get the first dial list entry. */
  238.  
  239.             DialNode    = (struct PhoneNode *)DialList -> lh_Head;
  240.  
  241.                 /* The big dialing loop, implemented as a goto -> mark
  242.                  * loop rather than one of those classical while .. do
  243.                  * loops.
  244.                  */
  245.  
  246. Dial:            Dialing        = TRUE;
  247.  
  248.                 /* Reset the sequence scanner, the user may have skipped
  249.                  * the previous dial attempt causing the modem to return
  250.                  * `NO CARRIER'. To prevent the dialer from skipping the
  251.                  * next dial entry as well as the previous we have to
  252.                  * flush any data pending on the serial line.
  253.                  */
  254.  
  255.             HandleSerial();
  256.  
  257.             FlowInit();
  258.  
  259.             FullCheck = TRUE;
  260.  
  261.                 /* Now for multiple phone numbers separated
  262.                  * by `|' characters. If `NextNumber' happens
  263.                  * to be zero, we will prepare to extract
  264.                  * the first phone number from the list.
  265.                  * In any other case we will try to obtain
  266.                  * the next number.
  267.                  */
  268.  
  269.             if(NextNumber)
  270.             {
  271.                 NextNumber    = ExtractString(NextNumber,    NumberBuffer,TRUE);
  272.                 NextInit    = ExtractString(NextInit,    InitBuffer,FALSE);
  273.                 NextExit    = ExtractString(NextExit,    ExitBuffer,FALSE);
  274.                 NextPrefix    = ExtractString(NextPrefix,    PrefixBuffer,FALSE);
  275.             }
  276.             else
  277.             {
  278.                 if(DialNode -> Entry)
  279.                 {
  280.                     NextNumber    = ExtractString(DialNode -> Entry -> Number,NumberBuffer,TRUE);
  281.                     NextInit    = ExtractString(DialNode -> Entry -> Config . ModemInit,InitBuffer,FALSE);
  282.                     NextExit    = ExtractString(DialNode -> Entry -> Config . ModemExit,ExitBuffer,FALSE);
  283.                     NextPrefix    = ExtractString(DialNode -> Entry -> Config . DialPrefix,PrefixBuffer,FALSE);
  284.                 }
  285.                 else
  286.                 {
  287.                     NextNumber    = ExtractString(DialNode -> VanillaNode . ln_Name,NumberBuffer,TRUE);
  288.                     NextInit    = ExtractString(Config . ModemInit,InitBuffer,FALSE);
  289.                     NextExit    = ExtractString(Config . ModemExit,ExitBuffer,FALSE);
  290.                     NextPrefix    = ExtractString(Config . DialPrefix,PrefixBuffer,FALSE);
  291.                 }
  292.             }
  293.  
  294.                 /* If DialNode -> Entry is nonzero it has
  295.                  * a configuration attached.
  296.                  */
  297.  
  298.             if(DialNode -> Entry)
  299.             {
  300.                 DialTimeout    = DialNode -> Entry -> Config . DialTimeout;
  301.                 DialRetries    = DialNode -> Entry -> Config . DialRetries;
  302.  
  303.                     /* We will need to change the serial parameters
  304.                      * in order to establish a connection.
  305.                      */
  306.  
  307.                 if(memcmp(&Config,&DialNode -> Entry -> Config,offsetof(struct Configuration,ModemInit)))
  308.                 {
  309.                     BYTE SameDevice = TRUE;
  310.  
  311.                     CopyMem(&DialNode -> Entry -> Config,&Config,offsetof(struct Configuration,ModemInit));
  312.  
  313.                     Config . SerBuffSize = DialNode -> Entry -> Config . SerBuffSize;
  314.  
  315.                         /* Any device name change? */
  316.  
  317.                     if(strcmp(PrivateConfig . SerialDevice,Config . SerialDevice))
  318.                         SameDevice = FALSE;
  319.                     else
  320.                     {
  321.                         if(PrivateConfig . SerBuffSize != Config . SerBuffSize)
  322.                             SameDevice = FALSE;
  323.  
  324.                             /* Handshaking mode changed to RTS/CTS protocol? */
  325.  
  326.                         if(PrivateConfig . HandshakingProtocol == HANDSHAKING_NONE && PrivateConfig . HandshakingProtocol != HANDSHAKING_NONE)
  327.                             SameDevice = FALSE;
  328.                     }
  329.  
  330.                         /* Stop any IO activity. */
  331.  
  332.                     if(ReadRequest)
  333.                         ClearSerial();
  334.                     else
  335.                         SameDevice = FALSE;
  336.  
  337.                         /* No dramatic changes? Simply change the parameters. */
  338.  
  339.                     if(SameDevice)
  340.                     {
  341.                         LONG Error;
  342.  
  343.                             /* Use new parameters... */
  344.  
  345.                         SetFlags(WriteRequest);
  346.                         SetFlags(ReadRequest);
  347.  
  348.                             /* ...and set them. */
  349.  
  350.                         WriteRequest -> IOSer . io_Command = SDCMD_SETPARAMS;
  351.  
  352.                         if(Error = DoIO(WriteRequest))
  353.                         {
  354.                             STRPTR    String;
  355.                             BYTE    Reset;
  356.  
  357.                             if(!(String = GetSerialError(Error,&Reset)))
  358.                                 String = LocaleString(MSG_SERIAL_ERROR_DEVBUSY_TXT);
  359.  
  360.                             SPrintf(SharedBuffer,String,Config . SerialDevice,Config . UnitNumber);
  361.  
  362.                             BlockWindow(PanelWindow);
  363.  
  364.                             MyEasyRequest(PanelWindow,LocaleString(MSG_GLOBAL_TERM_HAS_A_PROBLEM_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),SharedBuffer);
  365.  
  366.                             ReleaseWindow(PanelWindow);
  367.  
  368.                             if(Reset)
  369.                             {
  370.                                 WriteRequest -> IOSer . io_Command = CMD_RESET;
  371.  
  372.                                 DoIO(WriteRequest);
  373.  
  374.                                 GetFlags(&Config,WriteRequest);
  375.                                 SetFlags(ReadRequest);
  376.                             }
  377.                         }
  378.  
  379.                             /* Restart read request. */
  380.  
  381.                         ReadRequest -> IOSer . io_Command    = CMD_READ;
  382.                         ReadRequest -> IOSer . io_Data        = ReadBuffer;
  383.                         ReadRequest -> IOSer . io_Length    = 1;
  384.  
  385.                         SetSignal(0,SIG_SERIAL);
  386.  
  387.                         SendIO(ReadRequest);
  388.                     }
  389.                     else
  390.                     {
  391.                         UBYTE *Error;
  392.  
  393.                         DeleteSerial();
  394.  
  395.                         if(!(Error = CreateSerial()))
  396.                         {
  397.                             if(StripBuffer)
  398.                                 FreeVec(StripBuffer);
  399.  
  400.                             if(!(StripBuffer = (UBYTE *)AllocVec(Config . SerBuffSize,MEMF_ANY)))
  401.                                 Error = LocaleString(MSG_GLOBAL_NO_AUX_BUFFERS_TXT);
  402.                         }
  403.  
  404.                         if(Error)
  405.                         {
  406.                             BlockWindow(PanelWindow);
  407.  
  408.                             MyEasyRequest(PanelWindow,LocaleString(MSG_GLOBAL_TERM_HAS_A_PROBLEM_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),Error);
  409.  
  410.                             DeleteSerial();
  411.  
  412.                             ReleaseWindow(PanelWindow);
  413.  
  414.                             SerialSet = FALSE;
  415.  
  416.                             goto Quit;
  417.                         }
  418.                         else
  419.                         {
  420.                             if(SerialMessage)
  421.                             {
  422.                                 MyEasyRequest(Window,LocaleString(MSG_GLOBAL_TERM_HAS_A_PROBLEM_TXT),LocaleString(MSG_GLOBAL_CONTINUE_TXT),SerialMessage);
  423.  
  424.                                 SerialMessage = NULL;
  425.                             }
  426.                         }
  427.                     }
  428.  
  429.                     if(!Terminated)
  430.                     {
  431.                         SerWrite("\rAT\r",4);
  432.                         WaitTime(1,0);
  433.                     }
  434.  
  435.                         /* Don't reinitialize serial driver in ConfigSetup()! */
  436.  
  437.                     SerialSet = TRUE;
  438.                 }
  439.  
  440.                 if(ExitString[0])
  441.                 {
  442.                     SerialCommand(ExitString);
  443.  
  444.                     WaitTime(1,0);
  445.                 }
  446.  
  447.                 if(InitBuffer[0])
  448.                 {
  449.                     SerialCommand(InitBuffer);
  450.  
  451.                     WaitTime(1,0);
  452.                 }
  453.  
  454.                 strcpy(ExitString,ExitBuffer);
  455.  
  456.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],0,DialNode -> Entry -> Name);
  457.  
  458.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),DialNode -> Entry -> Name);
  459.  
  460.                 strcpy(SomeBuffer,PrefixBuffer);
  461.  
  462.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],1,NumberBuffer);
  463.                 strcat(SomeBuffer,NumberBuffer);
  464.             }
  465.             else
  466.             {
  467.                 DialTimeout    = Config . DialTimeout;
  468.                 DialRetries    = Config . DialRetries;
  469.  
  470.                 if(ExitString[0])
  471.                 {
  472.                     SerialCommand(ExitString);
  473.  
  474.                     WaitTime(1,0);
  475.                 }
  476.  
  477.                 strcpy(ExitString,ExitBuffer);
  478.  
  479.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],0,LocaleString(MSG_GLOBAL_UNKNOWN_TXT));
  480.  
  481.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),NumberBuffer);
  482.  
  483.                 strcpy(SomeBuffer,PrefixBuffer);
  484.  
  485.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],1,NumberBuffer);
  486.                 strcat(SomeBuffer,NumberBuffer);
  487.             }
  488.  
  489.             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  490.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],2,((struct PhoneNode *)DialNode -> VanillaNode . ln_Succ) -> Entry -> Name);
  491.             else
  492.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_NUMBER_NEXT],2,LocaleString(MSG_GLOBAL_NONE_TXT));
  493.  
  494.             if(DialNode -> Entry)
  495.                 strcat(SomeBuffer,DialNode -> Entry -> Config . DialSuffix);
  496.             else
  497.                 strcat(SomeBuffer,Config . DialSuffix);
  498.  
  499.             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_TXT));
  500.  
  501.                 /* Dial the number. */
  502.  
  503.             SerialCommand(SomeBuffer);
  504.  
  505.                 /* Reset the signal. */
  506.  
  507.             SetSignal(NULL,SIGBREAKF_CTRL_F);
  508.  
  509.             while(!Terminated)
  510.             {
  511.                 if(Dialing)
  512.                 {
  513.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",DialTimeout / 60,DialTimeout % 60);
  514.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],1,LocaleString(MSG_DIALPANEL_ATTEMPT_OF_TXT),DialAttempt + 1,DialRetries);
  515.                 }
  516.                 else
  517.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",RedialDelay / 60,RedialDelay % 60);
  518.  
  519.                 WaitTime(0,MILLION / 2);
  520.  
  521.                     /* The following commands are executed each second */
  522.  
  523.                 if((RunCount++) && !Terminated)
  524.                 {
  525.                     RunCount = 0;
  526.  
  527.                         /* Are we dialing or waiting? */
  528.  
  529.                     if(Dialing)
  530.                     {
  531.                             /* No chance, the dial timeout
  532.                              * has elapsed and no connection
  533.                              * was made.
  534.                              */
  535.  
  536.                         if(!(--DialTimeout))
  537.                         {
  538.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIAL_ATTEMPT_TIMEOUT_TXT));
  539.  
  540. Skip1:                            SerWrite("\r",1);
  541.                             WaitTime(1,0);
  542.  
  543.                                 /* Did we dial all the numbers available? */
  544.  
  545.                             if(NextNumber)
  546.                                 goto Dial;
  547.  
  548.                                 /* Is this one the last entry? */
  549.  
  550.                             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  551.                             {
  552.                                     /* Proceed to the next entry. */
  553.  
  554.                                 DialNode = (struct DialNode *)DialNode -> VanillaNode . ln_Succ;
  555.  
  556.                                 goto Dial;
  557.                             }
  558.                             else
  559.                             {
  560.                                     /* Is this one the last dial
  561.                                      * attempt to be made?
  562.                                      */
  563.  
  564.                                 if(++DialAttempt >= DialRetries)
  565.                                 {
  566.                                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  567.  
  568.                                     WakeUp(PanelWindow);
  569.  
  570.                                     WaitTime(2,0);
  571.  
  572.                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  573.  
  574.                                     Terminated = TRUE;
  575.                                 }
  576.                                 else
  577.                                 {
  578.                                         /* Get the first list entry. */
  579.  
  580.                                     DialNode = (struct PhoneNode *)DialList -> lh_Head;
  581.  
  582.                                         /* Get the redial delay. */
  583.  
  584.                                     if(DialNode -> Entry)
  585.                                         RedialDelay = 10 * DialNode -> Entry -> Config . RedialDelay;
  586.                                     else
  587.                                         RedialDelay = 10 * Config . RedialDelay;
  588.  
  589.                                         /* No redial delay? Restart dialing... */
  590.  
  591.                                     if(!RedialDelay)
  592.                                     {
  593.                                         WaitTime(1,0);
  594.  
  595.                                         goto Dial;
  596.                                     }
  597.                                     else
  598.                                     {
  599.                                             /* Go into redial delay. */
  600.  
  601.                                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_REDIAL_DELAY_TXT));
  602.  
  603.                                         Dialing = FALSE;
  604.  
  605.                                         Say(LocaleString(MSG_DIALPANEL_WAITING_TXT));
  606.                                     }
  607.                                 }
  608.                             }
  609.                         }
  610.                     }
  611.                     else
  612.                     {
  613.                         if(!(--RedialDelay))
  614.                         {
  615.                                 /* Get the first list entry. */
  616.  
  617. Skip2:                            DialNode = (struct PhoneNode *)DialList -> lh_Head;
  618.  
  619.                                 /* We are once again dialing. */
  620.  
  621.                             Dialing = TRUE;
  622.  
  623.                             goto Dial;
  624.                         }
  625.                     }
  626.                 }
  627.  
  628.                     /* Handle serial data flow. */
  629.  
  630.                 HandleSerial();
  631.  
  632.                     /* Something has changed in the flow
  633.                      * info structure.
  634.                      */
  635.  
  636.                 if(FlowInfo . Changed)
  637.                 {
  638.                         /* Current number is busy. */
  639.  
  640.                     if(FlowInfo . Busy || FlowInfo . NoCarrier)
  641.                     {
  642.                         FlowInit();
  643.  
  644.                         FullCheck = TRUE;
  645.  
  646.                         FlowInfo . Busy        = FALSE;
  647.                         FlowInfo . NoCarrier    = FALSE;
  648.                         FlowInfo . Changed    = FALSE;
  649.  
  650.                         if(Dialing)
  651.                         {
  652.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  653.  
  654.                             Say(LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  655.  
  656.                             WaitTime(1,0);
  657.  
  658.                             goto Skip1;
  659.                         }
  660.                     }
  661.  
  662.                         /* Line does not feature a dialtone. */
  663.  
  664.                     if(FlowInfo . NoDialTone)
  665.                     {
  666.                         FlowInit();
  667.  
  668.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  669.  
  670.                         WakeUp(PanelWindow);
  671.  
  672.                         WaitTime(1,0);
  673.  
  674.                         Say(LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  675.  
  676.                         Terminated = TRUE;
  677.                     }
  678.  
  679.                         /* Somebody tries to call us. */
  680.  
  681.                     if(FlowInfo . Ring && !Terminated)
  682.                     {
  683.                         FlowInit();
  684.  
  685.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  686.  
  687.                         WakeUp(PanelWindow);
  688.  
  689.                         WaitTime(1,0);
  690.  
  691.                         Say(LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  692.  
  693.                         Terminated = TRUE;
  694.                     }
  695.  
  696.                         /* Somebody's talking. */
  697.  
  698.                     if(FlowInfo . Voice && !Terminated)
  699.                     {
  700.                         FlowInit();
  701.  
  702.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  703.  
  704.                         WakeUp(PanelWindow);
  705.  
  706.                         WaitTime(1,0);
  707.  
  708.                         Say(LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  709.  
  710.                         Terminated = TRUE;
  711.                     }
  712.  
  713.                         /* We got a connect. */
  714.  
  715.                     if(FlowInfo . Connect && !Terminated)
  716.                     {
  717.                         FlowInfo . Connect = FALSE;
  718.                         FlowInfo . Changed = FALSE;
  719.  
  720.                             /* Install the new configuration. */
  721.  
  722. ConnectIt:                    if(DialNode -> Entry)
  723.                         {
  724.                             CopyMem(&DialNode -> Entry -> Config,&Config,sizeof(struct Configuration));
  725.  
  726.                             MakeCall(DialNode -> Entry -> Name,DialNode -> Entry -> Number);
  727.                         }
  728.                         else
  729.                             MakeCall("???",DialNode -> VanillaNode . ln_Name);
  730.  
  731.                                 /* Convert the baud rate. */
  732.  
  733.                         if(BaudBuffer[0] && Config . ConnectAutoBaud)
  734.                         {
  735.                             LONG TestRate,i,j;
  736.  
  737.                             for(i = j = 0 ; i < strlen(BaudBuffer) ; i++)
  738.                             {
  739.                                 if(BaudBuffer[i] == ' ')
  740.                                     continue;
  741.                                 else
  742.                                 {
  743.                                     if(BaudBuffer[i] >= '0' && BaudBuffer[i] <= '9')
  744.                                         SharedBuffer[j++] = BaudBuffer[i];
  745.                                     else
  746.                                         break;
  747.                                 }
  748.                             }
  749.  
  750.                             SharedBuffer[j] = 0;
  751.  
  752.                             TestRate = atol(SharedBuffer);
  753.  
  754.                             if(TestRate >= 110)
  755.                                 Config . BaudRate = TestRate;
  756.                         }
  757.  
  758.                             /* Reset the scanner. */
  759.  
  760.                         FlowInit();
  761.  
  762.                             /* Copy the remaining data. */
  763.  
  764.                         if(DialNode -> Entry)
  765.                         {
  766.                             SelectTime(DialNode -> Entry);
  767.  
  768.                             ChosenEntry    = DialNode -> Entry;
  769.                             WhichUnit    = DT_FIRST_UNIT;
  770.                             CurrentPay    = 0;
  771.                             SendStartup    = TRUE;
  772.  
  773.                             strcpy(Password,DialNode -> Entry -> Password);
  774.                             strcpy(UserName,DialNode -> Entry -> UserName);
  775.                         }
  776.                         else
  777.                         {
  778.                             CurrentPay    = 0;
  779.  
  780.                             ChosenEntry    = NULL;
  781.  
  782.                             Password[0]    = 0;
  783.                             UserName[0]    = 0;
  784.  
  785.                             SendStartup    = FALSE;
  786.                         }
  787.  
  788.                             /* We are now online. */
  789.  
  790.                         Online        = TRUE;
  791.                         Terminated    = TRUE;
  792.  
  793.                             /* Add another logfile entry. */
  794.  
  795.                         if(DialNode -> Entry)
  796.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Name,NumberBuffer);
  797.                         else
  798.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  799.  
  800.                             /* Open auto-capture file if necessary. */
  801.  
  802.                         if(Config . ConnectAutoCapture && Config . CapturePath[0])
  803.                         {
  804.                             UBYTE        SharedBuffer[256],Name[50],Date[20];
  805.                             struct DateTime    DateTime;
  806.  
  807.                             DateStamp(&DateTime . dat_Stamp);
  808.  
  809.                             DateTime . dat_Format    = FORMAT_DOS;
  810.                             DateTime . dat_Flags    = 0;
  811.                             DateTime . dat_StrDay    = NULL;
  812.                             DateTime . dat_StrDate    = Date;
  813.                             DateTime . dat_StrTime    = NULL;
  814.  
  815.                             strcpy(SharedBuffer,Config . CapturePath);
  816.  
  817.                             if(DateToStr(&DateTime))
  818.                             {
  819.                                 if(DialNode -> Entry)
  820.                                 {
  821.                                     WORD i;
  822.  
  823.                                     strcpy(Name,DialNode -> Entry -> Name);
  824.  
  825.                                     for(i = 0 ; i < strlen(Name) ; i++)
  826.                                     {
  827.                                         if(Name[i] == ' ')
  828.                                             Name[i] = '_';
  829.                                     }
  830.                                 }
  831.                                 else
  832.                                     strcpy(Name,LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  833.  
  834.                                 strcat(Name,"_");
  835.                                 strcat(Name,Date);
  836.  
  837.                                 if(AddPart(SharedBuffer,Name,256))
  838.                                 {
  839.                                     struct MenuItem *Item;
  840.  
  841.                                     Item = FindThisItem(MEN_CAPTURE_TO_FILE);
  842.  
  843.                                     Item -> Flags &= ~CHECKED;
  844.  
  845.                                     if(FileCapture)
  846.                                     {
  847.                                         BufferClose(FileCapture);
  848.  
  849.                                         if(!GetFileSize(CaptureName))
  850.                                             DeleteFile(CaptureName);
  851.                                         else
  852.                                             SetProtection(CaptureName,FIBF_EXECUTE);
  853.                                     }
  854.  
  855.                                     if(FileCapture = BufferOpen(SharedBuffer,"a"))
  856.                                     {
  857.                                         Item -> Flags |= CHECKED;
  858.  
  859.                                         strcpy(CaptureName,SharedBuffer);
  860.                                     }
  861.                                 }
  862.                             }
  863.                         }
  864.  
  865.                             /* Remove the node from the
  866.                              * dialing list.
  867.                              */
  868.  
  869.                         if(DialNode -> Entry)
  870.                             RemoveDialNode(DialNode);
  871.  
  872.                         Remove(&DialNode -> VanillaNode);
  873.  
  874.                         FreeVec(DialNode);
  875.  
  876.                             /* Wake the user up. */
  877.  
  878.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  879.  
  880.                         WakeUp(PanelWindow);
  881.  
  882.                         if(PrivateConfig . BackupConfig)
  883.                         {
  884.                             if(!BackupConfig)
  885.                             {
  886.                                 if(BackupConfig = (struct Configuration *)AllocVec(sizeof(struct Configuration),MEMF_ANY))
  887.                                     memcpy(BackupConfig,&PrivateConfig,sizeof(struct Configuration));
  888.                             }
  889.                         }
  890.  
  891.                         Say(LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  892.  
  893.                             /* Don't process any data until the screen
  894.                              * is set up correctly.
  895.                              */
  896.  
  897.                         Blocking = TRUE;
  898.  
  899.                             /* Perform system initialization. */
  900.  
  901.                         ConfigSetup();
  902.                     }
  903.                 }
  904.  
  905.                     /* Look for the hotkey. */
  906.  
  907.                 if(SetSignal(NULL,NULL) & SIGBREAKF_CTRL_F)
  908.                 {
  909.                     SetSignal(NULL,SIGBREAKF_CTRL_F);
  910.  
  911.                         /* Are we dialing or waiting? */
  912.  
  913.                     if(Dialing)
  914.                     {
  915.                         DialTimeout = 0;
  916.  
  917.                         goto Skip1;
  918.                     }
  919.                     else
  920.                     {
  921.                         RedialDelay = 0;
  922.  
  923.                         goto Skip2;
  924.                     }
  925.                 }
  926.  
  927.                     /* Pick up the window input. */
  928.  
  929.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  930.                 {
  931.                     Class    = Massage -> Class;
  932.                     Code    = Massage -> Code;
  933.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  934.  
  935.                     GT_ReplyIMsg(Massage);
  936.  
  937.                     if(Class == IDCMP_VANILLAKEY)
  938.                     {
  939.                         if(Code == ' ')
  940.                         {
  941.                             Class    = IDCMP_GADGETUP;
  942.                             Code    = 0;
  943.                             Gadget    = GadgetArray[GAD_SKIP];
  944.                         }
  945.                         else
  946.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&Class,&Code);
  947.                     }
  948.  
  949.                         /* Close the window, hang up the line. */
  950.  
  951.                     if(Class == IDCMP_CLOSEWINDOW)
  952.                     {
  953.                         Class    = IDCMP_GADGETUP;
  954.                         Gadget    = GadgetArray[GAD_ABORT];
  955.  
  956.                         Result = TRUE;
  957.                     }
  958.  
  959.                     if(Class == IDCMP_GADGETUP)
  960.                     {
  961.                         switch(Gadget -> GadgetID)
  962.                         {
  963.                                     /* Don't proceed to the next number in the buffer! */
  964.  
  965.                             case GAD_REMOVE:NextNumber = NULL;
  966.  
  967.                                     if(Dialing)
  968.                                     {
  969.                                         struct PhoneNode *NextNode = NULL;
  970.  
  971.                                             /* Is there another entry in the list? */
  972.  
  973.                                         if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  974.                                             NextNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  975.                                         else
  976.                                         {
  977.                                                 /* No, there isn't; do we have a list with
  978.                                                  * at least two entries in it?
  979.                                                  */
  980.  
  981.                                             if(DialList -> lh_Head -> ln_Succ -> ln_Succ)
  982.                                             {
  983.                                                     /* There is just a single entry
  984.                                                      * available, check for dial retry
  985.                                                      * limit.
  986.                                                      */
  987.  
  988.                                                 if(++DialAttempt >= DialRetries)
  989.                                                 {
  990.                                                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  991.  
  992.                                                     WakeUp(PanelWindow);
  993.  
  994.                                                     WaitTime(1,0);
  995.  
  996.                                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  997.  
  998.                                                     Terminated = TRUE;
  999.                                                 }
  1000.                                                 else
  1001.                                                 {
  1002.                                                         /* Grab first list entry and continue. */
  1003.  
  1004.                                                     NextNode = (struct PhoneNode *)DialList -> lh_Head;
  1005.                                                 }
  1006.                                             }
  1007.                                             else
  1008.                                             {
  1009.                                                 Terminated = TRUE;
  1010.  
  1011.                                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1012.  
  1013.                                                 WaitTime(1,0);
  1014.                                             }
  1015.                                         }
  1016.  
  1017.                                         DialTimeout = 0;
  1018.  
  1019.                                         SerWrite("\r",1);
  1020.                                         WaitTime(1,0);
  1021.  
  1022.                                             /* Remove dial entry from list. */
  1023.  
  1024.                                         if(DialNode -> Entry)
  1025.                                             RemoveDialNode(DialNode);
  1026.  
  1027.                                         Remove(&DialNode -> VanillaNode);
  1028.  
  1029.                                         FreeVec(DialNode);
  1030.  
  1031.                                             /* Is there an entry to proceed with? */
  1032.  
  1033.                                         if(NextNode)
  1034.                                         {
  1035.                                             DialNode = NextNode;
  1036.  
  1037.                                             goto Dial;
  1038.                                         }
  1039.                                     }
  1040.                                     else
  1041.                                     {
  1042.                                         struct PhoneNode *LastNode;
  1043.  
  1044.                                             /* We are to leave the redial delay loop,
  1045.                                              * are there at least two entries in
  1046.                                              * the list?
  1047.                                              */
  1048.  
  1049.                                         if(!DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1050.                                         {
  1051.                                                 /* No, there is just a single entry in
  1052.                                                  * the list.
  1053.                                                  */
  1054.  
  1055.                                             Terminated = TRUE;
  1056.  
  1057.                                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1058.  
  1059.                                             SerWrite("\r",1);
  1060.                                             WaitTime(2,0);
  1061.                                         }
  1062.  
  1063.                                             /* Remove last dial entry from list. */
  1064.  
  1065.                                         LastNode = (struct PhoneNode *)DialList -> lh_TailPred;
  1066.  
  1067.                                         if(LastNode -> Entry)
  1068.                                             RemoveDialNode(LastNode);
  1069.  
  1070.                                         Remove(&LastNode -> VanillaNode);
  1071.  
  1072.                                         FreeVec(LastNode);
  1073.  
  1074.                                             /* Get back to first list entry. */
  1075.  
  1076.                                         if(!Terminated)
  1077.                                         {
  1078.                                             RedialDelay = 0;
  1079.  
  1080.                                             goto Skip2;
  1081.                                         }
  1082.                                     }
  1083.  
  1084.                                     break;
  1085.  
  1086.                             case GAD_SKIP:    if(Dialing)
  1087.                                     {
  1088.                                         DialTimeout = 0;
  1089.  
  1090.                                         goto Skip1;
  1091.                                     }
  1092.                                     else
  1093.                                     {
  1094.                                         RedialDelay = 0;
  1095.  
  1096.                                         goto Skip2;
  1097.                                     }
  1098.  
  1099.                                         /* Forced online,
  1100.                                          * install new configuration
  1101.                                          * first.
  1102.                                          */
  1103.  
  1104.                             case GAD_ONLINE:if(DialNode -> Entry)
  1105.                                     {
  1106.                                         CopyMem(&DialNode -> Entry -> Config,&Config,sizeof(struct Configuration));
  1107.  
  1108.                                         MakeCall(DialNode -> Entry -> Name,DialNode -> Entry -> Number);
  1109.  
  1110.                                         SelectTime(DialNode -> Entry);
  1111.  
  1112.                                         ChosenEntry    = DialNode -> Entry;
  1113.                                         WhichUnit    = DT_FIRST_UNIT;
  1114.                                         CurrentPay    = 0;
  1115.                                         SendStartup    = TRUE;
  1116.  
  1117.                                         strcpy(Password,DialNode -> Entry -> Password);
  1118.                                         strcpy(UserName,DialNode -> Entry -> UserName);
  1119.                                     }
  1120.                                     else
  1121.                                     {
  1122.                                         MakeCall("???",DialNode -> VanillaNode . ln_Name);
  1123.  
  1124.                                         CurrentPay    = 0;
  1125.                                         ChosenEntry    = NULL;
  1126.                                         Password[0]    = 0;
  1127.                                         UserName[0]    = 0;
  1128.                                         SendStartup    = FALSE;
  1129.                                     }
  1130.  
  1131.                                         /* We are now online. */
  1132.  
  1133.                                     Online        = TRUE;
  1134.                                     Terminated    = TRUE;
  1135.  
  1136.                                         /* Add a new log action. */
  1137.  
  1138.                                     if(DialNode -> Entry)
  1139.                                         LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Name,NumberBuffer);
  1140.                                     else
  1141.                                         LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  1142.  
  1143.                                         /* Open auto-capture file. */
  1144.  
  1145.                                     if(Config . ConnectAutoCapture && Config . CapturePath[0])
  1146.                                     {
  1147.                                         UBYTE        SharedBuffer[256],Name[50],Date[20];
  1148.                                         struct DateTime    DateTime;
  1149.  
  1150.                                         DateStamp(&DateTime . dat_Stamp);
  1151.  
  1152.                                         DateTime . dat_Format    = FORMAT_DOS;
  1153.                                         DateTime . dat_Flags    = 0;
  1154.                                         DateTime . dat_StrDay    = NULL;
  1155.                                         DateTime . dat_StrDate    = Date;
  1156.                                         DateTime . dat_StrTime    = NULL;
  1157.  
  1158.                                         strcpy(SharedBuffer,Config . CapturePath);
  1159.  
  1160.                                         if(DateToStr(&DateTime))
  1161.                                         {
  1162.                                             if(DialNode -> Entry)
  1163.                                             {
  1164.                                                 WORD i;
  1165.  
  1166.                                                 strcpy(Name,DialNode -> Entry -> Name);
  1167.  
  1168.                                                 for(i = 0 ; i < strlen(Name) ; i++)
  1169.                                                 {
  1170.                                                     if(Name[i] == ' ')
  1171.                                                         Name[i] = '_';
  1172.                                                 }
  1173.                                             }
  1174.                                             else
  1175.                                                 strcpy(Name,LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  1176.  
  1177.                                             strcat(Name,"_");
  1178.                                             strcat(Name,Date);
  1179.  
  1180.                                             if(AddPart(SharedBuffer,Name,256))
  1181.                                             {
  1182.                                                 struct MenuItem *Item;
  1183.  
  1184.                                                 Item = FindThisItem(MEN_CAPTURE_TO_FILE);
  1185.  
  1186.                                                 Item -> Flags &= ~CHECKED;
  1187.  
  1188.                                                 if(FileCapture)
  1189.                                                 {
  1190.                                                     BufferClose(FileCapture);
  1191.  
  1192.                                                     if(!GetFileSize(CaptureName))
  1193.                                                         DeleteFile(CaptureName);
  1194.                                                     else
  1195.                                                         SetProtection(CaptureName,FIBF_EXECUTE);
  1196.                                                 }
  1197.  
  1198.                                                 if(FileCapture = BufferOpen(SharedBuffer,"a"))
  1199.                                                 {
  1200.                                                     Item -> Flags |= CHECKED;
  1201.  
  1202.                                                     strcpy(CaptureName,SharedBuffer);
  1203.                                                 }
  1204.                                             }
  1205.                                         }
  1206.                                     }
  1207.  
  1208.                                         /* Remove node from
  1209.                                          * dialing list and
  1210.                                          * perform system
  1211.                                          * setup.
  1212.                                          */
  1213.  
  1214.                                     if(DialNode -> Entry)
  1215.                                         RemoveDialNode(DialNode);
  1216.  
  1217.                                     Remove(&DialNode -> VanillaNode);
  1218.  
  1219.                                     FreeVec(DialNode);
  1220.  
  1221.                                     if(PrivateConfig . BackupConfig)
  1222.                                     {
  1223.                                         if(!BackupConfig)
  1224.                                         {
  1225.                                             if(BackupConfig = (struct Configuration *)AllocVec(sizeof(struct Configuration),MEMF_ANY))
  1226.                                                 memcpy(BackupConfig,&PrivateConfig,sizeof(struct Configuration));
  1227.                                         }
  1228.                                     }
  1229.  
  1230.                                     Blocking = TRUE;
  1231.  
  1232.                                     ConfigSetup();
  1233.  
  1234.                                     break;
  1235.  
  1236.                                 /* Abort the dialing process. */
  1237.  
  1238.                             case GAD_ABORT:    Terminated = TRUE;
  1239.  
  1240.                                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  1241.  
  1242.                                     SerWrite("\r",1);
  1243.                                     WaitTime(1,0);
  1244.  
  1245.                                     break;
  1246.                         }
  1247.                     }
  1248.                 }
  1249.             }
  1250.  
  1251.                 /* Are we online or not? */
  1252.  
  1253. Quit:            if(!Online)
  1254.             {
  1255.                     /* Is the serial setup different? */
  1256.  
  1257.                 if(memcmp(&PrivateConfig,&Config,58))
  1258.                 {
  1259.                         /* Swap the serial data. */
  1260.  
  1261.                     swmem(&PrivateConfig,&Config,58);
  1262.  
  1263.                         /* Set up the old serial configuration. */
  1264.  
  1265.                     ConfigSetup();
  1266.  
  1267.                         /* Reinitialize... */
  1268.  
  1269.                     SerWrite("\rAT\r",4);
  1270.                     WaitTime(1,0);
  1271.                 }
  1272.  
  1273.                     /* Do we have a valid modem exit string? */
  1274.  
  1275.                 if(ExitString[0])
  1276.                 {
  1277.                     SerialCommand(ExitString);
  1278.  
  1279.                     WaitTime(1,0);
  1280.                 }
  1281.             }
  1282.  
  1283.                 /* Reset the scanner. */
  1284.  
  1285.             FlowInit();
  1286.  
  1287.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  1288.  
  1289.             PopWindow();
  1290.  
  1291.             PositionX = PanelWindow -> LeftEdge;
  1292.             PositionY = PanelWindow -> TopEdge;
  1293.  
  1294.             CloseWindow(PanelWindow);
  1295.         }
  1296.     }
  1297.  
  1298.     FreeGadgets(GadgetList);
  1299.  
  1300.     SZ_FreeBoxes(BoxList);
  1301.  
  1302.         /* We are done now, restart echoing serial */
  1303.  
  1304.     Quiet = FALSE;
  1305.  
  1306.         /* Reset the display if necessary. */
  1307.  
  1308.     if(ResetDisplay)
  1309.         DisplayReset();
  1310.  
  1311.     if(Online)
  1312.         SetDialMenu(FALSE);
  1313.  
  1314.         /* Send the startup macro if necessary. */
  1315.  
  1316.     if(SendStartup && Online)
  1317.     {
  1318.         if(Config . StartupMacro[0])
  1319.             SerialCommand(Config . StartupMacro);
  1320.  
  1321.         SendStartup = FALSE;
  1322.     }
  1323.  
  1324.     return(Result);
  1325. }
  1326.