AmSessionEventHandler.h

00001 /*
00002  * Copyright (C) 2002-2003 Fhg Fokus
00003  *
00004  * This file is part of SEMS, a free SIP media server.
00005  *
00006  * SEMS is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version. This program is released under
00010  * the GPL with the additional exemption that compiling, linking,
00011  * and/or using OpenSSL is allowed.
00012  *
00013  * For a license to use the SEMS software under conditions
00014  * other than those described here, or to purchase support for this
00015  * software, please contact iptel.org by e-mail at the following addresses:
00016  *    info@iptel.org
00017  *
00018  * SEMS is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License 
00024  * along with this program; if not, write to the Free Software 
00025  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00026  */
00027 #ifndef _AmSessionEventHandler_h
00028 #define _AmSessionEventHandler_h
00029 
00030 #include "AmArg.h"
00031 #include "AmSipMsg.h"
00032 #include "AmSipEvent.h"
00033 #include "AmSipDialog.h"
00034 #include <string>
00035 using std::string;
00036 
00037 class AmConfigReader;
00038 
00049 class AmSessionEventHandler
00050   : public AmObject
00051 {
00052 public:
00053   bool destroy;
00054 
00055   AmSessionEventHandler()
00056     : destroy(true) {}
00057 
00058   virtual ~AmSessionEventHandler() {}
00059 
00061   virtual int configure(AmConfigReader& conf);
00062 
00063   /* 
00064    * All the methods return true if the event processing 
00065    * shall be stopped after them.
00066    */
00067   virtual bool process(AmEvent*);
00068 
00069   virtual bool onSipRequest(const AmSipRequest&);
00070   virtual bool onSipReply(const AmSipReply&, AmSipDialog::Status old_dlg_status);
00071   virtual bool onSipReqTimeout(const AmSipRequest &);
00072   virtual bool onSipRplTimeout(const AmSipRequest &, const AmSipReply &);
00073 
00074   virtual bool onSendRequest(AmSipRequest& req, int flags);
00075   virtual bool onSendReply(AmSipReply& reply, int flags);
00076 };
00077 
00078 
00079 #if __GNUC__ < 3
00080 #define CALL_EVENT_H(method,args...) \
00081             do{\
00082                 vector<AmSessionEventHandler*>::iterator evh = ev_handlers.begin(); \
00083                 bool stop = false; \
00084                 while((evh != ev_handlers.end()) && !stop){ \
00085                     stop = (*evh)->method( ##args ); \
00086                     evh++; \
00087                 } \
00088                 if(stop) \
00089                     return; \
00090             }while(0)
00091 #else
00092 #define CALL_EVENT_H(method,...) \
00093             do{\
00094                 vector<AmSessionEventHandler*>::iterator evh = ev_handlers.begin(); \
00095                 bool stop = false; \
00096                 while((evh != ev_handlers.end()) && !stop){ \
00097                     stop = (*evh)->method( __VA_ARGS__ ); \
00098                     evh++; \
00099                 } \
00100                 if(stop) \
00101                     return; \
00102             }while(0)
00103 #endif
00104 
00105 #endif
Home |  Recent changes |  Search |  Glossary |  Sitemap |  Login