]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
[core] add event::merge 996/head
authorSeven Du <dujinfang@x-y-t.cn>
Sun, 3 May 2020 09:53:42 +0000 (17:53 +0800)
committerSeven Du <dujinfang@x-y-t.cn>
Wed, 16 Dec 2020 15:05:16 +0000 (23:05 +0800)
src/include/switch_cpp.h
src/switch_cpp.cpp

index 21126ea571c175fb0f5f116d7b4834bbc8896648..5fd21fc55b251bc93290dec2d68f98c496af94d8 100644 (file)
@@ -176,6 +176,7 @@ SWITCH_DECLARE(bool) email(char *to, char *from, char *headers = NULL, char *bod
                 SWITCH_DECLARE(bool) addHeader(const char *header_name, const char *value);
                 SWITCH_DECLARE(bool) delHeader(const char *header_name);
                 SWITCH_DECLARE(bool) fire(void);
+                SWITCH_DECLARE(bool) merge(Event *to_merge);
 
         };
 
index f51d2c1fb875a3619431af459f529dde0ccfe1cf..c412f2b7dcbcf3e7e1c00623907f7cc375abb51a 100644 (file)
@@ -520,6 +520,24 @@ SWITCH_DECLARE(const char *)Event::getType(void)
        return (char *) "invalid";
 }
 
+SWITCH_DECLARE(bool)Event::merge(Event *to_merge)
+{
+       this_check(false);
+
+       if (!event) {
+               switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to merge to an event that does not exist!\n");
+               return false;
+       }
+
+       if (!to_merge || !to_merge->event) {
+               switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "Trying to merge from an event that does not exist!\n");
+               return false;
+       }
+
+       switch_event_merge(event, to_merge->event);
+
+       return true;
+}
 
 SWITCH_DECLARE_CONSTRUCTOR DTMF::DTMF(char idigit, uint32_t iduration)
 {