diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-05-10 15:07:47 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-05-10 15:07:47 +0000 |
commit | 32cc6d62a154d5724c40085f22747df2ee2ff4cb (patch) | |
tree | f47241b283331f42b0955de792493e8139925a73 | |
parent | 763272b5a51b73eedb013c209ad256f85afc8fd2 (diff) |
- fixed several issues in own details saving
- fixed issues with contacts look cycle in db
- fixed freez offline status after login error
- other few bugs
git-svn-id: http://svn.miranda-ng.org/main/trunk@4621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Skype/src/skype_account.cpp | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_chat.cpp | 9 | ||||
-rw-r--r-- | protocols/Skype/src/skype_contacts.cpp | 30 | ||||
-rw-r--r-- | protocols/Skype/src/skype_dialogs.cpp | 25 | ||||
-rw-r--r-- | protocols/Skype/src/skype_own_info.cpp | 38 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 33 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skypekit/contact.cpp | 4 |
9 files changed, 78 insertions, 76 deletions
diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index f834edb560..d79ee7e973 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -3,6 +3,7 @@ wchar_t *CSkypeProto::LogoutReasons[] =
{
+ LPGENW("") /* --- */,
LPGENW("LOGOUT_CALLED") /* LOGOUT_CALLED */,
LPGENW("HTTPS_PROXY_AUTH_FAILED") /* HTTPS_PROXY_AUTH_FAILED */,
LPGENW("SOCKS_PROXY_AUTH_FAILED") /* SOCKS_PROXY_AUTH_FAILED */,
@@ -235,7 +236,7 @@ void CSkypeProto::OnLoggedIn() this->LoadOwnInfo(this);
this->LoadChatList(this);
- this->LoadContactList(reinterpret_cast<void *>(static_cast<int>(true)));
+ this->LoadContactList(this);
this->LoadAuthWaitList(this);
fetch(this->transferList);
@@ -266,19 +267,19 @@ void CSkypeProto::SetServerStatus(int iNewStatus) void CSkypeProto::OnCblUpdated()
{
// reload our CL after skype CL fully synced
- this->LoadContactList(reinterpret_cast<void *>(static_cast<int>(false)));
+ this->LoadContactList(NULL);
}
void CSkypeProto::OnLoggedOut(CAccount::LOGOUTREASON reason)
{
this->Log(L"Failed to login: %s", CSkypeProto::LogoutReasons[reason]);
- this->m_iStatus = ID_STATUS_OFFLINE;
+ this->SetStatus(ID_STATUS_OFFLINE);
this->SendBroadcast(
ACKTYPE_LOGIN, ACKRESULT_FAILED,
NULL, CSkypeProto::SkypeToMirandaLoginError(reason));
- this->ShowNotification(CSkypeProto::LogoutReasons[reason - 1]);
+ this->ShowNotification(CSkypeProto::LogoutReasons[reason]);
if (this->rememberPassword && reason == CAccount::INCORRECT_PASSWORD)
{
diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index 5e210571b8..1a240d7089 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -192,17 +192,14 @@ bool CSkypeProto::IsChatRoom(HANDLE hContact) HANDLE CSkypeProto::GetChatRoomByCid(const wchar_t *cid)
{
- HANDLE hContact = ::db_find_first();
- while (hContact)
+ for (HANDLE hContact = ::db_find_first(this->m_szModuleName); hContact; hContact = ::db_find_next(hContact, this->m_szModuleName))
{
- if (this->IsProtoContact(hContact) && this->IsChatRoom(hContact))
+ if (this->IsChatRoom(hContact))
{
mir_ptr<wchar_t> chatID(::db_get_wsa(hContact, this->m_szModuleName, "ChatRoomID"));
- if ( lstrcmp(cid, chatID) == 0)
+ if (::lstrcmp(cid, chatID) == 0)
return hContact;
}
-
- hContact = ::db_find_next(hContact);
}
return 0;
diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index 6ef7f0cf1b..e64194bdd5 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -164,7 +164,7 @@ HANDLE CSkypeProto::GetContactBySid(const wchar_t *sid) if ( !this->IsChatRoom(hContact))
{
mir_ptr<wchar_t> contactSid( ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_LOGIN));
- if (::wcsicmp(contactSid, sid) == 0)
+ if (::lstrcmpi(contactSid, sid) == 0)
return hContact;
}
}
@@ -205,7 +205,7 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact) hContact = (HANDLE)::CallService(MS_DB_CONTACT_ADD, 0, 0);
::CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName);
- mir_ptr<wchar_t> nick( ::mir_utf8decodeW(contact->GetNick()));
+ mir_ptr<wchar_t> nick(::mir_utf8decodeW(contact->GetNick()));
switch(availability) {
case CContact::SKYPEOUT:
@@ -243,7 +243,10 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact) void __cdecl CSkypeProto::LoadContactList(void* data)
{
+ ::EnterCriticalSection(&this->cl_loading);
+
this->Log(L"Updating contacts list");
+
bool isFirstLoad = data != NULL;
g_skype->GetHardwiredContactGroup(CContactGroup::ALL_BUDDIES, this->commonList);
@@ -260,7 +263,7 @@ void __cdecl CSkypeProto::LoadContactList(void* data) contact->SetOnContactChangedCallback(
(CContact::OnContactChanged)&CSkypeProto::OnContactChanged,
this);
- mir_ptr<wchar_t> sid( ::mir_utf8decodeW(contact->GetSid()));
+
HANDLE hContact = this->AddContact(contact);
if ( !isFirstLoad)
@@ -272,16 +275,15 @@ void __cdecl CSkypeProto::LoadContactList(void* data) mir_ptr<wchar_t> nick( ::db_get_wsa(hContact, "CList", "MyHandle"));
if ( !nick || !::wcslen(nick))
{
- SEString data;
- contact->GetPropFullname(data);
-
- nick = ::mir_utf8decodeW(data);
+ nick = ::mir_utf8decodeW(contact->GetNick());
::db_set_ws(hContact, "CList", "MyHandle", nick);
}
this->UpdateProfile(contact.fetch(), hContact);
}
}
+
+ ::LeaveCriticalSection(&this->cl_loading);
}
void __cdecl CSkypeProto::LoadChatList(void*)
@@ -305,13 +307,6 @@ void __cdecl CSkypeProto::LoadChatList(void*) this->JoinToChat(conversation, false);
}
}
-
- /*CConversation::Refs conversations;
- g_skype->GetConversationList(conversations);
- for (uint i = 0; i < conversations.size(); i++)
- {
- conversations[i]->Delete();
- }*/
}
void __cdecl CSkypeProto::LoadAuthWaitList(void*)
@@ -346,13 +341,10 @@ bool CSkypeProto::IsContactOnline(HANDLE hContact) void CSkypeProto::SetAllContactStatus(int status)
{
- HANDLE hContact = ::db_find_first();
- while (hContact)
+ for (HANDLE hContact = ::db_find_first(this->m_szModuleName); hContact; hContact = ::db_find_next(hContact, this->m_szModuleName))
{
- if (this->IsProtoContact(hContact) && ::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) == 0)
+ if (::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) == 0)
::db_set_w(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, status);
-
- hContact = ::db_find_next(hContact);
}
}
diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index feb92db25c..980b7f81a6 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -485,7 +485,7 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA mir_ptr<wchar_t> lang( ::db_get_wsa(NULL, ppro->m_szModuleName, "Language1"));
for (auto it = CSkypeProto::languages.begin(); it != CSkypeProto::languages.end(); ++it)
{
- /*int nItem = */::SendMessage(
+ ::SendMessage(
::GetDlgItem(hwndDlg, IDC_LANGUAGE),
CB_ADDSTRING,
0,
@@ -493,10 +493,13 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA ::SendMessage(
::GetDlgItem(hwndDlg, IDC_LANGUAGE),
- CB_SETITEMDATA, i++, (LPARAM)&it->first);
+ CB_SETITEMDATA,
+ i,
+ (LPARAM)&it->first);
if (lang && it->second.compare(lang) == 0)
- ::SetDlgItemText(hwndDlg, IDC_LANGUAGE, ::TranslateTS(it->second.c_str()));
+ ::SendMessage(GetDlgItem(hwndDlg, IDC_LANGUAGE), CB_SETCURSEL, i, 0);
+ i++;
}
// nick
@@ -694,22 +697,20 @@ INT_PTR CALLBACK CSkypeProto::HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wP ::SendMessage(
::GetDlgItem(hwndDlg, IDC_COUNTRY),
CB_SETITEMDATA,
- i,
- (LPARAM)g_countries[i].id);
+ nItem,
+ (LPARAM)&g_countries[i].ISOcode);
if (countr && ::wcscmp(country, countr) == 0)
- ::SetDlgItemText(hwndDlg, IDC_COUNTRY, TranslateTS(country));
+ ::SendMessage(GetDlgItem(hwndDlg, IDC_COUNTRY), CB_SETCURSEL, nItem, 0);
::mir_free(country);
}
}
- tmi.prepareList((HANDLE)lParam, GetDlgItem(hwndDlg, IDC_TIMEZONE), TZF_PLF_CB);
- //HANDLE hTimeZone = tmi.createByContact ? tmi.createByContact(NULL, 0) : 0;
- //LPCTSTR TzDescr = tmi.getTzDescription(tmi.getTzName(hTimeZone));
- //SetDlgItemText(hwndDlg, IDC_TIMEZONE, TzDescr);
-
- //BYTE nTz = ::db_get_b(NULL, ppro->m_szModuleName, "Timezone", 0);
+ tmi.prepareList((HANDLE)lParam, ::GetDlgItem(hwndDlg, IDC_TIMEZONE), TZF_PLF_CB);
+ HANDLE hTimeZone = tmi.createByContact ? tmi.createByContact(NULL, 0) : 0;
+ LPCTSTR TzDescr = tmi.getTzDescription(tmi.getTzName(hTimeZone));
+ ::SetDlgItemText(hwndDlg, IDC_TIMEZONE, TzDescr);
}
break;
diff --git a/protocols/Skype/src/skype_own_info.cpp b/protocols/Skype/src/skype_own_info.cpp index 4a3b5415fc..cc5fb4c123 100644 --- a/protocols/Skype/src/skype_own_info.cpp +++ b/protocols/Skype/src/skype_own_info.cpp @@ -3,7 +3,7 @@ void __cdecl CSkypeProto::LoadOwnInfo(void *)
{
mir_ptr<wchar_t> nick( ::db_get_wsa(NULL, this->m_szModuleName, "Nick"));
- if (nick == NULL)
+ if ( !nick)
{
SEString data;
this->account->GetPropFullname(data);
@@ -11,7 +11,7 @@ void __cdecl CSkypeProto::LoadOwnInfo(void *) nick = ::mir_utf8decodeW(data);
::db_set_ws(NULL, this->m_szModuleName, "Nick", nick);
}
- //this->UpdateProfileAvatar(this->account.fetch());
+
this->UpdateProfile(this->account.fetch());
}
@@ -25,7 +25,8 @@ void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) case 0:
{
::GetDlgItemText(hwndPage, IDC_FULLNAME, text, SIZEOF(text));
- this->account->SetStrProperty(Account::P_FULLNAME, (char*)mir_ptr<char>(::mir_utf8encodeW(text)));
+ if (this->account->SetStrProperty(Account::P_FULLNAME, (char*)mir_ptr<char>(::mir_utf8encodeW(text))))
+ ::db_set_ws(NULL, this->m_szModuleName, "Nick", text);
::GetDlgItemText(hwndPage, IDC_MOOD, text, SIZEOF(text));
this->account->SetStrProperty(Account::P_MOOD_TEXT, (char*)mir_ptr<char>(::mir_utf8encodeW(text)));
@@ -49,12 +50,10 @@ void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) this->account->SetIntProperty(Account::P_BIRTHDAY, value);
int lang = ::SendMessage(GetDlgItem(hwndPage, IDC_LANGUAGE), CB_GETCURSEL, 0, 0);
- if (lang != -1) {
- std::wstring key = *(std::wstring *)SendMessage(GetDlgItem(hwndPage, IDC_LANGUAGE), CB_GETITEMDATA, lang, 0);
- this->account->SetStrProperty(
- Account::P_LANGUAGES,
- (char*)mir_ptr<char>(::mir_utf8encodeW(CSkypeProto::languages[key].c_str())));
- }
+ std::wstring key = *(std::wstring *)SendMessage(GetDlgItem(hwndPage, IDC_LANGUAGE), CB_GETITEMDATA, lang, 0);
+ this->account->SetStrProperty(
+ Account::P_LANGUAGES,
+ (char*)mir_ptr<char>(::mir_utf8encodeW(key.c_str())));
}
break;
@@ -74,7 +73,7 @@ void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) ::wcscat(emails, L" ");
::wcscat(emails, text);
}
- this->account->SetStrProperty(Account::P_EMAILS, (char*)mir_ptr<char>(::mir_utf8encodeW(text)));
+ this->account->SetStrProperty(Account::P_EMAILS, (char*)mir_ptr<char>(::mir_utf8encodeW(emails)));
::GetDlgItemText(hwndPage, IDC_MOBPHONE, text, SIZEOF(text));
this->account->SetStrProperty(Account::P_PHONE_MOBILE, (char*)mir_ptr<char>(::mir_utf8encodeW(text)));
@@ -95,10 +94,21 @@ void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) ::GetDlgItemText(hwndPage, IDC_STATE, text, SIZEOF(text));
this->account->SetStrProperty(Account::P_PROVINCE, (char*)mir_ptr<char>(::mir_utf8encodeW(text)));
- int i = ::SendMessage(GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETCURSEL, 0, 0);
- int id = ::SendMessage(GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETITEMDATA, i, 0);
- char *countrystr = (char *)::CallService(MS_UTILS_GETCOUNTRYBYNUMBER, (WPARAM)id, 0);
- this->account->SetStrProperty(Account::P_COUNTRY, countrystr);
+ int i = ::SendMessage(::GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETCURSEL, 0, 0);
+ char *iso = (char *)::SendMessage(::GetDlgItem(hwndPage, IDC_COUNTRY), CB_GETITEMDATA, i, 0);
+ this->account->SetStrProperty(Account::P_COUNTRY, iso);
+
+ HWND ctrl = ::GetDlgItem(hwndPage, IDC_TIMEZONE);
+ i = ::SendMessage(ctrl, CB_GETCURSEL, 0, 0);
+ HANDLE hTimeZone = (HANDLE)::SendMessage(ctrl, CB_GETITEMDATA, i, 0);
+
+ SYSTEMTIME my_st, utc_ts;
+ tmi.getTimeZoneTime(hTimeZone, &my_st);
+ tmi.getTimeZoneTime(UTC_TIME_HANDLE, &utc_ts);
+
+ uint diff_to_UTC_in_seconds = (my_st.wHour - utc_ts.wHour) * 3600 + (my_st.wMinute - utc_ts.wMinute) * 60;
+ uint timezone = 24*3600 + diff_to_UTC_in_seconds;
+ this->account->SetIntProperty(Account::P_TIMEZONE, timezone);
break;
}
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index 693fdc8fc9..c2ba3babdc 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -107,8 +107,7 @@ void CSkypeProto::UpdateProfileCountry(SEObject *obj, HANDLE hContact) mir_ptr<char> isocode(hContact ? ::mir_strdup(obj->GetStrProp(Contact::P_COUNTRY)) : ::mir_strdup(obj->GetStrProp(Account::P_COUNTRY)));
if ( !::strlen(isocode))
{
- country = (char *)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, 0xFFFF, 0);
- ::db_set_ws(hContact, this->m_szModuleName, "Country", ::mir_a2t(country));
+ ::db_unset(hContact, this->m_szModuleName, "Country");
}
else
{
@@ -179,25 +178,21 @@ void CSkypeProto::UpdateProfileHomepage(SEObject *obj, HANDLE hContact) void CSkypeProto::UpdateProfileLanguages(SEObject *obj, HANDLE hContact)
{
mir_ptr<wchar_t> isocodes(hContact ? ::mir_utf8decodeW(obj->GetStrProp(Contact::P_LANGUAGES)) : ::mir_utf8decodeW(obj->GetStrProp(Account::P_LANGUAGES)));
- if ( !::wcslen(isocodes))
- {
- ::db_unset(hContact, this->m_szModuleName, "Language1");
- ::db_unset(hContact, this->m_szModuleName, "Language2");
- ::db_unset(hContact, this->m_szModuleName, "Language3");
- }
- else
+
+ ::db_unset(hContact, this->m_szModuleName, "Language1");
+ ::db_unset(hContact, this->m_szModuleName, "Language2");
+ ::db_unset(hContact, this->m_szModuleName, "Language3");
+
+ StringList langs = isocodes;
+ for (size_t i = 0; i < langs.size(); i++)
{
- StringList langs = isocodes;
- for (size_t i = 0; i < langs.size(); i++)
+ if (CSkypeProto::languages.count(langs[i]))
{
- if (CSkypeProto::languages.count(langs[i]))
- {
- std::stringstream ss;
- ss << "Language" << i + 1;
- std::string key = ss.str();
- std::wstring val = CSkypeProto::languages[langs[i]];
- ::db_set_ws(hContact, this->m_szModuleName, key.c_str(), val.c_str());
- }
+ std::stringstream ss;
+ ss << "Language" << i + 1;
+ std::string key = ss.str();
+ std::wstring val = CSkypeProto::languages[langs[i]];
+ ::db_set_ws(hContact, this->m_szModuleName, key.c_str(), val.c_str());
}
}
}
diff --git a/protocols/Skype/src/skype_proto.cpp b/protocols/Skype/src/skype_proto.cpp index 692f924a54..1dfa99c3c5 100644 --- a/protocols/Skype/src/skype_proto.cpp +++ b/protocols/Skype/src/skype_proto.cpp @@ -6,6 +6,8 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) this->rememberPassword = false;
+ ::InitializeCriticalSection(&this->cl_loading);
+
this->SetAllContactStatus(ID_STATUS_OFFLINE);
DBEVENTTYPEDESCR dbEventType = { sizeof(dbEventType) };
@@ -26,6 +28,8 @@ CSkypeProto::CSkypeProto(const char* protoName, const TCHAR* userName) CSkypeProto::~CSkypeProto()
{
+ ::DeleteCriticalSection(&this->cl_loading);
+
::mir_free(this->login);
if (this->password)
{
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 02e77d000b..ee2cc4da46 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -184,6 +184,8 @@ protected: CContactGroup::Ref commonList;
CContactGroup::Ref authWaitList;
+ CRITICAL_SECTION cl_loading;
+
static std::map<std::wstring, std::wstring> languages;
// account
diff --git a/protocols/Skype/src/skypekit/contact.cpp b/protocols/Skype/src/skypekit/contact.cpp index 3f0a95b717..e1629fb460 100644 --- a/protocols/Skype/src/skypekit/contact.cpp +++ b/protocols/Skype/src/skypekit/contact.cpp @@ -24,9 +24,9 @@ SEString CContact::GetNick() CContact::AVAILABILITY availability;
this->GetPropAvailability(availability);
if (availability == CContact::SKYPEOUT)
- result = this->GetSid();
+ this->GetPropPstnnumber(result);
else
- this->GetPropDisplayname(result);
+ this->GetPropFullname(result);
return result;
}
|