summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2012-10-28 07:28:44 +0000
committerAlexander Lantsev <aunsane@gmail.com>2012-10-28 07:28:44 +0000
commitb20547300df739d3df7d22fd78895427f4720e1d (patch)
treecec3b2e294b1de158f157cedcb08349714ce51a5 /protocols
parent864c0325be58dc597972a879af53004b17873946 (diff)
- added services to extended avatar support
git-svn-id: http://svn.miranda-ng.org/main/trunk@2097 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Skype/src/skype_contacts.cpp2
-rw-r--r--protocols/Skype/src/skype_profile.cpp4
-rw-r--r--protocols/Skype/src/skype_proto.h8
-rw-r--r--protocols/Skype/src/skype_services.cpp146
-rw-r--r--protocols/Skype/src/skype_utils.cpp17
5 files changed, 172 insertions, 5 deletions
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp
index f39f34c175..26e3ea530c 100644
--- a/protocols/Skype/src/skype_contacts.cpp
+++ b/protocols/Skype/src/skype_contacts.cpp
@@ -49,7 +49,7 @@ void CSkypeProto::UpdateContactAvatar(HANDLE hContact, CContact::Ref contact)
if (data.size() > 0)
{
- wchar_t *path = this->GetAvatarFilePath(this->GetSettingString(hContact, "sid"));
+ wchar_t *path = this->GetContactAvatarFilePath(this->GetSettingString(hContact, "sid"));
FILE* fp = _wfopen(path, L"wb");
if (fp)
{
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp
index f4e989686f..884a145358 100644
--- a/protocols/Skype/src/skype_profile.cpp
+++ b/protocols/Skype/src/skype_profile.cpp
@@ -8,9 +8,9 @@ void CSkypeProto::UpdateOwnAvatar()
if (newTS > oldTS)
{
SEBinary data;
- this->account->GetPropAvatarImage(data);
+ //this->account->GetPropAvatarImage(data);
- if (data.size() > 0)
+ //if (data.size() > 0)
{
// todo: add own avatar loading'n'registration
}
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h
index a28c62d516..aee81b58c7 100644
--- a/protocols/Skype/src/skype_proto.h
+++ b/protocols/Skype/src/skype_proto.h
@@ -199,7 +199,8 @@ protected:
// utils
static void FakeAsync(void*);
- wchar_t* GetAvatarFilePath(wchar_t* skypeName);
+ wchar_t* GetOwnAvatarFilePath();
+ wchar_t* GetContactAvatarFilePath(wchar_t* skypeName);
int SkypeToMirandaLoginError(CAccount::LOGOUTREASON logoutReason);
@@ -231,6 +232,11 @@ protected:
// services
static LIST<void> serviceList;
+ int GetAvatarInfo(WPARAM, LPARAM);
+ int GetAvatarCaps(WPARAM, LPARAM);
+ int GetMyAvatar(WPARAM, LPARAM);
+ int SetMyAvatar(WPARAM, LPARAM);
+
// icons
static _tag_iconList iconList[];
diff --git a/protocols/Skype/src/skype_services.cpp b/protocols/Skype/src/skype_services.cpp
index 572867f984..a06f64dd0d 100644
--- a/protocols/Skype/src/skype_services.cpp
+++ b/protocols/Skype/src/skype_services.cpp
@@ -6,4 +6,150 @@ void CSkypeProto::InitServiceList()
{
CSkypeProto::serviceList.insert(
::CreateServiceFunction("Skype/MenuChoose", CSkypeProto::MenuChooseService));
+}
+
+int CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam)
+{
+ PROTO_AVATAR_INFORMATIONW *pai = (PROTO_AVATAR_INFORMATIONW*)lParam;
+
+ if (this->GetSettingWord(pai->hContact, "AvatarTS"))
+ {
+ return GAIR_NOAVATAR;
+ }
+
+ wchar_t *sid = this->GetSettingString(pai->hContact, "sid");
+ if (sid)
+ {
+ wchar_t *path = this->GetContactAvatarFilePath(sid);
+ if (path && !_waccess(path, 0))
+ {
+ ::wcsncpy(pai->filename, path, SIZEOF(pai->filename));
+ pai->format = PA_FORMAT_JPEG;
+ return GAIR_SUCCESS;
+ }
+ }
+
+ return GAIR_NOAVATAR;
+}
+
+int CSkypeProto::GetAvatarCaps(WPARAM wParam, LPARAM lParam)
+{
+ switch (wParam)
+ {
+ case AF_MAXSIZE:
+ {
+ POINT *size = (POINT*)lParam;
+ if (size)
+ {
+ size->x = 96;
+ size->y = 96;
+ }
+ }
+ break;
+
+ case AF_PROPORTION:
+ return PIP_SQUARE;
+
+ case AF_FORMATSUPPORTED:
+ if (lParam == PA_FORMAT_JPEG)
+ return 1;
+
+ case AF_ENABLED:
+ return 1;
+
+ case AF_DONTNEEDDELAYS:
+ break;
+
+ case AF_MAXFILESIZE:
+ // server accepts images of 7168 bytees, not bigger
+ return 7168;
+
+ 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;
+ }
+
+ return 0;
+}
+
+int CSkypeProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
+{
+ if (!wParam) return -2;
+
+ wchar_t *path = this->GetOwnAvatarFilePath();
+ if (path && !_waccess(path, 0))
+ {
+ ::wcsncpy((wchar_t *)wParam, path, (int)lParam);
+ delete path;
+ return 0;
+ }
+
+ delete path;
+ return -1;
+}
+
+int CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam)
+{
+ wchar_t *path = (wchar_t *)lParam;
+ int iRet = -1;
+
+ //if (path)
+ //{ // set file for avatar
+ // int dwPaFormat = DetectAvatarFormat(tszFile);
+ // if (dwPaFormat != PA_FORMAT_XML)
+ // {
+ // // if it should be image, check if it is valid
+ // HBITMAP avt = (HBITMAP)CallService(MS_UTILS_LOADBITMAPT, 0, (WPARAM)tszFile);
+ // if (!avt) return iRet;
+ // DeleteObject(avt);
+ // }
+
+ // TCHAR tszMyFile[MAX_PATH+1];
+ // GetFullAvatarFileName(0, NULL, dwPaFormat, tszMyFile, MAX_PATH);
+ // // if not in our storage, copy
+ // if (lstrcmp(tszFile, tszMyFile) && !CopyFile(tszFile, tszMyFile, FALSE))
+ // {
+ // NetLog_Server("Failed to copy our avatar to local storage.");
+ // return iRet;
+ // }
+
+ // BYTE *hash = calcMD5HashOfFile(tszMyFile);
+ // if (hash)
+ // {
+ // BYTE* ihash = (BYTE*)_alloca(0x14);
+ // // upload hash to server
+ // ihash[0] = 0; //unknown
+ // ihash[1] = dwPaFormat == PA_FORMAT_XML ? AVATAR_HASH_FLASH : AVATAR_HASH_STATIC; //hash type
+ // ihash[2] = 1; //hash status
+ // ihash[3] = 0x10; //hash len
+ // memcpy(ihash+4, hash, 0x10);
+ // updateServAvatarHash(ihash, 0x14);
+
+ // if (setSettingBlob(NULL, "AvatarHash", ihash, 0x14))
+ // {
+ // NetLog_Server("Failed to save avatar hash.");
+ // }
+
+ // TCHAR tmp[MAX_PATH];
+ // CallService(MS_UTILS_PATHTORELATIVET, (WPARAM)tszMyFile, (LPARAM)tmp);
+ // setSettingStringT(NULL, "AvatarFile", tmp);
+
+ // iRet = 0;
+
+ // SAFE_FREE((void**)&hash);
+ // }
+ //}
+ //else
+ //{ // delete user avatar
+ // deleteSetting(NULL, "AvatarFile");
+ // setSettingBlob(NULL, "AvatarHash", hashEmptyAvatar, 9);
+ // updateServAvatarHash(hashEmptyAvatar, 9); // set blank avatar
+ // iRet = 0;
+ //}
+
+ return iRet;
} \ No newline at end of file
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp
index fbe5647248..a7b397b826 100644
--- a/protocols/Skype/src/skype_utils.cpp
+++ b/protocols/Skype/src/skype_utils.cpp
@@ -231,7 +231,22 @@ void CSkypeProto::FakeAsync(void *param)
::mir_free(param);
}
-wchar_t* CSkypeProto::GetAvatarFilePath(wchar_t* skypeName)
+wchar_t* CSkypeProto::GetOwnAvatarFilePath()
+{
+ /*DBVARIANT dbvFile = {DBVT_DELETED};
+
+ if (!getSettingStringT(NULL, "AvatarFile", &dbvFile))
+ {
+ TCHAR tmp[MAX_PATH * 2];
+ CallService(MS_UTILS_PATHTOABSOLUTET, (WPARAM)dbvFile.ptszVal, (LPARAM)tmp);
+ ICQFreeVariant(&dbvFile);
+
+ return null_strdup(tmp);
+ }*/
+ return NULL;
+}
+
+wchar_t* CSkypeProto::GetContactAvatarFilePath(wchar_t* skypeName)
{
wchar_t* path = new wchar_t[MAX_PATH * 2];