home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / comm / term33so.lha / termDial.c < prev    next >
C/C++ Source or Header  |  1993-04-30  |  37KB  |  1,537 lines

  1. /*
  2. **    termDial.c
  3. **
  4. **    The dialing routine as called by the phonebook
  5. **
  6. **    Copyright © 1990-1993 by Olaf `Olsen' Barthel & MXM
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Panel gadget IDs. */
  13.  
  14. enum    {    GAD_SKIP,GAD_REMOVE,GAD_ONLINE,GAD_ABORT,
  15.         GADGET_COUNT };
  16.  
  17.     /* Panel box IDs. */
  18.  
  19. enum    {    BOX_CALL_COMMENT_NUMBER_NEXT,BOX_TIME_TRY,BOX_MESSAGE,
  20.         BOX_COUNT };
  21.  
  22.     /* CreateAllGadgets():
  23.      *
  24.      *    Create all gadgets required by the dial panel.
  25.      */
  26.  
  27. STATIC struct Gadget *
  28. CreateAllGadgets(struct TextBox **BoxArray,struct TextBox **BoxList,struct Gadget **GadgetArray,struct Gadget **GadgetList)
  29. {
  30.     struct Gadget        *Gadget;
  31.     struct NewGadget     NewGadget;
  32.     UWORD             Counter = 0,BoxCounter = 0;
  33.     struct TextBox        *Box;
  34.  
  35.     memset(&NewGadget,0,sizeof(struct NewGadget));
  36.  
  37.     SZ_SizeSetup(Window -> WScreen,&UserFont,TRUE);
  38.  
  39.     if(Gadget = CreateContext(GadgetList))
  40.     {
  41.         LONG ButtonWidth,LeftEdge;
  42.  
  43.         LeftEdge = SZ_LeftOffsetDelta(MSG_DIALPANEL_CALLING_TXT,MSG_DIALPANEL_MESSAGE_TXT);
  44.  
  45.         SZ_AddLeftOffset(LeftEdge);
  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) + LeftEdge)
  57.             SZ_SetWidth(ButtonWidth * 4 + 3 * InterWidth - LeftEdge);
  58.         else
  59.             SZ_SetWidth(SZ_BoxWidth(45));
  60.  
  61.         BoxArray[BoxCounter++] = Box = SZ_CreateTextBox(BoxList,
  62.             SZ_Chars,    45,
  63.             SZ_Lines,    4,
  64.             SZ_AutoWidth,    TRUE,
  65.         TAG_DONE);
  66.  
  67.         SZ_SetBoxTitles(Box,LocaleString(MSG_DIALPANEL_CALLING_TXT),LocaleString(MSG_DIALPANEL_COMMENT_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.         {
  87.             NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_SKIP_GAD);
  88.             NewGadget . ng_GadgetID        = Counter;
  89.  
  90.             SZ_SetWidth(ButtonWidth);
  91.  
  92.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  93.                 SZ_Adjust,    TRUE,
  94.                 SZ_AutoWidth,    TRUE,
  95.                 SZ_AlignExtra,    TRUE,
  96.                 SZ_AlignBottom,    TRUE,
  97.                 SZ_GroupCount,    4,
  98.             TAG_DONE);
  99.  
  100.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_REMOVE_GAD);
  101.             NewGadget . ng_GadgetID        = Counter;
  102.  
  103.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  104.                 SZ_Adjust,    TRUE,
  105.                 SZ_AutoWidth,    TRUE,
  106.                 SZ_GroupNext,    TRUE,
  107.             TAG_DONE);
  108.  
  109.             NewGadget . ng_GadgetText    = LocaleString(MSG_DIALPANEL_GO_TO_ONLINE_GAD);
  110.             NewGadget . ng_GadgetID        = Counter;
  111.  
  112.             GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  113.                 SZ_Adjust,    TRUE,
  114.                 SZ_AutoWidth,    TRUE,
  115.                 SZ_GroupNext,    TRUE,
  116.             TAG_DONE);
  117.  
  118.             NewGadget . ng_GadgetText    = LocaleString(MSG_GLOBAL_ABORT_GAD);
  119.             NewGadget . ng_GadgetID        = Counter;
  120.  
  121.             GadgetArray[Counter] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
  122.                 SZ_Adjust,    TRUE,
  123.                 SZ_AutoWidth,    TRUE,
  124.                 SZ_GroupNext,    TRUE,
  125.             TAG_DONE);
  126.         }
  127.         else
  128.             return(NULL);
  129.     }
  130.  
  131.     return(Gadget);
  132. }
  133.  
  134.     /* BuildName(STRPTR Name):
  135.      *
  136.      *    Build a file name from a BBS name and the current date.
  137.      */
  138.  
  139. STATIC VOID __regargs
  140. BuildName(STRPTR Name,STRPTR Date)
  141. {
  142.     if(Date[0])
  143.     {
  144.         WORD    NameLen = strlen(Name),
  145.             DateLen = strlen(Date),
  146.             Delta;
  147.  
  148.         if((Delta = NameLen + 1 + DateLen - 32) > 0)
  149.             Name[NameLen - Delta] = 0;
  150.  
  151.         strcat(Name,"_");
  152.         strcat(Name,Date);
  153.     }
  154. }
  155.  
  156.     /* FixName(STRPTR Name):
  157.      *
  158.      *    Build a correct AmigaDOS filename from a BBS name.
  159.      */
  160.  
  161. STATIC VOID __regargs
  162. FixName(STRPTR Name)
  163. {
  164.     WORD    NameLen    = strlen(Name),
  165.         i;
  166.  
  167.         /* Replace special characters. */
  168.  
  169.     for(i = 0 ; i < NameLen ; i++)
  170.     {
  171.         switch(Name[i])
  172.         {
  173.             case ' ':
  174.  
  175.                 Name[i] = '_';
  176.                 break;
  177.  
  178.             case ':':
  179.  
  180.                 Name[i] = '.';
  181.                 break;
  182.  
  183.             case '/':
  184.  
  185.                 Name[i] = '\\';
  186.                 break;
  187.  
  188.             case '\"':
  189.  
  190.                 Name[i] = '\'';
  191.                 break;
  192.         }
  193.     }
  194.  
  195.         /* Truncate the name. */
  196.  
  197.     if(NameLen > 31)
  198.         Name[31] = 0;
  199. }
  200.  
  201.     /* OpenAutoCaptureFile(STRPTR SomeName):
  202.      *
  203.      *    Open a capture file.
  204.      */
  205.  
  206. STATIC VOID __regargs
  207. OpenAutoCaptureFile(STRPTR SomeName)
  208. {
  209.     UBYTE        SharedBuffer[MAX_FILENAME_LENGTH],
  210.             Name[50],
  211.             Date[20],
  212.             Time[20];
  213.     struct DateTime    DateTime;
  214.  
  215.         /* Get the current time and date. */
  216.  
  217.     DateStamp(&DateTime . dat_Stamp);
  218.  
  219.         /* Prepare for date conversion. */
  220.  
  221.     DateTime . dat_Format    = FORMAT_DOS;
  222.     DateTime . dat_Flags    = 0;
  223.     DateTime . dat_StrDay    = NULL;
  224.     DateTime . dat_StrDate    = Date;
  225.     DateTime . dat_StrTime    = Time;
  226.  
  227.         /* Convert the date. */
  228.  
  229.     if(DateToStr(&DateTime))
  230.     {
  231.             /* Remember the BBS name. */
  232.  
  233.         strcpy(Name,SomeName);
  234.  
  235.             /* Append the creation date if necessary. */
  236.  
  237.         if(Config -> CaptureConfig -> AutoCaptureDate == AUTOCAPTURE_DATE_NAME)
  238.             BuildName(Name,Date);
  239.  
  240.             /* Make it a reasonable name. */
  241.  
  242.         FixName(Name);
  243.  
  244.             /* Get the capture file path. */
  245.  
  246.         strcpy(SharedBuffer,Config -> CaptureConfig -> CapturePath);
  247.  
  248.             /* Try to build a valid file and path name. */
  249.  
  250.         if(AddPart(SharedBuffer,Name,MAX_FILENAME_LENGTH))
  251.         {
  252.                 /* Is the capture file still open? */
  253.  
  254.             if(FileCapture)
  255.             {
  256.                     /* Close the file. */
  257.  
  258.                 BufferClose(FileCapture);
  259.  
  260.                     /* Any data written? */
  261.  
  262.                 if(!GetFileSize(CaptureName))
  263.                     DeleteFile(CaptureName);
  264.                 else
  265.                 {
  266.                     AddProtection(CaptureName,FIBF_EXECUTE);
  267.  
  268.                     if(Config -> MiscConfig -> CreateIcons)
  269.                         AddIcon(CaptureName,FILETYPE_TEXT,TRUE);
  270.                 }
  271.             }
  272.  
  273.                 /* Try to append the new data. */
  274.  
  275.             if(FileCapture = BufferOpen(SharedBuffer,"a"))
  276.             {
  277.                     /* Set the menu checkmark. */
  278.  
  279.                 CheckItem(MEN_CAPTURE_TO_FILE,TRUE);
  280.  
  281.                     /* Remember the current capture file name. */
  282.  
  283.                 strcpy(CaptureName,SharedBuffer);
  284.  
  285.                     /* Add the creation date if necessary. */
  286.  
  287.                 if(Config -> CaptureConfig -> AutoCaptureDate == AUTOCAPTURE_DATE_INCLUDE)
  288.                     BPrintf(FileCapture,LocaleString(MSG_DIALPANEL_FILE_CREATED_TXT),Time,Date);
  289.             }
  290.             else
  291.                 CheckItem(MEN_CAPTURE_TO_FILE,FALSE);
  292.  
  293.             ConOutputUpdate();
  294.         }
  295.     }
  296. }
  297.  
  298.     /* DialPanel():
  299.      *
  300.      *    This routine opens a small window in the middle of the
  301.      *    console window and walks down the list of numbers to
  302.      *    dial.
  303.      */
  304.  
  305. BYTE
  306. DialPanel()
  307. {
  308.     struct Gadget        *GadgetList = NULL;
  309.     struct Gadget        *GadgetArray[GADGET_COUNT];
  310.     struct TextBox        *BoxList = NULL;
  311.     struct TextBox        *BoxArray[BOX_COUNT];
  312.     struct Window        *PanelWindow;
  313.     struct PhoneNode    *DialNode;
  314.     BYTE             Result = FALSE;
  315.  
  316.     ChosenEntry = NULL;
  317.  
  318.         /* We are dialing. */
  319.  
  320.     Status = STATUS_DIALING;
  321.  
  322.         /* Create the gadgets. */
  323.  
  324.     if(CreateAllGadgets(BoxArray,&BoxList,GadgetArray,&GadgetList))
  325.     {
  326.             /* At last, open the window. */
  327.  
  328.         if(PanelWindow = OpenWindowTags(NULL,
  329.             WA_Left,    GetScreenLeft(Window) + (GetScreenWidth(Window) - SZ_GetWindowWidth()) / 2,
  330.             WA_Top,        GetScreenTop(Window) + (GetScreenHeight(Window) - SZ_GetWindowHeight())    / 2,
  331.             WA_Width,    SZ_GetWindowWidth(),
  332.             WA_Height,    SZ_GetWindowHeight(),
  333.  
  334.             WA_Activate,    TRUE,
  335.             WA_DragBar,    TRUE,
  336.             WA_DepthGadget,    TRUE,
  337.             WA_CloseGadget,    TRUE,
  338.             WA_RMBTrap,    TRUE,
  339.             WA_CustomScreen,Window -> WScreen,
  340.  
  341.             WA_IDCMP,    IDCMP_CLOSEWINDOW | IDCMP_VANILLAKEY | IDCMP_RAWKEY | BUTTONIDCMP,
  342.  
  343.             WA_Title,    LocaleString(MSG_DIALPANEL_DIALING_TXT),
  344.         TAG_DONE))
  345.         {
  346.             struct IntuiMessage    *Massage;
  347.             ULONG             IClass,Code;
  348.             struct Gadget        *Gadget;
  349.             LONG             RedialDelay = 0,DialTimeout,DialRetries,DialAttempt;
  350.             BYTE             Dialing,Terminated = FALSE,RunCount = 0,GotError = FALSE;
  351.  
  352.             UBYTE             SomeBuffer[300],ExitString[80],
  353.                          NumberBuffer[100],    *NextNumber    = NULL,
  354.                          InitBuffer[80],    *NextInit    = NULL,
  355.                          ExitBuffer[80],    *NextExit    = NULL,
  356.                          PrefixBuffer[80],    *NextPrefix    = NULL;
  357.  
  358.             GuideContext(CONTEXT_DIAL);
  359.  
  360.             ExitString[0] = 0;
  361.  
  362.                 /* Make the current one the active one. */
  363.  
  364.             PushWindow(PanelWindow);
  365.  
  366.                 /* Make a backup of the current configuration. */
  367.  
  368.             SaveConfig(Config,PrivateConfig);
  369.  
  370.                 /* Add the gadgets and refresh them. */
  371.  
  372.             AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
  373.             RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
  374.             GT_RefreshWindow(PanelWindow,NULL);
  375.  
  376.             SZ_DrawBoxes(PanelWindow -> RPort,BoxList);
  377.  
  378.                 /* Don't echo serial output. */
  379.  
  380.             Quiet        = TRUE;
  381.  
  382.                 /* Perform full sequence check. */
  383.  
  384.             FullCheck    = TRUE;
  385.  
  386.                 /* Reset the scanner. */
  387.  
  388.             FlowInit(TRUE);
  389.  
  390.                 /* Reset the number of dial attempts. */
  391.  
  392.             DialAttempt    = 0;
  393.  
  394.                 /* Get the first dial list entry. */
  395.  
  396.             DialNode    = (struct PhoneNode *)DialList -> lh_Head;
  397.  
  398.                 /* The big dialing loop, implemented as a goto -> mark
  399.                  * loop rather than one of those classical while .. do
  400.                  * loops.
  401.                  */
  402.  
  403. Dial:            Dialing        = TRUE;
  404.  
  405.                 /* Reset the sequence scanner, the user may have skipped
  406.                  * the previous dial attempt causing the modem to return
  407.                  * `NO CARRIER'. To prevent the dialer from skipping the
  408.                  * next dial entry as well as the previous we have to
  409.                  * flush any data pending on the serial line.
  410.                  */
  411.  
  412.             HandleSerial();
  413.  
  414.             FlowInit(TRUE);
  415.  
  416.                 /* Now for multiple phone numbers separated
  417.                  * by `|' characters. If `NextNumber' happens
  418.                  * to be zero, we will prepare to extract
  419.                  * the first phone number from the list.
  420.                  * In any other case we will try to obtain
  421.                  * the next number.
  422.                  */
  423.  
  424.             if(NextNumber)
  425.             {
  426.                 NextNumber    = ExtractString(NextNumber,    NumberBuffer,TRUE);
  427.                 NextInit    = ExtractString(NextInit,    InitBuffer,FALSE);
  428.                 NextExit    = ExtractString(NextExit,    ExitBuffer,FALSE);
  429.                 NextPrefix    = ExtractString(NextPrefix,    PrefixBuffer,FALSE);
  430.             }
  431.             else
  432.             {
  433.                 if(DialNode -> Entry)
  434.                 {
  435.                     NextNumber = ExtractString(DialNode -> Entry -> Header -> Number,NumberBuffer,TRUE);
  436.  
  437.                     if(DialNode -> Entry -> Config -> ModemConfig)
  438.                     {
  439.                         NextInit    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  440.                         NextExit    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  441.                         NextPrefix    = ExtractString(DialNode -> Entry -> Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  442.                     }
  443.                     else
  444.                     {
  445.                         NextInit    = ExtractString(Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  446.                         NextExit    = ExtractString(Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  447.                         NextPrefix    = ExtractString(Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  448.                     }
  449.                 }
  450.                 else
  451.                 {
  452.                     NextNumber    = ExtractString(DialNode -> VanillaNode . ln_Name,NumberBuffer,TRUE);
  453.  
  454.                     NextInit    = ExtractString(Config -> ModemConfig -> ModemInit,InitBuffer,FALSE);
  455.                     NextExit    = ExtractString(Config -> ModemConfig -> ModemExit,ExitBuffer,FALSE);
  456.                     NextPrefix    = ExtractString(Config -> ModemConfig -> DialPrefix,PrefixBuffer,FALSE);
  457.                 }
  458.             }
  459.  
  460.                 /* If DialNode -> Entry is nonzero it has
  461.                  * a configuration attached.
  462.                  */
  463.  
  464.             if(DialNode -> Entry)
  465.             {
  466.                 if(DialNode -> Entry -> Config -> ModemConfig)
  467.                 {
  468.                     DialTimeout    = DialNode -> Entry -> Config -> ModemConfig -> DialTimeout;
  469.                     DialRetries    = DialNode -> Entry -> Config -> ModemConfig -> DialRetries;
  470.                 }
  471.                 else
  472.                 {
  473.                     DialTimeout    = Config -> ModemConfig -> DialTimeout;
  474.                     DialRetries    = Config -> ModemConfig -> DialRetries;
  475.                 }
  476.  
  477.                     /* Send the modem exit string before we
  478.                      * will need to reconfigure the serial
  479.                      * device driver.
  480.                      */
  481.  
  482.                 if(ExitString[0])
  483.                 {
  484.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  485.  
  486.                     FlowInit(TRUE);
  487.  
  488.                     SerialCommand(ExitString);
  489.  
  490.                     WaitTime(1,0);
  491.  
  492.                     HandleSerial();
  493.  
  494.                     if(FlowInfo . Changed && FlowInfo . Error)
  495.                     {
  496.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  497.  
  498.                         GotError = TRUE;
  499.  
  500.                         goto Quit;
  501.                     }
  502.                 }
  503.  
  504.                     /* We will need to change the serial parameters
  505.                      * in order to establish a connection.
  506.                      */
  507.  
  508.                 if(DialNode -> Entry -> Config -> SerialConfig)
  509.                 {
  510.                     if(ReconfigureSerial(PanelWindow,DialNode -> Entry -> Config -> SerialConfig) == RECONFIGURE_FAILURE)
  511.                         goto Quit;
  512.                 }
  513.  
  514.                     /* Send the modem init string. */
  515.  
  516.                 if(InitBuffer[0] && !Terminated)
  517.                 {
  518.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  519.  
  520.                     FlowInit(TRUE);
  521.  
  522.                     SerialCommand(InitBuffer);
  523.  
  524.                     WaitTime(1,0);
  525.  
  526.                     HandleSerial();
  527.  
  528.                     if(FlowInfo . Changed && FlowInfo . Error)
  529.                     {
  530.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  531.  
  532.                         GotError = TRUE;
  533.  
  534.                         goto Quit;
  535.                     }
  536.                 }
  537.  
  538.                     /* Remember the new exit string. */
  539.  
  540.                 strcpy(ExitString,ExitBuffer);
  541.  
  542.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],0,DialNode -> Entry -> Header -> Name);
  543.  
  544.                 if(DialNode -> Entry -> Header -> Comment[0])
  545.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,DialNode -> Entry -> Header -> Comment);
  546.                 else
  547.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,"-");
  548.  
  549.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),DialNode -> Entry -> Header -> Name);
  550.  
  551.                 strcpy(SomeBuffer,PrefixBuffer);
  552.  
  553.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],2,NumberBuffer);
  554.  
  555.                 strcat(SomeBuffer,NumberBuffer);
  556.             }
  557.             else
  558.             {
  559.                 DialTimeout    = Config -> ModemConfig -> DialTimeout;
  560.                 DialRetries    = Config -> ModemConfig -> DialRetries;
  561.  
  562.                     /* Send the modem exit string. */
  563.  
  564.                 if(ExitString[0])
  565.                 {
  566.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  567.  
  568.                     FlowInit(TRUE);
  569.  
  570.                     SerialCommand(ExitBuffer);
  571.  
  572.                     WaitTime(1,0);
  573.  
  574.                     HandleSerial();
  575.  
  576.                     if(FlowInfo . Changed && FlowInfo . Error)
  577.                     {
  578.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  579.  
  580.                         GotError = TRUE;
  581.  
  582.                         goto Quit;
  583.                     }
  584.                 }
  585.  
  586.                     /* Remember the new exit string. */
  587.  
  588.                 strcpy(ExitString,ExitBuffer);
  589.  
  590.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],0,LocaleString(MSG_GLOBAL_UNKNOWN_TXT));
  591.  
  592.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],1,"-");
  593.  
  594.                 Say(LocaleString(MSG_DIALPANEL_NOW_CALLING_TXT),NumberBuffer);
  595.  
  596.                 strcpy(SomeBuffer,PrefixBuffer);
  597.  
  598.                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],2,NumberBuffer);
  599.  
  600.                 strcat(SomeBuffer,NumberBuffer);
  601.  
  602.                     /* Send the modem init string. */
  603.  
  604.                 if(InitBuffer[0])
  605.                 {
  606.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  607.  
  608.                     FlowInit(TRUE);
  609.  
  610.                     SerialCommand(InitBuffer);
  611.  
  612.                     WaitTime(1,0);
  613.  
  614.                     HandleSerial();
  615.  
  616.                     if(FlowInfo . Changed && FlowInfo . Error)
  617.                     {
  618.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  619.  
  620.                         GotError = TRUE;
  621.  
  622.                         goto Quit;
  623.                     }
  624.                 }
  625.             }
  626.  
  627.             if(NextNumber)
  628.             {
  629.                 if(DialNode -> Entry)
  630.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> Entry -> Header -> Name);
  631.                 else
  632.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> VanillaNode . ln_Name);
  633.             }
  634.             else
  635.             {
  636.                 if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  637.                 {
  638.                     if(DialNode -> Entry)
  639.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,((struct PhoneNode *)DialNode -> VanillaNode . ln_Succ) -> Entry -> Header -> Name);
  640.                     else
  641.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,DialNode -> VanillaNode . ln_Succ -> ln_Name);
  642.                 }
  643.                 else
  644.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_CALL_COMMENT_NUMBER_NEXT],3,LocaleString(MSG_GLOBAL_NONE_TXT));
  645.             }
  646.  
  647.             if(DialNode -> Entry)
  648.             {
  649.                 if(DialNode -> Entry -> Config -> ModemConfig)
  650.                     strcat(SomeBuffer,DialNode -> Entry -> Config -> ModemConfig -> DialSuffix);
  651.                 else
  652.                     strcat(SomeBuffer,Config -> ModemConfig -> DialSuffix);
  653.             }
  654.             else
  655.                 strcat(SomeBuffer,Config -> ModemConfig -> DialSuffix);
  656.  
  657.             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_TXT));
  658.  
  659.                 /* Dial the number. */
  660.  
  661.             SerialCommand(SomeBuffer);
  662.  
  663.                 /* Reset the signal. */
  664.  
  665.             SetSignal(NULL,SIG_SKIP | SIG_BREAK);
  666.  
  667.             while(!Terminated)
  668.             {
  669.                 if(CheckSignal(SIG_BREAK))
  670.                 {
  671.                     Terminated = TRUE;
  672.  
  673.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  674.  
  675.                     SerWrite("\r",1);
  676.                     WaitTime(1,0);
  677.  
  678.                         /* Ignore the response of the modem. */
  679.  
  680.                     HandleSerial();
  681.  
  682.                     FlowInit(TRUE);
  683.  
  684.                     break;
  685.                 }
  686.  
  687.                 if(Dialing)
  688.                 {
  689.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",DialTimeout / 60,DialTimeout % 60);
  690.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],1,LocaleString(MSG_DIALPANEL_ATTEMPT_OF_TXT),DialAttempt + 1,DialRetries);
  691.                 }
  692.                 else
  693.                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_TIME_TRY],0,"%2ld:%02ld",RedialDelay / 60,RedialDelay % 60);
  694.  
  695.                 WaitTime(0,MILLION / 2);
  696.  
  697.                     /* The following commands are executed each second */
  698.  
  699.                 if((RunCount++) && !Terminated)
  700.                 {
  701.                     RunCount = 0;
  702.  
  703.                         /* Are we dialing or waiting? */
  704.  
  705.                     if(Dialing)
  706.                     {
  707.                             /* No chance, the dial timeout
  708.                              * has elapsed and no connection
  709.                              * was made.
  710.                              */
  711.  
  712.                         if(!(--DialTimeout))
  713.                         {
  714.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIAL_ATTEMPT_TIMEOUT_TXT));
  715.  
  716. Skip1:                            SerWrite("\r",1);
  717.                             WaitTime(1,0);
  718.  
  719.                                 /* Ignore the response of the modem. */
  720.  
  721.                             HandleSerial();
  722.  
  723.                             FlowInit(TRUE);
  724.  
  725.                                 /* Did we dial all the numbers available? */
  726.  
  727.                             if(NextNumber)
  728.                                 goto Dial;
  729.  
  730.                                 /* Is this one the last entry? */
  731.  
  732.                             if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  733.                             {
  734.                                     /* Proceed to the next entry. */
  735.  
  736.                                 DialNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  737.  
  738.                                 goto Dial;
  739.                             }
  740.                             else
  741.                             {
  742.                                     /* Is this one the last dial
  743.                                      * attempt to be made?
  744.                                      */
  745.  
  746.                                 if(++DialAttempt >= DialRetries)
  747.                                 {
  748.                                     SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  749.  
  750.                                     WakeUp(PanelWindow,SOUND_BELL);
  751.  
  752.                                     WaitTime(2,0);
  753.  
  754.                                     Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  755.  
  756.                                     Terminated = TRUE;
  757.                                 }
  758.                                 else
  759.                                 {
  760.                                         /* Get the first list entry. */
  761.  
  762.                                     DialNode = (struct PhoneNode *)DialList -> lh_Head;
  763.  
  764.                                         /* Get the redial delay. */
  765.  
  766.                                     if(DialNode -> Entry)
  767.                                     {
  768.                                         if(DialNode -> Entry -> Config -> ModemConfig)
  769.                                             RedialDelay = 10 * DialNode -> Entry -> Config -> ModemConfig -> RedialDelay;
  770.                                         else
  771.                                             RedialDelay = 10 * Config -> ModemConfig -> RedialDelay;
  772.                                     }
  773.                                     else
  774.                                         RedialDelay = 10 * Config -> ModemConfig -> RedialDelay;
  775.  
  776.                                         /* No redial delay? Restart dialing... */
  777.  
  778.                                     if(!RedialDelay)
  779.                                     {
  780.                                         WaitTime(1,0);
  781.  
  782.                                         goto Dial;
  783.                                     }
  784.                                     else
  785.                                     {
  786.                                             /* Go into redial delay. */
  787.  
  788.                                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_REDIAL_DELAY_TXT));
  789.  
  790.                                         Dialing = FALSE;
  791.  
  792.                                         Say(LocaleString(MSG_DIALPANEL_WAITING_TXT));
  793.                                     }
  794.                                 }
  795.                             }
  796.                         }
  797.                     }
  798.                     else
  799.                     {
  800.                         if(!(--RedialDelay))
  801.                         {
  802.                                 /* Get the first list entry. */
  803.  
  804. Skip2:                            DialNode = (struct PhoneNode *)DialList -> lh_Head;
  805.  
  806.                                 /* We are once again dialing. */
  807.  
  808.                             goto Dial;
  809.                         }
  810.                     }
  811.                 }
  812.  
  813.                     /* Handle serial data flow. */
  814.  
  815.                 HandleSerial();
  816.  
  817.                     /* Something has changed in the flow
  818.                      * info structure.
  819.                      */
  820.  
  821.                 if(FlowInfo . Changed)
  822.                 {
  823.                         /* Current number is busy. */
  824.  
  825.                     if(FlowInfo . Busy || (FlowInfo . NoCarrier && Config -> ModemConfig -> NoCarrierIsBusy))
  826.                     {
  827.                         FlowInit(TRUE);
  828.  
  829.                         FlowInfo . Busy        = FALSE;
  830.                         FlowInfo . NoCarrier    = FALSE;
  831.                         FlowInfo . Changed    = FALSE;
  832.  
  833.                         if(Dialing)
  834.                         {
  835.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  836.  
  837.                             Say(LocaleString(MSG_DIALPANEL_LINE_IS_BUSY_TXT));
  838.  
  839.                             WaitTime(1,0);
  840.  
  841.                             goto Skip1;
  842.                         }
  843.                     }
  844.  
  845.                         /* Line does not feature a dialtone. */
  846.  
  847.                     if(FlowInfo . NoDialTone)
  848.                     {
  849.                         FlowInit(TRUE);
  850.  
  851.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  852.  
  853.                         WakeUp(PanelWindow,SOUND_BELL);
  854.  
  855.                         WaitTime(2,0);
  856.  
  857.                         Say(LocaleString(MSG_DIALPANEL_NO_DIALTONE_TXT));
  858.  
  859.                         Terminated = TRUE;
  860.                     }
  861.  
  862.                         /* Somebody tries to call us. */
  863.  
  864.                     if(FlowInfo . Ring && !Terminated)
  865.                     {
  866.                         FlowInit(TRUE);
  867.  
  868.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  869.  
  870.                         WakeUp(PanelWindow,SOUND_RING);
  871.  
  872.                         WaitTime(2,0);
  873.  
  874.                         Say(LocaleString(MSG_GLOBAL_INCOMING_CALL_TXT));
  875.  
  876.                         Terminated = TRUE;
  877.                     }
  878.  
  879.                         /* Somebody's talking. */
  880.  
  881.                     if(FlowInfo . Voice && !Terminated)
  882.                     {
  883.                         FlowInit(TRUE);
  884.  
  885.                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  886.  
  887.                         WakeUp(PanelWindow,SOUND_VOICE);
  888.  
  889.                         WaitTime(2,0);
  890.  
  891.                         Say(LocaleString(MSG_DIALPANEL_INCOMING_VOICE_CALL_TXT));
  892.  
  893.                         Terminated = TRUE;
  894.                     }
  895.  
  896.                         /* We got a connect. */
  897.  
  898.                     if(FlowInfo . Connect && !Terminated)
  899.                     {
  900.                         FlowInfo . Connect = FALSE;
  901.                         FlowInfo . Changed = FALSE;
  902.  
  903.                             /* Install the new configuration. */
  904.  
  905.                         if(DialNode -> Entry)
  906.                         {
  907.                             UpdateConfig(DialNode -> Entry -> Config,Config);
  908.  
  909.                             ConfigChanged = FALSE;
  910.  
  911.                             MakeCall(DialNode -> Entry -> Header -> Name,NumberBuffer);
  912.                         }
  913.                         else
  914.                             MakeCall("???",NumberBuffer);
  915.  
  916.                             /* Reset the scanner. */
  917.  
  918.                         FlowInit(TRUE);
  919.  
  920.                             /* Copy the remaining data. */
  921.  
  922.                         if(DialNode -> Entry)
  923.                         {
  924.                             SelectTime(DialNode -> Entry);
  925.  
  926.                             ChosenEntry    = DialNode -> Entry;
  927.                             WhichUnit    = DT_FIRST_UNIT;
  928.                             CurrentPay    = 0;
  929.                             SendStartup    = TRUE;
  930.  
  931.                             strcpy(Password,DialNode -> Entry -> Header -> Password);
  932.                             strcpy(UserName,DialNode -> Entry -> Header -> UserName);
  933.  
  934.                             strcpy(CurrentBBSName,DialNode -> Entry -> Header -> Name);
  935.                             strcpy(CurrentBBSComment,DialNode -> Entry -> Header -> Comment);
  936.  
  937.                             strcpy(CurrentBBSNumber,NumberBuffer);
  938.  
  939.                             if(DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit > 0 && DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro[0])
  940.                             {
  941.                                 LimitCount = DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit;
  942.  
  943.                                 strcpy(LimitMacro,DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro);
  944.                             }
  945.                             else
  946.                                 LimitCount = -1;
  947.                         }
  948.                         else
  949.                         {
  950.                             CurrentPay        = 0;
  951.  
  952.                             ChosenEntry        = NULL;
  953.  
  954.                             CurrentBBSName[0]    = 0;
  955.                             CurrentBBSComment[0]    = 0;
  956.  
  957.                             strcpy(CurrentBBSNumber,NumberBuffer);
  958.  
  959.                             Password[0]        = 0;
  960.                             UserName[0]        = 0;
  961.  
  962.                             SendStartup        = FALSE;
  963.  
  964.                             if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  965.                             {
  966.                                 LimitCount = Config -> ModemConfig -> ConnectLimit;
  967.  
  968.                                 strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  969.                             }
  970.                             else
  971.                                 LimitCount = -1;
  972.                         }
  973.  
  974.                             /* We are now online. */
  975.  
  976.                         Online        = TRUE;
  977.                         Terminated    = TRUE;
  978.  
  979.                             /* Add another logfile entry. */
  980.  
  981.                         if(DialNode -> Entry)
  982.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Header -> Name,NumberBuffer);
  983.                         else
  984.                             LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  985.  
  986.                             /* Open auto-capture file if necessary. */
  987.  
  988.                         if(Config -> CaptureConfig -> ConnectAutoCapture && Config -> CaptureConfig -> CapturePath[0])
  989.                         {
  990.                             if(DialNode -> Entry)
  991.                                 OpenAutoCaptureFile(DialNode -> Entry -> Header -> Name);
  992.                             else
  993.                                 OpenAutoCaptureFile(LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  994.                         }
  995.  
  996.                             /* Remove the node from the
  997.                              * dialing list.
  998.                              */
  999.  
  1000.                         if(DialNode -> Entry)
  1001.                             RemoveDialNode(DialNode);
  1002.  
  1003.                         Remove(&DialNode -> VanillaNode);
  1004.  
  1005.                         FreeVec(DialNode);
  1006.  
  1007.                             /* Wake the user up. */
  1008.  
  1009.                         if(BaudBuffer[0])
  1010.                         {
  1011.                             strcpy(SharedBuffer,"CONNECT ");
  1012.                             strcat(SharedBuffer,BaudBuffer);
  1013.  
  1014.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,SharedBuffer);
  1015.  
  1016.                             WakeUp(PanelWindow,SOUND_CONNECT);
  1017.  
  1018.                             WaitTime(2,0);
  1019.  
  1020.                                 /* Install new baud rate if desired. */
  1021.  
  1022.                             if(Config -> ModemConfig -> ConnectAutoBaud && DTERate > 110)
  1023.                                 Config -> SerialConfig -> BaudRate = DTERate;
  1024.                         }
  1025.                         else
  1026.                         {
  1027.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  1028.  
  1029.                             WakeUp(PanelWindow,SOUND_CONNECT);
  1030.                         }
  1031.  
  1032.                         if(PrivateConfig -> MiscConfig -> BackupConfig)
  1033.                         {
  1034.                             if(!BackupConfig)
  1035.                             {
  1036.                                 if(BackupConfig = CreateConfiguration(TRUE))
  1037.                                     SaveConfig(PrivateConfig,BackupConfig);
  1038.                             }
  1039.                         }
  1040.  
  1041.                         Say(LocaleString(MSG_DIALPANEL_CONNECTION_ESTABLISHED_TXT));
  1042.  
  1043.                             /* Perform system initialization. */
  1044.  
  1045.                         ConfigSetup();
  1046.                     }
  1047.                 }
  1048.  
  1049.                     /* Look for the hotkey. */
  1050.  
  1051.                 if(CheckSignal(SIG_SKIP))
  1052.                 {
  1053.                         /* Are we dialing or waiting? */
  1054.  
  1055.                     if(Dialing)
  1056.                     {
  1057.                         DialTimeout = 0;
  1058.  
  1059.                         goto Skip1;
  1060.                     }
  1061.                     else
  1062.                     {
  1063.                         RedialDelay = 0;
  1064.  
  1065.                         goto Skip2;
  1066.                     }
  1067.                 }
  1068.  
  1069.                     /* Pick up the window input. */
  1070.  
  1071.                 while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  1072.                 {
  1073.                     IClass    = Massage -> Class;
  1074.                     Code    = Massage -> Code;
  1075.                     Gadget    = (struct Gadget *)Massage -> IAddress;
  1076.  
  1077.                     GT_ReplyIMsg(Massage);
  1078.  
  1079.                     if(IClass == IDCMP_VANILLAKEY)
  1080.                     {
  1081.                         if(Code == ' ')
  1082.                         {
  1083.                             IClass    = IDCMP_GADGETUP;
  1084.                             Code    = 0;
  1085.                             Gadget    = GadgetArray[GAD_SKIP];
  1086.                         }
  1087.                         else
  1088.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1089.                     }
  1090.  
  1091.                     if(IClass == IDCMP_RAWKEY)
  1092.                         KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1093.  
  1094.                         /* Close the window, hang up the line. */
  1095.  
  1096.                     if(IClass == IDCMP_CLOSEWINDOW)
  1097.                     {
  1098.                         IClass    = IDCMP_GADGETUP;
  1099.                         Gadget    = GadgetArray[GAD_ABORT];
  1100.  
  1101.                         Result = TRUE;
  1102.                     }
  1103.  
  1104.                     if(IClass == IDCMP_GADGETUP)
  1105.                     {
  1106.                         switch(Gadget -> GadgetID)
  1107.                         {
  1108.                                     /* Don't proceed to the next number in the buffer! */
  1109.  
  1110.                             case GAD_REMOVE:
  1111.  
  1112.                                 NextNumber = NULL;
  1113.  
  1114.                                 if(Dialing)
  1115.                                 {
  1116.                                     struct PhoneNode *NextNode = NULL;
  1117.  
  1118.                                         /* Is there another entry in the list? */
  1119.  
  1120.                                     if(DialNode -> VanillaNode . ln_Succ -> ln_Succ)
  1121.                                         NextNode = (struct PhoneNode *)DialNode -> VanillaNode . ln_Succ;
  1122.                                     else
  1123.                                     {
  1124.                                             /* No, there isn't; do we have a list with
  1125.                                              * at least two entries in it?
  1126.                                              */
  1127.  
  1128.                                         if(DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1129.                                         {
  1130.                                                 /* There is just a single entry
  1131.                                                  * available, check for dial retry
  1132.                                                  * limit.
  1133.                                                  */
  1134.  
  1135.                                             if(++DialAttempt >= DialRetries)
  1136.                                             {
  1137.                                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1138.  
  1139.                                                 WakeUp(PanelWindow,SOUND_BELL);
  1140.  
  1141.                                                 WaitTime(2,0);
  1142.  
  1143.                                                 Say(LocaleString(MSG_DIALPANEL_MAXIMUM_NUMBER_OF_DIAL_RETRIES_TXT));
  1144.  
  1145.                                                 Terminated = TRUE;
  1146.                                             }
  1147.                                             else
  1148.                                             {
  1149.                                                     /* Grab first list entry and continue. */
  1150.  
  1151.                                                 NextNode = (struct PhoneNode *)DialList -> lh_Head;
  1152.                                             }
  1153.                                         }
  1154.                                         else
  1155.                                         {
  1156.                                             Terminated = TRUE;
  1157.  
  1158.                                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1159.  
  1160.                                             WaitTime(2,0);
  1161.                                         }
  1162.                                     }
  1163.  
  1164.                                     DialTimeout = 0;
  1165.  
  1166.                                     SerWrite("\r",1);
  1167.                                     WaitTime(1,0);
  1168.  
  1169.                                         /* Ignore the response of the modem. */
  1170.  
  1171.                                     HandleSerial();
  1172.  
  1173.                                     FlowInit(TRUE);
  1174.  
  1175.                                         /* Remove dial entry from list. */
  1176.  
  1177.                                     if(DialNode -> Entry)
  1178.                                         RemoveDialNode(DialNode);
  1179.  
  1180.                                     Remove(&DialNode -> VanillaNode);
  1181.  
  1182.                                     FreeVec(DialNode);
  1183.  
  1184.                                         /* Is there an entry to proceed with? */
  1185.  
  1186.                                     if(NextNode)
  1187.                                     {
  1188.                                         DialNode = NextNode;
  1189.  
  1190.                                         goto Dial;
  1191.                                     }
  1192.                                 }
  1193.                                 else
  1194.                                 {
  1195.                                     struct PhoneNode *LastNode;
  1196.  
  1197.                                         /* We are to leave the redial delay loop,
  1198.                                          * are there at least two entries in
  1199.                                          * the list?
  1200.                                          */
  1201.  
  1202.                                     if(!DialList -> lh_Head -> ln_Succ -> ln_Succ)
  1203.                                     {
  1204.                                             /* No, there is just a single entry in
  1205.                                              * the list.
  1206.                                              */
  1207.  
  1208.                                         Terminated = TRUE;
  1209.  
  1210.                                         SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_DIALING_LIST_IS_EMPTY_TXT));
  1211.  
  1212.                                         SerWrite("\r",1);
  1213.                                         WaitTime(2,0);
  1214.  
  1215.                                             /* Ignore the response of the modem. */
  1216.  
  1217.                                         HandleSerial();
  1218.  
  1219.                                         FlowInit(TRUE);
  1220.                                     }
  1221.  
  1222.                                         /* Remove last dial entry from list. */
  1223.  
  1224.                                     LastNode = (struct PhoneNode *)DialList -> lh_TailPred;
  1225.  
  1226.                                     if(LastNode -> Entry)
  1227.                                         RemoveDialNode(LastNode);
  1228.  
  1229.                                     Remove(&LastNode -> VanillaNode);
  1230.  
  1231.                                     FreeVec(LastNode);
  1232.  
  1233.                                         /* Get back to first list entry. */
  1234.  
  1235.                                     if(!Terminated)
  1236.                                     {
  1237.                                         RedialDelay = 0;
  1238.  
  1239.                                         goto Skip2;
  1240.                                     }
  1241.                                 }
  1242.  
  1243.                                 break;
  1244.  
  1245.                             case GAD_SKIP:
  1246.  
  1247.                                 if(Dialing)
  1248.                                 {
  1249.                                     DialTimeout = 0;
  1250.  
  1251.                                     goto Skip1;
  1252.                                 }
  1253.                                 else
  1254.                                 {
  1255.                                     RedialDelay = 0;
  1256.  
  1257.                                     goto Skip2;
  1258.                                 }
  1259.  
  1260.                             case GAD_ONLINE:
  1261.  
  1262.                                     /* Forced online,
  1263.                                      * install new configuration
  1264.                                      * first.
  1265.                                      */
  1266.  
  1267.                                 if(DialNode -> Entry)
  1268.                                 {
  1269.                                     UpdateConfig(DialNode -> Entry -> Config,Config);
  1270.  
  1271.                                     ConfigChanged = FALSE;
  1272.  
  1273.                                     MakeCall(DialNode -> Entry -> Header -> Name,NumberBuffer);
  1274.  
  1275.                                     SelectTime(DialNode -> Entry);
  1276.  
  1277.                                     ChosenEntry    = DialNode -> Entry;
  1278.                                     WhichUnit    = DT_FIRST_UNIT;
  1279.                                     CurrentPay    = 0;
  1280.                                     SendStartup    = TRUE;
  1281.  
  1282.                                     strcpy(Password,DialNode -> Entry -> Header -> Password);
  1283.                                     strcpy(UserName,DialNode -> Entry -> Header -> UserName);
  1284.  
  1285.                                     strcpy(CurrentBBSName,DialNode -> Entry -> Header -> Name);
  1286.                                     strcpy(CurrentBBSComment,DialNode -> Entry -> Header -> Comment);
  1287.  
  1288.                                     strcpy(CurrentBBSNumber,NumberBuffer);
  1289.  
  1290.                                     if(DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit > 0 && DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro[0])
  1291.                                     {
  1292.                                         LimitCount = DialNode -> Entry -> Config -> ModemConfig -> ConnectLimit;
  1293.  
  1294.                                         strcpy(LimitMacro,DialNode -> Entry -> Config -> ModemConfig -> ConnectLimitMacro);
  1295.                                     }
  1296.                                     else
  1297.                                         LimitCount = -1;
  1298.                                 }
  1299.                                 else
  1300.                                 {
  1301.                                     MakeCall("???",NumberBuffer);
  1302.  
  1303.                                     CurrentPay    = 0;
  1304.                                     ChosenEntry    = NULL;
  1305.                                     Password[0]    = 0;
  1306.                                     UserName[0]    = 0;
  1307.                                     SendStartup    = FALSE;
  1308.  
  1309.                                     CurrentBBSName[0]    = 0;
  1310.                                     CurrentBBSComment[0]    = 0;
  1311.  
  1312.                                     strcpy(CurrentBBSNumber,NumberBuffer);
  1313.  
  1314.                                     if(Config -> ModemConfig -> ConnectLimit > 0 && Config -> ModemConfig -> ConnectLimitMacro[0])
  1315.                                     {
  1316.                                         LimitCount = Config -> ModemConfig -> ConnectLimit;
  1317.  
  1318.                                         strcpy(LimitMacro,Config -> ModemConfig -> ConnectLimitMacro);
  1319.                                     }
  1320.                                     else
  1321.                                         LimitCount = -1;
  1322.                                 }
  1323.  
  1324.                                     /* We are now online. */
  1325.  
  1326.                                 Online        = TRUE;
  1327.                                 Terminated    = TRUE;
  1328.  
  1329.                                     /* Add a new log action. */
  1330.  
  1331.                                 if(DialNode -> Entry)
  1332.                                     LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_1_TXT),DialNode -> Entry -> Header -> Name,NumberBuffer);
  1333.                                 else
  1334.                                     LogAction(LocaleString(MSG_DIALPANEL_CONNECTED_TO_2_TXT),NumberBuffer);
  1335.  
  1336.                                     /* Open auto-capture file. */
  1337.  
  1338.                                 if(Config -> CaptureConfig -> ConnectAutoCapture && Config -> CaptureConfig -> CapturePath[0])
  1339.                                 {
  1340.                                     if(DialNode -> Entry)
  1341.                                         OpenAutoCaptureFile(DialNode -> Entry -> Header -> Name);
  1342.                                     else
  1343.                                         OpenAutoCaptureFile(LocaleString(MSG_DIALPANEL_CAPTURE_NAME_TXT));
  1344.                                 }
  1345.  
  1346.                                     /* Remove node from
  1347.                                      * dialing list and
  1348.                                      * perform system
  1349.                                      * setup.
  1350.                                      */
  1351.  
  1352.                                 if(DialNode -> Entry)
  1353.                                     RemoveDialNode(DialNode);
  1354.  
  1355.                                 Remove(&DialNode -> VanillaNode);
  1356.  
  1357.                                 FreeVec(DialNode);
  1358.  
  1359.                                 if(PrivateConfig -> MiscConfig -> BackupConfig)
  1360.                                 {
  1361.                                     if(!BackupConfig)
  1362.                                     {
  1363.                                         if(BackupConfig = CreateConfiguration(TRUE))
  1364.                                             SaveConfig(PrivateConfig,BackupConfig);
  1365.                                     }
  1366.                                 }
  1367.  
  1368.                                 ConfigSetup();
  1369.  
  1370.                                 break;
  1371.  
  1372.                                 /* Abort the dialing process. */
  1373.  
  1374.                             case GAD_ABORT:
  1375.  
  1376.                                 Terminated = TRUE;
  1377.  
  1378.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ABORTING_TXT));
  1379.  
  1380.                                 SerWrite("\r",1);
  1381.                                 WaitTime(1,0);
  1382.  
  1383.                                     /* Ignore the response of the modem. */
  1384.  
  1385.                                 HandleSerial();
  1386.  
  1387.                                 FlowInit(TRUE);
  1388.  
  1389.                                 break;
  1390.                         }
  1391.                     }
  1392.                 }
  1393.             }
  1394.  
  1395.                 /* Are we online or not? */
  1396.  
  1397. Quit:            if(!Online)
  1398.             {
  1399.                     /* Is the serial setup different? */
  1400.  
  1401.                 if(memcmp(Config -> SerialConfig,PrivateConfig -> SerialConfig,sizeof(struct SerialSettings)))
  1402.                 {
  1403.                         /* Swap the serial data. */
  1404.  
  1405.                     swmem(Config -> SerialConfig,PrivateConfig -> SerialConfig,sizeof(struct SerialSettings));
  1406.  
  1407.                         /* Set up the old serial configuration. */
  1408.  
  1409.                     if(ReconfigureSerial(PanelWindow,NULL) != RECONFIGURE_FAILURE)
  1410.                     {
  1411.                         if(ExitString[0])
  1412.                         {
  1413.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_EXIT_COMMAND_TXT));
  1414.  
  1415.                             FlowInit(TRUE);
  1416.  
  1417.                             SerialCommand(ExitBuffer);
  1418.  
  1419.                             WaitTime(1,0);
  1420.  
  1421.                             HandleSerial();
  1422.  
  1423.                             if(FlowInfo . Changed && FlowInfo . Error)
  1424.                             {
  1425.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  1426.  
  1427.                                 GotError = TRUE;
  1428.                             }
  1429.                         }
  1430.  
  1431.                         if(Config -> ModemConfig -> ModemInit[0] && !GotError)
  1432.                         {
  1433.                             SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_SENDING_MODEM_INIT_COMMAND_TXT));
  1434.  
  1435.                             FlowInit(TRUE);
  1436.  
  1437.                             SerialCommand(Config -> ModemConfig -> ModemInit);
  1438.  
  1439.                             WaitTime(1,0);
  1440.  
  1441.                             HandleSerial();
  1442.  
  1443.                             if(FlowInfo . Changed && FlowInfo . Error)
  1444.                             {
  1445.                                 SZ_PrintLine(PanelWindow -> RPort,BoxArray[BOX_MESSAGE],0,LocaleString(MSG_DIALPANEL_ERROR_SENDING_MODEM_COMMAND_TXT));
  1446.  
  1447.                                 GotError = TRUE;
  1448.                             }
  1449.                         }
  1450.                     }
  1451.                 }
  1452.             }
  1453.  
  1454.             if(GotError)
  1455.             {
  1456.                 WORD i;
  1457.  
  1458.                 for(i = GAD_SKIP ; i <= GAD_REMOVE ; i++)
  1459.                 {
  1460.                     GT_SetGadgetAttrs(GadgetArray[i],PanelWindow,NULL,
  1461.                         GA_Disabled,TRUE,
  1462.                     TAG_DONE);
  1463.                 }
  1464.  
  1465.                 WakeUp(PanelWindow,SOUND_BELL);
  1466.  
  1467.                 Terminated = FALSE;
  1468.  
  1469.                 do
  1470.                 {
  1471.                     if(Wait(PORTMASK(PanelWindow -> UserPort) | SIG_BREAK) & SIG_BREAK)
  1472.                         Terminated = TRUE;
  1473.                     else
  1474.                     {
  1475.                         while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
  1476.                         {
  1477.                             IClass    = Massage -> Class;
  1478.                             Code    = Massage -> Code;
  1479.                             Gadget    = (struct Gadget *)Massage -> IAddress;
  1480.  
  1481.                             GT_ReplyIMsg(Massage);
  1482.  
  1483.                             KeySelect(GadgetArray,GAD_ABORT,Code,PanelWindow,&Gadget,&IClass,&Code);
  1484.  
  1485.                             if(IClass == IDCMP_CLOSEWINDOW || (IClass = IDCMP_GADGETDOWN && Gadget -> GadgetID == GAD_ABORT))
  1486.                                 Terminated = TRUE;
  1487.                         }
  1488.                     }
  1489.                 }
  1490.                 while(!Terminated);
  1491.             }
  1492.  
  1493.             RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
  1494.  
  1495.             PopWindow();
  1496.  
  1497.             CloseWindow(PanelWindow);
  1498.         }
  1499.     }
  1500.  
  1501.     FreeGadgets(GadgetList);
  1502.  
  1503.     SZ_FreeBoxes(BoxList);
  1504.  
  1505.             /* Reset the scanner. */
  1506.  
  1507.     FullCheck = FALSE;
  1508.  
  1509.     FlowInit(TRUE);
  1510.  
  1511.         /* We are done now, restart echoing serial */
  1512.  
  1513.     Quiet = FALSE;
  1514.  
  1515.         /* Reset the display if necessary. */
  1516.  
  1517.     if(ResetDisplay)
  1518.         DisplayReset();
  1519.  
  1520.     if(Online)
  1521.     {
  1522.         SetDialMenu(FALSE);
  1523.  
  1524.             /* Send the startup macro if necessary. */
  1525.  
  1526.         if(SendStartup)
  1527.         {
  1528.             if(Config -> CommandConfig -> StartupMacro[0])
  1529.                 SerialCommand(Config -> CommandConfig -> StartupMacro);
  1530.  
  1531.             SendStartup = FALSE;
  1532.         }
  1533.     }
  1534.  
  1535.     return(Result);
  1536. }
  1537.