"Fossies" - the Fresh Open Source Software Archive

Member "bayonne-1.2.16/drivers/phonedev/step.cpp" (11 Apr 2003, 3400 Bytes) of package /linux/misc/old/bayonne-1.2.16.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "step.cpp" see the Fossies "Dox" file reference documentation.

    1 // Copyright (C) 2000 Open Source Telecom Corporation.
    2 //  
    3 // This program is free software; you can redistribute it and/or modify
    4 // it under the terms of the GNU General Public License as published by
    5 // the Free Software Foundation; either version 2 of the License, or
    6 // (at your option) any later version.
    7 // 
    8 // This program is distributed in the hope that it will be useful,
    9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
   10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11 // GNU General Public License for more details.
   12 // 
   13 // You should have received a copy of the GNU General Public License
   14 // along with this program; if not, write to the Free Software 
   15 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   16 
   17 #include "driver.h"
   18 
   19 #ifdef  CCXX_NAMESPACES
   20 namespace ost {
   21 using namespace std;
   22 #endif
   23 
   24 void PhonedevTrunk::trunkStep(trunkstep_t step)
   25 {
   26     TrunkEvent event;
   27     
   28     if(handler != &PhonedevTrunk::stepHandler)
   29         return;
   30 
   31     event.id = TRUNK_MAKE_STEP;
   32     event.parm.step = step;
   33     stepHandler(&event);
   34 }
   35 
   36 bool PhonedevTrunk::stepHandler(TrunkEvent *event)
   37 {
   38     switch(event->id)
   39     {
   40     case TRUNK_MAKE_STEP:
   41         if(idleHangup())
   42             return true;
   43         switch(event->parm.step)
   44         {
   45         case TRUNK_STEP_THREAD:
   46             handler = &PhonedevTrunk::threadHandler;
   47             return true;
   48         case TRUNK_STEP_SLEEP:
   49             handler = &PhonedevTrunk::sleepHandler;
   50             return true;
   51         case TRUNK_STEP_HANGUP:
   52             handler = &PhonedevTrunk::hangupHandler;
   53             return true;
   54         case TRUNK_STEP_ANSWER:
   55             handler = &PhonedevTrunk::answerHandler;
   56             return true;
   57         case TRUNK_STEP_COLLECT:
   58             handler = &PhonedevTrunk::collectHandler;
   59             return true;
   60         case TRUNK_STEP_FLASH:
   61             handler = &PhonedevTrunk::flashonHandler;
   62             return true;
   63         case TRUNK_STEP_PLAY:
   64             handler = &PhonedevTrunk::playHandler;
   65             return true;
   66         case TRUNK_STEP_RECORD:
   67             handler = &PhonedevTrunk::recordHandler;
   68             return true;
   69         case TRUNK_STEP_SOFTDIAL:
   70         case TRUNK_STEP_DIALXFER:
   71             handler = &PhonedevTrunk::dialHandler;
   72             return true;
   73         case TRUNK_STEP_PLAYWAIT:
   74             handler = &PhonedevTrunk::playwaitHandler;
   75             return true;
   76 #ifdef  XML_SCRIPTS
   77         case TRUNK_STEP_LOADER:
   78             handler = &PhonedevTrunk::loadHandler;
   79             return true;
   80 #endif
   81         }
   82         return false;
   83     case TRUNK_SERVICE_SUCCESS:
   84     case TRUNK_SERVICE_FAILURE:
   85         endTimer();
   86         setTimer(keythreads.getResetDelay());
   87         return true;
   88     case TRUNK_STOP_STATE:
   89     case TRUNK_TIMER_EXPIRED:
   90         flags.reset = false;
   91         stopServices();
   92     case TRUNK_ENTER_STATE:
   93         if(flags.offhook)
   94         {
   95             if(flags.trunk == TRUNK_MODE_OUTGOING)
   96                 status[id] = 'o';
   97             else
   98                 status[id] = 'i';
   99             setCPADetect(CPA_DIALTONE, true);
  100         }
  101         else
  102             setCPADetect(CPA_DIALTONE, false);
  103         setEcho(ECHO_OFF);
  104         setCPADetect(CPA_BUSYTONE, false);
  105         setDTMFDetect();
  106         endTimer();
  107 
  108         // if a dsp reset has occured, then we add a delay
  109         // for the dsp to settle before stepping
  110         if(flags.reset || thread)
  111         {
  112             enterState("reset");
  113             if(thread)
  114                 setTimer(thread->stop());
  115             else
  116                 setTimer(keythreads.getResetDelay());
  117             return true;
  118         }
  119         strcpy(numbers[5].sym.data, "step");
  120         debug->debugStep(this, getScript());
  121         monitor->monitorStep(this, getScript());
  122 
  123         // step and delay if still in same handler
  124 
  125         scriptStep();
  126 
  127         if(handler == &PhonedevTrunk::stepHandler)
  128             setTimer(keythreads.getStepDelay());
  129 
  130         return true;
  131     }
  132     return false;
  133 }
  134 
  135 #ifdef  CCXX_NAMESPACES
  136 };
  137 #endif