[Freeswitch-branches] [commit] r11917 - in freeswitch/branches/gmaruzz/mod_skypiax: . asterisk

FreeSWITCH SVN gmaruzz at freeswitch.org
Thu Feb 12 01:04:35 PST 2009


Author: gmaruzz
Date: Thu Feb 12 03:04:35 2009
New Revision: 11917

Log:
skypiax:  indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90

Modified:
   freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c
   freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
   freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
   freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
   freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c	Thu Feb 12 03:04:35 2009
@@ -12,7 +12,7 @@
 
 /* GLOBAL VARIABLES */
 int running = 1;
-int skypiax_dir_entry_extension=1; //FIXME one var for each interface!
+int skypiax_dir_entry_extension = 1;    //FIXME one var for each interface!
 char skypiax_console_active_array[50] = "";
 char *skypiax_console_active = skypiax_console_active_array;
 /*! \brief Count of active channels for this module */
@@ -286,7 +286,6 @@
   struct ast_channel *tmp = NULL;
   char *name = data;
 
-
   DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n",
              SKYPIAX_P_LOG, type, name, *cause, format);
 
@@ -442,10 +441,11 @@
     usleep(10000);              //10msec
   }
   if (p->interface_state != SKYPIAX_STATE_UP) {
-    ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
+    ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n",
+           SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
     res = -1;
   } else {
-      DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
+    DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
     res = 0;
   }
   return res;
@@ -501,7 +501,6 @@
   short *buf;
   int samples;
 
-
 /* if there are control frames queued to be sent by skypiax_queue_control, send it the first */
 //TODO maybe better a real queue?
   if (p && p->owner && p->control_to_send) {
@@ -572,8 +571,8 @@
     return -1;
   }
 
-    DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest,
-               timeout);
+  DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest,
+             timeout);
 
   strncpy(rdest, idest, sizeof(rdest) - 1);
   stringp = rdest;
@@ -586,8 +585,8 @@
   }
 
   strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
-    DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
-               idest, timeout, dstr);
+  DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
+             idest, timeout, dstr);
 
   strcpy(p->session_uuid_str, "dialing");
   status = skypiax_skype_call(p, dstr, timeout);
@@ -596,8 +595,8 @@
     return -1;
   }
 
-    DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
-               idest, timeout, dstr);
+  DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
+             idest, timeout, dstr);
 
   ast_setstate(p->owner, SKYPIAX_STATE_DIALING);
   return 0;
@@ -861,24 +860,24 @@
   /* go through the interfaces list (skypiax_iflist) WITHOUT locking */
   p = skypiax_iflist;
   while (p) {
-	  int i;
-	  /* for each interface in list */
-	  p2 = p->next;
-	  NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name);
-	  i=0;
-	  while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME
-		  usleep(1000);
-		  i++;
-	  }
-	  if (p->SkypiaxHandles.api_connected){
-		  NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name);
-	  } else {
-		  ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name);
-		  running = 0;
-		  return -1;
-	  }
-	  /* next one, please */
-	  p = p2;
+    int i;
+    /* for each interface in list */
+    p2 = p->next;
+    NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name);
+    i = 0;
+    while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) {  // 60sec FIXME
+      usleep(1000);
+      i++;
+    }
+    if (p->SkypiaxHandles.api_connected) {
+      NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name);
+    } else {
+      ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name);
+      running = 0;
+      return -1;
+    }
+    /* next one, please */
+    p = p2;
   }
   return 0;
 }
@@ -898,7 +897,6 @@
   struct skypiax_pvt *p = NULL, *p2 = NULL;
   int res;
 
-
   /* unregister our channel type with Asterisk */
   ast_channel_unregister(&skypiax_tech);
   ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
@@ -1024,7 +1022,7 @@
 {
   struct skypiax_pvt *p = NULL;
 
-    NOTICA("Returning Key\n", SKYPIAX_P_LOG);
+  NOTICA("Returning Key\n", SKYPIAX_P_LOG);
 
   return ASTERISK_GPL_KEY;
 }
@@ -1080,7 +1078,8 @@
             skypiax_store_boost(v->value, &skypiax_default.capture_boost))
         M_UINT("skypiax_dir_entry_extension_prefix",
                skypiax_default.skypiax_dir_entry_extension_prefix)
-        M_END(;);
+        M_END(;
+        );
     }
   }
 
@@ -1116,7 +1115,8 @@
       M_STR("skype_user", tmp->skype_user)
       M_UINT("skypiax_dir_entry_extension_prefix",
              tmp->skypiax_dir_entry_extension_prefix)
-      M_END(;);
+      M_END(;
+      );
   }
 
   if (debug_all) {
@@ -1231,34 +1231,33 @@
     return NULL;
   }
   /*
-  res = pipe(tmp->SkypiaxHandles.fdesc);
-  if (res) {
-    ast_log(LOG_ERROR, "Unable to create skype pipe\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-    }
-    free(tmp);
-    return NULL;
-  }
-  fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-  fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
-  */
+     res = pipe(tmp->SkypiaxHandles.fdesc);
+     if (res) {
+     ast_log(LOG_ERROR, "Unable to create skype pipe\n");
+     if (option_debug > 10) {
+     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
+     }
+     free(tmp);
+     return NULL;
+     }
+     fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+     fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+   */
   tmp->skype_thread = AST_PTHREADT_NULL;
 
   if (tmp->skype) {
-      ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
-              (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
-              (unsigned long) AST_PTHREADT_NULL);
+    ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
+            (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
+            (unsigned long) AST_PTHREADT_NULL);
 #ifdef __CYGWIN__
-    if (ast_pthread_create
-        (&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
+    if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
       free(tmp);
       return NULL;
     }
 #else /* __CYGWIN__ */
 #ifdef WANT_SKYPE_X11
-      ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
+    ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
     if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
       free(tmp);
@@ -1266,18 +1265,16 @@
     }
 #endif /* WANT_SKYPE_X11 */
 #endif /* __CYGWIN__ */
-    usleep(100000); //0.1 sec
-    if( tmp->skype_thread == AST_PTHREADT_NULL){
+    usleep(100000);             //0.1 sec
+    if (tmp->skype_thread == AST_PTHREADT_NULL) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
       free(tmp);
       return NULL;
     }
-      ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
-              (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
-              (unsigned long) AST_PTHREADT_NULL);
+    ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
+            (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
+            (unsigned long) AST_PTHREADT_NULL);
   }
-
-
 #if 0
   if (tmp->skype) {
 #if 0
@@ -1298,7 +1295,8 @@
     }
 #else /* __CYGWIN__ */
 #ifdef WANT_SKYPE_X11
-    if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) < 0) {
+    if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) <
+        0) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
       if (option_debug > 10) {
         DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
@@ -1308,8 +1306,8 @@
     }
 #endif /* WANT_SKYPE_X11 */
 #endif /* __CYGWIN__ */
-    usleep(100000); //0.1 sec
-    if( tmp->skype_thread == AST_PTHREADT_NULL){
+    usleep(100000);             //0.1 sec
+    if (tmp->skype_thread == AST_PTHREADT_NULL) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
       if (option_debug > 10) {
         DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
@@ -1322,12 +1320,8 @@
               (unsigned long) tmp->signaling_thread, (unsigned long) AST_PTHREADT_STOP,
               (unsigned long) AST_PTHREADT_NULL);
   }
-
 #endif
 
-
-
-
   /* return the newly created skypiax_pvt */
   return tmp;
 }
@@ -1522,7 +1516,7 @@
   int res;
 
   res = skypiax_skypeaudio_read(p);
-  f =  &p->read_frame;
+  f = &p->read_frame;
   return f;
 }
 
@@ -1557,7 +1551,7 @@
     if (p->skype) {
       res = skypiax_skype_read(p);
       if (res == CALLFLOW_INCOMING_HANGUP) {
-          DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
+        DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
         if (p->owner) {
           pthread_testcancel();
           ast_queue_control(p->owner, AST_CONTROL_HANGUP);
@@ -1596,7 +1590,7 @@
     *boost = BOOST_MAX;
   }
   *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
-    DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
+  DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
 }
 
 /*
@@ -1758,147 +1752,140 @@
 
 void *do_skypeapi_thread(void *obj)
 {
-	return skypiax_do_skypeapi_thread_func(obj);
+  return skypiax_do_skypeapi_thread_func(obj);
 }
 
-int dtmf_received(private_t *p, char *value){
+int dtmf_received(private_t * p, char *value)
+{
 
-	struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
-	DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value);
-	ast_queue_frame(p->owner, &f2);
+  struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+  DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value);
+  ast_queue_frame(p->owner, &f2);
 
-	return 0;
+  return 0;
 
 }
-int start_audio_threads(private_t *p) {
-                //if (!p->tcp_srv_thread) {
-                  if (ast_pthread_create
-                      (&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
-                    ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-                    return -1;
-                  } else {
-                    DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-                  }
-                //}
-                //if (!p->tcp_cli_thread) {
-                  if (ast_pthread_create
-                      (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
-                    ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                    return -1;
-                  } else {
-                    DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                  }
-                //}
 
+int start_audio_threads(private_t * p)
+{
+  //if (!p->tcp_srv_thread) {
+  if (ast_pthread_create(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
+    ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+    return -1;
+  } else {
+    DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+  }
+  //}
+  //if (!p->tcp_cli_thread) {
+  if (ast_pthread_create(&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
+    ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+    return -1;
+  } else {
+    DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+  }
+  //}
 
 #ifdef NOTDEF
-                  switch_threadattr_t *thd_attr = NULL;
+  switch_threadattr_t *thd_attr = NULL;
+
+  switch_threadattr_create(&thd_attr, skypiax_module_pool);
+  switch_threadattr_detach_set(thd_attr, 1);
+  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+  switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread,
+                       tech_pvt, skypiax_module_pool);
+  DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+  switch_threadattr_create(&thd_attr, skypiax_module_pool);
+  switch_threadattr_detach_set(thd_attr, 1);
+  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+  switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread,
+                       tech_pvt, skypiax_module_pool);
+  DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+  switch_sleep(100000);
 
-                  switch_threadattr_create(&thd_attr, skypiax_module_pool);
-                  switch_threadattr_detach_set(thd_attr, 1);
-                  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-                  switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr,
-                                       skypiax_do_tcp_srv_thread, tech_pvt,
-                                       skypiax_module_pool);
-                  DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
-                  switch_threadattr_create(&thd_attr, skypiax_module_pool);
-                  switch_threadattr_detach_set(thd_attr, 1);
-                  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-                  switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr,
-                                       skypiax_do_tcp_cli_thread, tech_pvt,
-                                       skypiax_module_pool);
-                  DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                  switch_sleep(100000);
- 
 #endif
 
-	return 0;
+  return 0;
 }
 
-int new_inbound_channel(private_t *p) {
+int new_inbound_channel(private_t * p)
+{
 
 #ifdef NOTDEF
-                  switch_core_session_t *session = NULL;
-                  switch_channel_t *channel = NULL;
-
-                  if ((session =
-                       switch_core_session_request(skypiax_endpoint_interface,
-                                                   NULL)) != 0) {
-                    switch_core_session_add_stream(session, NULL);
-                    channel = switch_core_session_get_channel(session);
-                    skypiax_tech_init(tech_pvt, session);
-
-                    if ((tech_pvt->caller_profile =
-                         switch_caller_profile_new(switch_core_session_get_pool(session),
-                                                   "skypiax", tech_pvt->dialplan,
-                                                   tech_pvt->callid_name,
-                                                   tech_pvt->callid_number, NULL, NULL,
-                                                   NULL, NULL, "mod_skypiax",
-                                                   tech_pvt->context,
-                                                   tech_pvt->destination)) != 0) {
-                      char name[128];
-                      //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
-                      switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
-                      switch_channel_set_name(channel, name);
-                      switch_channel_set_caller_profile(channel,
-                                                        tech_pvt->caller_profile);
-                    }
-                    switch_channel_set_state(channel, CS_INIT);
-                    if (switch_core_session_thread_launch(session) !=
-                        SWITCH_STATUS_SUCCESS) {
-                      ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
-                      switch_core_session_destroy(&session);
-                    }
-                  }
-                  switch_channel_mark_answered(channel);
+  switch_core_session_t *session = NULL;
+  switch_channel_t *channel = NULL;
 
+  if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
+    switch_core_session_add_stream(session, NULL);
+    channel = switch_core_session_get_channel(session);
+    skypiax_tech_init(tech_pvt, session);
+
+    if ((tech_pvt->caller_profile =
+         switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax",
+                                   tech_pvt->dialplan, tech_pvt->callid_name,
+                                   tech_pvt->callid_number, NULL, NULL, NULL, NULL,
+                                   "mod_skypiax", tech_pvt->context,
+                                   tech_pvt->destination)) != 0) {
+      char name[128];
+      //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
+      switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
+      switch_channel_set_name(channel, name);
+      switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
+    }
+    switch_channel_set_state(channel, CS_INIT);
+    if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+      ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
+      switch_core_session_destroy(&session);
+    }
+  }
+  switch_channel_mark_answered(channel);
 
 #endif
-	return 0;
+  return 0;
 }
-int outbound_channel_answered(private_t *p) {
-#ifdef NOTDEF
-                  switch_core_session_t *session = NULL;
-                  switch_channel_t *channel = NULL;
 
+int outbound_channel_answered(private_t * p)
+{
+#ifdef NOTDEF
+  switch_core_session_t *session = NULL;
+  switch_channel_t *channel = NULL;
 
-                  if (strlen(tech_pvt->session_uuid_str)) {
-                    session = switch_core_session_locate(tech_pvt->session_uuid_str);
-                  } else {
-                    ERRORA("No session???\n", SKYPIAX_P_LOG);
-                  }
-                  if (session) {
-                    channel = switch_core_session_get_channel(session);
-                  } else {
-                    ERRORA("No session???\n", SKYPIAX_P_LOG);
-                  }
-                  if (channel) {
-                    switch_channel_mark_answered(channel);
-                    //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
-                  } else {
-                    ERRORA("No channel???\n", SKYPIAX_P_LOG);
-                  }
+  if (strlen(tech_pvt->session_uuid_str)) {
+    session = switch_core_session_locate(tech_pvt->session_uuid_str);
+  } else {
+    ERRORA("No session???\n", SKYPIAX_P_LOG);
+  }
+  if (session) {
+    channel = switch_core_session_get_channel(session);
+  } else {
+    ERRORA("No session???\n", SKYPIAX_P_LOG);
+  }
+  if (channel) {
+    switch_channel_mark_answered(channel);
+    //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+  } else {
+    ERRORA("No channel???\n", SKYPIAX_P_LOG);
+  }
 
-                  switch_core_session_rwunlock(session);
+  switch_core_session_rwunlock(session);
 
 #endif
 
-              if (p->owner) {
-                ast_queue_control(p->owner, AST_CONTROL_ANSWER);
-              }
+  if (p->owner) {
+    ast_queue_control(p->owner, AST_CONTROL_ANSWER);
+  }
 
-                  NOTICA("HERE!\n", SKYPIAX_P_LOG);
+  NOTICA("HERE!\n", SKYPIAX_P_LOG);
 
-	return 0;
+  return 0;
 }
-void * skypiax_do_tcp_srv_thread(void *obj)
+void *skypiax_do_tcp_srv_thread(void *obj)
 {
-	return skypiax_do_tcp_srv_thread_func(obj);
+  return skypiax_do_tcp_srv_thread_func(obj);
 }
-void * skypiax_do_tcp_cli_thread(void *obj)
+void *skypiax_do_tcp_cli_thread(void *obj)
 {
-	return skypiax_do_tcp_cli_thread_func(obj);
+  return skypiax_do_tcp_cli_thread_func(obj);
 }
 
 int skypiax_skypeaudio_write(struct skypiax_pvt *p, struct ast_frame *f)
@@ -1962,10 +1949,11 @@
   //int fromcell = 0;
 
 #if 0
-  if(directoriax_entry_extension){
-    skypiax_dir_entry_extension=directoriax_entry_extension;
-  }else{
-    ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n");
+  if (directoriax_entry_extension) {
+    skypiax_dir_entry_extension = directoriax_entry_extension;
+  } else {
+    ast_cli(fd,
+            "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n");
     return RESULT_SUCCESS;
   }
 #endif
@@ -2027,7 +2015,7 @@
   } else {
     snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
   }
-    NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
+  NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
   time(&t);
   ast_copy_string(date, ctime(&t), sizeof(date));
 
@@ -2038,13 +2026,13 @@
 
   if (p->phonebook_writing_fp) {
     if (add_to_skypiax_dir_conf) {
-        NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
+      NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
       fprintf(p->phonebook_writing_fp, ";!\n");
       fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
       fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
       fprintf(p->phonebook_writing_fp, ";!\n");
     } else {
-        NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
+      NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
       fprintf(p->phonebook_writing_fp, ";!\n");
       fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");
       fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn);
@@ -2057,117 +2045,198 @@
 
   /*******************************************************************************************/
     //if (fromskype) {
-      if (p->skype) {
-        WARNINGA
-          ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n",
-           SKYPIAX_P_LOG);
-        if (p->skype_thread != AST_PTHREADT_NULL) {
-          char msg_to_skype[1024];
+    if (p->skype) {
+      WARNINGA
+        ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n",
+         SKYPIAX_P_LOG);
+      if (p->skype_thread != AST_PTHREADT_NULL) {
+        char msg_to_skype[1024];
+
+        p->skype_friends[0] = '\0';
+        sprintf(msg_to_skype, "#333 SEARCH FRIENDS");
+        if (skypiax_skype_write(p, msg_to_skype) < 0) {
+          return -1;
+        }
 
-          p->skype_friends[0] = '\0';
-          sprintf(msg_to_skype, "#333 SEARCH FRIENDS");
-          if (skypiax_skype_write(p, msg_to_skype) < 0) {
-            return -1;
+        int friends_count = 0;
+        while (p->skype_friends[0] == '\0') {
+          /* FIXME needs a timeout, can't wait forever! 
+           * eg. when skype is running but not connected! */
+          usleep(100);
+          friends_count++;
+          if (friends_count > 20000) {
+            return -1;          /* FIXME */
           }
+        }
 
-          int friends_count = 0;
-          while (p->skype_friends[0] == '\0') {
-            /* FIXME needs a timeout, can't wait forever! 
-             * eg. when skype is running but not connected! */
-            usleep(100);
-            friends_count++;
-            if (friends_count > 20000) {
-              return -1;        /* FIXME */
-            }
-          }
+      }
 
-        }
+      if (p->skype_thread != AST_PTHREADT_NULL) {
+        char msg_to_skype[1024];
 
-        if (p->skype_thread != AST_PTHREADT_NULL) {
-          char msg_to_skype[1024];
+        if (p->skype_friends[0] != '\0') {
+          char *buf, *where;
+          char **stringp;
+          int skype_dir_file_written = 0;
+
+          buf = p->skype_friends;
+          stringp = &buf;
+          where = strsep(stringp, ", ");
+          while (where) {
+            if (where[0] != '\0') {
+              /*
+               * So, we have the Skype username (the HANDLE, I think is called).
+               * But we want to call the names we see in the Skype contact list
+               * So, let's check the DISPLAYNAME (the end user modified contact name)
+               * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME 
+               * if the end user has not modify it)
+               * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the 
+               * Skipe username (the HANDLE)
+               */
+
+              p->skype_displayname[0] = '\0';
+              sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where);
+              skypiax_skype_write(p, msg_to_skype);
+              int displayname_count = 0;
+              while (p->skype_displayname[0] == '\0') {
+                /* FIXME needs a timeout, can't wait forever! 
+                 * eg. when skype is running but not connected! */
+                usleep(100);
+                displayname_count++;
+                if (displayname_count > 20000)
+                  return -1;    /* FIXME */
+              }
+              if (p->skype_displayname[0] != '\0') {
+                char *where2;
+                char sanitized[300];
+
+                sanitized[0] = '\0';
+
+                where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
+                if (where2) {
+
+                  /* there can be some *smart* that makes a displayname 
+                   * that is different than first<space>last, */
+                  /* maybe initials, simbols, slashes, 
+                   * something smartish... let's check */
+
+                  if (where2[12] != '\0') {
+                    int i = 12;
+                    int x = 0;
+                    int spaces = 0;
+                    int last_char_was_space = 0;
+
+                    for (i = 12; i < strlen(where2) && x < 299; i++) {
+                      if (!isalnum(where2[i])) {
+                        if (!isblank(where2[i])) {
+                          /* bad char */
+                          continue;
+                        }
+                        /* is a space */
+                        if (last_char_was_space == 1)   /* do not write 2 consecutive spaces */
+                          continue;
+                        last_char_was_space = 1;
+                        sanitized[x] = ' ';
+                        x++;
+                        continue;
+                      }
+                      /* is alphanum */
+                      last_char_was_space = 0;
+                      sanitized[x] = where2[i];
+                      x++;
+                      continue;
+                    }
 
-          if (p->skype_friends[0] != '\0') {
-            char *buf, *where;
-            char **stringp;
-            int skype_dir_file_written = 0;
+                    sanitized[x] = '\0';
+                    if (spaces == 0) {
+                    }
+                    DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
+                                 SKYPIAX_P_LOG, sanitized, where, &where2[12]);
+                  }
 
-            buf = p->skype_friends;
-            stringp = &buf;
-            where = strsep(stringp, ", ");
-            while (where) {
-              if (where[0] != '\0') {
-                /*
-                 * So, we have the Skype username (the HANDLE, I think is called).
-                 * But we want to call the names we see in the Skype contact list
-                 * So, let's check the DISPLAYNAME (the end user modified contact name)
-                 * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME 
-                 * if the end user has not modify it)
-                 * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the 
-                 * Skipe username (the HANDLE)
-                 */
-
-                p->skype_displayname[0] = '\0';
-                sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where);
-                skypiax_skype_write(p, msg_to_skype);
-                int displayname_count = 0;
-                while (p->skype_displayname[0] == '\0') {
-                  /* FIXME needs a timeout, can't wait forever! 
-                   * eg. when skype is running but not connected! */
-                  usleep(100);
-                  displayname_count++;
-                  if (displayname_count > 20000)
-                    return -1;  /* FIXME */
+                  if (where2[12] != '\0') {
+                    skypiax_dir_entry_extension++;
+                    if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
+                      fprintf(p->phonebook_writing_fp,
+                              "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                              where, sanitized, "no",
+                              p->skypiax_dir_entry_extension_prefix, "2",
+                              skypiax_dir_entry_extension, "yes", "not_specified");
+                    } else {    /* is a skype name */
+                      fprintf(p->phonebook_writing_fp,
+                              "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                              where, sanitized, "no",
+                              p->skypiax_dir_entry_extension_prefix, "1",
+                              skypiax_dir_entry_extension, "yes", "not_specified");
+                    }
+                    skype_dir_file_written = 1;
+
+                  }
                 }
-                if (p->skype_displayname[0] != '\0') {
-                  char *where2;
-                  char sanitized[300];
-
-                  sanitized[0] = '\0';
-
-                  where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
-                  if (where2) {
-
-                    /* there can be some *smart* that makes a displayname 
-                     * that is different than first<space>last, */
-                    /* maybe initials, simbols, slashes, 
-                     * something smartish... let's check */
-
-                    if (where2[12] != '\0') {
-                      int i = 12;
-                      int x = 0;
-                      int spaces = 0;
-                      int last_char_was_space = 0;
-
-                      for (i = 12; i < strlen(where2) && x < 299; i++) {
-                        if (!isalnum(where2[i])) {
-                          if (!isblank(where2[i])) {
-                            /* bad char */
-                            continue;
-                          }
-                          /* is a space */
-                          if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
-                            continue;
-                          last_char_was_space = 1;
-                          sanitized[x] = ' ';
-                          x++;
+              }
+              p->skype_displayname[0] = '\0';
+
+              p->skype_fullname[0] = '\0';
+              sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where);
+              skypiax_skype_write(p, msg_to_skype);
+              int fullname_count = 0;
+              while (p->skype_fullname[0] == '\0') {
+                /* FIXME needs a timeout, can't wait forever! 
+                 * eg. when skype is running but not connected! */
+                usleep(100);
+                fullname_count++;
+                if (fullname_count > 20000)
+                  return -1;    /* FIXME */
+              }
+              if (p->skype_fullname[0] != '\0') {
+                char *where2;
+                char sanitized[300];
+
+                where2 = strstr(p->skype_fullname, "FULLNAME ");
+                if (where2) {
+
+                  /* there can be some *smart* that makes a fullname 
+                   * that is different than first<space>last, */
+                  /* maybe initials, simbols, slashes,
+                   *  something smartish... let's check */
+
+                  if (where2[9] != '\0') {
+                    int i = 9;
+                    int x = 0;
+                    int spaces = 0;
+                    int last_char_was_space = 0;
+
+                    for (i = 9; i < strlen(where2) && x < 299; i++) {
+                      if (!isalnum(where2[i])) {
+                        if (!isblank(where2[i])) {
+                          /* bad char */
                           continue;
                         }
-                        /* is alphanum */
-                        last_char_was_space = 0;
-                        sanitized[x] = where2[i];
+                        /* is a space */
+                        if (last_char_was_space == 1)   /* do not write 2 consecutive spaces */
+                          continue;
+                        last_char_was_space = 1;
+                        sanitized[x] = ' ';
                         x++;
                         continue;
                       }
+                      /* alphanum */
+                      last_char_was_space = 0;
+                      sanitized[x] = where2[i];
+                      x++;
+                      continue;
+                    }
 
-                      sanitized[x] = '\0';
-                      if (spaces == 0) {
-                      }
-                      DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
-                                   SKYPIAX_P_LOG, sanitized, where, &where2[12]);
+                    sanitized[x] = '\0';
+                    if (spaces == 0) {
                     }
+                    DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
+                                 SKYPIAX_P_LOG, sanitized, where, &where2[9]);
+                  }
 
-                    if (where2[12] != '\0') {
-                      skypiax_dir_entry_extension++;
+                  if (skype_dir_file_written == 0) {
+                    skypiax_dir_entry_extension++;
+                    if (where2[9] != '\0') {
                       if (where[0] == '+' || isdigit(where[0])) {   /* is a skypeout number */
                         fprintf(p->phonebook_writing_fp,
                                 "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
@@ -2180,127 +2249,44 @@
                                 where, sanitized, "no",
                                 p->skypiax_dir_entry_extension_prefix, "1",
                                 skypiax_dir_entry_extension, "yes", "not_specified");
-                      }
-                      skype_dir_file_written = 1;
-
-                    }
-                  }
-                }
-                p->skype_displayname[0] = '\0';
-
-                p->skype_fullname[0] = '\0';
-                sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where);
-                skypiax_skype_write(p, msg_to_skype);
-                int fullname_count = 0;
-                while (p->skype_fullname[0] == '\0') {
-                  /* FIXME needs a timeout, can't wait forever! 
-                   * eg. when skype is running but not connected! */
-                  usleep(100);
-                  fullname_count++;
-                  if (fullname_count > 20000)
-                    return -1;  /* FIXME */
-                }
-                if (p->skype_fullname[0] != '\0') {
-                  char *where2;
-                  char sanitized[300];
-
-                  where2 = strstr(p->skype_fullname, "FULLNAME ");
-                  if (where2) {
-
-                    /* there can be some *smart* that makes a fullname 
-                     * that is different than first<space>last, */
-                    /* maybe initials, simbols, slashes,
-                     *  something smartish... let's check */
-
-                    if (where2[9] != '\0') {
-                      int i = 9;
-                      int x = 0;
-                      int spaces = 0;
-                      int last_char_was_space = 0;
-
-                      for (i = 9; i < strlen(where2) && x < 299; i++) {
-                        if (!isalnum(where2[i])) {
-                          if (!isblank(where2[i])) {
-                            /* bad char */
-                            continue;
-                          }
-                          /* is a space */
-                          if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
-                            continue;
-                          last_char_was_space = 1;
-                          sanitized[x] = ' ';
-                          x++;
-                          continue;
-                        }
-                        /* alphanum */
-                        last_char_was_space = 0;
-                        sanitized[x] = where2[i];
-                        x++;
-                        continue;
-                      }
 
-                      sanitized[x] = '\0';
-                      if (spaces == 0) {
                       }
-                      DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
-                                   SKYPIAX_P_LOG, sanitized, where, &where2[9]);
-                    }
-
-                    if (skype_dir_file_written == 0) {
-                      skypiax_dir_entry_extension++;
-                      if (where2[9] != '\0') {
-                        if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, sanitized, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "2",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-                        } else {    /* is a skype name */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, sanitized, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "1",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
 
-                        }
-
-                      } else {
-                        if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, where, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "2",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
-                        } else {    /* is a skype name */
-                          fprintf(p->phonebook_writing_fp,
-                                  "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
-                                  where, where, "no",
-                                  p->skypiax_dir_entry_extension_prefix, "1",
-                                  skypiax_dir_entry_extension, "yes", "not_specified");
+                    } else {
+                      if (where[0] == '+' || isdigit(where[0])) {   /* is a skypeout number */
+                        fprintf(p->phonebook_writing_fp,
+                                "%s  => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                where, where, "no", p->skypiax_dir_entry_extension_prefix,
+                                "2", skypiax_dir_entry_extension, "yes", "not_specified");
+                      } else {  /* is a skype name */
+                        fprintf(p->phonebook_writing_fp,
+                                "%s  => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                where, where, "no", p->skypiax_dir_entry_extension_prefix,
+                                "1", skypiax_dir_entry_extension, "yes", "not_specified");
 
-                        }
                       }
                     }
-
-                    skype_dir_file_written = 0;
-
                   }
 
+                  skype_dir_file_written = 0;
+
                 }
-                p->skype_fullname[0] = '\0';
 
               }
-              where = strsep(stringp, ", ");
-            }
+              p->skype_fullname[0] = '\0';
 
-            p->skype_friends[0] = '\0';
+            }
+            where = strsep(stringp, ", ");
           }
-        }
-      } else {
 
-        ast_cli(fd,
-                "Skype not configured on the 'current' console, not importing from Skype client!\n");
+          p->skype_friends[0] = '\0';
+        }
       }
+    } else {
+
+      ast_cli(fd,
+              "Skype not configured on the 'current' console, not importing from Skype client!\n");
+    }
     //}
   /*******************************************************************************************/
   /*******************************************************************************************/
@@ -2317,9 +2303,10 @@
   return RESULT_SUCCESS;
 }
 
-private_t *find_available_skypiax_interface(void) {
-	private_t *p;
-	int found = 0;
+private_t *find_available_skypiax_interface(void)
+{
+  private_t *p;
+  int found = 0;
 
   /* lock the interfaces' list */
   LOKKA(&skypiax_iflock);
@@ -2327,15 +2314,15 @@
   p = skypiax_iflist;
   /* Search for the requested interface and verify if is unowned */
   while (p) {
-      if (!p->owner) {
-        DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
-	found = 1;
+    if (!p->owner) {
+      DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
+      found = 1;
       /* we found the requested interface, bail out from the while loop */
-	break;
-      } else {
-        /* interface owned by a channel */
-        DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
-      }
+      break;
+    } else {
+      /* interface owned by a channel */
+      DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
+    }
     /* not yet found, next please */
     p = p->next;
   }
@@ -2343,14 +2330,12 @@
   /* lock the interfaces' list */
   UNLOCKA(&skypiax_iflock);
 
-
-  if(found)
-	  return p;
+  if (found)
+    return p;
   else
-	  return NULL;
+    return NULL;
 }
 
-
 /************************************************/
 #ifdef ASTERISK_VERSION_1_4
 #ifndef AST_MODULE

Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/skypiax.h	Thu Feb 12 03:04:35 2009
@@ -235,7 +235,6 @@
 
 #endif //WIN32
 
-
 /*! 
  * \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif
  */
@@ -396,13 +395,13 @@
 int skypiax_skype_call(struct skypiax_pvt *p, char *idest, int timeout);
 int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]);
 
-void * skypiax_do_tcp_srv_thread_func(void *obj);
-void * skypiax_do_tcp_cli_thread_func(void *obj);
-void * skypiax_do_skypeapi_thread_func(void *obj);
-int dtmf_received(private_t *tech_pvt, char *value);
-int start_audio_threads(private_t *tech_pvt);
-int new_inbound_channel(private_t *tech_pvt);
-int outbound_channel_answered(private_t *tech_pvt);
+void *skypiax_do_tcp_srv_thread_func(void *obj);
+void *skypiax_do_tcp_cli_thread_func(void *obj);
+void *skypiax_do_skypeapi_thread_func(void *obj);
+int dtmf_received(private_t * tech_pvt, char *value);
+int start_audio_threads(private_t * tech_pvt);
+int new_inbound_channel(private_t * tech_pvt);
+int outbound_channel_answered(private_t * tech_pvt);
 int skypiax_skype_senddigit(struct skypiax_pvt *p, char digit);
 int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
 #if defined(WIN32) && !defined(__CYGWIN__)

Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c	Thu Feb 12 03:04:35 2009
@@ -474,7 +474,7 @@
     private_t *tech_pvt;
     switch_channel_t *channel;
     switch_caller_profile_t *caller_profile;
-  char *rdest;
+    char *rdest;
 
     switch_core_session_add_stream(*new_session, NULL);
 
@@ -491,30 +491,32 @@
         slash = strrchr(interface_name, '/');
         *slash = '\0';
 
-	if (strncmp("ANY", interface_name,  strlen(interface_name)) == 0) {
-		/* we've been asked for the "ANY" interface, let's find the first idle interface */
-		DEBUGA_SKYPE("Finding one available skype interface\n",
-				SKYPIAX_P_LOG);
-		tech_pvt = find_available_skypiax_interface();
-		if(tech_pvt)
-			found=1;
-	}
+        if (strncmp("ANY", interface_name, strlen(interface_name)) == 0) {
+          /* we've been asked for the "ANY" interface, let's find the first idle interface */
+          DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG);
+          tech_pvt = find_available_skypiax_interface();
+          if (tech_pvt)
+            found = 1;
+        }
         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 */
+          /* 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, interface_name,
                 strlen(interface_name)) == 0)) {
-		  if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)){
-			  DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str);
-			  switch_core_session_destroy(new_session);
-			  return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE ;
-		  }
+            if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
+              DEBUGA_SKYPE
+                ("globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n",
+                 SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name,
+                 globals.SKYPIAX_INTERFACES[i].session_uuid_str);
+              switch_core_session_destroy(new_session);
+              return SWITCH_CAUSE_NORMAL_TEMPORARY_FAILURE;
+            }
 
             DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG,
                          i, globals.SKYPIAX_INTERFACES[i].name);
-            tech_pvt = &globals.SKYPIAX_INTERFACES[i];  
+            tech_pvt = &globals.SKYPIAX_INTERFACES[i];
             found = 1;
             break;
           }
@@ -557,18 +559,16 @@
       return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
     }
 
-
-  rdest = strchr(caller_profile->destination_number, '/');
-  *rdest++ = '\0';
-
+    rdest = strchr(caller_profile->destination_number, '/');
+    *rdest++ = '\0';
 
     skypiax_skype_call(tech_pvt, rdest, 30);
 
-  switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(*new_session),
-                     sizeof(tech_pvt->session_uuid_str));
-  caller_profile = tech_pvt->caller_profile;
-  caller_profile->destination_number = rdest;
-
+    switch_copy_string(tech_pvt->session_uuid_str,
+                       switch_core_session_get_uuid(*new_session),
+                       sizeof(tech_pvt->session_uuid_str));
+    caller_profile = tech_pvt->caller_profile;
+    caller_profile->destination_number = rdest;
 
     switch_channel_set_flag(channel, CF_OUTBOUND);
     switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
@@ -590,7 +590,6 @@
   int res;
   int forever = 1;
 
-
   DEBUGA_SKYPE("In skypiax_signaling_thread_func: started, p=%p\n", SKYPIAX_P_LOG,
                (void *) tech_pvt);
 
@@ -639,7 +638,7 @@
   switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
   if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
     ERRORA("open of %s failed\n", SKYPIAX_P_LOG, cf);
-    running=0;
+    running = 0;
     return SWITCH_STATUS_TERM;
   }
 
@@ -820,7 +819,7 @@
         memset(&newconf, '\0', sizeof(newconf));
         globals.SKYPIAX_INTERFACES[interface_id] = newconf;
 
-	tech_pvt=&globals.SKYPIAX_INTERFACES[interface_id];
+        tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
 
         switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id);
         if (name) {
@@ -907,17 +906,17 @@
 
         skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
 
-	i=0;
-        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME
+        i = 0;
+        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) {    // 60sec FIXME
           switch_sleep(1000);
-	  i++;
+          i++;
+        }
+        if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) {
+          NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+        } else {
+          ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+          return SWITCH_STATUS_FALSE;
         }
-	if(globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected){
-		NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
-	} else {
-		ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
-        return SWITCH_STATUS_FALSE;
-	}
 
       } else {
         ERRORA("interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n",
@@ -929,7 +928,7 @@
 
     for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
       if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-	      tech_pvt = &globals.SKYPIAX_INTERFACES[i];
+        tech_pvt = &globals.SKYPIAX_INTERFACES[i];
 
         DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n",
                      SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].interface_id);
@@ -963,7 +962,7 @@
   running = 1;
 
   if (load_config() != SWITCH_STATUS_SUCCESS)
-      return SWITCH_STATUS_FALSE;
+    return SWITCH_STATUS_FALSE;
 
   *module_interface = switch_loadable_module_create_module_interface(pool, modname);
   skypiax_endpoint_interface =
@@ -972,11 +971,11 @@
   skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
   skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
 
-  if(running)
-  /* indicate that the module should continue to be loaded */
-  return SWITCH_STATUS_SUCCESS;
+  if (running)
+    /* indicate that the module should continue to be loaded */
+    return SWITCH_STATUS_SUCCESS;
   else
-  return SWITCH_STATUS_FALSE;
+    return SWITCH_STATUS_FALSE;
 }
 
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
@@ -1040,165 +1039,156 @@
   return SWITCH_STATUS_SUCCESS;
 }
 
-void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
-                                                          void *obj)
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj)
+{
+  return skypiax_do_tcp_srv_thread_func(obj);
+}
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj)
 {
-	return skypiax_do_tcp_srv_thread_func(obj);
+  return skypiax_do_tcp_cli_thread_func(obj);
 }
-void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
-                                                          void *obj)
+void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj)
 {
-	return skypiax_do_tcp_cli_thread_func(obj);
-}
-void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread,
-                                                          void *obj)
-{
-	return skypiax_do_skypeapi_thread_func(obj);
-}
-
-int dtmf_received(private_t *tech_pvt, char *value){
-              switch_core_session_t *session = NULL;
-              switch_channel_t *channel = NULL;
-
-              session = switch_core_session_locate(tech_pvt->session_uuid_str);
-              channel = switch_core_session_get_channel(session);
-
-              if (channel) {
-                switch_dtmf_t dtmf =
-                  { (char) value[0], switch_core_default_dtmf_duration(0) };
-                DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
-                             switch_channel_get_name(channel));
-                switch_mutex_lock(tech_pvt->flag_mutex);
-		//FIXME: why sometimes DTMFs from here do not seems to be get by FS?
-                switch_channel_queue_dtmf(channel, &dtmf);
-                switch_set_flag(tech_pvt, TFLAG_DTMF);
-                switch_mutex_unlock(tech_pvt->flag_mutex);
-              } else {
-                WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]);
-	      }
-              switch_core_session_rwunlock(session);
-
-	return 0;
-}
-
-int start_audio_threads(private_t *tech_pvt) {
-                  switch_threadattr_t *thd_attr = NULL;
-
-                  switch_threadattr_create(&thd_attr, skypiax_module_pool);
-                  switch_threadattr_detach_set(thd_attr, 1);
-                  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-                  switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr,
-                                       skypiax_do_tcp_srv_thread, tech_pvt,
-                                       skypiax_module_pool);
-                  DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
-                  switch_threadattr_create(&thd_attr, skypiax_module_pool);
-                  switch_threadattr_detach_set(thd_attr, 1);
-                  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-                  switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr,
-                                       skypiax_do_tcp_cli_thread, tech_pvt,
-                                       skypiax_module_pool);
-                  DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                  switch_sleep(100000);
- 
-
-	return 0;
-}
-
-int new_inbound_channel(private_t *tech_pvt) {
-                  switch_core_session_t *session = NULL;
-                  switch_channel_t *channel = NULL;
-
-                  if ((session =
-                       switch_core_session_request(skypiax_endpoint_interface,
-                                                   NULL)) != 0) {
-                    switch_core_session_add_stream(session, NULL);
-                    channel = switch_core_session_get_channel(session);
-                    skypiax_tech_init(tech_pvt, session);
-
-                    if ((tech_pvt->caller_profile =
-                         switch_caller_profile_new(switch_core_session_get_pool(session),
-                                                   "skypiax", tech_pvt->dialplan,
-                                                   tech_pvt->callid_name,
-                                                   tech_pvt->callid_number, NULL, NULL,
-                                                   NULL, NULL, "mod_skypiax",
-                                                   tech_pvt->context,
-                                                   tech_pvt->destination)) != 0) {
-                      char name[128];
-                      //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
-                      switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
-                      switch_channel_set_name(channel, name);
-                      switch_channel_set_caller_profile(channel,
-                                                        tech_pvt->caller_profile);
-                    }
-                    switch_channel_set_state(channel, CS_INIT);
-                    if (switch_core_session_thread_launch(session) !=
-                        SWITCH_STATUS_SUCCESS) {
-                      ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
-                      switch_core_session_destroy(&session);
-                    }
-                  }
-                  switch_channel_mark_answered(channel);
-
-        DEBUGA_SKYPE("Here\n", SKYPIAX_P_LOG);
-
-	return 0;
-}
-int outbound_channel_answered(private_t *tech_pvt) {
-                  switch_core_session_t *session = NULL;
-                  switch_channel_t *channel = NULL;
-
-
-                  if (strlen(tech_pvt->session_uuid_str)) {
-                    session = switch_core_session_locate(tech_pvt->session_uuid_str);
-                  } else {
-                    ERRORA("No session???\n", SKYPIAX_P_LOG);
-                  }
-                  if (session) {
-                    channel = switch_core_session_get_channel(session);
-                  } else {
-                    ERRORA("No session???\n", SKYPIAX_P_LOG);
-                  }
-                  if (channel) {
-                    switch_channel_mark_answered(channel);
-                    //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
-                  } else {
-                    ERRORA("No channel???\n", SKYPIAX_P_LOG);
-                  }
-
-                  switch_core_session_rwunlock(session);
-                  DEBUGA_SKYPE("HERE!\n", SKYPIAX_P_LOG);
-
-
-	return 0;
-}
-
-private_t *find_available_skypiax_interface(void) {
-	private_t *tech_pvt;
-	int found = 0;
-	int i;
-
-	for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
-		if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-			int skype_state = 0;
-
-			tech_pvt = &globals.SKYPIAX_INTERFACES[i];
-			skype_state = tech_pvt->interface_state;
-			DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n",
-					SKYPIAX_P_LOG,
-					i, globals.SKYPIAX_INTERFACES[i].name, skype_state);
-			if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
-				found=1;
-				break;
-			}
-		}
-	}
-
-	if(found)
-		return tech_pvt;
-	else
-		return NULL;
+  return skypiax_do_skypeapi_thread_func(obj);
 }
+
+int dtmf_received(private_t * tech_pvt, char *value)
+{
+  switch_core_session_t *session = NULL;
+  switch_channel_t *channel = NULL;
+
+  session = switch_core_session_locate(tech_pvt->session_uuid_str);
+  channel = switch_core_session_get_channel(session);
+
+  if (channel) {
+    switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) };
+    DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
+                 switch_channel_get_name(channel));
+    switch_mutex_lock(tech_pvt->flag_mutex);
+    //FIXME: why sometimes DTMFs from here do not seems to be get by FS?
+    switch_channel_queue_dtmf(channel, &dtmf);
+    switch_set_flag(tech_pvt, TFLAG_DTMF);
+    switch_mutex_unlock(tech_pvt->flag_mutex);
+  } else {
+    WARNINGA("received %c DTMF, but no channel?\n", SKYPIAX_P_LOG, value[0]);
+  }
+  switch_core_session_rwunlock(session);
+
+  return 0;
+}
+
+int start_audio_threads(private_t * tech_pvt)
+{
+  switch_threadattr_t *thd_attr = NULL;
+
+  switch_threadattr_create(&thd_attr, skypiax_module_pool);
+  switch_threadattr_detach_set(thd_attr, 1);
+  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+  switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread,
+                       tech_pvt, skypiax_module_pool);
+  DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+  switch_threadattr_create(&thd_attr, skypiax_module_pool);
+  switch_threadattr_detach_set(thd_attr, 1);
+  switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+  switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread,
+                       tech_pvt, skypiax_module_pool);
+  DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+  switch_sleep(100000);
+
+  return 0;
+}
+
+int new_inbound_channel(private_t * tech_pvt)
+{
+  switch_core_session_t *session = NULL;
+  switch_channel_t *channel = NULL;
+
+  if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) {
+    switch_core_session_add_stream(session, NULL);
+    channel = switch_core_session_get_channel(session);
+    skypiax_tech_init(tech_pvt, session);
+
+    if ((tech_pvt->caller_profile =
+         switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax",
+                                   tech_pvt->dialplan, tech_pvt->callid_name,
+                                   tech_pvt->callid_number, NULL, NULL, NULL, NULL,
+                                   "mod_skypiax", tech_pvt->context,
+                                   tech_pvt->destination)) != 0) {
+      char name[128];
+      //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
+      switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
+      switch_channel_set_name(channel, name);
+      switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
+    }
+    switch_channel_set_state(channel, CS_INIT);
+    if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+      ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
+      switch_core_session_destroy(&session);
+    }
+  }
+  switch_channel_mark_answered(channel);
+
+  DEBUGA_SKYPE("Here\n", SKYPIAX_P_LOG);
+
+  return 0;
+}
+
+int outbound_channel_answered(private_t * tech_pvt)
+{
+  switch_core_session_t *session = NULL;
+  switch_channel_t *channel = NULL;
+
+  if (strlen(tech_pvt->session_uuid_str)) {
+    session = switch_core_session_locate(tech_pvt->session_uuid_str);
+  } else {
+    ERRORA("No session???\n", SKYPIAX_P_LOG);
+  }
+  if (session) {
+    channel = switch_core_session_get_channel(session);
+  } else {
+    ERRORA("No session???\n", SKYPIAX_P_LOG);
+  }
+  if (channel) {
+    switch_channel_mark_answered(channel);
+    //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+  } else {
+    ERRORA("No channel???\n", SKYPIAX_P_LOG);
+  }
+
+  switch_core_session_rwunlock(session);
+  DEBUGA_SKYPE("HERE!\n", SKYPIAX_P_LOG);
+
+  return 0;
+}
+
+private_t *find_available_skypiax_interface(void)
+{
+  private_t *tech_pvt;
+  int found = 0;
+  int i;
+
+  for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+    if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+      int skype_state = 0;
+
+      tech_pvt = &globals.SKYPIAX_INTERFACES[i];
+      skype_state = tech_pvt->interface_state;
+      DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n", SKYPIAX_P_LOG, i,
+                   globals.SKYPIAX_INTERFACES[i].name, skype_state);
+      if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
+        found = 1;
+        break;
+      }
+    }
+  }
+
+  if (found)
+    return tech_pvt;
+  else
+    return NULL;
+}
+
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	Thu Feb 12 03:04:35 2009
@@ -208,7 +208,7 @@
 #else                           /* WIN32 */
   int audiopipe[2];
   int audioskypepipe[2];
-  int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
+  int skypiax_sound_capt_fd;    /*!< \brief file descriptor for sound capture dev */
 #endif                          /* WIN32 */
   switch_thread_t *tcp_srv_thread;
   switch_thread_t *tcp_cli_thread;
@@ -246,18 +246,18 @@
 int skypiax_skype_call(private_t * tech_pvt, char *idest, int timeout);
 int skypiax_skype_senddigit(private_t * tech_pvt, char digit);
 
-void * skypiax_do_tcp_srv_thread_func(void *obj);
+void *skypiax_do_tcp_srv_thread_func(void *obj);
 void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj);
 
-void * skypiax_do_tcp_cli_thread_func(void *obj);
+void *skypiax_do_tcp_cli_thread_func(void *obj);
 void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj);
 
-void * skypiax_do_skypeapi_thread_func(void *obj);
+void *skypiax_do_skypeapi_thread_func(void *obj);
 void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj);
-int dtmf_received(private_t *tech_pvt, char *value);
-int start_audio_threads(private_t *tech_pvt);
-int new_inbound_channel(private_t *tech_pvt);
-int outbound_channel_answered(private_t *tech_pvt);
+int dtmf_received(private_t * tech_pvt, char *value);
+int start_audio_threads(private_t * tech_pvt);
+int new_inbound_channel(private_t * tech_pvt);
+int outbound_channel_answered(private_t * tech_pvt);
 int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
 #if defined(WIN32) && !defined(__CYGWIN__)
 int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany);

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	Thu Feb 12 03:04:35 2009
@@ -61,8 +61,9 @@
         return 0;
       }
       if (!strncasecmp(message, "ERROR 92 CALL", 12)) {
-        ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n",
-               SKYPIAX_P_LOG, message);
+        ERRORA
+          ("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n",
+           SKYPIAX_P_LOG, message);
         tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
         DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
         tech_pvt->skype_call_id[0] = '\0';
@@ -141,7 +142,7 @@
           char msg_to_skype[256];
           DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n",
                        SKYPIAX_P_LOG, message, obj, id, prop);
-            //TODO: authomatically flag messages as read based on config param
+          //TODO: authomatically flag messages as read based on config param
           sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
           skypiax_skype_write(tech_pvt, msg_to_skype);
         }
@@ -207,7 +208,7 @@
             char msg_to_skype[1024];
             if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
               /* we are not calling out */
-              if (!strlen(tech_pvt->skype_call_id)) { 
+              if (!strlen(tech_pvt->skype_call_id)) {
                 /* we are not inside an active call */
                 tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
                 tech_pvt->interface_state = SKYPIAX_STATE_RING;
@@ -229,24 +230,30 @@
                 strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
               } else {
                 /* we're owned, we're in a call, let's try to transfer */
-		/************************** TODO
+        /************************** TODO
 		 Checking here if it is possible to transfer this call to Test2
 		 -> GET CALL 288 CAN_TRANSFER Test2
 		 <- CALL 288 CAN_TRANSFER test2 TRUE
 		**********************************/
 
-		private_t *available_skypiax_interface;
+                private_t *available_skypiax_interface;
 
-		available_skypiax_interface = find_available_skypiax_interface();
-		if(available_skypiax_interface){
-			/* there is a skypiax interface idle, let's transfer the call to it */
-                DEBUGA_SKYPE ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id);
-                sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypiax_interface->name);
-		} else{
-			/* no skypiax interfaces idle, let's refuse the call */
-                DEBUGA_SKYPE ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
-                sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
-		}
+                available_skypiax_interface = find_available_skypiax_interface();
+                if (available_skypiax_interface) {
+                  /* there is a skypiax interface idle, let's transfer the call to it */
+                  DEBUGA_SKYPE
+                    ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n",
+                     SKYPIAX_P_LOG, tech_pvt->skype_call_id,
+                     available_skypiax_interface->name, id);
+                  sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id,
+                          available_skypiax_interface->name);
+                } else {
+                  /* no skypiax interfaces idle, let's refuse the call */
+                  DEBUGA_SKYPE
+                    ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n",
+                     SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+                  sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+                }
                 skypiax_skype_write(tech_pvt, msg_to_skype);
                 skypiax_sleep(10000);
                 DEBUGA_SKYPE
@@ -268,22 +275,23 @@
                          SKYPIAX_P_LOG, id);
           } else if (!strcasecmp(value, "MISSED")) {
             DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
-	  } else if (!strcasecmp(value, "FINISHED")) {
-		  DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
-		  if(!strcasecmp(tech_pvt->skype_call_id, id)){
-			  DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id);
-			  tech_pvt->skype_call_id[0] = '\0';
-			  if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
-				  //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-				  return CALLFLOW_INCOMING_HANGUP;
-			  } else {
-				  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-			  }	    
-		  }else {
-			  DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id);
-		  }
+          } else if (!strcasecmp(value, "FINISHED")) {
+            DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+            if (!strcasecmp(tech_pvt->skype_call_id, id)) {
+              DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n",
+                           SKYPIAX_P_LOG, id);
+              tech_pvt->skype_call_id[0] = '\0';
+              if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+                return CALLFLOW_INCOMING_HANGUP;
+              } else {
+                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+              }
+            } else {
+              DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id);
+            }
 
-	  } else if (!strcasecmp(value, "CANCELLED")) {
+          } else if (!strcasecmp(value, "CANCELLED")) {
             tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
             DEBUGA_SKYPE
               ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
@@ -329,33 +337,35 @@
             tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
             strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
             DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
-	  } else if (!strcasecmp(value, "INPROGRESS")) {
-		  char msg_to_skype[1024];
+          } else if (!strcasecmp(value, "INPROGRESS")) {
+            char msg_to_skype[1024];
 
-		  if(!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) || !strcasecmp(tech_pvt->skype_call_id, id)){
-			  tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-			  strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
-			  tech_pvt->interface_state = SKYPIAX_STATE_UP;
-			  DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
-			  sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
-					  tech_pvt->tcp_cli_port);
-			  skypiax_skype_write(tech_pvt, msg_to_skype);
-			  start_audio_threads(tech_pvt);
-			  sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
-					  tech_pvt->tcp_srv_port);
-			  skypiax_skype_write(tech_pvt, msg_to_skype);
-			  tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
-			  if (!strlen(tech_pvt->session_uuid_str)) {
-				  DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
-				  new_inbound_channel(tech_pvt);
-			  } else {
-				  DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
-				  outbound_channel_answered(tech_pvt);
-			  }
-		  }else {
-			  DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
-		  }
-	  } else {
+            if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id)
+                || !strcasecmp(tech_pvt->skype_call_id, id)) {
+              tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+              strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+              tech_pvt->interface_state = SKYPIAX_STATE_UP;
+              DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
+              sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+                      tech_pvt->tcp_cli_port);
+              skypiax_skype_write(tech_pvt, msg_to_skype);
+              start_audio_threads(tech_pvt);
+              sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+                      tech_pvt->tcp_srv_port);
+              skypiax_skype_write(tech_pvt, msg_to_skype);
+              tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
+              if (!strlen(tech_pvt->session_uuid_str)) {
+                DEBUGA_SKYPE("New Inbound Channel!\n", SKYPIAX_P_LOG);
+                new_inbound_channel(tech_pvt);
+              } else {
+                DEBUGA_SKYPE("Outbound Channel Answered!\n", SKYPIAX_P_LOG);
+                outbound_channel_answered(tech_pvt);
+              }
+            } else {
+              DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n",
+                           SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+            }
+          } else {
             WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
                      value);
           }
@@ -495,7 +505,7 @@
                                  SAMPLES_PER_FRAME * sizeof(short));
             if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
               ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG, howmany,
-                     (int)(SAMPLES_PER_FRAME * sizeof(short)));
+                     (int) (SAMPLES_PER_FRAME * sizeof(short)));
             }
             /* done with the stored half frame */
             tech_pvt->audiobuf_is_loaded = 0;
@@ -593,7 +603,7 @@
       if (!running)
         break;
       FD_ZERO(&fs);
-      to.tv_usec = 60000;  //60msec
+      to.tv_usec = 60000;       //60msec
       to.tv_sec = 0;
 #if defined(WIN32) && !defined(__CYGWIN__)
 /* on win32 we cannot select from the apr "pipe", so we select on socket writability */
@@ -609,7 +619,6 @@
       rt = select(fdselect + 1, &fs, NULL, NULL, &to);
 #endif
 
-
       if (rt > 0) {
         /* read from the pipe the audio frame we are supposed to send out */
         got =
@@ -617,7 +626,7 @@
                             SAMPLES_PER_FRAME * sizeof(short));
         if (got != SAMPLES_PER_FRAME * sizeof(short)) {
           WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
-                   (int)(SAMPLES_PER_FRAME * sizeof(short)));
+                   (int) (SAMPLES_PER_FRAME * sizeof(short)));
         }
 
         if (got == SAMPLES_PER_FRAME * sizeof(short)) {
@@ -641,9 +650,9 @@
             ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
           }
 
-          /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party*/
+          /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
           len = send(fd, (char *) cli_out, got, 0);
-	  skypiax_sleep(5000); //5 msec
+          skypiax_sleep(5000);  //5 msec
 
           if (len == -1) {
             break;
@@ -656,15 +665,15 @@
         } else {
 
           WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
-                   (int)(SAMPLES_PER_FRAME * sizeof(short)));
+                   (int) (SAMPLES_PER_FRAME * sizeof(short)));
         }
       } else {
         if (rt)
           ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);
-	  memset(cli_out, 0, sizeof(cli_out));
-          len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
-          len = send(fd, (char *) cli_out, sizeof(cli_out)/2, 0);
-          //DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
+        memset(cli_out, 0, sizeof(cli_out));
+        len = send(fd, (char *) cli_out, sizeof(cli_out), 0);
+        len = send(fd, (char *) cli_out, sizeof(cli_out) / 2, 0);
+        //DEBUGA_SKYPE("sent %d of zeros to keep the Skype client socket busy\n", SKYPIAX_P_LOG, sizeof(cli_out) + sizeof(cli_out)/2);
       }
 
     }
@@ -689,7 +698,7 @@
   if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
     if (samples)
       WARNINGA("read samples=%u expected=%u\n", SKYPIAX_P_LOG, samples,
-               (int)(SAMPLES_PER_FRAME * sizeof(short)));
+               (int) (SAMPLES_PER_FRAME * sizeof(short)));
     return 0;
   } else {
     /* A real frame */



More information about the Freeswitch-branches mailing list