<!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][14857] </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=14857">14857</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-09-14 17:13:00 -0500 (Mon, 14 Sep 2009)</dd>
</dl>
<h3>Log Message</h3>
<pre>skypiax: added skypiax_chat command. SYNTAX: skypiax_chat interface remote_skypename TEXT</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14856 => 14857)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-09-14 22:03:37 UTC (rev 14856)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-09-14 22:13:00 UTC (rev 14857)
</span><span class="lines">@@ -91,6 +91,8 @@
</span><span class="cx"> SWITCH_STANDARD_API(skypiax_function);
</span><span class="cx"> #define SKYPIAX_SYNTAX "interface_name skype_API_msg"
</span><span class="cx">
</span><ins>+SWITCH_STANDARD_API(skypiax_chat_function);
+#define SKYPIAX_CHAT_SYNTAX "interface_name remote_skypename TEXT"
</ins><span class="cx"> /* BEGIN: Changes here */
</span><span class="cx"> #define FULL_RELOAD 0
</span><span class="cx"> #define SOFT_RELOAD 1
</span><span class="lines">@@ -1425,6 +1427,7 @@
</span><span class="cx">
</span><span class="cx">                 SWITCH_ADD_API(commands_api_interface, "sk", "Skypiax console commands", sk_function, SK_SYNTAX);
</span><span class="cx">                 SWITCH_ADD_API(commands_api_interface, "skypiax", "Skypiax interface commands", skypiax_function, SKYPIAX_SYNTAX);
</span><ins>+                SWITCH_ADD_API(commands_api_interface, "skypiax_chat", "Skypiax_chat interface remote_skypename TEXT", skypiax_chat_function, SKYPIAX_CHAT_SYNTAX);
</ins><span class="cx">
</span><span class="cx">                 /* indicate that the module should continue to be loaded */
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1904,7 +1907,86 @@
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><ins>+SWITCH_STANDARD_API(skypiax_chat_function)
+{
+        char *mycmd = NULL, *argv[10] = { 0 };
+        int argc = 0;
+        private_t *tech_pvt = NULL;
+        int tried =0;
+        int i;
+        int found = 0;
+        char skype_msg[1024];
</ins><span class="cx">
</span><ins>+        if (!switch_strlen_zero(cmd) && (mycmd = strdup(cmd))) {
+                argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+        }
+
+        if (!argc) {
+                stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_CHAT_SYNTAX);
+                goto end;
+        }
+
+        if (argc < 3) {
+                stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_CHAT_SYNTAX);
+                goto end;
+        }
+
+        if (argv[0]) {
+
+                for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+                        /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
+                        if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+                                        && (strncmp(globals.SKYPIAX_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) {
+                                tech_pvt = &globals.SKYPIAX_INTERFACES[i];
+                                stream->write_function(stream, "Using interface: globals.SKYPIAX_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPIAX_INTERFACES[i].name);
+                                found = 1;
+                                break;
+                        }
+
+                }
+                if (!found) {
+                        stream->write_function(stream, "ERROR: A Skypiax interface with name='%s' was not found\n", argv[0]);
+                        goto end;
+                } else {
+                        char skype_msg[256];
+                        //NOTICA("TEXT is: %s\n", SKYPIAX_P_LOG, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1] );
+                        snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", argv[1]);
+                        skypiax_signaling_write(tech_pvt, skype_msg);
+                        usleep(100);
+                }
+        } else {
+                stream->write_function(stream, "ERROR, usage: %s", SKYPIAX_CHAT_SYNTAX);
+        }
+
+
+        found=0;
+
+        while(!found){
+                for(i=0; i<MAX_CHATS; i++){
+                        if(!strcmp(tech_pvt->chats[i].dialog_partner, argv[1]) ){
+                                snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, (char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]);
+                                skypiax_signaling_write(tech_pvt, skype_msg);
+                                found=1;
+                                break;
+                        }
+                }
+                if(found){
+                        break;
+                }
+                if(tried > 1000){
+                        stream->write_function(stream, "ERROR: no chat with dialog_partner='%s' was not found\n", argv[1]);
+                        break;
+                }
+                usleep(1000);
+        }
+
+end:
+        switch_safe_free(mycmd);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
</ins><span class="cx"> SWITCH_STANDARD_API(skypiax_function)
</span><span class="cx"> {
</span><span class="cx">         char *mycmd = NULL, *argv[10] = { 0 };
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14856 => 14857)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-09-14 22:03:37 UTC (rev 14856)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-09-14 22:13:00 UTC (rev 14857)
</span><span class="lines">@@ -163,6 +163,14 @@
</span><span class="cx"> };
</span><span class="cx"> #endif //WIN32
</span><span class="cx">
</span><ins>+#define MAX_CHATS 10
+
+struct chat {
+        char chatname[256];
+        char dialog_partner[256];
+};
+typedef struct chat chat_t;
+
</ins><span class="cx"> #define MAX_CHATMESSAGES 10
</span><span class="cx">
</span><span class="cx"> struct chatmessage {
</span><span class="lines">@@ -261,6 +269,7 @@
</span><span class="cx">         uint32_t ob_failed_calls;
</span><span class="cx">
</span><span class="cx">         chatmessage_t chatmessages[MAX_CHATMESSAGES];
</span><ins>+        chat_t chats[MAX_CHATS];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct private_object private_t;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14856 => 14857)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-09-14 22:03:37 UTC (rev 14856)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-09-14 22:13:00 UTC (rev 14857)
</span><span class="lines">@@ -222,6 +222,45 @@
</span><span class="cx">                                         skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><ins>+                        if (!strcasecmp(message, "CHAT")) {
+                                char msg_to_skype[256];
+                                int i;
+                                int found;
+
+                                skypiax_strncpy(obj, where, sizeof(obj) - 1);
+                                where = strsep(stringp, " ");
+                                skypiax_strncpy(id, where, sizeof(id) - 1);
+                                where = strsep(stringp, " ");
+                                skypiax_strncpy(prop, where, sizeof(prop) - 1);
+                                skypiax_strncpy(value, *stringp, sizeof(value) - 1);
+
+                                if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "DIALOG")) {
+                                        DEBUGA_SKYPE("CHAT %s is DIALOG\n", SKYPIAX_P_LOG, id);
+                                        sprintf(msg_to_skype, "GET CHAT %s DIALOG_PARTNER", id);
+                                        skypiax_signaling_write(tech_pvt, msg_to_skype);
+                                }
+
+                                if (!strcasecmp(prop, "DIALOG_PARTNER")) {
+                                        DEBUGA_SKYPE("CHAT %s has DIALOG_PARTNER %s\n", SKYPIAX_P_LOG, id, value);
+                                        found=0;
+                                        for(i=0; i<MAX_CHATS; i++){
+                                                if(strlen(tech_pvt->chats[i].chatname) == 0 || !strcmp(tech_pvt->chats[i].chatname, id) ){
+                                                        strncpy(tech_pvt->chats[i].chatname, id, sizeof(tech_pvt->chats[i].chatname));
+                                                        strncpy(tech_pvt->chats[i].dialog_partner, value, sizeof(tech_pvt->chats[i].dialog_partner));
+                                                        found=1;
+                                                        break;
+                                                }
+                                        }
+                                        if(!found){
+                                                ERRORA("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPIAX_P_LOG, MAX_CHATS);
+                                        }
+
+                                        DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chats[i].chatname, tech_pvt->chats[i].dialog_partner);
+                                }
+
+                        }
+
+
</ins><span class="cx">                         if (!strcasecmp(message, "CHATMESSAGE")) {
</span><span class="cx">                                 char msg_to_skype[256];
</span><span class="cx">                                 int i;
</span><span class="lines">@@ -232,20 +271,16 @@
</span><span class="cx">                                 skypiax_strncpy(id, where, sizeof(id) - 1);
</span><span class="cx">                                 where = strsep(stringp, " ");
</span><span class="cx">                                 skypiax_strncpy(prop, where, sizeof(prop) - 1);
</span><del>-                                //where = strsep(stringp, " ");
</del><span class="cx">                                 skypiax_strncpy(value, *stringp, sizeof(value) - 1);
</span><del>-                                //where = strsep(stringp, " ");
</del><span class="cx">
</span><del>-                                //ERRORA ("Skype MSG, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", SKYPIAX_P_LOG, obj, id, prop, value, where ? where : "NULL");
-
</del><span class="cx">                                 if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) {
</span><del>-                                        NOTICA("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPIAX_P_LOG, id);
</del><ins>+                                        DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPIAX_P_LOG, id);
</ins><span class="cx">                                         sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id);
</span><span class="cx">                                         skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) {
</span><del>-                                        NOTICA("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPIAX_P_LOG, id);
</del><ins>+                                        DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPIAX_P_LOG, id);
</ins><span class="cx">                                         found=0;
</span><span class="cx">                                         for(i=0; i<MAX_CHATMESSAGES; i++){
</span><span class="cx">                                                 if(strlen(tech_pvt->chatmessages[i].id) == 0){
</span><span class="lines">@@ -258,7 +293,7 @@
</span><span class="cx">                                         if(!found){
</span><span class="cx">                                                 ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPIAX_P_LOG, MAX_CHATMESSAGES);
</span><span class="cx">                                         } else {
</span><del>-                                                NOTICA("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
</del><ins>+                                                DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPIAX_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id);
</ins><span class="cx">                                                 sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id);
</span><span class="cx">                                                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                                                 skypiax_sleep(100);
</span><span class="lines">@@ -274,7 +309,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!strcasecmp(prop, "CHATNAME")) {
</span><del>-                                        NOTICA("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPIAX_P_LOG, id, value);
</del><ins>+                                        DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPIAX_P_LOG, id, value);
</ins><span class="cx">                                         found=0;
</span><span class="cx">                                         for(i=0; i<MAX_CHATMESSAGES; i++){
</span><span class="cx">                                                 if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</span><span class="lines">@@ -288,7 +323,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "FROM_HANDLE")) {
</span><del>-                                        NOTICA("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPIAX_P_LOG, id, value);
</del><ins>+                                        DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPIAX_P_LOG, id, value);
</ins><span class="cx">                                         found=0;
</span><span class="cx">                                         for(i=0; i<MAX_CHATMESSAGES; i++){
</span><span class="cx">                                                 if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</span><span class="lines">@@ -303,7 +338,7 @@
</span><span class="cx">
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "FROM_DISPNAME")) {
</span><del>-                                        NOTICA("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPIAX_P_LOG, id, value);
</del><ins>+                                        DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPIAX_P_LOG, id, value);
</ins><span class="cx">                                         found=0;
</span><span class="cx">                                         for(i=0; i<MAX_CHATMESSAGES; i++){
</span><span class="cx">                                                 if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</span><span class="lines">@@ -318,7 +353,7 @@
</span><span class="cx">
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, "BODY")) {
</span><del>-                                        NOTICA("CHATMESSAGE %s has BODY %s\n", SKYPIAX_P_LOG, id, value);
</del><ins>+                                        DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPIAX_P_LOG, id, value);
</ins><span class="cx">                                         found=0;
</span><span class="cx">                                         for(i=0; i<MAX_CHATMESSAGES; i++){
</span><span class="cx">                                                 if(!strcmp(tech_pvt->chatmessages[i].id, id)){
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>