From b3e0d5a4ed673b3ad80da1934359ee8c6606e1f4 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 21 Dec 2012 14:41:01 +0000 Subject: - sixed some issues with history, messages, chats and contacts git-svn-id: http://svn.miranda-ng.org/main/trunk@2778 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype.cpp | 2 +- protocols/Skype/src/skype_chat.cpp | 9 +++-- protocols/Skype/src/skype_contacts.cpp | 10 ++--- protocols/Skype/src/skype_dialogs.cpp | 33 ++++++++++------- protocols/Skype/src/skype_events.cpp | 68 ++++++++++++++++++---------------- protocols/Skype/src/skype_proto.cpp | 6 +-- protocols/Skype/src/skype_proto.h | 3 +- 7 files changed, 71 insertions(+), 60 deletions(-) (limited to 'protocols/Skype') diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index f2b22adf17..db48c01ff4 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -359,7 +359,7 @@ extern "C" int __declspec(dllexport) Load(void) g_skype->start(); PROTOCOLDESCRIPTOR pd = { sizeof(pd) }; - pd.szName = MODULE; + pd.szName = "SKYPE"; pd.type = PROTOTYPE_PROTOCOL; pd.fnInit = (pfnInitProto)CSkypeProto::InitSkypeProto; pd.fnUninit = (pfnUninitProto)CSkypeProto::UninitSkypeProto; diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 57a5a2faff..8072f443e0 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -54,7 +54,8 @@ void CSkypeProto::ChatValidateContact(HANDLE hItem, HWND hwndList, const char *c { if ( !this->IsProtoContact(hItem) || this->IsChatRoom(hItem)) { - /*char *sid = ::DBGetString(hItem, this->m_szModuleName, "sid"); + /*HANDLE hContact = (HANDLE)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem); + char *sid = ::DBGetString(hContact, this->m_szModuleName, "sid"); if (!sid) ::SendMessage(hwndList, CLM_DELETEITEM, (WPARAM)hItem, 0); else if(contacts && ::strstr(contacts, sid))*/ @@ -159,11 +160,11 @@ char *CSkypeProto::StartChat(const char *cid) conversation->SetOption(CConversation::P_OPT_DISCLOSE_HISTORY, 1); conversation->GetPropIdentity(data); - char *chatID = ::mir_strdup(data); + chatID = ::mir_strdup(data); } conversation->GetPropDisplayname(data); - char *chatName = ::mir_utf8decodeA((const char *)data); + char *chatName = ::mir_utf8decodeA(data); GCSESSION gcw = {0}; gcw.cbSize = sizeof(gcw); @@ -369,7 +370,7 @@ int __cdecl CSkypeProto::OnGCEventHook(WPARAM, LPARAM lParam) if (g_skype->GetConversationByIdentity(chatID, conversation, false)) { CMessage::Ref message; - char *text = ::mir_utf8encode(gch->pszText); + char *text = ::mir_utf8encode(gch->pszText); conversation->PostText(text, message); } } diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 116149cd55..bfdac69080 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -691,13 +691,13 @@ void __cdecl CSkypeProto::LoadContactList(void*) SEString data; contact->GetPropSkypename(data); - char *sid = ::mir_strdup((const char *)data); + char *sid = ::mir_strdup(data); contact->GetPropDisplayname(data); - char *nick = ::mir_utf8decodeA((const char *)data); + char *nick = ::mir_utf8decodeA(data); contact->GetPropFullname(data); - char *name = ::mir_utf8decodeA((const char *)data); + char *name = ::mir_utf8decodeA(data); DWORD flags = 0; CContact::AVAILABILITY availability; @@ -736,10 +736,10 @@ void __cdecl CSkypeProto::LoadContactList(void*) SEString data; conversations[i]->GetPropIdentity(data); - char *cid = ::mir_strdup((const char *)data); + char *cid = ::mir_strdup(data); conversations[i]->GetPropDisplayname(data); - char *name = ::mir_utf8decodeA((const char *)data); + char *name = ::mir_utf8decodeA(data); HANDLE hContact = this->AddChatRoomByID(cid, name); diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index fd41a16407..ed56eee734 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -459,12 +459,17 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP switch (msg) { case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); + { + TranslateDialogDefault(hwndDlg); - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - param = (InviteChatParam*)lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + param = (InviteChatParam*)lParam; -// WindowSetIcon(hwndDlg, "msn"); + HWND hwndClist = GetDlgItem(hwndDlg, IDC_CCLIST); + SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE); + + // WindowSetIcon(hwndDlg, "msn"); + } break; case WM_CLOSE: @@ -553,27 +558,27 @@ INT_PTR CALLBACK CSkypeProto::InviteToChatProc(HWND hwndDlg, UINT msg, WPARAM wP CConversation::Ref conversation; char *chatID = ::mir_strdup(param->id); + if (chatID) { + for (uint i = 0; i < invitedContacts.size(); i++) + { + param->ppro->AddChatContact(chatID, invitedContacts[i]); + } + g_skype->GetConversationByIdentity(chatID, conversation); conversation->AddConsumers(invitedContacts); } else { chatID = param->ppro->StartChat(NULL); + for (uint i = 0; i < invitedContacts.size(); i++) + { + param->ppro->AddChatContact(chatID, invitedContacts[i]); + } g_skype->GetConversationByIdentity(chatID, conversation); conversation->AddConsumers(invitedContacts); - - /*SEString data; - - conversation->GetPropIdentity(data); - char *cid = ::mir_strdup((const char *)data); - - for (uint i = 0; i < invitedContacts.size(); i++) - { - param->ppro->AddChatContact(cid, invitedContacts[i]); - }*/ } } diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 61b9724cb8..793a09a4f3 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -32,6 +32,7 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) CConversation::Ref conversation; g_skype->GetConversationByIdentity(chatID, conversation); + conversation->RetireFrom(); conversation->Delete(); } else @@ -43,16 +44,16 @@ int CSkypeProto::OnContactDeleted(WPARAM wParam, LPARAM lParam) void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref message) { - SEString data; + SEString data; uint timestamp; - message->GetPropTimestamp(timestamp); + message->GetPropTimestamp(timestamp); message->GetPropAuthor(data); - char *sid = ::mir_strdup((const char*)data); + char *sid = ::mir_strdup(data); message->GetPropBodyXml(data); - char *text = ::mir_utf8decodeA((const char*)data); + char *text = ::mir_strdup(data); CConversation::TYPE type; conversation->GetPropType(type); @@ -64,7 +65,7 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref for (uint i = 0; i < participants.size(); i ++) { participants[i]->GetPropIdentity(data); - char *contactSid = ::mir_strdup((const char *)data); + char *contactSid = ::mir_strdup(data); //todo: get nickname this->RaiseMessageSendedEvent( timestamp, @@ -76,14 +77,9 @@ void CSkypeProto::OnMessageSended(CConversation::Ref conversation, CMessage::Ref else { conversation->GetPropIdentity(data); - char *cid = ::mir_strdup((const char*)data); + char *cid = ::mir_strdup(data); - /*HANDLE hContact = this->GetChatRoomByID(cid); - if ( !hContact || ::DBGetContactSettingWord(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) - { - this->JoinChat(cid); - }*/ - this->SendChatMessage(cid, sid, text); + this->SendChatMessage(cid, sid, ::mir_utf8decodeA(text)); ::mir_free(cid); } @@ -97,17 +93,17 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R message->GetPropTimestamp(timestamp); message->GetPropAuthor(data); - char *sid = ::mir_strdup((const char*)data); + char *sid = ::mir_strdup(data); message->GetPropBodyXml(data); - char *text = ::mir_utf8decodeA((const char*)data); + char *text = ::mir_strdup(data); CConversation::TYPE type; conversation->GetPropType(type); if (type == CConversation::DIALOG) { message->GetPropAuthorDisplayname(data); - char *nick = ::mir_utf8encode((const char*)data); + char *nick = ::mir_utf8decodeA(data); this->RaiseMessageReceivedEvent( (DWORD)timestamp, @@ -118,22 +114,16 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R else { conversation->GetPropIdentity(data); - char *cid = ::mir_strdup((const char*)data); + char *cid = ::mir_strdup(data); - /*HANDLE hContact = this->GetChatRoomByID(cid); - if ( !hContact || ::DBGetContactSettingWord(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE) == ID_STATUS_OFFLINE) - { - this->JoinChat(cid); - }*/ - this->SendChatMessage(cid, sid, text); + this->SendChatMessage(cid, sid, ::mir_utf8decodeA(text)); ::mir_free(cid); } - /*const char *msg = (const char*)propValues[2]; - int len = ::strlen(msg) + 8; + /*int len = ::strlen(text) + 8; wchar_t *xml = new wchar_t[len]; - ::mir_sntprintf(xml, len, L"%s", ::mir_utf8decodeW(msg)); + ::mir_sntprintf(xml, len, L"%s", ::mir_utf8decodeW(text)); int bytesProcessed = 0; HXML hXml = xi.parseString(xml, &bytesProcessed, NULL);*/ @@ -147,14 +137,27 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa CMessage::SENDING_STATUS sendingStatus; message->GetPropSendingStatus(sendingStatus); + CMessage::CONSUMPTION_STATUS status; + message->GetPropConsumptionStatus(status); + + // it's old message (hystory sync) + if (status == CMessage::CONSUMED) return; + switch (messageType) { case CMessage::POSTED_EMOTE: case CMessage::POSTED_TEXT: - if (sendingStatus == CMessage::SENT) - this->OnMessageSended(conversation, message); - else if (!sendingStatus) - this->OnMessageReceived(conversation, message); + { + SEString data; + + message->GetPropAuthor(data); + char *sid = ::mir_strdup(data); + + if (::stricmp(sid, this->login) == 0) + this->OnMessageSended(conversation, message); + else + this->OnMessageReceived(conversation, message); + } break; case CMessage::ADDED_CONSUMERS: @@ -196,7 +199,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa case CMessage::RETIRED: { - SEString data; + SEString data; conversation->GetPropIdentity(data); char *cid = ::mir_strdup(data); @@ -205,8 +208,9 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa message->GetPropAuthor(data); char *sid = ::mir_strdup(data); - if (::stricmp(sid, this->login) != 0 && alreadyInChat.contains(sid)) - this->RemoveChatContact(cid, sid); + if (::stricmp(sid, this->login) != 0) + if (alreadyInChat.contains(sid)) + this->RemoveChatContact(cid, sid); } break; case CMessage::RETIRED_OTHERS: diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 54d43d56c9..ac249a8d8b 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -7,8 +7,8 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) this->m_tszUserName = mir_tstrdup(userName); this->m_szModuleName = mir_strdup(protoName); this->m_szProtoName = mir_strdup(protoName); - //_strlwr(m_szProtoName); - //this->m_szProtoName[0] = toupper(m_szProtoName[0]); + ::strlwr(m_szProtoName); + this->m_szProtoName[0] = ::toupper(m_szProtoName[0]); //this->login = NULL; this->password = NULL; @@ -248,7 +248,7 @@ int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char* msg) if (conversation) { Message::Ref message; - conversation->PostText(::mir_utf8encode(msg), message); + conversation->PostText(msg, message); } this->SendBroadcastAsync( diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index f1d5a07e66..8fa24a18a7 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -60,7 +60,8 @@ struct StringList : public LIST bool contains(char* p) { - return indexOf(p) >= 0; + int idx; + return List_GetIndex((SortedList*)this, (char*)p, &idx) == 1; } }; -- cgit v1.2.3