diff options
41 files changed, 1015 insertions, 980 deletions
diff --git a/protocols/Skype/Skype_10.vcxproj b/protocols/Skype/Skype_10.vcxproj index 953a03c36e..dea0492a7f 100644 --- a/protocols/Skype/Skype_10.vcxproj +++ b/protocols/Skype/Skype_10.vcxproj @@ -83,6 +83,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking>
<DisableSpecificWarnings>4996;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <ObjectFileName>$(IntDir)/%(RelativeDir)/</ObjectFileName>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@@ -180,17 +181,36 @@ </ResourceCompile>
</ItemDefinitionGroup>
<ItemGroup>
+ <ClInclude Include="src\aes\aes.h" />
<ClInclude Include="src\base64\base64.h" />
- <ClInclude Include="src\skype_subclassing.h" />
<ClInclude Include="src\skype.h" />
+ <ClInclude Include="src\skypekit\account.h" />
+ <ClInclude Include="src\skypekit\common.h" />
+ <ClInclude Include="src\skypekit\contact.h" />
+ <ClInclude Include="src\skypekit\conversation.h" />
+ <ClInclude Include="src\skypekit\group.h" />
+ <ClInclude Include="src\skypekit\message.h" />
+ <ClInclude Include="src\skypekit\participant.h" />
+ <ClInclude Include="src\skypekit\search.h" />
+ <ClInclude Include="src\skypekit\skype.h" />
+ <ClInclude Include="src\skypekit\transfer.h" />
<ClInclude Include="src\skype_proto.h" />
<ClInclude Include="src\version.h" />
<ClInclude Include="src\resource.h" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="src\aes\aes.c" />
+ <ClCompile Include="src\aes\aes.cpp" />
<ClCompile Include="src\base64\base64.cpp" />
<ClCompile Include="src\skype.cpp" />
+ <ClCompile Include="src\skypekit\account.cpp" />
+ <ClCompile Include="src\skypekit\contact.cpp" />
+ <ClCompile Include="src\skypekit\conversation.cpp" />
+ <ClCompile Include="src\skypekit\group.cpp" />
+ <ClCompile Include="src\skypekit\message.cpp" />
+ <ClCompile Include="src\skypekit\participant.cpp" />
+ <ClCompile Include="src\skypekit\search.cpp" />
+ <ClCompile Include="src\skypekit\skype.cpp" />
+ <ClCompile Include="src\skypekit\transfer.cpp" />
<ClCompile Include="src\skype_account.cpp" />
<ClCompile Include="src\skype_chat.cpp" />
<ClCompile Include="src\skype_contacts.cpp" />
@@ -203,10 +223,8 @@ <ClCompile Include="src\skype_netlib.cpp" />
<ClCompile Include="src\skype_profile.cpp" />
<ClCompile Include="src\skype_proto.cpp" />
- <ClCompile Include="src\skype_runtime.cpp" />
<ClCompile Include="src\skype_services.cpp" />
<ClCompile Include="src\skype_settings.cpp" />
- <ClCompile Include="src\skype_subclassing.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters index cb48bf40f0..d7470bc9bb 100644 --- a/protocols/Skype/Skype_10.vcxproj.filters +++ b/protocols/Skype/Skype_10.vcxproj.filters @@ -16,6 +16,12 @@ <Filter Include="Resource Files\Bin">
<UniqueIdentifier>{f1aeb5a2-f105-4b8c-a656-08dbe6dc7b2e}</UniqueIdentifier>
</Filter>
+ <Filter Include="Header Files\skypekit">
+ <UniqueIdentifier>{a39a08d1-b79a-47eb-8433-1351f9f01401}</UniqueIdentifier>
+ </Filter>
+ <Filter Include="Source Files\skypekit">
+ <UniqueIdentifier>{171bef99-1ab9-424f-835d-9e47ab62365c}</UniqueIdentifier>
+ </Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\skype.cpp">
@@ -27,9 +33,6 @@ <ClCompile Include="src\skype_dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skype_subclassing.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\skype_events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -69,13 +72,37 @@ <ClCompile Include="src\skype_chat.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skype_runtime.cpp">
+ <ClCompile Include="src\base64\base64.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\aes\aes.c">
- <Filter>Source Files</Filter>
+ <ClCompile Include="src\skypekit\account.cpp">
+ <Filter>Source Files\skypekit</Filter>
</ClCompile>
- <ClCompile Include="src\base64\base64.cpp">
+ <ClCompile Include="src\skypekit\contact.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\conversation.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\group.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\message.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\participant.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\search.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\skype.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skypekit\transfer.cpp">
+ <Filter>Source Files\skypekit</Filter>
+ </ClCompile>
+ <ClCompile Include="src\aes\aes.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
@@ -92,10 +119,40 @@ <ClInclude Include="src\skype_proto.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\skype_subclassing.h">
+ <ClInclude Include="src\base64\base64.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\base64\base64.h">
+ <ClInclude Include="src\skypekit\account.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\common.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\contact.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\conversation.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\group.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\message.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\participant.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\search.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\skype.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\skypekit\transfer.h">
+ <Filter>Header Files\skypekit</Filter>
+ </ClInclude>
+ <ClInclude Include="src\aes\aes.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
diff --git a/protocols/Skype/Skype_11.vcxproj b/protocols/Skype/Skype_11.vcxproj index d4917373b2..74862af1a0 100644 --- a/protocols/Skype/Skype_11.vcxproj +++ b/protocols/Skype/Skype_11.vcxproj @@ -186,7 +186,6 @@ <ItemGroup>
<ClInclude Include="src\aes\aes.h" />
<ClInclude Include="src\base64\base64.h" />
- <ClInclude Include="src\skype_subclassing.h" />
<ClInclude Include="src\skype.h" />
<ClInclude Include="src\skype_proto.h" />
<ClInclude Include="src\version.h" />
@@ -211,7 +210,6 @@ <ClCompile Include="src\skype_runtime.cpp" />
<ClCompile Include="src\skype_services.cpp" />
<ClCompile Include="src\skype_settings.cpp" />
- <ClCompile Include="src\skype_subclassing.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/protocols/Skype/Skype_11.vcxproj.filters b/protocols/Skype/Skype_11.vcxproj.filters index 9596201554..ad19d3605d 100644 --- a/protocols/Skype/Skype_11.vcxproj.filters +++ b/protocols/Skype/Skype_11.vcxproj.filters @@ -33,9 +33,6 @@ <ClCompile Include="src\skype_dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skype_subclassing.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\skype_events.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -98,9 +95,6 @@ <ClInclude Include="src\skype_proto.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\skype_subclassing.h">
- <Filter>Header Files</Filter>
- </ClInclude>
<ClInclude Include="src\base64\base64.h">
<Filter>Header Files\base64</Filter>
</ClInclude>
diff --git a/protocols/Skype/src/aes/aes.c b/protocols/Skype/src/aes/aes.cpp index 7e15f1547b..7e15f1547b 100644 --- a/protocols/Skype/src/aes/aes.c +++ b/protocols/Skype/src/aes/aes.cpp diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index 06376b70c9..9f080883bb 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -1,9 +1,16 @@ -#include "skype.h"
+//#include "skype.h"
#include "skype_proto.h"
+#include "aes\aes.h"
+#include "base64\base64.h"
+//#include "skypekit\skype.h"
+
+#include "..\..\..\skypekit\key.h"
+
int hLangpack;
+CSkype *g_skype;
HINSTANCE g_hInstance;
-XML_API xi = {0};
+
TIME_API tmi = {0};
PLUGININFOEX pluginInfo =
@@ -35,10 +42,255 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+// ---
+
+BOOL IsRunAsAdmin()
+{
+ BOOL fIsRunAsAdmin = FALSE;
+ DWORD dwError = ERROR_SUCCESS;
+ PSID pAdministratorsGroup = NULL;
+
+ // Allocate and initialize a SID of the administrators group.
+ SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
+ if ( !AllocateAndInitializeSid(
+ &NtAuthority,
+ 2,
+ SECURITY_BUILTIN_DOMAIN_RID,
+ DOMAIN_ALIAS_RID_ADMINS,
+ 0, 0, 0, 0, 0, 0,
+ &pAdministratorsGroup))
+ {
+ dwError = GetLastError();
+ goto Cleanup;
+ }
+
+ // Determine whether the SID of administrators group is enabled in
+ // the primary access token of the process.
+ if ( !CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
+ {
+ dwError = GetLastError();
+ goto Cleanup;
+ }
+
+Cleanup:
+ // Centralized cleanup for all allocated resources.
+ if (pAdministratorsGroup)
+ {
+ FreeSid(pAdministratorsGroup);
+ pAdministratorsGroup = NULL;
+ }
+
+ // Throw the error if something failed in the function.
+ if (ERROR_SUCCESS != dwError)
+ {
+ throw dwError;
+ }
+
+ return fIsRunAsAdmin;
+}
+
+char *LoadKeyPair(HINSTANCE hInstance)
+{
+ HRSRC hRes = FindResource(hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
+ if (hRes)
+ {
+ HGLOBAL hResource = LoadResource(hInstance, hRes);
+ if (hResource)
+ {
+ aes_context ctx;
+ unsigned char key[128];
+
+ int basedecoded = Base64::Decode(MY_KEY, (char *)key, MAX_PATH);
+ ::aes_set_key(&ctx, key, 128);
+ memset(key, 0, sizeof(key));
+
+ basedecoded = ::SizeofResource(hInstance, hRes);
+ char *pData = (char *)hResource;
+ if (!pData)
+ return NULL;
+
+ unsigned char *bufD = (unsigned char*)::malloc(basedecoded + 1);
+ unsigned char *tmpD = (unsigned char*)::malloc(basedecoded + 1);
+ basedecoded = Base64::Decode(pData, (char *)tmpD, basedecoded);
+
+ for (int i = 0; i < basedecoded; i += 16)
+ aes_decrypt(&ctx, tmpD+i, bufD+i);
+
+ ::free(tmpD);
+ bufD[basedecoded] = 0; //cert should be null terminated
+ return (char *)bufD;
+ }
+ return NULL;
+ }
+ return NULL;
+}
+
+int StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, int &port/*, const wchar_t *dbPath*/)
+{
+ STARTUPINFO cif;
+ PROCESS_INFORMATION pi;
+ wchar_t param[128];
+
+ ::ZeroMemory(&cif, sizeof(STARTUPINFO));
+ cif.cb = sizeof(STARTUPINFO);
+ cif.dwFlags = STARTF_USESHOWWINDOW;
+ cif.wShowWindow = SW_HIDE;
+
+ //HRSRC hRes;
+ //HGLOBAL hResource;
+ wchar_t fileName[MAX_PATH];
+
+ HRSRC hRes = ::FindResource(hInstance, MAKEINTRESOURCE(/*IDR_RUNTIME*/102), L"BIN");
+ if (hRes)
+ {
+ HGLOBAL hResource = ::LoadResource(hInstance, hRes);
+ if (hResource)
+ {
+ HANDLE hFile;
+ char *pData = (char *)LockResource(hResource);
+ DWORD dwSize = SizeofResource(hInstance, hRes), written = 0;
+ ::GetModuleFileName(hInstance, fileName, MAX_PATH);
+
+ wchar_t *skypeKitPath = ::wcsrchr(fileName, '\\');
+ if (skypeKitPath != NULL)
+ *skypeKitPath = 0;
+ ::swprintf(fileName, SIZEOF(fileName), L"%s\\%s", fileName, L"SkypeKit.exe");
+ if ( !::PathFileExists(fileName))
+ {
+ if ((hFile = ::CreateFile(
+ fileName,
+ GENERIC_WRITE,
+ 0,
+ NULL,
+ CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ 0)) != INVALID_HANDLE_VALUE)
+ {
+ ::WriteFile(hFile, (void *)pData, dwSize, &written, NULL);
+ ::CloseHandle(hFile);
+ }
+ else
+ {
+ // Check the current process's "run as administrator" status.
+ // Elevate the process if it is not run as administrator.
+ if (!IsRunAsAdmin())
+ {
+ wchar_t path[MAX_PATH], cmdLine[100];
+ ::GetModuleFileName(NULL, path, ARRAYSIZE(path));
+
+ if (profileName)
+ ::swprintf(
+ cmdLine,
+ SIZEOF(cmdLine),
+ L" /restart:%d /profile=%s",
+ ::GetCurrentProcessId(),
+ profileName);
+ else
+ ::swprintf(
+ cmdLine,
+ SIZEOF(cmdLine),
+ L" /restart:%d",
+ ::GetCurrentProcessId());
+
+ // Launch itself as administrator.
+ SHELLEXECUTEINFO sei = { sizeof(sei) };
+ sei.lpVerb = L"runas";
+ sei.lpFile = path;
+ sei.lpParameters = cmdLine;
+ //sei.hwnd = hDlg;
+ sei.nShow = SW_NORMAL;
+
+ if ( !::ShellExecuteEx(&sei))
+ {
+ DWORD dwError = ::GetLastError();
+ if (dwError == ERROR_CANCELLED)
+ {
+ // The user refused to allow privileges elevation.
+ // Do nothing ...
+ }
+ }
+ //else
+ //{
+ // //DestroyWindow(hDlg); // Quit itself
+ // ::CallService("CloseAction", 0, 0);
+ //}
+ }
+ return 0;
+ }
+ }
+ }
+ }
+
+ PROCESSENTRY32 entry;
+ entry.dwSize = sizeof(PROCESSENTRY32);
+
+ HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
+ if (::Process32First(snapshot, &entry) == TRUE) {
+ while (::Process32Next(snapshot, &entry) == TRUE) {
+ if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0) {
+ HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
+ port += rand() % 8963 + 1000;
+ ::CloseHandle(hProcess);
+ break;
+ }
+ }
+ }
+ ::CloseHandle(snapshot);
+
+ //::swprintf(param, SIZEOF(param), L"-p -P %d -f %s", port, dbPath);
+ ::swprintf(param, SIZEOF(param), L"-p -P %d", port);
+ int startingrt = ::CreateProcess(
+ fileName, param,
+ NULL, NULL, FALSE,
+ CREATE_NEW_CONSOLE,
+ NULL, NULL, &cif, &pi);
+ DWORD rterr = GetLastError();
+
+ //if (startingrt && rterr == ERROR_SUCCESS)
+ //return 1;
+ //else
+ //return 0;
+ return startingrt;
+}
+
+// ---
extern "C" int __declspec(dllexport) Load(void)
{
- mir_getXI(&xi);
+ int port = 8963;
+ VARST profilename( _T("%miranda_profilename%"));
+
+ if ( !StartSkypeRuntime(g_hInstance, (TCHAR*)profilename, port))
+ {
+ ::MessageBoxA(NULL, "", MODULE, MB_OK | MB_ICONERROR);
+ return 1;
+ }
+
+ char *keyPair = LoadKeyPair(g_hInstance);
+ if ( !keyPair)
+ {
+ ::MessageBoxA(NULL, "", MODULE, MB_OK | MB_ICONERROR);
+ return 1;
+ }
+
+ g_skype = new CSkype();
+ TransportInterface::Status status = g_skype->init(keyPair, "127.0.0.1", port);
+ if (status != TransportInterface::OK)
+ {
+ ::MessageBoxA(NULL, "", MODULE, MB_OK | MB_ICONERROR);
+ return 1;
+ }
+
+ if ( !g_skype->start())
+ {
+ ::MessageBoxA(NULL, "", MODULE, MB_OK | MB_ICONERROR);
+ return 1;
+ }
+
+ free(keyPair);
+
+ // ---
+
mir_getTMI(&tmi);
mir_getLP(&pluginInfo);
@@ -61,5 +313,8 @@ extern "C" int __declspec(dllexport) Unload(void) CSkypeProto::UninitMenus();
CSkypeProto::UninitIcons();
+ g_skype->stop();
+ delete g_skype;
+
return 0;
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index 8615ebf025..0a8d5a9f50 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -23,6 +23,7 @@ #include <m_database.h>
//#include <m_history.h>
//#include <m_idle.h>
+#include <m_folders.h>
#include <m_langpack.h>
#include <m_message.h>
#include <m_netlib.h>
@@ -48,14 +49,10 @@ #include <io.h>
#include <fcntl.h>
-
-#include <m_folders.h>
+#include <time.h>
#include "resource.h"
#include "version.h"
-#include "skype_subclassing.h"
-
-#include "..\..\..\skypekit\key.h"
#define MODULE "Skype"
#define SKYPE_SID_LIMIT 128
@@ -79,7 +76,7 @@ #define CMITEMS_COUNT 3
-extern HINSTANCE g_hInstance;
-
+class CSkype;
-struct CSkypeProto;
\ No newline at end of file +extern CSkype *g_skype;
+extern HINSTANCE g_hInstance;
\ No newline at end of file diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index d5a8db7f13..d28116a6ee 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -88,7 +88,7 @@ void __cdecl CSkypeProto::SignInAsync(void*) }
else
{
- ::CallService(MS_DB_CRYPT_ENCODESTRING, ::wcslen(this->password), (LPARAM)this->password);
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(this->password), (LPARAM)this->password);
}
this->LoadOwnInfo(this);
@@ -126,8 +126,8 @@ bool CSkypeProto::PreparePassword() ::mir_free(this->password);
this->password = NULL;
}
- this->password = ::db_get_wsa(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
- if ( !this->password || !::wcslen(this->password))
+ this->password = ::db_get_sa(NULL, this->m_szModuleName, SKYPE_SETTINGS_PASSWORD);
+ if ( !this->password || !::strlen(this->password))
{
if (this->password)
{
@@ -142,12 +142,12 @@ bool CSkypeProto::PreparePassword() }
else
{
- this->password = ::mir_wstrdup(param.password);
+ this->password = ::mir_strdup(param.password);
this->rememberPassword = param.rememberPassword;
}
}
else
- ::CallService(MS_DB_CRYPT_DECODESTRING, ::wcslen(this->password), (LPARAM)this->password);
+ ::CallService(MS_DB_CRYPT_DECODESTRING, ::strlen(this->password), (LPARAM)this->password);
}
return true;
@@ -158,7 +158,7 @@ bool CSkypeProto::SignIn(int status) if ( !this->PrepareLogin())
return false;
- if (this->skype->GetAccount(::mir_u2a(this->login), this->account))
+ if (g_skype->GetAccount(::mir_u2a(this->login), this->account))
{
if ( !this->PreparePassword())
return false;
@@ -172,7 +172,7 @@ bool CSkypeProto::SignIn(int status) this->SetAccountSettings();
- this->account->LoginWithPassword(::mir_utf8encodeW(this->password), false, false);
+ this->account->LoginWithPassword(this->password, false, false);
}
return true;
@@ -181,8 +181,8 @@ bool CSkypeProto::SignIn(int status) void CSkypeProto::SetAccountSettings()
{
int port = this->GetSettingWord("Port", rand() % 10000 + 10000);
- this->skype->SetInt(SETUPKEY_PORT, port);
- this->skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!this->GetSettingByte("UseAlternativePorts", 1));
+ g_skype->SetInt(SETUPKEY_PORT, port);
+ g_skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!this->GetSettingByte("UseAlternativePorts", 1));
}
bool CSkypeProto::IsAvatarChanged(const SEBinary &avatar)
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 3a909fa131..42a19fe190 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -195,7 +195,7 @@ void CSkypeProto::CreateChatWindow(CConversation::Ref conversation, bool showWin }
gcd.iType = GC_EVENT_CONTROL;
- ::CallServiceSync(MS_GC_EVENT, ShowWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce);
+ ::CallServiceSync(MS_GC_EVENT, showWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce);
::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce);
::mir_free(cid);
@@ -212,16 +212,16 @@ wchar_t *CSkypeProto::StartChat(const wchar_t *cid, const SEStringList &invitedC {
if (cid)
{
- this->skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
+ g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
conversation->GetJoinBlob(data);
- this->skype->GetConversationByBlob(data, conversation, false);
+ g_skype->GetConversationByBlob(data, conversation, false);
conversation->Join();
chatID = ::mir_wstrdup(cid);
}
else
{
- this->skype->CreateConference(conversation);
+ g_skype->CreateConference(conversation);
conversation->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
conversation->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
@@ -300,7 +300,7 @@ void CSkypeProto::JoinToChat(CConversation::Ref conversation, bool showWindow) mir_ptr<wchar_t> group = ::mir_utf8decodeW(CParticipant::GetRankName(rank));
CContact::Ref contact;
- this->skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
+ g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
CContact::AVAILABILITY status;
contact->GetPropAvailability(status);
@@ -392,9 +392,9 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM) CConversation::Ref conversation;
//todo: fixme
- this->skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
+ g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
conversation->GetJoinBlob(data);
- this->skype->GetConversationByBlob(data, conversation, false);
+ g_skype->GetConversationByBlob(data, conversation, false);
conversation->Join();
this->JoinToChat(conversation);
@@ -436,7 +436,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) case GC_SESSION_TERMINATE:
{
CConversation::Ref conversation;
- if (this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
+ if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
{
Participant::Refs participants;
conversation->GetParticipants(participants, CConversation::MYSELF);
@@ -449,7 +449,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) if (gch->ptszText && gch->ptszText[0])
{
CConversation::Ref conversation;
- if (this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
+ if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation, false))
{
CMessage::Ref message;
::mir_ptr<char> text(::mir_utf8encodeW(gch->ptszText));
@@ -588,7 +588,7 @@ void CSkypeProto::UpdateChatUserStatus(CContact::Ref contact) GC_INFO gci = {0};
gci.Flags = BYINDEX | ID;
- gci.pszModule = m_szModuleName;
+ gci.pszModule = this->m_szModuleName;
int count = ::CallServiceSync(MS_GC_GETSESSIONCOUNT, 0, (LPARAM)this->m_szModuleName);
for (int i = 0; i < count ; i++)
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index e2addbdc0f..22ef53c8de 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -234,7 +234,7 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact) void __cdecl CSkypeProto::LoadContactList(void*)
{
- this->skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
+ g_skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
this->commonList.fetch();
this->commonList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
@@ -262,7 +262,7 @@ void __cdecl CSkypeProto::LoadContactList(void*) void __cdecl CSkypeProto::LoadChatList(void*)
{
CConversation::Refs conversations;
- this->skype->GetConversationList(conversations);
+ g_skype->GetConversationList(conversations);
for (uint i = 0; i < conversations.size(); i++)
{
CConversation::TYPE type;
@@ -280,7 +280,7 @@ void __cdecl CSkypeProto::LoadChatList(void*) }
/*CConversation::Refs conversations;
- this->skype->GetConversationList(conversations);
+ g_skype->GetConversationList(conversations);
for (uint i = 0; i < conversations.size(); i++)
{
conversations[i]->Delete();
@@ -290,7 +290,7 @@ void __cdecl CSkypeProto::LoadChatList(void*) void __cdecl CSkypeProto::LoadAuthWaitList(void*)
{
CContact::Refs authContacts;
- this->skype->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
+ g_skype->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
this->authWaitList.fetch();
this->authWaitList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
@@ -334,7 +334,7 @@ void CSkypeProto::OnSearchCompleted(HANDLE hSearch) this->SendBroadcast(ACKTYPE_SEARCH, ACKRESULT_SUCCESS, hSearch, 0);
}
-void CSkypeProto::OnContactFinded(HANDLE hSearch, CContact::Ref contact)
+void CSkypeProto::OnContactFinded(CContact::Ref contact, HANDLE hSearch)
{
PROTOSEARCHRESULT psr = {0};
psr.cbSize = sizeof(psr);
@@ -380,7 +380,7 @@ void __cdecl CSkypeProto::SearchBySidAsync(void* arg) }
CContactSearch::Ref search;
- this->skype->CreateIdentitySearch(::mir_u2a(sid), search);
+ g_skype->CreateIdentitySearch(::mir_u2a(sid), search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYSID);
search->SetOnContactFindedCallback(
@@ -404,7 +404,7 @@ void __cdecl CSkypeProto::SearchByEmailAsync(void* arg) wchar_t *email = (wchar_t *)arg;
CContactSearch::Ref search;
- this->skype->CreateContactSearch(search);
+ g_skype->CreateContactSearch(search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYEMAIL);
search->SetOnContactFindedCallback(
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index c6d2778aa9..2e4bfe4139 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -12,16 +12,16 @@ bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* gu dbei.pBlob = (PBYTE)::mir_alloc(dbei.cbBlob);
::db_event_get(hDbEvent, &dbei);
- if (dbei.timestamp < timestamp)
+ /*if (dbei.timestamp < timestamp)
{
::mir_free(dbei.pBlob);
break;
- }
+ }*/
int sendFlag = dbei.flags & DBEF_SENT;
if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
{
- if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
+ if (::memcmp(&dbei.pBlob[dbei.cbBlob], guid, 32) == 0)
{
::mir_free(dbei.pBlob);
result = true;
@@ -100,9 +100,9 @@ void CSkypeProto::RaiseMessageReceivedEvent( const wchar_t *message,
bool isNeedCheck)
{
- if (isNeedCheck)
- if (this->IsMessageInDB(hContact, timestamp, guid))
- return;
+ //if (isNeedCheck)
+ // if (this->IsMessageInDB(hContact, timestamp, guid))
+ // return;
PROTORECVEVENT recv;
recv.flags = PREF_UTF;
@@ -119,8 +119,8 @@ void CSkypeProto::RaiseMessageSendedEvent( const char *guid,
const wchar_t *message)
{
- if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT))
- return;
+ //if (this->IsMessageInDB(hContact, timestamp, guid, DBEF_SENT))
+ // return;
char *msg = ::mir_utf8encodeW(message);
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 009e8c690c..5c31c68dec 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -13,8 +13,8 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR proto = (CSkypeProto*)lParam;
::SetWindowLongPtr(hwnd, GWLP_USERDATA, lParam);
{
- char *sid = ::db_get_sa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN);
- SetDlgItemTextA(hwnd, IDC_SL, sid);
+ wchar_t *sid = ::db_get_wsa(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ SetDlgItemText(hwnd, IDC_SL, sid);
::mir_free(sid);
}
{
@@ -65,9 +65,9 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR if (!proto->IsOnline() && proto->GetSettingWord("Status") <= ID_STATUS_OFFLINE)
{
- char sid[128];
- GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
- EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::strlen(sid));
+ wchar_t sid[128];
+ GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
+ EnableWindow(GetDlgItem(hwnd, IDC_REGISTER), ::wcslen(sid));
}
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
@@ -98,12 +98,12 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
CSkype::VALIDATERESULT reason;
- proto->skype->ValidatePassword(sid, pwd, reason);
+ g_skype->ValidatePassword(sid, pwd, reason);
if (reason == CSkype::VALIDATED_OK)
{
CAccount::Ref account;
- proto->skype->GetAccount(sid, proto->account);
+ g_skype->GetAccount(sid, proto->account);
proto->account->SetStrProperty(CAccount::P_FULLNAME, sid);
proto->account->SetOnAccountChangedCallback(
(CAccount::OnAccountChanged)&CSkypeProto::OnAccountChanged, proto);
@@ -117,14 +117,14 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR case IDC_CHANGE_PWD:
{
- wchar_t sid[128], pwd[128];
- GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
- GetDlgItemText(hwnd, IDC_PW, pwd, SIZEOF(pwd));
+ char sid[128], pwd[128];
+ GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
+ GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
PasswordChangeBoxParam param;
if (proto->ChangePassword(param))
{
- proto->account->ChangePassword(::mir_utf8encodeW(param.password), ::mir_utf8encodeW(param.password2));
+ proto->account->ChangePassword(param.password, param.password2);
}
}
break;
@@ -135,15 +135,16 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR case WM_NOTIFY:
if (reinterpret_cast<NMHDR*>(lParam)->code == PSN_APPLY && !proto->IsOnline())
{
- wchar_t data[128];
- GetDlgItemText(hwnd, IDC_SL, data, SIZEOF(data));
- ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN, data);
+ wchar_t sid[128];
+ GetDlgItemText(hwnd, IDC_SL, sid, SIZEOF(sid));
+ ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_LOGIN, sid);
::mir_free(proto->login);
- proto->login = ::mir_wstrdup(data);
+ proto->login = ::mir_wstrdup(sid);
- GetDlgItemText(hwnd, IDC_PW, data, sizeof(data));
- ::CallService(MS_DB_CRYPT_ENCODESTRING, wcslen(data), (LPARAM)&data);
- ::db_set_ws(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, data);
+ char pwd[128];
+ GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
+ ::CallService(MS_DB_CRYPT_ENCODESTRING, ::strlen(pwd), (LPARAM)&pwd);
+ ::db_set_s(NULL, proto->m_szModuleName, SKYPE_SETTINGS_PASSWORD, pwd);
HWND item = GetDlgItem(hwnd, IDC_PORT);
if (item)
@@ -233,9 +234,9 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordRequestProc(HWND hwndDlg, UINT msg, W {
param->rememberPassword = ::IsDlgButtonChecked(hwndDlg, IDC_SAVEPASSWORD) > 0;
- wchar_t password[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemText(hwndDlg, IDC_PASSWORD, password, SIZEOF(password));
- param->password = ::mir_wstrdup(password);
+ char password[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, password, SIZEOF(password));
+ param->password = ::mir_strdup(password);
::EndDialog(hwndDlg, IDOK);
}
@@ -290,16 +291,16 @@ INT_PTR CALLBACK CSkypeProto::SkypePasswordChangeProc(HWND hwndDlg, UINT msg, WP {
case IDOK:
{
- wchar_t oldPwd[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemText(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd));
- param->password = ::mir_wstrdup(oldPwd);
+ char oldPwd[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD, oldPwd, SIZEOF(oldPwd));
+ param->password = ::mir_strdup(oldPwd);
- wchar_t pwd1[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemText(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1));
- param->password2 = ::mir_wstrdup(pwd1);
+ char pwd1[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD2, pwd1, SIZEOF(pwd1));
+ param->password2 = ::mir_strdup(pwd1);
- wchar_t pwd2[SKYPE_PASSWORD_LIMIT];
- ::GetDlgItemText(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2));
+ char pwd2[SKYPE_PASSWORD_LIMIT];
+ ::GetDlgItemTextA(hwndDlg, IDC_PASSWORD3, pwd2, SIZEOF(pwd2));
::EndDialog(hwndDlg, IDOK);
}
@@ -647,7 +648,7 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP {
CContact::Ref contact;
CContact::AVAILABILITY status;
- param->ppro->skype->GetContact(invitedContacts[i], contact);
+ g_skype->GetContact(invitedContacts[i], contact);
contact->GetPropAvailability(status);
//todo: fix rank
@@ -659,7 +660,7 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP }
CConversation::Ref conversation;
- param->ppro->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
+ g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
conversation->AddConsumers(invitedContacts);
}
else
@@ -670,7 +671,7 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP {
CContact::Ref contact;
CContact::AVAILABILITY status;
- param->ppro->skype->GetContact(invitedContacts[i], contact);
+ g_skype->GetContact(invitedContacts[i], contact);
contact->GetPropAvailability(status);
//todo: fix rank
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 23a3599fcb..b35300a3b8 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -2,8 +2,6 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
{
- this->InitSkype();
-
this->InitChat();
this->InitNetLib();
this->InitCustomFolders();
@@ -11,6 +9,10 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM) this->HookEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
this->HookEvent(ME_USERINFO_INITIALISE, &CSkypeProto::OnUserInfoInit);
+ g_skype->SetOnMessageCallback(
+ (CSkype::OnMessaged)&CSkypeProto::OnMessage,
+ this);
+
return 0;
}
@@ -19,7 +21,6 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM) this->SetStatus(ID_STATUS_OFFLINE);
this->UninitNetLib();
- this->UninitSkype();
return 0;
}
@@ -35,7 +36,7 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) this->LeaveChat(chatID);
CConversation::Ref conversation;
- this->skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
+ g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
conversation->RetireFrom();
conversation->Delete();
}
@@ -55,15 +56,17 @@ int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam) SEBinary guid;
if (message->GetPropGuid(guid))
{
- evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, (evt->dbei->cbBlob + 32));
+ evt->dbei->pBlob = (PBYTE)::mir_realloc(evt->dbei->pBlob, (evt->dbei->cbBlob + 33));
::memcpy(&evt->dbei->pBlob[evt->dbei->cbBlob], guid.data(), 32);
- evt->dbei->cbBlob += 32;
+ evt->dbei->cbBlob += 33;
}
+ //delete message;
+
return 1;
}
-void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnMessageSended(CConversation::Ref &conversation, CMessage::Ref &message)
{
SEString data;
@@ -88,7 +91,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref participants[0]->GetPropIdentity(data);
CContact::Ref receiver;
- this->skype->GetContact(data, receiver);
+ g_skype->GetContact(data, receiver);
HANDLE hContact = this->AddContact(receiver);
@@ -130,7 +133,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref ::mir_free(text);
}
-void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
{
SEString data;
@@ -150,7 +153,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R message->GetPropAuthor(data);
CContact::Ref author;
- this->skype->GetContact(data, author);
+ g_skype->GetContact(data, author);
HANDLE hContact = this->AddContact(author);
@@ -181,7 +184,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R ::mir_free(text);
}
-void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer)
+void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
{
switch (prop)
{
@@ -191,7 +194,7 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) transfer->GetPropChatmsgGuid(guid);
CMessage::Ref message;
- this->skype->GetMessageByGuid(guid, message);
+ g_skype->GetMessageByGuid(guid, message);
uint oid = message->getOID();
@@ -239,7 +242,7 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) transfer->GetPropChatmsgGuid(guid);
CMessage::Ref message;
- this->skype->GetMessageByGuid(guid, message);
+ g_skype->GetMessageByGuid(guid, message);
uint oid = message->getOID();
@@ -259,10 +262,10 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) pfts.pszFiles = &pfts.szCurrentFile;
transfer->GetPropFilesize(data);
- pfts.totalBytes = pfts.currentFileSize = data.toUInt();
+ pfts.totalBytes = pfts.currentFileSize = data.toUInt64();
transfer->GetPropBytestransferred(data);
- pfts.totalProgress = pfts.currentFileProgress = data.toUInt();
+ pfts.totalProgress = pfts.currentFileProgress = data.toUInt64();
this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)oid, (LPARAM)&pfts);
}
@@ -270,7 +273,7 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) }
}
-void CSkypeProto::OnFile(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnFile(CConversation::Ref &conversation, CMessage::Ref &message)
{
CTransfer::Refs transfers;
message->GetTransfers(transfers);
@@ -375,7 +378,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa if ( !alreadyInChat.contains(sid))
{
CContact::Ref contact;
- this->skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
+ g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
CContact::AVAILABILITY status;
contact->GetPropAvailability(status);
@@ -453,7 +456,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa message->GetPropAuthor(identity);
CContact::Ref author;
- this->skype->GetContact(identity, author); + g_skype->GetContact(identity, author); HANDLE hContact = this->AddContact(author); diff --git a/protocols/Skype/src/skype_instances.cpp b/protocols/Skype/src/skype_instances.cpp index a34d99a192..996c588164 100644 --- a/protocols/Skype/src/skype_instances.cpp +++ b/protocols/Skype/src/skype_instances.cpp @@ -1,10 +1,5 @@ #include "skype_proto.h"
-int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam)
-{
- return this->SendBroadcast(NULL, type, result, hProcess, lParam);
-}
-
LIST<CSkypeProto> CSkypeProto::instanceList(1, CSkypeProto::CompareProtos);
CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* userName)
@@ -18,6 +13,7 @@ CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* u MB_ICONWARNING);
return NULL;
}
+
CSkypeProto *ppro = new CSkypeProto(protoName, userName);
CSkypeProto::instanceList.insert(ppro);
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index 59f9723ef7..fc08f4b814 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -77,7 +77,7 @@ int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam) CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
- if (this->skype->GetContact(sid, contact))
+ if (g_skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(true))
{
@@ -94,7 +94,7 @@ int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam) CContact::Ref contact;
HANDLE hContact = (HANDLE)wParam;
SEString sid(::mir_u2a(::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN))));
- if (this->skype->GetContact(sid, contact))
+ if (g_skype->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(false))
{
diff --git a/protocols/Skype/src/skype_netlib.cpp b/protocols/Skype/src/skype_netlib.cpp index 7401e8c84e..e0782e4a9f 100644 --- a/protocols/Skype/src/skype_netlib.cpp +++ b/protocols/Skype/src/skype_netlib.cpp @@ -38,40 +38,40 @@ void CSkypeProto::InitProxy() {
case PROXYTYPE_HTTP:
case PROXYTYPE_HTTPS:
- this->skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1);
- this->skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0);
- this->skype->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address);
+ g_skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1);
+ g_skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0);
+ g_skype->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
char encodedPass[MAX_PATH];
Base64::Encode(nlus.szProxyAuthPassword, encodedPass, MAX_PATH);
- this->skype->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
- this->skype->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass);
+ g_skype->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
+ g_skype->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass);
}
break;
case PROXYTYPE_SOCKS4:
case PROXYTYPE_SOCKS5:
- this->skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0);
- this->skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1);
- this->skype->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address);
+ g_skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0);
+ g_skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1);
+ g_skype->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
- this->skype->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
- this->skype->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword);
+ g_skype->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
+ g_skype->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword);
}
break;
default:
- this->skype->Delete(SETUPKEY_HTTPS_PROXY_ENABLE);
- this->skype->Delete(SETUPKEY_HTTPS_PROXY_ADDR);
- this->skype->Delete(SETUPKEY_HTTPS_PROXY_USER);
- this->skype->Delete(SETUPKEY_HTTPS_PROXY_PWD);
- this->skype->Delete(SETUPKEY_SOCKS_PROXY_ENABLE);
- this->skype->Delete(SETUPKEY_SOCKS_PROXY_ADDR);
- this->skype->Delete(SETUPKEY_SOCKS_PROXY_USER);
- this->skype->Delete(SETUPKEY_SOCKS_PROXY_PWD);
+ g_skype->Delete(SETUPKEY_HTTPS_PROXY_ENABLE);
+ g_skype->Delete(SETUPKEY_HTTPS_PROXY_ADDR);
+ g_skype->Delete(SETUPKEY_HTTPS_PROXY_USER);
+ g_skype->Delete(SETUPKEY_HTTPS_PROXY_PWD);
+ g_skype->Delete(SETUPKEY_SOCKS_PROXY_ENABLE);
+ g_skype->Delete(SETUPKEY_SOCKS_PROXY_ADDR);
+ g_skype->Delete(SETUPKEY_SOCKS_PROXY_USER);
+ g_skype->Delete(SETUPKEY_SOCKS_PROXY_PWD);
break;
}
}
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index dac3c2dd7d..e3b4edefd2 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -2,7 +2,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
{
- ProtoConstructor(this, protoName, userName);
+ ::ProtoConstructor(this, protoName, userName);
this->rememberPassword = false;
@@ -15,7 +15,7 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) dbEventType.descr = "Call";
::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
- this->HookEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate);
+ //this->HookEvent(ME_MSG_PRECREATEEVENT, &CSkypeProto::OnMessagePreCreate);
this->CreateServiceObj(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit);
// Chat API
@@ -46,7 +46,7 @@ HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr) {
//fixme
CContact::Ref contact;
- this->skype->GetContact(::mir_u2a(psr->id), contact);
+ g_skype->GetContact(::mir_u2a(psr->id), contact);
return this->AddContact(contact);
return 0;
}
@@ -128,7 +128,7 @@ int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) {
CContact::Ref contact;
SEString sid(::mir_u2a(this->GetSettingString(hContact, SKYPE_SETTINGS_LOGIN)));
- if (this->skype->GetContact(sid, contact))
+ if (g_skype->GetContact(sid, contact))
{
contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
contact->SendAuthRequest(::mir_utf8encodeW(szMessage));
@@ -146,7 +146,7 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const {
uint oid = (uint)hTransfer;
- MessageRef message(oid);
+ CMessage *message = new CMessage(oid, g_skype);
CTransfer::Refs transfers;
message->GetTransfers(transfers);
@@ -160,9 +160,12 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const if (!transfers[i]->Accept(::mir_u2a(fullPath), success) || !success)
{
// todo: write to log!
+ delete message;
return 0;
}
}
+
+ delete message;
return hTransfer;
}
@@ -225,7 +228,7 @@ DWORD_PTR __cdecl CSkypeProto:: GetCaps(int type, HANDLE hContact) return PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS |
PF4_OFFLINEFILES | PF4_IMSENDUTF | PF4_IMSENDOFFLINE;
case PFLAG_UNIQUEIDTEXT:
- return (DWORD_PTR)::Translate("Skype Name");
+ return (DWORD_PTR)::Translate("g_skype Name");
case PFLAG_UNIQUEIDSETTING:
return (DWORD_PTR)SKYPE_SETTINGS_LOGIN;
default:
@@ -286,9 +289,9 @@ int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre) ::db_unset(hContact, "CList", "Hidden");
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
- int length = ::strlen(pre->szMessage) + 1;
+ /*int length = ::strlen(pre->szMessage) + 1;
pre->szMessage = (char *)::mir_realloc(pre->szMessage, length + 32);
- ::memcpy(&pre->szMessage[length], (char *)pre->lParam, 32);
+ ::memcpy(&pre->szMessage[length], (char *)pre->lParam, 32);*/
return ::Proto_RecvMessage(hContact, pre);
}
@@ -305,7 +308,8 @@ HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescriptio mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
targets.append((char *)mir_ptr<char>(::mir_utf8encodeW(sid)));
- CConversation::Ref conversation = CConversation::FindBySid(this->skype, sid);
+ CConversation::Ref conversation;
+ g_skype->GetConversationByParticipants(targets, conversation);
SEFilenameList fileList;
for (int i = 0; ppszFiles[i]; i++)
@@ -337,9 +341,13 @@ HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescriptio int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg)
{
- CConversation::Ref conversation = CConversation::FindBySid(
- this->skype,
- ::mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)));
+ SEStringList targets;
+ wchar_t * sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN);
+ SEString identity = ::mir_u2a(sid);
+ targets.append(identity);
+
+ CConversation::Ref conversation;
+ g_skype->GetConversationByParticipants(targets, conversation);
if (conversation)
{
@@ -428,7 +436,13 @@ int __cdecl CSkypeProto::UserIsTyping( HANDLE hContact, int type ) mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
if (::wcsicmp(sid, this->login) != 0)
{
- CConversation::Ref conversation = CConversation::FindBySid(this->skype, sid);
+ SEStringList targets;
+ mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
+ targets.append((char *)mir_ptr<char>(::mir_utf8encodeW(sid)));
+
+ CConversation::Ref conversation;
+ g_skype->GetConversationByParticipants(targets, conversation);
+
if (conversation)
{
switch (type)
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 017e3b7af9..4f72dc8096 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -1,7 +1,7 @@ #pragma once
#include "skype.h"
-#include <time.h>
+#include "skypekit\skype.h"
typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
@@ -119,7 +119,7 @@ struct InviteChatParam struct PasswordRequestBoxParam
{
wchar_t *login;
- wchar_t *password;
+ char *password;
bool rememberPassword;
bool showRememberPasswordBox;
@@ -138,8 +138,8 @@ struct PasswordRequestBoxParam struct PasswordChangeBoxParam
{
- wchar_t *password;
- wchar_t *password2;
+ char *password;
+ char *password2;
PasswordChangeBoxParam() { }
@@ -153,7 +153,7 @@ struct PasswordChangeBoxParam struct CSkypeProto : public PROTO_INTERFACE
{
public:
- CSkypeProto(const char *, const wchar_t *);
+ CSkypeProto(const char *protoName, const wchar_t *userName);
~CSkypeProto();
// PROTO_INTERFACE
@@ -242,7 +242,6 @@ public: bool IsOnline();
protected:
- CSkype *skype;
CAccount::Ref account;
CContact::Refs contactList;
CTransfer::Refs transferList;
@@ -253,7 +252,7 @@ protected: void OnAccountChanged(int prop);
wchar_t *login;
- wchar_t *password;
+ char *password;
bool rememberPassword;
bool RequestPassword(PasswordRequestBoxParam ¶m);
@@ -279,12 +278,12 @@ protected: // messages
void OnMessage(CConversation::Ref conversation, CMessage::Ref message);
- void OnMessageSended(CConversation::Ref conversation, CMessage::Ref message);
- void OnMessageReceived(CConversation::Ref conversation, CMessage::Ref message);
+ void OnMessageSended(CConversation::Ref &conversation, CMessage::Ref &message);
+ void OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message);
// transfer
- void OnFile(CConversation::Ref conversation, CMessage::Ref message);
- void OnTransferChanged(int prop, CTransfer::Ref transfer);
+ void OnFile(CConversation::Ref &conversation, CMessage::Ref &message);
+ void OnTransferChanged(CTransfer::Ref transfer, int prop);
// chat
static wchar_t* Groups[];
@@ -329,7 +328,7 @@ protected: void UpdateContactLastEventDate(SEObject *obj, HANDLE hContact);
void OnSearchCompleted(HANDLE hSearch);
- void OnContactFinded(HANDLE hSearch, CContact::Ref contact);
+ void OnContactFinded(CContact::Ref contact, HANDLE hSearch);
void OnContactChanged(CContact::Ref contact, int prop);
void OnContactListChanged(const ContactRef& contact);
@@ -396,10 +395,6 @@ protected: SEBinary GetAvatarBinary(wchar_t *path);
- // runtime
- void InitSkype();
- void UninitSkype();
-
// instances
static LIST<CSkypeProto> instanceList;
static int CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2);
diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp deleted file mode 100644 index 45c1def4a2..0000000000 --- a/protocols/Skype/src/skype_runtime.cpp +++ /dev/null @@ -1,18 +0,0 @@ -#include "skype_proto.h"
-
-void CSkypeProto::InitSkype()
-{
- wchar_t *profileName = ::Utils_ReplaceVarsT(L"%miranda_profilename%");
- wchar_t *dbPath = ::Utils_ReplaceVarsT(L"%miranda_userdata%\\SkypeKit\\");
-
- this->skype = CSkype::GetInstance(g_hInstance, profileName, dbPath);
- this->skype->SetOnMessageCallback(
- (CSkype::OnMessaged)&CSkypeProto::OnMessage,
- this);
-}
-
-void CSkypeProto::UninitSkype()
-{
- this->skype->stop();
- delete this->skype;
-}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.cpp b/protocols/Skype/src/skype_subclassing.cpp deleted file mode 100644 index a055f0782f..0000000000 --- a/protocols/Skype/src/skype_subclassing.cpp +++ /dev/null @@ -1,574 +0,0 @@ -#include "skype.h"
-
-#include "base64/base64.h"
-extern "C"
-{
-#include "aes\aes.h"
-}
-
-// CSkype
-
-CSkype::CSkype(int num_threads) : Skype(num_threads)
-{
- this->proto = NULL;
- this->onMessagedCallback = NULL;
-}
-
-CAccount* CSkype::newAccount(int oid)
-{
- return new CAccount(oid, this);
-}
-
-CContactGroup* CSkype::newContactGroup(int oid)
-{
- return new CContactGroup(oid, this);
-}
-
-CContact* CSkype::newContact(int oid)
-{
- return new CContact(oid, this);
-}
-
-CConversation* CSkype::newConversation(int oid)
-{
- return new CConversation(oid, this);
-}
-
-CParticipant* CSkype::newParticipant(int oid)
-{
- return new CParticipant(oid, this);
-}
-
-CMessage* CSkype::newMessage(int oid)
-{
- return new CMessage(oid, this);
-}
-
-CTransfer* CSkype::newTransfer(int oid)
-{
- return new CTransfer(oid, this);
-}
-
-CContactSearch* CSkype::newContactSearch(int oid)
-{
- return new CContactSearch(oid, this);
-}
-
-void CSkype::OnMessage (
- const MessageRef & message,
- const bool & changesInboxTimestamp,
- const MessageRef & supersedesHistoryMessage,
- const ConversationRef & conversation)
-{
- /*uint now;
- skype->GetUnixTimestamp(now);
- conversation->SetConsumedHorizon(now);*/
-
- if (this->proto)
- (proto->*onMessagedCallback)(conversation->ref(), message->ref());
-}
-
-void CSkype::SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->onMessagedCallback = callback;
-}
-
-BOOL CSkype::IsRunAsAdmin()
-{
- BOOL fIsRunAsAdmin = FALSE;
- DWORD dwError = ERROR_SUCCESS;
- PSID pAdministratorsGroup = NULL;
-
- // Allocate and initialize a SID of the administrators group.
- SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
- if ( !AllocateAndInitializeSid(
- &NtAuthority,
- 2,
- SECURITY_BUILTIN_DOMAIN_RID,
- DOMAIN_ALIAS_RID_ADMINS,
- 0, 0, 0, 0, 0, 0,
- &pAdministratorsGroup))
- {
- dwError = GetLastError();
- goto Cleanup;
- }
-
- // Determine whether the SID of administrators group is enabled in
- // the primary access token of the process.
- if ( !CheckTokenMembership(NULL, pAdministratorsGroup, &fIsRunAsAdmin))
- {
- dwError = GetLastError();
- goto Cleanup;
- }
-
-Cleanup:
- // Centralized cleanup for all allocated resources.
- if (pAdministratorsGroup)
- {
- FreeSid(pAdministratorsGroup);
- pAdministratorsGroup = NULL;
- }
-
- // Throw the error if something failed in the function.
- if (ERROR_SUCCESS != dwError)
- {
- throw dwError;
- }
-
- return fIsRunAsAdmin;
-}
-
-char *CSkype::LoadKeyPair(HINSTANCE hInstance)
-{
- HRSRC hRes = FindResource(hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
- if (hRes)
- {
- HGLOBAL hResource = LoadResource(hInstance, hRes);
- if (hResource)
- {
- aes_context ctx;
- unsigned char key[128];
-
- int basedecoded = Base64::Decode(MY_KEY, (char *)key, MAX_PATH);
- ::aes_set_key(&ctx, key, 128);
- memset(key, 0, sizeof(key));
-
- basedecoded = ::SizeofResource(hInstance, hRes);
- char *pData = (char *)hResource;
- if (!pData)
- return NULL;
-
- unsigned char *bufD = (unsigned char*)::malloc(basedecoded + 1);
- unsigned char *tmpD = (unsigned char*)::malloc(basedecoded + 1);
- basedecoded = Base64::Decode(pData, (char *)tmpD, basedecoded);
-
- for (int i = 0; i < basedecoded; i += 16)
- aes_decrypt(&ctx, tmpD+i, bufD+i);
-
- ::free(tmpD);
- bufD[basedecoded] = 0; //cert should be null terminated
- return (char *)bufD;
- }
- return NULL;
- }
- return NULL;
-}
-
-int CSkype::StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, int &port, const wchar_t *dbPath)
-{
- STARTUPINFO cif;
- PROCESS_INFORMATION pi;
- wchar_t param[128];
-
- ::ZeroMemory(&cif, sizeof(STARTUPINFO));
- cif.cb = sizeof(STARTUPINFO);
- cif.dwFlags = STARTF_USESHOWWINDOW;
- cif.wShowWindow = SW_HIDE;
-
- //HRSRC hRes;
- //HGLOBAL hResource;
- wchar_t fileName[MAX_PATH];
-
- HRSRC hRes = ::FindResource(hInstance, MAKEINTRESOURCE(/*IDR_RUNTIME*/102), L"BIN");
- if (hRes)
- {
- HGLOBAL hResource = ::LoadResource(hInstance, hRes);
- if (hResource)
- {
- HANDLE hFile;
- char *pData = (char *)LockResource(hResource);
- DWORD dwSize = SizeofResource(hInstance, hRes), written = 0;
- ::GetModuleFileName(hInstance, fileName, MAX_PATH);
-
- wchar_t *skypeKitPath = ::wcsrchr(fileName, '\\');
- if (skypeKitPath != NULL)
- *skypeKitPath = 0;
- ::swprintf(fileName, SIZEOF(fileName), L"%s\\%s", fileName, L"SkypeKit.exe");
- if ( !::PathFileExists(fileName))
- {
- if ((hFile = ::CreateFile(
- fileName,
- GENERIC_WRITE,
- 0,
- NULL,
- CREATE_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- 0)) != INVALID_HANDLE_VALUE)
- {
- ::WriteFile(hFile, (void *)pData, dwSize, &written, NULL);
- ::CloseHandle(hFile);
- }
- else
- {
- // Check the current process's "run as administrator" status.
- // Elevate the process if it is not run as administrator.
- if (!CSkype::IsRunAsAdmin())
- {
- wchar_t path[MAX_PATH], cmdLine[100];
- ::GetModuleFileName(NULL, path, ARRAYSIZE(path));
- ::swprintf(
- cmdLine,
- SIZEOF(cmdLine),
- L" /restart:%d /profile=%s",
- ::GetCurrentProcessId(),
- profileName);
-
- // Launch itself as administrator.
- SHELLEXECUTEINFO sei = { sizeof(sei) };
- sei.lpVerb = L"runas";
- sei.lpFile = path;
- sei.lpParameters = cmdLine;
- //sei.hwnd = hDlg;
- sei.nShow = SW_NORMAL;
-
- if ( !::ShellExecuteEx(&sei))
- {
- DWORD dwError = ::GetLastError();
- if (dwError == ERROR_CANCELLED)
- {
- // The user refused to allow privileges elevation.
- // Do nothing ...
- }
- }
- //else
- //{
- // //DestroyWindow(hDlg); // Quit itself
- // ::CallService("CloseAction", 0, 0);
- //}
- }
- return 0;
- }
- }
- }
- }
-
- PROCESSENTRY32 entry;
- entry.dwSize = sizeof(PROCESSENTRY32);
-
- HANDLE snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
- if (::Process32First(snapshot, &entry) == TRUE) {
- while (::Process32Next(snapshot, &entry) == TRUE) {
- if (::wcsicmp(entry.szExeFile, L"SkypeKit.exe") == 0) {
- HANDLE hProcess = ::OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
- port += rand() % 8963 + 1000;
- ::CloseHandle(hProcess);
- break;
- }
- }
- }
- ::CloseHandle(snapshot);
-
- //::swprintf(param, SIZEOF(param), L"-p -P %d -f %s", port, dbPath);
- ::swprintf(param, SIZEOF(param), L"-p -P %d", port);
- int startingrt = ::CreateProcess(
- fileName, param,
- NULL, NULL, FALSE,
- CREATE_NEW_CONSOLE,
- NULL, NULL, &cif, &pi);
- DWORD rterr = GetLastError();
-
- //if (startingrt && rterr == ERROR_SUCCESS)
- //return 1;
- //else
- //return 0;
- return startingrt;
-}
-
-CSkype *CSkype::GetInstance(HINSTANCE hInstance, const wchar_t *profileName, const wchar_t *dbPath)
-{
- int port = 8963;
- if (!CSkype::StartSkypeRuntime(hInstance, profileName, port, dbPath)) return NULL;
-
- char *keyPair = CSkype::LoadKeyPair(hInstance);
- if (!keyPair)
- return NULL;
-
- CSkype *skype = new CSkype();
- TransportInterface::Status status = skype->init(keyPair, "127.0.0.1", port);
- if (status != TransportInterface::OK)
- return NULL;
- skype->start();
-
- free(keyPair);
-
- //this->skype->SetOnMessageCallback((CSkype::OnMessaged)&CSkypeProto::OnMessage, this);
- return skype;
-}
-
-// CAccount
-
-CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root)
-{
- this->proto = NULL;
- this->callback == NULL;
-}
-
-void CAccount::SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto)
-{
- this->skype = (CSkype *)root;
-
- this->proto = proto;
- this->callback = callback;
-}
-
-bool CAccount::SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result)
-{
- int fbl;
- if (!this->skype->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK)
- return false;
-
- if (!this->SetBinProperty(Account::P_AVATAR_IMAGE, avatar))
- return false;
-
- return true;
-}
-
-void CAccount::OnChange(int prop)
-{
- if (this->proto)
- (proto->*callback)(prop);
-}
-
-// CContactGroup
-
-CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root)
-{
- this->proto = NULL;
- this->callback == NULL;
-}
-
-void CContactGroup::SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->callback = callback;
-}
-
-void CContactGroup::OnChange(const ContactRef& contact)
-{
- if (this->proto)
- (proto->*callback)(contact);
-}
-
-// CContactSearch
-
-CContactSearch::CContactSearch(unsigned int oid, SERootObject* root) : ContactSearch(oid, root)
-{
- this->proto = NULL;
- this->SearchCompletedCallback == NULL;
- this->ContactFindedCallback == NULL;
-}
-
-void CContactSearch::OnChange(int prop)
-{
- if (prop == P_CONTACT_SEARCH_STATUS)
- {
- CContactSearch::STATUS status;
- this->GetPropContactSearchStatus(status);
- if (status == FINISHED || status == FAILED)
- {
- this->isSeachFinished = true;
- if (this->proto)
- (proto->*SearchCompletedCallback)(this->hSearch);
- }
- }
-}
-
-void CContactSearch::OnNewResult(const ContactRef& contact, const uint& rankValue)
-{
- if (this->proto)
- (proto->*ContactFindedCallback)(this->hSearch, contact->ref());
-}
-
-void CContactSearch::BlockWhileSearch()
-{
- this->isSeachFinished = false;
- this->isSeachFailed = false;
- while (!this->isSeachFinished && !this->isSeachFailed)
- Sleep(1);
-}
-
-void CContactSearch::SetProtoInfo(CSkypeProto* proto, HANDLE hSearch)
-{
- this->proto = proto;
- this->hSearch = hSearch;
-}
-
-void CContactSearch::SetOnSearchCompleatedCallback(OnSearchCompleted callback)
-{
- this->SearchCompletedCallback = callback;
-}
-
-void CContactSearch::SetOnContactFindedCallback(OnContactFinded callback)
-{
- this->ContactFindedCallback = callback;
-}
-
-// CParticipant
-
-CParticipant::CParticipant(unsigned int oid, SERootObject* root) : Participant(oid, root) { }
-
-SEString CParticipant::GetRankName(CParticipant::RANK rank)
-{
- char *result = NULL;
- switch (rank)
- {
- case CParticipant::CREATOR:
- result = "Creator";
- break;
- case CParticipant::ADMIN:
- result = "Admin";
- break;
- case CParticipant::SPEAKER:
- result = "Speaker";
- break;
- case CParticipant::WRITER:
- result = "Writer";
- break;
- case CParticipant::SPECTATOR:
- result = "Spectator";
- break;
- case CParticipant::RETIRED:
- result = "Retried";
- break;
- case CParticipant::OUTLAW:
- result = "Outlaw";
- break;
- }
- return result;
-}
-
-// CContact
-
-CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
-{
- this->proto = NULL;
- this->callback == NULL;
-}
-
-SEString CContact::GetSid()
-{
- SEString result;
- CContact::AVAILABILITY availability;
- this->GetPropAvailability(availability);
- if (availability == CContact::SKYPEOUT)
- this->GetPropPstnnumber(result);
- else
- this->GetPropSkypename(result);
- return result;
-}
-
-SEString CContact::GetNick()
-{
- SEString result;
- CContact::AVAILABILITY availability;
- this->GetPropAvailability(availability);
- if (availability == CContact::SKYPEOUT)
- result = this->GetSid();
- else
- this->GetPropDisplayname(result);
- return result;
-}
-
-bool CContact::GetFullname(SEString &firstName, SEString &lastName)
-{
- SEString fullname;
- this->GetPropFullname(fullname);
- int pos = fullname.find(" ");
- if (pos && pos < fullname.length())
- {
- firstName = fullname.substr(0, pos);
- lastName = fullname.right(pos);
- }
-
- firstName = fullname;
-
- return true;
-}
-
-void CContact::SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->callback = callback;
-}
-
-//bool CContact::SentAuthRequest(SEString message)
-//{
-// this->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
-// this->SendAuthRequest(message);
-//}
-
-void CContact::OnChange(int prop)
-{
- if (this->proto)
- (proto->*callback)(this->ref(), prop);
-}
-
-// Conversation
-
-CConversation::CConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root)
-{
- this->proto = NULL;
- this->messageReceivedCallback = NULL;
-}
-
-void CConversation::OnMessage(const MessageRef & message)
-{
- if (this->proto)
- (proto->*messageReceivedCallback)(message->ref());
-}
-
-void CConversation::OnChange(int prop)
-{
- if (prop == Conversation::P_LOCAL_LIVESTATUS) - { - Conversation::LOCAL_LIVESTATUS liveStatus; - this->GetPropLocalLivestatus(liveStatus); - if (liveStatus == Conversation::RINGING_FOR_ME) - {
-
- }
- }
-}
-
-CConversation::Ref CConversation::FindBySid(CSkype *skype, const wchar_t *sid)
-{
- SEString identity = ::mir_u2a(sid);
- SEStringList participants;
- participants.append(identity);
-
- CConversation::Ref conversation;
- skype->GetConversationByParticipants(participants, conversation);
-
- return conversation;
-}
-
-void CConversation::SetOnMessageReceivedCallback(OnMessageReceived callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->messageReceivedCallback = callback;
-}
-
-// CMessage
-
-CMessage::CMessage(unsigned int oid, SERootObject* root) : Message(oid, root) { }
-
-// CTransfer
-
-CTransfer::CTransfer(unsigned int oid, SERootObject* root) : Transfer(oid, root)
-{
- this->proto = NULL;
- this->transferCallback = NULL;
-}
-
-void CTransfer::SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->transferCallback = callback;
-}
-
-void CTransfer::OnChange(int prop)
-{
- if (this->proto)
- (proto->*transferCallback)(prop, this->ref());
-}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_subclassing.h b/protocols/Skype/src/skype_subclassing.h deleted file mode 100644 index 13fa95e7c3..0000000000 --- a/protocols/Skype/src/skype_subclassing.h +++ /dev/null @@ -1,201 +0,0 @@ -#pragma once
-
-#undef OCSP_REQUEST
-#undef OCSP_RESPONSE
-
-#include <skype-embedded_2.h>
-
-struct CSkypeProto;
-
-class CSkype;
-
-class CMessage : public Message
-{
-public:
- typedef DRef<CMessage, Message> Ref;
- typedef DRefs<CMessage, Message> Refs;
-
- CMessage(unsigned int oid, SERootObject* root);
-};
-
-class CTransfer : public Transfer
-{
-public:
- typedef void (CSkypeProto::* OnTransfer)(int prop, CTransfer::Ref transfer);
-
- typedef DRef<CTransfer, Transfer> Ref;
- typedef DRefs<CTransfer, Transfer> Refs;
-
- CTransfer(unsigned int oid, SERootObject* p_root);
-
- void SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto);
-
-private:
- CSkypeProto* proto;
- OnTransfer transferCallback;
-
- void OnChange(int prop);
-};
-
-class CParticipant : public Participant
-{
-public:
- typedef DRef<CParticipant, Participant> Ref;
- typedef DRefs<CParticipant, Participant> Refs;
-
- CParticipant(unsigned int oid, SERootObject* root);
-
- static SEString GetRankName(CParticipant::RANK rank);
-};
-
-class CConversation : public Conversation
-{
-public:
- typedef void (CSkypeProto::* OnMessageReceived)(CMessage::Ref message);
-
- typedef DRef<CConversation, Conversation> Ref;
- typedef DRefs<CConversation, Conversation> Refs;
-
- CConversation(unsigned int oid, SERootObject* root);
-
- static CConversation::Ref FindBySid(CSkype *skype, const wchar_t *sid);
-
- void SetOnMessageReceivedCallback(OnMessageReceived callback, CSkypeProto* proto);
-
-private:
- CSkypeProto* proto;
- OnMessageReceived messageReceivedCallback;
-
- void OnMessage(const MessageRef & message);
- void OnChange(int prop);
-};
-
-class CContact : public Contact
-{
-public:
- typedef void (CSkypeProto::* OnContactChanged)(CContact::Ref contact, int);
-
- typedef DRef<CContact, Contact> Ref;
- typedef DRefs<CContact, Contact> Refs;
-
- CContact(unsigned int oid, SERootObject* root);
-
- /*bool SentAuthRequest(SEString message);*/
-
- SEString GetSid();
- SEString GetNick();
- bool GetFullname(SEString &firstName, SEString &lastName);
-
- void SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto);
-
-private:
- CSkypeProto* proto;
- OnContactChanged callback;
-
- void OnChange(int prop);
-};
-
-class CContactSearch : public ContactSearch
-{
-public:
- typedef void (CSkypeProto::* OnSearchCompleted)(HANDLE hSearch);
- typedef void (CSkypeProto::* OnContactFinded)(HANDLE hSearch, CContact::Ref contact);
-
- typedef DRef<CContactSearch, ContactSearch> Ref;
- typedef DRefs<CContactSearch, ContactSearch> Refs;
-
- bool isSeachFinished;
- bool isSeachFailed;
-
- CContactSearch(unsigned int oid, SERootObject* root);
-
- void OnChange(int prop);
- void OnNewResult(const ContactRef& contact, const uint& rankValue);
-
- void SetProtoInfo(CSkypeProto* proto, HANDLE hSearch);
- void SetOnSearchCompleatedCallback(OnSearchCompleted callback);
- void SetOnContactFindedCallback(OnContactFinded callback);
-
- void BlockWhileSearch();
-private:
- HANDLE hSearch;
- CSkypeProto* proto;
- OnSearchCompleted SearchCompletedCallback;
- OnContactFinded ContactFindedCallback;
-};
-
-class CContactGroup : public ContactGroup
-{
-public:
- typedef void (CSkypeProto::* OnContactListChanged)(const ContactRef& contact);
-
- typedef DRef<CContactGroup, ContactGroup> Ref;
- typedef DRefs<CContactGroup, ContactGroup> Refs;
- CContactGroup(unsigned int oid, SERootObject* root);
-
- void SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto);
-
-private:
- CSkypeProto* proto;
- OnContactListChanged callback;
-
- void OnChange(const ContactRef& contact);
-};
-
-class CAccount : public Account
-{
-public:
- typedef void (CSkypeProto::* OnAccountChanged)(int);
-
- typedef DRef<CAccount, Account> Ref;
- typedef DRefs<CAccount, Account> Refs;
-
- CAccount(unsigned int oid, SERootObject* root);
-
- bool SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result);
-
- void SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto);
-
-private:
- CSkype *skype;
- CSkypeProto* proto;
- OnAccountChanged callback;
- void OnChange(int prop);
-};
-
-class CSkype : public Skype
-{
-public:
- typedef void (CSkypeProto::* OnMessaged)(CConversation::Ref conversation, CMessage::Ref message);
-
- CAccount* newAccount(int oid);
- CContactGroup* newContactGroup(int oid);
- CConversation* newConversation(int oid);
- CContactSearch* newContactSearch(int oid);
- CParticipant* newParticipant(int oid);
- CContact* newContact(int oid);
- CMessage* newMessage(int oid);
- CTransfer* newTransfer(int oid);
-
- CConversation::Refs inbox;
-
- CSkype(int num_threads = 1);
-
- void SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto);
-
- static CSkype *GetInstance(HINSTANCE hInstance, const wchar_t *profileName, const wchar_t *dbPath);
-
-private:
- CSkypeProto* proto;
- OnMessaged onMessagedCallback;
-
- void OnMessage(
- const MessageRef & message,
- const bool & changesInboxTimestamp,
- const MessageRef & supersedesHistoryMessage,
- const ConversationRef & conversation);
-
- static BOOL IsRunAsAdmin();
- static char *LoadKeyPair(HINSTANCE hInstance);
- static int StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, int &port, const wchar_t *dbPath);
-};
\ No newline at end of file diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index fe8141d83f..199e3b3c8f 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -281,14 +281,6 @@ LanguagesListEntry CSkypeProto::languages[] = {"Zulu", "zu"}
};
-
-void CSkypeProto::FakeAsync(void *param)
-{
- ::Sleep(100);
- ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)param);
- ::mir_free(param);
-}
-
int CSkypeProto::DetectAvatarFormatBuffer(const char *pBuffer)
{
if (!strncmp(pBuffer, "%PNG", 4))
@@ -399,20 +391,23 @@ void CSkypeProto::HookEvent(const char* szEvent, SkypeEventFunc handler) ::HookEventObj(szEvent, (MIRANDAHOOKOBJ)*( void**)&handler, this);
}
+void CSkypeProto::FakeAsync(void *param)
+{
+ ::Sleep(100);
+ ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)param);
+ ::mir_free(param);
+}
+
int CSkypeProto::SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam)
{
- /*ACKDATA ack = { sizeof(ACKDATA) };
- ack.szModule = this->m_szModuleName;
- ack.hContact = hContact;
- ack.type = type;
- ack.result = result;
- ack.hProcess = hProcess;
- ack.lParam = lParam;
-
- return ::CallService(MS_PROTO_BROADCASTACK, 0, (LPARAM)&ack);*/
return ::ProtoBroadcastAck(this->m_szModuleName, hContact, type, result, hProcess, lParam);
}
+int CSkypeProto::SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam)
+{
+ return this->SendBroadcast(NULL, type, result, hProcess, lParam);
+}
+
DWORD CSkypeProto::SendBroadcastAsync(HANDLE hContact, int type, int hResult, HANDLE hProcess, LPARAM lParam, size_t paramSize)
{
ACKDATA *ack = (ACKDATA *)::mir_calloc(sizeof(ACKDATA) + paramSize);
diff --git a/protocols/Skype/src/skypekit/account.cpp b/protocols/Skype/src/skypekit/account.cpp new file mode 100644 index 0000000000..313b1cf50d --- /dev/null +++ b/protocols/Skype/src/skypekit/account.cpp @@ -0,0 +1,34 @@ +#include "account.h"
+#include "skype.h"
+
+CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+void CAccount::SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto)
+{
+ this->skype = (CSkype *)root;
+
+ this->proto = proto;
+ this->callback = callback;
+}
+
+bool CAccount::SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result)
+{
+ int fbl;
+ if (!this->skype->ValidateAvatar(avatar, result, fbl) || result != Skype::VALIDATED_OK)
+ return false;
+
+ if (!this->SetBinProperty(Account::P_AVATAR_IMAGE, avatar))
+ return false;
+
+ return true;
+}
+
+void CAccount::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*callback)(prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/account.h b/protocols/Skype/src/skypekit/account.h new file mode 100644 index 0000000000..b537019698 --- /dev/null +++ b/protocols/Skype/src/skypekit/account.h @@ -0,0 +1,26 @@ +#pragma once
+
+#include "common.h"
+
+class CSkype;
+
+class CAccount : public Account
+{
+public:
+ typedef void (CSkypeProto::* OnAccountChanged)(int);
+
+ typedef DRef<CAccount, Account> Ref;
+ typedef DRefs<CAccount, Account> Refs;
+
+ CAccount(unsigned int oid, SERootObject* root);
+
+ bool SetAvatar(SEBinary avatar, Skype::VALIDATERESULT &result);
+
+ void SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto);
+
+private:
+ CSkype *skype;
+ CSkypeProto* proto;
+ OnAccountChanged callback;
+ void OnChange(int prop);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/common.h b/protocols/Skype/src/skypekit/common.h new file mode 100644 index 0000000000..de00501ba3 --- /dev/null +++ b/protocols/Skype/src/skypekit/common.h @@ -0,0 +1,8 @@ +#pragma once
+
+#undef OCSP_REQUEST
+#undef OCSP_RESPONSE
+
+#include <skype-embedded_2.h>
+
+struct CSkypeProto;
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/contact.cpp b/protocols/Skype/src/skypekit/contact.cpp new file mode 100644 index 0000000000..2030eba250 --- /dev/null +++ b/protocols/Skype/src/skypekit/contact.cpp @@ -0,0 +1,59 @@ +#include "contact.h"
+
+CContact::CContact(unsigned int oid, SERootObject* root) : Contact(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+SEString CContact::GetSid()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ this->GetPropPstnnumber(result);
+ else
+ this->GetPropSkypename(result);
+ return result;
+}
+
+SEString CContact::GetNick()
+{
+ SEString result;
+ CContact::AVAILABILITY availability;
+ this->GetPropAvailability(availability);
+ if (availability == CContact::SKYPEOUT)
+ result = this->GetSid();
+ else
+ this->GetPropDisplayname(result);
+ return result;
+}
+
+bool CContact::GetFullname(SEString &firstName, SEString &lastName)
+{
+ SEString fullname;
+ this->GetPropFullname(fullname);
+ int pos = fullname.find(" ");
+ if (pos && pos < fullname.length())
+ {
+ firstName = fullname.substr(0, pos);
+ lastName = fullname.right(pos);
+ }
+
+ firstName = fullname;
+
+ return true;
+}
+
+void CContact::SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->callback = callback;
+}
+
+void CContact::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*callback)(this->ref(), prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/contact.h b/protocols/Skype/src/skypekit/contact.h new file mode 100644 index 0000000000..ee36764c50 --- /dev/null +++ b/protocols/Skype/src/skypekit/contact.h @@ -0,0 +1,26 @@ +#pragma once
+
+#include "common.h"
+
+class CContact : public Contact
+{
+public:
+ typedef void (CSkypeProto::* OnContactChanged)(CContact::Ref contact, int);
+
+ typedef DRef<CContact, Contact> Ref;
+ typedef DRefs<CContact, Contact> Refs;
+
+ CContact(unsigned int oid, SERootObject* root);
+
+ SEString GetSid();
+ SEString GetNick();
+ bool GetFullname(SEString &firstName, SEString &lastName);
+
+ void SetOnContactChangedCallback(OnContactChanged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnContactChanged callback;
+
+ void OnChange(int prop);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/conversation.cpp b/protocols/Skype/src/skypekit/conversation.cpp new file mode 100644 index 0000000000..e907c82d75 --- /dev/null +++ b/protocols/Skype/src/skypekit/conversation.cpp @@ -0,0 +1,3 @@ +#include "conversation.h"
+
+CConversation::CConversation(unsigned int oid, SERootObject* root) : Conversation(oid, root) { }
diff --git a/protocols/Skype/src/skypekit/conversation.h b/protocols/Skype/src/skypekit/conversation.h new file mode 100644 index 0000000000..9fdc064962 --- /dev/null +++ b/protocols/Skype/src/skypekit/conversation.h @@ -0,0 +1,15 @@ +#pragma once
+
+#include "common.h"
+
+class CConversation : public Conversation
+{
+public:
+ typedef DRef<CConversation, Conversation> Ref;
+ typedef DRefs<CConversation, Conversation> Refs;
+
+ CConversation(unsigned int oid, SERootObject* root);
+
+private:
+ CSkypeProto* proto;
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/group.cpp b/protocols/Skype/src/skypekit/group.cpp new file mode 100644 index 0000000000..f547563bcf --- /dev/null +++ b/protocols/Skype/src/skypekit/group.cpp @@ -0,0 +1,19 @@ +#include "group.h"
+
+CContactGroup::CContactGroup(unsigned int oid, SERootObject* root) : ContactGroup(oid, root)
+{
+ this->proto = NULL;
+ this->callback == NULL;
+}
+
+void CContactGroup::SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->callback = callback;
+}
+
+void CContactGroup::OnChange(const ContactRef &contact)
+{
+ if (this->proto)
+ (proto->*callback)(contact);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/group.h b/protocols/Skype/src/skypekit/group.h new file mode 100644 index 0000000000..ff395594a5 --- /dev/null +++ b/protocols/Skype/src/skypekit/group.h @@ -0,0 +1,22 @@ +#pragma once
+
+#include "common.h"
+#include "contact.h"
+
+class CContactGroup : public ContactGroup
+{
+public:
+ typedef void (CSkypeProto::* OnContactListChanged)(CContact::Ref contact);
+
+ typedef DRef<CContactGroup, ContactGroup> Ref;
+ typedef DRefs<CContactGroup, ContactGroup> Refs;
+ CContactGroup(unsigned int oid, SERootObject* root);
+
+ void SetOnContactListChangedCallback(OnContactListChanged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnContactListChanged callback;
+
+ void OnChange(const ContactRef &contact);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/message.cpp b/protocols/Skype/src/skypekit/message.cpp new file mode 100644 index 0000000000..ce96de0c01 --- /dev/null +++ b/protocols/Skype/src/skypekit/message.cpp @@ -0,0 +1,3 @@ +#include "message.h"
+
+CMessage::CMessage(unsigned int oid, SERootObject* root) : Message(oid, root) { }
diff --git a/protocols/Skype/src/skypekit/message.h b/protocols/Skype/src/skypekit/message.h new file mode 100644 index 0000000000..6bf1eda497 --- /dev/null +++ b/protocols/Skype/src/skypekit/message.h @@ -0,0 +1,12 @@ +#pragma once
+
+#include "common.h"
+
+class CMessage : public Message
+{
+public:
+ typedef DRef<CMessage, Message> Ref;
+ typedef DRefs<CMessage, Message> Refs;
+
+ CMessage(unsigned int oid, SERootObject* root);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/participant.cpp b/protocols/Skype/src/skypekit/participant.cpp new file mode 100644 index 0000000000..8b25254a0e --- /dev/null +++ b/protocols/Skype/src/skypekit/participant.cpp @@ -0,0 +1,33 @@ +#include "participant.h"
+
+CParticipant::CParticipant(unsigned int oid, SERootObject* root) : Participant(oid, root) { }
+
+SEString CParticipant::GetRankName(CParticipant::RANK rank)
+{
+ char *result = NULL;
+ switch (rank)
+ {
+ case CParticipant::CREATOR:
+ result = "Creator";
+ break;
+ case CParticipant::ADMIN:
+ result = "Admin";
+ break;
+ case CParticipant::SPEAKER:
+ result = "Speaker";
+ break;
+ case CParticipant::WRITER:
+ result = "Writer";
+ break;
+ case CParticipant::SPECTATOR:
+ result = "Spectator";
+ break;
+ case CParticipant::RETIRED:
+ result = "Retried";
+ break;
+ case CParticipant::OUTLAW:
+ result = "Outlaw";
+ break;
+ }
+ return result;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/participant.h b/protocols/Skype/src/skypekit/participant.h new file mode 100644 index 0000000000..3a09d28017 --- /dev/null +++ b/protocols/Skype/src/skypekit/participant.h @@ -0,0 +1,14 @@ +#pragma once
+
+#include "common.h"
+
+class CParticipant : public Participant
+{
+public:
+ typedef DRef<CParticipant, Participant> Ref;
+ typedef DRefs<CParticipant, Participant> Refs;
+
+ CParticipant(unsigned int oid, SERootObject* root);
+
+ static SEString GetRankName(CParticipant::RANK rank);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/search.cpp b/protocols/Skype/src/skypekit/search.cpp new file mode 100644 index 0000000000..362e412c86 --- /dev/null +++ b/protocols/Skype/src/skypekit/search.cpp @@ -0,0 +1,53 @@ +#include "search.h"
+
+CContactSearch::CContactSearch(unsigned int oid, SERootObject* root) : ContactSearch(oid, root)
+{
+ this->proto = NULL;
+ this->SearchCompletedCallback == NULL;
+ this->ContactFindedCallback == NULL;
+}
+
+void CContactSearch::OnChange(int prop)
+{
+ if (prop == P_CONTACT_SEARCH_STATUS)
+ {
+ CContactSearch::STATUS status;
+ this->GetPropContactSearchStatus(status);
+ if (status == FINISHED || status == FAILED)
+ {
+ this->isSeachFinished = true;
+ if (this->proto)
+ (proto->*SearchCompletedCallback)(this->hSearch);
+ }
+ }
+}
+
+void CContactSearch::OnNewResult(const ContactRef &contact, const uint &rankValue)
+{
+ if (this->proto)
+ (proto->*ContactFindedCallback)(contact, this->hSearch);
+}
+
+void CContactSearch::BlockWhileSearch()
+{
+ this->isSeachFinished = false;
+ this->isSeachFailed = false;
+ while (!this->isSeachFinished && !this->isSeachFailed)
+ Sleep(1);
+}
+
+void CContactSearch::SetProtoInfo(CSkypeProto* proto, HANDLE hSearch)
+{
+ this->proto = proto;
+ this->hSearch = hSearch;
+}
+
+void CContactSearch::SetOnSearchCompleatedCallback(OnSearchCompleted callback)
+{
+ this->SearchCompletedCallback = callback;
+}
+
+void CContactSearch::SetOnContactFindedCallback(OnContactFinded callback)
+{
+ this->ContactFindedCallback = callback;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/search.h b/protocols/Skype/src/skypekit/search.h new file mode 100644 index 0000000000..60b920130d --- /dev/null +++ b/protocols/Skype/src/skypekit/search.h @@ -0,0 +1,33 @@ +#pragma once
+
+#include "common.h"
+#include "contact.h"
+
+class CContactSearch : public ContactSearch
+{
+public:
+ typedef void (CSkypeProto::* OnSearchCompleted)(HANDLE hSearch);
+ typedef void (CSkypeProto::* OnContactFinded)(CContact::Ref contact, HANDLE hSearch);
+
+ typedef DRef<CContactSearch, ContactSearch> Ref;
+ typedef DRefs<CContactSearch, ContactSearch> Refs;
+
+ bool isSeachFinished;
+ bool isSeachFailed;
+
+ CContactSearch(unsigned int oid, SERootObject* root);
+
+ void OnChange(int prop);
+ void OnNewResult(const ContactRef &contact, const uint &rankValue);
+
+ void SetProtoInfo(CSkypeProto* proto, HANDLE hSearch);
+ void SetOnSearchCompleatedCallback(OnSearchCompleted callback);
+ void SetOnContactFindedCallback(OnContactFinded callback);
+
+ void BlockWhileSearch();
+private:
+ HANDLE hSearch;
+ CSkypeProto* proto;
+ OnSearchCompleted SearchCompletedCallback;
+ OnContactFinded ContactFindedCallback;
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/skype.cpp b/protocols/Skype/src/skypekit/skype.cpp new file mode 100644 index 0000000000..fe22f548c8 --- /dev/null +++ b/protocols/Skype/src/skypekit/skype.cpp @@ -0,0 +1,63 @@ +#include "skype.h"
+
+CSkype::CSkype(int num_threads) : Skype(num_threads)
+{
+ this->proto = NULL;
+ this->onMessagedCallback = NULL;
+}
+
+CAccount* CSkype::newAccount(int oid)
+{
+ return new CAccount(oid, this);
+}
+
+CContactGroup* CSkype::newContactGroup(int oid)
+{
+ return new CContactGroup(oid, this);
+}
+
+CContact* CSkype::newContact(int oid)
+{
+ return new CContact(oid, this);
+}
+
+CConversation* CSkype::newConversation(int oid)
+{
+ return new CConversation(oid, this);
+}
+
+CParticipant* CSkype::newParticipant(int oid)
+{
+ return new CParticipant(oid, this);
+}
+
+CMessage* CSkype::newMessage(int oid)
+{
+ return new CMessage(oid, this);
+}
+
+CTransfer* CSkype::newTransfer(int oid)
+{
+ return new CTransfer(oid, this);
+}
+
+CContactSearch* CSkype::newContactSearch(int oid)
+{
+ return new CContactSearch(oid, this);
+}
+
+void CSkype::OnMessage (
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation)
+{
+ if (this->proto)
+ (proto->*onMessagedCallback)(conversation, message);
+}
+
+void CSkype::SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->onMessagedCallback = callback;
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/skype.h b/protocols/Skype/src/skypekit/skype.h new file mode 100644 index 0000000000..faac4f3d65 --- /dev/null +++ b/protocols/Skype/src/skypekit/skype.h @@ -0,0 +1,41 @@ +#pragma once
+
+#include "common.h"
+
+#include "group.h"
+#include "search.h"
+#include "account.h"
+#include "contact.h"
+#include "message.h"
+#include "transfer.h"
+#include "participant.h"
+#include "conversation.h"
+
+class CSkype : public Skype
+{
+public:
+ typedef void (CSkypeProto::* OnMessaged)(CConversation::Ref conversation, CMessage::Ref message);
+
+ CAccount* newAccount(int oid);
+ CContactGroup* newContactGroup(int oid);
+ CConversation* newConversation(int oid);
+ CContactSearch* newContactSearch(int oid);
+ CParticipant* newParticipant(int oid);
+ CContact* newContact(int oid);
+ CMessage* newMessage(int oid);
+ CTransfer* newTransfer(int oid);
+
+ CSkype(int num_threads = 1);
+
+ void SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnMessaged onMessagedCallback;
+
+ void OnMessage(
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation);
+};
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/transfer.cpp b/protocols/Skype/src/skypekit/transfer.cpp new file mode 100644 index 0000000000..986a5bcbab --- /dev/null +++ b/protocols/Skype/src/skypekit/transfer.cpp @@ -0,0 +1,19 @@ +#include "transfer.h"
+
+CTransfer::CTransfer(unsigned int oid, SERootObject* root) : Transfer(oid, root)
+{
+ this->proto = NULL;
+ this->transferCallback = NULL;
+}
+
+void CTransfer::SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto)
+{
+ this->proto = proto;
+ this->transferCallback = callback;
+}
+
+void CTransfer::OnChange(int prop)
+{
+ if (this->proto)
+ (proto->*transferCallback)(this->ref(), prop);
+}
\ No newline at end of file diff --git a/protocols/Skype/src/skypekit/transfer.h b/protocols/Skype/src/skypekit/transfer.h new file mode 100644 index 0000000000..d327c496b0 --- /dev/null +++ b/protocols/Skype/src/skypekit/transfer.h @@ -0,0 +1,22 @@ +#pragma once
+
+#include "common.h"
+
+class CTransfer : public Transfer
+{
+public:
+ typedef void (CSkypeProto::* OnTransfer)(CTransfer::Ref transfer, int);
+
+ typedef DRef<CTransfer, Transfer> Ref;
+ typedef DRefs<CTransfer, Transfer> Refs;
+
+ CTransfer(unsigned int oid, SERootObject* p_root);
+
+ void SetOnTransferCallback(OnTransfer callback, CSkypeProto* proto);
+
+private:
+ CSkypeProto* proto;
+ OnTransfer transferCallback;
+
+ void OnChange(int prop);
+};
\ No newline at end of file |