From 8d3522f82f331954a495275a0e23402906d9bb9a Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 30 Jun 2013 19:46:37 +0000 Subject: Skype: fixed #394 git-svn-id: http://svn.miranda-ng.org/main/trunk@5197 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/res/bookmark.ico | Bin 5430 -> 0 bytes protocols/Skype/src/skype_events.cpp | 4 +- protocols/Skype/src/skype_icons.cpp | 12 +++- protocols/Skype/src/skype_menus.cpp | 22 ++++---- protocols/Skype/src/skype_proto.cpp | 96 ++++++++++++++++++-------------- protocols/Skype/src/skype_proto.h | 5 +- protocols/Skype/src/skype_transfers.cpp | 63 +++++++++++++-------- 7 files changed, 122 insertions(+), 80 deletions(-) delete mode 100644 protocols/Skype/res/bookmark.ico (limited to 'protocols') diff --git a/protocols/Skype/res/bookmark.ico b/protocols/Skype/res/bookmark.ico deleted file mode 100644 index 63052a4a45..0000000000 Binary files a/protocols/Skype/res/bookmark.ico and /dev/null differ diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index d61e5d2dcf..542ec235a0 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -25,14 +25,14 @@ int CSkypeProto::OnProtoModulesLoaded(WPARAM, LPARAM) bbd.bbbFlags = BBBF_ISCHATBUTTON | BBBF_ISRSIDEBUTTON; bbd.ptszTooltip = ::TranslateT("Invite contacts to conference"); - bbd.hIcon = CSkypeProto::GetIconHandle("addContacts"); + bbd.hIcon = CSkypeProto::GetSkinIconHandle("addContacts"); bbd.dwButtonID = BBB_ID_CONF_INVITE; bbd.dwDefPos = 100 + bbd.dwButtonID; ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); bbd.bbbFlags = BBBF_ISIMBUTTON | BBBF_ISRSIDEBUTTON; bbd.ptszTooltip = ::TranslateT("Spawn conference"); - bbd.hIcon = CSkypeProto::GetIconHandle("conference"); + bbd.hIcon = CSkypeProto::GetSkinIconHandle("conference"); bbd.dwButtonID = BBB_ID_CONF_SPAWN; bbd.dwDefPos = 100 + bbd.dwButtonID; ::CallService(MS_BB_ADDBUTTON, 0, (LPARAM)&bbd); diff --git a/protocols/Skype/src/skype_icons.cpp b/protocols/Skype/src/skype_icons.cpp index 03a66d61ce..a04e6acbc0 100644 --- a/protocols/Skype/src/skype_icons.cpp +++ b/protocols/Skype/src/skype_icons.cpp @@ -50,10 +50,18 @@ HANDLE CSkypeProto::GetIconHandle(const char* name) return 0; } +HANDLE CSkypeProto::GetSkinIconHandle(const char* name) +{ + char iconName[100]; + ::mir_snprintf(iconName, SIZEOF(iconName), "%s_%s", MODULE, name); + HANDLE hIcon = ::Skin_GetIconHandle(iconName); + if ( !hIcon) + hIcon = CSkypeProto::GetIconHandle(name); + return hIcon; +} + void CSkypeProto::UninitIcons() { for (size_t i = 0; i < SIZEOF(CSkypeProto::IconList); i++) - { ::Skin_RemoveIcon(CSkypeProto::IconList[i].Name); - } } \ No newline at end of file diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index 527e90ac76..20b60f1546 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -28,18 +28,18 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) bool grantNeed = ::db_get_b(hContact, this->m_szModuleName, "Grant", 0) > 0; bool ignored = ::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) > 0; - Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); - Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); - Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed)); - Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_BLOCK], ctrlPressed); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || (!grantNeed && !authNeed)); + ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_BLOCK], ctrlPressed); CLISTMENUITEM clmi = { sizeof(clmi) }; clmi.cbSize = sizeof(CLISTMENUITEM); clmi.flags = CMIM_FLAGS; //::CallService(MS_IGNORE_ISIGNORED, wParam, IGNOREEVENT_ALL); if (::db_get_b(hContact, this->m_szModuleName, "Ignore", 0) == 1) - clmi.flags |= CMIF_CHECKED; - + //clmi.flags |= CMIF_CHECKED; + clmi.icolibItem = CSkypeProto::GetSkinIconHandle("contact"); ::CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)CSkypeProto::contactMenuItems[CMI_IGNORE], (LPARAM)&clmi); } @@ -142,7 +142,7 @@ void CSkypeProto::InitMenus() mi.pszService = MODULE"/Ignore"; mi.ptszName = LPGENT("Ignore"); mi.position = -200001000 + CMI_IGNORE; - mi.icolibItem = NULL;//CSkypeProto::GetIconHandle("ignore"); + mi.icolibItem = CSkypeProto::GetSkinIconHandle("ignore"); CSkypeProto::contactMenuItems[CMI_IGNORE] = ::Menu_AddContactMenuItem(&mi); ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::IgnoreCommand>); @@ -151,7 +151,7 @@ void CSkypeProto::InitMenus() mi.ptszName = LPGENT("Block"); //mi.flags |= CMIF_HIDDEN; mi.position = -200001000 + CMI_BLOCK; - mi.icolibItem = CSkypeProto::GetIconHandle("block"); + mi.icolibItem = CSkypeProto::GetSkinIconHandle("block"); CSkypeProto::contactMenuItems[CMI_BLOCK] = ::Menu_AddContactMenuItem(&mi); ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockCommand>); } @@ -176,7 +176,7 @@ void CSkypeProto::OnInitStatusMenu() mi.position = -1999901006; mi.hParentMenu = HGENMENU_ROOT; mi.flags = CMIF_ROOTPOPUP | CMIF_TCHAR | CMIF_KEEPUNTRANSLATED; - mi.icolibItem = CSkypeProto::GetIconHandle("main"); + mi.icolibItem = CSkypeProto::GetSkinIconHandle("main"); hSkypeRoot = m_hMenuRoot = ::Menu_AddProtoMenuItem(&mi); } else @@ -194,7 +194,7 @@ void CSkypeProto::OnInitStatusMenu() this->CreateServiceObj(tDest, &CSkypeProto::CreateChatRoomCommand); mi.ptszName = LPGENT("Create conference"); mi.position = 200000 + SMI_CHAT_CREATE; - mi.icolibItem = CSkypeProto::GetIconHandle("conference"); + mi.icolibItem = CSkypeProto::GetSkinIconHandle("conference"); ::Menu_AddProtoMenuItem(&mi); // Invite Command @@ -202,6 +202,6 @@ void CSkypeProto::OnInitStatusMenu() this->CreateServiceObj(tDest, &CSkypeProto::OpenIgnoreListCommand); mi.ptszName = LPGENT("Ignore list"); mi.position = 200000 + SMI_IGNORE_LIST; - mi.icolibItem = CSkypeProto::GetIconHandle("ignore"); + mi.icolibItem = CSkypeProto::GetSkinIconHandle("ignore"); ::Menu_AddProtoMenuItem(&mi); } \ No newline at end of file diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 394adc997d..9a52404047 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -22,12 +22,12 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : dbEventType.eventType = SKYPE_DB_EVENT_TYPE_CONTACTS; dbEventType.descr = "Skype contacts"; - dbEventType.eventIcon = CSkypeProto::GetIconHandle("sendContacts"); + dbEventType.eventIcon = CSkypeProto::GetSkinIconHandle("sendContacts"); ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); dbEventType.eventType = SKYPE_DB_EVENT_TYPE_CALL; dbEventType.descr = "Skype call"; - dbEventType.eventIcon = CSkypeProto::GetIconHandle("call"); + dbEventType.eventIcon = CSkypeProto::GetSkinIconHandle("call"); ::CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); this->InitInstanceServiceList(); @@ -149,25 +149,19 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const { uint oid = (uint)hTransfer; - MessageRef message(oid); - this->Log(L"Incoming file transfer is accepted"); - CTransfer::Refs transfers; - message->GetTransfers(transfers); - for (uint i = 0; i < transfers.size(); i++) - { - bool success; - wchar_t fullPath[MAX_PATH] = {0}; - - SEString data; - transfers[i]->GetPropFilename(data); - ptrW name(::mir_utf8decodeW(data)); - ::mir_sntprintf(fullPath, MAX_PATH, L"%s%s", szPath, name); - if (!transfers[i]->Accept((char *)ptrA(::mir_utf8encodeW(fullPath)), success) || !success) - { - return 0; - } - } + + bool success; + wchar_t fullPath[MAX_PATH] = {0}; + + SEString data; + TransferRef transfer(oid); + transfer->GetPropFilename(data); + ptrW name(::mir_utf8decodeW(data)); + ::mir_sntprintf(fullPath, MAX_PATH, L"%s%s", szPath, name); + + if (!transfer->Accept((char *)ptrA(::mir_utf8encodeW(fullPath)), success) || !success) + return 0; return hTransfer; } @@ -176,18 +170,12 @@ int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) { uint oid = (uint)hTransfer; - MessageRef message(oid); + TransferRef transfer(oid); + + if (!transfer->Cancel()) + return 0; this->Log(L"Incoming file transfer is cancelled"); - CTransfer::Refs transfers; - message->GetTransfers(transfers); - for (uint i = 0; i < transfers.size(); i++) - { - if (!transfers[i]->Cancel()) - { - return 0; - } - } return 1; } @@ -195,24 +183,50 @@ int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const TCHAR* szReason ) { uint oid = (uint)hTransfer; + + TransferRef transfer(oid); + if (!transfer->Cancel()) + return 0; - MessageRef message(oid); - this->Log(L"Incoming file transfer is denied"); - CTransfer::Refs transfers; - message->GetTransfers(transfers); - for (uint i = 0; i < transfers.size(); i++) - { - if (!transfers[i]->Cancel()) - { - return 0; - } - } + this->Log(L"Incoming file transfer is denied"); return 1; } int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename ) { + if ( !this->IsOnline()) + return 1; + + switch (*action) + { + case FILERESUME_SKIP: + /*if (ft->p2p_appID != 0) + p2p_sendStatus(ft, 603); + else + msnftp_sendAcceptReject (ft, false);*/ + break; + + case FILERESUME_RENAME: + //replaceStrT(ft->std.tszCurrentFile, *szFilename); + break; + + default: + /*bool fcrt = ft->create() != -1; + if (ft->p2p_appID != 0) + { + if (fcrt) + p2p_sendFeedStart(ft); + + p2p_sendStatus(ft, fcrt ? 200 : 603); + } + else + msnftp_sendAcceptReject (ft, fcrt);*/ + + //ProtoBroadcastAck(ft->std.hContact, ACKTYPE_FILE, ACKRESULT_INITIALISING, ft, 0); + break; + } + return 0; } diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 80e350a9ec..fe310eb913 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -288,8 +288,10 @@ protected: void OnContactsReceived(const ConversationRef &conversation, const MessageRef &message); // transfer + static wchar_t *TransferFailureReasons[]; + void OnFileEvent(const ConversationRef &conversation, const MessageRef &message); - void OnTransferChanged(CTransfer::Ref transfer, int prop); + void OnTransferChanged(const TransferRef &transfer, int prop); // chat void InitChatModule(); @@ -438,6 +440,7 @@ protected: // icons static _tag_iconList IconList[]; static HANDLE GetIconHandle(const char *name); + static HANDLE GetSkinIconHandle(const char *name); // menus HGENMENU m_hMenuRoot; diff --git a/protocols/Skype/src/skype_transfers.cpp b/protocols/Skype/src/skype_transfers.cpp index 4bb18e432a..2866f34e63 100644 --- a/protocols/Skype/src/skype_transfers.cpp +++ b/protocols/Skype/src/skype_transfers.cpp @@ -1,6 +1,21 @@ #include "skype.h" -void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) +wchar_t *CSkypeProto::TransferFailureReasons[] = +{ + LPGENW("") /* --- */, + LPGENW("SENDER_NOT_AUTHORISED") /* SENDER_NOT_AUTHORISED */, + LPGENW("REMOTELY_CANCELLED") /* REMOTELY_CANCELLED */, + LPGENW("FAILED_READ") /* FAILED_READ */, + LPGENW("FAILED_REMOTE_READ") /* FAILED_REMOTE_READ */, + LPGENW("FAILED_WRITE") /* FAILED_WRITE */, + LPGENW("FAILED_REMOTE_WRITE") /* FAILED_REMOTE_WRITE */, + LPGENW("REMOTE_DOES_NOT_SUPPORT_FT") /* REMOTE_DOES_NOT_SUPPORT_FT */, + LPGENW("REMOTE_OFFLINE_FOR_TOO_LONG") /* REMOTE_OFFLINE_FOR_TOO_LONG */, + LPGENW("TOO_MANY_PARALLEL") /* TOO_MANY_PARALLEL */, + LPGENW("PLACEHOLDER_TIMEOUT") /* PLACEHOLDER_TIMEOUT */ +}; + +void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) { switch (prop) { @@ -9,14 +24,13 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) SEBinary guid; transfer->GetPropChatmsgGuid(guid); - CMessage::Ref message; - this->GetMessageByGuid(guid, message); + Transfer::FAILUREREASON reason; - uint oid = message->getOID(); + uint oid = transfer->getOID(); SEString data; transfer->GetPropPartnerHandle(data); - HANDLE hContact = this->GetContactBySid(mir_ptr(::mir_utf8decodeW(data))); + HANDLE hContact = this->GetContactBySid(ptrW(::mir_utf8decodeW(data))); Transfer::STATUS status; transfer->GetPropStatus(status); @@ -33,8 +47,9 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) case CTransfer::TRANSFERRING_OVER_RELAY: this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)oid, 0); break; - case CTransfer::FAILED: - this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)oid, 0); + case CTransfer::FAILED: + transfer->GetPropFailurereason(reason); + this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)oid, (LPARAM)CSkypeProto::TransferFailureReasons[reason]); this->transferList.remove_val(transfer); break; case CTransfer::COMPLETED: @@ -43,7 +58,8 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) break; case CTransfer::CANCELLED: case CTransfer::CANCELLED_BY_REMOTE: - this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)oid, 0); + transfer->GetPropFailurereason(reason); + this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)oid, (LPARAM)CSkypeProto::TransferFailureReasons[reason]); this->transferList.remove_val(transfer); break; } @@ -57,10 +73,7 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) SEBinary guid; transfer->GetPropChatmsgGuid(guid); - CMessage::Ref message; - this->GetMessageByGuid(guid, message); - - uint oid = message->getOID(); + uint oid = transfer->getOID(); PROTOFILETRANSFERSTATUS pfts = {0}; pfts.cbSize = sizeof(pfts); @@ -69,7 +82,7 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) pfts.currentFileNumber = 0; transfer->GetPropPartnerHandle(data); - HANDLE hContact = this->GetContactBySid(mir_ptr(::mir_utf8decodeW(data))); + HANDLE hContact = this->GetContactBySid(ptrW(::mir_utf8decodeW(data))); pfts.hContact = hContact; transfer->GetPropFilename(data); @@ -91,14 +104,12 @@ void CSkypeProto::OnTransferChanged(CTransfer::Ref transfer, int prop) void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const MessageRef &message) { - CTransfer::Refs transfers; - message->GetTransfers(transfers); - //Sid::fetch(transferList); - Transfer::TYPE transferType; Transfer::STATUS transferStatus; - for (uint i = 0; i < transfers.size(); i++) + TransferRefs transfers; + message->GetTransfers(transfers); + for (size_t i = 0; i < transfers.size(); i++) { auto transfer = transfers[i]; @@ -113,8 +124,8 @@ void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const Message transfer->GetPropType(transferType); if (transferType == Transfer::INCOMING) { - transfer.fetch(); this->transferList.append(transfer); + transfer.fetch(); uint timestamp; message->GetPropTimestamp(timestamp); @@ -124,16 +135,22 @@ void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const Message HANDLE hContact = this->GetContactBySid(ptrW(::mir_utf8decodeW(data))); transfer->GetPropFilename(data); - wchar_t *path = ::mir_utf8decodeW(data); + wchar_t *fileName = ::mir_utf8decodeW(data); PROTORECVFILET pre = {0}; pre.flags = PREF_TCHAR; pre.fileCount = 1; pre.timestamp = timestamp; - pre.tszDescription = L" "; - pre.ptszFiles = &path; - pre.lParam = (LPARAM)message->getOID(); + pre.tszDescription = L""; + pre.ptszFiles = &fileName; + pre.lParam = (LPARAM)transfer->getOID(); ::ProtoChainRecvFile(hContact, &pre); + ::mir_free(fileName); + } + else if (transferType == Transfer::PLACEHOLDER) + { + this->transferList.append(transfer); + transfer.fetch(); } } } -- cgit v1.2.3