"Fossies" - the Fresh Open Source Software Archive

Member "bayonne-1.2.16/drivers/pika/join.cpp" (7 Jan 2001, 4006 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 "join.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 // As a special exception to the GNU General Public License, permission is
   18 // granted for additional uses of the text contained in its release
   19 // of Bayonne as noted here.
   20 //
   21 // This exception is that permission is hereby granted to link Bayonne 
   22 // with  the Pika MonteCarlo libraries to produce a executable image
   23 // without requiring MonteCarlo itself to be supplied in source form so
   24 // long as each source file so linked contains this exclusion.
   25 //
   26 // This exception does not however invalidate any other reasons why
   27 // the resulting executable file might be covered by the GNU General
   28 // public license or invalidate the licensing requirements of any
   29 // other component or library.
   30 //
   31 // This exception applies only to the code released by OST under the
   32 // name Bayonne.  If you copy code from other releases into a copy of
   33 // Bayonne, as the General Public License permits, the exception does not
   34 // apply to the code that you add in this way.  To avoid misleading
   35 // anyone as to the status of such modified files, you must delete
   36 // this exception notice from them.
   37 //
   38 // If you write modifications of your own to Bayonne, it is your choice
   39 // whether to permit this exception to apply to your modifications.
   40 // If you do not wish that, delete this exception notice, at which
   41 // point the terms of your modification would be covered under the GPL
   42 // as explicitly stated in "COPYING".
   43 
   44 #include "driver.h"
   45 
   46 bool PikaTrunk::joinHandler(TrunkEvent *event)
   47 {
   48     TrunkEvent jevent;
   49 
   50     switch(event->id)
   51     {
   52     case TRUNK_DTMF_KEYUP:
   53         if(joined)
   54             return true;
   55         return false;
   56     case TRUNK_TIMER_EXPIRED:
   57         disjoin();
   58         if(!TrunkSignal(TRUNK_SIGNAL_TIMEOUT))
   59             TrunkSignal(TRUNK_SIGNAL_STEP);
   60         handler = &PikaTrunk::stepHandler;
   61         return true;
   62     case TRUNK_ENTER_STATE:
   63         debug->DebugState(this, "join");
   64         endTimer();
   65         if(data.join.trunk)
   66         {
   67             jevent.id = TRUNK_JOIN_TRUNKS;
   68             jevent.parm.trunk = this;
   69             data.join.trunk->postEvent(&jevent);
   70             if(!joined)
   71             {
   72                 if(!TrunkSignal(TRUNK_SIGNAL_ERROR))
   73                     TrunkSignal(TRUNK_SIGNAL_STEP);
   74                 setSymbol(SYM_ERROR, "join-failed");
   75                 handler = &PikaTrunk::stepHandler;
   76                 return true;
   77             }
   78             status[id] = 'j';
   79         }
   80         else
   81         {
   82             Trunk::setDTMFDetect();
   83             status[id] = 'w';
   84         }
   85         if(data.join.wakeup)
   86             setTimer(data.join.wakeup);
   87         return true;
   88     case TRUNK_PART_TRUNKS:
   89         if(!joined)
   90             return true;
   91         
   92         endTimer();
   93         if(!TrunkSignal(TRUNK_SIGNAL_CANCEL))
   94             TrunkSignal(TRUNK_SIGNAL_HANGUP);
   95         handler = &PikaTrunk::stepHandler;
   96         return true;
   97     case TRUNK_SIGNAL_NOTIFY:
   98         if(joined)
   99             return false;
  100 
  101         if(event->parm.error)
  102             setSymbol(SYM_ERROR, event->parm.error);
  103 
  104         if(!TrunkSignal(TRUNK_SIGNAL_SIGNAL))
  105             TrunkSignal(TRUNK_SIGNAL_HANGUP);
  106         handler = &PikaTrunk::stepHandler;
  107         return true;
  108     case TRUNK_JOIN_TRUNKS:
  109         if(joined)
  110             return false;
  111 
  112         endTimer();
  113         stopDSP();
  114         joined = (PikaTrunk *)event->parm.trunk;        
  115         joined->joined = this;
  116         joined->stopDSP();
  117         if(!PK_MVIP_FullDuplexConnect(hTrk, joined->hTrk))
  118         {
  119             status[id] = 'j';
  120             return true;
  121         }
  122     
  123         joined = NULL;
  124         joined->joined = NULL;
  125         TrunkSignal(TRUNK_SIGNAL_ERROR);
  126         setSymbol(SYM_ERROR, "join-failed");
  127         handler = &PikaTrunk::stepHandler;
  128         return false;
  129     }
  130     return false;
  131 }