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

FreeSWITCH SVN gmaruzz at freeswitch.org
Tue Dec 23 13:11:02 PST 2008


Author: gmaruzz
Date: Tue Dec 23 16:11:02 2008
New Revision: 10928

Log:
skypiax: windows mysteries :-(, do not works correctly, let's check how to individuate the correct window to sendmessage to

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

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	Tue Dec 23 16:11:02 2008
@@ -502,6 +502,68 @@
 
 
 #ifdef WIN32
+#if 1
+/*******************************************************/
+int CALLBACK EnumWindowsProc(HWND hwnd, LPARAM param)
+{	DWORD pID;
+	DWORD TpID;
+	struct skypiax_interface *p = NULL;
+
+	TpID = GetWindowThreadProcessId(hwnd, &pID);
+
+	if (TpID == (DWORD)param)
+	{
+		NOTICA("HWND=%p\n", SKYPIAX_P_LOG, hwnd);
+		win32_hGlobal_SkypeAPIWindowHandle = hwnd;
+		return 0;
+	}else{
+		DEBUGA_SKYPE("HWND=%p\n", SKYPIAX_P_LOG, hwnd);
+		return 1;
+	}
+} 
+
+
+
+
+
+int LaunchSkype(void)
+{
+	PROCESS_INFORMATION pi;
+	STARTUPINFO si = {0};
+	struct skypiax_interface *p = NULL;
+	int ret=1;
+	int times=0;
+
+
+	si.cb = sizeof(si);
+
+	CreateProcess( "C:\\Program Files\\Skype\\Phone\\Skype.exe",
+			"/secondary /username:skypiax4 /password:", // Command line.
+			NULL, // Process handle not inheritable.
+			NULL, // Thread handle not inheritable.
+			FALSE, // Set handle inheritance to FALSE.
+			NORMAL_PRIORITY_CLASS, // No creation flags.
+			NULL, // Use parent's environment block.
+			NULL, // Use parent's starting directory.
+			&si, // Pointer to STARTUPINFO structure.
+			&pi  // Pointer to PROCESS_INFORMATION structure.
+		     );
+
+
+	while(ret){
+		ret = EnumWindows(&EnumWindowsProc, pi.dwThreadId);
+		switch_sleep(10000);
+		times++;
+		if (times == 1000)
+			break;
+	}
+	NOTICA("HWND=%p\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
+	return 1;
+
+}
+/*******************************************************/
+#endif //NOTDEF
+
 
 enum {
   SKYPECONTROLAPI_ATTACH_SUCCESS = 0,   /*  Client is successfully 
@@ -581,13 +643,16 @@
     if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
       switch (ulParam) {
       case SKYPECONTROLAPI_ATTACH_SUCCESS:
+	NOTICA(" OK, we have to find the subwindow, or something like HWND=%p\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
         NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
         win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+	NOTICA(" OK, we have to find the subwindow, or something like HWND=%p\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
         switch_sleep(5000);
         win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle =
           win32_hGlobal_SkypeAPIWindowHandle;
         break;
       case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+	NOTICA("HWND=%u\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
         WARNINGA
           ("\n\n\tIf I do not 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);
@@ -600,6 +665,12 @@
         break;
       case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
         DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
+
+	NOTICA("HWND=%u\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
+        SendMessage
+            (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+             (WPARAM) win32_hInit_MainWindowHandle, 0);
+	NOTICA("HWND=%u\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
         break;
       default:
         WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
@@ -694,6 +765,10 @@
   //DWORD MsgWaitResult;
   p = obj;
 
+  LaunchSkype();
+
+  NOTICA("HWND=%u\n", SKYPIAX_P_LOG, win32_hGlobal_SkypeAPIWindowHandle);
+
   switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool);
   //switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100);
 



More information about the Freeswitch-branches mailing list