diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-07-04 05:00:03 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-07-04 05:00:03 +0000 |
commit | 2f6035a86d42b71950b2090559d0eb29c593137c (patch) | |
tree | 8d791f18ca8373e470c1cb71c2b3dea648bc2cac | |
parent | 2726a957371d1f40ebf5a83c1434f70311a0f678 (diff) |
Skype: some fix in file transfer and blocked list dialog
git-svn-id: http://svn.miranda-ng.org/main/trunk@5226 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Skype/src/skype_blocked.cpp | 39 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_messages.cpp | 34 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 40 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 14 | ||||
-rw-r--r-- | protocols/Skype/src/skype_transfers.cpp | 60 |
6 files changed, 114 insertions, 75 deletions
diff --git a/protocols/Skype/src/skype_blocked.cpp b/protocols/Skype/src/skype_blocked.cpp index c9e885008c..a60e25b282 100644 --- a/protocols/Skype/src/skype_blocked.cpp +++ b/protocols/Skype/src/skype_blocked.cpp @@ -120,7 +120,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockProc(HWND hwndDlg, UINT msg, WPARAM wPar static WNDPROC oldWndProc = NULL;
-static LRESULT CALLBACK SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+LRESULT CALLBACK CSkypeProto::SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_LBUTTONDOWN)
{
@@ -135,20 +135,31 @@ static LRESULT CALLBACK SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM w lvi.iItem = hi.iItem;
if (ListView_GetItem(hwnd, &lvi))
{
- CContact *contact = (CContact *)lvi.lParam;
+ ContactParam *param = (ContactParam *)lvi.lParam;
- if (contact->SetBlocked(false))
+ if (param->contact->SetBlocked(false))
{
SEString data;
- contact->GetIdentity(data);
+ param->contact->GetIdentity(data);
+ ptrW sid(::mir_utf8decodeW(data));
+
+ HANDLE hContact = param->ppro->GetContactBySid(sid);
+ if (::db_get_b(hContact, param->ppro->m_szModuleName, "IsSkypeOut", 0) > 0)
+ ::db_set_w(hContact, param->ppro->m_szModuleName, "Status", ID_STATUS_ONTHEPHONE);
ListView_DeleteItem(hwnd, lvi.iItem);
- ::SendMessage(
+ int nItem = ::SendMessage(
::GetDlgItem(GetParent(hwnd), IDC_CONTACTS),
CB_ADDSTRING,
0,
- (LPARAM)ptrW(::Utf8DecodeW(data)));
+ (LPARAM)sid);
+
+ ::SendMessage(
+ ::GetDlgItem(GetParent(hwnd), IDC_CONTACTS),
+ CB_SETITEMDATA,
+ nItem,
+ (LPARAM)hContact);
}
}
}
@@ -220,12 +231,14 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WP {
auto contact = contacts[i];
+ ptrW sid(::mir_utf8decodeW(contact->GetSid()));
+
LVITEM lvi = {0};
lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
lvi.iItem = (int)i;
lvi.iImage = 0;
- lvi.lParam = (LPARAM)contact.fetch();
- lvi.pszText = ptrW(::mir_utf8decodeW(contact->GetSid()));
+ lvi.lParam = (LPARAM)new ContactParam(contact, ppro);
+ lvi.pszText = sid;
int iRow = ListView_InsertItem(hwndList, &lvi);
if (iRow != -1)
@@ -300,7 +313,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WP contact->SetBlocked(true, param.abuse);
if (::db_get_b(hContact, ppro->m_szModuleName, "IsSkypeOut", 0) > 0)
- ::db_set_w(hContact, ppro->m_szModuleName, "Status", ID_STATUS_ONTHEPHONE);
+ ::db_set_w(hContact, ppro->m_szModuleName, "Status", ID_STATUS_OFFLINE);
if (param.remove)
{
@@ -315,7 +328,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WP lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM;
lvi.iItem = (int)i;
lvi.iImage = 0;
- lvi.lParam = (LPARAM)contact.fetch();
+ lvi.lParam = (LPARAM)new ContactParam(contact, ppro);
lvi.pszText = sid;
int iRow = ListView_InsertItem(::GetDlgItem(hwndDlg, IDC_LIST), &lvi);
@@ -344,7 +357,7 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WP switch(LOWORD(wParam))
{
- case IDC_BM_LIST:
+ case IDC_LIST:
if (((LPNMHDR)lParam)->code == NM_DBLCLK)
{
HWND hwndList = ::GetDlgItem(hwndDlg, IDC_BM_LIST);
@@ -359,9 +372,9 @@ INT_PTR CALLBACK CSkypeProto::SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WP SEString data;
if (lvi.iGroupId == 1)
{
- CContact *contact = (CContact *)lvi.lParam;
+ ContactParam *param = (ContactParam *)lvi.lParam;
- contact->GetIdentity(data);
+ param->contact->GetIdentity(data);
ptrW sid(::mir_utf8decodeW(data));
::CallService(MS_MSG_SENDMESSAGE, (WPARAM)ppro->GetContactBySid(sid), 0);
}
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 176fe529f2..b6a3183e9c 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -194,7 +194,7 @@ HANDLE CSkypeProto::GetContactFromAuthEvent(HANDLE hEvent) return ::DbGetAuthEventContact(&dbei);
}
-HANDLE CSkypeProto::AddContact(CContact::Ref contact)
+HANDLE CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary)
{
ptrW sid(::mir_utf8decodeW(contact->GetSid()));
diff --git a/protocols/Skype/src/skype_messages.cpp b/protocols/Skype/src/skype_messages.cpp index 5b5bcad1bf..97a830b0b5 100644 --- a/protocols/Skype/src/skype_messages.cpp +++ b/protocols/Skype/src/skype_messages.cpp @@ -37,24 +37,23 @@ void CSkypeProto::OnMessageReceived(const ConversationRef &conversation, const M {
SEString data;
- CMessage::TYPE messageType;
+ Message::TYPE messageType;
message->GetPropType(messageType);
uint timestamp;
message->GetPropTimestamp(timestamp);
- CMessage::CONSUMPTION_STATUS status;
+ Message::CONSUMPTION_STATUS status;
message->GetPropConsumptionStatus(status);
message->GetPropBodyXml(data);
char *text = CSkypeProto::RemoveHtml(data);
+ ContactRef author;
message->GetPropAuthor(data);
-
- CContact::Ref author;
this->GetContact(data, author);
- HANDLE hContact = this->AddContact(author);
+ HANDLE hContact = this->AddContact(author, true);
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
SEBinary guid;
@@ -102,10 +101,9 @@ void CSkypeProto::OnMessageSent(const ConversationRef &conversation, const Messa conversation->GetParticipants(participants, CConversation::OTHER_CONSUMERS);
participants[0]->GetPropIdentity(data);
- CContact::Ref receiver;
- this->GetContact(data, receiver);
+ ptrW sid(::mir_utf8decodeW(data));
- HANDLE hContact = this->AddContact(receiver);
+ HANDLE hContact = this->GetContactBySid(sid);
this->SendBroadcast(
hContact,
ACKTYPE_MESSAGE,
@@ -215,11 +213,11 @@ void CSkypeProto::SyncMessageHystory(const ConversationRef &conversation, const {
conversation->SetConsumedHorizon(timestamp);
MessageRefs oldMessages, newMessages;
- conversation->GetLastMessages(oldMessages, newMessages, timestamp); - for (size_t i = 0; i < oldMessages.size(); i++) - this->OnMessageEvent(conversation, oldMessages[i]); - for (size_t i = 0; i < newMessages.size(); i++) - this->OnMessageEvent(conversation, newMessages[i]); + conversation->GetLastMessages(oldMessages, newMessages, timestamp);
+ for (size_t i = 0; i < oldMessages.size(); i++)
+ this->OnMessageEvent(conversation, oldMessages[i]);
+ for (size_t i = 0; i < newMessages.size(); i++)
+ this->OnMessageEvent(conversation, newMessages[i]);
conversation->SetConsumedHorizon(time(NULL));
}
}
@@ -242,9 +240,9 @@ void CSkypeProto::SyncHistoryCommand(HANDLE hContact, time_t timestamp) if (conversation)
{
- this->SyncMessageHystory(conversation, timestamp); - CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); - } + this->SyncMessageHystory(conversation, timestamp);
+ CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact);
+ }
}
}
@@ -309,8 +307,8 @@ int CSkypeProto::SyncAllTimeHistoryCommand(WPARAM wParam, LPARAM lParam) {
uint timestamp;
conversation->GetPropCreationTimestamp(timestamp);
- this->SyncMessageHystory(conversation, timestamp); - CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); + this->SyncMessageHystory(conversation, timestamp);
+ CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact);
}
}
return 0;
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index e8eadfd162..b5b60e35f7 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -155,13 +155,18 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const 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);
+ MessageRef msgRef(oid);
+ TransferRefs transfers;
+ msgRef->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
+ {
+ transfers[i]->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;
+ if ( !transfers[i]->Accept((char *)ptrA(::mir_utf8encodeW(fullPath)), success) || !success)
+ return 0;
+ }
return hTransfer;
}
@@ -170,10 +175,13 @@ int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) {
uint oid = (uint)hTransfer;
- TransferRef transfer(oid);
-
- if (!transfer->Cancel())
- return 0;
+ SEString data;
+ MessageRef msgRef(oid);
+ TransferRefs transfers;
+ msgRef->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
+ if ( !transfers[i]->Cancel())
+ return 0;
this->Log(L"Incoming file transfer is cancelled");
@@ -184,11 +192,15 @@ int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const T {
uint oid = (uint)hTransfer;
- TransferRef transfer(oid);
- if (!transfer->Cancel())
- return 0;
+ SEString data;
+ MessageRef msgRef(oid);
+ TransferRefs transfers;
+ msgRef->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
+ if ( !transfers[i]->Cancel())
+ return 0;
- this->Log(L"Incoming file transfer is denied");
+ this->Log(L"Incoming file transfer is denied");
return 1;
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index ccaa983a8a..e640686f31 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -19,6 +19,16 @@ struct ReadMessageParam CMessage::TYPE msgType;
};
+struct ContactParam
+{
+ ContactRef contact;
+ CSkypeProto *ppro;
+
+ ContactParam(const ContactRef &contact, CSkypeProto *ppro) : contact(contact), ppro(ppro)
+ {
+ }
+};
+
struct BlockParam
{
HANDLE hContact;
@@ -361,7 +371,7 @@ protected: bool IsProtoContact(HANDLE hContact);
HANDLE GetContactBySid(const wchar_t* sid);
HANDLE GetContactFromAuthEvent(HANDLE hEvent);
- HANDLE AddContact(CContact::Ref contact);
+ HANDLE AddContact(CContact::Ref contact, bool isTemporary = false);
bool IsContactOnline(HANDLE hContact);
void SetAllContactStatus(int status);
@@ -375,7 +385,6 @@ protected: void __cdecl SearchByEmailAsync(void*);
// profile
-
void UpdateProfileAvatar(SEObject *obj, HANDLE hContact = NULL);
void UpdateProfileAboutText(SEObject *obj, HANDLE hContact = NULL);
void UpdateProfileBirthday(SEObject *obj, HANDLE hContact = NULL);
@@ -484,6 +493,7 @@ protected: static INT_PTR CALLBACK SkypeBlockProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK SkypeBlockedOptionsProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+ static LRESULT CALLBACK SkypeBlockedOptionsSubProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
// database
bool IsMessageInDB(HANDLE hContact, DWORD timestamp, SEBinary &guid, int flag = 0);
diff --git a/protocols/Skype/src/skype_transfers.cpp b/protocols/Skype/src/skype_transfers.cpp index b3edeeba1a..f99d439ffa 100644 --- a/protocols/Skype/src/skype_transfers.cpp +++ b/protocols/Skype/src/skype_transfers.cpp @@ -21,11 +21,11 @@ void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) {
case Transfer::P_STATUS:
{
- SEBinary guid;
- transfer->GetPropChatmsgGuid(guid);
-
Transfer::FAILUREREASON reason;
+ SEBinary guid;
+ transfer->GetPropChatmsgGuid(guid);
+
MessageRef msgRef;
this->GetMessageByGuid(guid, msgRef);
@@ -39,10 +39,6 @@ void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) transfer->GetPropStatus(status);
switch(status)
{
- /*case CTransfer::NEW:
- break;*/
- /*case CTransfer::WAITING_FOR_ACCEPT:
- break;*/
case Transfer::CONNECTING:
this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)oid, 0);
break;
@@ -110,15 +106,21 @@ void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const MessageRef &message)
{
+ SEString data;
+ bool isRecvFiles = false;
Transfer::TYPE transferType;
Transfer::STATUS transferStatus;
TransferRefs transfers;
message->GetTransfers(transfers);
+ wchar_t **files = new wchar_t*[transfers.size()];
for (size_t i = 0; i < transfers.size(); i++)
{
auto transfer = transfers[i];
+ transfer->GetPropFilename(data);
+ files[i] = ::mir_utf8decodeW(data);
+
// For incomings, we need to check for transfer status, just to be sure.
// In some cases, a transfer can appear with STATUS == PLACEHOLDER
// As such transfers cannot be accepted, we will need to just store
@@ -130,28 +132,10 @@ void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const Message transfer->GetPropType(transferType);
if (transferType == Transfer::INCOMING)
{
+ isRecvFiles = true;
+
this->transferList.append(transfer);
transfer.fetch();
-
- uint timestamp;
- message->GetPropTimestamp(timestamp);
-
- SEString data;
- transfer->GetPropPartnerHandle(data);
- HANDLE hContact = this->GetContactBySid(ptrW(::mir_utf8decodeW(data)));
-
- transfer->GetPropFilename(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 = &fileName;
- pre.lParam = (LPARAM)transfer->getOID();
- ::ProtoChainRecvFile(hContact, &pre);
- ::mir_free(fileName);
}
else if (transferType == Transfer::PLACEHOLDER)
{
@@ -160,4 +144,26 @@ void CSkypeProto::OnFileEvent(const ConversationRef &conversation, const Message }
}
}
+ files[transfers.size()] = NULL;
+
+ if (isRecvFiles)
+ {
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ ContactRef author;
+ message->GetPropAuthor(data);
+ this->GetContact(data, author);
+
+ HANDLE hContact = this->AddContact(author, true);
+
+ PROTORECVFILET pre = {0};
+ pre.flags = PREF_TCHAR;
+ pre.fileCount = transfers.size();
+ pre.timestamp = timestamp;
+ pre.tszDescription = L"";
+ pre.ptszFiles = files;
+ pre.lParam = (LPARAM)message->getOID();
+ ::ProtoChainRecvFile(hContact, &pre);
+ }
}
\ No newline at end of file |