diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-04-21 09:51:58 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-04-21 09:51:58 +0000 |
commit | 49581e73a1f02bd48d2d2c1861efd77a4bb66059 (patch) | |
tree | 4e3cb02687ab1a1ea4038d96007525a2b379eb27 | |
parent | 23291e3639741d6539f39695036bd140429ddccc (diff) |
reworked file transfers
fixed auth requests
git-svn-id: http://svn.miranda-ng.org/main/trunk@4498 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Skype/Skype_10.vcxproj | 1 | ||||
-rw-r--r-- | protocols/Skype/Skype_10.vcxproj.filters | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skype.h | 5 | ||||
-rw-r--r-- | protocols/Skype/src/skype_account.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_database.cpp | 107 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 124 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 93 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 39 |
9 files changed, 180 insertions, 203 deletions
diff --git a/protocols/Skype/Skype_10.vcxproj b/protocols/Skype/Skype_10.vcxproj index 476c7db25f..02e29c13c8 100644 --- a/protocols/Skype/Skype_10.vcxproj +++ b/protocols/Skype/Skype_10.vcxproj @@ -207,7 +207,6 @@ <ClCompile Include="src\skype_services.cpp" />
<ClCompile Include="src\skype_settings.cpp" />
<ClCompile Include="src\skype_subclassing.cpp" />
- <ClCompile Include="src\skype_transfer.cpp" />
<ClCompile Include="src\skype_utils.cpp" />
</ItemGroup>
<ItemGroup>
diff --git a/protocols/Skype/Skype_10.vcxproj.filters b/protocols/Skype/Skype_10.vcxproj.filters index 08a34ba89e..cb48bf40f0 100644 --- a/protocols/Skype/Skype_10.vcxproj.filters +++ b/protocols/Skype/Skype_10.vcxproj.filters @@ -78,9 +78,6 @@ <ClCompile Include="src\base64\base64.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\skype_transfer.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index f489a78803..8615ebf025 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -79,4 +79,7 @@ #define CMITEMS_COUNT 3
-extern HINSTANCE g_hInstance;
\ No newline at end of file +extern HINSTANCE g_hInstance;
+
+
+struct CSkypeProto;
\ No newline at end of file diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index e7e9829de4..d5a8db7f13 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -97,6 +97,8 @@ void __cdecl CSkypeProto::SignInAsync(void*) this->LoadChatList(this);
this->SetStatus(this->m_iDesiredStatus);
+
+ fetch(this->transferList);
}
bool CSkypeProto::PrepareLogin()
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index c29580d1bc..8bb2149163 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -329,6 +329,15 @@ void __cdecl CSkypeProto::LoadAuthWaitList(void*) }
}
+bool CSkypeProto::IsContactOnline(HANDLE hContact)
+{
+ return ::db_get_w(
+ hContact,
+ this->m_szModuleName,
+ SKYPE_SETTINGS_STATUS,
+ ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE;
+}
+
void CSkypeProto::SetAllContactStatus(int status)
{
HANDLE hContact = ::db_find_first();
diff --git a/protocols/Skype/src/skype_database.cpp b/protocols/Skype/src/skype_database.cpp index 6ce36fbaa8..c6d2778aa9 100644 --- a/protocols/Skype/src/skype_database.cpp +++ b/protocols/Skype/src/skype_database.cpp @@ -1,12 +1,48 @@ #include "skype_proto.h"
+bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag)
+{
+ bool result = false;
+
+ HANDLE hDbEvent = ::db_event_last(hContact);
+ while (hDbEvent)
+ {
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.cbBlob = ::db_event_getBlobSize(hDbEvent);
+ dbei.pBlob = (PBYTE)::mir_alloc(dbei.cbBlob);
+ ::db_event_get(hDbEvent, &dbei);
+
+ if (dbei.timestamp < timestamp)
+ {
+ ::mir_free(dbei.pBlob);
+ break;
+ }
+
+ int sendFlag = dbei.flags & DBEF_SENT;
+ if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
+ {
+ if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
+ {
+ ::mir_free(dbei.pBlob);
+ result = true;
+ break;
+ }
+ }
+
+ ::mir_free(dbei.pBlob);
+ hDbEvent = ::db_event_prev(hDbEvent);
+ }
+
+ return result;
+}
+
HANDLE CSkypeProto::AddDataBaseEvent(HANDLE hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob)
{
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
dbei.szModule = this->m_szModuleName;
dbei.timestamp = timestamp;
- dbei.eventType = EVENTTYPE_MESSAGE;
+ dbei.eventType = type;
dbei.cbBlob = cbBlob;
dbei.pBlob = pBlob;
dbei.flags = flags;
@@ -18,28 +54,23 @@ void CSkypeProto::RaiseAuthRequestEvent( DWORD timestamp,
CContact::Ref contact)
{
- char *sid = ::mir_utf8decodeA(contact->GetSid());
- char *nick = ::mir_utf8decodeA(contact->GetNick());
+ char *sid = ::mir_strdup(contact->GetSid());
+ char *nick = ::mir_strdup(contact->GetNick());
SEString data;
contact->GetPropReceivedAuthrequest(data);
- char* reason = ::mir_utf8decodeA(data);
+ char* reason = ::mir_strdup(data);
SEString last;
contact->GetFullname(data, last);
- char* firstName = ::mir_utf8decodeA(data);
- char* lastName = ::mir_utf8decodeA(last);
-
- PROTORECVEVENT pre = {0};
-
- CCSDATA ccs = {0};
- ccs.szProtoService = PSR_AUTH;
- ccs.hContact = this->AddContact(contact);
- ccs.wParam = 0;
- ccs.lParam = (LPARAM)⪯
- pre.timestamp = timestamp;
- pre.lParam = (DWORD)
+ char* firstName = ::mir_strdup(data);
+ char* lastName = ::mir_strdup(last);
+
+ HANDLE hContact = this->AddContact(contact);
+
+ /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/
+ DWORD cbBlob = (DWORD)
(sizeof(DWORD) * 2) +
::strlen(nick) +
::strlen(firstName) +
@@ -48,54 +79,18 @@ void CSkypeProto::RaiseAuthRequestEvent( ::strlen(reason) +
5;
- /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/
- char *pCurBlob = pre.szMessage = (char*)::mir_alloc(pre.lParam);
+ PBYTE pBlob, pCurBlob;
+ pCurBlob = pBlob = (PBYTE)::mir_alloc(cbBlob);
*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
- *((PDWORD)pCurBlob) = (DWORD)ccs.hContact; pCurBlob += sizeof(DWORD);
+ *((PDWORD)pCurBlob) = (DWORD)hContact; pCurBlob += sizeof(DWORD);
::strcpy((char*)pCurBlob, nick); pCurBlob += ::strlen(nick) + 1;
::strcpy((char*)pCurBlob, firstName); pCurBlob += ::strlen(firstName) + 1;
::strcpy((char*)pCurBlob, lastName); pCurBlob += ::strlen(lastName) + 1;
::strcpy((char*)pCurBlob, sid); pCurBlob += ::strlen(sid) + 1;
::strcpy((char*)pCurBlob, reason);
- ::CallService(MS_PROTO_CHAINRECV, 0, (LPARAM)&ccs);
-}
-
-bool CSkypeProto::IsMessageInDB(HANDLE hContact, DWORD timestamp, const char* guid, int flag)
-{
- bool result = false;
-
- HANDLE hDbEvent = ::db_event_last(hContact);
- while (hDbEvent)
- {
- DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbBlob = ::db_event_getBlobSize(hDbEvent);
- dbei.pBlob = (PBYTE)::mir_alloc(dbei.cbBlob);
- ::db_event_get(hDbEvent, &dbei);
-
- if (dbei.timestamp < timestamp)
- {
- ::mir_free(dbei.pBlob);
- break;
- }
-
- int sendFlag = dbei.flags & DBEF_SENT;
- if (dbei.eventType == EVENTTYPE_MESSAGE && sendFlag == flag)
- {
- if (::memcmp(&dbei.pBlob[dbei.cbBlob - 32], guid, 32) == 0)
- {
- ::mir_free(dbei.pBlob);
- result = true;
- break;
- }
- }
-
- ::mir_free(dbei.pBlob);
- hDbEvent = ::db_event_prev(hDbEvent);
- }
-
- return result;
+ this->AddDataBaseEvent(hContact, EVENTTYPE_AUTHREQUEST, time(NULL), PREF_UTF, cbBlob, pBlob);
}
void CSkypeProto::RaiseMessageReceivedEvent(
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index 55aba660ca..7e9e37e72a 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -183,19 +183,23 @@ void CSkypeProto::OnMessageReceived(CConversation::Ref conversation, CMessage::R void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer)
{
+ // todo: add progress changing
if (prop == Transfer::P_STATUS)
{
- Transfer::STATUS status;
- transfer->GetPropStatus(status);
+ SEBinary guid;
+ transfer->GetPropChatmsgGuid(guid);
- auto ft = this->FindFileTransfer(transfer);
+ CMessage::Ref message;
+ this->skype->GetMessageByGuid(guid, message);
+
+ uint oid = message->getOID();
SEString data;
transfer->GetPropPartnerHandle(data);
- mir_ptr<wchar_t> sid(::mir_utf8decodeW(data));
-
- HANDLE hContact = this->GetContactBySid(sid);
+ HANDLE hContact = this->GetContactBySid(mir_ptr<wchar_t>(::mir_utf8decodeW(data)));
+ Transfer::STATUS status;
+ transfer->GetPropStatus(status);
switch(status)
{
/*case CTransfer::NEW:
@@ -203,26 +207,29 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) /*case CTransfer::WAITING_FOR_ACCEPT:
break;*/
case CTransfer::CONNECTING:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)ft, 0);
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, (HANDLE)oid, 0);
break;
- case CTransfer::TRANSFERRING:
+ /*case CTransfer::TRANSFERRING:
case CTransfer::TRANSFERRING_OVER_RELAY:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)ft, 0);
- break;
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_CONNECTED, (HANDLE)oid, 0);
+ break;*/
case CTransfer::FAILED:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)ft, 0);
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)oid, 0);
+ this->transferList.remove_val(transfer);
break;
case CTransfer::COMPLETED:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)ft, 0);
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)oid, 0);
+ this->transferList.remove_val(transfer);
break;
case CTransfer::CANCELLED:
case CTransfer::CANCELLED_BY_REMOTE:
- this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)ft, 0);
+ this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DENIED, (HANDLE)oid, 0);
+ this->transferList.remove_val(transfer);
break;
}
}
- if (prop == Transfer::P_BYTESTRANSFERRED)
- {
+ //if (prop == Transfer::P_BYTESTRANSFERRED)
+ //{
//PROTOFILETRANSFERSTATUS
//this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)ccid, 0);
//SEString transferProgressStr;
@@ -249,69 +256,64 @@ void CSkypeProto::OnTransferChanged(int prop, CTransfer::Ref transfer) //this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)ccid, 0);
// printf("Progress: %3.0f%% (%1.0f KB/s)\n", progress, transferRateInKb);
- }
+ //}
}
-void CSkypeProto::OnFileReceived(CConversation::Ref conversation, CMessage::Ref message)
+void CSkypeProto::OnFile(CConversation::Ref conversation, CMessage::Ref message)
{
- CTransfer::Refs transferList;
- message->GetTransfers(transferList);
- Sid::fetch(transferList);
+ CTransfer::Refs transfers;
+ message->GetTransfers(transfers);
+ //Sid::fetch(transferList);
Transfer::TYPE transferType;
Transfer::STATUS transferStatus;
- for (uint i = 0; i < transferList.size(); i++)
+ for (uint i = 0; i < transfers.size(); i++)
{
- auto transfer = transferList[i];
- transfer.fetch();
- transfer->SetOnTransferCallback(
- (CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged,
- this);
- //this->transferList.append(transfer);
+ auto transfer = transfers[i];
// 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
// the reference to Transfer Object and then check for further
// status changes in Transfer::OnChange
- transfer->GetPropType(transferType);
transfer->GetPropStatus(transferStatus);
- if ((transferType == Transfer::INCOMING) && (transferStatus == Transfer::NEW))
+ if (transferStatus == Transfer::NEW)
{
- //transferList[i]->AutoAccept();
- SEString name;
- transfer->GetPropFilename(name);
-
- wchar_t *path = ::mir_utf8decodeW(name);
-
- SEString data;
- transfer->GetPropPartnerHandle(data);
- mir_ptr<wchar_t> sid(::mir_utf8decodeW(data));
-
- HANDLE hContact = this->GetContactBySid(sid);
-
- auto ft = new FileTransfer(this);
- ft->transfers.append(transfer);
- transfer->GetPropChatmsgGuid(ft->guid);
- this->fileTransferList.insert(ft);
-
- PROTORECVFILET pre = {0};
- pre.flags = PREF_TCHAR;
- pre.fileCount = 1;
- pre.timestamp = time(NULL);
- pre.tszDescription = L" ";
- pre.ptszFiles = &path;
- pre.lParam = (LPARAM)ft;
- ::ProtoChainRecvFile(hContact, &pre);
-
- ::mir_free(path);
+ transfer->GetPropType(transferType);
+ if (transferType == Transfer::INCOMING)
+ {
+ uint timestamp;
+ message->GetPropTimestamp(timestamp);
+
+ SEString data;
+ transfer->GetPropPartnerHandle(data);
+ HANDLE hContact = this->GetContactBySid(mir_ptr<wchar_t>(::mir_utf8decodeW(data)));
+
+ transfer->GetPropFilename(data);
+ wchar_t *path = ::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();
+ ::ProtoChainRecvFile(hContact, &pre);
+
+ transfer.fetch();
+ transfer->SetOnTransferCallback(
+ (CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged,
+ this);
+ this->transferList.append(transfer);
+ }
+ /*else
+ {
+ }*/
}
- }
- //SEString bodyXml;
- //message->GetPropBodyXml(bodyXml);
- //printf("File transfer msg BodyXML:\n%s\n", (const char*)bodyXml);
+ }
}
void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref message)
@@ -338,7 +340,7 @@ void CSkypeProto::OnMessage(CConversation::Ref conversation, CMessage::Ref messa break;
case CMessage::POSTED_FILES:
- this->OnFileReceived(conversation, message);
+ this->OnFile(conversation, message);
break;
case CMessage::ADDED_CONSUMERS:
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 13a51a0d74..dac3c2dd7d 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -1,13 +1,9 @@ #include "skype_proto.h"
-CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) : fileTransferList(1)
+CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName)
{
ProtoConstructor(this, protoName, userName);
- //this->fileTransferList = new LIST<FileTransfer>(1);
-
- //this->login = NULL;
- //this->password = NULL;
this->rememberPassword = false;
this->signin_lock = CreateMutex(0, false, 0);
@@ -148,17 +144,22 @@ HANDLE __cdecl CSkypeProto::ChangeInfo( int iInfoType, void* pInfoData ) { retur HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const TCHAR* szPath )
{
- auto ft = (FileTransfer*)hTransfer;
+ uint oid = (uint)hTransfer;
+
+ MessageRef message(oid);
- for (uint i = 0; i < ft->transfers.size(); i++)
+ CTransfer::Refs transfers;
+ message->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
{
bool success;
SEString name;
wchar_t fullPath[MAX_PATH] = {0};
- ft->transfers[i]->GetPropFilename(name);
+ transfers[i]->GetPropFilename(name);
::mir_sntprintf(fullPath, MAX_PATH, L"%s%s", szPath, ::mir_utf8decodeW(name));
- if (ft->transfers[i]->Accept(::mir_u2a(fullPath), success) && success)
+ if (!transfers[i]->Accept(::mir_u2a(fullPath), success) || !success)
{
+ // todo: write to log!
return 0;
}
}
@@ -168,32 +169,42 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer )
{
- auto ft = (FileTransfer*)hTransfer;
+ uint oid = (uint)hTransfer;
- for (uint i = 0; i < ft->transfers.size(); i++)
+ MessageRef message(oid);
+
+ CTransfer::Refs transfers;
+ message->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
{
- if (ft->transfers[i]->Cancel())
+ if (!transfers[i]->Cancel())
{
- return 1;
+ // todo: write to log!
+ return 0;
}
}
- return 0;
+ return 1;
}
int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const TCHAR* szReason )
{
- auto ft = (FileTransfer*)hTransfer;
+ uint oid = (uint)hTransfer;
- for (uint i = 0; i < ft->transfers.size(); i++)
+ MessageRef message(oid);
+
+ CTransfer::Refs transfers;
+ message->GetTransfers(transfers);
+ for (uint i = 0; i < transfers.size(); i++)
{
- if (ft->transfers[i]->Cancel())
+ if (!transfers[i]->Cancel())
{
- return 1;
+ // todo: write to log!
+ return 0;
}
}
- return 0;
+ return 1;
}
int __cdecl CSkypeProto::FileResume( HANDLE hTransfer, int* action, const TCHAR** szFilename )
@@ -263,14 +274,16 @@ HWND __cdecl CSkypeProto::SearchAdvanced( HWND owner ) { return 0; } HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ){ return 0; }
int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* ) { return 0; }
+
int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* evt)
{
- //db_unset(hContact, "CList", "Hidden");
+ ::db_unset(hContact, "CList", "Hidden");
return Proto_RecvFile(hContact, evt);
}
int __cdecl CSkypeProto::RecvMsg( HANDLE hContact, PROTORECVEVENT* pre)
{
+ ::db_unset(hContact, "CList", "Hidden");
this->UserIsTyping(hContact, PROTOTYPE_SELFTYPING_OFF);
int length = ::strlen(pre->szMessage) + 1;
@@ -290,49 +303,33 @@ HANDLE __cdecl CSkypeProto::SendFile( HANDLE hContact, const TCHAR* szDescriptio {
SEStringList targets;
mir_ptr<wchar_t> sid(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
- targets.append(::mir_u2a(sid));
+ targets.append((char *)mir_ptr<char>(::mir_utf8encodeW(sid)));
- CConversation::Ref conversation = CConversation::FindBySid(
- this->skype,
- sid);
- conversation.fetch();
+ CConversation::Ref conversation = CConversation::FindBySid(this->skype, sid);
SEFilenameList fileList;
for (int i = 0; ppszFiles[i]; i++)
- {
- char* file = ::mir_u2a(ppszFiles[i]);
- fileList.append(file);
- }
+ fileList.append((char *)mir_ptr<char>(::mir_utf8encodeW(ppszFiles[i])));
auto error = TRANSFER_OPEN_SUCCESS;
SEFilename errFile; MessageRef msgRef;
- if ( !conversation->PostFiles(fileList, ::mir_u2a(szDescription), error, errFile, msgRef) || error)
- {
- // todo: despair
- //this->SendBroadcast(hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)ccid, 0);
+ //(char *)mir_ptr<char>(::mir_utf8encodeW(szDescription))
+ if ( !conversation->PostFiles(fileList, " ", error, errFile, msgRef) || error)
return 0;
- }
- FileTransfer *ft = new FileTransfer(this);
- if (msgRef->GetTransfers(ft->transfers))
+ CTransfer::Refs transfers;
+ if (msgRef->GetTransfers(transfers))
{
- Sid::fetch(ft->transfers);
- for (uint i = 0; i < ft->transfers.size(); i++)
+ for (uint i = 0; i < transfers.size(); i++)
{
- auto transfer = ft->transfers[i];
+ auto transfer = transfers[i];
transfer.fetch();
- transfer->SetOnTransferCallback(
- (CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged,
- this);
- //this->transferList.append(transfer);
+ transfer->SetOnTransferCallback((CTransfer::OnTransfer)&CSkypeProto::OnTransferChanged, this);
+ this->transferList.append(transfer);
}
}
- //auto ft = new FileTransfer(this);
- msgRef->GetPropGuid(ft->guid);
- this->fileTransferList.insert(ft);
-
- return ft;
+ return (HANDLE)msgRef->getOID();
}
return 0;
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index dd3981f0d2..dd694fa681 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -3,17 +3,14 @@ #include "skype.h"
#include <time.h>
-struct CSkypeProto;
-
typedef void (__cdecl CSkypeProto::* SkypeThreadFunc) (void*);
-typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
typedef int (__cdecl CSkypeProto::* SkypeEventFunc)(WPARAM, LPARAM);
+typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFunc)(WPARAM, LPARAM);
typedef INT_PTR (__cdecl CSkypeProto::* SkypeServiceFuncParam)(WPARAM, LPARAM, LPARAM);
struct StringList : public LIST<char>
{
- static int compare(const char* p1, const char* p2)
- { return _stricmp(p1, p2); }
+ static int compare(const char* p1, const char* p2) { return _stricmp(p1, p2); }
StringList() : LIST<char>(2, compare) {}
StringList(const char* string, const char *delimeters) : LIST<char>(2, compare)
@@ -153,27 +150,6 @@ struct PasswordChangeBoxParam }
};
-struct FileTransfer
-{
- CSkypeProto* ppro;
- SEBinary guid;
- CTransfer::Refs transfers;
- //char *who;
- //char *msg;
- //char *ftoken;
- //char *relay;
- //HANDLE hContact;
- //int cancel;
- //char *url;
- //HANDLE hWaitEvent;
- //DWORD action;
- //int y7;
- ////YList *files;
- //PROTOFILETRANSFERSTATUS pfts;
-
- FileTransfer(CSkypeProto* ppro) { this->ppro = ppro; }
-};
-
struct CSkypeProto : public PROTO_INTERFACE
{
public:
@@ -269,7 +245,7 @@ protected: CSkype *skype;
CAccount::Ref account;
CContact::Refs contactList;
-// CTransfer::Refs transferList;
+ CTransfer::Refs transferList;
CContactGroup::Ref commonList;
CContactGroup::Ref authWaitList;
@@ -306,12 +282,8 @@ protected: void OnMessageSended(CConversation::Ref conversation, CMessage::Ref message);
void OnMessageReceived(CConversation::Ref conversation, CMessage::Ref message);
- // file transfer
- LIST<FileTransfer> fileTransferList;
- FileTransfer *FindTransfer(SEBinary guid);
- FileTransfer *FindFileTransfer(CTransfer::Ref transfer);
-
- void OnFileReceived(CConversation::Ref conversation, CMessage::Ref message);
+ // transfer
+ void OnFile(CConversation::Ref conversation, CMessage::Ref message);
void OnTransferChanged(int prop, CTransfer::Ref transfer);
// chat
@@ -363,6 +335,7 @@ protected: HANDLE GetContactFromAuthEvent(HANDLE hEvent);
HANDLE AddContact(CContact::Ref contact);
+ bool IsContactOnline(HANDLE hContact);
void SetAllContactStatus(int status);
void __cdecl LoadContactList(void*);
|