"Fossies" - the Fresh Open Source Software Archive

Member "bayonne-1.2.16/drivers/aculab/hangup.cpp" (11 Dec 2002, 4672 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 "hangup.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 unaltered 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 
   46 #include "driver.h"
   47 
   48 #ifdef    CCXX_NAMESPACES
   49 using namespace std;
   50 namespace ost {
   51 #endif
   52 
   53 /*
   54  * We were either requested to hangup this trunk/line/channel, or
   55  * the remote party hung up on us and we now have to do the clean
   56  * up.
   57  */
   58 bool AculabTrunk::hangupHandler(TrunkEvent *event)
   59 {
   60     timeout_t reset = 0;
   61     struct cause_xparms cause;
   62     struct in_xparms in_xparms;
   63 
   64     slog(Slog::levelDebug) <<name<<": hangupHandler event "<<event->id<<endl;
   65 
   66     switch(event->id)
   67     {
   68     case TRUNK_ENTER_STATE:
   69         enterState("hangup");
   70         status[id] = 'h';
   71         exittimer=0;
   72         endTimer();
   73         Part();
   74 
   75         if(tgi.pid)
   76             kill(tgi.pid, SIGHUP);
   77 
   78         if (thread) {
   79             reset = thread->stop();
   80         }
   81         else {
   82             reset = 0;
   83         }
   84 
   85         Trunk::flags.dsp = DSP_MODE_INACTIVE;
   86 
   87         if (!(Trunk::flags.offhook || _call_setup)) {
   88             handler = &AculabTrunk::idleHandler;
   89 //          return true;
   90         }
   91 
   92     case TRUNK_CALL_RELEASE:
   93         /*
   94          * Release driver resources
   95          */
   96         endTimer();
   97         status[id] = '#';
   98 
   99         aculabivr.clrChannel(this);
  100 
  101         memset(&cause,0,sizeof(cause));
  102 
  103         cause.handle = handle;
  104         cause.cause  = 0;
  105         cause.raw    = 0;
  106         if (call_release(&cause)) {
  107             slog(Slog::levelError) <<name<<": call release FAILED"<<endl;
  108         }
  109 
  110         /*
  111          * Put an idle pattern onto network to please the exchange
  112          */
  113         idle_net_ts(port, ts);
  114 
  115         /*
  116          * Free up DSP resources
  117          */
  118         resetDSPChannel();
  119         freeDSP();
  120 
  121         /*
  122          * Reset channel and begin listening for incoming calls
  123          * again.
  124          */
  125         in_xparms.net=port;
  126         in_xparms.ts=ts;
  127         in_xparms.cnf=0;
  128         if (call_openin(&in_xparms) == 0) {
  129             /* channel # may change between calls! */
  130             handle=in_xparms.handle;
  131             channel=call_handle_2_chan(in_xparms.handle);
  132         }
  133         else {
  134             slog(Slog::levelError) <<name<<": call openin FAILED"<<endl;
  135         }
  136 
  137         aculabivr.setChannel(this);
  138 
  139         Trunk::flags.offhook=false;
  140 
  141         if((timeout_t)group->getHangup() > reset) {
  142             setTimer(group->getHangup());
  143         }
  144         else {
  145             setTimer(reset);
  146         }
  147 
  148         exittimer=0;
  149 
  150         detach();
  151 
  152         handler = &AculabTrunk::idleHandler;
  153 
  154         return true;
  155     case TRUNK_TIMER_EXPIRED:
  156         endTimer();
  157         stopServices();
  158         Trunk::flags.reset = false;
  159         handler = &AculabTrunk::idleHandler;
  160         return true;
  161     case TRUNK_MAKE_IDLE:
  162     case TRUNK_STOP_DISCONNECT:
  163     case TRUNK_LINE_WINK:
  164     case TRUNK_CPA_DIALTONE:
  165         return true;
  166     case TRUNK_RINGING_ON:
  167         endTimer();
  168         Trunk::flags.reset = false;
  169         handler = &AculabTrunk::idleHandler;
  170         return idleHandler(event);
  171     }
  172     return false;
  173 }
  174 
  175 #ifdef    CCXX_NAMESPACES
  176 };
  177 #endif