]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add fire-message-events profile param
authorAnthony Minessale <anthm@freeswitch.org>
Wed, 29 Aug 2012 20:34:17 +0000 (15:34 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Wed, 29 Aug 2012 20:34:17 +0000 (15:34 -0500)
src/mod/endpoints/mod_sofia/mod_sofia.h
src/mod/endpoints/mod_sofia/sofia.c
src/mod/endpoints/mod_sofia/sofia_presence.c

index ecbf36d7a4c57866ac4bd20a54721ecf0acb0918..817ea8506320d7d1b9d472c6ed1cef7a98b31349 100644 (file)
@@ -271,6 +271,7 @@ typedef enum {
        PFLAG_CONFIRM_BLIND_TRANSFER,
        PFLAG_THREAD_PER_REG,
        PFLAG_MWI_USE_REG_CALLID,
+       PFLAG_FIRE_MESSAGE_EVENTS,
        /* No new flags below this line */
        PFLAG_MAX
 } PFLAGS;
index 85162d61b9b623b7fbef3db6e8bb884f0a1b110b..582f4c0bdfcd25a87a82ec2fe9ca21848fd55de3 100644 (file)
@@ -3410,6 +3410,12 @@ switch_status_t reconfig_sofia(sofia_profile_t *profile)
                                                } else {
                                                        sofia_clear_pflag(profile, PFLAG_IN_DIALOG_CHAT);
                                                }
+                                       } else if (!strcasecmp(var, "fire-message-events")) {
+                                               if (switch_true(val)) {
+                                                       sofia_set_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS);
+                                               } else {
+                                                       sofia_clear_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS);
+                                               }
                                        } else if (!strcasecmp(var, "disable-hold")) {
                                                if (switch_true(val)) {
                                                        sofia_set_pflag(profile, PFLAG_DISABLE_HOLD);
@@ -4336,6 +4342,12 @@ switch_status_t config_sofia(int reload, char *profile_name)
                                                } else {
                                                        sofia_clear_pflag(profile, PFLAG_IN_DIALOG_CHAT);
                                                }
+                                       } else if (!strcasecmp(var, "fire-message-events")) {
+                                               if (switch_true(val)) {
+                                                       sofia_set_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS);
+                                               } else {
+                                                       sofia_clear_pflag(profile, PFLAG_FIRE_MESSAGE_EVENTS);
+                                               }
                                        } else if (!strcasecmp(var, "t38-passthru")) {
                                                if (switch_true(val)) {
                                                        sofia_set_pflag(profile, PFLAG_T38_PASSTHRU);
index 3f07d1c64206adfb805b43bf33fe0b5ac19dc3d1..cc9e054258a5be1ba338466b2a759f0eebfbfcd0 100644 (file)
@@ -4349,7 +4349,7 @@ void sofia_presence_handle_sip_i_message(int status,
                if (nh) {
                        char hash_key[512];
                        private_object_t *tech_pvt;
-                       switch_event_t *event;
+                       switch_event_t *event, *event_dup;
                        char *to_addr;
                        char *from_addr;
                        char *p;
@@ -4379,6 +4379,8 @@ void sofia_presence_handle_sip_i_message(int status,
                        }
 
                        if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) {
+                               event->flags |= EF_UNIQ_HEADERS;
+
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", profile->url);
                                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
 
@@ -4407,6 +4409,14 @@ void sofia_presence_handle_sip_i_message(int status,
                                if (msg) {
                                        switch_event_add_body(event, "%s", msg);
                                }
+
+                               if (switch_event_dup(&event_dup, event) == SWITCH_STATUS_SUCCESS) {
+                                       event_dup->event_id = SWITCH_EVENT_RECV_MESSAGE;
+                                       switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Event-Name", switch_event_name(event->event_id));
+                                       switch_event_fire(&event_dup);
+                               }
+
+
                        } else {
                                abort();
                        }