From 6cf606f2a07171347b5a5dc6da323af6ca36a30c Mon Sep 17 00:00:00 2001 From: Seven Du Date: Sun, 3 May 2020 17:53:42 +0800 Subject: [PATCH] [core] add event::merge --- src/include/switch_cpp.h | 1 + src/switch_cpp.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 21126ea571..5fd21fc55b 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -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); }; diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index f51d2c1fb8..c412f2b7dc 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -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) {