<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14995] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14995">14995</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-09-26 17:54:11 -0500 (Sat, 26 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>celliax: incoming SMS now generates a correct event, with additional headers: proto, login, from, date, subject, during-call and a body containing the SMS body. Only the raw fields that are in ucs2 are decoded to utf8 (eg: sender and body)</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliaxh">freeswitch/branches/gmaruzz/mod_celliax/celliax.h</a></li>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc">freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c</a></li>
<li><a href="#freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc">freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax.h (14994 => 14995)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-09-26 19:36:58 UTC (rev 14994)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax.h        2009-09-26 22:54:11 UTC (rev 14995)
</span><span class="lines">@@ -398,6 +398,9 @@
</span><span class="cx">         int unread_sms_msg_id;
</span><span class="cx">         int reading_sms_msg;
</span><span class="cx">         char sms_message[4800];
</span><ins>+        char sms_sender[256];
+        char sms_date[256];
+        char sms_body[4800];
</ins><span class="cx">         int sms_cnmi_not_supported;
</span><span class="cx">         char sms_receiving_program[256];
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxcelliax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c (14994 => 14995)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-09-26 19:36:58 UTC (rev 14994)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c        2009-09-26 22:54:11 UTC (rev 14995)
</span><span class="lines">@@ -927,7 +927,7 @@
</span><span class="cx">                                                                 char *arg1[] = { tech_pvt->sms_receiving_program, (char *) NULL };
</span><span class="cx">                                                                 int i;
</span><span class="cx">
</span><del>-                                                                NOTICA("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, tech_pvt->sms_message);
</del><ins>+                                                                DEBUGA_CELLIAX("incoming SMS message:>>>%s<<<\n", CELLIAX_P_LOG, tech_pvt->sms_message);
</ins><span class="cx">                                                                 res=pipe(fd1);
</span><span class="cx">                                                                 pid1 = fork();
</span><span class="cx">
</span><span class="lines">@@ -1321,7 +1321,7 @@
</span><span class="cx">                         if (tech_pvt->reading_sms_msg > 1 && at_ack == -1) {
</span><span class="cx">                                 int c;
</span><span class="cx">                                 char sms_body[16000];
</span><del>-                                int err;
</del><ins>+                                int err=0;
</ins><span class="cx">
</span><span class="cx">                                 if (strncmp(tech_pvt->line_array.result[i], "+CMGR", 5) == 0) {        /* we are reading the "header" of an SMS */
</span><span class="cx">                                         char content[512];
</span><span class="lines">@@ -1331,6 +1331,7 @@
</span><span class="cx">
</span><span class="cx">                                         int inside_comma = 0;
</span><span class="cx">                                         int inside_quote = 0;
</span><ins>+                                        int which_field = 0;
</ins><span class="cx">                                         int d = 0;
</span><span class="cx">
</span><span class="cx">                                         for (c = 0; c < strlen(tech_pvt->line_array.result[i]); c++) {
</span><span class="lines">@@ -1347,14 +1348,19 @@
</span><span class="cx">                                                         if (inside_quote) {
</span><span class="cx">                                                                 inside_quote = 0;
</span><span class="cx">                                                                 //ERRORA("END_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", CELLIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
</span><del>-                                                                DEBUGA_CELLIAX("content=%s\n", CELLIAX_P_LOG, content);
</del><ins>+                                                                DEBUGA_CELLIAX("%d content=%s\n", CELLIAX_P_LOG, which_field, content);
</ins><span class="cx">
</span><span class="cx">                                                                 strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                                                 strncat(tech_pvt->sms_message, content, ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                                                 strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">
</span><span class="cx">                                                                 memset(content2, '\0', sizeof(content2));
</span><del>-                                                                err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
</del><ins>+                                                                if(which_field==1){
+                                                                        err = ucs2_to_utf8(tech_pvt, content, content2, sizeof(content2));
+                                                                } else {
+                                                                        err=0;
+                                                                        strncpy(content2, content, sizeof(content2));
+                                                                }
</ins><span class="cx">
</span><span class="cx">                                                                 strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                                                 if (!err)
</span><span class="lines">@@ -1362,6 +1368,15 @@
</span><span class="cx">                                                                 strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                                                 memset(content, '\0', sizeof(content));
</span><span class="cx">                                                                 d = 0;
</span><ins>+                                                                if(which_field==1){
+                                                                        strncpy(tech_pvt->sms_sender, content2, sizeof(tech_pvt->sms_sender));
+
+                                                                } else if(which_field==2){
+                                                                        strncpy(tech_pvt->sms_date, content2, sizeof(tech_pvt->sms_date));
+                                                                } else if(which_field > 2){
+                                                                WARNINGA("WHY which_field is > 2 ? (which_field is %d)\n", CELLIAX_P_LOG, which_field);
+                                                                }
+                                                                which_field++;
</ins><span class="cx">                                                         } else {
</span><span class="cx">                                                                 inside_quote = 1;
</span><span class="cx">                                                                 //WARNINGA("START_CONTENT inside_comma=%d, inside_quote=%d, we're at=%s\n", CELLIAX_P_LOG, inside_comma, inside_quote, &tech_pvt->line_array.result[i][c]);
</span><span class="lines">@@ -1377,12 +1392,15 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }                                //it was the +CMGR answer from the cellphone
</span><span class="cx">                                 else {
</span><ins>+                                        DEBUGA_CELLIAX("body=%s\n", CELLIAX_P_LOG, sms_body);
</ins><span class="cx">                                         strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                         strncat(tech_pvt->sms_message, tech_pvt->line_array.result[i], ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                         strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">
</span><span class="cx">                                         memset(sms_body, '\0', sizeof(sms_body));
</span><span class="cx">                                         err = ucs2_to_utf8(tech_pvt, tech_pvt->line_array.result[i], sms_body, sizeof(sms_body));
</span><ins>+                                        DEBUGA_CELLIAX("body=%s\n", CELLIAX_P_LOG, sms_body);
+                                        strncpy(tech_pvt->sms_body, sms_body, sizeof(tech_pvt->sms_body));
</ins><span class="cx">
</span><span class="cx">                                         strncat(tech_pvt->sms_message, "---", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">                                         if (!err)
</span><span class="lines">@@ -1390,7 +1408,6 @@
</span><span class="cx">                                         strncat(tech_pvt->sms_message, "|||", ((sizeof(tech_pvt->sms_message) - strlen(tech_pvt->sms_message)) - 1));
</span><span class="cx">
</span><span class="cx">                                         DEBUGA_CELLIAX("sms_message=%s\n", CELLIAX_P_LOG, tech_pvt->sms_message);
</span><del>-
</del><span class="cx">                                 }                                //it was the UCS2 from cellphone
</span><span class="cx">
</span><span class="cx">                         }                                        //we were reading the SMS
</span></span></pre></div>
<a id="freeswitchbranchesgmaruzzmod_celliaxmod_celliaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14994 => 14995)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-09-26 19:36:58 UTC (rev 14994)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c        2009-09-26 22:54:11 UTC (rev 14995)
</span><span class="lines">@@ -2333,7 +2333,8 @@
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="cx">         int event_sent_to_esl = 0;
</span><span class="cx">
</span><del>-        DEBUGA_CELLIAX("received SMS on interface %s\n", CELLIAX_P_LOG, tech_pvt->name);
</del><ins>+        DEBUGA_CELLIAX("received SMS on interface %s: %s\n", CELLIAX_P_LOG, tech_pvt->name, tech_pvt->sms_message);
+        DEBUGA_CELLIAX("received SMS on interface %s: DATE=%s, SENDER=%s, BODY=%s\n", CELLIAX_P_LOG, tech_pvt->name, tech_pvt->sms_date, tech_pvt->sms_sender, tech_pvt->sms_body);
</ins><span class="cx">
</span><span class="cx">         if (!switch_strlen_zero(tech_pvt->session_uuid_str)) {
</span><span class="cx">                 session = switch_core_session_locate(tech_pvt->session_uuid_str);
</span><span class="lines">@@ -2342,11 +2343,12 @@
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", MDL_CHAT_PROTO);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name);
</span><span class="cx">                 //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
</span><del>-                switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", "333444555"); //FIXME
</del><ins>+                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);
</ins><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
</span><span class="cx">                 //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
</span><span class="cx">                 //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
</span><del>-                switch_event_add_body(event, "%s", tech_pvt->sms_message);
</del><ins>+                switch_event_add_body(event, "%s", tech_pvt->sms_body);
</ins><span class="cx">                 if(session){
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
</span><span class="cx">                         if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -2370,10 +2372,12 @@
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name);
</span><span class="cx">                         //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname);
</span><span class="cx">                         //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle);
</span><ins>+                        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);
</ins><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE");
</span><span class="cx">                         //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname);
</span><span class="cx">                         //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id);
</span><del>-                        switch_event_add_body(event, "%s", tech_pvt->sms_message);
</del><ins>+                        switch_event_add_body(event, "%s", tech_pvt->sms_body);
</ins><span class="cx">                         if(session){
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true");
</span><span class="cx">                         } else { //no session
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>