[Freeswitch-svn] [commit] r12320 - freeswitch/trunk/src/mod/endpoints/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Fri Feb 27 03:08:23 PST 2009


Author: gmaruzz
Date: Fri Feb 27 05:08:23 2009
New Revision: 12320

Log:
skypiax: fixed http://jira.freeswitch.org/browse/MODSKYPIAX-21 on windows, let's check if it works on linux

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

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	Fri Feb 27 05:08:23 2009
@@ -940,15 +940,32 @@
 
         skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
 
+        NOTICA("WAITING max 6 seconds to connect to SKYPE API for interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
         i = 0;
-        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 60000) {    // 60sec FIXME
+        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected == 0 && running && i < 400) {    // 6sec on windows (why ????)  FIXME
+          //DEBUGA_SKYPE("interface_id=%d, times=%d\n", SKYPIAX_P_LOG, interface_id, i);
           switch_sleep(1000);
           i++;
         }
         if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.api_connected) {
-          NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+          NOTICA("SKYPE API connected for interface_id=%d, waiting max 60 seconds for CURRENTUSERHANDLE==%s\n", SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
         } else {
-          ERRORA("FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+          ERRORA("SKYPE API FAILED to connect for interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+          running = 0;
+          return SWITCH_STATUS_FALSE;
+        }
+
+        i = 0;
+        while (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle == 0 && running && i < 4000) {    // 60sec on windows (why ????)  FIXME
+          //DEBUGA_SKYPE("interface_id=%d, times=%d\n", SKYPIAX_P_LOG, interface_id, i);
+          switch_sleep(1000);
+          i++;
+        }
+        if (globals.SKYPIAX_INTERFACES[interface_id].SkypiaxHandles.currentuserhandle) {
+          NOTICA("CURRENTUSERHANDLE ok (%s), interface_id=%d STARTED\n", SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, interface_id);
+        } else {
+          ERRORA("FAILED to find CURRENTUSERHANDLE=%s, FAILED to start interface_id=%d\n", SKYPIAX_P_LOG, globals.SKYPIAX_INTERFACES[interface_id].skype_user, interface_id);
+          running = 0;
           return SWITCH_STATUS_FALSE;
         }
 
@@ -995,8 +1012,10 @@
 
   running = 1;
 
-  if (load_config() != SWITCH_STATUS_SUCCESS)
+  if (load_config() != SWITCH_STATUS_SUCCESS) {
+    running = 0;
     return SWITCH_STATUS_FALSE;
+  }
 
   *module_interface = switch_loadable_module_create_module_interface(pool, modname);
   skypiax_endpoint_interface =
@@ -1039,6 +1058,7 @@
         DEBUGA_SKYPE
           ("got FALSE here, thread probably was already dead. GetLastError returned: %d\n",
            SKYPIAX_P_LOG, GetLastError());
+            globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread=NULL;
       }
 #else
       XEvent e;
@@ -1057,9 +1077,9 @@
       XSync(tech_pvt->SkypiaxHandles.disp, False);
 #endif
     }
-    while (x) {
+    while (x) {//FIXME 2 seconds?
       x--;
-      switch_yield(20000);
+      switch_yield(20000); 
     }
     if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
       switch_thread_join(&status,

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	Fri Feb 27 05:08:23 2009
@@ -136,6 +136,7 @@
   Window skype_win;
   Display *disp;
   Window win;
+  int currentuserhandle;
   int api_connected;
   int fdesc[2];
 };
@@ -148,6 +149,7 @@
   char win32_acInit_WindowClassName[128];
   UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
   UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+  int currentuserhandle;
   int api_connected;
   switch_file_t *fdesc[2];
 };

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	Fri Feb 27 05:08:23 2009
@@ -100,7 +100,7 @@
         where = strsep(stringp, " ");
         strncpy(id, where, sizeof(id) - 1);
         if (!strcasecmp(id, tech_pvt->skype_user)) {
-          tech_pvt->SkypiaxHandles.api_connected = 1;
+          tech_pvt->SkypiaxHandles.currentuserhandle = 1;
           DEBUGA_SKYPE
             ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n",
              SKYPIAX_P_LOG, message, obj, id, tech_pvt->skype_user);
@@ -909,6 +909,8 @@
   lReturnCode = 0;
   fIssueDefProc = 0;
   tech_pvt = (private_t *) GetWindowLong(hWindow, GWL_USERDATA);
+  if(!running)
+	  return lReturnCode;
   switch (uiMessage) {
   case WM_CREATE:
     tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
@@ -945,8 +947,9 @@
           tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
         switch (ulParam) {
         case SKYPECONTROLAPI_ATTACH_SUCCESS:
-          if (!tech_pvt->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
             DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
+            tech_pvt->SkypiaxHandles.api_connected = 1;
             tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
             tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle =
               tech_pvt->SkypiaxHandles.win32_hGlobal_SkypeAPIWindowHandle;
@@ -957,7 +960,7 @@
             ("\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);
           skypiax_sleep(5000);
-          if (!tech_pvt->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
             SendMessage(HWND_BROADCAST,
                         tech_pvt->SkypiaxHandles.
                         win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
@@ -974,7 +977,7 @@
         case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
           DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
           skypiax_sleep(5000);
-          if (!tech_pvt->SkypiaxHandles.api_connected) {
+          if (!tech_pvt->SkypiaxHandles.currentuserhandle) {
             SendMessage(HWND_BROADCAST,
                         tech_pvt->SkypiaxHandles.
                         win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
@@ -1234,12 +1237,14 @@
   if (status != Success || format_ret != 32 || nitems_ret != 1) {
     SkypiaxHandles->skype_win = (Window) - 1;
     DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
+    tech_pvt->SkypiaxHandles.api_connected = 0;
     return 0;
   }
 
   SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
   DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
                (unsigned int) SkypiaxHandles->skype_win);
+  tech_pvt->SkypiaxHandles.api_connected = 1;
   return 1;
 }
 



More information about the Freeswitch-svn mailing list