From 773421e8ba17637d994088c393d406226b516a30 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 11 Oct 2013 14:01:25 +0000 Subject: - m_hNetlibUser moved to PROTO_INTERFACE; - unified protocol loggers git-svn-id: http://svn.miranda-ng.org/main/trunk@6435 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_account.cpp | 26 +++++++++++++------------- protocols/Skype/src/skype_avatars.cpp | 10 +++++----- protocols/Skype/src/skype_chat.cpp | 22 +++++++++++----------- protocols/Skype/src/skype_contacts.cpp | 2 +- protocols/Skype/src/skype_netlib.cpp | 20 ++++---------------- protocols/Skype/src/skype_profile.cpp | 2 +- protocols/Skype/src/skype_proto.cpp | 20 ++++++++++---------- protocols/Skype/src/skype_proto.h | 4 ---- protocols/Skype/src/skype_transfers.cpp | 4 ++-- 9 files changed, 47 insertions(+), 63 deletions(-) (limited to 'protocols/Skype') diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index 218639d919..ceb0748dcb 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -118,7 +118,7 @@ bool CSkypeProto::LogIn() this->SetAccountSettings(); - this->Log(L"Login in an account"); + this->debugLogW(L"Login in an account"); this->account->LoginWithPassword(this->password, false, false); } @@ -130,7 +130,7 @@ void CSkypeProto::LogOut() if (this->IsOnline() || this->m_iStatus == ID_STATUS_CONNECTING) { this->account->SetAvailability(Contact::OFFLINE); - this->Log(L"Logout from account"); + this->debugLogW(L"Logout from account"); this->account->Logout(true); } } @@ -138,19 +138,19 @@ void CSkypeProto::LogOut() void CSkypeProto::SetAccountSettings() { int port = this->getWord("Port", rand() % 10000 + 10000); - this->Log(L"Setting port number to %d", port); + this->debugLogW(L"Setting port number to %d", port); this->SetInt(SETUPKEY_PORT, port); bool useAlternativePorts = this->getByte("UseAlternativePorts", 1) > 0; if (useAlternativePorts) - this->Log(L"Setting listening of alternative ports (80, 443)"); + this->debugLogW(L"Setting listening of alternative ports (80, 443)"); this->SetInt(SETUPKEY_DISABLE_PORT80, (int)!useAlternativePorts); // Create default group for new contacts DBVARIANT dbv = {0}; if ( !getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0) { - this->Log(L"Setting default group for new contacts"); + this->debugLogW(L"Setting default group for new contacts"); ::Clist_CreateGroup(0, dbv.ptszVal); ::db_free(&dbv); } @@ -158,10 +158,10 @@ void CSkypeProto::SetAccountSettings() void CSkypeProto::InitProxy() { - if (this->hNetLibUser) + if (this->m_hNetlibUser) { NETLIBUSERSETTINGS nlus = { sizeof(NETLIBUSERSETTINGS) }; - ::CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)this->hNetLibUser, (LPARAM)&nlus); + ::CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)this->m_hNetlibUser, (LPARAM)&nlus); if (nlus.useProxy) { @@ -172,7 +172,7 @@ void CSkypeProto::InitProxy() { case PROXYTYPE_HTTP: case PROXYTYPE_HTTPS: - this->Log(L"Setting https user proxy config"); + this->debugLogW(L"Setting https user proxy config"); this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 1); this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 0); this->SetStr(SETUPKEY_HTTPS_PROXY_ADDR, address); @@ -186,7 +186,7 @@ void CSkypeProto::InitProxy() case PROXYTYPE_SOCKS4: case PROXYTYPE_SOCKS5: - this->Log(L"Setting socks user proxy config"); + this->debugLogW(L"Setting socks user proxy config"); this->SetInt(SETUPKEY_HTTPS_PROXY_ENABLE, 0); this->SetInt(SETUPKEY_SOCKS_PROXY_ENABLE, 1); this->SetStr(SETUPKEY_SOCKS_PROXY_ADDR, address); @@ -199,7 +199,7 @@ void CSkypeProto::InitProxy() break; default: - this->Log(L"Setting automatic proxy detection"); + this->debugLogW(L"Setting automatic proxy detection"); this->Delete(SETUPKEY_HTTPS_PROXY_ENABLE); this->Delete(SETUPKEY_HTTPS_PROXY_ADDR); this->Delete(SETUPKEY_HTTPS_PROXY_USER); @@ -251,7 +251,7 @@ void CSkypeProto::SetServerStatus(int iNewStatus) CContact::AVAILABILITY availability = CSkypeProto::MirandaToSkypeStatus(iNewStatus); if (availability != CContact::UNKNOWN) { - this->Log(L"Setting status to %d", iNewStatus); + this->debugLogW(L"Setting status to %d", iNewStatus); this->account->SetAvailability(availability); } @@ -266,7 +266,7 @@ void CSkypeProto::OnCblUpdated() void CSkypeProto::OnLoggedOut(CAccount::LOGOUTREASON reason) { - this->Log(L"Failed to login: %s", CSkypeProto::LogoutReasons[reason]); + this->debugLogW(L"Failed to login: %s", CSkypeProto::LogoutReasons[reason]); if (this->m_iStatus == ID_STATUS_CONNECTING) this->SendBroadcast( @@ -327,7 +327,7 @@ void CSkypeProto::OnAccountChanged(int prop) this->account->GetPropPwdchangestatus(status); if (status != CAccount::PWD_CHANGING) { - this->Log(L"Failed to chage password: %s", CSkypeProto::PasswordChangeReasons[status]); + this->debugLogW(L"Failed to chage password: %s", CSkypeProto::PasswordChangeReasons[status]); this->ShowNotification(CSkypeProto::PasswordChangeReasons[status]); } } diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index 0c3be45a88..9ca9b0dddd 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -129,33 +129,33 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) ptrW avatarPath( this->GetContactAvatarFilePath(NULL)); if ( !::wcscmp(path, avatarPath)) { - this->Log(L"New avatar path are same with old."); + this->debugLogW(L"New avatar path are same with old."); return -1; } SEBinary avatar = this->GetAvatarBinary(path); if (avatar.size() == 0) { - this->Log(L"Failed to read avatar file."); + this->debugLogW(L"Failed to read avatar file."); return -1; } if (this->IsAvatarChanged(avatar)) { - this->Log(L"New avatar are same with old."); + this->debugLogW(L"New avatar are same with old."); return -1; } if ( !::CopyFile(path, avatarPath, FALSE)) { - this->Log(L"Failed to copy new avatar to local storage."); + this->debugLogW(L"Failed to copy new avatar to local storage."); return -1; } Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; if (!this->account->SetAvatar(avatar, result)) { - this->Log(CSkypeProto::ValidationReasons[result]); + this->debugLogW(CSkypeProto::ValidationReasons[result]); return -1; } diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index c8e5dcda39..3bb2534bbf 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -182,7 +182,7 @@ void ChatRoom::CreateChatSession(bool showWindow) ::CallServiceSync(MS_GC_EVENT, showWindow ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce); ::CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); - this->ppro->Log(L"Created new chat session %s", this->cid); + this->ppro->debugLogW(L"Created new chat session %s", this->cid); } void ChatRoom::SetTopic(const wchar_t *topic) @@ -343,19 +343,19 @@ void ChatRoom::Join(const wchar_t *joinBlob, CSkypeProto *ppro) void ChatRoom::SendMessage(const wchar_t *text) { - this->ppro->Log(L"Sending chat message %s", this->cid); + this->ppro->debugLogW(L"Sending chat message %s", this->cid); CMessage::Ref message; if (this->conversation->PostText((char *)ptrA(::mir_utf8encodeW(text)), message)) - this->ppro->Log(L"Chat message sent %s", this->cid); + this->ppro->debugLogW(L"Chat message sent %s", this->cid); } void ChatRoom::LeaveChat() { - this->ppro->Log(L"Leaving chat session %s", this->cid); + this->ppro->debugLogW(L"Leaving chat session %s", this->cid); if (this->conversation->RetireFrom()) - this->ppro->Log(L"Retired from conversation %s", this->cid); + this->ppro->debugLogW(L"Retired from conversation %s", this->cid); GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; gcd.ptszID = this->cid; @@ -370,13 +370,13 @@ void ChatRoom::LeaveChat() void ChatRoom::LeaveChatAndDelete() { - this->ppro->Log(L"Leaving chat session %s", this->cid); + this->ppro->debugLogW(L"Leaving chat session %s", this->cid); if (this->conversation->RetireFrom()) - this->ppro->Log(L"Retired from conversation %s", this->cid); + this->ppro->debugLogW(L"Retired from conversation %s", this->cid); if (this->conversation->Delete()) - this->ppro->Log(L"Delete conversation %s", this->cid); + this->ppro->debugLogW(L"Delete conversation %s", this->cid); GCDEST gcd = { ppro->m_szModuleName, { NULL }, GC_EVENT_CONTROL }; gcd.ptszID = this->cid; @@ -781,7 +781,7 @@ void ChatRoom::OnEvent(const ConversationRef &conversation, const MessageRef &me message->GetPropConsumptionStatus(status); if (status != Message::CONSUMED) { - this->ppro->Log(L"Retired other event for conversation %s", this->cid); + this->ppro->debugLogW(L"Retired other event for conversation %s", this->cid); uint timestamp; message->GetPropTimestamp(timestamp); @@ -819,7 +819,7 @@ void ChatRoom::OnEvent(const ConversationRef &conversation, const MessageRef &me message->GetPropConsumptionStatus(status); if (status != Message::CONSUMED) { - this->ppro->Log(L"Retired event for conversation %s", this->cid); + this->ppro->debugLogW(L"Retired event for conversation %s", this->cid); uint timestamp; message->GetPropTimestamp(timestamp); @@ -1634,7 +1634,7 @@ INT_PTR __cdecl CSkypeProto::OnLeaveChat(WPARAM wParam, LPARAM) void __cdecl CSkypeProto::LoadChatList(void*) { - this->Log(L"Updating group chats list"); + this->debugLogW(L"Updating group chats list"); CConversation::Refs conversations; this->GetConversationList(conversations); diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 72a518a80f..33042e728d 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -243,7 +243,7 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary) void __cdecl CSkypeProto::LoadContactList(void* data) { - this->Log(L"Updating contacts list"); + this->debugLogW(L"Updating contacts list"); bool isFirstLoad = data != NULL; diff --git a/protocols/Skype/src/skype_netlib.cpp b/protocols/Skype/src/skype_netlib.cpp index 8641eb8de8..6a958d0217 100644 --- a/protocols/Skype/src/skype_netlib.cpp +++ b/protocols/Skype/src/skype_netlib.cpp @@ -10,25 +10,13 @@ void CSkypeProto::InitNetLib() nlu.flags = NUF_OUTGOING | NUF_INCOMING | NUF_HTTPCONNS | NUF_UNICODE; nlu.ptszDescriptiveName = name; nlu.szSettingsModule = this->m_szModuleName; - this->hNetLibUser = (HANDLE)::CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); + this->m_hNetlibUser = (HANDLE)::CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); - this->Log(L"Setting protocol/module name to '%s'", (TCHAR*)_A2T(m_szModuleName)); + this->debugLogW(L"Setting protocol/module name to '%s'", (TCHAR*)_A2T(m_szModuleName)); } void CSkypeProto::UninitNetLib() { - ::Netlib_CloseHandle(this->hNetLibUser); - this->hNetLibUser = NULL; + ::Netlib_CloseHandle(this->m_hNetlibUser); + this->m_hNetlibUser = NULL; } - -void CSkypeProto::Log(const wchar_t *fmt, ...) -{ - va_list va; - wchar_t msg[1024]; - - va_start(va, fmt); - ::mir_vsntprintf(msg, SIZEOF(msg), fmt, va); - va_end(va); - - ::CallService(MS_NETLIB_LOGW, (WPARAM)this->hNetLibUser, (LPARAM)msg); -} \ No newline at end of file diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index f76b238d80..bd59491c34 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -288,7 +288,7 @@ void CSkypeProto::UpdateProfileTimezone(SEObject *obj, HANDLE hContact) void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) { - this->Log(L"Updating profile for %p", hContact); + this->debugLogW(L"Updating profile for %p", hContact); this->UpdateProfileAvatar(obj, hContact); uint newTS = hContact ? obj->GetUintProp(Contact::P_PROFILE_TIMESTAMP) : obj->GetUintProp(Account::P_PROFILE_TIMESTAMP); diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 3c9cab6546..1966d403be 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -150,7 +150,7 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const { uint oid = (uint)hTransfer; - this->Log(L"Incoming file transfer is accepted"); + this->debugLogW(L"Incoming file transfer is accepted"); bool success; wchar_t fullPath[MAX_PATH] = {0}; @@ -187,7 +187,7 @@ HANDLE __cdecl CSkypeProto::FileAllow( HANDLE hContact, HANDLE hTransfer, const //if ( !ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (HANDLE)oid, (LPARAM)&pfts)) if ( !transfer->Accept((char *)ptrA(::mir_utf8encodeW(fullPath)), success) || !success) { - this->Log(L"Cannot accept file transfer"); + this->debugLogW(L"Cannot accept file transfer"); this->transferList.remove_val(transfer); } } @@ -210,7 +210,7 @@ int __cdecl CSkypeProto::FileCancel( HANDLE hContact, HANDLE hTransfer ) if (transferStatus <= Transfer::CANCELLED && this->transferList.contains(transfer)) { if ( !transfer->Cancel()) - this->Log(L"Incoming file transfer is cancelled"); + this->debugLogW(L"Incoming file transfer is cancelled"); this->transferList.remove_val(transfer); } } @@ -234,7 +234,7 @@ int __cdecl CSkypeProto::FileDeny( HANDLE hContact, HANDLE hTransfer, const T if (transferStatus <= Transfer::CANCELLED && this->transferList.contains(transfer)) { if ( !transfer->Cancel()) - this->Log(L"Incoming file transfer is denied"); + this->debugLogW(L"Incoming file transfer is denied"); this->transferList.remove_val(transfer); } } @@ -362,7 +362,7 @@ HWND __cdecl CSkypeProto::CreateExtendedSearchUI( HWND owner ){ return 0; } int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* pre) { - this->Log(L"Incoming contacts"); + this->debugLogW(L"Incoming contacts"); ::db_unset(hContact, "CList", "Hidden"); return (INT_PTR)this->AddDBEvent( @@ -376,14 +376,14 @@ int __cdecl CSkypeProto::RecvContacts( HANDLE hContact, PROTORECVEVENT* pre) int __cdecl CSkypeProto::RecvFile( HANDLE hContact, PROTORECVFILET* pre) { - this->Log(L"Incoming file transfer"); + this->debugLogW(L"Incoming file transfer"); ::db_unset(hContact, "CList", "Hidden"); return ::Proto_RecvFile(hContact, pre); } int __cdecl CSkypeProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre) { - this->Log(L"Incoming message"); + this->debugLogW(L"Incoming message"); ::db_unset(hContact, "CList", "Hidden"); ReadMessageParam *param = (ReadMessageParam*)pre->lParam; @@ -409,7 +409,7 @@ int __cdecl CSkypeProto::SendContacts(HANDLE hContact, int flags, int nContacts, { if (this->IsOnline() && hContact && hContactsList) { - this->Log(L"Outcoming contacts"); + this->debugLogW(L"Outcoming contacts"); ConversationRef conversation; if ( !this->isChatRoom(hContact)) @@ -460,7 +460,7 @@ HANDLE __cdecl CSkypeProto::SendFile(HANDLE hContact, const TCHAR *szDescription { if (this->IsOnline() && hContact && ppszFiles) { - this->Log(L"Outcoming file transfer"); + this->debugLogW(L"Outcoming file transfer"); ConversationRef conversation; if ( !this->isChatRoom(hContact)) @@ -529,7 +529,7 @@ HANDLE __cdecl CSkypeProto::SendFile(HANDLE hContact, const TCHAR *szDescription int __cdecl CSkypeProto::SendMsg(HANDLE hContact, int flags, const char *msg) { - this->Log(L"Outcoming message"); + this->debugLogW(L"Outcoming message"); SEStringList targets; targets.append((char *)_T2A(::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID))); diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 186cf34ea3..094fa8c6e8 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -477,13 +477,9 @@ protected: HANDLE CreateEvent(const char* szService); // netlib - HANDLE hNetLibUser; - void InitNetLib(); void UninitNetLib(); - void Log(const wchar_t *fmt, ...); - // services void InitInstanceServiceList(); diff --git a/protocols/Skype/src/skype_transfers.cpp b/protocols/Skype/src/skype_transfers.cpp index 227edaeea6..a6f5fc5cab 100644 --- a/protocols/Skype/src/skype_transfers.cpp +++ b/protocols/Skype/src/skype_transfers.cpp @@ -46,7 +46,7 @@ void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) break; case Transfer::FAILED: transfer->GetPropFailurereason(reason); - this->Log(L"File transfer failed: %s", CSkypeProto::TransferFailureReasons[reason]); + this->debugLogW(L"File transfer failed: %s", CSkypeProto::TransferFailureReasons[reason]); this->transferList.remove_val(transfer); this->transferts[oid].files[fOid].isCanceled = true; break; @@ -58,7 +58,7 @@ void CSkypeProto::OnTransferChanged(const TransferRef &transfer, int prop) case Transfer::CANCELLED: case Transfer::CANCELLED_BY_REMOTE: transfer->GetPropFailurereason(reason); - this->Log(L"File transfer cancelled: %s", CSkypeProto::TransferFailureReasons[reason]); + this->debugLogW(L"File transfer cancelled: %s", CSkypeProto::TransferFailureReasons[reason]); this->transferList.remove_val(transfer); this->transferts[oid].files[fOid].isCanceled = true; break; -- cgit v1.2.3