diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-06 11:22:35 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-06 11:22:35 +0000 |
commit | fe3fa7726ed116a4c6eaded2b43308131a030443 (patch) | |
tree | 5207c3a695b56b6d3142d90800a6263e9aee579e /protocols | |
parent | c68b7c22bd877ba609552de152dbb4ed84230bad (diff) |
- added avatar loading
- some minor changes
git-svn-id: http://svn.miranda-ng.org/main/trunk@1792 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/src/skype.h | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 54 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 8 | ||||
-rw-r--r-- | protocols/Skype/src/skype_settings.cpp | 13 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 41 |
5 files changed, 111 insertions, 8 deletions
diff --git a/protocols/Skype/src/skype.h b/protocols/Skype/src/skype.h index fe28a32f84..beb8677250 100644 --- a/protocols/Skype/src/skype.h +++ b/protocols/Skype/src/skype.h @@ -8,7 +8,7 @@ //#pragma warning(push)
//# pragma warning(disable:4312)
#include <newpluginapi.h>
-//#include <m_avatars.h>
+#include <m_avatars.h>
//#include <m_button.h>
//#include <m_chat.h>
//#include <m_clc.h>
@@ -35,6 +35,7 @@ //#include <m_addcontact.h>
#include <m_icolib.h>
#include <m_utils.h>
+#include <m_folders.h>
#include <m_system_cpp.h>
//#include <m_hotkeys.h>
//#pragma warning(pop)
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index a83398d15a..fd1d6afe1d 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -1,6 +1,5 @@ #include "skype_proto.h"
-
void CSkypeProto::OnContactChanged(CContact* contact, int prop)
{
if (prop == CContact::P_AVAILABILITY)
@@ -20,7 +19,7 @@ void CSkypeProto::OnContactChanged(CContact* contact, int prop) if (availability == CContact::PENDINGAUTH)
this->SetSettingWord(hContact, "Auth", 1);
else
- DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
+ this->DeleteSetting(hContact, "Auth");
}
}
}
@@ -137,7 +136,7 @@ void CSkypeProto::LoadContactInfo(HANDLE hContact, CContact::Ref contact) if (availability == CContact::PENDINGAUTH)
this->SetSettingWord(hContact, "Auth", 1);
else
- DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
+ this->DeleteSetting(hContact, "Auth");
uint newTS = 0;
DWORD oldTS = 0;
@@ -145,17 +144,30 @@ void CSkypeProto::LoadContactInfo(HANDLE hContact, CContact::Ref contact) // profile info
contact->GetPropProfileTimestamp(newTS);
oldTS = this->GetSettingDword(hContact, "ProfileUpdateTS");
- if (newTS > oldTS)
+ //if (newTS > oldTS)
{
uint uData;
SEString sData;
// birth date
contact->GetPropBirthday(uData);
+ if (uData > 0)
+ {
+ struct tm* ptm;
+ time_t timeGMT = (time_t)uData;
+ ptm = gmtime(&timeGMT);
+ this->SetSettingByte(hContact, "BirthDay", ptm->tm_mday);
+ this->SetSettingByte(hContact, "BirthMonth", ptm->tm_mon);
+ this->SetSettingWord(hContact, "BirthYear", ptm->tm_year + 1917);
+ }
// gender
contact->GetPropGender(uData);
this->SetSettingByte(hContact, "Gender", (BYTE)(uData ? 'M' : 'F'));
// timezone
contact->GetPropTimezone(uData);
+ if (uData > 0)
+ this->SetSettingByte(hContact, "TimeZone", uData);
+ else
+ this->DeleteSetting(hContact, "TimeZone");
// language
contact->GetPropLanguages(sData);
// country (en, ru, etc)
@@ -186,7 +198,6 @@ void CSkypeProto::LoadContactInfo(HANDLE hContact, CContact::Ref contact) // about contact->GetPropAbout(sData);
this->SetSettingString(hContact, "About", ::mir_a2u((const char*)sData));
-
// profile update ts
this->SetSettingDword(hContact, "ProfileUpdateTS", newTS);
}
@@ -204,7 +215,38 @@ void CSkypeProto::LoadContactInfo(HANDLE hContact, CContact::Ref contact) }
// avatar
- // todo: add avatar loading
+ contact->GetPropProfileTimestamp(newTS);
+ oldTS = this->GetSettingDword(hContact, "AvatarTS");
+ if (newTS > oldTS)
+ {
+ SEBinary avatar;
+ contact->GetPropAvatarImage(avatar);
+
+ if (avatar.size() > 0)
+ {
+ FILE* fp = _wfopen(this->GetAvatarFilePath(this->GetSettingString(hContact, "SkypeName")), L"w");
+ for (int i = 0; i < avatar.size(); i++)
+ {
+ if (i)
+ fputc(',', fp);
+ fputc('\'', fp);
+ switch(avatar[i])
+ {
+ case '\n':
+ fputc('\\', fp);
+ fputc('n', fp);
+ break;
+
+ default:
+ fputc(avatar[i], fp);
+ }
+ }
+ CloseHandle(fp);
+ }
+ // todo: need to register avatar to contact
+ //avatar update ts
+ this->SetSettingDword(hContact, "AvatarTS", newTS);
+ }
}
void __cdecl CSkypeProto::LoadContactList(void*)
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 3db7cd5bfa..8ae37492c8 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -1,6 +1,7 @@ #pragma once
#include "skype.h"
+#include <time.h>
struct CSkypeProto;
@@ -126,6 +127,8 @@ protected: // utils
static char* GetCountryNameById(int countryId);
static int GetCountryIdByName(const char* countryName);
+
+ wchar_t* GetAvatarFilePath(wchar_t* skypeName);
// instances
static LIST<CSkypeProto> instanceList;
@@ -171,7 +174,7 @@ protected: wchar_t* GetSettingString(HANDLE hContact, const char *setting, wchar_t* errorValue = NULL);
wchar_t* GetDecodeSettingString(const char *setting, wchar_t* errorValue = NULL);
wchar_t* GetDecodeSettingString(HANDLE hContact, const char *setting, wchar_t* errorValue = NULL);
-
+ //
bool SetSettingByte(const char *setting, BYTE value);
bool SetSettingByte(HANDLE hContact, const char *setting, BYTE value);
bool SetSettingWord(const char *setting, WORD value);
@@ -182,6 +185,9 @@ protected: bool SetSettingString(HANDLE hContact, const char *setting, wchar_t* value);
bool SetDecodeSettingString(const char *setting, wchar_t* value);
bool SetDecodeSettingString(HANDLE hContact, const char *setting, wchar_t* value);
+ //
+ void DeleteSetting(const char *setting);
+ void DeleteSetting(HANDLE hContact, const char *setting);
// dialog procs
static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
diff --git a/protocols/Skype/src/skype_settings.cpp b/protocols/Skype/src/skype_settings.cpp index e183e70fff..5cbe890268 100644 --- a/protocols/Skype/src/skype_settings.cpp +++ b/protocols/Skype/src/skype_settings.cpp @@ -66,6 +66,7 @@ wchar_t* CSkypeProto::GetDecodeSettingString(const char *setting, wchar_t* error return this->GetDecodeSettingString(NULL, setting, errorValue);
}
+//
bool CSkypeProto::SetSettingByte(HANDLE hContact, const char *setting, BYTE value)
{
@@ -118,4 +119,16 @@ bool CSkypeProto::SetDecodeSettingString(HANDLE hContact, const char *setting, w bool CSkypeProto::SetDecodeSettingString(const char *setting, wchar_t* value)
{
return this->SetDecodeSettingString(NULL, setting, value);
+}
+
+//
+
+void CSkypeProto::DeleteSetting(const char *setting)
+{
+ this->DeleteSetting(NULL, setting);
+}
+
+void CSkypeProto::DeleteSetting(HANDLE hContact, const char *setting)
+{
+ ::DBDeleteContactSetting(hContact, this->m_szModuleName, setting);
}
\ No newline at end of file diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index f64c1973d2..ae973f5fad 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -20,6 +20,47 @@ char* CSkypeProto::GetCountryNameById(int countryId) return (char*)::CallService(MS_UTILS_GETCOUNTRYBYNUMBER, (WPARAM)countryId, NULL); } +wchar_t* CSkypeProto::GetAvatarFilePath(wchar_t* skypeName)
+{
+ wchar_t* path = new wchar_t[MAX_PATH * 2];
+
+ FOLDERSGETDATA fgd = {0};
+ fgd.cbSize = sizeof(FOLDERSGETDATA);
+ fgd.nMaxPathSize = MAX_PATH * 2;
+ fgd.szPathT = path;
+ fgd.flags = FF_UNICODE;
+
+ HANDLE hAvatarsFolder;
+ if (::ServiceExists(MS_FOLDERS_REGISTER_PATH))
+ {
+ wchar_t tszPath[MAX_PATH * 2];
+ ::mir_sntprintf(
+ tszPath,
+ MAX_PATH * 2,
+ _T("%%miranda_avatarcache%%\\") _T(TCHAR_STR_PARAM) _T("\\"),
+ this->m_szModuleName);
+
+ hAvatarsFolder = ::FoldersRegisterCustomPathT(this->m_szModuleName, "Avatars Cache", tszPath);
+ }
+
+ if (::CallService(MS_FOLDERS_GET_PATH, (WPARAM)hAvatarsFolder, (LPARAM)&fgd))
+ {
+ wchar_t *tmpPath = ::Utils_ReplaceVarsT(L"%miranda_avatarcache%");
+ ::mir_sntprintf(path, MAX_PATH * 2, _T("%s\\") _T(TCHAR_STR_PARAM) _T("\\"), tmpPath, this->m_szModuleName);
+ mir_free(tmpPath);
+ }
+ else
+ wcscat(path, L"\\");
+
+ wcscat(path, skypeName);
+ wcscat(path, L".jpg");
+
+ // make sure the avatar cache directory exists
+ ::CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)path);
+
+ return path; +} + int CSkypeProto::CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2)
{
return wcscmp(p1->m_tszUserName, p2->m_tszUserName);
|