1 /*
2  * Copyright (C) 2002-2003 Fhg Fokus
3  *
4  * This file is part of SEMS, a free SIP media server.
5  *
6  * SEMS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version. This program is released under
10  * the GPL with the additional exemption that compiling, linking,
11  * and/or using OpenSSL is allowed.
12  *
13  * For a license to use the SEMS software under conditions
14  * other than those described here, or to purchase support for this
15  * software, please contact iptel.org by e-mail at the following addresses:
16  *    info@iptel.org
17  *
18  * SEMS is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26  */
27 /** @file AmEvent.h */
28 #ifndef AmEvent_h
29 #define AmEvent_h
30 
31 #include "AmArg.h"
32 
33 #include <string>
34 using std::string;
35 
36 #define E_PLUGIN           100
37 #define E_SYSTEM           101
38 #define E_SIP_SUBSCRIPTION 102
39 #define E_B2B_APP          103
40 #define E_IVR              104
41 
42 
43 /** \brief base event class */
44 struct AmEvent
45 {
46   int event_id;
47   bool processed;
48 
49   AmEvent(int event_id);
50   AmEvent(const AmEvent& rhs);
51 
52   virtual ~AmEvent();
53 
54   virtual AmEvent* clone();
55 };
56 
57 /**
58  * \brief named event for inter-plugin-API
59  *
60  * Optionally the AmPluginEvent also holds a dynamic argument array.
61  */
62 struct AmPluginEvent: public AmEvent
63 {
64   string      name;
65   AmArg       data;
66 
67   AmPluginEvent(const string& n);
68 
69   AmPluginEvent(const string& n, const AmArg& d);
70 };
71 
72 /**
73  * Timer Event: Name
74  */
75 #define TIMEOUTEVENT_NAME "timer_timeout"
76 
77 /**
78  * \brief User Timer Event
79  * data[0]: int timer_id
80  */
81 class AmTimeoutEvent : public AmPluginEvent
82 {
83  public:
84   AmTimeoutEvent(int timer_id);
85 };
86 
87 /**
88  * \brief named event for system events (e.g. server stopped)
89  */
90 struct AmSystemEvent : public AmEvent
91 {
92   enum EvType {
93     ServerShutdown = 0,
94     User1,
95     User2
96   };
97 
98   EvType sys_event;
99 
100   AmSystemEvent(EvType e);
101 
102   AmSystemEvent(const AmSystemEvent& rhs);
103 
104   AmEvent* clone();
105 
106   static const char* getDescription(EvType t);
107 
108 };
109 
110 /** \brief event handler interface */
111 class AmEventHandler
112 {
113  public:
114   virtual void process(AmEvent*)=0;
~AmEventHandler()115   virtual ~AmEventHandler() { };
116 };
117 
118 #endif
119