From cff253668f6805beea2c98afa8296b407e8d2106 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 1 Oct 2012 04:45:13 +0000 Subject: - probably fixed multiple start of skype runtime git-svn-id: http://svn.miranda-ng.org/main/trunk@1733 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype.cpp | 60 +++++++++++++++++++++++++++++++------------ 1 file changed, 44 insertions(+), 16 deletions(-) (limited to 'protocols/Skype/src/skype.cpp') diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index e7060c289a..63d19f8077 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -57,6 +57,7 @@ static int SkypeProtoUninit(CSkypeProto* ppro) } char* keyBuf = 0; +int port = 8963; int LoadKeyPair() { @@ -87,39 +88,66 @@ int LoadKeyPair() printf("Error opening app token file: %s\n", g_keyFileName); return 0; -}; +} -extern "C" int __declspec(dllexport) Load(void) +void StartSkypeRuntime() { - // loading skype SDK + // loading skype runtime // shitcode - char* bsp; - STARTUPINFOA cif; + int port = 8963; + wchar_t* bsp; + STARTUPINFO cif; PROCESS_INFORMATION pi; - char runtimePath[MAX_PATH]; - - GetModuleFileNameA(g_hInstance, runtimePath, MAX_PATH); - bsp = strrchr(runtimePath, '\\' ); - runtimePath[strlen(runtimePath) - strlen(bsp)] = '\0'; - strcat(runtimePath, "\\..\\..\\..\\..\\SkypeKit\\SDK\\bin\\windows-x86\\windows-x86-skypekit.exe"); + wchar_t runtimePath[MAX_PATH]; + TCHAR param[128]; + + GetModuleFileName(g_hInstance, runtimePath, MAX_PATH); + bsp = wcsrchr(runtimePath, '\\' ); + runtimePath[wcslen(runtimePath) - wcslen(bsp)] = '\0'; + bsp = wcsrchr(runtimePath, '\\' ); + runtimePath[wcslen(runtimePath) - wcslen(bsp)] = '\0'; + bsp = wcsrchr(runtimePath, '\\' ); + runtimePath[wcslen(runtimePath) - wcslen(bsp)] = '\0'; + bsp = wcsrchr(runtimePath, '\\' ); + runtimePath[wcslen(runtimePath) - wcslen(bsp)] = '\0'; + bsp = wcsrchr(runtimePath, '\\' ); + runtimePath[wcslen(runtimePath) - wcslen(bsp)] = '\0'; + //\\..\\..\\..\\.. + wcscat(runtimePath, L"\\SkypeKit\\SDK\\bin\\windows-x86\\windows-x86-skypekit.exe"); ZeroMemory(&cif,sizeof(STARTUPINFOA)); + cif.cb = sizeof(STARTUPINFO); + cif.dwFlags = STARTF_USESHOWWINDOW; + cif.wShowWindow = SW_HIDE; + + + if ( FindWindow(NULL, runtimePath)) + { + port += rand() % 100; + } + + mir_sntprintf(param, SIZEOF(param), L"-p -p %d", port); - CreateProcessA( + CreateProcess( runtimePath, + param, NULL, NULL, - NULL, - TRUE, + FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &cif, &pi); +} - g_skype = new CSkype(); +extern "C" int __declspec(dllexport) Load(void) +{ + StartSkypeRuntime(); LoadKeyPair(); - g_skype->init(keyBuf, "127.0.0.1", 8963, "streamlog.txt"); + + g_skype = new CSkype(); + g_skype->init(keyBuf, "127.0.0.1", port, "streamlog.txt"); g_skype->start(); PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; -- cgit v1.2.3