summaryrefslogtreecommitdiff
path: root/protocols/Skype/src/skype_profile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Skype/src/skype_profile.cpp')
-rw-r--r--protocols/Skype/src/skype_profile.cpp381
1 files changed, 157 insertions, 224 deletions
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp
index d9df4724c4..081f8b22dc 100644
--- a/protocols/Skype/src/skype_profile.cpp
+++ b/protocols/Skype/src/skype_profile.cpp
@@ -1,13 +1,13 @@
#include "skype_proto.h"
-void CSkypeProto::UpdateOwnAvatar()
+void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact)
{
- uint newTS = 0;
- this->account->GetPropAvatarTimestamp(newTS);
- DWORD oldTS = this->GetSettingDword("AvatarTS");
- wchar_t *path = this->GetContactAvatarFilePath(NULL);
- SEBinary data;
- this->account->GetPropAvatarImage(data);
+ uint newTS = obj->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182);
+ DWORD oldTS = this->GetSettingDword(hContact, "AvatarTS");
+
+ wchar_t *path = this->GetContactAvatarFilePath(hContact);
+ SEBinary data = obj->GetBinProp(/* *::P_AVATAR_IMAGE */ 37);
+
if ((newTS > oldTS) || (!newTS && data.size() > 0 && _waccess(path, 0) == -1) || (newTS && _waccess(path, 0) == -1)) //hack for avatars without timestamp
{
FILE* fp = _wfopen(path, L"wb");
@@ -21,28 +21,40 @@ void CSkypeProto::UpdateOwnAvatar()
PROTO_AVATAR_INFORMATIONW pai = {0};
pai.cbSize = sizeof(pai);
pai.format = PA_FORMAT_JPEG;
- pai.hContact = NULL;
+ pai.hContact = hContact;
wcscpy(pai.filename, path);
- this->SendBroadcast(ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
+ this->SendBroadcast(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
}
}
+
delete path;
}
-void CSkypeProto::UpdateOwnBirthday()
+void CSkypeProto::UpdateProfileAboutText(SEObject *obj, HANDLE hContact)
+{
+ wchar_t* aboutText = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_ABOUT */ 18));
+ if ( !::wcslen(aboutText))
+ this->DeleteSetting(hContact, "About");
+ else
+ this->SetSettingString(hContact, "About", aboutText);
+ ::mir_free(aboutText);
+}
+
+void CSkypeProto::UpdateProfileBirthday(SEObject *obj, HANDLE hContact)
{
- uint data;
- this->account->GetPropBirthday(data);
- TCHAR date[9];
+ uint data = obj->GetUintProp(/* *::P_BIRTHDAY */ 7);
if (data > 0)
{
+ TCHAR date[9];
_itot_s(data, date, 10);
+
INT day, month, year;
_stscanf(date, _T("%04d%02d%02d"), &year, &month, &day);
- this->SetSettingByte("BirthDay", day);
- this->SetSettingByte("BirthMonth", month);
- this->SetSettingWord("BirthYear", year);
+
+ this->SetSettingByte(hContact, "BirthDay", day);
+ this->SetSettingByte(hContact, "BirthMonth", month);
+ this->SetSettingWord(hContact, "BirthYear", year);
SYSTEMTIME sToday = {0};
GetLocalTime(&sToday);
@@ -50,203 +62,191 @@ void CSkypeProto::UpdateOwnBirthday()
if (sToday.wMonth < month || (sToday.wMonth == month && sToday.wDay < day))
nAge--;
if (nAge)
- this->SetSettingWord("Age", ( WORD )nAge );
+ this->SetSettingWord( hContact, "Age", ( WORD )nAge );
}
else
{
- this->DeleteSetting("BirthDay");
- this->DeleteSetting("BirthMonth");
- this->DeleteSetting("BirthYear");
- this->DeleteSetting("Age");
+ this->DeleteSetting(hContact, "BirthDay");
+ this->DeleteSetting(hContact, "BirthMonth");
+ this->DeleteSetting(hContact, "BirthYear");
+ this->DeleteSetting(hContact, "Age");
}
}
-void CSkypeProto::UpdateOwnCity()
+void CSkypeProto::UpdateProfileCity(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropCity(data);
- wchar_t* city = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(city, L"") == 0)
- this->DeleteSetting("City");
+ wchar_t* city = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_CITY */ 12));
+ if ( !::wcslen(city))
+ this->DeleteSetting(hContact, "City");
else
- this->SetSettingString("City", city);
+ this->SetSettingString(hContact, "City", city);
::mir_free(city);
}
-void CSkypeProto::UpdateOwnCountry()
+void CSkypeProto::UpdateProfileCountry(SEObject *obj, HANDLE hContact)
{
- // country (en, ru, etc)
- SEString data;
char* country;
- this->account->GetPropCountry(data);
- char* isocode = ::mir_utf8decodeA((const char*)data);
- if (strcmp(isocode, "") == 0)
+ char* isocode = ::mir_strdup(obj->GetStrProp(/* *::P_COUNTRY */ 10));
+ if ( !::strlen(isocode))
{
country = (char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, 0xFFFF, 0);
- this->SetSettingString("Country", _A2T(country));
+ this->SetSettingString(hContact, "Country", ::mir_a2t(country));
}
else
{
country = (char*)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0);
- this->SetSettingString("Country", _A2T(country));
+ this->SetSettingString(hContact, "Country", ::mir_a2t(country));
}
::mir_free(isocode);
}
-void CSkypeProto::UpdateOwnEmails()
+void CSkypeProto::UpdateProfileEmails(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropEmails(data);
- wchar_t* emails = ::mir_utf8decodeW((const char*)data);
+ wchar_t* emails = ::mir_a2u(obj->GetStrProp(/* *::P_EMAILS */ 16));
if (wcscmp(emails, L"") == 0)
{
- this->DeleteSetting("e-mail0");
- this->DeleteSetting("e-mail1");
- this->DeleteSetting("e-mail2");
+ this->DeleteSetting(hContact, "e-mail0");
+ this->DeleteSetting(hContact, "e-mail1");
+ this->DeleteSetting(hContact, "e-mail2");
}
else
{
wchar_t* p = wcstok(emails, L" ");
if (p == NULL)
{
- this->SetSettingString("e-mail0", emails);
+ this->SetSettingString(hContact, "e-mail0", emails);
}
else
{
- this->SetSettingString("e-mail0", p);
+ this->SetSettingString(hContact, "e-mail0", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString("e-mail1", p);
+ if (p) this->SetSettingString(hContact, "e-mail1", p);
p = wcstok(NULL, L" ");
- if (p) this->SetSettingString("e-mail2", p);
+ if (p) this->SetSettingString(hContact, "e-mail2", p);
}
+ ::mir_free(p);
}
::mir_free(emails);
}
-void CSkypeProto::UpdateOwnGender()
+void CSkypeProto::UpdateProfileFullName(SEObject *obj, HANDLE hContact)
{
- uint data;
- this->account->GetPropGender(data);
+ wchar_t* fullname = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5));
+ if ( !::wcslen(fullname))
+ this->DeleteSetting(hContact, "LastName");
+ else
+ this->SetSettingString(hContact, "LastName", fullname);
+ ::mir_free(fullname);
+}
+
+void CSkypeProto::UpdateProfileGender(SEObject *obj, HANDLE hContact)
+{
+ uint data = obj->GetUintProp(/* *::P_GENDER */ 8);
if (data)
- this->SetSettingByte("Gender", (BYTE)(data == 1 ? 'M' : 'F'));
+ this->SetSettingByte(hContact, "Gender", (BYTE)(data == 1 ? 'M' : 'F'));
else
- this->DeleteSetting("Gender");
+ this->DeleteSetting(hContact, "Gender");
}
-void CSkypeProto::UpdateOwnHomepage()
+void CSkypeProto::UpdateProfileHomepage(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropHomepage(data);
- wchar_t* homepage = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(homepage, L"") == 0)
- this->DeleteSetting("Homepage");
+ wchar_t* homepage = ::mir_a2u(obj->GetStrProp(/* *::P_HOMEPAGE */ 17));
+ if (::wcscmp(homepage, L"") == 0)
+ this->DeleteSetting(hContact, "Homepage");
else
- this->SetSettingString("Homepage", homepage);
- ::mir_free(homepage);
+ this->SetSettingString(hContact, "Homepage", homepage);
+ ::mir_free(homepage);
}
-void CSkypeProto::UpdateOwnLanguages()
+void CSkypeProto::UpdateProfileLanguages(SEObject *obj, HANDLE hContact)
{
- // languages (en, ru, etc), space searated
- SEString data;
- this->account->GetPropLanguages(data);
- char* isocode = ::mir_utf8decodeA((const char*)data);
- if (strcmp(isocode, "") == 0)
+ wchar_t *isocodes = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_LANGUAGES */ 9));
+ if ( !::wcslen(isocodes))
{
- this->DeleteSetting("Language1");
+ this->DeleteSetting(hContact, "Language1");
+ this->DeleteSetting(hContact, "Language2");
+ this->DeleteSetting(hContact, "Language3");
}
else
{
- for (int i = 0; i < SIZEOF(CSkypeProto::languages); i++)
- if ( lstrcmpiA((char*)isocode, CSkypeProto::languages[i].ISOcode) == 0)
+ wchar_t* p = wcstok(isocodes, L" ");
+ if (p == NULL)
+ {
+ this->SetSettingString(hContact, "e-Language1", isocodes);
+ }
+ else
+ {
+ this->SetSettingString(hContact, "e-Language1", p);
+ p = wcstok(NULL, L" ");
+ if (p) this->SetSettingString(hContact, "e-Language2", p);
+ p = wcstok(NULL, L" ");
+ if (p) this->SetSettingString(hContact, "e-Language3", p);
+ }
+
+ // todo: fix
+ /*for (int i = 0; i < SIZEOF(CSkypeProto::languages); i++)
+ if ( ::stricmp((char*)isocode, CSkypeProto::languages[i].ISOcode) == 0)
{
- this->SetSettingString("Language1", ::mir_a2u(CSkypeProto::languages[i].szName));
+ this->SetSettingString(hContact, "Language1", ::mir_a2u(CSkypeProto::languages[i].szName));
break;
- }
+ }*/
}
- ::mir_free(isocode);
+ ::mir_free(isocodes);
}
-void CSkypeProto::UpdateOwnMobilePhone()
+void CSkypeProto::UpdateProfileMobilePhone(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropPhoneMobile(data);
- wchar_t* phone = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(phone, L"") == 0)
- this->DeleteSetting("Cellular");
+ wchar_t* phone = ::mir_a2u(obj->GetStrProp(/* *::P_PHONE_MOBILE */ 15));
+ if ( !::wcslen(phone))
+ this->DeleteSetting(hContact, "Cellular");
else
- this->SetSettingString("Cellular", phone);
+ this->SetSettingString(hContact, "Cellular", phone);
::mir_free(phone);
}
-void CSkypeProto::UpdateOwnNickName()
-{
- SEString data;
- this->account->GetPropFullname(data);
- wchar_t* nick = ::mir_utf8decodeW((const char*)data);
- this->SetSettingString("Nick", nick);
- ::mir_free(nick);
-}
-
-void CSkypeProto::UpdateOwnPhone()
+void CSkypeProto::UpdateProfilePhone(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropPhoneHome(data);
- wchar_t* phone = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(phone, L"") == 0)
- this->DeleteSetting("Phone");
+ wchar_t* phone = ::mir_a2u(obj->GetStrProp(/* *::P_PHONE_HOME */ 13));
+ if ( !::wcslen(phone))
+ this->DeleteSetting(hContact, "Phone");
else
- this->SetSettingString("Phone", phone);
+ this->SetSettingString(hContact, "Phone", phone);
::mir_free(phone);
}
-void CSkypeProto::UpdateOwnOfficePhone()
+void CSkypeProto::UpdateProfileOfficePhone(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropPhoneOffice(data);
- wchar_t* phone = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(phone, L"") == 0)
- this->DeleteSetting("CompanyPhone");
+ wchar_t* phone = ::mir_a2u(obj->GetStrProp(/* *::P_PHONE_OFFICE */ 14));
+ if ( !::wcslen(phone))
+ this->DeleteSetting(hContact, "CompanyPhone");
else
- this->SetSettingString("CompanyPhone", phone);
+ this->SetSettingString(hContact, "CompanyPhone", phone);
::mir_free(phone);
}
-void CSkypeProto::UpdateOwnState()
+void CSkypeProto::UpdateProfileState(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropProvince(data);
- wchar_t* state = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(state, L"") == 0)
- this->DeleteSetting("State");
+ wchar_t* state = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_PROVINCE */ 11));
+ if ( !::wcslen(state))
+ this->DeleteSetting(hContact, "State");
else
- this->SetSettingString("State", state);
+ this->SetSettingString(hContact, "State", state);
::mir_free(state);
}
-void CSkypeProto::UpdateOwnStatusMessage()
+void CSkypeProto::UpdateProfileStatusMessage(SEObject *obj, HANDLE hContact)
{
- uint newTS = 0;
- this->account->GetPropMoodTimestamp(newTS);
- DWORD oldTS = this->GetSettingDword("XStatusTS");
- if (newTS > oldTS)
- {
- SEString data;
- this->account->GetPropMoodText(data);
- wchar_t* status = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(status, L"") == 0)
- this->DeleteSetting("XStatusMsg");
- else
- this->SetSettingString("XStatusMsg", status);
- ::mir_free(status);
- this->SetSettingDword("XStatusTS", newTS);
- }
+ wchar_t* statusMessage = ::mir_utf8decodeW(obj->GetStrProp(/* *::P_MOOD_TEXT */ 26));
+ if ( !::wcslen(statusMessage))
+ this->DeleteSetting(hContact, "XStatusMsg");
+ else
+ this->SetSettingString(hContact, "XStatusMsg", statusMessage);
+ ::mir_free(statusMessage);
}
-void CSkypeProto::UpdateOwnTimezone()
+void CSkypeProto::UpdateProfileTimezone(SEObject *obj, HANDLE hContact)
{
- uint data;
- this->account->GetPropTimezone(data);
+ uint data = obj->GetUintProp(/* *::P_TIMEZONE */ 27);
if (data > 0)
{
uint diffmin = (data - 24*3600) / 60;
@@ -259,7 +259,7 @@ void CSkypeProto::UpdateOwnTimezone()
uint mins = ::abs((int)(diffmin % 60));
wchar_t timeshift[7];
::mir_sntprintf(timeshift, SIZEOF(timeshift), _T("%s%d:%02d"), sign, hours, mins);
-
+
wchar_t *szMin = wcschr(timeshift, ':');
int nTz = ::_wtoi(timeshift) * -2;
nTz += (nTz < 0 ? -1 : 1) * (szMin ? _ttoi( szMin + 1 ) / 30 : 0);
@@ -268,112 +268,45 @@ void CSkypeProto::UpdateOwnTimezone()
if (::GetTimeZoneInformation(&tzinfo) == TIME_ZONE_ID_DAYLIGHT)
nTz -= tzinfo.DaylightBias / 30;
- this->SetSettingByte("Timezone", (signed char)nTz);
+ this->SetSettingByte(hContact, "Timezone", (signed char)nTz);
}
else
- this->DeleteSetting("TimeZone");
+ this->DeleteSetting(hContact, "TimeZone");
}
-void CSkypeProto::UpdateOwnAbout()
+void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact)
{
- SEString data;
- this->account->GetPropAbout(data);
- wchar_t* about = ::mir_utf8decodeW((const char*)data);
- if (wcscmp(about, L"") == 0)
- this->DeleteSetting("About");
- else
- this->SetSettingString("About", about);
- ::mir_free(about);
-}
-void CSkypeProto::UpdateOwnProfile()
-{
- uint newTS = 0;
- this->account->GetPropProfileTimestamp(newTS);
- DWORD oldTS = this->GetSettingDword("ProfileTS");
- if (newTS > oldTS)
+ uint newTS = obj->GetUintProp(/* *::P_PROFILE_TIMESTAMP */ 19);
+ if (newTS > this->GetSettingDword("ProfileTS"))
{
- this->UpdateOwnAvatar();
- this->UpdateOwnBirthday();
- this->UpdateOwnCity();
- this->UpdateOwnCountry();
- this->UpdateOwnEmails();
- this->UpdateOwnGender();
- this->UpdateOwnHomepage();
- this->UpdateOwnLanguages();
- this->UpdateOwnMobilePhone();
- this->UpdateOwnNickName();
- this->UpdateOwnPhone();
- this->UpdateOwnOfficePhone();
- this->UpdateOwnState();
- this->UpdateOwnStatusMessage();
- this->UpdateOwnTimezone();
- this->UpdateOwnAbout();
+ this->UpdateProfileAboutText(obj, hContact);
+ this->UpdateProfileBirthday(obj, hContact);
+ this->UpdateProfileCity(obj, hContact);
+ this->UpdateProfileCountry(obj, hContact);
+ this->UpdateProfileEmails(obj, hContact);
+ this->UpdateProfileFullName(obj, hContact);
+ this->UpdateProfileGender(obj, hContact);
+ this->UpdateProfileHomepage(obj, hContact);
+ this->UpdateProfileLanguages(obj, hContact);
+ this->UpdateProfileMobilePhone(obj, hContact);
+ this->UpdateProfilePhone(obj, hContact);
+ this->UpdateProfileOfficePhone(obj, hContact);
+ this->UpdateProfileState(obj, hContact);
+ this->UpdateProfileTimezone(obj, hContact);
- this->SetSettingDword("ProfileTS", newTS);
- }
-}
+ if (hContact)
+ {
+ this->UpdateContactOnlineSinceTime(obj, hContact);
+ this->UpdateContactLastEventDate(obj, hContact);
-void CSkypeProto::OnProfileChanged(int prop)
-{
- switch(prop)
- {
- case CAccount::P_AVATAR_IMAGE:
- case CAccount::P_AVATAR_TIMESTAMP:
- this->UpdateOwnAvatar();
- break;
- case CAccount::P_BIRTHDAY:
- this->UpdateOwnBirthday();
- break;
- case CAccount::P_CITY:
- this->UpdateOwnCity();
- break;
- case CAccount::P_COUNTRY:
- this->UpdateOwnCountry();
- break;
- case CAccount::P_EMAILS:
- this->UpdateOwnEmails();
- break;
- case CAccount::P_GENDER:
- this->UpdateOwnGender();
- break;
- case CAccount::P_HOMEPAGE:
- this->UpdateOwnHomepage();
- break;
- case CAccount::P_LANGUAGES:
- this->UpdateOwnLanguages();
- break;
- case CAccount::P_MOOD_TEXT:
- case CAccount::P_MOOD_TIMESTAMP:
- this->UpdateOwnStatusMessage();
- break;
- case CAccount::P_PHONE_HOME:
- this->UpdateOwnPhone();
- break;
- case CAccount::P_PHONE_MOBILE:
- this->UpdateOwnMobilePhone();
- break;
- case CAccount::P_PHONE_OFFICE:
- this->UpdateOwnOfficePhone();
- break;
- case CAccount::P_PROFILE_TIMESTAMP:
- this->UpdateOwnProfile();
- break;
- case CAccount::P_PROVINCE:
- this->UpdateOwnState();
- break;
- case CAccount::P_TIMEZONE:
- this->UpdateOwnTimezone();
- break;
- case CAccount::P_FULLNAME:
- this->UpdateOwnNickName();
- break;
- case CAccount::P_ABOUT:
- this->UpdateOwnAbout();
- break;
+ this->SetSettingString(hContact, "MirVer", L"Skype");
+ }
+
+ this->SetSettingDword("ProfileTS", newTS);
}
}
void __cdecl CSkypeProto::LoadOwnInfo(void*)
{
- this->UpdateOwnProfile();
+ this->UpdateProfile(this->account.fetch());
} \ No newline at end of file