home *** CD-ROM | disk | FTP | other *** search
- /* $Revision Header * Header built automatically - do not edit! *************
- *
- * (C) Copyright 1990 by Olaf 'Olsen' Barthel & MXM
- *
- * Name .....: DialPanel.c
- * Created ..: Monday 21-Jan-91 20:12
- * Revision .: 0
- *
- * Date Author Comment
- * ========= ======== ====================
- * 21-Jan-91 Olsen Created this file!
- *
- * $Revision Header ********************************************************/
-
- #include "TermGlobal.h"
-
- /* Dimensions of the panel window. */
-
- #define WIDTH (50*8+43)
- #define HEIGHT (9*8+24)
-
- /* Rendering offsets into the window. */
-
- #define ORIGIN_X 10
- #define ORIGIN_Y 12
-
- /* Panel gadget IDs. */
-
- enum { GAD_SKIP,GAD_ONLINE,GAD_ABORT };
-
- /* Menu item IDs. */
-
- enum { MEN_SKIP=1,MEN_ONLINE,MEN_ABORT,MEN_QUITPANEL };
-
- /* The menu attached to the dial window. */
-
- STATIC struct NewMenu DialMenu[] =
- {
- { NM_TITLE, "Project", 0 , 0, 0, (APTR)0},
- { NM_ITEM, "Skip", "S", 0, 0, (APTR)MEN_SKIP},
- { NM_ITEM, "Go To Online", "G", 0, 0, (APTR)MEN_ONLINE},
- { NM_ITEM, "Abort Dialing", "A", 0, 0, (APTR)MEN_ABORT},
- { NM_ITEM, NM_BARLABEL, 0 , 0, 0, (APTR)0},
- { NM_ITEM, "Quit", "Q", 0, 0, (APTR)MEN_QUITPANEL},
- { NM_END, 0, 0 , 0, 0, (APTR)0}
- };
-
- /* CreateAllGadgets():
- *
- * Create all gadgets required by the dial panel.
- */
-
- STATIC struct Gadget *
- CreateAllGadgets(struct Gadget **GadgetArray,struct Gadget **GadgetList,APTR VisualInfo,UWORD TopEdge)
- {
- struct Gadget *Gadget;
- struct NewGadget NewGadget;
- UWORD Counter = 0;
-
- if(Gadget = CreateContext(GadgetList))
- {
- NewGadget . ng_Height = 12;
- NewGadget . ng_GadgetText = "_Skip";
- NewGadget . ng_Width = strlen(NewGadget . ng_GadgetText) * 8 + 8;
- NewGadget . ng_TextAttr = &DefaultFont;
- NewGadget . ng_VisualInfo = VisualInfo;
- NewGadget . ng_GadgetID = Counter;
- NewGadget . ng_LeftEdge = 10;
- NewGadget . ng_Flags = 0;
- NewGadget . ng_TopEdge = HEIGHT - 3 - NewGadget . ng_Height;
-
- GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
- GT_Underscore, '_',
- TAG_DONE);
-
- NewGadget . ng_GadgetText = "_Go To Online";
- NewGadget . ng_Width = strlen(NewGadget . ng_GadgetText) * 8 + 8;
- NewGadget . ng_GadgetID = Counter;
- NewGadget . ng_LeftEdge = (WIDTH - NewGadget . ng_Width) >> 1;
-
- GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
- GT_Underscore, '_',
- TAG_DONE);
-
- NewGadget . ng_GadgetText = "_Abort Dialing";
- NewGadget . ng_Width = strlen(NewGadget . ng_GadgetText) * 8 + 8;
- NewGadget . ng_GadgetID = Counter;
- NewGadget . ng_LeftEdge = WIDTH - 10 - NewGadget . ng_Width;
-
- GadgetArray[Counter++] = Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
- GT_Underscore, '_',
- TAG_DONE);
- }
-
- return(Gadget);
- }
-
- /* PrintInfo(struct Window *SomeWindow,SHORT X,SHORT Y,BYTE *String,...):
- *
- * Print a string at a given position into the panel window.
- */
-
- STATIC VOID
- PrintInfo(struct Window *SomeWindow,SHORT X,SHORT Y,BYTE *String,...)
- {
- va_list VarArgs;
-
- va_start(VarArgs,String);
- VSPrintf(SharedBuffer,String,VarArgs);
- va_end(VarArgs);
-
- Move(SomeWindow -> RPort,ORIGIN_X + X * 8,ORIGIN_Y + 6 + Y * 8);
- Text(SomeWindow -> RPort,SharedBuffer,strlen(SharedBuffer));
- }
-
- /* DialPanel():
- *
- * This routine opens a small window in the middle of the
- * console window and walks down the list of numbers to
- * dial.
- */
-
- VOID
- DialPanel()
- {
- STATIC SHORT PositionX = -1,PositionY = -1;
-
- struct Gadget *GadgetList;
- struct Gadget *GadgetArray[3];
- struct Window *PanelWindow;
- struct Menu *PanelMenu;
-
- struct PhoneNode *SubNode;
-
- BaudBuffer[0] = 0;
-
- /* We are dialing. */
-
- Status = STATUS_DIALING;
-
- /* Create the gadgets. */
-
- if(CreateAllGadgets(&GadgetArray[0],&GadgetList,VisualInfo,Screen -> WBorTop + Screen -> Font -> ta_YSize + 1))
- {
- /* Create the menu. */
-
- if(PanelMenu = CreateMenus(DialMenu,
- GTMN_FrontPen, 0,
- TAG_DONE))
- {
- /* Layout the menu items to fit on the
- * screen.
- */
-
- if(LayoutMenus(PanelMenu,VisualInfo,
- GTMN_TextAttr,&DefaultFont,
- TAG_DONE))
- {
- if(PositionX == -1)
- PositionX = (Screen -> Width - WIDTH) >> 1;
-
- if(PositionY == -1)
- PositionY = (Screen -> Height - HEIGHT) >> 1;
-
- /* At last, open the window. */
-
- if(PanelWindow = OpenWindowTags(NULL,
- WA_Width, WIDTH,
- WA_Height, HEIGHT,
-
- WA_Left, PositionX,
- WA_Top, PositionY,
-
- WA_Activate, TRUE,
- WA_DragBar, TRUE,
- WA_DepthGadget, TRUE,
- WA_CloseGadget, TRUE,
- WA_RMBTrap, TRUE,
- WA_CustomScreen,Screen,
-
- WA_IDCMP, IDCMP_CLOSEWINDOW | BUTTONIDCMP | IDCMP_MENUPICK,
-
- WA_Title, "Dialing...",
- TAG_DONE))
- {
- struct IntuiMessage *Massage;
- ULONG Class,Code;
- struct Gadget *Gadget;
- BYTE Terminated = FALSE;
- LONG DialTimeout = 0,DialAttempt = 0,Time;
- LONG SomeCount = 0;
- BYTE DelayCount = 0;
- BYTE Redialing = FALSE;
- UBYTE SomeBuffer[100];
- BYTE BaudWasPending = FALSE;
- BYTE Pen1,Pen2;
-
- UBYTE *ExitString = NULL;
-
- switch(Config . ColourMode)
- {
- case COLOUR_AMIGA: Pen1 = 1;
- Pen2 = 3;
- break;
-
- case COLOUR_EIGHT: Pen1 = 4;
- Pen2 = 7;
- break;
-
- case COLOUR_SIXTEEN: Pen1 = 15;
- Pen2 = 8;
- break;
-
- case COLOUR_MONO: Pen1 = Pen2 = 1;
- break;
- }
-
- PushWindow(PanelWindow);
-
- /* Make a backup of the current configuration. */
-
- CopyMem(&Config,&PrivateConfig,sizeof(struct Configuration));
-
- /* Add the gadgets and refresh them. */
-
- AddGList(PanelWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
- RefreshGList(GadgetList,PanelWindow,NULL,(UWORD)-1);
- GT_RefreshWindow(PanelWindow,NULL);
-
- /* Attach the menu to the window. */
-
- SetMenuStrip(PanelWindow,PanelMenu);
-
- PanelWindow -> Flags &= ~WFLG_RMBTRAP;
-
- /* Print someinformation into the
- * panel window.
- */
-
- SetAPen(PanelWindow -> RPort,Pen1);
- SetBPen(PanelWindow -> RPort,0);
- SetDrMd(PanelWindow -> RPort,JAM2);
-
- PrintInfo(PanelWindow,0,0,"Calling...:");
- PrintInfo(PanelWindow,0,1,"Number....:");
- PrintInfo(PanelWindow,0,2,"Next......:");
-
- PrintInfo(PanelWindow,0,4,"Timeout...:");
- PrintInfo(PanelWindow,0,5,"Attempt...:");
-
- PrintInfo(PanelWindow,0,7,"Message...:");
-
- SetAPen(PanelWindow -> RPort,Pen2);
-
- /* Get the first node in the list. */
-
- SubNode = (struct PhoneNode *)SubList -> lh_Head;
-
- /* Reset the data flow scanner. */
-
- FlowInit();
-
- /* Don't echo serial output. */
-
- Quiet = TRUE;
-
- /* Perform full sequence check. */
-
- FullCheck = TRUE;
-
- /* Display the information associated
- * with the current list node.
- */
-
- BigLoop: if(SubNode -> Entry)
- {
- /* We will need to change the serial parameters
- * in order to establish a connection.
- */
-
- if(memcmp(&Config,&SubNode -> Entry -> Config,58))
- {
- CopyMem(&Config,&PrivateConfig,58);
-
- CopyMem(&SubNode -> Entry -> Config,&Config,58);
-
- ConfigSetup();
-
- WaitTime(0,MILLION / 2);
- SerWrite("\rAT\r",4);
- WaitTime(0,MILLION / 2);
- }
-
- if(ExitString)
- {
- SerialCommand(ExitString);
- WaitTime(0,MILLION / 2);
- }
-
- if(SubNode -> Entry -> Config . ModemInit[0])
- {
- SerialCommand(SubNode -> Entry -> Config . ModemInit);
- WaitTime(0,MILLION / 2);
- }
-
- if(SubNode -> Entry -> Config . ModemExit[0])
- ExitString = SubNode -> Entry -> Config . ModemExit;
- else
- ExitString = NULL;
-
- PrintInfo(PanelWindow,12,0,"%-40.40s",SubNode -> Entry -> Name);
-
- Say("Now calling: %s",SubNode -> Entry -> Name);
- }
- else
- {
- PrintInfo(PanelWindow,12,0,"%-40.40s","-- Unknown --");
-
- Say("Now calling: %s",SubNode -> VanillaNode . ln_Name);
- }
-
- strcpy(SomeBuffer,SubNode -> Entry ? SubNode -> Entry -> Config . DialPrefix : Config . DialPrefix);
-
- if(SomeCount != SubListNum - 1)
- PrintInfo(PanelWindow,12,2,"%-40.40s",((struct PhoneNode *)SubNode -> VanillaNode . ln_Succ) -> Entry -> Name);
- else
- PrintInfo(PanelWindow,12,2,"%-40.40s","-- None --");
-
- if(SubNode -> Entry)
- {
- PrintInfo(PanelWindow,12,1,"%-40.40s",SubNode -> Entry -> Number);
- strcat(SomeBuffer,SubNode -> Entry -> Number);
- }
- else
- {
- PrintInfo(PanelWindow,12,1,"%-40.40s",SubNode -> VanillaNode . ln_Name);
- strcat(SomeBuffer,SubNode -> VanillaNode . ln_Name);
- }
-
- strcat(SomeBuffer,"\r");
-
- Time = SubNode -> Entry ? SubNode -> Entry -> Config . DialTimeout : Config . DialTimeout;
-
- PrintInfo(PanelWindow,12,4,"%2ld:%02ld",Time / 60,Time % 60);
- PrintInfo(PanelWindow,12,5,"%5ld of %5ld",DialAttempt + 1,(SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries));
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Dialing...");
-
- DelayCount = 1;
-
- DialTimeout = 0;
-
- /* Dial the number. */
-
- SerialCommand(SomeBuffer);
-
- /* Reset the signal. */
-
- SetSignal(NULL,SIGBREAKF_CTRL_F);
-
- while(!Terminated)
- {
- WaitTime(0,MILLION / 2);
-
- /* Something has changed in the flow
- * info structure.
- */
-
- if(FlowInfo . Changed)
- {
- /* We had a connect and the
- * baud rate has been transferred.
- */
-
- if(BaudWasPending && !BaudPending)
- {
- ULONG Value;
-
- if(Value = atol(BaudBuffer))
- {
- if(SubNode -> Entry)
- CopyMem(&SubNode -> Entry -> Config,&Config,sizeof(struct Configuration));
-
- PrivateConfig . BaudRate = Config . BaudRate = Value;
-
- FlushSerial();
-
- SetParameters();
-
- ReadRequest -> IOSer . io_Command = CMD_READ;
- ReadRequest -> IOSer . io_Data = ReadBuffer;
- ReadRequest -> IOSer . io_Length = 1;
-
- SendIO(ReadRequest);
- }
-
- goto ConnectIt;
- }
-
- /* Current number is busy. */
-
- if(FlowInfo . Busy)
- {
- FlowInit();
-
- FullCheck = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Line Is Busy.");
-
- Say("Line is busy.");
-
- WaitTime(1,0);
-
- FlowInfo . Busy = FALSE;
- FlowInfo . Changed = FALSE;
-
- goto DialOn;
- }
-
- /* Somebody tries to call us. */
-
- if(FlowInfo . Ring)
- {
- FlowInit();
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Incoming Call!");
-
- WakeUp(PanelWindow);
-
- Say("Incoming call.");
-
- Terminated = TRUE;
- }
-
- /* Somebody's talking. */
-
- if(FlowInfo . Voice)
- {
- FlowInit();
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Incoming Voice Call!");
-
- WakeUp(PanelWindow);
-
- Say("Icoming voice call.");
-
- Terminated = TRUE;
- }
-
- /* We got a connect. */
-
- if(FlowInfo . Connect)
- {
- FlowInfo . Connect = FALSE;
- FlowInfo . Changed = FALSE;
-
- if(BaudPending)
- {
- if(Config . ConnectAutoBaud)
- BaudWasPending = TRUE;
- else
- BaudPending = FALSE;
- }
-
- ConnectIt: if(!BaudPending)
- {
- if(!BaudWasPending)
- {
- if(SubNode -> Entry)
- CopyMem(&SubNode -> Entry -> Config,&Config,sizeof(struct Configuration));
- }
-
- if(BaudBuffer[0])
- {
- LONG TestRate = atol(BaudBuffer);
-
- if(TestRate >= 110)
- {
- Config . BaudRate = TestRate;
-
- SetParameters();
- }
- }
-
- FlowInit();
-
- if(SubNode -> Entry)
- {
- PayPerUnit[0] = SubNode -> Entry -> PayPerUnit[0];
- PayPerUnit[1] = SubNode -> Entry -> PayPerUnit[1];
-
- SecPerUnit[0] = SubNode -> Entry -> SecPerUnit[0];
- SecPerUnit[1] = SubNode -> Entry -> SecPerUnit[1];
-
- TimeOfDay[0] = SubNode -> Entry -> TimeOfDay[0];
- TimeOfDay[1] = SubNode -> Entry -> TimeOfDay[1];
-
- strcpy(Password,SubNode -> Entry -> Password);
-
- CurrentPay = 0;
-
- SendStartup = TRUE;
- }
- else
- {
- CurrentPay = 0;
-
- SecPerUnit[0] = SecPerUnit[1] = 0;
- PayPerUnit[0] = PayPerUnit[1] = 0;
-
- TimeOfDay[0] = TimeOfDay[1];
-
- Password[0] = 0;
-
- SendStartup = FALSE;
- }
-
- Online = TRUE;
-
- Terminated = TRUE;
-
- if(SubNode -> Entry)
- LogAction("Connected to \"%s\".",SubNode -> Entry -> Name);
- else
- LogAction("Connected to %s.",SubNode -> VanillaNode . ln_Name);
-
- if(Config . ConnectAutoCapture && Config . CapturePath[0])
- {
- UBYTE SharedBuffer[256],Name[50],Date[20];
- struct DateTime DateTime;
-
- DateStamp(&DateTime . dat_Stamp);
-
- DateTime . dat_Format = FORMAT_DOS;
- DateTime . dat_Flags = 0;
- DateTime . dat_StrDay = NULL;
- DateTime . dat_StrDate = Date;
- DateTime . dat_StrTime = NULL;
-
- strcpy(SharedBuffer,Config . CapturePath);
-
- if(DateToStr(&DateTime))
- {
- if(SubNode -> Entry)
- {
- SHORT i;
-
- strcpy(Name,SubNode -> Entry -> Name);
-
- for(i = 0 ; i < strlen(Name) ; i++)
- {
- if(Name[i] == ' ')
- Name[i] = '_';
- }
- }
- else
- strcpy(Name,"Capture");
-
- strcat(Name,"_");
- strcat(Name,Date);
-
- if(AddPart(SharedBuffer,Name,256))
- {
- struct MenuItem *Item;
-
- Item = FindThisItem(MEN_CAPTUREDISK);
-
- if(FileCapture)
- Close(FileCapture);
-
- Item -> Flags &= ~CHECKED;
-
- if(GetFileSize(SharedBuffer))
- {
- if(FileCapture = Open(SharedBuffer,MODE_READWRITE))
- {
- if(Seek(FileCapture,0,OFFSET_END) == -1)
- {
- Close(FileCapture);
-
- FileCapture = NULL;
- }
- }
- }
- else
- FileCapture = Open(SharedBuffer,MODE_NEWFILE);
-
- if(FileCapture)
- {
- Item -> Flags |= CHECKED;
-
- strcpy(CaptureName,SharedBuffer);
- }
- }
- }
- }
-
- SubItemNum = SomeCount;
- RemSubEntry();
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Connection Established.");
-
- WakeUp(PanelWindow);
-
- Say("Connection established.");
-
- ConfigSetup();
- }
- }
- }
-
- if(DelayCount++ == 1)
- {
- DelayCount = 0;
-
- if(Redialing)
- {
- Time = 60 * (SubNode -> Entry ? SubNode -> Entry -> Config . RedialDelay : Config . RedialDelay) - DialTimeout;
-
- PrintInfo(PanelWindow,12,4,"%2ld:%02ld",Time / 60,Time % 60);
-
- DialTimeout++;
-
- /* No redial delay specified (zero), so we'll
- * fake it.
- */
-
- if(!(SubNode -> Entry ? SubNode -> Entry -> Config . RedialDelay : Config . RedialDelay))
- DialTimeout = 60 * (SubNode -> Entry ? SubNode -> Entry -> Config . RedialDelay : Config . RedialDelay);
-
- if(DialTimeout == 60 * (SubNode -> Entry ? SubNode -> Entry -> Config . RedialDelay : Config . RedialDelay))
- {
- Redialing = FALSE;
-
- if(++DialAttempt >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- NoRedial: Terminated = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Maximum Number Of Dial Retries Reached!");
-
- Say("Maximum number of dial retries reached.");
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(1,0);
- }
- else
- goto BigLoop;
- }
- }
- else
- {
- Time = (SubNode -> Entry ? SubNode -> Entry -> Config . DialTimeout : Config . DialTimeout - DialTimeout) - DialTimeout;
-
- PrintInfo(PanelWindow,12,4,"%2ld:%02ld",Time / 60,Time % 60);
-
- DialTimeout++;
-
- if(DialTimeout == (SubNode -> Entry ? SubNode -> Entry -> Config . DialTimeout : Config . DialTimeout))
- {
- PrintInfo(PanelWindow,12,7,"%-40.40s","Dial Attempt Timeout.");
-
- WaitTime(1,0);
-
- DialOn: if(SomeCount == SubListNum - 1)
- {
- if(DialAttempt + 1 >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- Redialing = FALSE;
-
- goto NoRedial;
- }
-
- Redialing = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Redial Delay...");
-
- SomeCount = 0;
- DialTimeout = 0;
-
- SubNode = (struct PhoneNode *)SubList -> lh_Head;
-
- WaitTime(0,MILLION / 2);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
- }
- else
- {
- SubNode = (struct PhoneNode *)SubNode -> VanillaNode . ln_Succ;
-
- SomeCount++;
-
- WaitTime(0,MILLION / 2);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- goto BigLoop;
- }
- }
- }
- }
-
- HandleSerial();
-
- /* Look for the hot key. */
-
- if(SetSignal(NULL,NULL) & SIGBREAKF_CTRL_F)
- {
- SetSignal(NULL,SIGBREAKF_CTRL_F);
-
- if(Redialing)
- {
- Redialing = FALSE;
-
- if(++DialAttempt >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- Terminated = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Maximum Number Of Dial Retries Reached!");
-
- Say("Maximum number of dial retries reached.");
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(1,0);
- }
- else
- {
- WaitTime(0,MILLION / 2);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- goto BigLoop;
- }
- }
- else
- {
- if(SomeCount == SubListNum - 1)
- {
- if(DialAttempt + 1 >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- Redialing = FALSE;
-
- goto NoRedial;
- }
-
- Redialing = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Redial Delay...");
-
- SomeCount = 0;
- DialTimeout = 0;
-
- SubNode = (struct PhoneNode *)SubList -> lh_Head;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
- }
- else
- {
- SubNode = (struct PhoneNode *)SubNode -> VanillaNode . ln_Succ;
-
- SomeCount++;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- goto BigLoop;
- }
- }
- }
-
- while(!Terminated && (Massage = (struct IntuiMessage *)GT_GetIMsg(PanelWindow -> UserPort)))
- {
- Class = Massage -> Class;
- Code = Massage -> Code;
- Gadget = (struct Gadget *)Massage -> IAddress;
-
- GT_ReplyIMsg(Massage);
-
- if(Class == MENUPICK)
- {
- struct MenuItem *MenuItem;
-
- while(Code != MENUNULL)
- {
- MenuItem = ItemAddress(PanelMenu,Code);
-
- switch((ULONG)MENU_USERDATA(MenuItem))
- {
- case MEN_QUITPANEL: Class = IDCMP_CLOSEWINDOW;
- break;
-
- case MEN_SKIP: Class = IDCMP_GADGETUP;
- Gadget = GadgetArray[GAD_SKIP];
- break;
-
- case MEN_ONLINE: Class = IDCMP_GADGETUP;
- Gadget = GadgetArray[GAD_ONLINE];
- break;
-
- case MEN_ABORT: Class = IDCMP_GADGETUP;
- Gadget = GadgetArray[GAD_ABORT];
- break;
-
- default: break;
- }
-
- Code = MenuItem -> NextSelect;
- }
- }
-
- if(Class == IDCMP_CLOSEWINDOW)
- {
- Terminated = TRUE;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
- }
-
- if(Class == IDCMP_GADGETUP)
- {
- switch(Gadget -> GadgetID)
- {
- case GAD_SKIP: if(Redialing)
- {
- Redialing = FALSE;
-
- if(++DialAttempt >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- Terminated = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Maximum Number Of Dial Retries Reached!");
-
- Say("Maximum number of dial retries reached.");
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(1,0);
- }
- else
- {
- WaitTime(0,MILLION / 2);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- goto BigLoop;
- }
- }
- else
- {
- if(SomeCount == SubListNum - 1)
- {
- if(DialAttempt + 1 >= (SubNode -> Entry ? SubNode -> Entry -> Config . DialRetries : Config . DialRetries))
- {
- Redialing = FALSE;
-
- goto NoRedial;
- }
-
- Redialing = TRUE;
-
- PrintInfo(PanelWindow,12,7,"%-40.40s","Redial Delay...");
-
- SomeCount = 0;
- DialTimeout = 0;
-
- SubNode = (struct PhoneNode *)SubList -> lh_Head;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
- }
- else
- {
- SubNode = (struct PhoneNode *)SubNode -> VanillaNode . ln_Succ;
-
- SomeCount++;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- goto BigLoop;
- }
- }
-
- break;
-
- case GAD_ONLINE:if(SubNode -> Entry)
- CopyMem(&SubNode -> Entry -> Config,&Config,sizeof(struct Configuration));
-
- if(SubNode -> Entry)
- {
- PayPerUnit[0] = SubNode -> Entry -> PayPerUnit[0];
- PayPerUnit[1] = SubNode -> Entry -> PayPerUnit[1];
-
- SecPerUnit[0] = SubNode -> Entry -> SecPerUnit[0];
- SecPerUnit[1] = SubNode -> Entry -> SecPerUnit[1];
-
- TimeOfDay[0] = SubNode -> Entry -> TimeOfDay[0];
- TimeOfDay[1] = SubNode -> Entry -> TimeOfDay[1];
-
- CurrentPay = 0;
-
- strcpy(Password,SubNode -> Entry -> Password);
-
- SendStartup = TRUE;
- }
- else
- {
- CurrentPay = 0;
-
- SecPerUnit[0] = SecPerUnit[1] = 0;
- PayPerUnit[0] = PayPerUnit[1] = 0;
-
- TimeOfDay[0] = TimeOfDay[1];
-
- Password[0] = 0;
-
- SendStartup = FALSE;
- }
-
- Online = TRUE;
- Terminated = TRUE;
-
- SubItemNum = SomeCount;
-
- if(SubNode -> Entry)
- LogAction("Connected to \"%s\".",SubNode -> Entry -> Name);
- else
- LogAction("Connected to %s.",SubNode -> VanillaNode . ln_Name);
-
- if(Config . ConnectAutoCapture && Config . CapturePath[0])
- {
- UBYTE SharedBuffer[256],Name[50],Date[20];
- struct DateTime DateTime;
-
- DateStamp(&DateTime . dat_Stamp);
-
- DateTime . dat_Format = FORMAT_DOS;
- DateTime . dat_Flags = 0;
- DateTime . dat_StrDay = NULL;
- DateTime . dat_StrDate = Date;
- DateTime . dat_StrTime = NULL;
-
- strcpy(SharedBuffer,Config . CapturePath);
-
- if(DateToStr(&DateTime))
- {
- if(SubNode -> Entry)
- {
- SHORT i;
-
- strcpy(Name,SubNode -> Entry -> Name);
-
- for(i = 0 ; i < strlen(Name) ; i++)
- {
- if(Name[i] == ' ')
- Name[i] = '_';
- }
- }
- else
- strcpy(Name,"Capture");
-
- strcat(Name,"_");
- strcat(Name,Date);
-
- if(AddPart(SharedBuffer,Name,256))
- {
- struct MenuItem *Item;
-
- Item = FindThisItem(MEN_CAPTUREDISK);
-
- if(FileCapture)
- Close(FileCapture);
-
- Item -> Flags &= ~CHECKED;
-
- if(GetFileSize(SharedBuffer))
- {
- if(FileCapture = Open(SharedBuffer,MODE_READWRITE))
- {
- if(Seek(FileCapture,0,OFFSET_END) == -1)
- {
- Close(FileCapture);
-
- FileCapture = NULL;
- }
- }
- }
- else
- FileCapture = Open(SharedBuffer,MODE_NEWFILE);
-
- if(FileCapture)
- {
- Item -> Flags |= CHECKED;
-
- strcpy(CaptureName,SharedBuffer);
- }
- }
- }
- }
-
- RemSubEntry();
-
- ConfigSetup();
-
- break;
-
- case GAD_ABORT: Terminated = TRUE;
-
- WaitTime(1,0);
- SerWrite("\r",1);
- WaitTime(0,MILLION / 2);
-
- break;
-
- default: break;
- }
- }
- }
- }
-
- if(!Online)
- {
- if(memcmp(&PrivateConfig,&Config,58))
- {
- swmem(&PrivateConfig,&Config,sizeof(struct Configuration));
-
- ConfigSetup();
-
- WaitTime(0,MILLION / 2);
- SerWrite("\rAT\r",4);
- WaitTime(0,MILLION / 2);
- }
-
- if(ExitString)
- {
- SerialCommand(ExitString);
- WaitTime(0,MILLION / 2);
- }
- }
-
- FlowInit();
-
- PanelWindow -> Flags |= WFLG_RMBTRAP;
-
- ClearMenuStrip(PanelWindow);
-
- RemoveGList(PanelWindow,GadgetList,(UWORD)-1);
-
- PopWindow();
-
- PositionX = PanelWindow -> LeftEdge;
- PositionY = PanelWindow -> TopEdge;
-
- CloseWindow(PanelWindow);
- }
- }
-
- FreeMenus(PanelMenu);
- }
-
- FreeGadgets(GadgetList);
- }
-
- Quiet = FALSE;
- }
-