[Freeswitch-svn] [commit] r11119 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Sun Jan 11 04:13:49 PST 2009


Author: gmaruzz
Date: Sun Jan 11 06:13:49 2009
New Revision: 11119

Log:
skypiax: no more skypiax_interface pointers, only private_t pointers

Modified:
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Sun Jan 11 06:13:49 2009
@@ -19,7 +19,7 @@
   int fd;
   int calls;
   char hold_music[256];
-  skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
+  private_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
   switch_mutex_t *mutex;
 } globals;
 
@@ -56,7 +56,6 @@
 
 static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
 {
-  skypiax_interface_t *p = NULL;
   if (switch_core_codec_init
       (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
        SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
@@ -84,8 +83,7 @@
 
 }
 
-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session,
-                       skypiax_interface_t * p)
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session)
 {
 
   DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -97,13 +95,8 @@
                     switch_core_session_get_pool(session));
   switch_core_session_set_private(session, tech_pvt);
   tech_pvt->session = session;
-  if (p) {
-    tech_pvt->p = p;
-    p->tech_pvt = tech_pvt;
-
-  }
   if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
-    ERRORA("skypiax_docec FAILED\n", SKYPIAX_P_LOG);
+    ERRORA("skypiax_codec FAILED\n", SKYPIAX_P_LOG);
   } else {
     DEBUGA_SKYPE("skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
   }
@@ -120,7 +113,6 @@
 {
   switch_channel_t *channel;
   private_t *tech_pvt = NULL;
-  skypiax_interface_t *p = NULL;
 
   tech_pvt = switch_core_session_get_private(session);
   assert(tech_pvt != NULL);
@@ -146,7 +138,6 @@
 {
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
-  skypiax_interface_t *p = NULL;
   char msg_to_skype[256];
 
   channel = switch_core_session_get_channel(session);
@@ -155,17 +146,16 @@
   tech_pvt = switch_core_session_get_private(session);
   assert(tech_pvt != NULL);
 
-  p = tech_pvt->p;
 
   switch_clear_flag_locked(tech_pvt, TFLAG_IO);
   switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
   //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
 
-  if (strlen(p->skype_call_id)) {
+  if (strlen(tech_pvt->skype_call_id)) {
     //switch_thread_cond_signal(tech_pvt->cond);
-    WARNINGA("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id);
-    sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id);
-    skypiax_skype_write(p, msg_to_skype);
+    WARNINGA("hanging up skype call: %s\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id);
+    sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id);
+    skypiax_skype_write(tech_pvt, msg_to_skype);
   }
 
   if (tech_pvt->read_codec.implementation) {
@@ -191,7 +181,6 @@
 {
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
-  skypiax_interface_t *p = NULL;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -209,7 +198,6 @@
 
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
-  skypiax_interface_t *p = NULL;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -226,7 +214,6 @@
 {
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
-  skypiax_interface_t *p = NULL;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -256,14 +243,14 @@
 
 static switch_status_t channel_on_exchange_media(switch_core_session_t * session)
 {
-  skypiax_interface_t *p = NULL;
+  private_t *tech_pvt = NULL;
   DEBUGA_SKYPE("CHANNEL LOOPBACK\n", SKYPIAX_P_LOG);
   return SWITCH_STATUS_SUCCESS;
 }
 
 static switch_status_t channel_on_soft_execute(switch_core_session_t * session)
 {
-  skypiax_interface_t *p = NULL;
+  private_t *tech_pvt = NULL;
   DEBUGA_SKYPE("CHANNEL TRANSMIT\n", SKYPIAX_P_LOG);
   return SWITCH_STATUS_SUCCESS;
 }
@@ -271,15 +258,12 @@
 static switch_status_t channel_send_dtmf(switch_core_session_t * session,
                                          const switch_dtmf_t * dtmf)
 {
-  skypiax_interface_t *p = NULL;
   private_t *tech_pvt = switch_core_session_get_private(session);
   switch_assert(tech_pvt != NULL);
 
-  p = tech_pvt->p;
-
   NOTICA("DTMF: %c\n", SKYPIAX_P_LOG, dtmf->digit);
 
-  skypiax_skype_senddigit(p, dtmf->digit);
+  skypiax_skype_senddigit(tech_pvt, dtmf->digit);
 
   return SWITCH_STATUS_SUCCESS;
 }
@@ -291,7 +275,6 @@
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
   switch_byte_t *data;
-  skypiax_interface_t *p = NULL;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -362,7 +345,6 @@
   switch_channel_t *channel = NULL;
   private_t *tech_pvt = NULL;
   unsigned int sent;
-  struct skypiax_interface *p = NULL;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -370,8 +352,6 @@
   tech_pvt = switch_core_session_get_private(session);
   assert(tech_pvt != NULL);
 
-  p = tech_pvt->p;
-  assert(p != NULL);
 
   if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
     ERRORA("CIAPA \n", SKYPIAX_P_LOG);
@@ -385,9 +365,9 @@
 
   sent = frame->datalen;
 #ifdef WIN32
-  switch_file_write(p->audioskypepipe[1], frame->data, &sent);
+  switch_file_write(tech_pvt->audioskypepipe[1], frame->data, &sent);
 #else /* WIN32 */
-  sent = write(p->audioskypepipe[1], frame->data, sent);
+  sent = write(tech_pvt->audioskypepipe[1], frame->data, sent);
 #endif /* WIN32 */
   if (sent != frame->datalen && sent != -1) {
     DEBUGA_SKYPE("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
@@ -400,7 +380,6 @@
 {
   private_t *tech_pvt;
   switch_channel_t *channel = NULL;
-  struct skypiax_interface *p;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -408,7 +387,6 @@
   tech_pvt = switch_core_session_get_private(session);
   assert(tech_pvt != NULL);
 
-  p = tech_pvt->p;
 
   DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG);
 
@@ -420,7 +398,6 @@
 {
   switch_channel_t *channel;
   private_t *tech_pvt;
-  struct skypiax_interface *p;
 
   channel = switch_core_session_get_channel(session);
   assert(channel != NULL);
@@ -428,7 +405,6 @@
   tech_pvt = (private_t *) switch_core_session_get_private(session);
   assert(tech_pvt != NULL);
 
-  p = tech_pvt->p;
 
   switch (msg->message_id) {
   case SWITCH_MESSAGE_INDICATE_ANSWER:
@@ -452,7 +428,6 @@
 {
   struct private_object *tech_pvt = switch_core_session_get_private(session);
   char *body = switch_event_get_body(event);
-  skypiax_interface_t *p = NULL;
   switch_assert(tech_pvt != NULL);
 
   if (!body) {
@@ -495,7 +470,6 @@
     private_t *tech_pvt;
     switch_channel_t *channel;
     switch_caller_profile_t *caller_profile;
-    skypiax_interface_t *p = NULL;
 
     switch_core_session_add_stream(*new_session, NULL);
 
@@ -522,8 +496,8 @@
 
             DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG,
                          i, globals.SKYPIAX_INTERFACES[i].name);
-            tech_pvt->p = &globals.SKYPIAX_INTERFACES[i];   //FIXME
-            globals.SKYPIAX_INTERFACES[i].tech_pvt = tech_pvt;  //FIXME
+            tech_pvt = &globals.SKYPIAX_INTERFACES[i];   //FIXME
+            //globals.SKYPIAX_INTERFACES[i].tech_pvt = tech_pvt;  //FIXME
             found = 1;
             break;
           }
@@ -544,7 +518,7 @@
 
       }
       channel = switch_core_session_get_channel(*new_session);
-      skypiax_tech_init(tech_pvt, *new_session, NULL);
+      skypiax_tech_init(tech_pvt, *new_session);
     } else {
       ERRORA("Hey where is my memory pool?\n", SKYPIAX_P_LOG);
       switch_core_session_destroy(new_session);
@@ -555,7 +529,7 @@
       char name[128];
 
       snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
-      //snprintf(name, sizeof(name), "skypiax/%s", p->name);
+      //snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
       switch_channel_set_name(channel, name);
       NOTICA("outbound_profile->destination_number=|||%s|||\n", SKYPIAX_P_LOG,
              outbound_profile->destination_number);
@@ -575,7 +549,7 @@
       return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
     }
 
-    skypiax_skype_call(tech_pvt->p, caller_profile->destination_number, 30, *new_session);
+    skypiax_skype_call(tech_pvt, caller_profile->destination_number, 30, *new_session);
 
     switch_channel_set_flag(channel, CF_OUTBOUND);
     switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
@@ -593,27 +567,26 @@
 static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t * thread,
                                                              void *obj)
 {
-  struct skypiax_interface *p = obj;
+  private_t *tech_pvt = obj;
   int res;
   int forever = 1;
 
   DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
 
   DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG,
-               (void *) p);
+               (void *) tech_pvt);
 
   while (forever) {
     if (!running)
       break;
-    res = skypiax_skype_read(p);
+    res = skypiax_skype_read(tech_pvt);
     if (res == CALLFLOW_INCOMING_HANGUP) {
       switch_core_session_t *session = NULL;
-      private_t *tech_pvt = NULL;
+      //private_t *tech_pvt = NULL;
       switch_channel_t *channel = NULL;
 
       DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
 
-      tech_pvt = p->tech_pvt;
       if (tech_pvt) {
         session = tech_pvt->session;
 
@@ -630,7 +603,7 @@
       } else {
         ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
       }
-      p->interface_state = SKYPIAX_STATE_DOWN;
+      tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
       tech_pvt->session = NULL; //FIXME
     }
   }
@@ -642,7 +615,7 @@
 {
   char *cf = "skypiax.conf";
   switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
-  skypiax_interface_t *p = NULL;
+  private_t *tech_pvt = NULL;
 
   switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
   if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
@@ -819,7 +792,7 @@
 #endif /* WIN32 */
 
       if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
-        struct skypiax_interface newconf;
+        private_t newconf;
         switch_threadattr_t *do_skype_thd_attr = NULL;
         switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL;
 
@@ -943,7 +916,7 @@
 
 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
 {
-  struct skypiax_interface *p = NULL;   //for logging
+  private_t *tech_pvt = NULL;   //for logging
 
   skypiax_module_pool = pool;
 
@@ -966,7 +939,7 @@
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown)
 {
   int x = 100;
-  struct skypiax_interface *p = NULL;
+  private_t *tech_pvt = NULL;
   switch_status_t status;
   unsigned int howmany = 8;
   int interface_id;
@@ -974,34 +947,34 @@
   running = 0;
 
   for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
-    p = &globals.SKYPIAX_INTERFACES[interface_id];
+    tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
 
     if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread) {
 #ifdef WIN32
-      switch_file_write(p->SkypiaxHandles.fdesc[1], "sciutati", &howmany);  // let's the controldev_thread die
+      switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", &howmany);  // let's the controldev_thread die
 #else /* WIN32 */
-      howmany = write(p->SkypiaxHandles.fdesc[1], "sciutati", howmany);
+      howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", howmany);
 #endif /* WIN32 */
     }
 
     if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread) {
 #ifdef WIN32
-      if (SendMessage(p->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die
+      if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die
         ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError());
       }
 #else
       XEvent e;
       Atom atom1 =
-        XInternAtom(p->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+        XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
       memset(&e, 0, sizeof(e));
       e.xclient.type = ClientMessage;
       e.xclient.message_type = atom1;   /*  leading message */
-      e.xclient.display = p->SkypiaxHandles.disp;
-      e.xclient.window = p->SkypiaxHandles.skype_win;
+      e.xclient.display = tech_pvt->SkypiaxHandles.disp;
+      e.xclient.window = tech_pvt->SkypiaxHandles.skype_win;
       e.xclient.format = 8;
 
-      XSendEvent(p->SkypiaxHandles.disp, p->SkypiaxHandles.win, False, 0, &e);
-      XSync(p->SkypiaxHandles.disp, False);
+      XSendEvent(tech_pvt->SkypiaxHandles.disp, tech_pvt->SkypiaxHandles.win, False, 0, &e);
+      XSync(tech_pvt->SkypiaxHandles.disp, False);
 #endif
     }
     while (x) {

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h	Sun Jan 11 06:13:49 2009
@@ -79,7 +79,7 @@
 #define WARNINGA(...)  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, 		"rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA  %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
 #define NOTICA(...)  switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, 		"rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA  %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
 
-#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
+#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", -1, tech_pvt ? tech_pvt->interface_state : -1, tech_pvt ? tech_pvt->skype_callflow : -1
 
 /*********************************/
 #define SKYPIAX_CAUSE_NORMAL		1
@@ -154,7 +154,8 @@
 
 #endif //WIN32
 
-struct skypiax_interface {
+#if 0
+private_t {
   char interface_id[80];
   char name[80];
   char dialplan[80];
@@ -221,7 +222,8 @@
   char skype_password[256];
 };
 
-typedef struct skypiax_interface skypiax_interface_t;
+typedef private_t private_t;
+#endif
 
 struct private_object {
   unsigned int flags;
@@ -233,20 +235,88 @@
   switch_caller_profile_t *caller_profile;
   switch_mutex_t *mutex;
   switch_mutex_t *flag_mutex;
-  skypiax_interface_t *p;
+  //private_t *p;
   //switch_thread_cond_t *cond;
+
+  char interface_id[80];
+  char name[80];
+  char dialplan[80];
+  char context[80];
+  char dial_regex[256];
+  char fail_dial_regex[256];
+  char hold_music[256];
+  char type[256];
+  char X11_display[256];
+#ifdef WIN32
+  unsigned short tcp_cli_port;
+  unsigned short tcp_srv_port;
+#else
+  int tcp_cli_port;
+  int tcp_srv_port;
+#endif
+  struct SkypiaxHandles SkypiaxHandles;
+
+  int interface_state;          /*!< \brief 'state' of the interface (channel) */
+  char language[80];            /*!< \brief default Asterisk dialplan language for this interface */
+  char exten[80];               /*!< \brief default Asterisk dialplan extension for this interface */
+  int skypiax_sound_rate;       /*!< \brief rate of the sound device, in Hz, eg: 8000 */
+  switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
+  char callid_name[50];
+  char callid_number[50];
+  double playback_boost;
+  double capture_boost;
+  int stripmsd;
+  switch_thread_t *skype_thread;
+  char skype_call_id[512];
+  int skype_call_ongoing;
+  char skype_friends[4096];
+  char skype_fullname[512];
+  char skype_displayname[512];
+  int skype_callflow;           /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
+  int skype;                    /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
+  int control_to_send;
+#ifdef WIN32
+  switch_file_t *audiopipe[2];
+  switch_file_t *audioskypepipe[2];
+#else                           /* WIN32 */
+  int audiopipe[2];
+  int audioskypepipe[2];
+#endif                          /* WIN32 */
+  switch_thread_t *tcp_srv_thread;
+  switch_thread_t *tcp_cli_thread;
+  switch_thread_t *skypiax_do_controldev_thread_thread;
+  switch_thread_t *skypiax_do_skype_thread_thread;
+  short audiobuf[SAMPLES_PER_FRAME];
+  int audiobuf_is_loaded;
+
+  //int phonebook_listing;
+  //int phonebook_querying;
+  //int phonebook_listing_received_calls;
+
+  //int phonebook_first_entry;
+  //int phonebook_last_entry;
+  //int phonebook_number_lenght;
+  //int phonebook_text_lenght;
+  FILE *phonebook_writing_fp;
+  int skypiax_dir_entry_extension_prefix;
+  //void *tech_pvt;
+  char skype_user[256];
+  char skype_password[256];
+
+
+
+
 };
 
 typedef struct private_object private_t;
 
 void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj);
-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session,
-                       skypiax_interface_t * p);
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session);
 switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt);
-int skypiax_skypeaudio_init(struct skypiax_interface *p);
-int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype);
-int skypiax_skype_read(struct skypiax_interface *p);
+int skypiax_skypeaudio_init(private_t *p);
+int skypiax_skype_write(private_t *p, char *msg_to_skype);
+int skypiax_skype_read(private_t *p);
 
-int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
+int skypiax_skype_call(private_t *p, char *idest, int timeout,
                        switch_core_session_t * session);
-int skypiax_skype_senddigit(struct skypiax_interface *p, char digit);
+int skypiax_skype_senddigit(private_t *p, char digit);

Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	Sun Jan 11 06:13:49 2009
@@ -8,7 +8,7 @@
 static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
                                                           void *obj)
 {
-  struct skypiax_interface *p = obj;
+  private_t *tech_pvt = obj;
   int s;
 #ifdef WIN32
   unsigned int len;
@@ -40,7 +40,7 @@
   memset(&my_addr, 0, sizeof(my_addr));
   my_addr.sin_family = AF_INET;
   my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
-  my_addr.sin_port = htons(p->tcp_srv_port);
+  my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
     ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -66,9 +66,9 @@
     DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
     if (!running)
       break;
-    while (p->interface_state != SKYPIAX_STATE_DOWN
-           && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
-               || p->skype_callflow == SKYPIAX_STATE_UP)) {
+    while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+           && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+               || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
 
 #ifdef WIN32
       unsigned int fdselect;
@@ -108,6 +108,8 @@
 
         if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
 
+  ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]);
+  ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]);
           if (len > 0) {
             a = 0;
             for (i = 0; i < len / sizeof(short); i++) {
@@ -116,17 +118,17 @@
               a++;
             }
 
-            if (!p->audiobuf_is_loaded) {
+            if (!tech_pvt->audiobuf_is_loaded) {
               for (i = 0; i < (len / sizeof(short)) / 2; i++) {
-                p->audiobuf[i] = srv_out[i];
+                tech_pvt->audiobuf[i] = srv_out[i];
               }
-              p->audiobuf_is_loaded = 1;
+              tech_pvt->audiobuf_is_loaded = 1;
             } else {
               unsigned int howmany;
 
               howmany = len / 2 / 2;
               for (i = 0; i < howmany; i++)
-                totalbuf[i] = p->audiobuf[i];
+                totalbuf[i] = tech_pvt->audiobuf[i];
 
               howmany = len / 2 / 2;
               for (a = 0; a < howmany; a++) {
@@ -137,11 +139,11 @@
               howmany = len;
 
 #ifdef WIN32
-              switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+              switch_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany);
 #else /* WIN32 */
-              howmany = write(p->audiopipe[1], totalbuf, howmany);
+              howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany);
 #endif /* WIN32 */
-              p->audiobuf_is_loaded = 0;
+              tech_pvt->audiobuf_is_loaded = 0;
             }
 
           } else if (len == 0) {
@@ -154,38 +156,40 @@
           }
         } else if (SAMPLERATE_SKYPIAX == 16000) {
 
+  //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]);
+  //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]);
           if (len > 0) {
             if (len == SAMPLES_PER_FRAME * sizeof(short)) {
 #ifdef WIN32
               unsigned int howmany;
 
               howmany = len;
-              switch_file_write(p->audiopipe[1], srv_in, &howmany);
+              switch_file_write(tech_pvt->audiopipe[1], srv_in, &howmany);
 #else /* WIN32 */
-              len = write(p->audiopipe[1], srv_in, len);
+              len = write(tech_pvt->audiopipe[1], srv_in, len);
 #endif /* WIN32 */
             } else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
-              if (!p->audiobuf_is_loaded) {
+              if (!tech_pvt->audiobuf_is_loaded) {
                 for (i = 0; i < (len / sizeof(short)); i++) {
-                  p->audiobuf[i] = srv_in[i];
+                  tech_pvt->audiobuf[i] = srv_in[i];
                 }
-                p->audiobuf_is_loaded = 1;
+                tech_pvt->audiobuf_is_loaded = 1;
               } else {
                 unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short);
 
                 for (i = 0; i < (len / sizeof(short)); i++)
-                  totalbuf[i] = p->audiobuf[i];
+                  totalbuf[i] = tech_pvt->audiobuf[i];
                 for (a = 0; a < (len / sizeof(short)); a++) {
                   totalbuf[i] = srv_in[a];
                   i++;
                 }
 
 #ifdef WIN32
-                switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+                switch_file_write(tech_pvt->audiopipe[1], totalbuf, &howmany);
 #else /* WIN32 */
-                howmany = write(p->audiopipe[1], totalbuf, howmany);
+                howmany = write(tech_pvt->audiopipe[1], totalbuf, howmany);
 #endif /* WIN32 */
-                p->audiobuf_is_loaded = 0;
+                tech_pvt->audiobuf_is_loaded = 0;
               }
 
             } else {
@@ -212,24 +216,24 @@
     }
 #ifdef WIN32
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
+    switch_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size);
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
-    p->interface_state = SKYPIAX_STATE_DOWN;
+    switch_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
+    tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
+    switch_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size);
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
+    switch_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
 #else /* WIN32 */
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(p->audiopipe[1], kill_cli_buff, kill_cli_size);
+    len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(p->audioskypepipe[1], kill_cli_buff, kill_cli_size);
-    p->interface_state = SKYPIAX_STATE_DOWN;
+    len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
+    tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(p->audiopipe[1], kill_cli_buff, kill_cli_size);
+    len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(p->audioskypepipe[1], kill_cli_buff, kill_cli_size);
+    len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
 #endif /* WIN32 */
     DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
 #ifndef WIN32
@@ -255,7 +259,7 @@
 static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
                                                           void *obj)
 {
-  struct skypiax_interface *p = obj;
+  private_t *tech_pvt = obj;
   int s;
   struct sockaddr_in my_addr;
   struct sockaddr_in remote_addr;
@@ -284,7 +288,7 @@
   memset(&my_addr, 0, sizeof(my_addr));
   my_addr.sin_family = AF_INET;
   my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
-  my_addr.sin_port = htons(p->tcp_cli_port);    //FIXME configurable!
+  my_addr.sin_port = htons(tech_pvt->tcp_cli_port);    //FIXME configurable!
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
     ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -315,9 +319,9 @@
     DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
     if (!running)
       break;
-    while (p->interface_state != SKYPIAX_STATE_DOWN
-           && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
-               || p->skype_callflow == SKYPIAX_STATE_UP)) {
+    while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
+           && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+               || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
 #ifdef WIN32
       unsigned int fdselect;
 #else
@@ -332,7 +336,7 @@
 #ifdef WIN32
       fdselect = fd;            //cannot select on audioskypepipe, let's select on socket write
 #else /* WIN32 */
-      fdselect = p->audioskypepipe[0];
+      fdselect = tech_pvt->audioskypepipe[0];
 #endif /* WIN32 */
       FD_ZERO(&fs);
       FD_SET(fdselect, &fs);
@@ -348,9 +352,9 @@
         if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
           got = SAMPLES_PER_FRAME * sizeof(short);
 #ifdef WIN32
-          switch_file_read(p->audioskypepipe[0], cli_in, &got);
+          switch_file_read(tech_pvt->audioskypepipe[0], cli_in, &got);
 #else /* WIN32 */
-          got = read(p->audioskypepipe[0], cli_in, got);
+          got = read(tech_pvt->audioskypepipe[0], cli_in, got);
 #endif /* WIN32 */
 
           if (got > 0) {
@@ -378,9 +382,9 @@
         } else if (SAMPLERATE_SKYPIAX == 16000) {
           got = SAMPLES_PER_FRAME * sizeof(short);
 #ifdef WIN32
-          switch_file_read(p->audioskypepipe[0], cli_in, &got);
+          switch_file_read(tech_pvt->audioskypepipe[0], cli_in, &got);
 #else /* WIN32 */
-          got = read(p->audioskypepipe[0], cli_in, got);
+          got = read(tech_pvt->audioskypepipe[0], cli_in, got);
 #endif /* WIN32 */
 
           if (got > 0) {
@@ -434,25 +438,29 @@
   return NULL;
 }
 
-int skypiax_skypeaudio_init(struct skypiax_interface *p)
+int skypiax_skypeaudio_init(private_t *tech_pvt)
 {
 
 #ifdef WIN32
   switch_status_t rv;
-  rv = switch_file_pipe_create(&p->audiopipe[0], &p->audiopipe[1], skypiax_module_pool);
+  rv = switch_file_pipe_create(&tech_pvt->audiopipe[0], &tech_pvt->audiopipe[1], skypiax_module_pool);
   rv =
-    switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1],
+    switch_file_pipe_create(&tech_pvt->audioskypepipe[0], &tech_pvt->audioskypepipe[1],
                             skypiax_module_pool);
 #else /* WIN32 */
-  if (pipe(p->audiopipe)) {
-    fcntl(p->audiopipe[0], F_SETFL, O_NONBLOCK);
-    fcntl(p->audiopipe[1], F_SETFL, O_NONBLOCK);
-  }
-  if (pipe(p->audioskypepipe)) {
-    fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
-    fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
+  if (pipe(tech_pvt->audiopipe)) {
+    fcntl(tech_pvt->audiopipe[0], F_SETFL, O_NONBLOCK);
+    fcntl(tech_pvt->audiopipe[1], F_SETFL, O_NONBLOCK);
+  }
+  if (pipe(tech_pvt->audioskypepipe)) {
+    fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
+    fcntl(tech_pvt->audioskypepipe[1], F_SETFL, O_NONBLOCK);
   }
 #endif /* WIN32 */
+
+  ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]);
+  ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]);
+
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
   }
@@ -461,7 +469,7 @@
 
 switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
 {
-  struct skypiax_interface *p;
+  //private_t *p;
   unsigned int samples;
   int rt;
 #ifndef WIN32
@@ -470,11 +478,10 @@
   struct timeval to;
 #endif /* WIN32 */
 
-  p = tech_pvt->p;
 #ifdef WIN32
   rt = 1;
 #else /* WIN32 */
-  fdselect = p->audiopipe[0];
+  fdselect = tech_pvt->audiopipe[0];
   FD_ZERO(&fs);
   FD_SET(fdselect, &fs);
   to.tv_usec = 2000000;         //2000 msec
@@ -484,15 +491,18 @@
   if (rt > 0) {
     samples = SAMPLES_PER_FRAME * sizeof(short);
 #ifdef WIN32
-    switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
+    switch_file_read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, &samples);
 #else /* WIN32 */
-    samples = read(p->audiopipe[0], tech_pvt->read_frame.data, samples);
+    samples = read(tech_pvt->audiopipe[0], tech_pvt->read_frame.data, samples);
 #endif /* WIN32 */
 
+  //ERRORA("tech_pvt->audiopipe[0] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[0]);
+  //ERRORA("tech_pvt->audiopipe[1] = %d\n", SKYPIAX_P_LOG, tech_pvt->audiopipe[1]);
     if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
       if (samples)
         ERRORA("SRV PIPE READ=====> NOT GOOD samples=%u expected=%lu\n", SKYPIAX_P_LOG,
                samples, SAMPLES_PER_FRAME * sizeof(short));
+      assert(samples == SAMPLES_PER_FRAME * sizeof(short)); //do a crash, please
       //do nothing
     } else {
       /* A real frame */
@@ -554,24 +564,24 @@
 {
   LRESULT lReturnCode;
   int fIssueDefProc;
-  struct skypiax_interface *p = NULL;
+  //private_t *p = NULL;
 
   lReturnCode = 0;
   fIssueDefProc = 0;
-  p = (struct skypiax_interface *) GetWindowLong(hWindow, GWL_USERDATA);
+  tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
   switch (uiMessage) {
   case WM_CREATE:
-    p = (struct skypiax_interface *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
+    tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
     SetWindowLong(hWindow, GWL_USERDATA, (LONG) p);
     DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
     break;
   case WM_DESTROY:
     NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
-    p->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
+    tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
     PostQuitMessage(0);
     break;
   case WM_COPYDATA:
-    if (p->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+    if (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
       unsigned int howmany;
       char msg_from_skype[2048];
 
@@ -582,21 +592,21 @@
               sizeof(msg_from_skype) - 2);
 
       howmany = strlen(msg_from_skype) + 1;
-      switch_file_write(p->SkypiaxHandles.fdesc[1], msg_from_skype, &howmany);
+      switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], msg_from_skype, &howmany);
       //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
       lReturnCode = 1;
     }
     break;
   default:
-    if (p && p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
-      if (uiMessage == p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+    if (p && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+      if (uiMessage == tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
         switch (ulParam) {
         case SKYPECONTROLAPI_ATTACH_SUCCESS:
-          if (!p->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.api_connected) {
             NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
-            p->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
-            p->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
-              p->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
+            tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+            tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
+              tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
           }
           break;
         case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
@@ -604,11 +614,11 @@
             ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
              SKYPIAX_P_LOG);
           switch_sleep(5000);
-          if (!p->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.api_connected) {
             SendMessage(HWND_BROADCAST,
-                        p->SkypiaxHandles.
+                        tech_pvt->SkypiaxHandles.
                         win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-                        (WPARAM) p->SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
+                        (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
           }
           break;
         case SKYPECONTROLAPI_ATTACH_REFUSED:
@@ -620,11 +630,11 @@
         case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
           DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
           switch_sleep(5000);
-          if (!p->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.api_connected) {
             SendMessage(HWND_BROADCAST,
-                        p->SkypiaxHandles.
+                        tech_pvt->SkypiaxHandles.
                         win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-                        (WPARAM) p->SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
+                        (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0);
           }
           break;
         default:
@@ -642,7 +652,7 @@
   return (lReturnCode);
 }
 
-int win32_Initialize_CreateWindowClass(struct skypiax_interface *p)
+int win32_Initialize_CreateWindowClass(private_t *tech_pvt)
 {
   unsigned char *paucUUIDString;
   RPC_STATUS lUUIDResult;
@@ -651,26 +661,26 @@
 
   fReturnStatus = 0;
   lUUIDResult = UuidCreate(&oUUID);
-  p->SkypiaxHandles.win32_hInit_ProcessHandle =
+  tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle =
     (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
-  if (p->SkypiaxHandles.win32_hInit_ProcessHandle != NULL
+  if (tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle != NULL
       && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
     if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
       WNDCLASS oWindowClass;
 
-      strcpy(p->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-");
-      strcat(p->SkypiaxHandles.win32_acInit_WindowClassName, (char *) paucUUIDString);
+      strcpy(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "Skype-API-Skypiax-");
+      strcat(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, (char *) paucUUIDString);
 
       oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
       oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
       oWindowClass.cbClsExtra = 0;
       oWindowClass.cbWndExtra = 0;
-      oWindowClass.hInstance = p->SkypiaxHandles.win32_hInit_ProcessHandle;
+      oWindowClass.hInstance = tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle;
       oWindowClass.hIcon = NULL;
       oWindowClass.hCursor = NULL;
       oWindowClass.hbrBackground = NULL;
       oWindowClass.lpszMenuName = NULL;
-      oWindowClass.lpszClassName = p->SkypiaxHandles.win32_acInit_WindowClassName;
+      oWindowClass.lpszClassName = tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName;
 
       if (RegisterClass(&oWindowClass) != 0)
         fReturnStatus = 1;
@@ -679,34 +689,34 @@
     }
   }
   if (fReturnStatus == 0)
-    CloseHandle(p->SkypiaxHandles.win32_hInit_ProcessHandle),
-      p->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
+    CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
+      tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
   return (fReturnStatus);
 }
 
-void win32_DeInitialize_DestroyWindowClass(struct skypiax_interface *p)
+void win32_DeInitialize_DestroyWindowClass(private_t *tech_pvt)
 {
-  UnregisterClass(p->SkypiaxHandles.win32_acInit_WindowClassName,
-                  p->SkypiaxHandles.win32_hInit_ProcessHandle);
-  CloseHandle(p->SkypiaxHandles.win32_hInit_ProcessHandle),
-    p->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
+  UnregisterClass(tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName,
+                  tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle);
+  CloseHandle(tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle),
+    tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle = NULL;
 }
 
-int win32_Initialize_CreateMainWindow(struct skypiax_interface *p)
+int win32_Initialize_CreateMainWindow(private_t *tech_pvt)
 {
-  p->SkypiaxHandles.win32_hInit_MainWindowHandle =
+  tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
     CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
-                   p->SkypiaxHandles.win32_acInit_WindowClassName, "",
+                   tech_pvt->SkypiaxHandles.win32_acInit_WindowClassName, "",
                    WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
-                   128, 128, NULL, 0, p->SkypiaxHandles.win32_hInit_ProcessHandle, p);
-  return (p->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
+                   128, 128, NULL, 0, tech_pvt->SkypiaxHandles.win32_hInit_ProcessHandle, p);
+  return (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
 }
 
-void win32_DeInitialize_DestroyMainWindow(struct skypiax_interface *p)
+void win32_DeInitialize_DestroyMainWindow(private_t *tech_pvt)
 {
-  if (p->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
-    DestroyWindow(p->SkypiaxHandles.win32_hInit_MainWindowHandle),
-      p->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
+  if (tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle != NULL)
+    DestroyWindow(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle),
+      tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
 }
 
 DWORD win32_dwThreadId;
@@ -722,28 +732,27 @@
   /*    destroy main window */
   /*  destroy window class */
 
-  struct skypiax_interface *p;
+  private_t *tech_pvt = obj;
 
-  p = obj;
-  switch_file_pipe_create(&p->SkypiaxHandles.fdesc[0],
-                          &p->SkypiaxHandles.fdesc[1], skypiax_module_pool);
-  p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
+  switch_file_pipe_create(&tech_pvt->SkypiaxHandles.fdesc[0],
+                          &tech_pvt->SkypiaxHandles.fdesc[1], skypiax_module_pool);
+  tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
     RegisterWindowMessage("SkypeControlAPIAttach");
-  p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
+  tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
     RegisterWindowMessage("SkypeControlAPIDiscover");
 
   switch_sleep(2000000);
 
-  if (p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
-      && p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
+  if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
+      && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
     if (win32_Initialize_CreateWindowClass(p)) {
       if (win32_Initialize_CreateMainWindow(p)) {
         if (SendMessage
             (HWND_BROADCAST,
-             p->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
-             (WPARAM) p->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
-          p->SkypiaxHandles.win32_hInit_MainWindowHandle =
-            p->SkypiaxHandles.win32_hInit_MainWindowHandle;
+             tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+             (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, 0) != 0) {
+          tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle =
+            tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle;
           while (1) {
             MSG oMessage;
             if (!running)
@@ -818,7 +827,7 @@
   unsigned long bytes_after_ret;
   unsigned char *prop;
   int status;
-  struct skypiax_interface *p = NULL;
+  private_t *tech_pvt = NULL;
 
   //XLockDisplay(disp);
   status =
@@ -846,7 +855,7 @@
 
   int *dispptr;
   int disp;
-  struct skypiax_interface *p = NULL;
+  private_t *tech_pvt = NULL;
 
   dispptr = data;
   disp = *dispptr;
@@ -865,28 +874,27 @@
 void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
 {
 
-  struct skypiax_interface *p;
+  private_t *tech_pvt = obj;
   struct SkypiaxHandles *SkypiaxHandles;
   char buf[512];
   Display *disp = NULL;
   Window root = -1;
   Window win = -1;
 
-  p = obj;
   DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
 
-  if (pipe(p->SkypiaxHandles.fdesc)) {
-    fcntl(p->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
-    fcntl(p->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+  if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
+    fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+    fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
   }
-  SkypiaxHandles = &p->SkypiaxHandles;
-  disp = XOpenDisplay(p->X11_display);
+  SkypiaxHandles = &tech_pvt->SkypiaxHandles;
+  disp = XOpenDisplay(tech_pvt->X11_display);
   if (!disp) {
     ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
-           p->X11_display);
+           tech_pvt->X11_display);
     return NULL;
   } else {
-    DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, p->X11_display);
+    DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, tech_pvt->X11_display);
   }
 
   int xfd;
@@ -978,7 +986,7 @@
 }
 #endif // WIN32
 
-int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
+int skypiax_skype_write(private_t *tech_pvt, char *msg_to_skype)
 {
 #ifdef WIN32
   static char acInputRow[1024];
@@ -1003,14 +1011,14 @@
   oCopyData.cbData = strlen(acInputRow) + 1;
   if (oCopyData.cbData != 1) {
     if (SendMessage
-        (p->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
-         (WPARAM) p->SkypiaxHandles.win32_hInit_MainWindowHandle,
+        (tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
+         (WPARAM) tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle,
          (LPARAM) & oCopyData) == FALSE) {
       ERRORA
         ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
          SKYPIAX_P_LOG);
-      p->skype = 0;
-      p->skype_thread = NULL;
+      tech_pvt->skype = 0;
+      tech_pvt->skype_thread = NULL;
       if (option_debug > 100) {
         DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
       }
@@ -1022,7 +1030,7 @@
   if (option_debug > 100) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
   }
-  SkypiaxHandles = &p->SkypiaxHandles;
+  SkypiaxHandles = &tech_pvt->SkypiaxHandles;
 
   if (!skypiax_skype_send_message(SkypiaxHandles, msg_to_skype)) {
     ERRORA
@@ -1042,7 +1050,7 @@
 
 }
 
-int skypiax_skype_read(struct skypiax_interface *p)
+int skypiax_skype_read(private_t *tech_pvt)
 {
 
   char read_from_pipe[4096];
@@ -1059,9 +1067,6 @@
   fd_set fs;
   struct timeval to;
 #endif /* WIN32 */
-  private_t *tech_pvt = NULL;
-
-  tech_pvt = p->tech_pvt;
 
   if (option_debug > 100) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1074,7 +1079,7 @@
 #ifdef WIN32
   rt = 1;
 #else /* WIN32 */
-  fdselect = p->SkypiaxHandles.fdesc[0];
+  fdselect = tech_pvt->SkypiaxHandles.fdesc[0];
   FD_ZERO(&fs);
   FD_SET(fdselect, &fs);
   to.tv_usec = 2000000;         //500 msec
@@ -1083,13 +1088,13 @@
 #endif /* WIN32 */
 
   if (rt > 0) {
-    if (p->SkypiaxHandles.fdesc[0]) {
+    if (tech_pvt->SkypiaxHandles.fdesc[0]) {
       howmany = sizeof(read_from_pipe);
 #ifdef WIN32
-      switch_file_read(p->SkypiaxHandles.fdesc[0], read_from_pipe, &howmany);
+      switch_file_read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, &howmany);
 #else /* WIN32 */
       howmany =
-        read(p->SkypiaxHandles.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
+        read(tech_pvt->SkypiaxHandles.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
 #endif /* WIN32 */
 
       a = 0;
@@ -1099,8 +1104,8 @@
 
         if (read_from_pipe[i] == '\0') {
 
-          DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
-                       howmany, i, a, messaggio);
+          //DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio);
+          DEBUGA_SKYPE("READING: |||%s||| \n", SKYPIAX_P_LOG, messaggio);
 
           if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
                                                        just authorized */
@@ -1108,7 +1113,7 @@
               ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
                SKYPIAX_P_LOG);
             switch_sleep(1000000);
-            skypiax_skype_write(p, "PROTOCOL 6");
+            skypiax_skype_write(tech_pvt, "PROTOCOL 6");
             switch_sleep(10000);
             return 0;
           }
@@ -1116,19 +1121,19 @@
           if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
             ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
                    SKYPIAX_P_LOG, messaggio);
-            p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+            tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
             if (option_debug)
               DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
-            p->skype_call_id[0] = '\0';
+            tech_pvt->skype_call_id[0] = '\0';
 
-            if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+            if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
               if (option_debug > 100) {
                 DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
               }
-              p->interface_state = SKYPIAX_STATE_DOWN;
+              tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
               return CALLFLOW_INCOMING_HANGUP;
             } else {
-              p->interface_state = SKYPIAX_STATE_DOWN;
+              tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
             }
           }
 
@@ -1144,36 +1149,36 @@
           if (!strcasecmp(messaggio, "#333")) {
             /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
              * messaggio_2, &messaggio_2[11]); */
-            memset(p->skype_friends, 0, 4096);
-            strncpy(p->skype_friends, &messaggio_2[11], 4095);
+            memset(tech_pvt->skype_friends, 0, 4096);
+            strncpy(tech_pvt->skype_friends, &messaggio_2[11], 4095);
           }
           if (!strcasecmp(messaggio, "#222")) {
             /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
              * messaggio_2, &messaggio_2[10]); */
-            memset(p->skype_fullname, 0, 512);
-            strncpy(p->skype_fullname, &messaggio_2[10], 511);
+            memset(tech_pvt->skype_fullname, 0, 512);
+            strncpy(tech_pvt->skype_fullname, &messaggio_2[10], 511);
           }
           if (!strcasecmp(messaggio, "#765")) {
             /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
              * messaggio_2, &messaggio_2[10]); */
-            memset(p->skype_displayname, 0, 512);
-            strncpy(p->skype_displayname, &messaggio_2[10], 511);
+            memset(tech_pvt->skype_displayname, 0, 512);
+            strncpy(tech_pvt->skype_displayname, &messaggio_2[10], 511);
           }
           if (!strcasecmp(messaggio, "ERROR")) {
             ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
-            p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+            tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
             if (option_debug)
               DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
-            p->skype_call_id[0] = '\0';
+            tech_pvt->skype_call_id[0] = '\0';
 
-            if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+            if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
               if (option_debug > 100) {
                 DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
               }
-              p->interface_state = SKYPIAX_STATE_DOWN;
+              tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
               return CALLFLOW_INCOMING_HANGUP;
             } else {
-              p->interface_state = SKYPIAX_STATE_DOWN;
+              tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
             }
           }
           if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
@@ -1183,9 +1188,9 @@
 
             strncpy(id, where, sizeof(id) - 1);
 
-            if (!strcasecmp(id, p->skype_user)) {
-              p->SkypiaxHandles.api_connected = 1;
-              //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, p->skype_user);
+            if (!strcasecmp(id, tech_pvt->skype_user)) {
+              tech_pvt->SkypiaxHandles.api_connected = 1;
+              //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, tech_pvt->skype_user);
             }
           }
 
@@ -1207,7 +1212,7 @@
 
               //FIXME: TODO: allow authorization based on config param
               sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
-              skypiax_skype_write(p, msg_to_skype);
+              skypiax_skype_write(tech_pvt, msg_to_skype);
             }
           }
 
@@ -1236,7 +1241,7 @@
 
                 //FIXME: TODO: allow authorization based on config param
                 sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
-                skypiax_skype_write(p, msg_to_skype);
+                skypiax_skype_write(tech_pvt, msg_to_skype);
               }
             } else if (!strcasecmp(prop, "BODY")) {
               char msg_to_skype[256];
@@ -1246,7 +1251,7 @@
 
               //FIXME: TODO: on config param ???
               sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
-              skypiax_skype_write(p, msg_to_skype);
+              skypiax_skype_write(tech_pvt, msg_to_skype);
             }
 
           }
@@ -1275,39 +1280,38 @@
                  SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
 
             if (!strcasecmp(prop, "PARTNER_HANDLE")) {
-              strncpy(p->callid_number, value, sizeof(p->callid_number) - 1);
+              strncpy(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1);
               WARNINGA
-                ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n",
-                 SKYPIAX_P_LOG, id, p->callid_number);
+                ("the skype_call %s caller PARTNER_HANDLE (tech_pvt->callid_number) is: %s\n",
+                 SKYPIAX_P_LOG, id, tech_pvt->callid_number);
               return CALLFLOW_INCOMING_RING;
             }
             if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
-              snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value,
+              snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", value,
                        where ? " " : "", where ? where : "");
               WARNINGA
-                ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n",
-                 SKYPIAX_P_LOG, id, p->callid_name);
+                ("the skype_call %s caller PARTNER_DISPNAME (tech_pvt->callid_name) is: %s\n",
+                 SKYPIAX_P_LOG, id, tech_pvt->callid_name);
             }
             if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
               DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
                            id);
-              if (p->interface_state == SKYPIAX_STATE_DOWN)
-                p->interface_state = SKYPIAX_STATE_PRERING;
+              if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+                tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
             }
             if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
               DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
-              if (p->interface_state == SKYPIAX_STATE_DOWN)
-                p->interface_state = SKYPIAX_STATE_PRERING;
+              if (tech_pvt->interface_state == SKYPIAX_STATE_DOWN)
+                tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
             }
 
             if (!strcasecmp(prop, "DTMF")) {
               switch_core_session_t *session = NULL;
-              private_t *tech_pvt = NULL;
               switch_channel_t *channel = NULL;
 
               DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
 
-              tech_pvt = p->tech_pvt;
+              //tech_pvt = p;
               session = tech_pvt->session;
               channel = switch_core_session_get_channel(session);
 
@@ -1329,8 +1333,8 @@
                  SKYPIAX_P_LOG, id);
             }
             if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
-              if (strcasecmp(id, p->skype_call_id)) {
-                strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+              if (strcasecmp(id, tech_pvt->skype_call_id)) {
+                strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
                 if (option_debug > 1)
                   DEBUGA_SKYPE
                     ("We called a Skype contact and he answered us on skype_call: %s.\n",
@@ -1342,34 +1346,34 @@
 
               if (!strcasecmp(value, "RINGING")) {
                 char msg_to_skype[1024];
-                if (p->interface_state != SKYPIAX_STATE_DIALING) {
+                if (tech_pvt->interface_state != SKYPIAX_STATE_DIALING) {
                   /* we are not calling out */
 
-                  if (!strlen(p->skype_call_id)) {  //FIXME
+                  if (!strlen(tech_pvt->skype_call_id)) {  //FIXME
                     /* we are not inside an active call */
-                    p->skype_callflow = CALLFLOW_STATUS_RINGING;
-                    p->interface_state = SKYPIAX_STATE_RING;
+                    tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+                    tech_pvt->interface_state = SKYPIAX_STATE_RING;
                     /* no owner, no active call, let's answer */
-                    skypiax_skype_write(p, "SET AGC OFF");
+                    skypiax_skype_write(tech_pvt, "SET AGC OFF");
                     switch_sleep(10000);
-                    skypiax_skype_write(p, "SET AEC OFF");
+                    skypiax_skype_write(tech_pvt, "SET AEC OFF");
                     switch_sleep(10000);
                     sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
-                    skypiax_skype_write(p, msg_to_skype);
+                    skypiax_skype_write(tech_pvt, msg_to_skype);
                     switch_sleep(10000);
                     sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
-                    skypiax_skype_write(p, msg_to_skype);
+                    skypiax_skype_write(tech_pvt, msg_to_skype);
                     switch_sleep(10000);
                     sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
-                    skypiax_skype_write(p, msg_to_skype);
+                    skypiax_skype_write(tech_pvt, msg_to_skype);
                     if (option_debug)
                       DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
                                    SKYPIAX_P_LOG, id);
-                    strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+                    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 refuse */
                     sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
-                    skypiax_skype_write(p, msg_to_skype);
+                    skypiax_skype_write(tech_pvt, msg_to_skype);
                     switch_sleep(10000);
                     DEBUGA_SKYPE
                       ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
@@ -1378,79 +1382,79 @@
                   }
                 } else {
                   /* we are calling out */
-                  p->skype_callflow = CALLFLOW_STATUS_RINGING;
-                  p->interface_state = SKYPIAX_STATE_RINGING;
-                  //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
-                  strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+                  tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
+                  tech_pvt->interface_state = SKYPIAX_STATE_RINGING;
+                  //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
+                  strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
                   DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
                                SKYPIAX_P_LOG, id);
                 }
               } else if (!strcasecmp(value, "EARLYMEDIA")) {
-                p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
-                p->interface_state = SKYPIAX_STATE_DIALING;
-                //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
+                tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+                tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
+                //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
                 DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
                              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")) {
-                //p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+                //tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED;
                 if (option_debug)
                   DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
-                p->skype_call_id[0] = '\0';
+                tech_pvt->skype_call_id[0] = '\0';
 
-                if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
                   if (option_debug > 100) {
                     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
                   }
-                  //p->interface_state = SKYPIAX_STATE_DOWN;
+                  //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
                   return CALLFLOW_INCOMING_HANGUP;
                 } else {
-                  p->interface_state = SKYPIAX_STATE_DOWN;
+                  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
                 }
 
               } else if (!strcasecmp(value, "CANCELLED")) {
-                p->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+                tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED;
                 if (option_debug)
                   DEBUGA_SKYPE
                     ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
                      SKYPIAX_P_LOG, id);
-                p->skype_call_id[0] = '\0';
+                tech_pvt->skype_call_id[0] = '\0';
 
-                if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+                if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
                   if (option_debug > 100) {
                     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
                   }
-                  p->interface_state = SKYPIAX_STATE_DOWN;
+                  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
                   return CALLFLOW_INCOMING_HANGUP;
                 } else {
-                  p->interface_state = SKYPIAX_STATE_DOWN;
+                  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
                 }
               } else if (!strcasecmp(value, "FAILED")) {
-                p->skype_callflow = CALLFLOW_STATUS_FAILED;
+                tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
                 if (option_debug)
                   DEBUGA_SKYPE
                     ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
                      SKYPIAX_P_LOG, id);
-                p->skype_call_id[0] = '\0';
-                strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
-                p->interface_state = SKYPIAX_STATE_DOWN;
+                tech_pvt->skype_call_id[0] = '\0';
+                strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+                tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
                 if (option_debug > 100) {
                   DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
                 }
                 return CALLFLOW_INCOMING_HANGUP;
               } else if (!strcasecmp(value, "REFUSED")) {
-                if (!strcasecmp(id, p->skype_call_id)) {
+                if (!strcasecmp(id, tech_pvt->skype_call_id)) {
                   /* this is the id of the call we are in, probably we generated it */
-                  p->skype_callflow = CALLFLOW_STATUS_REFUSED;
+                  tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED;
                   if (option_debug)
                     DEBUGA_SKYPE
                       ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
                        SKYPIAX_P_LOG, id);
-                  strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
-                  p->interface_state = SKYPIAX_STATE_DOWN;
-                  p->skype_call_id[0] = '\0';
+                  strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
+                  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
+                  tech_pvt->skype_call_id[0] = '\0';
                   if (option_debug > 100) {
                     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
                   }
@@ -1461,19 +1465,19 @@
 
                 }
               } else if (!strcasecmp(value, "ROUTING")) {
-                p->skype_callflow = CALLFLOW_STATUS_ROUTING;
-                p->interface_state = SKYPIAX_STATE_DIALING;
-                strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+                tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING;
+                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 ROUTING\n", SKYPIAX_P_LOG, id);
               } else if (!strcasecmp(value, "UNPLACED")) {
-                p->skype_callflow = CALLFLOW_STATUS_UNPLACED;
-                p->interface_state = SKYPIAX_STATE_DIALING;
-                strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+                tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED;
+                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")) {
-                p->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
-                strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
-                p->interface_state = SKYPIAX_STATE_UP;
+                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;
                 if (option_debug > 1)
                   DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
 
@@ -1488,36 +1492,36 @@
                   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(&p->tcp_srv_thread, thd_attr,
-                                       skypiax_do_tcp_srv_thread, p, skypiax_module_pool);
+                  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(&p->tcp_cli_thread, thd_attr,
-                                       skypiax_do_tcp_cli_thread, p, skypiax_module_pool);
+                  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);
                   sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
-                          p->tcp_srv_port);
-                  skypiax_skype_write(p, msg_to_skype);
+                          tech_pvt->tcp_srv_port);
+                  skypiax_skype_write(tech_pvt, msg_to_skype);
                   switch_sleep(100000);
                   sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
-                          p->tcp_cli_port);
-                  skypiax_skype_write(p, msg_to_skype);
+                          tech_pvt->tcp_cli_port);
+                  skypiax_skype_write(tech_pvt, msg_to_skype);
                   switch_sleep(100000);
                 }
 
-                p->skype_callflow = SKYPIAX_STATE_UP;
+                tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
 
                 //FIXME switch_core_session_t **new_session;
 
                 //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
 
-                if (!p->tech_pvt || !tech_pvt->session) {   //FIXME FIXME FIXME 
+                if (!tech_pvt->session) {   //FIXME FIXME FIXME 
                   switch_core_session_t *session = NULL;
-                  private_t *tech_pvt = NULL;
+                  //private_t *tech_pvt = NULL;
                   switch_channel_t *channel = NULL;
 
                   NOTICA("New Inbound Channel!\n", SKYPIAX_P_LOG);
@@ -1526,27 +1530,28 @@
                        switch_core_session_request(skypiax_endpoint_interface,
                                                    NULL)) != 0) {
                     switch_core_session_add_stream(session, NULL);
-                    if ((tech_pvt =
-                         (private_t *) switch_core_session_alloc(session,
-                                                                 sizeof(private_t))) !=
-                        0) {
                       channel = switch_core_session_get_channel(session);
-                      skypiax_tech_init(tech_pvt, session, p);
+                      skypiax_tech_init(tech_pvt, session);
+#if 0
+                    if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) {
+                      channel = switch_core_session_get_channel(session);
+                      skypiax_tech_init(tech_pvt, session);
                     } else {
                       ERRORA("Hey where is my memory pool?\n", SKYPIAX_P_LOG);
                       switch_core_session_destroy(&session);
                       break;
                     }
+#endif
 
                     if ((tech_pvt->caller_profile =
                          switch_caller_profile_new(switch_core_session_get_pool(session),
-                                                   "skypiax", "XML", p->callid_name,
-                                                   p->callid_number, NULL, "calling_ani",
+                                                   "skypiax", "XML", tech_pvt->callid_name,
+                                                   tech_pvt->callid_number, NULL, "calling_ani",
                                                    NULL, NULL, "mod_skypiax", "public",
                                                    "5000")) != 0) {
                       char name[128];
-                      //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", p->name, tech_pvt->caller_profile->destination_number);
-                      switch_snprintf(name, sizeof(name), "skypiax/%s", p->name);
+                      //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);
@@ -1562,14 +1567,8 @@
                   switch_channel_mark_answered(channel);
                 } else {
                   switch_core_session_t *session = NULL;
-                  private_t *tech_pvt = NULL;
                   switch_channel_t *channel = NULL;
 
-                  if (p->tech_pvt) {
-                    tech_pvt = p->tech_pvt;
-                  } else {
-                    ERRORA("No p->tech_pvt???\n", SKYPIAX_P_LOG);
-                  }
                   if (tech_pvt->session) {
                     session = tech_pvt->session;
                   } else {
@@ -1612,7 +1611,7 @@
   return 0;
 }
 
-int skypiax_skype_senddigit(struct skypiax_interface *p, char digit)
+int skypiax_skype_senddigit(private_t *tech_pvt, char digit)
 {
   char msg_to_skype[1024];
   if (option_debug > 10) {
@@ -1621,9 +1620,9 @@
 
   NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
 
-  sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
+  sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit);
 
-  skypiax_skype_write(p, msg_to_skype);
+  skypiax_skype_write(tech_pvt, msg_to_skype);
 
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -1631,15 +1630,15 @@
   return 0;
 }
 
-int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
+int skypiax_skype_call(private_t *tech_pvt, char *idest, int timeout,
                        switch_core_session_t * session)
 {
   char *rdest;
   char msg_to_skype[1024];
-  private_t *tech_pvt;
+  //private_t *tech_pvt;
   switch_caller_profile_t *caller_profile;
 
-  tech_pvt = p->tech_pvt;
+  //tech_pvt = p;
 
   if (option_debug > 10) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1652,13 +1651,13 @@
   if (option_debug)
     DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
   NOTICA("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
-  skypiax_skype_write(p, "SET AGC OFF");
+  skypiax_skype_write(tech_pvt, "SET AGC OFF");
   switch_sleep(10000);
-  skypiax_skype_write(p, "SET AEC OFF");
+  skypiax_skype_write(tech_pvt, "SET AEC OFF");
   switch_sleep(10000);
 
   sprintf(msg_to_skype, "CALL %s", rdest);
-  if (skypiax_skype_write(p, msg_to_skype) < 0) {
+  if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {
 
     ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG);
     if (option_debug > 10) {
@@ -1670,6 +1669,6 @@
   caller_profile = tech_pvt->caller_profile;
   caller_profile->destination_number = rdest;
 
-  //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
+  //FIXME ast_queue_control(tech_pvt->owner, SKYPIAX_CONTROL_RINGING);
   return 0;
 }



More information about the Freeswitch-svn mailing list