From 0ad4fffb15944d82febdcec80ef920cd400d8169 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Mon, 3 Jun 2013 20:54:43 +0000 Subject: - use core base64 funcs - few changes in group chat git-svn-id: http://svn.miranda-ng.org/main/trunk@4876 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/Skype_10.vcxproj | 4 +- protocols/Skype/Skype_10.vcxproj.filters | 6 - protocols/Skype/Skype_11.vcxproj | 2 - protocols/Skype/Skype_11.vcxproj.filters | 6 - protocols/Skype/src/base64/base64.cpp | 102 ------- protocols/Skype/src/base64/base64.h | 12 - protocols/Skype/src/skype_account.cpp | 10 +- protocols/Skype/src/skype_chat.cpp | 504 ++++++++++++++++--------------- protocols/Skype/src/skype_chat.h | 4 +- protocols/Skype/src/skype_instances.cpp | 2 +- protocols/Skype/src/skype_runtime.cpp | 53 ++-- 11 files changed, 299 insertions(+), 406 deletions(-) delete mode 100644 protocols/Skype/src/base64/base64.cpp delete mode 100644 protocols/Skype/src/base64/base64.h diff --git a/protocols/Skype/Skype_10.vcxproj b/protocols/Skype/Skype_10.vcxproj index e787b6147f..834aa59e98 100644 --- a/protocols/Skype/Skype_10.vcxproj +++ b/protocols/Skype/Skype_10.vcxproj @@ -84,7 +84,7 @@ 4996;%(DisableSpecificWarnings) MultiThreadedDebugDLL $(IntDir)/%(RelativeDir)/ - afxres.h + afxres.h Windows @@ -183,7 +183,6 @@ - @@ -202,7 +201,6 @@ - diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters index 86f651cdb2..dad133ab2a 100644 --- a/protocols/Skype/Skype_10.vcxproj.filters +++ b/protocols/Skype/Skype_10.vcxproj.filters @@ -66,9 +66,6 @@ Source Files - - Source Files - Source Files\skypekit @@ -134,9 +131,6 @@ Header Files - - Header Files - Header Files\skypekit diff --git a/protocols/Skype/Skype_11.vcxproj b/protocols/Skype/Skype_11.vcxproj index 25b8272c7f..32b126ac9a 100644 --- a/protocols/Skype/Skype_11.vcxproj +++ b/protocols/Skype/Skype_11.vcxproj @@ -188,7 +188,6 @@ - @@ -207,7 +206,6 @@ - diff --git a/protocols/Skype/Skype_11.vcxproj.filters b/protocols/Skype/Skype_11.vcxproj.filters index 3fbc5a9f87..e4e52e2a0e 100644 --- a/protocols/Skype/Skype_11.vcxproj.filters +++ b/protocols/Skype/Skype_11.vcxproj.filters @@ -69,9 +69,6 @@ Source Files - - Source Files - Source Files\skypekit @@ -134,9 +131,6 @@ Header Files - - Header Files - Header Files\skypekit diff --git a/protocols/Skype/src/base64/base64.cpp b/protocols/Skype/src/base64/base64.cpp deleted file mode 100644 index 4cd1ebf007..0000000000 --- a/protocols/Skype/src/base64/base64.cpp +++ /dev/null @@ -1,102 +0,0 @@ -#include "base64.h" - -char Base64::CharBase64[] = -{ - 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', - 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', - 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', - 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' -}; - -ULONG Base64::Encode(const char *inputString, char *outputBuffer, SIZE_T nMaxLength) -{ - int outpos = 0; - char chr[3], enc[4]; - - for (unsigned int i = 0; i < ::strlen(inputString); i += 3) - { - if (outpos + 4 >= (int)nMaxLength) - break; - - chr[0] = inputString[i]; - chr[1] = inputString[i+1]; - chr[2] = inputString[i+2]; - - enc[0] = chr[0] >> 2; - enc[1] = ((chr[0] & 0x03) << 4) | (chr[1] >> 4); - enc[2] = ((chr[1] & 0x0F) << 2) | (chr[2] >> 6); - enc[3] = chr[2] & 0x3F; - - outputBuffer[outpos++] = Base64::CharBase64[enc[0]]; - outputBuffer[outpos++] = Base64::CharBase64[enc[1]]; - - if (i + 1 >= ::strlen(inputString)) - { - outputBuffer[outpos++] = '='; - outputBuffer[outpos++] = '='; - } - else if (i + 2 >= ::strlen(inputString)) - { - outputBuffer[outpos++] = Base64::CharBase64[enc[2]]; - outputBuffer[outpos++] = '='; - } - else - { - outputBuffer[outpos++] = Base64::CharBase64[enc[2]]; - outputBuffer[outpos++] = Base64::CharBase64[enc[3]]; - } - } - - outputBuffer[outpos] = 0; - return outpos; -} - -int Base64::IndexBase64[] = -{ - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,62, -1,-1,-1,63, - 52,53,54,55, 56,57,58,59, 60,61,-1,-1, -1,-1,-1,-1, - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11,12,13,14, - 15,16,17,18, 19,20,21,22, 23,24,25,-1, -1,-1,-1,-1, - -1,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40, - 41,42,43,44, 45,46,47,48, 49,50,51,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, - -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1, -1,-1,-1,-1 -}; - -ULONG Base64::Decode(const char *inputString, char *outputBuffer, SIZE_T nMaxLength) -{ - int outpos = 0; - char chr[3], enc[4]; - - for (int i = 0; i < (int)::strlen(inputString); i += 4) - { - if (outpos+3 >= (int)nMaxLength) break; - - enc[0] = Base64::IndexBase64[inputString[i]]; - enc[1] = Base64::IndexBase64[inputString[i+1]]; - enc[2] = Base64::IndexBase64[inputString[i+2]]; - enc[3] = Base64::IndexBase64[inputString[i+3]]; - - if (enc[0] == -1 || enc[1] == -1) break; - - chr[0] = (enc[0] << 2) | (enc[1] >> 4); - chr[1] = ((enc[1] & 15) << 4) | (enc[2] >> 2); - chr[2] = ((enc[2] & 3) << 6) | enc[3]; - - outputBuffer[outpos++] = chr[0]; - - if (enc[2] != -1) outputBuffer[outpos++] = chr[1]; - if (enc[3] != -1) outputBuffer[outpos++] = chr[2]; - } - - outputBuffer[outpos] = 0; - return outpos; -} \ No newline at end of file diff --git a/protocols/Skype/src/base64/base64.h b/protocols/Skype/src/base64/base64.h deleted file mode 100644 index c81ef778fc..0000000000 --- a/protocols/Skype/src/base64/base64.h +++ /dev/null @@ -1,12 +0,0 @@ -#include - -class Base64 -{ -private: - static char CharBase64[]; - static int IndexBase64[]; - -public: - static ULONG Encode(const char *inputString, char *outputBuffer, SIZE_T nMaxLength); - static ULONG Decode(const char *inputString, char *outputBuffer, SIZE_T nMaxLength); -}; \ No newline at end of file diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index aa19ea233e..2f1379048f 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -1,5 +1,4 @@ #include "skype_proto.h" -#include "base64/base64.h" wchar_t *CSkypeProto::LogoutReasons[] = { @@ -181,11 +180,12 @@ void CSkypeProto::InitProxy() this->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address); if (nlus.useProxyAuth) { - char encodedPass[MAX_PATH]; - Base64::Encode(nlus.szProxyAuthPassword, encodedPass, MAX_PATH); + char *encodedPass = (char *)::CallService(MS_UTILS_ENCODEBASE64, 0, (LPARAM)nlus.szProxyAuthPassword); this->SetStr(SETUPKEY_HTTPS_PROXY_USER, nlus.szProxyAuthUser); this->SetStr(SETUPKEY_HTTPS_PROXY_PWD, encodedPass); + + ::mir_free(encodedPass); } break; @@ -197,8 +197,12 @@ void CSkypeProto::InitProxy() this->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address); if (nlus.useProxyAuth) { + char *encodedPass = (char *)::CallService(MS_UTILS_ENCODEBASE64, 0, (LPARAM)nlus.szProxyAuthPassword); + this->SetStr(SETUPKEY_SOCKS_PROXY_USER, nlus.szProxyAuthUser); this->SetStr(SETUPKEY_SOCKS_PROXY_PWD, nlus.szProxyAuthPassword); + + ::mir_free(encodedPass); } break; diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 2d7a34fda7..73839e4f00 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -141,7 +141,10 @@ void ChatRoom::Start(const ParticipantRefs &participants, bool showWindow) member->status = CSkypeProto::SkypeToMirandaStatus(status); contact->GetPropFullname(data); - member->nick = ::mir_utf8decodeW(data); + if (data.length() != 0) + member->nick = ::mir_utf8decodeW(data); + else + member->nick = ::mir_wstrdup(sid); this->AddMember(member); } @@ -181,24 +184,18 @@ void ChatRoom::SendEvent(ChatMember *member, int eventType, DWORD timestamp, DWO ::CallServiceSync(MS_GC_EVENT, 0, (LPARAM)&gce); } -//void ChatRoom::SendEvent(const wchar_t *sid, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message) -//{ -// if ( !this->IsMe(sid)) -// { -// ChatMember search(sid); -// ChatMember *member = this->members.find(&search); -// if (member != NULL) -// { -// this->SendEvent(member, eventType, timestamp, flags, itemData, status, message); -// } -// } -// else -// { -// ChatMember self(this->me); -// -// this->SendEvent(&self, eventType, timestamp, flags, itemData, status, message); -// } -//} +void ChatRoom::SendEvent(const wchar_t *sid, int eventType, DWORD timestamp, DWORD flags, DWORD itemData, const wchar_t *status, const wchar_t *message) +{ + if ( !this->IsMe(sid)) + { + ChatMember search(sid); + ChatMember *member = this->members.find(&search); + if (member != NULL) + this->SendEvent(member, eventType, timestamp, flags, itemData, status, message); + } + else + this->SendEvent(this->me, eventType, timestamp, flags, itemData, status, message); +} void ChatRoom::AppendMessage(const wchar_t *sid, const wchar_t *message, DWORD timestamp, int eventType) { @@ -326,6 +323,203 @@ void ChatRoom::RemoveMember(const wchar_t *sid, DWORD timestamp) this->RemoveMember(&member, timestamp); } +void ChatRoom::OnEvent(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 data; + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + message->GetPropBodyXml(data); + ptrW text =::mir_a2u(CSkypeProto::RemoveHtml(data)); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->AppendMessage(sid, text, timestamp, messageType == CMessage::POSTED_TEXT ? GC_EVENT_MESSAGE : GC_EVENT_ACTION); + } + break; + + case Message::ADDED_CONSUMERS: + case Message::ADDED_APPLICANTS: + { + SEString data; + + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropIdentities(data); + char *identities = ::mir_strdup(data); + if (identities) + { + char *identity = ::strtok(identities, " "); + if (identity != NULL) + { + do + { + Contact::Ref contact; + this->ppro->GetContact(identity, contact); + + contact->GetIdentity(data); + ptrW sid = ::mir_utf8decodeW(data); + + ChatMember *member = new ChatMember(sid); + //todo: fix rank + + member->rank = + messageType == Message::ADDED_APPLICANTS ? + Participant::APPLICANT : + Participant::SPEAKER; + //conversation->GetUintProp(Conversation::P_OPT_ENTRY_LEVEL_RANK); + //participants[i]->GetUintProp(Participant::P_RANK); + + Contact::AVAILABILITY status; + contact->GetPropAvailability(status); + member->status = CSkypeProto::SkypeToMirandaStatus(status); + + contact->GetPropFullname(data); + member->nick = ::mir_utf8decodeW(data); + + this->AddMember(member, timestamp); + + identity = ::strtok(NULL, " "); + } + while (identity != NULL); + } + ::mir_free(identities); + } + } + } + break; + + case Message::RETIRED_OTHERS: + { + SEString data; + + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + message->GetPropIdentities(data); + char *identities = ::mir_strdup(data); + if (identities) + { + char *identity = ::strtok(identities, " "); + if (identity != NULL) + { + do + { + this->KickMember(ptrW(::mir_utf8decodeW(identity)), sid, timestamp); + + identity = ::strtok(NULL, " "); + } + while (identity != NULL); + } + ::mir_free(identities); + } + } + } + break; + + case Message::RETIRED: + { + SEString data; + + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + this->RemoveMember(sid, timestamp); + } + } + break; + + case Message::SET_RANK: + { + SEString data; + message->GetPropBodyXml(data); + ptrA text = ::mir_strdup(data); + int i = 0; + + { + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + ChatMember search(sid); + ChatMember *member = this->FindChatMember(sid); + if (member != NULL) + { + uint timestamp; + message->GetPropTimestamp(timestamp); + + message->GetPropBodyXml(data); + ptrW rank = ::mir_utf8decodeW(data); + + member->rank = 0; + } + } + } + break; + + case CMessage::STARTED_LIVESESSION: + { + SEString data; + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->SendEvent( + sid, + GC_EVENT_INFORMATION, + timestamp, + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Incoming group call received")); + } + break; + + case CMessage::ENDED_LIVESESSION: + { + SEString data; + + message->GetPropAuthor(data); + ptrW sid = ::mir_utf8decodeW(data); + + uint timestamp; + message->GetPropTimestamp(timestamp); + + this->SendEvent( + sid, + GC_EVENT_INFORMATION, + timestamp, + GCEF_ADDTOLOG, + 0, + NULL, + ::TranslateT("Incoming group call finished")); + } + break; + } +} + int __cdecl ChatRoom::OnGCEventHook(WPARAM, LPARAM lParam) { GCHOOK *gch = (GCHOOK *)lParam; @@ -414,7 +608,15 @@ int __cdecl ChatRoom::OnGCMenuHook(WPARAM, LPARAM lParam) { GCMENUITEMS *gcmi = (GCMENUITEMS*) lParam; - //if (gcmi == NULL || ::stricmp(gcmi->pszModule, this->m_szModuleName)) + GC_INFO gci = {0}; + gci.Flags = BYID | DATA; + gci.pszModule = gcmi->pszModule; + + ::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci); + + ChatRoom *room = (ChatRoom *)gci.dwItemData; + + if (room == NULL || ::stricmp(gcmi->pszModule, room->ppro->m_szModuleName)) return 0; if (gcmi->Type == MENU_ON_LOG) @@ -1255,239 +1457,32 @@ void CSkypeProto::OnChatEvent(const ConversationRef &conversation, const 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(ptrW(::mir_utf8decodeW(author)), this->login) == 0) - this->OnChatMessageSent(conversation, message, messageType); - else - this->OnChatMessageReceived(conversation, message, messageType); - } - break; + GC_INFO gci = {0}; + gci.Flags = BYID | DATA; + gci.pszModule = this->m_szModuleName; - case Message::ADDED_CONSUMERS: - case Message::ADDED_APPLICANTS: - { - SEString data; + if ( !::CallServiceSync(MS_GC_GETINFO, 0, (LPARAM)&gci)) + { + ChatRoom *room = (ChatRoom *)gci.dwItemData; + room->OnEvent(conversation, message); + } + else + { + SEString data; - conversation->GetPropIdentity(data); - ptrW cid = ::mir_utf8decodeW(data); + conversation->GetPropIdentity(data); + ptrW cid = ::mir_utf8decodeW(data); - ChatRoom *room = this->chatList->FindChatRoom(cid); - if (room == NULL) - { - conversation->GetPropDisplayname(data); - ptrW name = ::mir_utf8decodeW(data); + conversation->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); - ChatRoom *room = new ChatRoom(cid, name, this); - this->chatList->AddChatRoom(room); + ChatRoom *room = new ChatRoom(cid, name, this); + this->chatList->AddChatRoom(room); - Participant::Refs participants; - conversation->GetParticipants(participants, Conversation::ALL); + Participant::Refs participants; + conversation->GetParticipants(participants, Conversation::ALL); - room->Start(participants, true); - } - else - { - uint timestamp; - message->GetPropTimestamp(timestamp); - - message->GetPropIdentities(data); - char *identities = ::mir_strdup(data); - if (identities) - { - char *identity = ::strtok(identities, " "); - if (identity != NULL) - { - do - { - Contact::Ref contact; - this->GetContact(identity, contact); - - contact->GetIdentity(data); - ptrW sid = ::mir_utf8decodeW(data); - - ChatMember *member = new ChatMember(sid); - //todo: fix rank - - member->rank = - messageType == Message::ADDED_APPLICANTS ? - Participant::APPLICANT : - Participant::SPEAKER; - //conversation->GetUintProp(Conversation::P_OPT_ENTRY_LEVEL_RANK); - //participants[i]->GetUintProp(Participant::P_RANK); - - Contact::AVAILABILITY status; - contact->GetPropAvailability(status); - member->status = CSkypeProto::SkypeToMirandaStatus(status); - - contact->GetPropFullname(data); - member->nick = ::mir_utf8decodeW(data); - - room->AddMember(member, timestamp); - - identity = ::strtok(NULL, " "); - } - while (identity != NULL); - } - ::mir_free(identities); - } - } - } - break; - - case Message::RETIRED_OTHERS: - { - SEString data; - - conversation->GetPropIdentity(data); - ptrW cid = ::mir_utf8decodeW(data); - - ChatRoom *room = this->chatList->FindChatRoom(cid); - if (room != NULL) - { - uint timestamp; - message->GetPropTimestamp(timestamp); - - message->GetPropAuthor(data); - ptrW sid = ::mir_utf8decodeW(data); - - message->GetPropIdentities(data); - char *identities = ::mir_strdup(data); - if (identities) - { - char *identity = ::strtok(identities, " "); - if (identity != NULL) - { - do - { - room->KickMember(ptrW(::mir_utf8decodeW(identity)), sid, timestamp); - - identity = ::strtok(NULL, " "); - } - while (identity != NULL); - } - ::mir_free(identities); - } - } - } - break; - - case Message::RETIRED: - { - SEString data; - - conversation->GetPropIdentity(data); - ptrW cid = ::mir_utf8decodeW(data); - - ChatRoom *room = this->chatList->FindChatRoom(cid); - if (room != NULL) - { - uint timestamp; - message->GetPropTimestamp(timestamp); - - message->GetPropAuthor(data); - ptrW sid = ::mir_utf8decodeW(data); - - room->RemoveMember(sid, timestamp); - } - } - break; - - case CMessage::SPAWNED_CONFERENCE: - { - SEString data; - - conversation->GetPropIdentity(data); - ptrW cid = ::mir_utf8decodeW(data); - - conversation->GetPropDisplayname(data); - ptrW name = ::mir_utf8decodeW(data); - - ChatRoom *room = new ChatRoom(cid, name, this); - this->chatList->AddChatRoom(room); - - CParticipant::Refs participants; - conversation->GetParticipants(participants, CConversation::ALL); - - room->Start(participants, true); - } - break; - - case Message::SET_RANK: - { - SEString data; - message->GetPropBodyXml(data); - ptrA text = ::mir_strdup(data); - int i = 0; - - conversation->GetPropIdentity(data); - ptrW cid = ::mir_utf8decodeW(data); - - ChatRoom *room = this->chatList->FindChatRoom(cid); - if (room != NULL) - { - message->GetPropAuthor(data); - ptrW sid = ::mir_utf8decodeW(data); - - ChatMember search(sid); - ChatMember *member = room->FindChatMember(sid); - if (member != NULL) - { - uint timestamp; - message->GetPropTimestamp(timestamp); - - message->GetPropBodyXml(data); - ptrW rank = ::mir_utf8decodeW(data); - - member->rank = 0; - } - } - } - break; - - case CMessage::STARTED_LIVESESSION: - { - SEString data; - - conversation->GetPropIdentity(data); - ptrW 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); - ptrW 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; + room->Start(participants, true); } } @@ -1499,5 +1494,20 @@ void CSkypeProto::OnConversationListChange( uint convoType = conversation->GetUintProp(Conversation::P_TYPE); if (convoType == Conversation::CONFERENCE && type == Conversation::INBOX_CONVERSATIONS && added) { + SEString data; + + conversation->GetPropIdentity(data); + ptrW cid = ::mir_utf8decodeW(data); + + conversation->GetPropDisplayname(data); + ptrW name = ::mir_utf8decodeW(data); + + ChatRoom *room = new ChatRoom(cid, name, this); + this->chatList->AddChatRoom(room); + + Participant::Refs participants; + conversation->GetParticipants(participants, Conversation::ALL); + + room->Start(participants, true); } } \ No newline at end of file diff --git a/protocols/Skype/src/skype_chat.h b/protocols/Skype/src/skype_chat.h index 947b2324b1..d12cc3fa72 100644 --- a/protocols/Skype/src/skype_chat.h +++ b/protocols/Skype/src/skype_chat.h @@ -95,7 +95,7 @@ public: void LeaveChat(); void SendEvent(ChatMember *member, int eventType, DWORD timestamp = time(NULL), DWORD flags = GCEF_ADDTOLOG, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL); - //void SendEvent(const wchar_t *sid, int eventType, DWORD timestamp = time(NULL), DWORD flags = GCEF_ADDTOLOG, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL); + void SendEvent(const wchar_t *sid, int eventType, DWORD timestamp = time(NULL), DWORD flags = GCEF_ADDTOLOG, DWORD itemData = 0, const wchar_t *status = NULL, const wchar_t *message = NULL); void AppendMessage(const wchar_t *sid, const wchar_t *message, DWORD timestamp = time(NULL), int eventType = GC_EVENT_MESSAGE); @@ -115,6 +115,8 @@ public: void RemoveMember(ChatMember *member, DWORD timestamp = time(NULL)); void RemoveMember(const wchar_t *sid, DWORD timestamp = time(NULL)); + + void OnEvent(const ConversationRef &conversation, const MessageRef &message); }; class ChatList diff --git a/protocols/Skype/src/skype_instances.cpp b/protocols/Skype/src/skype_instances.cpp index 6cc9c77d9b..aef0cb6e1e 100644 --- a/protocols/Skype/src/skype_instances.cpp +++ b/protocols/Skype/src/skype_instances.cpp @@ -41,7 +41,7 @@ CSkypeProto* CSkypeProto::InitSkypeProto(const char* protoName, const wchar_t* u return NULL; } - free(keyPair); + ::mir_free(keyPair); if ( !ppro->start()) { diff --git a/protocols/Skype/src/skype_runtime.cpp b/protocols/Skype/src/skype_runtime.cpp index 1844d2109a..9824ef10bb 100644 --- a/protocols/Skype/src/skype_runtime.cpp +++ b/protocols/Skype/src/skype_runtime.cpp @@ -1,43 +1,50 @@ #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) + HRSRC hResource = FindResource(g_hInstance, MAKEINTRESOURCE(IDR_KEY), L"BIN"); + if (hResource) { - HGLOBAL hResource = LoadResource(g_hInstance, hRes); - if (hResource) + HGLOBAL hLoadedResource = LoadResource(g_hInstance, hResource); + if (hLoadedResource) { - aes_context ctx; - unsigned char key[128]; + LPVOID pLockedResource = LockResource(hLoadedResource); - int basedecoded = Base64::Decode(MY_KEY, (char *)key, MAX_PATH); - ::aes_set_key(&ctx, key, 128); - memset(key, 0, sizeof(key)); + if (pLockedResource) + { + aes_context ctx; + char *key = (char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)MY_KEY); + + ::aes_set_key(&ctx, (unsigned char *)key, 128); + ::mir_free(key); + + int length = ::SizeofResource(g_hInstance, hResource); + if (length != 0) + { + char *pData = (char *)pLockedResource; + if (!pData) + return NULL; - basedecoded = ::SizeofResource(g_hInstance, hRes); - char *pData = (char *)hResource; - if (!pData) - return NULL; + pData[length] = 0; - unsigned char *bufD = (unsigned char *)::malloc(basedecoded + 1); - unsigned char *tmpD = (unsigned char *)::malloc(basedecoded + 1); - basedecoded = Base64::Decode(pData, (char *)tmpD, basedecoded); + unsigned char *bufD = (unsigned char *)::mir_alloc(length * 2); + unsigned char *tmpD = (unsigned char *)::CallService(MS_UTILS_DECODEBASE64, 0, (LPARAM)pData); - for (int i = 0; i < basedecoded; i += 16) - aes_decrypt(&ctx, tmpD+i, bufD+i); + for (int i = 0; i < length; i += 16) + aes_decrypt(&ctx, tmpD + i, bufD + i); - ::free(tmpD); - bufD[basedecoded] = 0; //cert should be null terminated - return (char *)bufD; + ::mir_free(tmpD); + //bufD[length] = 0; //cert should be null terminated + return (char *)bufD; + } + } } - return NULL; } + return NULL; } -- cgit v1.2.3