summaryrefslogtreecommitdiff
path: root/protocols/Skype
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2013-05-13 18:30:05 +0000
committerAlexander Lantsev <aunsane@gmail.com>2013-05-13 18:30:05 +0000
commit2a1e6f05aa9fcc4dfe642bd42aeb175e3958d4b3 (patch)
tree1f0195caf23d086ecae10fc75b11fa61d85e9a66 /protocols/Skype
parent59651e97603936fc7179864506caa1818e260c76 (diff)
Merged revision(s) from branches/unsane/skype_test:
- CSkypeProto is derived of Skype class now - chat events moved to skype_chat.cpp - fixed chat message timestamp - fixed #331, #332 git-svn-id: http://svn.miranda-ng.org/main/trunk@4644 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Skype')
-rw-r--r--protocols/Skype/Skype_10.vcxproj4
-rw-r--r--protocols/Skype/Skype_10.vcxproj.filters12
-rw-r--r--protocols/Skype/Skype_11.vcxproj4
-rw-r--r--protocols/Skype/Skype_11.vcxproj.filters7
-rw-r--r--protocols/Skype/src/skype.cpp116
-rw-r--r--protocols/Skype/src/skype.h3
-rw-r--r--protocols/Skype/src/skype_account.cpp42
-rw-r--r--protocols/Skype/src/skype_chat.cpp244
-rw-r--r--protocols/Skype/src/skype_contacts.cpp12
-rw-r--r--protocols/Skype/src/skype_dialogs.cpp8
-rw-r--r--protocols/Skype/src/skype_events.cpp241
-rw-r--r--protocols/Skype/src/skype_instances.cpp33
-rw-r--r--protocols/Skype/src/skype_menus.cpp4
-rw-r--r--protocols/Skype/src/skype_messages.cpp40
-rw-r--r--protocols/Skype/src/skype_proto.cpp16
-rw-r--r--protocols/Skype/src/skype_proto.h129
-rw-r--r--protocols/Skype/src/skype_runtime.cpp93
-rw-r--r--protocols/Skype/src/skype_skype.cpp56
-rw-r--r--protocols/Skype/src/skype_transfers.cpp6
-rw-r--r--protocols/Skype/src/skype_utils.cpp228
-rw-r--r--protocols/Skype/src/skypekit/account.cpp3
-rw-r--r--protocols/Skype/src/skypekit/account.h4
-rw-r--r--protocols/Skype/src/skypekit/skypekit.cpp78
-rw-r--r--protocols/Skype/src/skypekit/skypekit.h43
24 files changed, 829 insertions, 597 deletions
diff --git a/protocols/Skype/Skype_10.vcxproj b/protocols/Skype/Skype_10.vcxproj
index 712c5d6355..4c32bf787d 100644
--- a/protocols/Skype/Skype_10.vcxproj
+++ b/protocols/Skype/Skype_10.vcxproj
@@ -192,7 +192,6 @@
<ClInclude Include="src\skypekit\message.h" />
<ClInclude Include="src\skypekit\participant.h" />
<ClInclude Include="src\skypekit\search.h" />
- <ClInclude Include="src\skypekit\skypekit.h" />
<ClInclude Include="src\skypekit\transfer.h" />
<ClInclude Include="src\skype_chat.h" />
<ClInclude Include="src\skype_proto.h" />
@@ -211,7 +210,6 @@
<ClCompile Include="src\skypekit\message.cpp" />
<ClCompile Include="src\skypekit\participant.cpp" />
<ClCompile Include="src\skypekit\search.cpp" />
- <ClCompile Include="src\skypekit\skypekit.cpp" />
<ClCompile Include="src\skypekit\transfer.cpp" />
<ClCompile Include="src\skype_account.cpp" />
<ClCompile Include="src\skype_avatars.cpp" />
@@ -229,6 +227,8 @@
<ClCompile Include="src\skype_own_info.cpp" />
<ClCompile Include="src\skype_profile.cpp" />
<ClCompile Include="src\skype_proto.cpp" />
+ <ClCompile Include="src\skype_runtime.cpp" />
+ <ClCompile Include="src\skype_skype.cpp" />
<ClCompile Include="src\skype_services.cpp" />
<ClCompile Include="src\skype_transfers.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters
index 86fcc68b3b..86f651cdb2 100644
--- a/protocols/Skype/Skype_10.vcxproj.filters
+++ b/protocols/Skype/Skype_10.vcxproj.filters
@@ -99,9 +99,6 @@
<ClCompile Include="src\skype_avatars.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skypekit\skypekit.cpp">
- <Filter>Source Files\skypekit</Filter>
- </ClCompile>
<ClCompile Include="src\skype_hooks.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@@ -117,6 +114,12 @@
<ClCompile Include="src\skype_profile.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\skype_skype.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skype_runtime.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
@@ -164,9 +167,6 @@
<ClInclude Include="src\aes\aes.h">
<Filter>Header Files</Filter>
</ClInclude>
- <ClInclude Include="src\skypekit\skypekit.h">
- <Filter>Header Files\skypekit</Filter>
- </ClInclude>
<ClInclude Include="src\string_list.h">
<Filter>Header Files</Filter>
</ClInclude>
diff --git a/protocols/Skype/Skype_11.vcxproj b/protocols/Skype/Skype_11.vcxproj
index 28aff6a4cd..d28e6ea6ab 100644
--- a/protocols/Skype/Skype_11.vcxproj
+++ b/protocols/Skype/Skype_11.vcxproj
@@ -197,7 +197,6 @@
<ClInclude Include="src\skypekit\message.h" />
<ClInclude Include="src\skypekit\participant.h" />
<ClInclude Include="src\skypekit\search.h" />
- <ClInclude Include="src\skypekit\skypekit.h" />
<ClInclude Include="src\skypekit\transfer.h" />
<ClInclude Include="src\skype_proto.h" />
<ClInclude Include="src\string_list.h" />
@@ -215,7 +214,6 @@
<ClCompile Include="src\skypekit\message.cpp" />
<ClCompile Include="src\skypekit\participant.cpp" />
<ClCompile Include="src\skypekit\search.cpp" />
- <ClCompile Include="src\skypekit\skypekit.cpp" />
<ClCompile Include="src\skypekit\transfer.cpp" />
<ClCompile Include="src\skype_account.cpp" />
<ClCompile Include="src\skype_avatars.cpp" />
@@ -233,7 +231,9 @@
<ClCompile Include="src\skype_own_info.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_skype.cpp" />
<ClCompile Include="src\skype_transfers.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
</ItemGroup>
diff --git a/protocols/Skype/Skype_11.vcxproj.filters b/protocols/Skype/Skype_11.vcxproj.filters
index 5794644ded..5b722542ba 100644
--- a/protocols/Skype/Skype_11.vcxproj.filters
+++ b/protocols/Skype/Skype_11.vcxproj.filters
@@ -114,8 +114,11 @@
<ClCompile Include="src\skype_transfers.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skypekit\skypekit.cpp">
- <Filter>Source Files\skypekit</Filter>
+ <ClCompile Include="src\skype_runtime.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="src\skype_skype.cpp">
+ <Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp
index f52a45ef97..057350e3dd 100644
--- a/protocols/Skype/src/skype.cpp
+++ b/protocols/Skype/src/skype.cpp
@@ -1,10 +1,6 @@
#include "skype_proto.h"
-#include "aes\aes.h"
-#include "base64\base64.h"
-#include "..\..\..\skypekit\key.h"
int hLangpack;
-CSkype *g_skype;
HINSTANCE g_hInstance;
TIME_API tmi = {0};
@@ -88,49 +84,8 @@ Cleanup:
return fIsRunAsAdmin;
}
-char *LoadKeyPair(HINSTANCE hInstance)
+int UnpackSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName)
{
- 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)
-{
- STARTUPINFO cif = {0};
- cif.cb = sizeof(STARTUPINFO);
- cif.dwFlags = STARTF_USESHOWWINDOW;
- cif.wShowWindow = SW_HIDE;
-
wchar_t fileName[MAX_PATH];
::GetModuleFileName(hInstance, fileName, MAX_PATH);
@@ -213,75 +168,23 @@ int StartSkypeRuntime(HINSTANCE hInstance, const wchar_t *profileName, int &port
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);
-
- wchar_t param[128];
- PROCESS_INFORMATION pi;
- VARST dbPath( _T("%miranda_userdata%\\SkypeKit"));
- ::swprintf(param, SIZEOF(param), L"-p -P %d -f \"%s\"", port, dbPath);
- int startingrt = ::CreateProcess(
- fileName, param,
- NULL, NULL, FALSE,
- CREATE_NEW_CONSOLE,
- NULL, NULL, &cif, &pi);
-
- return startingrt;
+ return 1;
}
// ---
extern "C" int __declspec(dllexport) Load(void)
{
- mir_getTMI(&tmi);
- mir_getLP(&pluginInfo);
-
- int port = 8963;
VARST profilename( _T("%miranda_profilename%"));
- if ( !StartSkypeRuntime(g_hInstance, (TCHAR *)profilename, port))
+ if ( !UnpackSkypeRuntime(g_hInstance, (TCHAR *)profilename))
{
- ::MessageBox(NULL, TranslateT("Proccess SkypeKit.exe did not start."), _T(MODULE), MB_OK | MB_ICONERROR);
+ ::MessageBox(NULL, TranslateT("Did not unpack SkypeKit.exe."), _T(MODULE), MB_OK | MB_ICONERROR);
return 1;
}
- char *keyPair = LoadKeyPair(g_hInstance);
- if ( !keyPair)
- {
- ::MessageBox(NULL, TranslateT("Initialization key corrupted or not valid."), _T(MODULE), MB_OK | MB_ICONERROR);
- return 1;
- }
-
- g_skype = new CSkype(1);
- TransportInterface::Status status = g_skype->init(keyPair, "127.0.0.1", port);
- if (status != TransportInterface::OK)
- {
- ::MessageBox(NULL, TranslateT("SkypeKit did not initialize."), _T(MODULE), MB_OK | MB_ICONERROR);
- return 1;
- }
-
- free(keyPair);
-
- if ( !g_skype->start())
- {
- ::MessageBox(NULL, TranslateT("SkypeKit did not start."), _T(MODULE), MB_OK | MB_ICONERROR);
- return 1;
- }
-
- // ---
+ mir_getTMI(&tmi);
+ mir_getLP(&pluginInfo);
PROTOCOLDESCRIPTOR pd = { sizeof(pd) };
pd.szName = "SKYPE";
@@ -292,11 +195,10 @@ extern "C" int __declspec(dllexport) Load(void)
CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&g_cbCountries, (LPARAM)&g_countries);
- CSkypeProto::InitLanguages();
-
CSkypeProto::InitIcons();
CSkypeProto::InitMenus();
CSkypeProto::InitHookList();
+ CSkypeProto::InitLanguages();
CSkypeProto::InitServiceList();
return 0;
@@ -307,8 +209,8 @@ extern "C" int __declspec(dllexport) Unload(void)
CSkypeProto::UninitIcons();
CSkypeProto::UninitMenus();
- g_skype->stop();
- delete g_skype;
+ //this->stop();
+ //delete this->skypeKit;
return 0;
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h
index b6b7746f34..ceeeede69f 100644
--- a/protocols/Skype/src/skype.h
+++ b/protocols/Skype/src/skype.h
@@ -68,9 +68,6 @@
#define SMI_CHAT_INVITE 1
-class CSkype;
-
-extern CSkype *g_skype;
extern HINSTANCE g_hInstance;
extern int g_cbCountries;
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp
index b8832b2266..d102e6acd0 100644
--- a/protocols/Skype/src/skype_account.cpp
+++ b/protocols/Skype/src/skype_account.cpp
@@ -107,7 +107,7 @@ bool CSkypeProto::LogIn()
if (this->IsOnline() || !this->PrepareLogin())
return false;
- if (g_skype->GetAccount(::mir_u2a(this->login), this->account))
+ if (this->GetAccount(::mir_u2a(this->login), this->account))
{
if ( !this->PreparePassword())
return false;
@@ -144,12 +144,12 @@ void CSkypeProto::SetAccountSettings()
{
int port = ::db_get_w(NULL, this->m_szModuleName, "Port", rand() % 10000 + 10000);
this->Log(L"Setting port number to %d", port);
- g_skype->SetInt(SETUPKEY_PORT, port);
+ this->SetInt(SETUPKEY_PORT, port);
bool useAlternativePorts = ::db_get_b(NULL, this->m_szModuleName, "UseAlternativePorts", 1) > 0;
if (useAlternativePorts)
this->Log(L"Setting listening of alternative ports (80, 443)");
- g_skype->SetInt(SETUPKEY_DISABLE_PORT80, (int)!useAlternativePorts);
+ this->SetInt(SETUPKEY_DISABLE_PORT80, (int)!useAlternativePorts);
// Create default group for new contacts
DBVARIANT dbv = {0};
@@ -178,42 +178,42 @@ void CSkypeProto::InitProxy()
case PROXYTYPE_HTTP:
case PROXYTYPE_HTTPS:
this->Log(L"Setting https user proxy config");
- g_skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1);
- g_skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0);
- g_skype->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address);
+ this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1);
+ this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0);
+ this->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
char encodedPass[MAX_PATH];
Base64::Encode(nlus.szProxyAuthPassword, encodedPass, MAX_PATH);
- g_skype->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
- g_skype->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass);
+ this->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser);
+ this->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass);
}
break;
case PROXYTYPE_SOCKS4:
case PROXYTYPE_SOCKS5:
this->Log(L"Setting socks user proxy config");
- g_skype->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0);
- g_skype->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1);
- g_skype->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address);
+ this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0);
+ this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1);
+ this->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address);
if (nlus.useProxyAuth)
{
- g_skype->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
- g_skype->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword);
+ this->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser);
+ this->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword);
}
break;
default:
this->Log(L"Setting automatic proxy detection");
- 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);
+ this->Delete(SETUPKEY_HTTPS_PROXY_ENABLE);
+ this->Delete(SETUPKEY_HTTPS_PROXY_ADDR);
+ this->Delete(SETUPKEY_HTTPS_PROXY_USER);
+ this->Delete(SETUPKEY_HTTPS_PROXY_PWD);
+ this->Delete(SETUPKEY_SOCKS_PROXY_ENABLE);
+ this->Delete(SETUPKEY_SOCKS_PROXY_ADDR);
+ this->Delete(SETUPKEY_SOCKS_PROXY_USER);
+ this->Delete(SETUPKEY_SOCKS_PROXY_PWD);
break;
}
}
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp
index d5f0c9d787..51a51f132c 100644
--- a/protocols/Skype/src/skype_chat.cpp
+++ b/protocols/Skype/src/skype_chat.cpp
@@ -321,7 +321,7 @@ CConversation::Ref CSkypeProto::StartChat(StringList &invitedContacts)
}
CConversation::Ref conversation;
- if (g_skype->CreateConferenceWithConsumers(conversation, needToAdd))
+ if (this->CreateConferenceWithConsumers(conversation, needToAdd))
{
delete param;
@@ -388,7 +388,7 @@ void CSkypeProto::JoinToChat(CConversation::Ref conversation, bool showWindow)
participants[i]->GetPropRank(rank);
CContact::Ref contact;
- g_skype->GetContact(std::string(::mir_utf8encodeW(sid.c_str())).c_str(), contact);
+ this->GetContact(std::string(::mir_utf8encodeW(sid.c_str())).c_str(), contact);
auto status = Contact::OFFLINE;
contact->GetPropAvailability(status);
@@ -420,7 +420,7 @@ void CSkypeProto::AddConactsToChat(CConversation::Ref conversation, const String
if (invitedContacts.contains(sid) && !alreadyInChat.contains(sid))
{
CContact::Ref contact;
- g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
+ this->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(sid)), contact);
CContact::AVAILABILITY status;
contact->GetPropAvailability(status);
@@ -452,7 +452,7 @@ void CSkypeProto::LeaveChat(const wchar_t *cid)
::CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, (LPARAM)&gce);
}
-void CSkypeProto::RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message)
+void CSkypeProto::RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message, DWORD timestamp)
{
HANDLE hContact = this->GetContactBySid(sid);
mir_ptr<wchar_t> nick(::db_get_wsa(hContact, this->m_szModuleName, "Nick"));
@@ -475,7 +475,7 @@ void CSkypeProto::RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt
gce.dwItemData = itemData;
gce.ptszStatus = status;
gce.ptszText = message;
- gce.time = time(NULL);
+ gce.time = timestamp;
::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce);
}
@@ -511,9 +511,9 @@ INT_PTR __cdecl CSkypeProto::OnJoinChat(WPARAM wParam, LPARAM)
CConversation::Ref conversation;
//todo: fixme
- g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
+ this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation);
conversation->GetJoinBlob(data);
- g_skype->GetConversationByBlob(data, conversation, false);
+ this->GetConversationByBlob(data, conversation, false);
conversation->Join();
this->JoinToChat(conversation);
@@ -545,7 +545,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
CConversation::Ref conversation;
switch (gch->pDest->iType) {
case GC_SESSION_TERMINATE:
- if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
+ if (this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
Participant::Refs participants;
conversation->GetParticipants(participants, CConversation::MYSELF);
@@ -556,7 +556,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
case GC_USER_MESSAGE:
if (gch->ptszText && gch->ptszText[0])
{
- if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
+ if (this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
CMessage::Ref message;
mir_ptr<char> text(::mir_utf8encodeW(gch->ptszText));
@@ -566,7 +566,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
break;
/*case GC_USER_CHANMGR:
- if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
+ if (this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
StringList invitedContacts(this->GetChatUsers(cid));
this->InviteConactsToChat(conversation, invitedContacts);
@@ -580,7 +580,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam)
case GC_USER_LOGMENU:
switch(gch->dwData) {
case 10:
- if (g_skype->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
+ if (this->GetConversationByIdentity(::mir_utf8encodeW(cid), conversation, false))
{
StringList invitedContacts(this->GetChatUsers(cid));
this->InviteConactsToChat(conversation, invitedContacts);
@@ -686,4 +686,226 @@ void CSkypeProto::UpdateChatUserStatus(CContact::Ref contact)
0,
CSkypeProto::SkypeToMirandaStatus(availability));
}
+}
+
+void CSkypeProto::OnChatMessageReceived(const ConversationRef &conversation, const MessageRef &message, uint messageType)
+{
+ SEString data;
+
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ message->GetPropBodyXml(data);
+ char *text = CSkypeProto::RemoveHtml(data);
+
+ message->GetPropAuthor(data);
+ mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+
+ //this->SendChatMessage(cid, sid, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+ this->RaiseChatEvent(
+ cid,
+ sid,
+ messageType == CMessage::POSTED_TEXT ? GC_EVENT_MESSAGE : GC_EVENT_ACTION,
+ GCEF_ADDTOLOG,
+ 0,
+ NULL,
+ mir_ptr<wchar_t>(::mir_utf8decodeW(text)),
+ timestamp);
+}
+
+void CSkypeProto::OnChatMessageSent(const ConversationRef &conversation, const MessageRef &message, uint messageType)
+{
+ SEString data;
+
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ message->GetPropBodyXml(data);
+ char *text = CSkypeProto::RemoveHtml(data);
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+
+ message->GetPropAuthor(data);
+ mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
+
+ //this->SendChatMessage(cid, nick, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
+ this->RaiseChatEvent(
+ cid,
+ sid,
+ messageType == CMessage::POSTED_TEXT ? GC_EVENT_MESSAGE : GC_EVENT_ACTION,
+ GCEF_ADDTOLOG,
+ 0,
+ NULL,
+ mir_ptr<wchar_t>(::mir_utf8decodeW(text)),
+ timestamp);
+}
+
+void CSkypeProto::OnChatEvent(const ConversationRef &conversation, const MessageRef &message)
+{
+ uint messageType;
+ messageType = message->GetUintProp(Message::P_TYPE);
+
+ switch (messageType)
+ {
+ case CMessage::POSTED_EMOTE:
+ case CMessage::POSTED_TEXT:
+ {
+ SEString author;
+ message->GetPropAuthor(author);
+
+ if (::wcsicmp(mir_ptr<wchar_t>(::mir_utf8decodeW(author)), this->login) == 0)
+ this->OnChatMessageSent(conversation, message, messageType);
+ else
+ this->OnChatMessageReceived(conversation, message, messageType);
+ }
+ break;
+
+ case CMessage::ADDED_CONSUMERS:
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
+
+ HANDLE hContact = this->AddChatRoom(conversation);
+ if ( !this->IsContactOnline(hContact))
+ {
+ this->JoinToChat(conversation);
+ }
+ else
+ {
+ StringList alreadyInChat(this->GetChatUsers(cid));
+
+ message->GetPropIdentities(data);
+ StringList needToAdd(::mir_utf8decodeW(data));
+
+ CParticipant::Refs participants;
+ conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
+ for (uint i = 0; i < participants.size(); i++)
+ {
+ participants[i]->GetPropIdentity(data);
+ std::wstring sid = ::mir_utf8decodeW(data);
+
+ if (needToAdd.contains(sid.c_str()) && !alreadyInChat.contains(sid.c_str()))
+ {
+ CContact::Ref contact;
+ this->GetContact(std::string(::mir_utf8encodeW(sid.c_str())).c_str(), contact);
+
+ CContact::AVAILABILITY status;
+ contact->GetPropAvailability(status);
+
+ CParticipant::RANK rank;
+ participants[i]->GetPropRank(rank);
+
+ this->AddChatContact(
+ cid,
+ sid.c_str(),
+ CSkypeProto::Roles[rank],
+ CSkypeProto::SkypeToMirandaStatus(status));
+ }
+ }
+ }
+ }
+ break;
+
+ case CMessage::RETIRED:
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ wchar_t *cid = ::mir_utf8decodeW(data);
+
+ StringList alreadyInChat(this->GetChatUsers(cid));
+
+ message->GetPropAuthor(data);
+ wchar_t *sid = ::mir_utf8decodeW(data);
+ if (::wcsicmp(sid, this->login) != 0)
+ if (alreadyInChat.contains(sid))
+ this->RemoveChatContact(cid, sid);
+ }
+ break;
+
+ case CMessage::RETIRED_OTHERS:
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+
+ message->GetPropIdentities(data);
+
+ StringList alreadyInChat(this->GetChatUsers(cid));
+ StringList needToKick(::mir_utf8decodeW(data));
+
+ for (size_t i = 0; i < needToKick.size(); i++)
+ {
+ const wchar_t *sid = needToKick[i];
+ if (::wcsicmp(sid, this->login) == 0)
+ {
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+ this->ShowNotification(::TranslateT("You have been kicked from the chat room"), 0, hContact);
+ this->LeaveChat(cid);
+ }
+ else if ( !alreadyInChat.contains(sid))
+ this->KickChatContact(cid, sid);
+ }
+ }
+ break;
+
+ case CMessage::SPAWNED_CONFERENCE:
+ {
+ SEString data;
+ conversation->GetPropIdentity(data);
+ char *cid = ::mir_strdup(data);
+
+ HANDLE hContact = this->AddChatRoom(conversation);
+ if ( !this->IsContactOnline(hContact))
+ {
+ this->JoinToChat(conversation);
+ }
+ }
+ break;
+
+ case CMessage::STARTED_LIVESESSION:
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+
+ this->RaiseChatEvent(
+ cid,
+ this->login,
+ GC_EVENT_INFORMATION,
+ GCEF_ADDTOLOG,
+ 0,
+ NULL,
+ ::TranslateT("Incoming group call received"));
+ }
+ break;
+
+ case CMessage::ENDED_LIVESESSION:
+ {
+ SEString data;
+
+ conversation->GetPropIdentity(data);
+ mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
+ HANDLE hContact = this->GetChatRoomByCid(cid);
+
+ this->RaiseChatEvent(
+ cid,
+ this->login,
+ GC_EVENT_INFORMATION,
+ GCEF_ADDTOLOG,
+ 0,
+ NULL,
+ ::TranslateT("Incoming group call finished"));
+ }
+ break;
+ }
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index e5f15afd93..b0909f8435 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -254,7 +254,7 @@ void __cdecl CSkypeProto::LoadContactList(void* data)
bool isFirstLoad = data != NULL;
- g_skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
+ this->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
this->commonList.fetch();
this->commonList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
@@ -293,7 +293,7 @@ void __cdecl CSkypeProto::LoadChatList(void*)
{
this->Log(L"Updating group chats list");
CConversation::Refs conversations;
- g_skype->GetConversationList(conversations);
+ this->GetConversationList(conversations);
for (uint i = 0; i < conversations.size(); i++)
{
@@ -315,7 +315,7 @@ void __cdecl CSkypeProto::LoadChatList(void*)
void __cdecl CSkypeProto::LoadAuthWaitList(void*)
{
CContact::Refs authContacts;
- g_skype->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
+ this->GetHardwiredContactGroup(CContactGroup::CONTACTS_WAITING_MY_AUTHORIZATION, this->authWaitList);
this->authWaitList.fetch();
this->authWaitList->SetOnContactListChangedCallback(
(CContactGroup::OnContactListChanged)&CSkypeProto::OnContactListChanged,
@@ -404,7 +404,7 @@ void __cdecl CSkypeProto::SearchBySidAsync(void* arg)
}
CContactSearch::Ref search;
- g_skype->CreateIdentitySearch(::mir_u2a(sid), search);
+ this->CreateIdentitySearch(::mir_u2a(sid), search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYSID);
search->SetOnContactFindedCallback(
@@ -425,7 +425,7 @@ void __cdecl CSkypeProto::SearchByEmailAsync(void* arg)
mir_ptr<wchar_t> email((wchar_t *)arg);
CContactSearch::Ref search;
- g_skype->CreateContactSearch(search);
+ this->CreateContactSearch(search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYEMAIL);
search->SetOnContactFindedCallback(
@@ -451,7 +451,7 @@ void __cdecl CSkypeProto::SearchByNamesAsync(void* arg)
std::string lName = " "; lName += ::mir_utf8encodeW(psr->lastName);
CContactSearch::Ref search;
- g_skype->CreateContactSearch(search);
+ this->CreateContactSearch(search);
search.fetch();
search->SetProtoInfo(this, (HANDLE)SKYPE_SEARCH_BYNAMES);
search->SetOnContactFindedCallback(
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp
index 980b7f81a6..108aa09bd1 100644
--- a/protocols/Skype/src/skype_dialogs.cpp
+++ b/protocols/Skype/src/skype_dialogs.cpp
@@ -109,13 +109,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeMainOptionsProc(HWND hwnd, UINT message, WPAR
GetDlgItemTextA(hwnd, IDC_SL, sid, SIZEOF(sid));
GetDlgItemTextA(hwnd, IDC_PW, pwd, SIZEOF(pwd));
- CSkype::VALIDATERESULT reason;
- g_skype->ValidatePassword(sid, pwd, reason);
+ Skype::VALIDATERESULT reason;
+ proto->ValidatePassword(sid, pwd, reason);
- if (reason == CSkype::VALIDATED_OK)
+ if (reason == Skype::VALIDATED_OK)
{
CAccount::Ref account;
- g_skype->GetAccount(sid, proto->account);
+ proto->GetAccount(sid, proto->account);
proto->account->SetStrProperty(CAccount::P_FULLNAME, sid);
proto->account->SetOnAccountChangedCallback(
(CAccount::OnAccountChanged)&CSkypeProto::OnAccountChanged, proto);
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp
index 63f5bebb84..7eb31cb246 100644
--- a/protocols/Skype/src/skype_events.cpp
+++ b/protocols/Skype/src/skype_events.cpp
@@ -29,10 +29,6 @@ int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
HookEvent(ME_MSG_WINDOWEVENT, &CSkypeProto::OnSrmmWindowOpen);
}
- g_skype->SetOnMessageCallback(
- (CSkype::OnMessaged)&CSkypeProto::OnSkypeEvent,
- this);
-
return 0;
}
@@ -53,6 +49,7 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
this->SetStatus(ID_STATUS_OFFLINE);
this->UninitNetLib();
+
return 0;
}
@@ -67,7 +64,7 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam)
this->LeaveChat(chatID);
CConversation::Ref conversation;
- g_skype->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
+ this->GetConversationByIdentity(::mir_utf8encodeW(chatID), conversation);
conversation->RetireFrom();
conversation->Delete();
}
@@ -201,235 +198,11 @@ int __cdecl CSkypeProto::OnTabSRMMButtonPressed(WPARAM wParam, LPARAM lParam)
return 1;
}
-void CSkypeProto::OnChatMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- message->GetPropAuthor(data);
- mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
-
- CMessage::TYPE messageType;
- message->GetPropType(messageType);
-
- //this->SendChatMessage(cid, sid, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
- this->RaiseChatEvent(
- cid,
- sid,
- messageType == CMessage::POSTED_TEXT ? /*GC_EVENT_MESSAGE */ 0x0040 : /*GC_EVENT_ACTION */ 0x0200,
- /*GCEF_ADDTOLOG*/ 0x0001,
- 0,
- NULL,
- mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
-}
-
-void CSkypeProto::OnChatMessageSent(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- SEString data;
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- message->GetPropBodyXml(data);
- char *text = CSkypeProto::RemoveHtml(data);
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
-
- message->GetPropAuthor(data);
- mir_ptr<wchar_t> sid( ::mir_utf8decodeW(data));
-
- CMessage::TYPE messageType;
- message->GetPropType(messageType);
-
- //this->SendChatMessage(cid, nick, mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
- this->RaiseChatEvent(
- cid,
- sid,
- messageType == CMessage::POSTED_TEXT ? /*GC_EVENT_MESSAGE */ 0x0040 : /*GC_EVENT_ACTION */ 0x0200,
- /*GCEF_ADDTOLOG*/ 0x0001,
- 0,
- NULL,
- mir_ptr<wchar_t>(::mir_utf8decodeW(text)));
-}
-
-void CSkypeProto::OnChatEvent(CConversation::Ref &conversation, CMessage::Ref &message)
-{
- CMessage::TYPE messageType;
- message->GetPropType(messageType);
-
- switch (messageType)
- {
- case CMessage::POSTED_EMOTE:
- case CMessage::POSTED_TEXT:
- {
- SEString author;
- message->GetPropAuthor(author);
-
- if (::wcsicmp(mir_ptr<wchar_t>(::mir_utf8decodeW(author)), this->login) == 0)
- this->OnChatMessageSent(conversation, message);
- else
- this->OnChatMessageReceived(conversation, message);
- }
- break;
-
- case CMessage::ADDED_CONSUMERS:
- {
- SEString data;
-
- conversation->GetPropIdentity(data);
- wchar_t *cid = ::mir_utf8decodeW(data);
-
- HANDLE hContact = this->AddChatRoom(conversation);
- if ( !this->IsContactOnline(hContact))
- {
- this->JoinToChat(conversation);
- }
- else
- {
- StringList alreadyInChat(this->GetChatUsers(cid));
-
- message->GetPropIdentities(data);
- StringList needToAdd(::mir_utf8decodeW(data));
-
- CParticipant::Refs participants;
- conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
- for (uint i = 0; i < participants.size(); i++)
- {
- participants[i]->GetPropIdentity(data);
- std::wstring sid = ::mir_utf8decodeW(data);
-
- if (needToAdd.contains(sid.c_str()) && !alreadyInChat.contains(sid.c_str()))
- {
- CContact::Ref contact;
- g_skype->GetContact(std::string(::mir_utf8encodeW(sid.c_str())).c_str(), contact);
-
- CContact::AVAILABILITY status;
- contact->GetPropAvailability(status);
-
- CParticipant::RANK rank;
- participants[i]->GetPropRank(rank);
-
- this->AddChatContact(
- cid,
- sid.c_str(),
- CSkypeProto::Roles[rank],
- CSkypeProto::SkypeToMirandaStatus(status));
- }
- }
- }
- }
- break;
-
- case CMessage::RETIRED:
- {
- SEString data;
-
- conversation->GetPropIdentity(data);
- wchar_t *cid = ::mir_utf8decodeW(data);
-
- StringList alreadyInChat(this->GetChatUsers(cid));
-
- message->GetPropAuthor(data);
- wchar_t *sid = ::mir_utf8decodeW(data);
- if (::wcsicmp(sid, this->login) != 0)
- if (alreadyInChat.contains(sid))
- this->RemoveChatContact(cid, sid);
- }
- break;
-
- case CMessage::RETIRED_OTHERS:
- {
- SEString data;
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
-
- message->GetPropIdentities(data);
-
- StringList alreadyInChat(this->GetChatUsers(cid));
- StringList needToKick(::mir_utf8decodeW(data));
-
- for (size_t i = 0; i < needToKick.size(); i++)
- {
- const wchar_t *sid = needToKick[i];
- if (::wcsicmp(sid, this->login) == 0)
- {
- HANDLE hContact = this->GetChatRoomByCid(cid);
- this->ShowNotification(::TranslateT("You have been kicked from the chat room"), 0, hContact);
- this->LeaveChat(cid);
- }
- else if ( !alreadyInChat.contains(sid))
- this->KickChatContact(cid, sid);
- }
- }
- break;
-
- case CMessage::SPAWNED_CONFERENCE:
- {
- SEString data;
- conversation->GetPropIdentity(data);
- char *cid = ::mir_strdup(data);
-
- HANDLE hContact = this->AddChatRoom(conversation);
- if ( !this->IsContactOnline(hContact))
- {
- this->JoinToChat(conversation);
- }
- }
- break;
-
- case CMessage::STARTED_LIVESESSION:
- {
- conversation->LeaveLiveSession();
-
- SEString data;
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
- HANDLE hContact = this->GetChatRoomByCid(cid);
-
- this->RaiseChatEvent(
- cid,
- this->login,
- /*GC_EVENT_INFORMATION*/ 0x0100,
- /*GCEF_ADDTOLOG*/ 0x0001,
- 0,
- NULL,
- ::TranslateT("Group call"));
- }
- break;
-
- case CMessage::ENDED_LIVESESSION:
- {
- SEString data;
-
- conversation->GetPropIdentity(data);
- mir_ptr<wchar_t> cid( ::mir_utf8decodeW(data));
- HANDLE hContact = this->GetChatRoomByCid(cid);
-
- this->RaiseChatEvent(
- cid,
- this->login,
- /*GC_EVENT_INFORMATION*/ 0x0100,
- /*GCEF_ADDTOLOG*/ 0x0001,
- 0,
- NULL,
- ::TranslateT("The call is completed"));
- }
- break;
- }
-}
-
-void CSkypeProto::OnSkypeEvent(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnMessage (
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation)
{
CMessage::TYPE messageType;
message->GetPropType(messageType);
diff --git a/protocols/Skype/src/skype_instances.cpp b/protocols/Skype/src/skype_instances.cpp
index 5232bd7cc8..5a49149ea8 100644
--- a/protocols/Skype/src/skype_instances.cpp
+++ b/protocols/Skype/src/skype_instances.cpp
@@ -20,6 +20,37 @@ CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* u
}
CSkypeProto *ppro = new CSkypeProto(protoName, userName);
+
+ VARST profilename( _T("%miranda_profilename%"));
+
+ if ( !ppro->StartSkypeRuntime((TCHAR *)profilename))
+ {
+ CSkypeProto::ShowNotification(::TranslateT("Did not unpack SkypeKit.exe."));
+ return NULL;
+ }
+
+ char *keyPair = ppro->LoadKeyPair();
+ if ( !keyPair)
+ {
+ CSkypeProto::ShowNotification(::TranslateT("Initialization key corrupted or not valid."));
+ return NULL;
+ }
+
+ TransportInterface::Status status = ppro->init(keyPair, "127.0.0.1", ppro->runtimePort);
+ if (status != TransportInterface::OK)
+ {
+ CSkypeProto::ShowNotification(::TranslateT("SkypeKit did not initialize."));
+ return NULL;
+ }
+
+ free(keyPair);
+
+ if ( !ppro->start())
+ {
+ ::MessageBox(NULL, TranslateT("SkypeKit did not start."), _T(MODULE), MB_OK | MB_ICONERROR);
+ return NULL;
+ }
+
CSkypeProto::instanceList.insert(ppro);
return ppro;
@@ -27,6 +58,8 @@ CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* u
int CSkypeProto::UninitSkypeProto(CSkypeProto* ppro)
{
+ ppro->StopSkypeRuntime();
+
CSkypeProto::instanceList.remove(ppro);
delete ppro;
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp
index 536e587d86..74d256d631 100644
--- a/protocols/Skype/src/skype_menus.cpp
+++ b/protocols/Skype/src/skype_menus.cpp
@@ -76,7 +76,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 (g_skype->GetContact(sid, contact))
+ if (this->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(true))
{
@@ -93,7 +93,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 (g_skype->GetContact(sid, contact))
+ if (this->GetContact(sid, contact))
{
if (contact->SetBuddyStatus(false))
{
diff --git a/protocols/Skype/src/skype_messages.cpp b/protocols/Skype/src/skype_messages.cpp
index ced5ab8647..356224f5fd 100644
--- a/protocols/Skype/src/skype_messages.cpp
+++ b/protocols/Skype/src/skype_messages.cpp
@@ -33,7 +33,7 @@ int CSkypeProto::OnMessagePreCreate(WPARAM, LPARAM lParam)
return 1;
}
-void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message)
+void CSkypeProto::OnMessageReceived(const ConversationRef &conversation, const MessageRef &message)
{
SEString data;
@@ -52,7 +52,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::
message->GetPropAuthor(data);
CContact::Ref author;
- g_skype->GetContact(data, author);
+ this->GetContact(data, author);
HANDLE hContact = this->AddContact(author);
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
@@ -75,7 +75,7 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref &conversation, CMessage::
/////////////////////////////////////////////////////////////////////////////////////////
-void CSkypeProto::OnMessageSent(CConversation::Ref &conversation, CMessage::Ref &message)
+void CSkypeProto::OnMessageSent(const ConversationRef &conversation, const MessageRef &message)
{
SEString data;
@@ -99,7 +99,7 @@ void CSkypeProto::OnMessageSent(CConversation::Ref &conversation, CMessage::Ref
participants[0]->GetPropIdentity(data);
CContact::Ref receiver;
- g_skype->GetContact(data, receiver);
+ this->GetContact(data, receiver);
HANDLE hContact = this->AddContact(receiver);
this->SendBroadcast(
@@ -119,7 +119,7 @@ void CSkypeProto::OnMessageSent(CConversation::Ref &conversation, CMessage::Ref
status == CMessage::UNCONSUMED_NORMAL);
}
-void CSkypeProto::OnMessageEvent(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnMessageEvent(const ConversationRef &conversation, const MessageRef &message)
{
CMessage::TYPE messageType;
message->GetPropType(messageType);
@@ -141,8 +141,31 @@ void CSkypeProto::OnMessageEvent(CConversation::Ref conversation, CMessage::Ref
case CMessage::STARTED_LIVESESSION:
{
- conversation->LeaveLiveSession();
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ SEString identity;
+ message->GetPropAuthor(identity);
+
+ CContact::Ref author;
+ this->GetContact(identity, author);
+
+ HANDLE hContact = this->AddContact(author);
+
+ char *message = ::mir_utf8encode(::Translate("Incoming call received"));
+
+ this->AddDBEvent(
+ hContact,
+ SKYPE_DB_EVENT_TYPE_CALL,
+ timestamp,
+ DBEF_UTF,
+ (DWORD)::strlen(message) + 1,
+ (PBYTE)message);
+ }
+ break;
+ case CMessage::ENDED_LIVESESSION:
+ {
uint timestamp;
message->GetPropTimestamp(timestamp);
@@ -150,11 +173,11 @@ void CSkypeProto::OnMessageEvent(CConversation::Ref conversation, CMessage::Ref
message->GetPropAuthor(identity);
CContact::Ref author;
- g_skype->GetContact(identity, author);
+ this->GetContact(identity, author);
HANDLE hContact = this->AddContact(author);
- char *message = ::mir_utf8encode(::Translate("Incoming call"));
+ char *message = ::mir_utf8encode(::Translate("Incoming call finished"));
this->AddDBEvent(
hContact,
@@ -164,5 +187,6 @@ void CSkypeProto::OnMessageEvent(CConversation::Ref conversation, CMessage::Ref
(DWORD)::strlen(message) + 1,
(PBYTE)message);
}
+ break;
}
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp
index db33037edc..6044bd6343 100644
--- a/protocols/Skype/src/skype_proto.cpp
+++ b/protocols/Skype/src/skype_proto.cpp
@@ -1,6 +1,6 @@
#include "skype_proto.h"
-CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
+CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : Skype(1)
{
::ProtoConstructor(this, protoName, userName);
@@ -37,13 +37,15 @@ CSkypeProto::~CSkypeProto()
this->password = NULL;
}
+ this->stop();
+
::ProtoDestructor(this);
}
HANDLE __cdecl CSkypeProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
CContact::Ref contact;
- g_skype->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(psr->id)), contact);
+ this->GetContact((char *)mir_ptr<char>(::mir_utf8encodeW(psr->id)), contact);
return this->AddContact(contact);
}
@@ -124,7 +126,7 @@ int __cdecl CSkypeProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage)
{
CContact::Ref contact;
SEString sid( mir_ptr<char>(::mir_u2a( mir_ptr<wchar_t>(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN)))));
- if (g_skype->GetContact(sid, contact))
+ if (this->GetContact(sid, contact))
{
contact->SetBuddyStatus(Contact::AUTHORIZED_BY_ME);
contact->SendAuthRequest(::mir_utf8encodeW(szMessage));
@@ -142,7 +144,7 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const
{
uint oid = (uint)hTransfer;
- CMessage *message = new CMessage(oid, g_skype);
+ CMessage *message = this->newMessage(oid);
this->Log(L"Incoming file transfer is accepted");
CTransfer::Refs transfers;
@@ -319,7 +321,7 @@ HANDLE __cdecl CSkypeProto::SendFile(HANDLE hContact, const TCHAR *szDescription
targets.append((char *)mir_ptr<char>(::mir_utf8encodeW(sid)));
CConversation::Ref conversation;
- g_skype->GetConversationByParticipants(targets, conversation);
+ this->GetConversationByParticipants(targets, conversation);
SEFilenameList fileList;
for (int i = 0; ppszFiles[i]; i++)
@@ -358,7 +360,7 @@ int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char *msg)
targets.append(identity);
CConversation::Ref conversation;
- g_skype->GetConversationByParticipants(targets, conversation);
+ this->GetConversationByParticipants(targets, conversation);
if (conversation)
{
@@ -443,7 +445,7 @@ int __cdecl CSkypeProto::UserIsTyping(HANDLE hContact, int type)
targets.append(std::string(::mir_utf8encodeW(sid)).c_str());
CConversation::Ref conversation;
- g_skype->GetConversationByParticipants(targets, conversation);
+ this->GetConversationByParticipants(targets, conversation);
if (conversation)
{
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index 88903af885..edc3e76e9c 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -2,7 +2,16 @@
#include "skype.h"
#include "string_list.h"
-#include "skypekit\skypekit.h"
+
+#include "skypekit\common.h"
+#include "skypekit\group.h"
+#include "skypekit\search.h"
+#include "skypekit\account.h"
+#include "skypekit\contact.h"
+#include "skypekit\message.h"
+#include "skypekit\transfer.h"
+#include "skypekit\participant.h"
+#include "skypekit\conversation.h"
#include <map>
#include <string>
@@ -73,9 +82,10 @@ struct PasswordChangeBoxParam
}
};
-struct CSkypeProto : public PROTO_INTERFACE
+struct CSkypeProto : public PROTO_INTERFACE, private Skype
{
public:
+ // PROTO_INTERFACE
CSkypeProto(const char *protoName, const wchar_t *userName);
~CSkypeProto();
@@ -126,30 +136,15 @@ public:
virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam );
- virtual int __cdecl RequestAuth(WPARAM, LPARAM);
- virtual int __cdecl GrantAuth(WPARAM, LPARAM);
- virtual int __cdecl RevokeAuth(WPARAM, LPARAM);
-
- // events
- int __cdecl OnModulesLoaded(WPARAM, LPARAM);
- int __cdecl OnPreShutdown(WPARAM, LPARAM);
- int __cdecl OnContactDeleted(WPARAM, LPARAM);
- int __cdecl OnOptionsInit(WPARAM, LPARAM);
- int __cdecl OnSrmmWindowOpen(WPARAM, LPARAM);
- int __cdecl OnUserInfoInit(WPARAM, LPARAM);
- INT_PTR __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam);
-
- int __cdecl OnMessagePreCreate(WPARAM, LPARAM);
- int __cdecl OnTabSRMMButtonPressed(WPARAM, LPARAM);
-
// instances
static CSkypeProto* InitSkypeProto(const char* protoName, const wchar_t* userName);
static int UninitSkypeProto(CSkypeProto* ppro);
+ static CSkypeProto* GetInstanceByHContact(HANDLE hContact);
+
// icons
static void InitIcons();
static void UninitIcons();
- static HANDLE GetIconHandle(const char *name);
// menus
void OnInitStatusMenu();
@@ -162,22 +157,29 @@ public:
// hooks
static void InitHookList();
- INT_PTR __cdecl InviteCommand(WPARAM, LPARAM);
-
- static CSkypeProto* GetInstanceByHContact(HANDLE hContact);
- static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
-
- bool IsOnline();
-
+ // languages
static void InitLanguages();
- BYTE NeedUpdate;
+private:
+ // Skype
+ 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);
- static void ShowNotification(const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
- static void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
+ bool CreateConferenceWithConsumers(ConversationRef &conference, const SEStringList &identities);
- int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
- int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+ void OnMessage(
+ const MessageRef & message,
+ const bool & changesInboxTimestamp,
+ const MessageRef & supersedesHistoryMessage,
+ const ConversationRef & conversation);
+
+ PROCESS_INFORMATION pi;
protected:
CAccount::Ref account;
@@ -189,7 +191,9 @@ protected:
CRITICAL_SECTION contact_search_lock;
- static std::map<std::wstring, std::wstring> languages;
+ bool IsOnline();
+
+ BYTE NeedUpdate;
// account
static wchar_t *LogoutReasons[];
@@ -234,17 +238,13 @@ protected:
SEBinary GetAvatarBinary(wchar_t *path);
- // events
- void OnSkypeEvent(CConversation::Ref conversation, CMessage::Ref message);
- void OnChatEvent(CConversation::Ref &conversation, CMessage::Ref &message);
-
// messages
- void OnMessageEvent(CConversation::Ref conversation, CMessage::Ref message);
- void OnMessageSent(CConversation::Ref &conversation, CMessage::Ref &message);
- void OnMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message);
+ void OnMessageEvent(const ConversationRef &conversation, const MessageRef &message);
+ void OnMessageSent(const ConversationRef &conversation, const MessageRef &message);
+ void OnMessageReceived(const ConversationRef &conversation, const MessageRef &message);
// transfer
- void OnFile(CConversation::Ref &conversation, CMessage::Ref &message);
+ void OnFile(const ConversationRef &conversation, const MessageRef &message);
void OnTransferChanged(CTransfer::Ref transfer, int prop);
// chat
@@ -273,7 +273,7 @@ protected:
void InviteConactsToChat(CConversation::Ref conversation, const StringList &invitedContacts);
void AddConactsToChat(CConversation::Ref conversation, const StringList &invitedContacts);
- void RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, DWORD flags = 0x0001, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL);
+ void RaiseChatEvent(const wchar_t *cid, const wchar_t *sid, int evt, DWORD flags = 0x0001, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL, DWORD timestamp = time(NULL));
void SendChatMessage(const wchar_t *cid, const wchar_t *sid, const wchar_t *message);
void AddChatContact(const wchar_t *cid, const wchar_t *sid, const wchar_t *group, const WORD status = ID_STATUS_ONLINE);
void KickChatContact(const wchar_t *cid, const wchar_t *sid);
@@ -285,8 +285,9 @@ protected:
int __cdecl OnGCMenuHook(WPARAM, LPARAM lParam);
int __cdecl OnGCEventHook(WPARAM, LPARAM lParam);
- void OnChatMessageSent(CConversation::Ref &conversation, CMessage::Ref &message);
- void OnChatMessageReceived(CConversation::Ref &conversation, CMessage::Ref &message);
+ void OnChatMessageSent(const ConversationRef &conversation, const MessageRef &message, uint messageType);
+ void OnChatMessageReceived(const ConversationRef &conversation, const MessageRef &message, uint messageType);
+ void OnChatEvent(const ConversationRef &conversation, const MessageRef &message);
// contacts
void UpdateContactAuthState(HANDLE hContact, CContact::Ref contact);
@@ -361,12 +362,22 @@ protected:
static int SkypeToMirandaStatus(CContact::AVAILABILITY availability);
static CContact::AVAILABILITY MirandaToSkypeStatus(int status);
- static bool FileExists(wchar_t *path);
+ static bool FileExists(wchar_t *path);
+
+ static void ShowNotification(const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
+ static void ShowNotification(const wchar_t *caption, const wchar_t *message, int flags = 0, HANDLE hContact = NULL);
+
+ // languages
+ static std::map<std::wstring, std::wstring> languages;
// instances
static LIST<CSkypeProto> instanceList;
static int CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2);
+ //
+ int SendBroadcast(int type, int result, HANDLE hProcess, LPARAM lParam);
+ int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hProcess, LPARAM lParam);
+
void CreateServiceObj(const char* szService, SkypeServiceFunc serviceProc);
void CreateServiceObjParam(const char* szService, SkypeServiceFunc serviceProc, LPARAM lParam);
@@ -395,17 +406,25 @@ protected:
// icons
static _tag_iconList IconList[];
+ static HANDLE GetIconHandle(const char *name);
- // menu
+ // menus
HGENMENU m_hMenuRoot;
static HANDLE hChooserMenu;
static HANDLE contactMenuItems[CMI_TEMS_COUNT];
static HANDLE contactMenuServices[CMI_TEMS_COUNT];
+
+ virtual int __cdecl RequestAuth(WPARAM, LPARAM);
+ virtual int __cdecl GrantAuth(WPARAM, LPARAM);
+ virtual int __cdecl RevokeAuth(WPARAM, LPARAM);
static void EnableMenuItem(HANDLE hMenuItem, BOOL bEnable);
static INT_PTR MenuChooseService(WPARAM wParam, LPARAM lParam);
-
+
+ INT_PTR __cdecl InviteCommand(WPARAM, LPARAM);
+
+ static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam);
int OnPrebuildContactMenu(WPARAM wParam, LPARAM);
// database
@@ -432,4 +451,22 @@ protected:
static INT_PTR CALLBACK PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK ContactSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+
+ // skype runtime
+ int runtimePort;
+ char *LoadKeyPair();
+ int StartSkypeRuntime(const wchar_t *profileName);
+ void CSkypeProto::StopSkypeRuntime();
+
+ // events
+ int __cdecl OnModulesLoaded(WPARAM, LPARAM);
+ int __cdecl OnPreShutdown(WPARAM, LPARAM);
+ int __cdecl OnContactDeleted(WPARAM, LPARAM);
+ int __cdecl OnOptionsInit(WPARAM, LPARAM);
+ int __cdecl OnSrmmWindowOpen(WPARAM, LPARAM);
+ int __cdecl OnUserInfoInit(WPARAM, LPARAM);
+ INT_PTR __cdecl OnAccountManagerInit(WPARAM wParam, LPARAM lParam);
+
+ int __cdecl OnMessagePreCreate(WPARAM, LPARAM);
+ int __cdecl OnTabSRMMButtonPressed(WPARAM, LPARAM);
};
diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp
new file mode 100644
index 0000000000..a9588d8ff1
--- /dev/null
+++ b/protocols/Skype/src/skype_runtime.cpp
@@ -0,0 +1,93 @@
+#include "skype_proto.h"
+
+#include "aes\aes.h"
+#include "base64\base64.h"
+
+#include "..\..\..\skypekit\key.h"
+
+char *CSkypeProto::LoadKeyPair()
+{
+ HRSRC hRes = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN");
+ if (hRes)
+ {
+ HGLOBAL hResource = LoadResource(g_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(g_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 CSkypeProto::StartSkypeRuntime(const wchar_t *profileName)
+{
+ STARTUPINFO cif = {0};
+ cif.cb = sizeof(STARTUPINFO);
+ cif.dwFlags = STARTF_USESHOWWINDOW;
+ cif.wShowWindow = SW_HIDE;
+
+ wchar_t fileName[MAX_PATH];
+ ::GetModuleFileName(g_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");
+
+ 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);
+ this->runtimePort += rand() % 8963 + 1000;
+ ::CloseHandle(hProcess);
+ break;
+ }
+ }
+ }
+ ::CloseHandle(snapshot);
+
+ wchar_t param[128];
+ //PROCESS_INFORMATION pi;
+ VARST dbPath( _T("%miranda_userdata%\\SkypeKit"));
+ ::swprintf(param, SIZEOF(param), L"-p -P %d -f \"%s\"", this->runtimePort, dbPath);
+ int startingrt = ::CreateProcess(
+ fileName, param,
+ NULL, NULL, FALSE,
+ CREATE_NEW_CONSOLE,
+ NULL, NULL, &cif, &this->pi);
+
+ return startingrt;
+}
+
+void CSkypeProto::StopSkypeRuntime()
+{
+ DWORD exitCode = 0;
+ GetExitCodeProcess(this->pi.hProcess, &exitCode);
+ TerminateProcess(this->pi.hProcess, exitCode);
+} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_skype.cpp b/protocols/Skype/src/skype_skype.cpp
new file mode 100644
index 0000000000..3e9eeac7fe
--- /dev/null
+++ b/protocols/Skype/src/skype_skype.cpp
@@ -0,0 +1,56 @@
+#include "skype_proto.h"
+
+CAccount* CSkypeProto::newAccount(int oid)
+{
+ return new CAccount(oid, this);
+}
+
+CContactGroup* CSkypeProto::newContactGroup(int oid)
+{
+ return new CContactGroup(oid, this);
+}
+
+CContact* CSkypeProto::newContact(int oid)
+{
+ return new CContact(oid, this);
+}
+
+CConversation* CSkypeProto::newConversation(int oid)
+{
+ return new CConversation(oid, this);
+}
+
+CParticipant* CSkypeProto::newParticipant(int oid)
+{
+ return new CParticipant(oid, this);
+}
+
+CMessage* CSkypeProto::newMessage(int oid)
+{
+ return new CMessage(oid, this);
+}
+
+CTransfer* CSkypeProto::newTransfer(int oid)
+{
+ return new CTransfer(oid, this);
+}
+
+CContactSearch* CSkypeProto::newContactSearch(int oid)
+{
+ return new CContactSearch(oid, this);
+}
+
+bool CSkypeProto::CreateConferenceWithConsumers(ConversationRef &conference, const SEStringList &identities)
+{
+ if (this->CreateConference(conference))
+ {
+ conference->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
+ conference->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
+ conference->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
+ conference->AddConsumers(identities);
+
+ return true;
+ }
+
+ return false;
+} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_transfers.cpp b/protocols/Skype/src/skype_transfers.cpp
index 3fd10a14fc..5f3270306a 100644
--- a/protocols/Skype/src/skype_transfers.cpp
+++ b/protocols/Skype/src/skype_transfers.cpp
@@ -10,7 +10,7 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
transfer->GetPropChatmsgGuid(guid);
CMessage::Ref message;
- g_skype->GetMessageByGuid(guid, message);
+ this->GetMessageByGuid(guid, message);
uint oid = message->getOID();
@@ -58,7 +58,7 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
transfer->GetPropChatmsgGuid(guid);
CMessage::Ref message;
- g_skype->GetMessageByGuid(guid, message);
+ this->GetMessageByGuid(guid, message);
uint oid = message->getOID();
@@ -89,7 +89,7 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop)
}
}
-void CSkypeProto::OnFile(CConversation::Ref &conversation, CMessage::Ref &message)
+void CSkypeProto::OnFile(const ConversationRef &conversation, const MessageRef &message)
{
CTransfer::Refs transfers;
message->GetTransfers(transfers);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index 51a07fb9d9..85a0a43a9b 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -19,13 +19,227 @@ std::map<std::wstring, std::wstring> CSkypeProto::languages;
void CSkypeProto::InitLanguages()
{
-
- List_String languageCodeList;
- List_String languageNameList;
- if (g_skype->GetISOLanguageInfo(languageCodeList, languageNameList))
- for (size_t i = 0; i < languageCodeList.size(); i++)
- CSkypeProto::languages[::mir_a2u(languageCodeList[i])] = ::mir_a2u(languageNameList[i]);
-}
+ std::map<std::wstring, std::wstring> result;
+ result[L"ab"] = L"Abkhazian";
+ result[L"aa"] = L"Afar";
+ result[L"af"] = L"Afrikaans";
+ result[L"ak"] = L"Akan";
+ result[L"sq"] = L"Albanian";
+ result[L"am"] = L"Amharic";
+ result[L"ar"] = L"Arabic";
+ result[L"an"] = L"Aragonese";
+ result[L"hy"] = L"Armenian";
+ result[L"as"] = L"Assamese";
+ result[L"av"] = L"Avaric";
+ result[L"ae"] = L"Avestan";
+ result[L"ay"] = L"Aymara";
+ result[L"az"] = L"Azerbaijani";
+ result[L"bm"] = L"Bambara";
+ result[L"ba"] = L"Bashkir";
+ result[L"eu"] = L"Basque";
+ result[L"be"] = L"Belarusian";
+ result[L"bn"] = L"Bengali";
+ result[L"bh"] = L"Bihari languages";
+ result[L"bi"] = L"Bislama";
+ result[L"nb"] = L"Bokmal, Norwegian";
+ result[L"bs"] = L"Bosnian";
+ result[L"br"] = L"Breton";
+ result[L"bg"] = L"Bulgarian";
+ result[L"my"] = L"Burmese";
+ result[L"es"] = L"Castilian";
+ result[L"ca"] = L"Catalan";
+ result[L"km"] = L"Central Khmer";
+ result[L"ch"] = L"Chamorro";
+ result[L"ce"] = L"Chechen";
+ result[L"ny"] = L"Chewa";
+ result[L"ny"] = L"Chichewa";
+ result[L"zh"] = L"Chinese";
+ result[L"za"] = L"Chuang";
+ result[L"cu"] = L"Church Slavic";
+ result[L"cu"] = L"Church Slavonic";
+ result[L"cv"] = L"Chuvash";
+ result[L"kw"] = L"Cornish";
+ result[L"co"] = L"Corsican";
+ result[L"cr"] = L"Cree";
+ result[L"hr"] = L"Croatian";
+ result[L"cs"] = L"Czech";
+ result[L"da"] = L"Danish";
+ result[L"dv"] = L"Dhivehi";
+ result[L"dv"] = L"Divehi";
+ result[L"nl"] = L"Dutch";
+ result[L"dz"] = L"Dzongkha";
+ result[L"en"] = L"English";
+ result[L"eo"] = L"Esperanto";
+ result[L"et"] = L"Estonian";
+ result[L"ee"] = L"Ewe";
+ result[L"fo"] = L"Faroese";
+ result[L"fj"] = L"Fijian";
+ result[L"fi"] = L"Finnish";
+ result[L"nl"] = L"Flemish";
+ result[L"fr"] = L"French";
+ result[L"ff"] = L"Fulah";
+ result[L"gd"] = L"Gaelic";
+ result[L"gl"] = L"Galician";
+ result[L"lg"] = L"Ganda";
+ result[L"ka"] = L"Georgian";
+ result[L"de"] = L"German";
+ result[L"ki"] = L"Gikuyu";
+ result[L"el"] = L"Greek, Modern (1453-)";
+ result[L"kl"] = L"Greenlandic";
+ result[L"gn"] = L"Guarani";
+ result[L"gu"] = L"Gujarati";
+ result[L"ht"] = L"Haitian";
+ result[L"ht"] = L"Haitian Creole";
+ result[L"ha"] = L"Hausa";
+ result[L"he"] = L"Hebrew";
+ result[L"hz"] = L"Herero";
+ result[L"hi"] = L"Hindi";
+ result[L"ho"] = L"Hiri Motu";
+ result[L"hu"] = L"Hungarian";
+ result[L"is"] = L"Icelandic";
+ result[L"io"] = L"Ido";
+ result[L"ig"] = L"Igbo";
+ result[L"id"] = L"Indonesian";
+ result[L"ia"] = L"Interlingua (International Auxiliary Language Association)";
+ result[L"ie"] = L"Interlingue";
+ result[L"iu"] = L"Inuktitut";
+ result[L"ik"] = L"Inupiaq";
+ result[L"ga"] = L"Irish";
+ result[L"it"] = L"Italian";
+ result[L"ja"] = L"Japanese";
+ result[L"jv"] = L"Javanese";
+ result[L"kl"] = L"Kalaallisut";
+ result[L"kn"] = L"Kannada";
+ result[L"kr"] = L"Kanuri";
+ result[L"ks"] = L"Kashmiri";
+ result[L"kk"] = L"Kazakh";
+ result[L"ki"] = L"Kikuyu";
+ result[L"rw"] = L"Kinyarwanda";
+ result[L"ky"] = L"Kirghiz";
+ result[L"kv"] = L"Komi";
+ result[L"kg"] = L"Kongo";
+ result[L"ko"] = L"Korean";
+ result[L"kj"] = L"Kuanyama";
+ result[L"ku"] = L"Kurdish";
+ result[L"kj"] = L"Kwanyama";
+ result[L"ky"] = L"Kyrgyz";
+ result[L"lo"] = L"Lao";
+ result[L"la"] = L"Latin";
+ result[L"lv"] = L"Latvian";
+ result[L"lb"] = L"Letzeburgesch";
+ result[L"li"] = L"Limburgan";
+ result[L"li"] = L"Limburger";
+ result[L"li"] = L"Limburgish";
+ result[L"ln"] = L"Lingala";
+ result[L"lt"] = L"Lithuanian";
+ result[L"lu"] = L"Luba-Katanga";
+ result[L"lb"] = L"Luxembourgish";
+ result[L"mk"] = L"Macedonian";
+ result[L"mg"] = L"Malagasy";
+ result[L"ms"] = L"Malay";
+ result[L"ml"] = L"Malayalam";
+ result[L"dv"] = L"Maldivian";
+ result[L"mt"] = L"Maltese";
+ result[L"gv"] = L"Manx";
+ result[L"mi"] = L"Maori";
+ result[L"mr"] = L"Marathi";
+ result[L"mh"] = L"Marshallese";
+ result[L"ro"] = L"Moldavian";
+ result[L"ro"] = L"Moldovan";
+ result[L"mn"] = L"Mongolian";
+ result[L"na"] = L"Nauru";
+ result[L"nv"] = L"Navaho";
+ result[L"nv"] = L"Navajo";
+ result[L"nd"] = L"Ndebele, North";
+ result[L"nr"] = L"Ndebele, South";
+ result[L"ng"] = L"Ndonga";
+ result[L"ne"] = L"Nepali";
+ result[L"nd"] = L"North Ndebele";
+ result[L"se"] = L"Northern Sami";
+ result[L"no"] = L"Norwegian";
+ result[L"nb"] = L"Norwegian Bokmal";
+ result[L"nn"] = L"Norwegian Nynorsk";
+ result[L"ii"] = L"Nuosu";
+ result[L"ny"] = L"Nyanja";
+ result[L"nn"] = L"Nynorsk, Norwegian";
+ result[L"ie"] = L"Occidental";
+ result[L"oc"] = L"Occitan (post 1500)";
+ result[L"oj"] = L"Ojibwa";
+ result[L"cu"] = L"Old Bulgarian";
+ result[L"cu"] = L"Old Church Slavonic";
+ result[L"cu"] = L"Old Slavonic";
+ result[L"or"] = L"Oriya";
+ result[L"om"] = L"Oromo";
+ result[L"os"] = L"Ossetian";
+ result[L"os"] = L"Ossetic";
+ result[L"pi"] = L"Pali";
+ result[L"pa"] = L"Panjabi";
+ result[L"ps"] = L"Pashto";
+ result[L"fa"] = L"Persian";
+ result[L"pl"] = L"Polish";
+ result[L"pt"] = L"Portuguese";
+ result[L"pa"] = L"Punjabi";
+ result[L"ps"] = L"Pushto";
+ result[L"qu"] = L"Quechua";
+ result[L"ro"] = L"Romanian";
+ result[L"rm"] = L"Romansh";
+ result[L"rn"] = L"Rundi";
+ result[L"ru"] = L"Russian";
+ result[L"sm"] = L"Samoan";
+ result[L"sg"] = L"Sango";
+ result[L"sa"] = L"Sanskrit";
+ result[L"sc"] = L"Sardinian";
+ result[L"gd"] = L"Scottish Gaelic";
+ result[L"sr"] = L"Serbian";
+ result[L"sn"] = L"Shona";
+ result[L"ii"] = L"Sichuan Yi";
+ result[L"sd"] = L"Sindhi";
+ result[L"si"] = L"Sinhala";
+ result[L"si"] = L"Sinhalese";
+ result[L"sk"] = L"Slovak";
+ result[L"sl"] = L"Slovenian";
+ result[L"so"] = L"Somali";
+ result[L"st"] = L"Sotho, Southern";
+ result[L"nr"] = L"South Ndebele";
+ result[L"es"] = L"Spanish";
+ result[L"su"] = L"Sundanese";
+ result[L"sw"] = L"Swahili";
+ result[L"ss"] = L"Swati";
+ result[L"sv"] = L"Swedish";
+ result[L"tl"] = L"Tagalog";
+ result[L"ty"] = L"Tahitian";
+ result[L"tg"] = L"Tajik";
+ result[L"ta"] = L"Tamil";
+ result[L"tt"] = L"Tatar";
+ result[L"te"] = L"Telugu";
+ result[L"th"] = L"Thai";
+ result[L"bo"] = L"Tibetan";
+ result[L"ti"] = L"Tigrinya";
+ result[L"to"] = L"Tonga (Tonga Islands)";
+ result[L"ts"] = L"Tsonga";
+ result[L"tn"] = L"Tswana";
+ result[L"tr"] = L"Turkish";
+ result[L"tk"] = L"Turkmen";
+ result[L"tw"] = L"Twi";
+ result[L"ug"] = L"Uighur";
+ result[L"uk"] = L"Ukrainian";
+ result[L"ur"] = L"Urdu";
+ result[L"ug"] = L"Uyghur";
+ result[L"uz"] = L"Uzbek";
+ result[L"ca"] = L"Valencian";
+ result[L"ve"] = L"Venda";
+ result[L"vi"] = L"Vietnamese";
+ result[L"vo"] = L"Volapuk";
+ result[L"wa"] = L"Walloon";
+ result[L"cy"] = L"Welsh";
+ result[L"fy"] = L"Western Frisian";
+ result[L"wo"] = L"Wolof";
+ result[L"xh"] = L"Xhosa";
+ result[L"yi"] = L"Yiddish";
+ result[L"yo"] = L"Yoruba";
+ result[L"za"] = L"Zhuang";
+ result[L"zu"] = L"Zulu";
+ }
void CSkypeProto::InitCustomFolders()
{
diff --git a/protocols/Skype/src/skypekit/account.cpp b/protocols/Skype/src/skypekit/account.cpp
index fa931d179e..08c37d67e2 100644
--- a/protocols/Skype/src/skypekit/account.cpp
+++ b/protocols/Skype/src/skypekit/account.cpp
@@ -1,5 +1,4 @@
#include "account.h"
-#include "skypekit.h"
CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root)
{
@@ -9,7 +8,7 @@ CAccount::CAccount(unsigned int oid, SERootObject* root) : Account(oid, root)
void CAccount::SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto)
{
- this->skype = (CSkype *)root;
+ this->skype = (Skype *)root;
this->proto = proto;
this->callback = callback;
diff --git a/protocols/Skype/src/skypekit/account.h b/protocols/Skype/src/skypekit/account.h
index 07ff0b929c..36a78e745b 100644
--- a/protocols/Skype/src/skypekit/account.h
+++ b/protocols/Skype/src/skypekit/account.h
@@ -2,8 +2,6 @@
#include "common.h"
-class CSkype;
-
class CAccount : public Account
{
public:
@@ -20,7 +18,7 @@ public:
void SetOnAccountChangedCallback(OnAccountChanged callback, CSkypeProto* proto);
private:
- CSkype *skype;
+ Skype *skype;
CSkypeProto* proto;
OnAccountChanged callback;
void OnChange(int prop);
diff --git a/protocols/Skype/src/skypekit/skypekit.cpp b/protocols/Skype/src/skypekit/skypekit.cpp
deleted file mode 100644
index d06f505969..0000000000
--- a/protocols/Skype/src/skypekit/skypekit.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-#include "skypekit.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);
-}
-
-bool CSkype::CreateConferenceWithConsumers(ConversationRef &conference, const SEStringList &identities)
-{
- if (this->CreateConference(conference))
- {
- conference->SetOption(CConversation::P_OPT_JOINING_ENABLED, true);
- conference->SetOption(CConversation::P_OPT_ENTRY_LEVEL_RANK, CParticipant::WRITER);
- conference->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1);
- conference->AddConsumers(identities);
-
- return true;
- }
-
- return false;
-}
-
-void CSkype::SetOnMessageCallback(OnMessaged callback, CSkypeProto* proto)
-{
- this->proto = proto;
- this->onMessagedCallback = callback;
-}
-
-void CSkype::OnMessage (
- const MessageRef & message,
- const bool & changesInboxTimestamp,
- const MessageRef & supersedesHistoryMessage,
- const ConversationRef & conversation)
-{
- if (this->proto && this->onMessagedCallback)
- (proto->*onMessagedCallback)(conversation, message);
-}
diff --git a/protocols/Skype/src/skypekit/skypekit.h b/protocols/Skype/src/skypekit/skypekit.h
deleted file mode 100644
index 3f1d7b1e58..0000000000
--- a/protocols/Skype/src/skypekit/skypekit.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#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);
-
- bool CreateConferenceWithConsumers(ConversationRef &conference, const SEStringList &identities);
-
-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