"Fossies" - the Fresh Open Source Software Archive

Member "bayonne-1.2.16/drivers/aculab/collect.cpp" (16 Jan 2003, 4111 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 "collect.cpp" see the Fossies "Dox" file reference documentation.

    1 // Copyright (C) 2002 David Kerry.
    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 Aculab telephony libraries to produce a executable image
   23 // without requiring Aculab's libraries to be supplied in a free software
   24 // license as long as each source file so linked contains this exclusion
   25 // and the unalrtered Aculab source files are made available.
   26 //
   27 // This exception does not however invalidate any other reasons why
   28 // the resulting executable file might be covered by the GNU General
   29 // public license or invalidate the licensing requirements of any
   30 // other component or library.
   31 //
   32 // This exception applies only to the code released by OST under the
   33 // name Bayonne.  If you copy code from other releases into a copy of
   34 // Bayonne, as the General Public License permits, the exception does not
   35 // apply to the code that you add in this way.  To avoid misleading
   36 // anyone as to the status of such modified files, you must delete
   37 // this exception notice from them.
   38 //
   39 // If you write modifications of your own to Bayonne, it is your choice
   40 // whether to permit this exception to apply to your modifications.
   41 // If you do not wish that, delete this exception notice, at which
   42 // point the terms of your modification would be covered under the GPL
   43 // as explicitly stated in "COPYING".
   44 
   45 #include "driver.h"
   46 
   47 #ifdef    CCXX_NAMESPACES
   48 using namespace std;
   49 namespace ost {
   50 #endif
   51 
   52 bool AculabTrunk::collectHandler(TrunkEvent *event)
   53 {
   54     unsigned short mask;
   55         unsigned copy = 0;
   56         Symbol *sym = (Symbol *)data.collect.var;
   57 
   58     switch(event->id)
   59     {
   60     case TRUNK_ENTER_STATE:
   61         enterState("collect");
   62         if(digits >= data.collect.count)
   63         {
   64             trunkSignal(TRUNK_SIGNAL_STEP);
   65             handler = &AculabTrunk::stepHandler;
   66             return true;
   67         }
   68         Trunk::flags.dsp = DSP_MODE_VOICE;
   69         setDTMFDetect(true);
   70         setTimer(data.collect.timeout);
   71         return true;
   72     case TRUNK_TIMER_EXPIRED:
   73         if(!trunkSignal(TRUNK_SIGNAL_TIMEOUT)) {
   74             trunkSignal(TRUNK_SIGNAL_STEP);
   75         }
   76         handler = &AculabTrunk::stepHandler;
   77         setDTMFDetect(false);
   78         return true;
   79     case TRUNK_DTMF_KEYUP:
   80         mask = (1 << event->parm.dtmf.digit);
   81         if(mask & data.collect.ignore) {
   82             return true;
   83         }
   84         if(!(mask & data.collect.term))
   85         {
   86             dtmf.bin.data[digits++] = digit[event->parm.dtmf.digit];
   87             dtmf.bin.data[digits] = 0;
   88         }               
   89         if(digits >= data.collect.count || (mask & data.collect.term))
   90         {
   91                         if(sym)
   92                         {
   93                                 copy = sym->flags.size;
   94                                 if(copy > digits)
   95                                         copy = digits;
   96                                 if(copy)
   97                                         strncpy(sym->data, dtmf.bin.data, copy);
   98                                 sym->data[copy] = 0;
   99                 sym->flags.initial = false;
  100                                 if(sym->flags.commit)
  101                                         commit(sym);
  102                 digits = 0;
  103                 dtmf.bin.data[0] = 0;
  104                         }
  105 
  106             endTimer();
  107             trunkSignal(TRUNK_SIGNAL_STEP);
  108             handler = &AculabTrunk::stepHandler;
  109         }
  110         else {
  111             setTimer(data.collect.timeout);
  112         }
  113         return true;
  114     }
  115     return false;
  116 }
  117 
  118 #ifdef    CCXX_NAMESPACES
  119 };
  120 #endif