From 4101e6b2b7ecad3c8fdb70b59d59a61856b6abb7 Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Sun, 13 May 2012 18:27:51 +0200 Subject: [PATCH] gsmopen: mod_sms tweak --- src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp | 37 +++++++++++++++++-- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp index d75dd5e6c4..d1443afc50 100644 --- a/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp +++ b/src/mod/endpoints/mod_gsmopen/mod_gsmopen.cpp @@ -2978,6 +2978,7 @@ int sms_incoming(private_t *tech_pvt) DEBUGA_GSMOPEN("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s|\n", GSMOPEN_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender, tech_pvt->sms_body); +#ifdef NOTDEF if (!zstr(tech_pvt->session_uuid_str)) { session = switch_core_session_locate(tech_pvt->session_uuid_str); } @@ -2993,7 +2994,6 @@ int sms_incoming(private_t *tech_pvt) //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); -/* mod_sms begin */ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", GSMOPEN_CHAT_PROTO); @@ -3002,10 +3002,7 @@ int sms_incoming(private_t *tech_pvt) //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); -/* mod_sms end */ switch_event_add_body(event, "%s\n", tech_pvt->sms_body); - //switch_core_chat_send(GSMOPEN_CHAT_PROTO, event); /* mod_sms */ - switch_core_chat_send("GLOBAL", event); /* mod_sms */ if (session) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true"); if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) { @@ -3052,6 +3049,38 @@ int sms_incoming(private_t *tech_pvt) if (session) { switch_core_session_rwunlock(session); } +#endif //NOTDEF + /* mod_sms begin */ + if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", GSMOPEN_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->sms_sender); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "date", tech_pvt->sms_date); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "datacodingscheme", tech_pvt->sms_datacodingscheme); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "servicecentreaddress", tech_pvt->sms_servicecentreaddress); + switch_event_add_header(event, SWITCH_STACK_BOTTOM, "messagetype", "%d", tech_pvt->sms_messagetype); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", GSMOPEN_CHAT_PROTO); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->sms_sender); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); + //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); + switch_event_add_body(event, "%s\n", tech_pvt->sms_body); + //switch_core_chat_send("GLOBAL", event); /* mod_sms */ + switch_core_chat_send("GLOBAL", event); /* mod_sms */ + } else { + + ERRORA("cannot create event on interface %s. WHY?????\n", GSMOPEN_P_LOG, tech_pvt->name); + } + /* mod_sms end */ + + //memset(&tech_pvt->chatmessages[which], '\0', sizeof(&tech_pvt->chatmessages[which]) ); //memset(tech_pvt->sms_message, '\0', sizeof(tech_pvt->sms_message)); return 0;