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