From 30b3cd352057c79cf26e1ce73a8c6554cbb4b7be Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 26 Apr 2013 15:19:17 +0000 Subject: cleanup project git-svn-id: http://svn.miranda-ng.org/main/trunk@4534 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_services.cpp | 138 +++++---------------------------- 1 file changed, 18 insertions(+), 120 deletions(-) (limited to 'protocols/Skype/src/skype_services.cpp') diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp index a7703a0e6d..4900b51b99 100644 --- a/protocols/Skype/src/skype_services.cpp +++ b/protocols/Skype/src/skype_services.cpp @@ -1,6 +1,6 @@ #include "skype_proto.h" -LIST CSkypeProto::serviceList(0); +LIST CSkypeProto::serviceList(1); void CSkypeProto::InitServiceList() { @@ -8,134 +8,32 @@ void CSkypeProto::InitServiceList() ::CreateServiceFunction("Skype/MenuChoose", CSkypeProto::MenuChooseService)); } -INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam) +void CSkypeProto::UninitServiceList() { - PROTO_AVATAR_INFORMATIONW *pai = (PROTO_AVATAR_INFORMATIONW*)lParam; - - if (this->GetSettingWord(pai->hContact, "AvatarTS")) - { - return GAIR_NOAVATAR; - } - - wchar_t *sid = ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN); - if (sid) - { - wchar_t *path = this->GetContactAvatarFilePath(pai->hContact); - if (path && !_waccess(path, 0)) - { - ::wcsncpy(pai->filename, path, SIZEOF(pai->filename)); - pai->format = PA_FORMAT_JPEG; - return GAIR_SUCCESS; - } - - ::mir_free(sid); - } - - return GAIR_NOAVATAR; -} - -INT_PTR __cdecl CSkypeProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam) -{ - switch (wParam) + for (int i = 0; i < CSkypeProto::serviceList.getCount(); i++) { - case AF_MAXSIZE: - { - POINT *size = (POINT*)lParam; - if (size) - { - size->x = 96; - size->y = 96; - } - } - break; - - case AF_PROPORTION: - return PIP_NONE; - - case AF_FORMATSUPPORTED: - return lParam == PA_FORMAT_JPEG; - - case AF_ENABLED: - return 1; - - case AF_DONTNEEDDELAYS: - return 1; - - case AF_MAXFILESIZE: - // server accepts images of 32000 bytees, not bigger - return 32000; - - case AF_DELAYAFTERFAIL: - // do not request avatar again if server gave an error - return 1;// * 60 * 60 * 1000; // one hour - - case AF_FETCHALWAYS: - // avatars can be fetched all the time (server only operation) - return 1; + ::DestroyServiceFunction(CSkypeProto::serviceList[i]); } - - return 0; } -INT_PTR __cdecl CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam) +void CSkypeProto::InitInstanceServiceList() { - if (!wParam) return -2; - - wchar_t *path = this->GetContactAvatarFilePath(NULL); - if (path && ::PathFileExists(path)) - { - ::wcsncpy((wchar_t *)wParam, path, (int)lParam); - delete path; - return 0; - } - - return -1; + // Message API + this->CreateServiceObj(PS_CREATEACCMGRUI, &CSkypeProto::OnAccountManagerInit); + // Chat API + this->CreateServiceObj(PS_JOINCHAT, &CSkypeProto::OnJoinChat); + this->CreateServiceObj(PS_LEAVECHAT, &CSkypeProto::OnLeaveChat); + // Avatar API + this->CreateServiceObj(PS_GETAVATARINFOT, &CSkypeProto::GetAvatarInfo); + this->CreateServiceObj(PS_GETAVATARCAPS, &CSkypeProto::GetAvatarCaps); + this->CreateServiceObj(PS_GETMYAVATART, &CSkypeProto::GetMyAvatar); + this->CreateServiceObj(PS_SETMYAVATART, &CSkypeProto::SetMyAvatar); } -INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) +void CSkypeProto::UninitInstanceServiceList() { - wchar_t *path = (wchar_t *)lParam; - int iRet = -1; - - if (path) + for (int i = 0; i < this->instanceServiceList.getCount(); i++) { - wchar_t *avatarPath = this->GetContactAvatarFilePath(NULL); - if (::wcscmp(path, avatarPath) && !::CopyFile(path, avatarPath, FALSE)) - { - this->Log(L"Failed to copy our avatar to local storage."); - return iRet; - } - - SEBinary avatar = this->GetAvatarBinary(avatarPath); - if (avatar.size() == 0) - { - this->Log(L"Failed to read avatar file."); - return iRet; - } - - if (!this->IsAvatarChanged(avatar)) - { - this->Log(L"New avatar are same with old."); - return iRet; - } - - Skype::VALIDATERESULT result = Skype::NOT_VALIDATED; - if (!this->account->SetAvatar(avatar, result)) - { - this->Log(CSkypeProto::ValidationReasons[result]); - return iRet; - } - - uint newTS = this->account->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182); - this->SetSettingDword("AvatarTS", newTS); - iRet = 0; + ::DestroyServiceFunction(this->instanceServiceList[i]); } - else - { - this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); - this->DeleteSetting("AvatarTS"); - iRet = 0; - } - - return iRet; } \ No newline at end of file -- cgit v1.2.3