diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2012-10-06 09:54:57 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2012-10-06 09:54:57 +0000 |
commit | 15dafd06973f1a3a49faeeb7b781bd11f9e011a5 (patch) | |
tree | 751ec084f31c5198fa2453bcad9bce2499ff6b55 /protocols | |
parent | e8fa894df94628c991f19a7c1642bac68fa069b1 (diff) |
- added part of contact info loading
git-svn-id: http://svn.miranda-ng.org/main/trunk@1790 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Skype/src/skype.cpp | 5 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 95 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 18 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 30 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 20 |
6 files changed, 147 insertions, 24 deletions
diff --git a/protocols/Skype/src/skype.cpp b/protocols/Skype/src/skype.cpp index e905bcf8be..b1b0b628f3 100644 --- a/protocols/Skype/src/skype.cpp +++ b/protocols/Skype/src/skype.cpp @@ -133,6 +133,11 @@ extern "C" int __declspec(dllexport) Load(void) pd.fnUninit = (pfnUninitProto)CSkypeProto::UninitSkypeProto;
CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast<LPARAM>(&pd));
+ CallService(
+ MS_UTILS_GETCOUNTRYLIST,
+ (WPARAM)&CSkypeProto::countriesCount,
+ (LPARAM)&CSkypeProto::countryList);
+
CSkypeProto::InitIcons();
CSkypeProto::InitMenus();
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 46169ef871..a83398d15a 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -27,7 +27,7 @@ void CSkypeProto::OnContactChanged(CContact* contact, int prop) bool CSkypeProto::IsProtoContact(HANDLE hContact)
{
- return (::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName));
+ return ::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) < 0;
}
HANDLE CSkypeProto::GetContactBySkypeName(wchar_t* skypeName)
@@ -37,7 +37,10 @@ HANDLE CSkypeProto::GetContactBySkypeName(wchar_t* skypeName) {
if (this->IsProtoContact(hContact))
{
- if (::wcscmp(skypeName, this->GetSettingString(hContact, "SkypeName", L"")) == 0)
+ wchar_t* data = this->GetSettingString(hContact, "SkypeName", L"");
+ bool result = ::wcscmp(skypeName, data) == 0;
+ mir_free(data);
+ if (result)
return hContact;
}
@@ -125,6 +128,85 @@ CContact::AVAILABILITY CSkypeProto::MirandaToSkypeStatus(int status) return availability;
}
+void CSkypeProto::LoadContactInfo(HANDLE hContact, CContact::Ref contact)
+{
+ CContact::AVAILABILITY availability;
+ contact->GetPropAvailability(availability);
+ this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
+
+ if (availability == CContact::PENDINGAUTH)
+ this->SetSettingWord(hContact, "Auth", 1);
+ else
+ DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
+
+ uint newTS = 0;
+ DWORD oldTS = 0;
+
+ // profile info
+ contact->GetPropProfileTimestamp(newTS);
+ oldTS = this->GetSettingDword(hContact, "ProfileUpdateTS");
+ if (newTS > oldTS)
+ {
+ uint uData;
+ SEString sData;
+ // birth date
+ contact->GetPropBirthday(uData);
+ // gender
+ contact->GetPropGender(uData);
+ this->SetSettingByte(hContact, "Gender", (BYTE)(uData ? 'M' : 'F'));
+ // timezone
+ contact->GetPropTimezone(uData);
+ // language
+ contact->GetPropLanguages(sData);
+ // country (en, ru, etc)
+ contact->GetPropCountry(sData);
+ BYTE countryId = this->GetCountryIdByName((const char*)sData);
+ this->SetSettingByte(hContact, "Country", countryId);
+ // state
+ contact->GetPropProvince(sData);
+ this->SetSettingString(hContact, "State", ::mir_a2u((const char*)sData));
+ // city
+ contact->GetPropCity(sData);
+ this->SetSettingString(hContact, "City", ::mir_a2u((const char*)sData));
+ // home phone + contact->GetPropPhoneHome(sData); + this->SetSettingString(hContact, "Phone", ::mir_a2u((const char*)sData)); + // office phone + contact->GetPropPhoneOffice(sData); + this->SetSettingString(hContact, "CompanyPhone", ::mir_a2u((const char*)sData)); + // mobile phone + contact->GetPropPhoneMobile(sData);
+ this->SetSettingString(hContact, "Cellular", ::mir_a2u((const char*)sData));
+ // e-mail + contact->GetPropEmails(sData); + this->SetSettingString(hContact, "e-mail", ::mir_a2u((const char*)sData)); + // homepage + contact->GetPropHomepage(sData); + this->SetSettingString(hContact, "Homepage", ::mir_a2u((const char*)sData)); + // about + contact->GetPropAbout(sData);
+ this->SetSettingString(hContact, "About", ::mir_a2u((const char*)sData));
+
+ // profile update ts
+ this->SetSettingDword(hContact, "ProfileUpdateTS", newTS);
+ }
+
+ // mood text
+ contact->GetPropProfileTimestamp(newTS);
+ oldTS = this->GetSettingDword(hContact, "XStatusTS");
+ if (newTS > oldTS)
+ {
+ SEString status;
+ contact->GetPropAbout(status);
+ this->SetSettingString(hContact, "XStatusMsg", ::mir_a2u((const char*)status));
+ // mood text update ts
+ this->SetSettingDword(hContact, "XStatusTS", newTS);
+ }
+
+ // avatar
+ // todo: add avatar loading
+}
+
void __cdecl CSkypeProto::LoadContactList(void*)
{
g_skype->GetHardwiredContactGroup(CContactGroup::ALL_KNOWN_CONTACTS, this->contactGroup);
@@ -147,14 +229,7 @@ void __cdecl CSkypeProto::LoadContactList(void*) HANDLE hContact = this->AddContactBySkypeName(skypeName, displayName, 0);
- CContact::AVAILABILITY availability;
- contact->GetPropAvailability(availability);
- this->SetSettingWord(hContact, SKYPE_SETTINGS_STATUS, this->SkypeToMirandaStatus(availability));
-
- if (availability == CContact::PENDINGAUTH)
- this->SetSettingWord(hContact, "Auth", 1);
- else
- DBDeleteContactSetting(hContact, this->m_szModuleName, "Auth");
+ this->LoadContactInfo(hContact, contact);
}
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index eee1e393f8..72fa4b2613 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -13,8 +13,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeAccountProc(HWND hwnd, UINT message, WPARAM w proto = reinterpret_cast<CSkypeProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- SetDlgItemText(hwnd, IDC_SL, proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L""));
- SetDlgItemText(hwnd, IDC_PW, proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L""));
+ wchar_t* data = proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L"");
+ SetDlgItemText(hwnd, IDC_SL, data);
+ ::mir_free(data);
+
+ data = proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L"");
+ SetDlgItemText(hwnd, IDC_PW, data);
+ ::mir_free(data);
if ( proto->m_iStatus != ID_STATUS_OFFLINE)
{
@@ -74,8 +79,13 @@ INT_PTR CALLBACK CSkypeProto::SkypeOptionsProc(HWND hwnd, UINT message, WPARAM w proto = reinterpret_cast<CSkypeProto*>(lparam);
SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- SetDlgItemText(hwnd, IDC_SL, proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L""));
- SetDlgItemText(hwnd, IDC_PW, proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L""));
+ wchar_t* data = proto->GetSettingString(SKYPE_SETTINGS_LOGIN, L"");
+ SetDlgItemText(hwnd, IDC_SL, data);
+ ::mir_free(data);
+
+ data = proto->GetDecodeSettingString(SKYPE_SETTINGS_PASSWORD, L"");
+ SetDlgItemText(hwnd, IDC_PW, data);
+ ::mir_free(data);
if (proto->m_iStatus != ID_STATUS_OFFLINE)
{
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index cbc9b6fdf0..e4c6170c76 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -24,6 +24,9 @@ CSkypeProto::~CSkypeProto() CloseHandle(this->signin_lock);
+ mir_free(this->login);
+ mir_free(this->password);
+
mir_free(this->m_szProtoName);
mir_free(this->m_szModuleName);
mir_free(this->m_tszUserName);
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 2b1384c9ba..3db7cd5bfa 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -71,6 +71,10 @@ public: virtual int __cdecl OnEvent( PROTOEVENTTYPE eventType, WPARAM wParam, LPARAM lParam );
+ // utils
+ static int countriesCount;
+ static CountryListEntry* countryList;
+
// events
int __cdecl OnModulesLoaded(WPARAM, LPARAM);
int __cdecl OnPreShutdown(WPARAM, LPARAM);
@@ -105,6 +109,8 @@ protected: HANDLE signin_lock;
void __cdecl SignIn(void*);
+
+ void LoadContactInfo(HANDLE hContact, CContact::Ref contact);
void __cdecl LoadContactList(void*);
// contacts
@@ -117,6 +123,10 @@ protected: CContact::AVAILABILITY MirandaToSkypeStatus(int status);
void SetAllContactStatus(int status);
+ // utils
+ static char* GetCountryNameById(int countryId);
+ static int GetCountryIdByName(const char* countryName);
+
// instances
static LIST<CSkypeProto> instanceList;
static int CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2);
@@ -162,16 +172,16 @@ protected: 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 = 0);
- bool SetSettingByte(HANDLE hContact, const char *setting, BYTE value = 0);
- bool SetSettingWord(const char *setting, WORD value = 0);
- bool SetSettingWord(HANDLE hContact, const char *setting, WORD value = 0);
- bool SetSettingDword(const char *setting, DWORD value = 0);
- bool SetSettingDword(HANDLE hContact, const char *setting, DWORD value = 0);
- bool SetSettingString(const char *setting, wchar_t* value = NULL);
- bool SetSettingString(HANDLE hContact, const char *setting, wchar_t* value = NULL);
- bool SetDecodeSettingString(const char *setting, wchar_t* value = NULL);
- bool SetDecodeSettingString(HANDLE hContact, const char *setting, wchar_t* value = NULL);
+ bool SetSettingByte(const char *setting, BYTE value);
+ bool SetSettingByte(HANDLE hContact, const char *setting, BYTE value);
+ bool SetSettingWord(const char *setting, WORD value);
+ bool SetSettingWord(HANDLE hContact, const char *setting, WORD value);
+ bool SetSettingDword(const char *setting, DWORD value);
+ bool SetSettingDword(HANDLE hContact, const char *setting, DWORD value);
+ bool SetSettingString(const char *setting, wchar_t* value);
+ 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);
// dialog procs
static INT_PTR CALLBACK SkypeAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index f2a9d28461..f64c1973d2 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -1,5 +1,25 @@ #include "skype_proto.h" +int CSkypeProto::countriesCount;
+CountryListEntry* CSkypeProto::countryList; + +int CSkypeProto::GetCountryIdByName(const char* countryName) +{ + for (int i = 0; i < CSkypeProto::countriesCount; i++) + { + const char* country = CSkypeProto::countryList[i].szName; + if (strcmp(CSkypeProto::countryList[i].szName, countryName) == 0) + return CSkypeProto::countryList[i].id; + } + + return 0; +} + +char* CSkypeProto::GetCountryNameById(int countryId) +{ + return (char*)::CallService(MS_UTILS_GETCOUNTRYBYNUMBER, (WPARAM)countryId, NULL); +} + int CSkypeProto::CompareProtos(const CSkypeProto *p1, const CSkypeProto *p2)
{
return wcscmp(p1->m_tszUserName, p2->m_tszUserName);
|