]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add event system
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Dec 2005 19:53:29 +0000 (19:53 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 13 Dec 2005 19:53:29 +0000 (19:53 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@128 d0543943-73ff-0310-b7d9-9358b9ac24b2

Makefile.am
Makefile.in
modules.conf
src/include/config.h.in
src/include/switch.h
src/include/switch_core.h
src/include/switch_types.h
src/switch.c
src/switch_core.c

index 4bf53d80ddc89802f5592d63a9c46ff6da4ed8fb..d6ea4b4f8e9998b0f7bf828633b96dfa97cc31d9 100644 (file)
@@ -45,7 +45,8 @@ src/switch_console.c \
 src/switch_core.c \
 src/switch_loadable_module.c \
 src/switch_mutex.c \
-src/switch_utils.c
+src/switch_utils.c \
+src/switch_event.c
 
 #bindir = $(PREFIX)/bin
 #libdir = $(PREFIX)/lib
@@ -62,7 +63,8 @@ library_include_HEADERS =     src/include/switch.h \
                                src/include/switch_types.h \
                                src/include/switch_utils.h \
                                src/include/switch_caller.h \
-                               src/include/switch_buffer.h
+                               src/include/switch_buffer.h \
+                               src/include/switch_event.h
 
 lib_LTLIBRARIES                = libfreeswitch.la
 libfreeswitch_la_CFLAGS        = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g  
index 1067f7f59d33c8436e38481dc103057d6ee6de7b..6931eabf495f5120b0c155f5501012dd5902b1ff 100644 (file)
@@ -75,7 +75,8 @@ am_libfreeswitch_la_OBJECTS = libfreeswitch_la-switch_buffer.lo \
        libfreeswitch_la-switch_core.lo \
        libfreeswitch_la-switch_loadable_module.lo \
        libfreeswitch_la-switch_mutex.lo \
-       libfreeswitch_la-switch_utils.lo
+       libfreeswitch_la-switch_utils.lo \
+       libfreeswitch_la-switch_event.lo
 libfreeswitch_la_OBJECTS = $(am_libfreeswitch_la_OBJECTS)
 binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
 PROGRAMS = $(bin_PROGRAMS)
@@ -252,7 +253,8 @@ src/switch_console.c \
 src/switch_core.c \
 src/switch_loadable_module.c \
 src/switch_mutex.c \
-src/switch_utils.c
+src/switch_utils.c \
+src/switch_event.c
 
 
 #bindir = $(PREFIX)/bin
@@ -270,7 +272,8 @@ library_include_HEADERS = src/include/switch.h \
                                src/include/switch_types.h \
                                src/include/switch_utils.h \
                                src/include/switch_caller.h \
-                               src/include/switch_buffer.h
+                               src/include/switch_buffer.h \
+                               src/include/switch_event.h
 
 lib_LTLIBRARIES = libfreeswitch.la
 libfreeswitch_la_CFLAGS = $(AM_CFLAGS) -Wall -Werror -Wstrict-prototypes -Wmissing-prototypes -g  
@@ -406,6 +409,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_config.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_console.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_core.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_event.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_loadable_module.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_mutex.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libfreeswitch_la-switch_utils.Plo@am__quote@
@@ -494,6 +498,13 @@ libfreeswitch_la-switch_utils.lo: src/switch_utils.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_utils.lo `test -f 'src/switch_utils.c' || echo '$(srcdir)/'`src/switch_utils.c
 
+libfreeswitch_la-switch_event.lo: src/switch_event.c
+@am__fastdepCC_TRUE@   if $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -MT libfreeswitch_la-switch_event.lo -MD -MP -MF "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c; \
+@am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo" "$(DEPDIR)/libfreeswitch_la-switch_event.Plo"; else rm -f "$(DEPDIR)/libfreeswitch_la-switch_event.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='src/switch_event.c' object='libfreeswitch_la-switch_event.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libfreeswitch_la_CFLAGS) $(CFLAGS) -c -o libfreeswitch_la-switch_event.lo `test -f 'src/switch_event.c' || echo '$(srcdir)/'`src/switch_event.c
+
 freeswitch-switch.o: src/switch.c
 @am__fastdepCC_TRUE@   if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(freeswitch_CFLAGS) $(CFLAGS) -MT freeswitch-switch.o -MD -MP -MF "$(DEPDIR)/freeswitch-switch.Tpo" -c -o freeswitch-switch.o `test -f 'src/switch.c' || echo '$(srcdir)/'`src/switch.c; \
 @am__fastdepCC_TRUE@   then mv -f "$(DEPDIR)/freeswitch-switch.Tpo" "$(DEPDIR)/freeswitch-switch.Po"; else rm -f "$(DEPDIR)/freeswitch-switch.Tpo"; exit 1; fi
index 7c00f2874b1e7be0a7adcac13f44f2c51f116a52..1a10c37ecf7e57b3baf691370851d81f3dfd577e 100644 (file)
@@ -12,3 +12,4 @@ mod_rawaudio
 mod_iaxchan
 #mod_opalchan
 mod_codec_g729
+mod_event_test
index 75786f81fb7a4730cf0e146d42e270281f0137a8..5f449b963e7f9c5229fe638dbfd48fec38c479bd 100644 (file)
@@ -1,7 +1,4 @@
-/* config.h.in.  Generated from configure.in by autoheader.  */
-
-/* Define to 1 if you have the <arpa/inet.h> header file. */
-#undef HAVE_ARPA_INET_H
+/* src/include/config.h.in.  Generated from configure.in by autoheader.  */
 
 /* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
    */
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have the <fcntl.h> header file. */
-#undef HAVE_FCNTL_H
-
 /* Define to 1 if you have the `gethostname' function. */
 #undef HAVE_GETHOSTNAME
 
-/* Define to 1 if you have the `gettimeofday' function. */
-#undef HAVE_GETTIMEOFDAY
-
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `localtime_r' function. */
-#undef HAVE_LOCALTIME_R
-
 /* Define to 1 if your system has a GNU libc compatible `malloc' function, and
    to 0 otherwise. */
 #undef HAVE_MALLOC
 
-/* Define to 1 if you have the `memmove' function. */
-#undef HAVE_MEMMOVE
-
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the `memset' function. */
-#undef HAVE_MEMSET
-
 /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 #undef HAVE_NDIR_H
 
-/* Define to 1 if you have the <netdb.h> header file. */
-#undef HAVE_NETDB_H
-
-/* Define to 1 if you have the <netinet/in.h> header file. */
-#undef HAVE_NETINET_IN_H
-
-/* Define to 1 if you have the `socket' function. */
-#undef HAVE_SOCKET
-
 /* Define to 1 if you have the <stdint.h> header file. */
 #undef HAVE_STDINT_H
 
 /* Define to 1 if you have the <stdlib.h> header file. */
 #undef HAVE_STDLIB_H
 
-/* Define to 1 if you have the `strcasecmp' function. */
-#undef HAVE_STRCASECMP
-
-/* Define to 1 if you have the `strchr' function. */
-#undef HAVE_STRCHR
-
-/* Define to 1 if you have the `strdup' function. */
-#undef HAVE_STRDUP
-
 /* Define to 1 if you have the `strftime' function. */
 #undef HAVE_STRFTIME
 
 /* Define to 1 if you have the <string.h> header file. */
 #undef HAVE_STRING_H
 
-/* Define to 1 if you have the `strncasecmp' function. */
-#undef HAVE_STRNCASECMP
-
-/* Define to 1 if you have the `strstr' function. */
-#undef HAVE_STRSTR
-
 /* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
    */
 #undef HAVE_SYS_DIR_H
 
-/* Define to 1 if you have the <sys/ioctl.h> header file. */
-#undef HAVE_SYS_IOCTL_H
-
 /* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
    */
 #undef HAVE_SYS_NDIR_H
 
-/* Define to 1 if you have the <sys/socket.h> header file. */
-#undef HAVE_SYS_SOCKET_H
-
 /* Define to 1 if you have the <sys/stat.h> header file. */
 #undef HAVE_SYS_STAT_H
 
-/* Define to 1 if you have the <sys/time.h> header file. */
-#undef HAVE_SYS_TIME_H
-
 /* Define to 1 if you have the <sys/types.h> header file. */
 #undef HAVE_SYS_TYPES_H
 
index acb0d6a5a647579ba5f30d8a588b87e0bdf8476b..217ef666f39d1fbb6cfaecb577bf9ef81186e1c5 100644 (file)
@@ -116,7 +116,7 @@ extern "C" {
 #include <switch_module_interfaces.h>
 #include <switch_channel.h>
 #include <switch_buffer.h>
-
+#include <switch_event.h>
 
 #ifdef __cplusplus
 }
index eacb3c330ee5ed568cec48c4125bac178995396f..4146cfc4c02a0e71768886ad5301b8949aa04424 100644 (file)
@@ -119,6 +119,7 @@ SWITCH_DECLARE(switch_status) switch_core_session_set_read_codec(switch_core_ses
 SWITCH_DECLARE(switch_status) switch_core_session_set_write_codec(switch_core_session *session, switch_codec *codec);
 SWITCH_DECLARE(switch_memory_pool *) switch_core_session_get_pool(switch_core_session *session);
 SWITCH_DECLARE(void) pbx_core_session_signal_state_change(switch_core_session *session);
+SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup);
 
 #ifdef __cplusplus
 }
index eff3592fc23816bdda36ed850ab74404dedb8a39..211cb9b7abf5fb5c61615924d9847aba5d7fdf56 100644 (file)
@@ -122,6 +122,21 @@ typedef enum {
        SWITCH_IO_FLAG_NOOP = 0,
 } switch_io_flag;
 
+/* make sure this is synced with the EVENT_NAMES array in switch_event.c
+   also never put any new ones before EVENT_ALL
+*/
+typedef enum {
+       SWITCH_EVENT_CUSTOM,
+       SWITCH_EVENT_INBOUND_CHAN,
+       SWITCH_EVENT_OUTBOUND_CHAN,
+       SWITCH_EVENT_ANSWER_CHAN,
+       SWITCH_EVENT_HANGUP_CHAN,
+       SWITCH_EVENT_STARTUP,
+       SWITCH_EVENT_ALL
+} switch_event_t;
+
+typedef struct switch_event_node switch_event_node;
+typedef void (*switch_event_callback_t)(switch_event_t, int, char *);
 typedef struct switch_loadable_module switch_loadable_module;
 typedef struct switch_frame switch_frame;
 typedef struct switch_channel switch_channel;
index 7eae62fc3c758ea3af85b12b83f0fa83abb4d92e..b3b3841455474c1100db2a133beb5e6620d94708 100644 (file)
@@ -51,6 +51,7 @@ int main(int argc, char *argv[]) {
                exit(-1);
        }
 
+       switch_event_fire(SWITCH_EVENT_STARTUP, "Ready");
        switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_GLOBAL_VERSION);
 
        /* wait for console input */
index 0a62a795c97fb998a2ec6f6bc8c7365e2f590748..dcfc7bf2f88cdcc259da2328fd173ce163d6efd8 100644 (file)
@@ -422,6 +422,20 @@ SWITCH_DECLARE(char *) switch_core_session_strdup(switch_core_session *session,
        return duped;
 }
 
+
+SWITCH_DECLARE(char *) switch_core_strdup(switch_memory_pool *pool, char *todup)
+{
+       char *duped = NULL;
+
+       assert(pool != NULL);
+       assert(todup != NULL);
+
+       if (todup && (duped = apr_palloc(pool, strlen(todup)+1))) {
+               strcpy(duped, todup);
+       }
+       return duped;
+}
+
 SWITCH_DECLARE(void *) switch_core_session_get_private(switch_core_session *session)
 {
        assert(session != NULL);
@@ -1500,7 +1514,8 @@ SWITCH_DECLARE(switch_status) switch_core_init(void)
                return SWITCH_STATUS_MEMERR;
        }
        switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Allocated memory pool.\n");
-
+       switch_event_init(runtime.memory_pool);
+       
 #ifdef EMBED_PERL
        if (! (my_perl = perl_alloc())) {
                switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Could not allocate perl intrepreter\n");