diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-01 04:45:13 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-01 04:45:13 +0000 |
commit | cff253668f6805beea2c98afa8296b407e8d2106 (patch) | |
tree | df44ec955bfbd385e86ba9b6ddc05688c02e3da4 /protocols | |
parent | 43908113c0b81a16a62af304d2d97b6df3c94cd3 (diff) |
- probably fixed multiple start of skype runtime
git-svn-id: http://svn.miranda-ng.org/main/trunk@1733 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/src/skype.cpp | 60 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 2 |
2 files changed, 45 insertions, 17 deletions
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) };
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 962dce0167..0490caa17e 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -30,7 +30,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) CSkypeProto::~CSkypeProto()
{
- Netlib_CloseHandle(this->hNetlibUser);
+ //Netlib_CloseHandle(this->hNetlibUser);
this->hNetlibUser = NULL;
CloseHandle(this->signin_lock);
|