]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add new chatplan concept and mod_sms. Apps for chat messages: copy new base freeswit...
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 21 Sep 2011 19:31:10 +0000 (14:31 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 21 Sep 2011 19:31:18 +0000 (14:31 -0500)
35 files changed:
conf/chatplan/default.xml [new file with mode: 0644]
conf/freeswitch.xml
libs/esl/src/esl_event.c
libs/esl/src/include/esl_event.h
src/include/switch_core.h
src/include/switch_cpp.h
src/include/switch_event.h
src/include/switch_ivr.h
src/include/switch_loadable_module.h
src/include/switch_module_interfaces.h
src/include/switch_regex.h
src/include/switch_types.h
src/mod/applications/mod_sms/mod_sms.2008.vcproj [new file with mode: 0644]
src/mod/applications/mod_sms/mod_sms.2010.vcxproj [new file with mode: 0644]
src/mod/applications/mod_sms/mod_sms.c [new file with mode: 0644]
src/mod/endpoints/mod_dingaling/mod_dingaling.c
src/mod/endpoints/mod_sofia/sofia_presence.c
src/mod/endpoints/mod_sofia/sofia_reg.c
src/mod/languages/mod_java/src/org/freeswitch/swig/Event.java
src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java
src/mod/languages/mod_java/switch_swig_wrap.cpp
src/mod/languages/mod_lua/mod_lua.cpp
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/mod/languages/mod_managed/freeswitch_wrap.cxx
src/mod/languages/mod_managed/managed/swig.cs
src/mod/languages/mod_perl/freeswitch.pm
src/mod/languages/mod_perl/mod_perl_wrap.cpp
src/mod/languages/mod_python/freeswitch.py
src/mod/languages/mod_python/mod_python_wrap.cpp
src/switch_cpp.cpp
src/switch_event.c
src/switch_ivr.c
src/switch_loadable_module.c
src/switch_regex.c
src/switch_xml.c

diff --git a/conf/chatplan/default.xml b/conf/chatplan/default.xml
new file mode 100644 (file)
index 0000000..b67bb63
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<include>
+  <context name="default">
+
+    <extension name="demo">
+      <condition field="to" expression="^(.*)$">
+       <!--    <action application="lua" data="test.lua"/> -->
+
+       <action application="reply" data="Hello, you said: ${_body}"/>
+      </condition>
+    </extension>
+
+  </context>
+</include>
index 42eede31ee09dfc47d4e89f48ac64b379f5876f8..7a1b1d3d1581231d3168e0c37f1a8abe27846c97 100644 (file)
     <X-PRE-PROCESS cmd="include" data="dialplan/*.xml"/>
   </section>
 
+  <section name="chatplan" description="Regex/XML Chatplan">
+    <X-PRE-PROCESS cmd="include" data="chatplan/*.xml"/>
+  </section>
+
   <!-- mod_dingaling is reliant on the vcard data in the "directory" section. -->
   <!-- mod_sofia is reliant on the user data for authorization --> 
   <section name="directory" description="User Directory">
index 71e7d42b2a9dc31868fc01afa7654cd26f08c66b..ead853ea4636447614bfc75521be4584c081f24b 100644 (file)
@@ -270,8 +270,9 @@ ESL_DECLARE(char *) esl_event_get_header_idx(esl_event_t *event, const char *hea
                }
 
                return hp->value;
-               
-       }
+       } else if (!strcmp(header_name, "_body")) {
+               return event->body;
+       }               
 
        return NULL;
 }
@@ -414,6 +415,10 @@ static esl_status_t esl_event_base_add_header(esl_event_t *event, esl_stack_t st
        int index = 0;
        char *real_header_name = NULL;
 
+       if (!strcmp(header_name, "_body")) {
+               esl_event_set_body(event, data);
+       }
+
        if ((index_ptr = strchr(header_name, '['))) {
                index_ptr++;
                index = atoi(index_ptr);
@@ -604,6 +609,17 @@ ESL_DECLARE(esl_status_t) esl_event_add_header_string(esl_event_t *event, esl_st
        return ESL_FAIL;
 }
 
+ESL_DECLARE(esl_status_t) esl_event_set_body(esl_event_t *event, const char *body)
+{
+       esl_safe_free(event->body);
+
+       if (body) {
+               event->body = DUP(body);
+       }
+       
+       return ESL_SUCCESS;
+}
+
 ESL_DECLARE(esl_status_t) esl_event_add_body(esl_event_t *event, const char *fmt, ...)
 {
        int ret = 0;
index d6be0470e88004d6dbb9427eedeb82e51c5ecc20..1cc6134e421c2c3b7a4491ff535cfc29c9950769 100644 (file)
@@ -298,6 +298,7 @@ ESL_DECLARE(esl_status_t) esl_event_create_json(esl_event_t **event, const char
   \note the body parameter can be shadowed by the esl_event_reserve_subclass_detailed function
 */
 ESL_DECLARE(esl_status_t) esl_event_add_body(esl_event_t *event, const char *fmt, ...);
+ESL_DECLARE(esl_status_t) esl_event_set_body(esl_event_t *event, const char *body);
 
 /*!
   \brief Create a new event assuming it will not be custom event and therefore hiding the unused parameters
index 1591cf18ccede6b4dad4f37a60d7fe4b6481207c..7f1db105f80d9035f4a02478d0c64297e1b6f34e 100644 (file)
@@ -2110,7 +2110,7 @@ SWITCH_DECLARE(void) switch_cond_next(void);
 SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to,
                                                                                                                   const char *subject, const char *body, const char *type, const char *hint);
 SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event);
-
+SWITCH_DECLARE(switch_status_t) switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event);
 
 SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds);
 
index e9f5c29d92b6690d17f49eff5a3705146b4a66cd..70e484bf51b1780c38d6ecf253738eab9fe7d20b 100644 (file)
@@ -156,6 +156,8 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod
                 SWITCH_DECLARE_CONSTRUCTOR Event(const char *type, const char *subclass_name = NULL);
                 SWITCH_DECLARE_CONSTRUCTOR Event(switch_event_t *wrap_me, int free_me = 0);
                 virtual SWITCH_DECLARE_CONSTRUCTOR ~ Event();
+                SWITCH_DECLARE(int) chat_execute(const char *app, const char *data = NULL);
+                SWITCH_DECLARE(int) chat_send(const char *dest_proto = NULL);
                 SWITCH_DECLARE(const char *) serialize(const char *format = NULL);
                 SWITCH_DECLARE(bool) setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
                 SWITCH_DECLARE(const char *) getHeader(const char *header_name);
index c6b1d64c35ae8a44dca5d59a9623d9ad9ed09dfc..23cd0825b5275c6e1d1446d8acaff52c44edfb69 100644 (file)
@@ -103,7 +103,8 @@ struct switch_event {
 };
 
 typedef enum {
-       EF_UNIQ_HEADERS = (1 << 0)
+       EF_UNIQ_HEADERS = (1 << 0),
+       EF_NO_CHAT_EXEC = (1 << 1)
 } switch_event_flag_t;
 
 
@@ -157,6 +158,8 @@ _Ret_opt_z_ SWITCH_DECLARE(char *) switch_event_get_header_idx(switch_event_t *e
 
 #define switch_event_get_header_nil(e, h) switch_str_nil(switch_event_get_header(e,h))
 
+SWITCH_DECLARE(switch_status_t) switch_event_rename_header(switch_event_t *event, const char *header_name, const char *new_header_name);
+
 /*!
   \brief Retrieve the body value from an event
   \param event the event to read the body from
@@ -207,6 +210,8 @@ SWITCH_DECLARE(void) switch_event_destroy(switch_event_t **event);
 */
 SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_event_t *todup);
 SWITCH_DECLARE(void) switch_event_merge(switch_event_t *event, switch_event_t *tomerge);
+SWITCH_DECLARE(switch_status_t) switch_event_dup_reply(switch_event_t **event, switch_event_t *todup);
+
 /*!
   \brief Fire an event with full arguement list
   \param file the calling file
@@ -321,6 +326,9 @@ SWITCH_DECLARE(switch_status_t) switch_event_running(void);
 */
 SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...) PRINTF_FUNCTION(2, 3);
 #endif
+
+SWITCH_DECLARE(switch_status_t) switch_event_set_body(switch_event_t *event, const char *body);
+
 SWITCH_DECLARE(char *) switch_event_expand_headers(switch_event_t *event, const char *in);
 
 SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char *file, _In_z_ char *func, _In_ int line,
index 6b2a10d43f764ac5dda108ee7cc96bfae7b6c7e1..901519f7dd7ae0f0315c899e3a7981d2a9f69054 100644 (file)
@@ -931,6 +931,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_release_file_handle(switch_core_sessi
 SWITCH_DECLARE(switch_status_t) switch_ivr_process_fh(switch_core_session_t *session, const char *cmd, switch_file_handle_t *fhp);
 SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *session, const char *file, const char *insert_file, switch_size_t sample_point);
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto);
+
 /** @} */
 
 SWITCH_END_EXTERN_C
index 4b81a1f25e1881193b0090e0fc7104b80bc593d7..62fcac23430aa6fd716dbcd1baee1982f29ffa82 100644 (file)
@@ -55,33 +55,35 @@ SWITCH_BEGIN_EXTERN_C
        struct switch_loadable_module_interface {
        /*! the name of the module */
        const char *module_name;
-       /*! the table of endpoints the module has implmented */
+       /*! the table of endpoints the module has implemented */
        switch_endpoint_interface_t *endpoint_interface;
-       /*! the table of timers the module has implmented */
+       /*! the table of timers the module has implemented */
        switch_timer_interface_t *timer_interface;
-       /*! the table of dialplans the module has implmented */
+       /*! the table of dialplans the module has implemented */
        switch_dialplan_interface_t *dialplan_interface;
-       /*! the table of codecs the module has implmented */
+       /*! the table of codecs the module has implemented */
        switch_codec_interface_t *codec_interface;
-       /*! the table of applications the module has implmented */
+       /*! the table of applications the module has implemented */
        switch_application_interface_t *application_interface;
-       /*! the table of api functions the module has implmented */
+       /*! the table of chat applications the module has implemented */
+       switch_chat_application_interface_t *chat_application_interface;
+       /*! the table of api functions the module has implemented */
        switch_api_interface_t *api_interface;
-       /*! the table of file formats the module has implmented */
+       /*! the table of file formats the module has implemented */
        switch_file_interface_t *file_interface;
-       /*! the table of speech interfaces the module has implmented */
+       /*! the table of speech interfaces the module has implemented */
        switch_speech_interface_t *speech_interface;
-       /*! the table of directory interfaces the module has implmented */
+       /*! the table of directory interfaces the module has implemented */
        switch_directory_interface_t *directory_interface;
-       /*! the table of chat interfaces the module has implmented */
+       /*! the table of chat interfaces the module has implemented */
        switch_chat_interface_t *chat_interface;
-       /*! the table of say interfaces the module has implmented */
+       /*! the table of say interfaces the module has implemented */
        switch_say_interface_t *say_interface;
-       /*! the table of asr interfaces the module has implmented */
+       /*! the table of asr interfaces the module has implemented */
        switch_asr_interface_t *asr_interface;
-       /*! the table of management interfaces the module has implmented */
+       /*! the table of management interfaces the module has implemented */
        switch_management_interface_t *management_interface;
-       /*! the table of limit interfaces the module has implmented */
+       /*! the table of limit interfaces the module has implemented */
        switch_limit_interface_t *limit_interface;
        switch_thread_rwlock_t *rwlock;
        int refs;
@@ -169,6 +171,15 @@ SWITCH_DECLARE(switch_timer_interface_t *) switch_loadable_module_get_timer_inte
  */
 SWITCH_DECLARE(switch_application_interface_t *) switch_loadable_module_get_application_interface(const char *name);
 
+/*!
+  \brief Retrieve the chat application interface by it's registered name
+  \param name the name of the chat application
+  \return the desired chat application interface
+ */
+SWITCH_DECLARE(switch_chat_application_interface_t *) switch_loadable_module_get_chat_application_interface(const char *name);
+
+SWITCH_DECLARE(switch_status_t) switch_core_execute_chat_app(switch_event_t *message, const char *app, const char *data);
+
 /*!
   \brief Retrieve the API interface by it's registered name
   \param name the name of the API
@@ -335,6 +346,18 @@ SWITCH_MOD_DECLARE(switch_status_t) switch_module_shutdown(void);
        break; \
        }
 
+#define SWITCH_ADD_CHAT_APP(app_int, int_name, short_descript, long_descript, funcptr, syntax_string, app_flags) \
+       for (;;) { \
+       app_int = (switch_chat_application_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_CHAT_APPLICATION_INTERFACE); \
+       app_int->interface_name = int_name; \
+       app_int->chat_application_function = funcptr; \
+       app_int->short_desc = short_descript; \
+       app_int->long_desc = long_descript; \
+       app_int->syntax = syntax_string; \
+       app_int->flags = app_flags; \
+       break; \
+       }
+
 #define SWITCH_ADD_DIALPLAN(dp_int, int_name, funcptr) \
        for (;;) { \
        dp_int = (switch_dialplan_interface_t *)switch_loadable_module_create_interface(*module_interface, SWITCH_DIALPLAN_INTERFACE); \
index 7c666ab9f4ccf2c42e2d6a81d00246f453fa4451..acb85407c73577e86f504ee4796c4493ad276708 100644 (file)
@@ -681,6 +681,27 @@ struct switch_application_interface {
        struct switch_application_interface *next;
 };
 
+/*! \brief A module interface to implement a chat application */
+struct switch_chat_application_interface {
+       /*! the name of the interface */
+       const char *interface_name;
+       /*! function the application implements */
+       switch_chat_application_function_t chat_application_function;
+       /*! the long winded description of the application */
+       const char *long_desc;
+       /*! the short and sweet description of the application */
+       const char *short_desc;
+       /*! an example of the application syntax */
+       const char *syntax;
+       /*! flags to control behaviour */
+       uint32_t flags;
+       switch_thread_rwlock_t *rwlock;
+       int refs;
+       switch_mutex_t *reflock;
+       switch_loadable_module_interface_t *parent;
+       struct switch_chat_application_interface *next;
+};
+
 /*! \brief A module interface to implement an api function */
 struct switch_api_interface {
        /*! the name of the interface */
index 27f4852966e4fadd0bf049f4a4ccc89f3623f921..6558299b53b572a1bcc58756bd0b1ebd74bdcb4f 100644 (file)
@@ -74,6 +74,7 @@ SWITCH_DECLARE(void) switch_capture_regex(switch_regex_t *re, int match_count, c
                                                                                  int *ovector, const char *var, switch_cap_callback_t callback, void *user_data);
 
 SWITCH_DECLARE_NONSTD(void) switch_regex_set_var_callback(const char *var, const char *val, void *user_data);
+SWITCH_DECLARE_NONSTD(void) switch_regex_set_event_header_callback(const char *var, const char *val, void *user_data);
 
 #define switch_regex_safe_free(re)     if (re) {\
                                switch_regex_free(re);\
index c7e8a5f4725cf327000c9ceed9ec9f4ff0bf5691..e0419718c1600a5f54bf78f766a1e0a76c787c97 100644 (file)
@@ -325,7 +325,8 @@ typedef enum {
        SWITCH_SAY_INTERFACE,
        SWITCH_ASR_INTERFACE,
        SWITCH_MANAGEMENT_INTERFACE,
-       SWITCH_LIMIT_INTERFACE
+       SWITCH_LIMIT_INTERFACE,
+       SWITCH_CHAT_APPLICATION_INTERFACE
 } switch_module_interface_name_t;
 
 typedef enum {
@@ -495,6 +496,7 @@ typedef enum {
        SWITCH_XML_SECTION_DIRECTORY = (1 << 1),
        SWITCH_XML_SECTION_DIALPLAN = (1 << 2),
        SWITCH_XML_SECTION_PHRASES = (1 << 3),
+       SWITCH_XML_SECTION_CHATPLAN = (1 << 4),
 
        /* Nothing after this line */
        SWITCH_XML_SECTION_MAX = (1 << 4)
@@ -1221,6 +1223,12 @@ typedef enum {
 } switch_application_flag_enum_t;
 typedef uint32_t switch_application_flag_t;
 
+typedef enum {
+       SCAF_NONE = 0
+} switch_chat_application_flag_enum_t;
+typedef uint32_t switch_chat_application_flag_t;
+
+
 /*!
   \enum switch_signal_t
   \brief Signals to send to channels
@@ -1729,6 +1737,7 @@ typedef struct switch_timer_interface switch_timer_interface_t;
 typedef struct switch_dialplan_interface switch_dialplan_interface_t;
 typedef struct switch_codec_interface switch_codec_interface_t;
 typedef struct switch_application_interface switch_application_interface_t;
+typedef struct switch_chat_application_interface switch_chat_application_interface_t;
 typedef struct switch_api_interface switch_api_interface_t;
 typedef struct switch_file_interface switch_file_interface_t;
 typedef struct switch_speech_interface switch_speech_interface_t;
@@ -1780,7 +1789,8 @@ typedef switch_status_t (*switch_core_codec_fmtp_parse_func_t) (const char *fmtp
 typedef switch_status_t (*switch_core_codec_destroy_func_t) (switch_codec_t *);
 
 
-
+typedef switch_status_t (*switch_chat_application_function_t) (switch_event_t *, const char *);
+#define SWITCH_STANDARD_CHAT_APP(name) static switch_status_t name (switch_event_t *message, const char *data)
 
 typedef void (*switch_application_function_t) (switch_core_session_t *, const char *);
 #define SWITCH_STANDARD_APP(name) static void name (switch_core_session_t *session, const char *data)
diff --git a/src/mod/applications/mod_sms/mod_sms.2008.vcproj b/src/mod/applications/mod_sms/mod_sms.2008.vcproj
new file mode 100644 (file)
index 0000000..6d9109b
--- /dev/null
@@ -0,0 +1,287 @@
+<?xml version="1.0" encoding="Windows-1252"?>\r
+<VisualStudioProject\r
+       ProjectType="Visual C++"\r
+       Version="9.00"\r
+       Name="mod_sms"\r
+       ProjectGUID="{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}"\r
+       RootNamespace="mod_sms"\r
+       Keyword="Win32Proj"\r
+       TargetFrameworkVersion="131072"\r
+       >\r
+       <Platforms>\r
+               <Platform\r
+                       Name="Win32"\r
+               />\r
+               <Platform\r
+                       Name="x64"\r
+               />\r
+       </Platforms>\r
+       <ToolFiles>\r
+       </ToolFiles>\r
+       <Configurations>\r
+               <Configuration\r
+                       Name="Debug|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               UsePrecompiledHeader="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               RandomizedBaseAddress="1"\r
+                               DataExecutionPrevention="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Debug|x64"\r
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               UsePrecompiledHeader="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"\r
+                               RandomizedBaseAddress="1"\r
+                               DataExecutionPrevention="0"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|Win32"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               UsePrecompiledHeader="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               RandomizedBaseAddress="1"\r
+                               DataExecutionPrevention="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+               <Configuration\r
+                       Name="Release|x64"\r
+                       OutputDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"\r
+                       ConfigurationType="2"\r
+                       InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"\r
+                       CharacterSet="2"\r
+                       >\r
+                       <Tool\r
+                               Name="VCPreBuildEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCustomBuildTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXMLDataGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCWebServiceProxyGeneratorTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCMIDLTool"\r
+                               TargetEnvironment="3"\r
+                       />\r
+                       <Tool\r
+                               Name="VCCLCompilerTool"\r
+                               UsePrecompiledHeader="0"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManagedResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCResourceCompilerTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPreLinkEventTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCLinkerTool"\r
+                               OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"\r
+                               RandomizedBaseAddress="1"\r
+                               DataExecutionPrevention="0"\r
+                               TargetMachine="17"\r
+                       />\r
+                       <Tool\r
+                               Name="VCALinkTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCManifestTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCXDCMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCBscMakeTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCFxCopTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCAppVerifierTool"\r
+                       />\r
+                       <Tool\r
+                               Name="VCPostBuildEventTool"\r
+                       />\r
+               </Configuration>\r
+       </Configurations>\r
+       <References>\r
+       </References>\r
+       <Files>\r
+               <File\r
+                       RelativePath=".\mod_sms.c"\r
+                       >\r
+               </File>\r
+       </Files>\r
+       <Globals>\r
+       </Globals>\r
+</VisualStudioProject>\r
diff --git a/src/mod/applications/mod_sms/mod_sms.2010.vcxproj b/src/mod/applications/mod_sms/mod_sms.2010.vcxproj
new file mode 100644 (file)
index 0000000..4dbbf47
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+  <ItemGroup Label="ProjectConfigurations">\r
+    <ProjectConfiguration Include="Debug|Win32">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Debug|x64">\r
+      <Configuration>Debug</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|Win32">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>Win32</Platform>\r
+    </ProjectConfiguration>\r
+    <ProjectConfiguration Include="Release|x64">\r
+      <Configuration>Release</Configuration>\r
+      <Platform>x64</Platform>\r
+    </ProjectConfiguration>\r
+  </ItemGroup>\r
+  <PropertyGroup Label="Globals">\r
+    <ProjectName>mod_sms</ProjectName>\r
+    <ProjectGuid>{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}</ProjectGuid>\r
+    <RootNamespace>mod_sms</RootNamespace>\r
+    <Keyword>Win32Proj</Keyword>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">\r
+    <ConfigurationType>DynamicLibrary</ConfigurationType>\r
+    <CharacterSet>MultiByte</CharacterSet>\r
+  </PropertyGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+  <ImportGroup Label="ExtensionSettings">\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+    <Import Project="..\..\..\..\w32\module_release.props" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+    <Import Project="..\..\..\..\w32\module_debug.props" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+    <Import Project="..\..\..\..\w32\module_release.props" />\r
+  </ImportGroup>\r
+  <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">\r
+    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+    <Import Project="..\..\..\..\w32\module_debug.props" />\r
+  </ImportGroup>\r
+  <PropertyGroup Label="UserMacros" />\r
+  <PropertyGroup>\r
+    <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>\r
+    <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>\r
+    <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>\r
+  </PropertyGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+    </ClCompile>\r
+    <Link>\r
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>\r
+      <DataExecutionPrevention>\r
+      </DataExecutionPrevention>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">\r
+    <Midl>\r
+      <TargetEnvironment>X64</TargetEnvironment>\r
+    </Midl>\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+    </ClCompile>\r
+    <Link>\r
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>\r
+      <DataExecutionPrevention>\r
+      </DataExecutionPrevention>\r
+      <TargetMachine>MachineX64</TargetMachine>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+    </ClCompile>\r
+    <Link>\r
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>\r
+      <DataExecutionPrevention>\r
+      </DataExecutionPrevention>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">\r
+    <Midl>\r
+      <TargetEnvironment>X64</TargetEnvironment>\r
+    </Midl>\r
+    <ClCompile>\r
+      <PrecompiledHeader>\r
+      </PrecompiledHeader>\r
+    </ClCompile>\r
+    <Link>\r
+      <RandomizedBaseAddress>false</RandomizedBaseAddress>\r
+      <DataExecutionPrevention>\r
+      </DataExecutionPrevention>\r
+      <TargetMachine>MachineX64</TargetMachine>\r
+    </Link>\r
+  </ItemDefinitionGroup>\r
+  <ItemGroup>\r
+    <ClCompile Include="mod_sms.c" />\r
+  </ItemGroup>\r
+  <ItemGroup>\r
+    <ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2010.vcxproj">\r
+      <Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>\r
+      <ReferenceOutputAssembly>false</ReferenceOutputAssembly>\r
+    </ProjectReference>\r
+  </ItemGroup>\r
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+  <ImportGroup Label="ExtensionTargets">\r
+  </ImportGroup>\r
+</Project>\r
diff --git a/src/mod/applications/mod_sms/mod_sms.c b/src/mod/applications/mod_sms/mod_sms.c
new file mode 100644 (file)
index 0000000..096ee6b
--- /dev/null
@@ -0,0 +1,510 @@
+/* 
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005-2011, Anthony Minessale II <anthm@freeswitch.org>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthm@freeswitch.org>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * 
+ * Anthony Minessale II <anthm@freeswitch.org>
+ *
+ * mod_sms.c -- Abstract SMS 
+ *
+ */
+#include <switch.h>
+#define SMS_CHAT_PROTO "GLOBAL_SMS"
+#define MY_EVENT_SEND_MESSAGE "SMS::SEND_MESSAGE"
+
+/* Prototypes */
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown);
+SWITCH_MODULE_RUNTIME_FUNCTION(mod_sms_runtime);
+SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load);
+SWITCH_MODULE_DEFINITION(mod_sms, mod_sms_load, mod_sms_shutdown, NULL);
+
+
+static void event_handler(switch_event_t *event) 
+{
+       const char *dest_proto = switch_event_get_header(event, "dest_proto");
+       switch_core_chat_send(dest_proto, event);
+}
+
+typedef enum {
+       BREAK_ON_TRUE,
+       BREAK_ON_FALSE,
+       BREAK_ALWAYS,
+       BREAK_NEVER
+} break_t;
+
+
+
+static int parse_exten(switch_event_t *event, switch_xml_t xexten, switch_event_t **extension)
+{
+       switch_xml_t xcond, xaction, xexpression;
+       char *exten_name = (char *) switch_xml_attr(xexten, "name");
+       int proceed = 0;
+       char *expression_expanded = NULL, *field_expanded = NULL;
+       switch_regex_t *re = NULL;
+       const char *to = switch_event_get_header(event, "to");
+
+       if (!to) {
+               to = "nobody";
+       }
+
+       if (!exten_name) {
+               exten_name = "_anon_";
+       }
+
+       for (xcond = switch_xml_child(xexten, "condition"); xcond; xcond = xcond->next) {
+               char *field = NULL;
+               char *do_break_a = NULL;
+               char *expression = NULL;
+               const char *field_data = NULL;
+               int ovector[30];
+               switch_bool_t anti_action = SWITCH_TRUE;
+               break_t do_break_i = BREAK_ON_FALSE;
+
+               int time_match = switch_xml_std_datetime_check(xcond);
+
+               switch_safe_free(field_expanded);
+               switch_safe_free(expression_expanded);
+
+               if (switch_xml_child(xcond, "condition")) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Nested conditions are not allowed!\n");
+                       proceed = 1;
+                       goto done;
+               }
+
+               field = (char *) switch_xml_attr(xcond, "field");
+
+               if ((xexpression = switch_xml_child(xcond, "expression"))) {
+                       expression = switch_str_nil(xexpression->txt);
+               } else {
+                       expression = (char *) switch_xml_attr_soft(xcond, "expression");
+               }
+
+               if ((expression_expanded = switch_event_expand_headers(event, expression)) == expression) {
+                       expression_expanded = NULL;
+               } else {
+                       expression = expression_expanded;
+               }
+
+               if ((do_break_a = (char *) switch_xml_attr(xcond, "break"))) {
+                       if (!strcasecmp(do_break_a, "on-true")) {
+                               do_break_i = BREAK_ON_TRUE;
+                       } else if (!strcasecmp(do_break_a, "on-false")) {
+                               do_break_i = BREAK_ON_FALSE;
+                       } else if (!strcasecmp(do_break_a, "always")) {
+                               do_break_i = BREAK_ALWAYS;
+                       } else if (!strcasecmp(do_break_a, "never")) {
+                               do_break_i = BREAK_NEVER;
+                       } else {
+                               do_break_a = NULL;
+                       }
+               }
+
+               if (time_match == 1) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                         "Chatplan: %s Date/Time Match (PASS) [%s] break=%s\n",
+                                                         to, exten_name, do_break_a ? do_break_a : "on-false");
+                       anti_action = SWITCH_FALSE;
+               } else if (time_match == 0) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                         "Chatplan: %s Date/Time Match (FAIL) [%s] break=%s\n",
+                                                         to, exten_name, do_break_a ? do_break_a : "on-false");
+               }
+
+               if (field) {
+                       if (strchr(field, '$')) {
+                               if ((field_expanded = switch_event_expand_headers(event, field)) == field) {
+                                       field_expanded = NULL;
+                                       field_data = field;
+                               } else {
+                                       field_data = field_expanded;
+                               }
+                       } else {
+                               field_data = switch_event_get_header(event, field);
+                       }
+                       if (!field_data) {
+                               field_data = "";
+                       }
+
+                       if ((proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                                 "Chatplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n",
+                                                                 to, exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
+                               anti_action = SWITCH_FALSE;
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                                 "Chatplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n",
+                                                                 to, exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
+                       }
+               } else if (time_match == -1) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                         "Chatplan: %s Absolute Condition [%s]\n", to, exten_name);
+                       anti_action = SWITCH_FALSE;
+               }
+
+               if (anti_action) {
+                       for (xaction = switch_xml_child(xcond, "anti-action"); xaction; xaction = xaction->next) {
+                               const char *application = switch_xml_attr_soft(xaction, "application");
+                               const char *loop = switch_xml_attr(xaction, "loop");
+                               const char *data;
+                               const char *inline_ = switch_xml_attr_soft(xaction, "inline");
+                               int xinline = switch_true(inline_);
+                               int loop_count = 1;
+
+                               if (!zstr(xaction->txt)) {
+                                       data = xaction->txt;
+                               } else {
+                                       data = (char *) switch_xml_attr_soft(xaction, "data");
+                               }
+
+                               if (!*extension) {
+                                       if ((switch_event_create(extension, SWITCH_EVENT_CLONE)) != SWITCH_STATUS_SUCCESS) {
+                                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+                                               abort();
+                                       }
+                               }
+
+                               if (loop) {
+                                       loop_count = atoi(loop);
+                               }
+
+                               for (;loop_count > 0; loop_count--) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                       "Chatplan: %s ANTI-Action %s(%s) %s\n", to, application, data, xinline ? "INLINE" : "");
+
+                                       if (xinline) {
+                                               switch_core_execute_chat_app(event, application, data);
+                                       } else {
+                                               switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, data);
+                                       }
+                               }
+                               proceed = 1;
+                       }
+               } else {
+                       if (field && strchr(expression, '(')) {
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "DP_MATCH", NULL);
+                               switch_capture_regex(re, proceed, field_data, ovector, "DP_MATCH", switch_regex_set_event_header_callback, event);
+                       }
+
+                       for (xaction = switch_xml_child(xcond, "action"); xaction; xaction = xaction->next) {
+                               char *application = (char *) switch_xml_attr_soft(xaction, "application");
+                               const char *loop = switch_xml_attr(xaction, "loop");
+                               char *data = NULL;
+                               char *substituted = NULL;
+                               uint32_t len = 0;
+                               char *app_data = NULL;
+                               const char *inline_ = switch_xml_attr_soft(xaction, "inline");
+                               int xinline = switch_true(inline_);
+                               int loop_count = 1;
+
+                               if (!zstr(xaction->txt)) {
+                                       data = xaction->txt;
+                               } else {
+                                       data = (char *) switch_xml_attr_soft(xaction, "data");
+                               }
+
+                               if (field && strchr(expression, '(')) {
+                                       len = (uint32_t) (strlen(data) + strlen(field_data) + 10) * proceed;
+                                       if (!(substituted = malloc(len))) {
+                                               abort();
+                                       }
+                                       memset(substituted, 0, len);
+                                       switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector);
+                                       app_data = substituted;
+                               } else {
+                                       app_data = data;
+                               }
+
+                               if (!*extension) {
+                                       if ((switch_event_create(extension, SWITCH_EVENT_CLONE)) != SWITCH_STATUS_SUCCESS) {
+                                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
+                                               abort();
+                                       }
+                               }
+
+                               if (loop) {
+                                       loop_count = atoi(loop);
+                               }
+                               for (;loop_count > 0; loop_count--) {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                       "Chatplan: %s Action %s(%s) %s\n", to, application, app_data, xinline ? "INLINE" : "");
+
+                                       if (xinline) {
+                                               switch_core_execute_chat_app(event, application, app_data);
+                                       } else {
+                                               switch_event_add_header_string(*extension, SWITCH_STACK_BOTTOM, application, data);
+                                       }
+                               }
+                               switch_safe_free(substituted);
+                       }
+               }
+               switch_regex_safe_free(re);
+
+               if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) ||
+                        (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) {
+                       break;
+               }
+       }
+
+  done:
+       switch_regex_safe_free(re);
+       switch_safe_free(field_expanded);
+       switch_safe_free(expression_expanded);
+       return proceed;
+}
+
+
+static switch_event_t *chatplan_hunt(switch_event_t *event)
+{
+       switch_event_t *extension = NULL;
+       switch_xml_t alt_root = NULL, cfg, xml = NULL, xcontext, xexten = NULL;
+       const char *alt_path;
+       const char *context;
+       const char *from;
+       const char *to;
+
+       if (!(context = switch_event_get_header(event, "context"))) {
+               context = "default";
+       }
+
+       if (!(from = switch_event_get_header(event, "from_user"))) {
+               from = switch_event_get_header(event, "from");
+       }
+
+       if (!(to = switch_event_get_header(event, "to_user"))) {
+               to = switch_event_get_header(event, "to");
+       }
+
+       alt_path = switch_event_get_header(event, "alt_path");
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Processing text message %s->%s in context %s\n", from, to, context);
+
+       /* get our handle to the "chatplan" section of the config */
+
+       if (!zstr(alt_path)) {
+               switch_xml_t conf = NULL, tag = NULL;
+               if (!(alt_root = switch_xml_parse_file_simple(alt_path))) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of [%s] failed\n", alt_path);
+                       goto done;
+               }
+
+               if ((conf = switch_xml_find_child(alt_root, "section", "name", "chatplan")) && (tag = switch_xml_find_child(conf, "chatplan", NULL, NULL))) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Getting chatplan from alternate path: %s\n", alt_path);
+                       xml = alt_root;
+                       cfg = tag;
+               } else {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of chatplan failed\n");
+                       goto done;
+               }
+       } else {
+               if (switch_xml_locate("chatplan", NULL, NULL, NULL, &xml, &cfg, event, SWITCH_FALSE) != SWITCH_STATUS_SUCCESS) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of chatplan failed\n");
+                       goto done;
+               }
+       }
+
+       /* get a handle to the context tag */
+       if (!(xcontext = switch_xml_find_child(cfg, "context", "name", context))) {
+               if (!(xcontext = switch_xml_find_child(cfg, "context", "name", "global"))) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Context %s not found\n", context);
+                       goto done;
+               }
+       }
+
+       xexten = switch_xml_child(xcontext, "extension");
+       
+       while (xexten) {
+               int proceed = 0;
+               const char *cont = switch_xml_attr(xexten, "continue");
+               const char *exten_name = switch_xml_attr(xexten, "name");
+
+               if (!exten_name) {
+                       exten_name = "UNKNOWN";
+               }
+
+               switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_DEBUG,
+                                                 "Chatplan: %s parsing [%s->%s] continue=%s\n",
+                                                 to, context, exten_name, cont ? cont : "false");
+
+               proceed = parse_exten(event, xexten, &extension);
+               
+               if (proceed && !switch_true(cont)) {
+                       break;
+               }
+
+               xexten = xexten->next;
+       }
+
+       switch_xml_free(xml);
+       xml = NULL;
+
+  done:
+       switch_xml_free(xml);
+       return extension;
+}
+
+
+static switch_status_t chat_send(switch_event_t *message_event)
+                                                                {
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
+       switch_event_t *exten;
+       
+       if ((exten = chatplan_hunt(message_event))) {
+               switch_event_header_t *hp;
+               
+               for (hp = exten->headers; hp; hp = hp->next) {
+                       status = switch_core_execute_chat_app(message_event, hp->name, hp->value);
+                       if (!SWITCH_READ_ACCEPTABLE(status)) {
+                               break;
+                       }
+               }
+
+               switch_event_destroy(&exten);
+       }
+
+
+       status = SWITCH_STATUS_BREAK;
+
+
+       return status;
+
+}
+
+SWITCH_STANDARD_CHAT_APP(stop_function)
+{
+       switch_set_flag(message, EF_NO_CHAT_EXEC);
+       return SWITCH_STATUS_FALSE;
+}
+
+SWITCH_STANDARD_CHAT_APP(send_function)
+{
+       const char *dest_proto = data;
+
+       if (zstr(dest_proto)) {
+               dest_proto = switch_event_get_header(message, "dest_proto");
+       }
+
+       switch_core_chat_send(dest_proto, message);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_CHAT_APP(set_function)
+{
+       char *var, *val;
+
+       if (data) {
+               var = strdup(data);
+               if ((val = strchr(var, '='))) {
+                       *val++ = '\0';
+               }
+               if (zstr(val)) {
+                       switch_event_del_header(message, var);
+               } else {
+                       switch_event_add_header_string(message, SWITCH_STACK_BOTTOM, var, val);
+               }
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_CHAT_APP(fire_function)
+{
+       switch_event_t *fireme;
+
+       switch_event_dup(&fireme, message);
+       switch_event_fire(&fireme);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+SWITCH_STANDARD_CHAT_APP(reply_function)
+{
+       switch_event_t *reply;
+       const char *proto = switch_event_get_header(message, "proto");
+
+       if (proto) {
+               switch_ivr_create_message_reply(&reply, message, SMS_CHAT_PROTO);
+               
+               if (!zstr(data)) {
+                       switch_event_add_body(reply, data);
+               }
+
+               switch_core_chat_deliver(proto, &reply);
+
+               return SWITCH_STATUS_SUCCESS;
+       }
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+/* Macro expands to: switch_status_t mod_sms_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
+SWITCH_MODULE_LOAD_FUNCTION(mod_sms_load)
+{
+       switch_chat_interface_t *chat_interface;
+       switch_chat_application_interface_t *chat_app_interface;
+
+
+       if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_SEND_MESSAGE, event_handler, NULL) != SWITCH_STATUS_SUCCESS) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
+               return SWITCH_STATUS_GENERR;
+       }
+       
+       /* connect my internal structure to the blank pointer passed to me */
+       *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+
+       SWITCH_ADD_CHAT(chat_interface, SMS_CHAT_PROTO, chat_send);
+
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "reply", "reply to a message", "reply to a message", reply_function, "", SCAF_NONE);
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "stop", "stop execution", "stop execution", stop_function, "", SCAF_NONE);
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "set", "set a variable", "set a variable", set_function, "", SCAF_NONE);
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "send", "send the message as-is", "send the message as-is", send_function, "", SCAF_NONE);
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "fire", "fire the message", "fire the message", fire_function, "", SCAF_NONE);
+                                               
+       /* indicate that the module should continue to be loaded */
+       return SWITCH_STATUS_SUCCESS;
+}
+
+/*
+  Called when the system shuts down
+  Macro expands to: switch_status_t mod_sms_shutdown() */
+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_sms_shutdown)
+{
+       switch_event_unbind_callback(event_handler);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
+
+
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4
+ */
index 527a2a0fa2bbc668443e3fc91a046291009e6a0a..1a7dd221ef1632221cc19eeafb033571f75ac046 100644 (file)
@@ -2929,7 +2929,7 @@ static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsessi
                                        }
                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to);
                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", subject);
-                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "normal");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", hint);
                                        
                                        if (msg) {
index db7aa94a3a63d82844f62f6c4a8e51bb3505677b..06b1ce496e59a1caf623c80997871c93c63a43e0 100644 (file)
@@ -99,7 +99,10 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
        //const char *subject;
        const char *body;
        const char *type;
-       const char *hint;
+       const char *from_full;
+       char header[256] = "";
+       char *route_uri = NULL;
+       const char *network_ip = NULL, *network_port = NULL;
 
        proto = switch_event_get_header(message_event, "proto");
        from = switch_event_get_header(message_event, "from");
@@ -107,8 +110,10 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
        //subject = switch_event_get_header(message_event, "subject");
        body = switch_event_get_body(message_event);
        type = switch_event_get_header(message_event, "type");
-       hint = switch_event_get_header(message_event, "hint");
-
+       from_full = switch_event_get_header(message_event, "from_full");
+       
+       network_ip = switch_event_get_header(message_event, "to_sip_ip");
+       network_port = switch_event_get_header(message_event, "to_sip_port");
 
        if (!to) {
                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To: header.\n");
@@ -130,6 +135,10 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                user = prof;
                prof = NULL;
        }
+
+       if (!prof) {
+               prof = switch_event_get_header(message_event, "sip_profile");
+       }
        
        if (!strncasecmp(user, "sip:", 4)) {
                to_uri = user;
@@ -141,8 +150,9 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                } else {
                        host++;
                }
-               if (!prof)
+               if (!prof) {
                        prof = host;
+               }
        }
 
        if (!prof || !(profile = sofia_glue_find_profile(prof))) {
@@ -159,24 +169,34 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                }
        }
 
+
        if (to_uri) {
                switch_console_push_match(&list, to_uri);
        }  else if (!(list = sofia_reg_find_reg_url_multi(profile, user, host))) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find registered user %s@%s\n", user, host);
-               goto end;
+               sofia_profile_t *test;
+
+               if ((test = sofia_glue_find_profile(host))) {
+                       sofia_glue_release_profile(test);
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending to local box for %s@%s\n", user, host);
+                       /* our box let's not send it */
+               } else {
+                       char *tmp;
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Can't find registered user %s@%s\n", user, host);
+                       tmp = switch_mprintf("sip:%s@%s", user, host);
+                       switch_console_push_match(&list, tmp);
+                       free(tmp);
+               }
+
        }
        
        if (!strcasecmp(proto, SOFIA_CHAT_PROTO)) {
-               from = hint;
+               from = from_full;
        } else {
                char *fp, *p = NULL;
                
                fp = strdup(from);
+               switch_assert(fp);
 
-               if (!fp) {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
-                       goto end;
-               }
 
                if ((p = strchr(fp, '@'))) {
                        *p++ = '\0';
@@ -189,12 +209,23 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                        }
                }
 
-               ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fp, proto, fp, p);
+               if (switch_stristr("global", proto)) {
+                       ffrom = switch_mprintf("\"%s\" <sip:%s@%s>", fp, fp, p);
+               } else {
+                       ffrom = switch_mprintf("\"%s\" <sip:%s+%s@%s>", fp, proto, fp, p);
+               }
 
                from = ffrom;
                switch_safe_free(fp);
        }
 
+       if (!list) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+               "Chat proto [%s]\nfrom [%s]\nto [%s]\n%s\nNobody to send to: Profile %s\n", proto, from, to,
+                                                 body ? body : "[no body]", prof ? prof : "NULL");
+               goto end;
+       }
+
        for (m = list->head; m; m = m->next) {
 
                if (!(dst = sofia_glue_get_destination(m->val))) {
@@ -250,21 +281,34 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
                
                /* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */
 
+               //printf("DEBUG To: [%s] From: [%s] Contact: [%s] RURI [%s] ip [%s] port [%s]\n", to, from, contact, dst->route_uri, network_ip, network_port);
+
+               //DUMP_EVENT(message_event);
+
+               if (zstr(dst->route_uri) && !zstr(user) && !zstr(network_ip) && (zstr(host) || strcmp(network_ip, host))) {
+                       route_uri = switch_mprintf("sip:%s@%s:%s", user, network_ip, network_port);
+               }
+
                msg_nh = nua_handle(profile->nua, NULL,
-                                                       TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
-                                                       TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
-                                                       SIPTAG_FROM_STR(from),
-                                                       TAG_IF(contact, NUTAG_URL(contact)),
-                                                       SIPTAG_TO_STR(dup_dest),
-                                                       SIPTAG_CONTACT_STR(contact_str),
                                                        TAG_END());
 
                nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
                
+               switch_snprintf(header, sizeof(header), "X-FS-Sending-Message: %s", switch_core_get_uuid());
+
                nua_message(msg_nh,
+                                       TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
+                                       TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
+                                       TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
+                                       SIPTAG_FROM_STR(from),
+                                       TAG_IF(contact, NUTAG_URL(contact)),
+                                       SIPTAG_TO_STR(dup_dest),
+                                       SIPTAG_CONTACT_STR(contact_str),
+
                                        TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
                                        SIPTAG_CONTENT_TYPE_STR(ct),
                                        SIPTAG_PAYLOAD_STR(body),
+                                       SIPTAG_HEADER_STR(header),
                                        TAG_END());
 
                sofia_glue_free_destination(dst);
@@ -277,6 +321,7 @@ switch_status_t sofia_presence_chat_send(switch_event_t *message_event)
   end:
        
        switch_safe_free(contact);
+       switch_safe_free(route_uri);
        switch_safe_free(ffrom);
        switch_safe_free(dup);
 
@@ -2873,13 +2918,25 @@ void sofia_presence_handle_sip_i_message(int status,
                const char *to_host = NULL;
                sip_payload_t *payload = sip->sip_payload;
                char *msg = NULL;
+               const char *us;
+               char network_ip[80];
+               int network_port = 0;
+
+               if ((us = sofia_glue_get_unknown_header(sip, "X-FS-Sending-Message")) && !strcmp(us, switch_core_get_uuid())) {
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Not sending message to ourselves!\n");
+                       goto end;
+               }
 
                if (sip->sip_content_type && sip->sip_content_type->c_subtype) {
                        if (strstr(sip->sip_content_type->c_subtype, "composing")) {
-                               return;
+                               goto end;
                        }
                }
 
+
+               sofia_glue_get_addr(de->data->e_msg, network_ip, sizeof(network_ip), &network_port);
+
+
                if (from) {
                        from_user = from->a_url->url_user;
                        from_host = from->a_url->url_host;
@@ -2891,7 +2948,7 @@ void sofia_presence_handle_sip_i_message(int status,
                }
 
                if (!to_user) {
-                       return;
+                       goto end;
                }
 
                if (payload) {
@@ -2924,7 +2981,7 @@ void sofia_presence_handle_sip_i_message(int status,
                                to_addr = switch_mprintf("%s@%s", to_user, to_host);
                        }
 
-                       from_addr = switch_mprintf("%s/%s@%s", profile->name, from_user, from_host);
+                       from_addr = switch_mprintf("%s@%s", from_user, from_host);
 
                        if (sofia_test_pflag(profile, PFLAG_IN_DIALOG_CHAT)) {
                                sofia_presence_set_hash_key(hash_key, sizeof(hash_key), sip);
@@ -2936,10 +2993,22 @@ void sofia_presence_handle_sip_i_message(int status,
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", from_addr);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", from_user);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", from_host);
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", to_user);
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", to_host);
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_sip_ip", network_ip);
+                               switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from_sip_port", "%d", network_port);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", to_addr);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
-                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "normal");
-                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", full_from);
+
+                               
+                               if (sip->sip_content_type && sip->sip_content_type->c_subtype) {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", sip->sip_content_type->c_type);
+                               } else {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "text/plain");
+                               }
+
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", full_from);
+                               switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "sip_profile", profile->name);
                                
                                if (msg) {
                                        switch_event_add_body(event, "%s", msg);
@@ -2952,7 +3021,6 @@ void sofia_presence_handle_sip_i_message(int status,
                                switch_core_session_queue_event(tech_pvt->session, &event);
                        } else {
                                switch_core_chat_send(proto, event);
-                               switch_core_chat_send("GLOBAL", event);
                                switch_event_destroy(&event);
                        }
 
@@ -2964,6 +3032,11 @@ void sofia_presence_handle_sip_i_message(int status,
                        }
                }
        }
+
+ end:
+
+       nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS_MSG(de->data->e_msg), TAG_END());
+
 }
 
 void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip)
index c591e9393d65f6f407f85d960624ce9a39b0284a..ad7438e487715cb4e04edd55b9bc03fece9653ef 100644 (file)
@@ -1397,7 +1397,7 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
                }
                /* Log line added to support Fail2Ban */
                if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
-                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth challenge (%s) on sofia profile '%s' "
+                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "SIP auth challenge (%s) on sofia profile '%s' "
                                                          "for [%s@%s] from ip %s\n", (regtype == REG_INVITE) ? "INVITE" : "REGISTER", 
                                                          profile->name, to_user, to_host, network_ip);
                }
index c1c9ba17e758a769327b4705532b5b8fcdee10a4..d1adc09dc6a66f8bb3f986904c4c2e8a3b95b7c4 100644 (file)
@@ -66,6 +66,14 @@ public class Event {
     this(freeswitchJNI.new_Event__SWIG_1(SWIGTYPE_p_switch_event_t.getCPtr(wrap_me), free_me), true);
   }
 
+  public int chat_execute(String app, String data) {
+    return freeswitchJNI.Event_chat_execute(swigCPtr, this, app, data);
+  }
+
+  public int chat_send(String dest_proto) {
+    return freeswitchJNI.Event_chat_send(swigCPtr, this, dest_proto);
+  }
+
   public String serialize(String format) {
     return freeswitchJNI.Event_serialize(swigCPtr, this, format);
   }
index 069b7eecf2fde62ebf12b3be28d99d9e600017cc..fc74914d155ecd5981725d5570529afb7c61a745 100644 (file)
@@ -54,6 +54,8 @@ class freeswitchJNI {
   public final static native long new_Event__SWIG_0(String jarg1, String jarg2);
   public final static native long new_Event__SWIG_1(long jarg1, int jarg2);
   public final static native void delete_Event(long jarg1);
+  public final static native int Event_chat_execute(long jarg1, Event jarg1_, String jarg2, String jarg3);
+  public final static native int Event_chat_send(long jarg1, Event jarg1_, String jarg2);
   public final static native String Event_serialize(long jarg1, Event jarg1_, String jarg2);
   public final static native boolean Event_setPriority(long jarg1, Event jarg1_, long jarg2);
   public final static native String Event_getHeader(long jarg1, Event jarg1_, String jarg2);
index 4b3c9d38d1822273587fe7bd562fd44c6b2b11b1..5061dc46f6586ca5de67d43a73cac1d12c946a76 100644 (file)
@@ -1054,6 +1054,57 @@ SWIGEXPORT void JNICALL Java_org_freeswitch_swig_freeswitchJNI_delete_1Event(JNI
 }
 
 
+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1chat_1execute(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3) {
+  jint jresult = 0 ;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) NULL ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Event **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  arg3 = 0;
+  if (jarg3) {
+    arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);
+    if (!arg3) return 0;
+  }
+  result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
+  jresult = (jint)result; 
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+  if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);
+  return jresult;
+}
+
+
+SWIGEXPORT jint JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1chat_1send(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
+  jint jresult = 0 ;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) NULL ;
+  int result;
+  
+  (void)jenv;
+  (void)jcls;
+  (void)jarg1_;
+  arg1 = *(Event **)&jarg1; 
+  arg2 = 0;
+  if (jarg2) {
+    arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);
+    if (!arg2) return 0;
+  }
+  result = (int)(arg1)->chat_send((char const *)arg2);
+  jresult = (jint)result; 
+  if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);
+  return jresult;
+}
+
+
 SWIGEXPORT jstring JNICALL Java_org_freeswitch_swig_freeswitchJNI_Event_1serialize(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2) {
   jstring jresult = 0 ;
   Event *arg1 = (Event *) 0 ;
index dc01aa9fa9d975a73df805cc4eafb7df847e69e5..a165795cb04a0a4d1deda95cea98610503a92c5c 100644 (file)
@@ -430,6 +430,24 @@ SWITCH_STANDARD_API(luarun_api_function)
        return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_STANDARD_CHAT_APP(lua_chat_function)
+{
+       lua_State *L = lua_init();
+       char *dup = NULL;
+
+       if (data) {
+               dup = strdup(data);
+       }
+
+       mod_lua_conjure_event(L, message, "message", 1);
+       lua_parse_and_execute(L, (char *)dup);
+       lua_uninit(L);
+
+       switch_safe_free(dup);
+
+       return SWITCH_STATUS_SUCCESS;
+
+}
 
 SWITCH_STANDARD_API(lua_api_function)
 {
@@ -591,6 +609,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
        switch_api_interface_t *api_interface;
        switch_application_interface_t *app_interface;
        switch_dialplan_interface_t *dp_interface;
+       switch_chat_application_interface_t *chat_app_interface;
 
        /* connect my internal structure to the blank pointer passed to me */
        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
@@ -600,6 +619,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_lua_load)
        SWITCH_ADD_APP(app_interface, "lua", "Launch LUA ivr", "Run a lua ivr on a channel", lua_function, "<script>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
        SWITCH_ADD_DIALPLAN(dp_interface, "LUA", lua_dialplan_hunt);
 
+       SWITCH_ADD_CHAT_APP(chat_app_interface, "lua", "execute a lua script", "execute a lua script", lua_chat_function, "<script>", SCAF_NONE);
 
 
        globals.pool = pool;
index 5891bfbc1a6476a48ba26771d18be51e63db863f..3bb1ad5d719a4322649c140371532eb3a0c2a770 100644 (file)
@@ -2890,6 +2890,69 @@ fail:
 }
 
 
+static int _wrap_Event_chat_execute(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) NULL ;
+  int result;
+  
+  SWIG_check_num_args("chat_execute",2,3)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("chat_execute",1,"Event *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("chat_execute",2,"char const *");
+  if(lua_gettop(L)>=3 && !lua_isstring(L,3)) SWIG_fail_arg("chat_execute",3,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_chat_execute",1,SWIGTYPE_p_Event);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  if(lua_gettop(L)>=3){
+    arg3 = (char *)lua_tostring(L, 3);
+  }
+  result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
+  SWIG_arg=0;
+  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Event_chat_send(lua_State* L) {
+  int SWIG_arg = -1;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) NULL ;
+  int result;
+  
+  SWIG_check_num_args("chat_send",1,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("chat_send",1,"Event *");
+  if(lua_gettop(L)>=2 && !lua_isstring(L,2)) SWIG_fail_arg("chat_send",2,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_Event,0))){
+    SWIG_fail_ptr("Event_chat_send",1,SWIGTYPE_p_Event);
+  }
+  
+  if(lua_gettop(L)>=2){
+    arg2 = (char *)lua_tostring(L, 2);
+  }
+  result = (int)(arg1)->chat_send((char const *)arg2);
+  SWIG_arg=0;
+  lua_pushnumber(L, (lua_Number) result); SWIG_arg++;
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
 static int _wrap_Event_serialize(lua_State* L) {
   int SWIG_arg = -1;
   Event *arg1 = (Event *) 0 ;
@@ -3149,6 +3212,8 @@ Event *arg1 = (Event *) obj;
 delete arg1;
 }
 static swig_lua_method swig_Event_methods[] = {
+    {"chat_execute", _wrap_Event_chat_execute}, 
+    {"chat_send", _wrap_Event_chat_send}, 
     {"serialize", _wrap_Event_serialize}, 
     {"setPriority", _wrap_Event_setPriority}, 
     {"getHeader", _wrap_Event_getHeader}, 
index 6e9c56de0eef3e40c618effa2779388254bc9e3c..8bacc37b85a47ca160fdb7fbd982f789a5783313 100644 (file)
@@ -5590,6 +5590,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_regex_set_var_callback(char * jarg1, c
 }
 
 
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_regex_set_event_header_callback(char * jarg1, char * jarg2, void * jarg3) {
+  char *arg1 = (char *) 0 ;
+  char *arg2 = (char *) 0 ;
+  void *arg3 = (void *) 0 ;
+  
+  arg1 = (char *)jarg1; 
+  arg2 = (char *)jarg2; 
+  arg3 = (void *)jarg3; 
+  switch_regex_set_event_header_callback((char const *)arg1,(char const *)arg2,arg3);
+}
+
+
 SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get() {
   int jresult ;
   int result;
@@ -10542,6 +10554,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_send(char * jarg1, void * jar
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_chat_deliver(char * jarg1, void * jarg2) {
+  int jresult ;
+  char *arg1 = (char *) 0 ;
+  switch_event_t **arg2 = (switch_event_t **) 0 ;
+  switch_status_t result;
+  
+  arg1 = (char *)jarg1; 
+  arg2 = (switch_event_t **)jarg2; 
+  result = (switch_status_t)switch_core_chat_deliver((char const *)arg1,arg2);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_preprocess_session(void * jarg1, char * jarg2) {
   int jresult ;
   switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
@@ -11388,6 +11414,29 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_applicatio
 }
 
 
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_application_interface_set(void * jarg1, void * jarg2) {
+  switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
+  switch_chat_application_interface_t *arg2 = (switch_chat_application_interface_t *) 0 ;
+  
+  arg1 = (switch_loadable_module_interface *)jarg1; 
+  arg2 = (switch_chat_application_interface_t *)jarg2; 
+  if (arg1) (arg1)->chat_application_interface = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_interface_chat_application_interface_get(void * jarg1) {
+  void * jresult ;
+  switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
+  switch_chat_application_interface_t *result = 0 ;
+  
+  arg1 = (switch_loadable_module_interface *)jarg1; 
+  result = (switch_chat_application_interface_t *) ((arg1)->chat_application_interface);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
 SWIGEXPORT void SWIGSTDCALL CSharp_switch_loadable_module_interface_api_interface_set(void * jarg1, void * jarg2) {
   switch_loadable_module_interface *arg1 = (switch_loadable_module_interface *) 0 ;
   switch_api_interface_t *arg2 = (switch_api_interface_t *) 0 ;
@@ -11810,6 +11859,34 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_application_inte
 }
 
 
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_chat_application_interface(char * jarg1) {
+  void * jresult ;
+  char *arg1 = (char *) 0 ;
+  switch_chat_application_interface_t *result = 0 ;
+  
+  arg1 = (char *)jarg1; 
+  result = (switch_chat_application_interface_t *)switch_loadable_module_get_chat_application_interface((char const *)arg1);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_core_execute_chat_app(void * jarg1, char * jarg2, char * jarg3) {
+  int jresult ;
+  switch_event_t *arg1 = (switch_event_t *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_event_t *)jarg1; 
+  arg2 = (char *)jarg2; 
+  arg3 = (char *)jarg3; 
+  result = (switch_status_t)switch_core_execute_chat_app(arg1,(char const *)arg2,(char const *)arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT void * SWIGSTDCALL CSharp_switch_loadable_module_get_api_interface(char * jarg1) {
   void * jresult ;
   char *arg1 = (char *) 0 ;
@@ -23227,6 +23304,302 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_application_interface(void * ja
 }
 
 
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_interface_name_set(void * jarg1, char * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (char *)jarg2; 
+  {
+    if (arg2) {
+      arg1->interface_name = (char const *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->interface_name, (const char *)arg2);
+    } else {
+      arg1->interface_name = 0;
+    }
+  }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_interface_name_get(void * jarg1) {
+  char * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (char *) ((arg1)->interface_name);
+  jresult = SWIG_csharp_string_callback((const char *)result); 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_chat_application_function_set(void * jarg1, void * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_chat_application_function_t arg2 = (switch_chat_application_function_t) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (switch_chat_application_function_t)jarg2; 
+  if (arg1) (arg1)->chat_application_function = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_chat_application_function_get(void * jarg1) {
+  void * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_chat_application_function_t result;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (switch_chat_application_function_t) ((arg1)->chat_application_function);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_long_desc_set(void * jarg1, char * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (char *)jarg2; 
+  {
+    if (arg2) {
+      arg1->long_desc = (char const *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->long_desc, (const char *)arg2);
+    } else {
+      arg1->long_desc = 0;
+    }
+  }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_long_desc_get(void * jarg1) {
+  char * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (char *) ((arg1)->long_desc);
+  jresult = SWIG_csharp_string_callback((const char *)result); 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_short_desc_set(void * jarg1, char * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (char *)jarg2; 
+  {
+    if (arg2) {
+      arg1->short_desc = (char const *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->short_desc, (const char *)arg2);
+    } else {
+      arg1->short_desc = 0;
+    }
+  }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_short_desc_get(void * jarg1) {
+  char * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (char *) ((arg1)->short_desc);
+  jresult = SWIG_csharp_string_callback((const char *)result); 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_syntax_set(void * jarg1, char * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (char *)jarg2; 
+  {
+    if (arg2) {
+      arg1->syntax = (char const *) (new char[strlen((const char *)arg2)+1]);
+      strcpy((char *)arg1->syntax, (const char *)arg2);
+    } else {
+      arg1->syntax = 0;
+    }
+  }
+}
+
+
+SWIGEXPORT char * SWIGSTDCALL CSharp_switch_chat_application_interface_syntax_get(void * jarg1) {
+  char * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  char *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (char *) ((arg1)->syntax);
+  jresult = SWIG_csharp_string_callback((const char *)result); 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_flags_set(void * jarg1, unsigned long jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  uint32_t arg2 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (uint32_t)jarg2; 
+  if (arg1) (arg1)->flags = arg2;
+  
+}
+
+
+SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_chat_application_interface_flags_get(void * jarg1) {
+  unsigned long jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  uint32_t result;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (uint32_t) ((arg1)->flags);
+  jresult = (unsigned long)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_rwlock_set(void * jarg1, void * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_thread_rwlock_t *arg2 = (switch_thread_rwlock_t *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (switch_thread_rwlock_t *)jarg2; 
+  if (arg1) (arg1)->rwlock = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_rwlock_get(void * jarg1) {
+  void * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_thread_rwlock_t *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (switch_thread_rwlock_t *) ((arg1)->rwlock);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_refs_set(void * jarg1, int jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  int arg2 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (int)jarg2; 
+  if (arg1) (arg1)->refs = arg2;
+  
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_chat_application_interface_refs_get(void * jarg1) {
+  int jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  int result;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (int) ((arg1)->refs);
+  jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_reflock_set(void * jarg1, void * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_mutex_t *arg2 = (switch_mutex_t *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (switch_mutex_t *)jarg2; 
+  if (arg1) (arg1)->reflock = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_reflock_get(void * jarg1) {
+  void * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_mutex_t *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (switch_mutex_t *) ((arg1)->reflock);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_parent_set(void * jarg1, void * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_loadable_module_interface_t *arg2 = (switch_loadable_module_interface_t *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (switch_loadable_module_interface_t *)jarg2; 
+  if (arg1) (arg1)->parent = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_parent_get(void * jarg1) {
+  void * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_loadable_module_interface_t *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (switch_loadable_module_interface_t *) ((arg1)->parent);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_switch_chat_application_interface_next_set(void * jarg1, void * jarg2) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_chat_application_interface *arg2 = (switch_chat_application_interface *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  arg2 = (switch_chat_application_interface *)jarg2; 
+  if (arg1) (arg1)->next = arg2;
+  
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_switch_chat_application_interface_next_get(void * jarg1) {
+  void * jresult ;
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  switch_chat_application_interface *result = 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  result = (switch_chat_application_interface *) ((arg1)->next);
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void * SWIGSTDCALL CSharp_new_switch_chat_application_interface() {
+  void * jresult ;
+  switch_chat_application_interface *result = 0 ;
+  
+  result = (switch_chat_application_interface *)new switch_chat_application_interface();
+  jresult = (void *)result; 
+  return jresult;
+}
+
+
+SWIGEXPORT void SWIGSTDCALL CSharp_delete_switch_chat_application_interface(void * jarg1) {
+  switch_chat_application_interface *arg1 = (switch_chat_application_interface *) 0 ;
+  
+  arg1 = (switch_chat_application_interface *)jarg1; 
+  delete arg1;
+  
+}
+
+
 SWIGEXPORT void SWIGSTDCALL CSharp_switch_api_interface_interface_name_set(void * jarg1, char * jarg2) {
   switch_api_interface *arg1 = (switch_api_interface *) 0 ;
   char *arg2 = (char *) 0 ;
@@ -26443,6 +26816,22 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_get_header_idx(void * jarg1, c
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_rename_header(void * jarg1, char * jarg2, char * jarg3) {
+  int jresult ;
+  switch_event_t *arg1 = (switch_event_t *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_event_t *)jarg1; 
+  arg2 = (char *)jarg2; 
+  arg3 = (char *)jarg3; 
+  result = (switch_status_t)switch_event_rename_header(arg1,(char const *)arg2,(char const *)arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_get_body(void * jarg1) {
   char * jresult ;
   switch_event_t *arg1 = (switch_event_t *) 0 ;
@@ -26551,6 +26940,20 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_event_merge(void * jarg1, void * jarg2
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_dup_reply(void * jarg1, void * jarg2) {
+  int jresult ;
+  switch_event_t **arg1 = (switch_event_t **) 0 ;
+  switch_event_t *arg2 = (switch_event_t *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_event_t **)jarg1; 
+  arg2 = (switch_event_t *)jarg2; 
+  result = (switch_status_t)switch_event_dup_reply(arg1,arg2);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_fire_detailed(char * jarg1, char * jarg2, int jarg3, void * jarg4, void * jarg5) {
   int jresult ;
   char *arg1 = (char *) 0 ;
@@ -26783,6 +27186,20 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_running() {
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_event_set_body(void * jarg1, char * jarg2) {
+  int jresult ;
+  switch_event_t *arg1 = (switch_event_t *) 0 ;
+  char *arg2 = (char *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_event_t *)jarg1; 
+  arg2 = (char *)jarg2; 
+  result = (switch_status_t)switch_event_set_body(arg1,(char const *)arg2);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT char * SWIGSTDCALL CSharp_switch_event_expand_headers(void * jarg1, char * jarg2) {
   char * jresult ;
   switch_event_t *arg1 = (switch_event_t *) 0 ;
@@ -29763,6 +30180,22 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_insert_file(void * jarg1, char * ja
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_create_message_reply(void * jarg1, void * jarg2, char * jarg3) {
+  int jresult ;
+  switch_event_t **arg1 = (switch_event_t **) 0 ;
+  switch_event_t *arg2 = (switch_event_t *) 0 ;
+  char *arg3 = (char *) 0 ;
+  switch_status_t result;
+  
+  arg1 = (switch_event_t **)jarg1; 
+  arg2 = (switch_event_t *)jarg2; 
+  arg3 = (char *)jarg3; 
+  result = (switch_status_t)switch_ivr_create_message_reply(arg1,arg2,(char const *)arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() {
   int jresult ;
   int result;
@@ -34872,6 +35305,36 @@ SWIGEXPORT void SWIGSTDCALL CSharp_delete_Event(void * jarg1) {
 }
 
 
+SWIGEXPORT int SWIGSTDCALL CSharp_Event_chat_execute(void * jarg1, char * jarg2, char * jarg3) {
+  int jresult ;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) NULL ;
+  int result;
+  
+  arg1 = (Event *)jarg1; 
+  arg2 = (char *)jarg2; 
+  arg3 = (char *)jarg3; 
+  result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
+  jresult = result; 
+  return jresult;
+}
+
+
+SWIGEXPORT int SWIGSTDCALL CSharp_Event_chat_send(void * jarg1, char * jarg2) {
+  int jresult ;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) NULL ;
+  int result;
+  
+  arg1 = (Event *)jarg1; 
+  arg2 = (char *)jarg2; 
+  result = (int)(arg1)->chat_send((char const *)arg2);
+  jresult = result; 
+  return jresult;
+}
+
+
 SWIGEXPORT char * SWIGSTDCALL CSharp_Event_Serialize(void * jarg1, char * jarg2) {
   char * jresult ;
   Event *arg1 = (Event *) 0 ;
index 8d78c7d735b09d8a9a271a8be90653a2d2d6aded..3f828e09671d9fb0680799fc4f7387d2549f02e6 100644 (file)
@@ -542,20 +542,20 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public partial class Event : IDisposable {
+public class EventConsumer : IDisposable {
   private HandleRef swigCPtr;
   protected bool swigCMemOwn;
 
-  internal Event(IntPtr cPtr, bool cMemoryOwn) {
+  internal EventConsumer(IntPtr cPtr, bool cMemoryOwn) {
     swigCMemOwn = cMemoryOwn;
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  internal static HandleRef getCPtr(Event obj) {
+  internal static HandleRef getCPtr(EventConsumer obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 
-  ~Event() {
+  ~EventConsumer() {
     Dispose();
   }
 
@@ -563,92 +563,96 @@ public partial class Event : IDisposable {
     lock(this) {
       if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
         swigCMemOwn = false;
-        freeswitchPINVOKE.delete_Event(swigCPtr);
+        freeswitchPINVOKE.delete_EventConsumer(swigCPtr);
       }
       swigCPtr = new HandleRef(null, IntPtr.Zero);
       GC.SuppressFinalize(this);
     }
   }
 
-  public switch_event InternalEvent {
+  public SWIGTYPE_p_switch_queue_t events {
     set {
-      freeswitchPINVOKE.Event_InternalEvent_set(swigCPtr, switch_event.getCPtr(value));
+      freeswitchPINVOKE.EventConsumer_events_set(swigCPtr, SWIGTYPE_p_switch_queue_t.getCPtr(value));
     } 
     get {
-      IntPtr cPtr = freeswitchPINVOKE.Event_InternalEvent_get(swigCPtr);
-      switch_event ret = (cPtr == IntPtr.Zero) ? null : new switch_event(cPtr, false);
+      IntPtr cPtr = freeswitchPINVOKE.EventConsumer_events_get(swigCPtr);
+      SWIGTYPE_p_switch_queue_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_queue_t(cPtr, false);
       return ret;
     } 
   }
 
-  public string serialized_string {
+  public switch_event_types_t e_event_id {
     set {
-      freeswitchPINVOKE.Event_serialized_string_set(swigCPtr, value);
+      freeswitchPINVOKE.EventConsumer_e_event_id_set(swigCPtr, (int)value);
     } 
     get {
-      string ret = freeswitchPINVOKE.Event_serialized_string_get(swigCPtr);
+      switch_event_types_t ret = (switch_event_types_t)freeswitchPINVOKE.EventConsumer_e_event_id_get(swigCPtr);
       return ret;
     } 
   }
 
-  public int mine {
+  public string e_callback {
     set {
-      freeswitchPINVOKE.Event_mine_set(swigCPtr, value);
+      freeswitchPINVOKE.EventConsumer_e_callback_set(swigCPtr, value);
     } 
     get {
-      int ret = freeswitchPINVOKE.Event_mine_get(swigCPtr);
+      string ret = freeswitchPINVOKE.EventConsumer_e_callback_get(swigCPtr);
       return ret;
     } 
   }
 
-  public Event(string type, string subclass_name) : this(freeswitchPINVOKE.new_Event__SWIG_0(type, subclass_name), true) {
-  }
-
-  public Event(switch_event wrap_me, int free_me) : this(freeswitchPINVOKE.new_Event__SWIG_1(switch_event.getCPtr(wrap_me), free_me), true) {
-  }
-
-  public string Serialize(string format) {
-    string ret = freeswitchPINVOKE.Event_Serialize(swigCPtr, format);
-    return ret;
-  }
-
-  public bool SetPriority(switch_priority_t priority) {
-    bool ret = freeswitchPINVOKE.Event_SetPriority(swigCPtr, (int)priority);
-    return ret;
-  }
-
-  public string GetHeader(string header_name) {
-    string ret = freeswitchPINVOKE.Event_GetHeader(swigCPtr, header_name);
-    return ret;
+  public string e_subclass_name {
+    set {
+      freeswitchPINVOKE.EventConsumer_e_subclass_name_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.EventConsumer_e_subclass_name_get(swigCPtr);
+      return ret;
+    } 
   }
 
-  public string GetBody() {
-    string ret = freeswitchPINVOKE.Event_GetBody(swigCPtr);
-    return ret;
+  public string e_cb_arg {
+    set {
+      freeswitchPINVOKE.EventConsumer_e_cb_arg_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.EventConsumer_e_cb_arg_get(swigCPtr);
+      return ret;
+    } 
   }
 
-  public string GetEventType() {
-    string ret = freeswitchPINVOKE.Event_GetEventType(swigCPtr);
-    return ret;
+  public SWIGTYPE_p_p_switch_event_node enodes {
+    set {
+      freeswitchPINVOKE.EventConsumer_enodes_set(swigCPtr, SWIGTYPE_p_p_switch_event_node.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.EventConsumer_enodes_get(swigCPtr);
+      SWIGTYPE_p_p_switch_event_node ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_p_switch_event_node(cPtr, false);
+      return ret;
+    } 
   }
 
-  public bool AddBody(string value) {
-    bool ret = freeswitchPINVOKE.Event_AddBody(swigCPtr, value);
-    return ret;
+  public uint node_index {
+    set {
+      freeswitchPINVOKE.EventConsumer_node_index_set(swigCPtr, value);
+    } 
+    get {
+      uint ret = freeswitchPINVOKE.EventConsumer_node_index_get(swigCPtr);
+      return ret;
+    } 
   }
 
-  public bool AddHeader(string header_name, string value) {
-    bool ret = freeswitchPINVOKE.Event_AddHeader(swigCPtr, header_name, value);
-    return ret;
+  public EventConsumer(string event_name, string subclass_name) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name), true) {
   }
 
-  public bool DeleteHeader(string header_name) {
-    bool ret = freeswitchPINVOKE.Event_DeleteHeader(swigCPtr, header_name);
+  public int bind(string event_name, string subclass_name) {
+    int ret = freeswitchPINVOKE.EventConsumer_bind(swigCPtr, event_name, subclass_name);
     return ret;
   }
 
-  public bool Fire() {
-    bool ret = freeswitchPINVOKE.Event_Fire(swigCPtr);
+  public Event pop(int block) {
+    IntPtr cPtr = freeswitchPINVOKE.EventConsumer_pop(swigCPtr, block);
+    Event ret = (cPtr == IntPtr.Zero) ? null : new Event(cPtr, true);
     return ret;
   }
 
@@ -668,20 +672,20 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class EventConsumer : IDisposable {
+public partial class Event : IDisposable {
   private HandleRef swigCPtr;
   protected bool swigCMemOwn;
 
-  internal EventConsumer(IntPtr cPtr, bool cMemoryOwn) {
+  internal Event(IntPtr cPtr, bool cMemoryOwn) {
     swigCMemOwn = cMemoryOwn;
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  internal static HandleRef getCPtr(EventConsumer obj) {
+  internal static HandleRef getCPtr(Event obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 
-  ~EventConsumer() {
+  ~Event() {
     Dispose();
   }
 
@@ -689,96 +693,102 @@ public class EventConsumer : IDisposable {
     lock(this) {
       if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
         swigCMemOwn = false;
-        freeswitchPINVOKE.delete_EventConsumer(swigCPtr);
+        freeswitchPINVOKE.delete_Event(swigCPtr);
       }
       swigCPtr = new HandleRef(null, IntPtr.Zero);
       GC.SuppressFinalize(this);
     }
   }
 
-  public SWIGTYPE_p_switch_queue_t events {
+  public switch_event InternalEvent {
     set {
-      freeswitchPINVOKE.EventConsumer_events_set(swigCPtr, SWIGTYPE_p_switch_queue_t.getCPtr(value));
+      freeswitchPINVOKE.Event_InternalEvent_set(swigCPtr, switch_event.getCPtr(value));
     } 
     get {
-      IntPtr cPtr = freeswitchPINVOKE.EventConsumer_events_get(swigCPtr);
-      SWIGTYPE_p_switch_queue_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_queue_t(cPtr, false);
+      IntPtr cPtr = freeswitchPINVOKE.Event_InternalEvent_get(swigCPtr);
+      switch_event ret = (cPtr == IntPtr.Zero) ? null : new switch_event(cPtr, false);
       return ret;
     } 
   }
 
-  public switch_event_types_t e_event_id {
+  public string serialized_string {
     set {
-      freeswitchPINVOKE.EventConsumer_e_event_id_set(swigCPtr, (int)value);
+      freeswitchPINVOKE.Event_serialized_string_set(swigCPtr, value);
     } 
     get {
-      switch_event_types_t ret = (switch_event_types_t)freeswitchPINVOKE.EventConsumer_e_event_id_get(swigCPtr);
+      string ret = freeswitchPINVOKE.Event_serialized_string_get(swigCPtr);
       return ret;
     } 
   }
 
-  public string e_callback {
+  public int mine {
     set {
-      freeswitchPINVOKE.EventConsumer_e_callback_set(swigCPtr, value);
+      freeswitchPINVOKE.Event_mine_set(swigCPtr, value);
     } 
     get {
-      string ret = freeswitchPINVOKE.EventConsumer_e_callback_get(swigCPtr);
+      int ret = freeswitchPINVOKE.Event_mine_get(swigCPtr);
       return ret;
     } 
   }
 
-  public string e_subclass_name {
-    set {
-      freeswitchPINVOKE.EventConsumer_e_subclass_name_set(swigCPtr, value);
-    } 
-    get {
-      string ret = freeswitchPINVOKE.EventConsumer_e_subclass_name_get(swigCPtr);
-      return ret;
-    } 
+  public Event(string type, string subclass_name) : this(freeswitchPINVOKE.new_Event__SWIG_0(type, subclass_name), true) {
   }
 
-  public string e_cb_arg {
-    set {
-      freeswitchPINVOKE.EventConsumer_e_cb_arg_set(swigCPtr, value);
-    } 
-    get {
-      string ret = freeswitchPINVOKE.EventConsumer_e_cb_arg_get(swigCPtr);
-      return ret;
-    } 
+  public Event(switch_event wrap_me, int free_me) : this(freeswitchPINVOKE.new_Event__SWIG_1(switch_event.getCPtr(wrap_me), free_me), true) {
   }
 
-  public SWIGTYPE_p_p_switch_event_node enodes {
-    set {
-      freeswitchPINVOKE.EventConsumer_enodes_set(swigCPtr, SWIGTYPE_p_p_switch_event_node.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.EventConsumer_enodes_get(swigCPtr);
-      SWIGTYPE_p_p_switch_event_node ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_p_switch_event_node(cPtr, false);
-      return ret;
-    } 
+  public int chat_execute(string app, string data) {
+    int ret = freeswitchPINVOKE.Event_chat_execute(swigCPtr, app, data);
+    return ret;
   }
 
-  public uint node_index {
-    set {
-      freeswitchPINVOKE.EventConsumer_node_index_set(swigCPtr, value);
-    } 
-    get {
-      uint ret = freeswitchPINVOKE.EventConsumer_node_index_get(swigCPtr);
-      return ret;
-    } 
+  public int chat_send(string dest_proto) {
+    int ret = freeswitchPINVOKE.Event_chat_send(swigCPtr, dest_proto);
+    return ret;
   }
 
-  public EventConsumer(string event_name, string subclass_name) : this(freeswitchPINVOKE.new_EventConsumer(event_name, subclass_name), true) {
+  public string Serialize(string format) {
+    string ret = freeswitchPINVOKE.Event_Serialize(swigCPtr, format);
+    return ret;
   }
 
-  public int bind(string event_name, string subclass_name) {
-    int ret = freeswitchPINVOKE.EventConsumer_bind(swigCPtr, event_name, subclass_name);
+  public bool SetPriority(switch_priority_t priority) {
+    bool ret = freeswitchPINVOKE.Event_SetPriority(swigCPtr, (int)priority);
     return ret;
   }
 
-  public Event pop(int block) {
-    IntPtr cPtr = freeswitchPINVOKE.EventConsumer_pop(swigCPtr, block);
-    Event ret = (cPtr == IntPtr.Zero) ? null : new Event(cPtr, true);
+  public string GetHeader(string header_name) {
+    string ret = freeswitchPINVOKE.Event_GetHeader(swigCPtr, header_name);
+    return ret;
+  }
+
+  public string GetBody() {
+    string ret = freeswitchPINVOKE.Event_GetBody(swigCPtr);
+    return ret;
+  }
+
+  public string GetEventType() {
+    string ret = freeswitchPINVOKE.Event_GetEventType(swigCPtr);
+    return ret;
+  }
+
+  public bool AddBody(string value) {
+    bool ret = freeswitchPINVOKE.Event_AddBody(swigCPtr, value);
+    return ret;
+  }
+
+  public bool AddHeader(string header_name, string value) {
+    bool ret = freeswitchPINVOKE.Event_AddHeader(swigCPtr, header_name, value);
+    return ret;
+  }
+
+  public bool DeleteHeader(string header_name) {
+    bool ret = freeswitchPINVOKE.Event_DeleteHeader(swigCPtr, header_name);
+    return ret;
+  }
+
+  public bool Fire() {
+    bool ret = freeswitchPINVOKE.Event_Fire(swigCPtr);
     return ret;
   }
 
@@ -957,6 +967,10 @@ public class freeswitch {
     freeswitchPINVOKE.switch_regex_set_var_callback(var, val, SWIGTYPE_p_void.getCPtr(user_data));
   }
 
+  public static void switch_regex_set_event_header_callback(string var, string val, SWIGTYPE_p_void user_data) {
+    freeswitchPINVOKE.switch_regex_set_event_header_callback(var, val, SWIGTYPE_p_void.getCPtr(user_data));
+  }
+
   public static void switch_core_session_sched_heartbeat(SWIGTYPE_p_switch_core_session session, uint seconds) {
     freeswitchPINVOKE.switch_core_session_sched_heartbeat(SWIGTYPE_p_switch_core_session.getCPtr(session), seconds);
   }
@@ -2424,6 +2438,11 @@ public class freeswitch {
     return ret;
   }
 
+  public static switch_status_t switch_core_chat_deliver(string dest_proto, SWIGTYPE_p_p_switch_event message_event) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_chat_deliver(dest_proto, SWIGTYPE_p_p_switch_event.getCPtr(message_event));
+    return ret;
+  }
+
   public static switch_status_t switch_ivr_preprocess_session(SWIGTYPE_p_switch_core_session session, string cmds) {
     switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_preprocess_session(SWIGTYPE_p_switch_core_session.getCPtr(session), cmds);
     return ret;
@@ -2621,6 +2640,17 @@ public class freeswitch {
     return ret;
   }
 
+  public static switch_chat_application_interface switch_loadable_module_get_chat_application_interface(string name) {
+    IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_chat_application_interface(name);
+    switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
+    return ret;
+  }
+
+  public static switch_status_t switch_core_execute_chat_app(switch_event message, string app, string data) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_core_execute_chat_app(switch_event.getCPtr(message), app, data);
+    return ret;
+  }
+
   public static switch_api_interface switch_loadable_module_get_api_interface(string name) {
     IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_get_api_interface(name);
     switch_api_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_api_interface(cPtr, false);
@@ -4027,6 +4057,11 @@ public class freeswitch {
     return ret;
   }
 
+  public static switch_status_t switch_event_rename_header(switch_event arg0, string header_name, string new_header_name) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_rename_header(switch_event.getCPtr(arg0), header_name, new_header_name);
+    return ret;
+  }
+
   public static string switch_event_get_body(switch_event arg0) {
     string ret = freeswitchPINVOKE.switch_event_get_body(switch_event.getCPtr(arg0));
     return ret;
@@ -4065,6 +4100,11 @@ public class freeswitch {
     freeswitchPINVOKE.switch_event_merge(switch_event.getCPtr(arg0), switch_event.getCPtr(tomerge));
   }
 
+  public static switch_status_t switch_event_dup_reply(SWIGTYPE_p_p_switch_event arg0, switch_event todup) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_dup_reply(SWIGTYPE_p_p_switch_event.getCPtr(arg0), switch_event.getCPtr(todup));
+    return ret;
+  }
+
   public static switch_status_t switch_event_fire_detailed(string file, string func, int line, SWIGTYPE_p_p_switch_event arg3, SWIGTYPE_p_void user_data) {
     switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_fire_detailed(file, func, line, SWIGTYPE_p_p_switch_event.getCPtr(arg3), SWIGTYPE_p_void.getCPtr(user_data));
     return ret;
@@ -4139,6 +4179,11 @@ public class freeswitch {
     return ret;
   }
 
+  public static switch_status_t switch_event_set_body(switch_event arg0, string body) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_event_set_body(switch_event.getCPtr(arg0), body);
+    return ret;
+  }
+
   public static string switch_event_expand_headers(switch_event arg0, string arg1) {
     string ret = freeswitchPINVOKE.switch_event_expand_headers(switch_event.getCPtr(arg0), arg1);
     return ret;
@@ -4851,6 +4896,11 @@ public class freeswitch {
     return ret;
   }
 
+  public static switch_status_t switch_ivr_create_message_reply(SWIGTYPE_p_p_switch_event reply, switch_event message, string new_proto) {
+    switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_ivr_create_message_reply(SWIGTYPE_p_p_switch_event.getCPtr(reply), switch_event.getCPtr(message), new_proto);
+    return ret;
+  }
+
   public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) {
     switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen));
     if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve();
@@ -7409,6 +7459,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_regex_set_var_callback")]
   public static extern void switch_regex_set_var_callback(string jarg1, string jarg2, HandleRef jarg3);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_regex_set_event_header_callback")]
+  public static extern void switch_regex_set_event_header_callback(string jarg1, string jarg2, HandleRef jarg3);
+
   [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get")]
   public static extern int SWITCH_MAX_CORE_THREAD_SESSION_OBJS_get();
 
@@ -8540,6 +8593,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_send")]
   public static extern int switch_core_chat_send(string jarg1, HandleRef jarg2);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_core_chat_deliver")]
+  public static extern int switch_core_chat_deliver(string jarg1, HandleRef jarg2);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_preprocess_session")]
   public static extern int switch_ivr_preprocess_session(HandleRef jarg1, string jarg2);
 
@@ -8741,6 +8797,12 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_application_interface_get")]
   public static extern IntPtr switch_loadable_module_interface_application_interface_get(HandleRef jarg1);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_chat_application_interface_set")]
+  public static extern void switch_loadable_module_interface_chat_application_interface_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_chat_application_interface_get")]
+  public static extern IntPtr switch_loadable_module_interface_chat_application_interface_get(HandleRef jarg1);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_interface_api_interface_set")]
   public static extern void switch_loadable_module_interface_api_interface_set(HandleRef jarg1, HandleRef jarg2);
 
@@ -8849,6 +8911,12 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_application_interface")]
   public static extern IntPtr switch_loadable_module_get_application_interface(string jarg1);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_chat_application_interface")]
+  public static extern IntPtr switch_loadable_module_get_chat_application_interface(string jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_core_execute_chat_app")]
+  public static extern int switch_core_execute_chat_app(HandleRef jarg1, string jarg2, string jarg3);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_loadable_module_get_api_interface")]
   public static extern IntPtr switch_loadable_module_get_api_interface(string jarg1);
 
@@ -11618,25 +11686,97 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_application_interface")]
   public static extern void delete_switch_application_interface(HandleRef jarg1);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_interface_name_set")]
-  public static extern void switch_api_interface_interface_name_set(HandleRef jarg1, string jarg2);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_interface_name_set")]
+  public static extern void switch_chat_application_interface_interface_name_set(HandleRef jarg1, string jarg2);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_interface_name_get")]
-  public static extern string switch_api_interface_interface_name_get(HandleRef jarg1);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_interface_name_get")]
+  public static extern string switch_chat_application_interface_interface_name_get(HandleRef jarg1);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_desc_set")]
-  public static extern void switch_api_interface_desc_set(HandleRef jarg1, string jarg2);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_chat_application_function_set")]
+  public static extern void switch_chat_application_interface_chat_application_function_set(HandleRef jarg1, HandleRef jarg2);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_desc_get")]
-  public static extern string switch_api_interface_desc_get(HandleRef jarg1);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_chat_application_function_get")]
+  public static extern IntPtr switch_chat_application_interface_chat_application_function_get(HandleRef jarg1);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_function_set")]
-  public static extern void switch_api_interface_function_set(HandleRef jarg1, HandleRef jarg2);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_long_desc_set")]
+  public static extern void switch_chat_application_interface_long_desc_set(HandleRef jarg1, string jarg2);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_function_get")]
-  public static extern IntPtr switch_api_interface_function_get(HandleRef jarg1);
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_long_desc_get")]
+  public static extern string switch_chat_application_interface_long_desc_get(HandleRef jarg1);
 
-  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_syntax_set")]
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_short_desc_set")]
+  public static extern void switch_chat_application_interface_short_desc_set(HandleRef jarg1, string jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_short_desc_get")]
+  public static extern string switch_chat_application_interface_short_desc_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_syntax_set")]
+  public static extern void switch_chat_application_interface_syntax_set(HandleRef jarg1, string jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_syntax_get")]
+  public static extern string switch_chat_application_interface_syntax_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_flags_set")]
+  public static extern void switch_chat_application_interface_flags_set(HandleRef jarg1, uint jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_flags_get")]
+  public static extern uint switch_chat_application_interface_flags_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_rwlock_set")]
+  public static extern void switch_chat_application_interface_rwlock_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_rwlock_get")]
+  public static extern IntPtr switch_chat_application_interface_rwlock_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_refs_set")]
+  public static extern void switch_chat_application_interface_refs_set(HandleRef jarg1, int jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_refs_get")]
+  public static extern int switch_chat_application_interface_refs_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_reflock_set")]
+  public static extern void switch_chat_application_interface_reflock_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_reflock_get")]
+  public static extern IntPtr switch_chat_application_interface_reflock_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_parent_set")]
+  public static extern void switch_chat_application_interface_parent_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_parent_get")]
+  public static extern IntPtr switch_chat_application_interface_parent_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_next_set")]
+  public static extern void switch_chat_application_interface_next_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_chat_application_interface_next_get")]
+  public static extern IntPtr switch_chat_application_interface_next_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_new_switch_chat_application_interface")]
+  public static extern IntPtr new_switch_chat_application_interface();
+
+  [DllImport("mod_managed", EntryPoint="CSharp_delete_switch_chat_application_interface")]
+  public static extern void delete_switch_chat_application_interface(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_interface_name_set")]
+  public static extern void switch_api_interface_interface_name_set(HandleRef jarg1, string jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_interface_name_get")]
+  public static extern string switch_api_interface_interface_name_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_desc_set")]
+  public static extern void switch_api_interface_desc_set(HandleRef jarg1, string jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_desc_get")]
+  public static extern string switch_api_interface_desc_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_function_set")]
+  public static extern void switch_api_interface_function_set(HandleRef jarg1, HandleRef jarg2);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_function_get")]
+  public static extern IntPtr switch_api_interface_function_get(HandleRef jarg1);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_syntax_set")]
   public static extern void switch_api_interface_syntax_set(HandleRef jarg1, string jarg2);
 
   [DllImport("mod_managed", EntryPoint="CSharp_switch_api_interface_syntax_get")]
@@ -12344,6 +12484,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_get_header_idx")]
   public static extern string switch_event_get_header_idx(HandleRef jarg1, string jarg2, int jarg3);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_event_rename_header")]
+  public static extern int switch_event_rename_header(HandleRef jarg1, string jarg2, string jarg3);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_get_body")]
   public static extern string switch_event_get_body(HandleRef jarg1);
 
@@ -12368,6 +12511,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_merge")]
   public static extern void switch_event_merge(HandleRef jarg1, HandleRef jarg2);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_event_dup_reply")]
+  public static extern int switch_event_dup_reply(HandleRef jarg1, HandleRef jarg2);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_fire_detailed")]
   public static extern int switch_event_fire_detailed(string jarg1, string jarg2, int jarg3, HandleRef jarg4, HandleRef jarg5);
 
@@ -12413,6 +12559,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_running")]
   public static extern int switch_event_running();
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_event_set_body")]
+  public static extern int switch_event_set_body(HandleRef jarg1, string jarg2);
+
   [DllImport("mod_managed", EntryPoint="CSharp_switch_event_expand_headers")]
   public static extern string switch_event_expand_headers(HandleRef jarg1, string jarg2);
 
@@ -13004,6 +13153,9 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_insert_file")]
   public static extern int switch_ivr_insert_file(HandleRef jarg1, string jarg2, string jarg3, HandleRef jarg4);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_create_message_reply")]
+  public static extern int switch_ivr_create_message_reply(HandleRef jarg1, HandleRef jarg2, string jarg3);
+
   [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")]
   public static extern int SWITCH_RTP_MAX_BUF_LEN_get();
 
@@ -14219,6 +14371,12 @@ class freeswitchPINVOKE {
   [DllImport("mod_managed", EntryPoint="CSharp_delete_Event")]
   public static extern void delete_Event(HandleRef jarg1);
 
+  [DllImport("mod_managed", EntryPoint="CSharp_Event_chat_execute")]
+  public static extern int Event_chat_execute(HandleRef jarg1, string jarg2, string jarg3);
+
+  [DllImport("mod_managed", EntryPoint="CSharp_Event_chat_send")]
+  public static extern int Event_chat_send(HandleRef jarg1, string jarg2);
+
   [DllImport("mod_managed", EntryPoint="CSharp_Event_Serialize")]
   public static extern string Event_Serialize(HandleRef jarg1, string jarg2);
 
@@ -15773,18 +15931,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t {
+public class SWIGTYPE_p_f_p_switch_codec__switch_status_t {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_f_p_switch_codec__switch_status_t(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t() {
+  protected SWIGTYPE_p_f_p_switch_codec__switch_status_t() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_codec__switch_status_t obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -15803,18 +15961,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_f_p_switch_codec__switch_status_t {
+public class SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_f_p_switch_codec__switch_status_t(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_f_p_switch_codec__switch_status_t() {
+  protected SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_codec__switch_status_t obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_codec_unsigned_long_p_q_const__switch_codec_settings__switch_status_t obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -16343,18 +16501,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension {
+public class SWIGTYPE_p_f_p_switch_core_session__switch_status_t {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_f_p_switch_core_session__switch_status_t(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension() {
+  protected SWIGTYPE_p_f_p_switch_core_session__switch_status_t() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session__switch_status_t obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -16373,18 +16531,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_f_p_switch_core_session__switch_status_t {
+public class SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_f_p_switch_core_session__switch_status_t(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_f_p_switch_core_session__switch_status_t() {
+  protected SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session__switch_status_t obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_core_session_t_p_void_p_switch_caller_profile_t__p_switch_caller_extension obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -16523,6 +16681,36 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
+public class SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t {
+  private HandleRef swigCPtr;
+
+  internal SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t(IntPtr cPtr, bool futureUse) {
+    swigCPtr = new HandleRef(this, cPtr);
+  }
+
+  protected SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t() {
+    swigCPtr = new HandleRef(null, IntPtr.Zero);
+  }
+
+  internal static HandleRef getCPtr(SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t obj) {
+    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+  }
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
+using System;
+using System.Runtime.InteropServices;
+
 public class SWIGTYPE_p_f_p_switch_event__switch_status_t {
   private HandleRef swigCPtr;
 
@@ -18533,18 +18721,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_p_switch_xml {
+public class SWIGTYPE_p_p_switch_xml_binding {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_p_switch_xml(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_p_switch_xml_binding(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_p_switch_xml() {
+  protected SWIGTYPE_p_p_switch_xml_binding() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_xml obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_xml_binding obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -18563,18 +18751,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_p_switch_xml_binding {
+public class SWIGTYPE_p_p_switch_xml {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_p_switch_xml_binding(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_p_switch_xml(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_p_switch_xml_binding() {
+  protected SWIGTYPE_p_p_switch_xml() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_xml_binding obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_p_switch_xml obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -19253,18 +19441,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_switch_ivr_menu {
+public class SWIGTYPE_p_switch_ivr_menu_action_function_t {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_switch_ivr_menu(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_switch_ivr_menu_action_function_t(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_switch_ivr_menu() {
+  protected SWIGTYPE_p_switch_ivr_menu_action_function_t() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_switch_ivr_menu obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_switch_ivr_menu_action_function_t obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -19283,18 +19471,18 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class SWIGTYPE_p_switch_ivr_menu_action_function_t {
+public class SWIGTYPE_p_switch_ivr_menu {
   private HandleRef swigCPtr;
 
-  internal SWIGTYPE_p_switch_ivr_menu_action_function_t(IntPtr cPtr, bool futureUse) {
+  internal SWIGTYPE_p_switch_ivr_menu(IntPtr cPtr, bool futureUse) {
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  protected SWIGTYPE_p_switch_ivr_menu_action_function_t() {
+  protected SWIGTYPE_p_switch_ivr_menu() {
     swigCPtr = new HandleRef(null, IntPtr.Zero);
   }
 
-  internal static HandleRef getCPtr(SWIGTYPE_p_switch_ivr_menu_action_function_t obj) {
+  internal static HandleRef getCPtr(SWIGTYPE_p_switch_ivr_menu obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 }
@@ -21592,6 +21780,100 @@ public class switch_cache_db_odbc_options_t : IDisposable {
 
 namespace FreeSWITCH.Native {
 
+public enum switch_call_cause_t {
+  SWITCH_CAUSE_NONE = 0,
+  SWITCH_CAUSE_UNALLOCATED_NUMBER = 1,
+  SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
+  SWITCH_CAUSE_NO_ROUTE_DESTINATION = 3,
+  SWITCH_CAUSE_CHANNEL_UNACCEPTABLE = 6,
+  SWITCH_CAUSE_CALL_AWARDED_DELIVERED = 7,
+  SWITCH_CAUSE_NORMAL_CLEARING = 16,
+  SWITCH_CAUSE_USER_BUSY = 17,
+  SWITCH_CAUSE_NO_USER_RESPONSE = 18,
+  SWITCH_CAUSE_NO_ANSWER = 19,
+  SWITCH_CAUSE_SUBSCRIBER_ABSENT = 20,
+  SWITCH_CAUSE_CALL_REJECTED = 21,
+  SWITCH_CAUSE_NUMBER_CHANGED = 22,
+  SWITCH_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
+  SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
+  SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
+  SWITCH_CAUSE_INVALID_NUMBER_FORMAT = 28,
+  SWITCH_CAUSE_FACILITY_REJECTED = 29,
+  SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
+  SWITCH_CAUSE_NORMAL_UNSPECIFIED = 31,
+  SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
+  SWITCH_CAUSE_NETWORK_OUT_OF_ORDER = 38,
+  SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
+  SWITCH_CAUSE_SWITCH_CONGESTION = 42,
+  SWITCH_CAUSE_ACCESS_INFO_DISCARDED = 43,
+  SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
+  SWITCH_CAUSE_PRE_EMPTED = 45,
+  SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
+  SWITCH_CAUSE_OUTGOING_CALL_BARRED = 52,
+  SWITCH_CAUSE_INCOMING_CALL_BARRED = 54,
+  SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
+  SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
+  SWITCH_CAUSE_SERVICE_UNAVAILABLE = 63,
+  SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
+  SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
+  SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
+  SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
+  SWITCH_CAUSE_INVALID_CALL_REFERENCE = 81,
+  SWITCH_CAUSE_INCOMPATIBLE_DESTINATION = 88,
+  SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
+  SWITCH_CAUSE_MANDATORY_IE_MISSING = 96,
+  SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
+  SWITCH_CAUSE_WRONG_MESSAGE = 98,
+  SWITCH_CAUSE_IE_NONEXIST = 99,
+  SWITCH_CAUSE_INVALID_IE_CONTENTS = 100,
+  SWITCH_CAUSE_WRONG_CALL_STATE = 101,
+  SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
+  SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
+  SWITCH_CAUSE_PROTOCOL_ERROR = 111,
+  SWITCH_CAUSE_INTERWORKING = 127,
+  SWITCH_CAUSE_SUCCESS = 142,
+  SWITCH_CAUSE_ORIGINATOR_CANCEL = 487,
+  SWITCH_CAUSE_CRASH = 500,
+  SWITCH_CAUSE_SYSTEM_SHUTDOWN = 501,
+  SWITCH_CAUSE_LOSE_RACE = 502,
+  SWITCH_CAUSE_MANAGER_REQUEST = 503,
+  SWITCH_CAUSE_BLIND_TRANSFER = 600,
+  SWITCH_CAUSE_ATTENDED_TRANSFER = 601,
+  SWITCH_CAUSE_ALLOTTED_TIMEOUT = 602,
+  SWITCH_CAUSE_USER_CHALLENGE = 603,
+  SWITCH_CAUSE_MEDIA_TIMEOUT = 604,
+  SWITCH_CAUSE_PICKED_OFF = 605,
+  SWITCH_CAUSE_USER_NOT_REGISTERED = 606,
+  SWITCH_CAUSE_PROGRESS_TIMEOUT = 607
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
+public enum switch_call_direction_t {
+  SWITCH_CALL_DIRECTION_INBOUND,
+  SWITCH_CALL_DIRECTION_OUTBOUND
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
 using System;
 using System.Runtime.InteropServices;
 
@@ -22227,100 +22509,6 @@ namespace FreeSWITCH.Native {
 
 namespace FreeSWITCH.Native {
 
-public enum switch_call_cause_t {
-  SWITCH_CAUSE_NONE = 0,
-  SWITCH_CAUSE_UNALLOCATED_NUMBER = 1,
-  SWITCH_CAUSE_NO_ROUTE_TRANSIT_NET = 2,
-  SWITCH_CAUSE_NO_ROUTE_DESTINATION = 3,
-  SWITCH_CAUSE_CHANNEL_UNACCEPTABLE = 6,
-  SWITCH_CAUSE_CALL_AWARDED_DELIVERED = 7,
-  SWITCH_CAUSE_NORMAL_CLEARING = 16,
-  SWITCH_CAUSE_USER_BUSY = 17,
-  SWITCH_CAUSE_NO_USER_RESPONSE = 18,
-  SWITCH_CAUSE_NO_ANSWER = 19,
-  SWITCH_CAUSE_SUBSCRIBER_ABSENT = 20,
-  SWITCH_CAUSE_CALL_REJECTED = 21,
-  SWITCH_CAUSE_NUMBER_CHANGED = 22,
-  SWITCH_CAUSE_REDIRECTION_TO_NEW_DESTINATION = 23,
-  SWITCH_CAUSE_EXCHANGE_ROUTING_ERROR = 25,
-  SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER = 27,
-  SWITCH_CAUSE_INVALID_NUMBER_FORMAT = 28,
-  SWITCH_CAUSE_FACILITY_REJECTED = 29,
-  SWITCH_CAUSE_RESPONSE_TO_STATUS_ENQUIRY = 30,
-  SWITCH_CAUSE_NORMAL_UNSPECIFIED = 31,
-  SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION = 34,
-  SWITCH_CAUSE_NETWORK_OUT_OF_ORDER = 38,
-  SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE = 41,
-  SWITCH_CAUSE_SWITCH_CONGESTION = 42,
-  SWITCH_CAUSE_ACCESS_INFO_DISCARDED = 43,
-  SWITCH_CAUSE_REQUESTED_CHAN_UNAVAIL = 44,
-  SWITCH_CAUSE_PRE_EMPTED = 45,
-  SWITCH_CAUSE_FACILITY_NOT_SUBSCRIBED = 50,
-  SWITCH_CAUSE_OUTGOING_CALL_BARRED = 52,
-  SWITCH_CAUSE_INCOMING_CALL_BARRED = 54,
-  SWITCH_CAUSE_BEARERCAPABILITY_NOTAUTH = 57,
-  SWITCH_CAUSE_BEARERCAPABILITY_NOTAVAIL = 58,
-  SWITCH_CAUSE_SERVICE_UNAVAILABLE = 63,
-  SWITCH_CAUSE_BEARERCAPABILITY_NOTIMPL = 65,
-  SWITCH_CAUSE_CHAN_NOT_IMPLEMENTED = 66,
-  SWITCH_CAUSE_FACILITY_NOT_IMPLEMENTED = 69,
-  SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED = 79,
-  SWITCH_CAUSE_INVALID_CALL_REFERENCE = 81,
-  SWITCH_CAUSE_INCOMPATIBLE_DESTINATION = 88,
-  SWITCH_CAUSE_INVALID_MSG_UNSPECIFIED = 95,
-  SWITCH_CAUSE_MANDATORY_IE_MISSING = 96,
-  SWITCH_CAUSE_MESSAGE_TYPE_NONEXIST = 97,
-  SWITCH_CAUSE_WRONG_MESSAGE = 98,
-  SWITCH_CAUSE_IE_NONEXIST = 99,
-  SWITCH_CAUSE_INVALID_IE_CONTENTS = 100,
-  SWITCH_CAUSE_WRONG_CALL_STATE = 101,
-  SWITCH_CAUSE_RECOVERY_ON_TIMER_EXPIRE = 102,
-  SWITCH_CAUSE_MANDATORY_IE_LENGTH_ERROR = 103,
-  SWITCH_CAUSE_PROTOCOL_ERROR = 111,
-  SWITCH_CAUSE_INTERWORKING = 127,
-  SWITCH_CAUSE_SUCCESS = 142,
-  SWITCH_CAUSE_ORIGINATOR_CANCEL = 487,
-  SWITCH_CAUSE_CRASH = 500,
-  SWITCH_CAUSE_SYSTEM_SHUTDOWN = 501,
-  SWITCH_CAUSE_LOSE_RACE = 502,
-  SWITCH_CAUSE_MANAGER_REQUEST = 503,
-  SWITCH_CAUSE_BLIND_TRANSFER = 600,
-  SWITCH_CAUSE_ATTENDED_TRANSFER = 601,
-  SWITCH_CAUSE_ALLOTTED_TIMEOUT = 602,
-  SWITCH_CAUSE_USER_CHALLENGE = 603,
-  SWITCH_CAUSE_MEDIA_TIMEOUT = 604,
-  SWITCH_CAUSE_PICKED_OFF = 605,
-  SWITCH_CAUSE_USER_NOT_REGISTERED = 606,
-  SWITCH_CAUSE_PROGRESS_TIMEOUT = 607
-}
-
-}
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-namespace FreeSWITCH.Native {
-
-public enum switch_call_direction_t {
-  SWITCH_CALL_DIRECTION_INBOUND,
-  SWITCH_CALL_DIRECTION_OUTBOUND
-}
-
-}
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-namespace FreeSWITCH.Native {
-
 public enum switch_channel_app_flag_t {
   CF_APP_TAGGED = (1 << 0),
   CF_APP_T38 = (1 << 1),
@@ -22678,6 +22866,183 @@ public class switch_channel_timetable : IDisposable {
 
 namespace FreeSWITCH.Native {
 
+public enum switch_chat_application_flag_enum_t {
+  SCAF_NONE = 0
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
+using System;
+using System.Runtime.InteropServices;
+
+public class switch_chat_application_interface : IDisposable {
+  private HandleRef swigCPtr;
+  protected bool swigCMemOwn;
+
+  internal switch_chat_application_interface(IntPtr cPtr, bool cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = new HandleRef(this, cPtr);
+  }
+
+  internal static HandleRef getCPtr(switch_chat_application_interface obj) {
+    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+  }
+
+  ~switch_chat_application_interface() {
+    Dispose();
+  }
+
+  public virtual void Dispose() {
+    lock(this) {
+      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
+        swigCMemOwn = false;
+        freeswitchPINVOKE.delete_switch_chat_application_interface(swigCPtr);
+      }
+      swigCPtr = new HandleRef(null, IntPtr.Zero);
+      GC.SuppressFinalize(this);
+    }
+  }
+
+  public string interface_name {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_interface_name_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.switch_chat_application_interface_interface_name_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t chat_application_function {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_chat_application_function_set(swigCPtr, SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_chat_application_function_get(swigCPtr);
+      SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_event_p_q_const__char__switch_status_t(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public string long_desc {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_long_desc_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.switch_chat_application_interface_long_desc_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public string short_desc {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_short_desc_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.switch_chat_application_interface_short_desc_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public string syntax {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_syntax_set(swigCPtr, value);
+    } 
+    get {
+      string ret = freeswitchPINVOKE.switch_chat_application_interface_syntax_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public uint flags {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_flags_set(swigCPtr, value);
+    } 
+    get {
+      uint ret = freeswitchPINVOKE.switch_chat_application_interface_flags_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public SWIGTYPE_p_switch_thread_rwlock_t rwlock {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_rwlock_set(swigCPtr, SWIGTYPE_p_switch_thread_rwlock_t.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_rwlock_get(swigCPtr);
+      SWIGTYPE_p_switch_thread_rwlock_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_thread_rwlock_t(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public int refs {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_refs_set(swigCPtr, value);
+    } 
+    get {
+      int ret = freeswitchPINVOKE.switch_chat_application_interface_refs_get(swigCPtr);
+      return ret;
+    } 
+  }
+
+  public SWIGTYPE_p_switch_mutex_t reflock {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_reflock_set(swigCPtr, SWIGTYPE_p_switch_mutex_t.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_reflock_get(swigCPtr);
+      SWIGTYPE_p_switch_mutex_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_switch_mutex_t(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_loadable_module_interface parent {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_parent_set(swigCPtr, switch_loadable_module_interface.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_parent_get(swigCPtr);
+      switch_loadable_module_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_loadable_module_interface(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_chat_application_interface next {
+    set {
+      freeswitchPINVOKE.switch_chat_application_interface_next_set(swigCPtr, switch_chat_application_interface.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_chat_application_interface_next_get(swigCPtr);
+      switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_chat_application_interface() : this(freeswitchPINVOKE.new_switch_chat_application_interface(), true) {
+  }
+
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
 using System;
 using System.Runtime.InteropServices;
 
@@ -25431,7 +25796,8 @@ public class switch_event : IDisposable {
 namespace FreeSWITCH.Native {
 
 public enum switch_event_flag_t {
-  EF_UNIQ_HEADERS = (1 << 0)
+  EF_UNIQ_HEADERS = (1 << 0),
+  EF_NO_CHAT_EXEC = (1 << 1)
 }
 
 }
@@ -26714,20 +27080,20 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
-public class switch_io_event_hooks : IDisposable {
+public class switch_io_event_hook_kill_channel : IDisposable {
   private HandleRef swigCPtr;
   protected bool swigCMemOwn;
 
-  internal switch_io_event_hooks(IntPtr cPtr, bool cMemoryOwn) {
+  internal switch_io_event_hook_kill_channel(IntPtr cPtr, bool cMemoryOwn) {
     swigCMemOwn = cMemoryOwn;
     swigCPtr = new HandleRef(this, cPtr);
   }
 
-  internal static HandleRef getCPtr(switch_io_event_hooks obj) {
+  internal static HandleRef getCPtr(switch_io_event_hook_kill_channel obj) {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
   }
 
-  ~switch_io_event_hooks() {
+  ~switch_io_event_hook_kill_channel() {
     Dispose();
   }
 
@@ -26735,229 +27101,39 @@ public class switch_io_event_hooks : IDisposable {
     lock(this) {
       if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
         swigCMemOwn = false;
-        freeswitchPINVOKE.delete_switch_io_event_hooks(swigCPtr);
+        freeswitchPINVOKE.delete_switch_io_event_hook_kill_channel(swigCPtr);
       }
       swigCPtr = new HandleRef(null, IntPtr.Zero);
       GC.SuppressFinalize(this);
     }
   }
 
-  public switch_io_event_hook_outgoing_channel outgoing_channel {
+  public SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t kill_channel {
     set {
-      freeswitchPINVOKE.switch_io_event_hooks_outgoing_channel_set(swigCPtr, switch_io_event_hook_outgoing_channel.getCPtr(value));
+      freeswitchPINVOKE.switch_io_event_hook_kill_channel_kill_channel_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t.getCPtr(value));
     } 
     get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_outgoing_channel_get(swigCPtr);
-      switch_io_event_hook_outgoing_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_outgoing_channel(cPtr, false);
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_kill_channel_kill_channel_get(swigCPtr);
+      SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t(cPtr, false);
       return ret;
     } 
   }
 
-  public switch_io_event_hook_receive_message receive_message {
+  public switch_io_event_hook_kill_channel next {
     set {
-      freeswitchPINVOKE.switch_io_event_hooks_receive_message_set(swigCPtr, switch_io_event_hook_receive_message.getCPtr(value));
+      freeswitchPINVOKE.switch_io_event_hook_kill_channel_next_set(swigCPtr, switch_io_event_hook_kill_channel.getCPtr(value));
     } 
     get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_receive_message_get(swigCPtr);
-      switch_io_event_hook_receive_message ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_receive_message(cPtr, false);
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_kill_channel_next_get(swigCPtr);
+      switch_io_event_hook_kill_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_kill_channel(cPtr, false);
       return ret;
     } 
   }
 
-  public switch_io_event_hook_receive_event receive_event {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_receive_event_set(swigCPtr, switch_io_event_hook_receive_event.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_receive_event_get(swigCPtr);
-      switch_io_event_hook_receive_event ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_receive_event(cPtr, false);
-      return ret;
-    } 
+  public switch_io_event_hook_kill_channel() : this(freeswitchPINVOKE.new_switch_io_event_hook_kill_channel(), true) {
   }
 
-  public switch_io_event_hook_read_frame read_frame {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_read_frame_set(swigCPtr, switch_io_event_hook_read_frame.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_read_frame_get(swigCPtr);
-      switch_io_event_hook_read_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_read_frame(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_video_read_frame video_read_frame {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_video_read_frame_set(swigCPtr, switch_io_event_hook_video_read_frame.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_video_read_frame_get(swigCPtr);
-      switch_io_event_hook_video_read_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_video_read_frame(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_write_frame write_frame {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_write_frame_set(swigCPtr, switch_io_event_hook_write_frame.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_write_frame_get(swigCPtr);
-      switch_io_event_hook_write_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_write_frame(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_video_write_frame video_write_frame {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_video_write_frame_set(swigCPtr, switch_io_event_hook_video_write_frame.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_video_write_frame_get(swigCPtr);
-      switch_io_event_hook_video_write_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_video_write_frame(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_kill_channel kill_channel {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_kill_channel_set(swigCPtr, switch_io_event_hook_kill_channel.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_kill_channel_get(swigCPtr);
-      switch_io_event_hook_kill_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_kill_channel(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_send_dtmf send_dtmf {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_send_dtmf_set(swigCPtr, switch_io_event_hook_send_dtmf.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_send_dtmf_get(swigCPtr);
-      switch_io_event_hook_send_dtmf ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_send_dtmf(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_recv_dtmf recv_dtmf {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_recv_dtmf_set(swigCPtr, switch_io_event_hook_recv_dtmf.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_recv_dtmf_get(swigCPtr);
-      switch_io_event_hook_recv_dtmf ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_recv_dtmf(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_state_change state_change {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_state_change_set(swigCPtr, switch_io_event_hook_state_change.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_state_change_get(swigCPtr);
-      switch_io_event_hook_state_change ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_change(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_state_run state_run {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_state_run_set(swigCPtr, switch_io_event_hook_state_run.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_state_run_get(swigCPtr);
-      switch_io_event_hook_state_run ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_run(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_resurrect_session resurrect_session {
-    set {
-      freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_get(swigCPtr);
-      switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hooks() : this(freeswitchPINVOKE.new_switch_io_event_hooks(), true) {
-  }
-
-}
-
-}
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-namespace FreeSWITCH.Native {
-
-using System;
-using System.Runtime.InteropServices;
-
-public class switch_io_event_hook_kill_channel : IDisposable {
-  private HandleRef swigCPtr;
-  protected bool swigCMemOwn;
-
-  internal switch_io_event_hook_kill_channel(IntPtr cPtr, bool cMemoryOwn) {
-    swigCMemOwn = cMemoryOwn;
-    swigCPtr = new HandleRef(this, cPtr);
-  }
-
-  internal static HandleRef getCPtr(switch_io_event_hook_kill_channel obj) {
-    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
-  }
-
-  ~switch_io_event_hook_kill_channel() {
-    Dispose();
-  }
-
-  public virtual void Dispose() {
-    lock(this) {
-      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
-        swigCMemOwn = false;
-        freeswitchPINVOKE.delete_switch_io_event_hook_kill_channel(swigCPtr);
-      }
-      swigCPtr = new HandleRef(null, IntPtr.Zero);
-      GC.SuppressFinalize(this);
-    }
-  }
-
-  public SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t kill_channel {
-    set {
-      freeswitchPINVOKE.switch_io_event_hook_kill_channel_kill_channel_set(swigCPtr, SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_kill_channel_kill_channel_get(swigCPtr);
-      SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t ret = (cPtr == IntPtr.Zero) ? null : new SWIGTYPE_p_f_p_switch_core_session_int__switch_status_t(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_kill_channel next {
-    set {
-      freeswitchPINVOKE.switch_io_event_hook_kill_channel_next_set(swigCPtr, switch_io_event_hook_kill_channel.getCPtr(value));
-    } 
-    get {
-      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hook_kill_channel_next_get(swigCPtr);
-      switch_io_event_hook_kill_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_kill_channel(cPtr, false);
-      return ret;
-    } 
-  }
-
-  public switch_io_event_hook_kill_channel() : this(freeswitchPINVOKE.new_switch_io_event_hook_kill_channel(), true) {
-  }
-
-}
+}
 
 }
 /* ----------------------------------------------------------------------------
@@ -27387,6 +27563,196 @@ namespace FreeSWITCH.Native {
 using System;
 using System.Runtime.InteropServices;
 
+public class switch_io_event_hooks : IDisposable {
+  private HandleRef swigCPtr;
+  protected bool swigCMemOwn;
+
+  internal switch_io_event_hooks(IntPtr cPtr, bool cMemoryOwn) {
+    swigCMemOwn = cMemoryOwn;
+    swigCPtr = new HandleRef(this, cPtr);
+  }
+
+  internal static HandleRef getCPtr(switch_io_event_hooks obj) {
+    return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
+  }
+
+  ~switch_io_event_hooks() {
+    Dispose();
+  }
+
+  public virtual void Dispose() {
+    lock(this) {
+      if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
+        swigCMemOwn = false;
+        freeswitchPINVOKE.delete_switch_io_event_hooks(swigCPtr);
+      }
+      swigCPtr = new HandleRef(null, IntPtr.Zero);
+      GC.SuppressFinalize(this);
+    }
+  }
+
+  public switch_io_event_hook_outgoing_channel outgoing_channel {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_outgoing_channel_set(swigCPtr, switch_io_event_hook_outgoing_channel.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_outgoing_channel_get(swigCPtr);
+      switch_io_event_hook_outgoing_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_outgoing_channel(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_receive_message receive_message {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_receive_message_set(swigCPtr, switch_io_event_hook_receive_message.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_receive_message_get(swigCPtr);
+      switch_io_event_hook_receive_message ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_receive_message(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_receive_event receive_event {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_receive_event_set(swigCPtr, switch_io_event_hook_receive_event.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_receive_event_get(swigCPtr);
+      switch_io_event_hook_receive_event ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_receive_event(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_read_frame read_frame {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_read_frame_set(swigCPtr, switch_io_event_hook_read_frame.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_read_frame_get(swigCPtr);
+      switch_io_event_hook_read_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_read_frame(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_video_read_frame video_read_frame {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_video_read_frame_set(swigCPtr, switch_io_event_hook_video_read_frame.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_video_read_frame_get(swigCPtr);
+      switch_io_event_hook_video_read_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_video_read_frame(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_write_frame write_frame {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_write_frame_set(swigCPtr, switch_io_event_hook_write_frame.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_write_frame_get(swigCPtr);
+      switch_io_event_hook_write_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_write_frame(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_video_write_frame video_write_frame {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_video_write_frame_set(swigCPtr, switch_io_event_hook_video_write_frame.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_video_write_frame_get(swigCPtr);
+      switch_io_event_hook_video_write_frame ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_video_write_frame(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_kill_channel kill_channel {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_kill_channel_set(swigCPtr, switch_io_event_hook_kill_channel.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_kill_channel_get(swigCPtr);
+      switch_io_event_hook_kill_channel ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_kill_channel(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_send_dtmf send_dtmf {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_send_dtmf_set(swigCPtr, switch_io_event_hook_send_dtmf.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_send_dtmf_get(swigCPtr);
+      switch_io_event_hook_send_dtmf ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_send_dtmf(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_recv_dtmf recv_dtmf {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_recv_dtmf_set(swigCPtr, switch_io_event_hook_recv_dtmf.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_recv_dtmf_get(swigCPtr);
+      switch_io_event_hook_recv_dtmf ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_recv_dtmf(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_state_change state_change {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_state_change_set(swigCPtr, switch_io_event_hook_state_change.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_state_change_get(swigCPtr);
+      switch_io_event_hook_state_change ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_change(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_state_run state_run {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_state_run_set(swigCPtr, switch_io_event_hook_state_run.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_state_run_get(swigCPtr);
+      switch_io_event_hook_state_run ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_state_run(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hook_resurrect_session resurrect_session {
+    set {
+      freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_set(swigCPtr, switch_io_event_hook_resurrect_session.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_io_event_hooks_resurrect_session_get(swigCPtr);
+      switch_io_event_hook_resurrect_session ret = (cPtr == IntPtr.Zero) ? null : new switch_io_event_hook_resurrect_session(cPtr, false);
+      return ret;
+    } 
+  }
+
+  public switch_io_event_hooks() : this(freeswitchPINVOKE.new_switch_io_event_hooks(), true) {
+  }
+
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
+using System;
+using System.Runtime.InteropServices;
+
 public class switch_io_event_hook_send_dtmf : IDisposable {
   private HandleRef swigCPtr;
   protected bool swigCMemOwn;
@@ -27815,6 +28181,31 @@ namespace FreeSWITCH.Native {
 
 namespace FreeSWITCH.Native {
 
+public enum switch_io_routine_name_t {
+  SWITCH_IO_OUTGOING_CHANNEL,
+  SWITCH_IO_READ_FRAME,
+  SWITCH_IO_WRITE_FRAME,
+  SWITCH_IO_KILL_CHANNEL,
+  SWITCH_IO_SEND_DTMF,
+  SWITCH_IO_RECEIVE_MESSAGE,
+  SWITCH_IO_RECEIVE_EVENT,
+  SWITCH_IO_STATE_CHANGE,
+  SWITCH_IO_READ_VIDEO_FRAME,
+  SWITCH_IO_WRITE_VIDEO_FRAME,
+  SWITCH_IO_RESURRECT_SESSION
+}
+
+}
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.35
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+namespace FreeSWITCH.Native {
+
 using System;
 using System.Runtime.InteropServices;
 
@@ -28005,31 +28396,6 @@ public class switch_io_routines : IDisposable {
 
 namespace FreeSWITCH.Native {
 
-public enum switch_io_routine_name_t {
-  SWITCH_IO_OUTGOING_CHANNEL,
-  SWITCH_IO_READ_FRAME,
-  SWITCH_IO_WRITE_FRAME,
-  SWITCH_IO_KILL_CHANNEL,
-  SWITCH_IO_SEND_DTMF,
-  SWITCH_IO_RECEIVE_MESSAGE,
-  SWITCH_IO_RECEIVE_EVENT,
-  SWITCH_IO_STATE_CHANGE,
-  SWITCH_IO_READ_VIDEO_FRAME,
-  SWITCH_IO_WRITE_VIDEO_FRAME,
-  SWITCH_IO_RESURRECT_SESSION
-}
-
-}
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 1.3.35
- *
- * Do not make changes to this file unless you know what you are doing--modify
- * the SWIG interface file instead.
- * ----------------------------------------------------------------------------- */
-
-namespace FreeSWITCH.Native {
-
 public enum switch_ivr_action_t {
   SWITCH_IVR_ACTION_DIE,
   SWITCH_IVR_ACTION_EXECMENU,
@@ -28557,6 +28923,17 @@ public class switch_loadable_module_interface : IDisposable {
     } 
   }
 
+  public switch_chat_application_interface chat_application_interface {
+    set {
+      freeswitchPINVOKE.switch_loadable_module_interface_chat_application_interface_set(swigCPtr, switch_chat_application_interface.getCPtr(value));
+    } 
+    get {
+      IntPtr cPtr = freeswitchPINVOKE.switch_loadable_module_interface_chat_application_interface_get(swigCPtr);
+      switch_chat_application_interface ret = (cPtr == IntPtr.Zero) ? null : new switch_chat_application_interface(cPtr, false);
+      return ret;
+    } 
+  }
+
   public switch_api_interface api_interface {
     set {
       freeswitchPINVOKE.switch_loadable_module_interface_api_interface_set(swigCPtr, switch_api_interface.getCPtr(value));
@@ -29094,7 +29471,8 @@ public enum switch_module_interface_name_t {
   SWITCH_SAY_INTERFACE,
   SWITCH_ASR_INTERFACE,
   SWITCH_MANAGEMENT_INTERFACE,
-  SWITCH_LIMIT_INTERFACE
+  SWITCH_LIMIT_INTERFACE,
+  SWITCH_CHAT_APPLICATION_INTERFACE
 }
 
 }
index e55ffac7dedddfdef0b1406900d1ea317ad19de0..0e45a5e13ac5e2936d5c97d623361d717b0e4341 100644 (file)
@@ -292,6 +292,8 @@ sub DESTROY {
     }
 }
 
+*chat_execute = *freeswitchc::Event_chat_execute;
+*chat_send = *freeswitchc::Event_chat_send;
 *serialize = *freeswitchc::Event_serialize;
 *setPriority = *freeswitchc::Event_setPriority;
 *getHeader = *freeswitchc::Event_getHeader;
index 3957f52448793b71a54f8d0f2edceac5eb8347f9..3b1165bc7e5f738022347ca7b5b9452156bc0d52 100644 (file)
@@ -3679,6 +3679,99 @@ XS(_wrap_delete_Event) {
 }
 
 
+XS(_wrap_Event_chat_execute) {
+  {
+    Event *arg1 = (Event *) 0 ;
+    char *arg2 = (char *) 0 ;
+    char *arg3 = (char *) NULL ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int res3 ;
+    char *buf3 = 0 ;
+    int alloc3 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 2) || (items > 3)) {
+      SWIG_croak("Usage: Event_chat_execute(self,app,data);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Event, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_execute" "', argument " "1"" of type '" "Event *""'"); 
+    }
+    arg1 = reinterpret_cast< Event * >(argp1);
+    res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_execute" "', argument " "2"" of type '" "char const *""'");
+    }
+    arg2 = reinterpret_cast< char * >(buf2);
+    if (items > 2) {
+      res3 = SWIG_AsCharPtrAndSize(ST(2), &buf3, NULL, &alloc3);
+      if (!SWIG_IsOK(res3)) {
+        SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Event_chat_execute" "', argument " "3"" of type '" "char const *""'");
+      }
+      arg3 = reinterpret_cast< char * >(buf3);
+    }
+    result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+    SWIG_croak_null();
+  }
+}
+
+
+XS(_wrap_Event_chat_send) {
+  {
+    Event *arg1 = (Event *) 0 ;
+    char *arg2 = (char *) NULL ;
+    int result;
+    void *argp1 = 0 ;
+    int res1 = 0 ;
+    int res2 ;
+    char *buf2 = 0 ;
+    int alloc2 = 0 ;
+    int argvi = 0;
+    dXSARGS;
+    
+    if ((items < 1) || (items > 2)) {
+      SWIG_croak("Usage: Event_chat_send(self,dest_proto);");
+    }
+    res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_Event, 0 |  0 );
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_send" "', argument " "1"" of type '" "Event *""'"); 
+    }
+    arg1 = reinterpret_cast< Event * >(argp1);
+    if (items > 1) {
+      res2 = SWIG_AsCharPtrAndSize(ST(1), &buf2, NULL, &alloc2);
+      if (!SWIG_IsOK(res2)) {
+        SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_send" "', argument " "2"" of type '" "char const *""'");
+      }
+      arg2 = reinterpret_cast< char * >(buf2);
+    }
+    result = (int)(arg1)->chat_send((char const *)arg2);
+    ST(argvi) = SWIG_From_int  SWIG_PERL_CALL_ARGS_1(static_cast< int >(result)); argvi++ ;
+    
+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    XSRETURN(argvi);
+  fail:
+    
+    if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+    SWIG_croak_null();
+  }
+}
+
+
 XS(_wrap_Event_serialize) {
   {
     Event *arg1 = (Event *) 0 ;
@@ -9492,6 +9585,8 @@ static swig_command_info swig_commands[] = {
 {"freeswitchc::Event_mine_get", _wrap_Event_mine_get},
 {"freeswitchc::new_Event", _wrap_new_Event},
 {"freeswitchc::delete_Event", _wrap_delete_Event},
+{"freeswitchc::Event_chat_execute", _wrap_Event_chat_execute},
+{"freeswitchc::Event_chat_send", _wrap_Event_chat_send},
 {"freeswitchc::Event_serialize", _wrap_Event_serialize},
 {"freeswitchc::Event_setPriority", _wrap_Event_setPriority},
 {"freeswitchc::Event_getHeader", _wrap_Event_getHeader},
index d49016d3057c369c0ff3584600537e369771fa9b..c43fc8f3b8a5784ebcc42c4e390b13aaacced796 100644 (file)
@@ -175,6 +175,8 @@ class Event(_object):
         except: self.this = this
     __swig_destroy__ = _freeswitch.delete_Event
     __del__ = lambda self : None;
+    def chat_execute(*args): return _freeswitch.Event_chat_execute(*args)
+    def chat_send(*args): return _freeswitch.Event_chat_send(*args)
     def serialize(*args): return _freeswitch.Event_serialize(*args)
     def setPriority(*args): return _freeswitch.Event_setPriority(*args)
     def getHeader(*args): return _freeswitch.Event_getHeader(*args)
index 036aac8ea503269e64c2e5297d08c57c0c556156..3dd8a32f8a6112ab18a9a252bda2136116de96de 100644 (file)
@@ -4541,6 +4541,90 @@ fail:
 }
 
 
+SWIGINTERN PyObject *_wrap_Event_chat_execute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) 0 ;
+  char *arg3 = (char *) NULL ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 ;
+  char *buf2 = 0 ;
+  int alloc2 = 0 ;
+  int res3 ;
+  char *buf3 = 0 ;
+  int alloc3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO|O:Event_chat_execute",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Event, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_execute" "', argument " "1"" of type '" "Event *""'"); 
+  }
+  arg1 = reinterpret_cast< Event * >(argp1);
+  res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_execute" "', argument " "2"" of type '" "char const *""'");
+  }
+  arg2 = reinterpret_cast< char * >(buf2);
+  if (obj2) {
+    res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Event_chat_execute" "', argument " "3"" of type '" "char const *""'");
+    }
+    arg3 = reinterpret_cast< char * >(buf3);
+  }
+  result = (int)(arg1)->chat_execute((char const *)arg2,(char const *)arg3);
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+  return resultobj;
+fail:
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  if (alloc3 == SWIG_NEWOBJ) delete[] buf3;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_Event_chat_send(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  Event *arg1 = (Event *) 0 ;
+  char *arg2 = (char *) NULL ;
+  int result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 ;
+  char *buf2 = 0 ;
+  int alloc2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O|O:Event_chat_send",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Event, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Event_chat_send" "', argument " "1"" of type '" "Event *""'"); 
+  }
+  arg1 = reinterpret_cast< Event * >(argp1);
+  if (obj1) {
+    res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Event_chat_send" "', argument " "2"" of type '" "char const *""'");
+    }
+    arg2 = reinterpret_cast< char * >(buf2);
+  }
+  result = (int)(arg1)->chat_send((char const *)arg2);
+  resultobj = SWIG_From_int(static_cast< int >(result));
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  return resultobj;
+fail:
+  if (alloc2 == SWIG_NEWOBJ) delete[] buf2;
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_Event_serialize(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Event *arg1 = (Event *) 0 ;
@@ -9042,6 +9126,8 @@ static PyMethodDef SwigMethods[] = {
         { (char *)"Event_mine_get", _wrap_Event_mine_get, METH_VARARGS, NULL},
         { (char *)"new_Event", _wrap_new_Event, METH_VARARGS, NULL},
         { (char *)"delete_Event", _wrap_delete_Event, METH_VARARGS, NULL},
+        { (char *)"Event_chat_execute", _wrap_Event_chat_execute, METH_VARARGS, NULL},
+        { (char *)"Event_chat_send", _wrap_Event_chat_send, METH_VARARGS, NULL},
         { (char *)"Event_serialize", _wrap_Event_serialize, METH_VARARGS, NULL},
         { (char *)"Event_setPriority", _wrap_Event_setPriority, METH_VARARGS, NULL},
         { (char *)"Event_getHeader", _wrap_Event_getHeader, METH_VARARGS, NULL},
index a284854f46c5509d4a9ea6dc0035e8060912de9d..83dfca17b9c74b6253be57784376f46d2f279a37 100644 (file)
@@ -284,6 +284,19 @@ SWITCH_DECLARE_CONSTRUCTOR Event::~Event()
        }
 }
 
+SWITCH_DECLARE(int)Event::chat_execute(const char *app, const char *data)
+{
+       return (int) switch_core_execute_chat_app(event, app, data);
+}
+
+SWITCH_DECLARE(int)Event::chat_send(const char *dest_proto)
+{
+       if (zstr(dest_proto)) {
+               dest_proto = switch_event_get_header(event, "dest_proto");
+       }
+
+       return (int) switch_core_chat_send(dest_proto, event);
+}
 
 SWITCH_DECLARE(const char *)Event::serialize(const char *format)
 {
index 8265a182072075446e73ddb83a50a3e2fbcf642e..bb7000903d9a3659be9dee17432b3055a0e3b44f 100644 (file)
@@ -697,7 +697,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_subclass_detailed(const char
 
        memset(*event, 0, sizeof(switch_event_t));
 
-       if (event_id == SWITCH_EVENT_REQUEST_PARAMS || event_id == SWITCH_EVENT_CHANNEL_DATA) {
+       if (event_id == SWITCH_EVENT_REQUEST_PARAMS || event_id == SWITCH_EVENT_CHANNEL_DATA || event_id == SWITCH_EVENT_MESSAGE) {
                (*event)->flags |= EF_UNIQ_HEADERS;
        }
 
@@ -721,6 +721,35 @@ SWITCH_DECLARE(switch_status_t) switch_event_set_priority(switch_event_t *event,
        return SWITCH_STATUS_SUCCESS;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_event_rename_header(switch_event_t *event, const char *header_name, const char *new_header_name)
+{
+       switch_event_header_t *hp;
+       switch_ssize_t hlen = -1;
+       unsigned long hash = 0;
+       int x = 0;
+
+       switch_assert(event);
+
+       if (!header_name) {
+               return SWITCH_STATUS_FALSE;
+       }
+
+       hash = switch_ci_hashfunc_default(header_name, &hlen);
+
+       for (hp = event->headers; hp; hp = hp->next) {
+               if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name)) {
+                       FREE(hp->name);
+                       hp->name = DUP(new_header_name);
+                       hlen = -1;
+                       hp->hash = switch_ci_hashfunc_default(hp->name, &hlen);
+                       x++;
+               }
+       }
+
+       return x ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
+}
+
+
 SWITCH_DECLARE(switch_event_header_t *) switch_event_get_header_ptr(switch_event_t *event, const char *header_name)
 {
        switch_event_header_t *hp;
@@ -756,6 +785,8 @@ SWITCH_DECLARE(char *) switch_event_get_header_idx(switch_event_t *event, const
                }
 
                return hp->value;                       
+       } else if (!strcmp(header_name, "_body")) {
+               return event->body;
        }
 
        return NULL;
@@ -900,6 +931,11 @@ static switch_status_t switch_event_base_add_header(switch_event_t *event, switc
        int index = 0;
        char *real_header_name = NULL;
 
+
+       if (!strcmp(header_name, "_body")) {
+               switch_event_set_body(event, data);
+       }
+
        if ((index_ptr = strchr(header_name, '['))) {
                index_ptr++;
                index = atoi(index_ptr);
@@ -1102,6 +1138,17 @@ SWITCH_DECLARE(switch_status_t) switch_event_add_header_string(switch_event_t *e
        return SWITCH_STATUS_GENERR;
 }
 
+SWITCH_DECLARE(switch_status_t) switch_event_set_body(switch_event_t *event, const char *body)
+{
+       switch_safe_free(event->body);
+
+       if (body) {
+               event->body = DUP(body);
+       }
+       
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_event_add_body(switch_event_t *event, const char *fmt, ...)
 {
        int ret = 0;
@@ -1228,6 +1275,64 @@ SWITCH_DECLARE(switch_status_t) switch_event_dup(switch_event_t **event, switch_
        return SWITCH_STATUS_SUCCESS;
 }
 
+
+SWITCH_DECLARE(switch_status_t) switch_event_dup_reply(switch_event_t **event, switch_event_t *todup)
+{
+       switch_event_header_t *hp;
+       char hname[1024] = "";
+       char *p;
+
+       if (switch_event_create_subclass(event, SWITCH_EVENT_CLONE, todup->subclass_name) != SWITCH_STATUS_SUCCESS) {
+               return SWITCH_STATUS_GENERR;
+       }
+
+       (*event)->event_id = todup->event_id;
+       (*event)->event_user_data = todup->event_user_data;
+       (*event)->bind_user_data = todup->bind_user_data;
+       (*event)->flags = todup->flags;
+
+       for (hp = todup->headers; hp; hp = hp->next) {
+               char *name = hp->name, *value = hp->value;
+               
+               if (todup->subclass_name && !strcmp(hp->name, "Event-Subclass")) {
+                       continue;
+               }
+               
+               if (!strncasecmp(hp->name, "from_", 5)) {
+                       p = hp->name + 5;
+                       switch_snprintf(hname, sizeof(hname), "to_%s", p);
+                       name = hname;
+               } else if (!strncasecmp(hp->name, "to_", 3)) {
+                       p = hp->name + 3;
+                       switch_snprintf(hname, sizeof(hname), "from_%s", p);
+                       name = hname;
+               } else if (!strcasecmp(name, "to")) {
+                       name = "from";
+               } else if (!strcasecmp(name, "from")) {
+                       name = "to";
+               }
+               
+               if (hp->idx) {
+                       int i;
+                       for (i = 0; i < hp->idx; i++) {
+                               switch_event_add_header_string(*event, SWITCH_STACK_PUSH, name, hp->array[i]);
+                       }
+               } else {
+                       switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, name, value);
+               }
+       }
+
+       switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "replying", "true");
+
+       if (todup->body) {
+               switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "orig_body", todup->body);
+       }
+
+       (*event)->key = todup->key;
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 SWITCH_DECLARE(switch_status_t) switch_event_serialize(switch_event_t *event, char **str, switch_bool_t encode)
 {
        switch_size_t len = 0;
index 45b582b7157b428413121a33db3ab8f3a3f77431..e0aa689e5c81a7e5ddacd8a6b55c1baa22f861ab 100644 (file)
@@ -3102,6 +3102,19 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_insert_file(switch_core_session_t *se
 }
 
 
+SWITCH_DECLARE(switch_status_t) switch_ivr_create_message_reply(switch_event_t **reply, switch_event_t *message, const char *new_proto)
+{
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
+
+       if ((status = switch_event_dup_reply(reply, message) != SWITCH_STATUS_SUCCESS)) {
+               abort();
+       }
+
+       switch_event_add_header_string(*reply, SWITCH_STACK_BOTTOM, "proto", new_proto);
+
+       return status;
+}
+
 
 /* For Emacs:
  * Local Variables:
index 63688638723005b15c94aef8ad421942575946e6..c288571b191480bc39b0f9ca07eeb0c6328e3126 100644 (file)
@@ -63,6 +63,7 @@ struct switch_loadable_module_container {
        switch_hash_t *dialplan_hash;
        switch_hash_t *timer_hash;
        switch_hash_t *application_hash;
+       switch_hash_t *chat_application_hash;
        switch_hash_t *api_hash;
        switch_hash_t *file_hash;
        switch_hash_t *speech_hash;
@@ -265,6 +266,28 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
                }
        }
 
+       if (new_module->module_interface->chat_application_interface) {
+               const switch_chat_application_interface_t *ptr;
+
+               for (ptr = new_module->module_interface->chat_application_interface; ptr; ptr = ptr->next) {
+                       if (!ptr->interface_name) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to load application interface from %s due to no interface name.\n", key);
+                       } else {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Chat Application '%s'\n", ptr->interface_name);
+                               if (switch_event_create(&event, SWITCH_EVENT_MODULE_LOAD) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "application");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "description", switch_str_nil(ptr->short_desc));
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "syntax", switch_str_nil(ptr->syntax));
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "key", new_module->key);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "filename", new_module->filename);
+                                       switch_event_fire(&event);
+                               }
+                               switch_core_hash_insert(loadable_modules.chat_application_hash, ptr->interface_name, (const void *) ptr);
+                       }
+               }
+       }
+
        if (new_module->module_interface->api_interface) {
                const switch_api_interface_t *ptr;
 
@@ -468,36 +491,22 @@ static switch_status_t switch_loadable_module_process(char *key, switch_loadable
 
 }
 
-SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to,
-                                                                                                                  const char *subject, const char *body, const char *type, const char *hint)
-{
-       switch_event_t *message_event;
-       switch_status_t status;
+#define CHAT_MAX_MSG_QUEUE 101
+#define CHAT_QUEUE_SIZE 5000
 
-       if (switch_event_create(&message_event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "proto", proto);
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "from", from);
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "to", to);
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject);
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type);
-               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint);
-               
-               if (body) {
-                       switch_event_add_body(message_event, "%s", body);
-               }
-       } else {
-               abort();
-       }       
-
-       status = switch_core_chat_send(dest_proto, message_event);
+static struct {
+       switch_queue_t *msg_queue[CHAT_MAX_MSG_QUEUE];
+       switch_thread_t *msg_queue_thread[CHAT_MAX_MSG_QUEUE];
+       int msg_queue_len;
+       switch_mutex_t *mutex;
+       switch_memory_pool_t *pool;
+       int running;
+} chat_globals;
 
-       switch_event_destroy(&message_event);
+static int IDX = 0;
 
-       return status;
-       
-}
 
-SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event)
+static switch_status_t do_chat_send(switch_event_t *message_event)
 
 {
        switch_chat_interface_t *ci;
@@ -505,9 +514,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, sw
        switch_hash_index_t *hi;
        const void *var;
        void *val;
+       const char *proto;
+       const char *replying;
+       const char *dest_proto;
+       int do_skip = 0;
 
        /*
-       const char *proto;
+
        const char *from; 
        const char *to;
        const char *subject;
@@ -516,12 +529,16 @@ SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, sw
        const char *hint;
        */              
 
+
+
+       dest_proto = switch_event_get_header(message_event, "dest_proto");
+
        if (!dest_proto) {
                return SWITCH_STATUS_FALSE;
        }
 
        /*
-       proto = switch_event_get_header(message_event, "proto");
+
        from = switch_event_get_header(message_event, "from");
        to = switch_event_get_header(message_event, "to");
        subject = switch_event_get_header(message_event, "subject");
@@ -530,23 +547,33 @@ SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, sw
        hint = switch_event_get_header(message_event, "hint");
        */
 
-
-       if (!strcasecmp(dest_proto, "GLOBAL")) {
+       proto = switch_event_get_header(message_event, "proto");
+       replying = switch_event_get_header(message_event, "replying");
+       
+       if (!switch_true(replying) && !switch_stristr("global", proto)) {
                switch_mutex_lock(loadable_modules.mutex);
                for (hi = switch_hash_first(NULL, loadable_modules.chat_hash); hi; hi = switch_hash_next(hi)) {
                        switch_hash_this(hi, &var, NULL, &val);
                        
                        if ((ci = (switch_chat_interface_t *) val)) {
                                if (ci->chat_send && !strncasecmp(ci->interface_name, "GLOBAL_", 7)) {
-                                       if ((status = ci->chat_send(message_event)) != SWITCH_STATUS_SUCCESS) {
+                                       status = ci->chat_send(message_event);
+
+                                       if (status == SWITCH_STATUS_BREAK) {
+                                               do_skip = 1;
+                                       }
+                                       
+                                       if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Chat Interface Error [%s]!\n", dest_proto);
                                                break;
-                                       }                       
+                                       }
                                }
                        }
                }
                switch_mutex_unlock(loadable_modules.mutex);
-       } else {
+       }
+       
+       if (!do_skip && !switch_stristr("GLOBAL", dest_proto)) {
                if (!(ci = switch_loadable_module_get_chat_interface(dest_proto)) || !ci->chat_send) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid chat interface [%s]!\n", dest_proto);
                        return SWITCH_STATUS_FALSE;
@@ -558,6 +585,205 @@ SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, sw
        return status;
 }
 
+static void chat_process_event(switch_event_t **eventp)
+{
+       switch_event_t *event;
+
+       switch_assert(eventp);
+
+       event = *eventp;
+       *eventp = NULL;
+
+       do_chat_send(event);
+       switch_event_destroy(&event);
+}
+
+
+void *SWITCH_THREAD_FUNC chat_thread_run(switch_thread_t *thread, void *obj)
+{
+       void *pop;
+       switch_queue_t *q = (switch_queue_t *) obj;
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Chat Thread Started\n");
+
+
+       while(switch_queue_pop(q, &pop) == SWITCH_STATUS_SUCCESS && pop) {
+               switch_event_t *event = (switch_event_t *) pop;
+               chat_process_event(&event);
+               switch_cond_next();
+       }
+
+       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Chat Thread Ended\n");
+
+       return NULL;    
+}
+
+
+static void chat_thread_start(int idx)
+{
+
+       if (idx >= CHAT_MAX_MSG_QUEUE || (idx < chat_globals.msg_queue_len && chat_globals.msg_queue_thread[idx])) {
+               return;
+       }
+
+       switch_mutex_lock(chat_globals.mutex);
+       
+       if (idx >= chat_globals.msg_queue_len) {
+               int i;
+               chat_globals.msg_queue_len = idx + 1;
+
+               for (i = 0; i < chat_globals.msg_queue_len; i++) {
+                       if (!chat_globals.msg_queue[i]) {
+                               switch_threadattr_t *thd_attr = NULL;
+
+                               switch_queue_create(&chat_globals.msg_queue[i], CHAT_QUEUE_SIZE, chat_globals.pool);
+
+                               switch_threadattr_create(&thd_attr, chat_globals.pool);
+                               switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+                               //switch_threadattr_priority_increase(thd_attr);
+                               switch_thread_create(&chat_globals.msg_queue_thread[i], 
+                                                                        thd_attr, 
+                                                                        chat_thread_run, 
+                                                                        chat_globals.msg_queue[i], 
+                                                                        chat_globals.pool);
+                       }
+               }
+       }
+
+       switch_mutex_unlock(chat_globals.mutex);
+}
+
+
+static void chat_queue_message(switch_event_t **eventp)
+{
+       int idx = 0;
+       switch_event_t *event;
+
+       switch_assert(eventp);
+
+       event = *eventp;
+       *eventp = NULL;
+       
+       if (chat_globals.running == 0) {
+               chat_process_event(&event);
+               return;
+       }
+
+ again:
+
+       switch_mutex_lock(chat_globals.mutex);
+       idx = IDX;
+       IDX++; 
+       if (IDX >= chat_globals.msg_queue_len) IDX = 0;
+       switch_mutex_unlock(chat_globals.mutex);
+       
+       chat_thread_start(idx);
+
+       if (switch_queue_trypush(chat_globals.msg_queue[idx], event) != SWITCH_STATUS_SUCCESS) {
+               if (chat_globals.msg_queue_len < CHAT_MAX_MSG_QUEUE) {
+                       chat_thread_start(idx + 1);
+                       goto again;
+               } else {
+                       switch_queue_push(chat_globals.msg_queue[idx], event);
+               }
+       }
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_execute_chat_app(switch_event_t *message, const char *app, const char *data)
+{
+       switch_chat_application_interface_t *cai;
+       switch_status_t status = SWITCH_STATUS_SUCCESS;
+       char *expanded;
+
+       if (!(cai = switch_loadable_module_get_chat_application_interface(app)) || !cai->chat_application_function) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid chat application interface [%s]!\n", app);
+               return SWITCH_STATUS_FALSE;
+       }
+
+       if (switch_test_flag(message, EF_NO_CHAT_EXEC)) {
+               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Message is not allowed to execute apps\n");
+               switch_goto_status(SWITCH_STATUS_FALSE, end);
+       }
+
+       expanded = switch_event_expand_headers(message, data);
+       
+       status = cai->chat_application_function(message, expanded);
+
+       if (expanded != data) {
+               free(expanded);
+       }
+
+ end:
+
+       UNPROTECT_INTERFACE(cai);
+
+       return status;
+
+}
+
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_chat_send_args(const char *dest_proto, const char *proto, const char *from, const char *to,
+                                                                                                                  const char *subject, const char *body, const char *type, const char *hint)
+{
+       switch_event_t *message_event;
+       switch_status_t status;
+
+       if (switch_event_create(&message_event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "proto", proto);
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "from", from);
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "to", to);
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject);
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type);
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint);
+               
+               if (body) {
+                       switch_event_add_body(message_event, "%s", body);
+               }
+       } else {
+               abort();
+       }       
+
+       if (dest_proto) {
+               switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "dest_proto", dest_proto);
+       }
+
+       chat_queue_message(&message_event);
+       status = SWITCH_STATUS_SUCCESS;
+
+       return status;
+       
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *dest_proto, switch_event_t *message_event)
+{
+       switch_event_t *dup;
+
+       switch_event_dup(&dup, message_event);
+
+       if (dest_proto) {
+               switch_event_add_header_string(dup, SWITCH_STACK_BOTTOM, "dest_proto", dest_proto);
+       }
+
+       chat_queue_message(&dup);
+       return SWITCH_STATUS_SUCCESS;
+}
+
+
+SWITCH_DECLARE(switch_status_t) switch_core_chat_deliver(const char *dest_proto, switch_event_t **message_event)
+{
+
+       if (dest_proto) {
+               switch_event_add_header_string(*message_event, SWITCH_STACK_BOTTOM, "dest_proto", dest_proto);
+       }
+
+       chat_queue_message(message_event);
+
+       return SWITCH_STATUS_SUCCESS;
+}
+
 
 static switch_status_t switch_loadable_module_unprocess(switch_loadable_module_t *old_module)
 {
@@ -684,6 +910,32 @@ static switch_status_t switch_loadable_module_unprocess(switch_loadable_module_t
                }
        }
 
+       if (old_module->module_interface->chat_application_interface) {
+               const switch_chat_application_interface_t *ptr;
+               for (ptr = old_module->module_interface->chat_application_interface; ptr; ptr = ptr->next) {
+                       if (ptr->interface_name) {
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting Application '%s'\n", ptr->interface_name);
+                               switch_core_session_hupall_matching_var(SWITCH_CURRENT_APPLICATION_VARIABLE, ptr->interface_name, SWITCH_CAUSE_MANAGER_REQUEST);
+                               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+                               if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
+                                       switch_thread_rwlock_unlock(ptr->rwlock);
+                               } else {
+                                       switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up on '%s' waiting for existing references.\n", ptr->interface_name);
+                               }
+
+                               if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "application");
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name);
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "description", switch_str_nil(ptr->short_desc));
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "syntax", switch_str_nil(ptr->syntax));
+                                       switch_event_fire(&event);
+                               }
+                               switch_core_hash_delete(loadable_modules.chat_application_hash, ptr->interface_name);
+                       }
+               }
+       }
+
        if (old_module->module_interface->api_interface) {
                const switch_api_interface_t *ptr;
 
@@ -1355,6 +1607,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(switch_bool_t autolo
        switch_core_hash_init_nocase(&loadable_modules.codec_hash, loadable_modules.pool);
        switch_core_hash_init_nocase(&loadable_modules.timer_hash, loadable_modules.pool);
        switch_core_hash_init_nocase(&loadable_modules.application_hash, loadable_modules.pool);
+       switch_core_hash_init_nocase(&loadable_modules.chat_application_hash, loadable_modules.pool);
        switch_core_hash_init_nocase(&loadable_modules.api_hash, loadable_modules.pool);
        switch_core_hash_init(&loadable_modules.file_hash, loadable_modules.pool);
        switch_core_hash_init_nocase(&loadable_modules.speech_hash, loadable_modules.pool);
@@ -1470,6 +1723,13 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_init(switch_bool_t autolo
 
        switch_loadable_module_runtime();
 
+       chat_globals.running = 1;
+       memset(&chat_globals, 0, sizeof(chat_globals));
+       chat_globals.pool = loadable_modules.pool;
+       switch_mutex_init(&chat_globals.mutex, SWITCH_MUTEX_NESTED, chat_globals.pool);
+
+       chat_thread_start(1);
+
        return SWITCH_STATUS_SUCCESS;
 }
 
@@ -1529,11 +1789,24 @@ SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
        switch_hash_index_t *hi;
        void *val;
        switch_loadable_module_t *module;
+       int i;
 
        if (!loadable_modules.module_hash) {
                return;
        }
 
+       chat_globals.running = 0;
+
+       for (i = 0; i < chat_globals.msg_queue_len; i++) {      
+               switch_queue_push(chat_globals.msg_queue[i], NULL);
+       }
+
+       for (i = 0; i < chat_globals.msg_queue_len; i++) {
+               switch_status_t st;
+               switch_thread_join(&st, chat_globals.msg_queue_thread[i]);
+       }
+
+
        for (hi = switch_hash_first(NULL, loadable_modules.module_hash); hi; hi = switch_hash_next(hi)) {
                switch_hash_this(hi, NULL, NULL, &val);
                module = (switch_loadable_module_t *) val;
@@ -1557,6 +1830,7 @@ SWITCH_DECLARE(void) switch_loadable_module_shutdown(void)
        switch_core_hash_destroy(&loadable_modules.codec_hash);
        switch_core_hash_destroy(&loadable_modules.timer_hash);
        switch_core_hash_destroy(&loadable_modules.application_hash);
+       switch_core_hash_destroy(&loadable_modules.chat_application_hash);
        switch_core_hash_destroy(&loadable_modules.api_hash);
        switch_core_hash_destroy(&loadable_modules.file_hash);
        switch_core_hash_destroy(&loadable_modules.speech_hash);
@@ -1625,6 +1899,7 @@ SWITCH_DECLARE(switch_codec_interface_t *) switch_loadable_module_get_codec_inte
 HASH_FUNC(dialplan)
 HASH_FUNC(timer)
 HASH_FUNC(application)
+HASH_FUNC(chat_application)
 HASH_FUNC(api)
 HASH_FUNC(file)
 HASH_FUNC(speech)
@@ -1978,6 +2253,9 @@ SWITCH_DECLARE(void *) switch_loadable_module_create_interface(switch_loadable_m
        case SWITCH_APPLICATION_INTERFACE:
                ALLOC_INTERFACE(application)
 
+       case SWITCH_CHAT_APPLICATION_INTERFACE:
+               ALLOC_INTERFACE(chat_application)
+
        case SWITCH_API_INTERFACE:
                ALLOC_INTERFACE(api)
 
index e6aa375077acb8c8a69e8643ad184b3638b45931..58be38cb6c35dda802eb826a7423f146de1e0139 100644 (file)
@@ -256,6 +256,13 @@ SWITCH_DECLARE_NONSTD(void) switch_regex_set_var_callback(const char *var, const
        switch_channel_add_variable_var_check(channel, var, val, SWITCH_FALSE, SWITCH_STACK_PUSH);
 }
 
+SWITCH_DECLARE_NONSTD(void) switch_regex_set_event_header_callback(const char *var, const char *val, void *user_data)
+{
+
+       switch_event_t *event = (switch_event_t *) user_data;
+       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val);
+}
+
 
 
 /* For Emacs:
index f5880f18a5a0652854b89a53c23020148b568898..d4d7c3f12dd02d50bf4916479d1cc34f52e3e51a 100644 (file)
@@ -160,6 +160,7 @@ static struct xml_section_t SECTIONS[] = {
        {"directory", SWITCH_XML_SECTION_DIRECTORY},
        {"dialplan", SWITCH_XML_SECTION_DIALPLAN},
        {"phrases", SWITCH_XML_SECTION_PHRASES},
+       {"chatplan", SWITCH_XML_SECTION_CHATPLAN},
        {NULL, 0}
 };