From 00c866aaa0b79c354f9c71ca5d61f57daeec6e6a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Jul 2013 20:01:20 +0000 Subject: protocol DB helpers for Skype git-svn-id: http://svn.miranda-ng.org/main/trunk@5313 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_account.cpp | 6 +- protocols/Skype/src/skype_avatars.cpp | 8 +- protocols/Skype/src/skype_blocked.cpp | 8 +- protocols/Skype/src/skype_chat.cpp | 4 +- protocols/Skype/src/skype_contacts.cpp | 51 +++++------- protocols/Skype/src/skype_dialogs.cpp | 30 ++++--- protocols/Skype/src/skype_menus.cpp | 10 +-- protocols/Skype/src/skype_own_info.cpp | 2 +- protocols/Skype/src/skype_profile.cpp | 148 ++++++++++++++++----------------- 9 files changed, 125 insertions(+), 142 deletions(-) (limited to 'protocols/Skype/src') diff --git a/protocols/Skype/src/skype_account.cpp b/protocols/Skype/src/skype_account.cpp index 8834318596..a7a9401191 100644 --- a/protocols/Skype/src/skype_account.cpp +++ b/protocols/Skype/src/skype_account.cpp @@ -137,18 +137,18 @@ void CSkypeProto::LogOut() void CSkypeProto::SetAccountSettings() { - int port = ::db_get_w(NULL, this->m_szModuleName, "Port", rand() % 10000 + 10000); + int port = this->getWord("Port", rand() % 10000 + 10000); this->Log(L"Setting port number to %d", port); this->SetInt(SETUPKEY_PORT, port); - bool useAlternativePorts = ::db_get_b(NULL, this->m_szModuleName, "UseAlternativePorts", 1) > 0; + bool useAlternativePorts = this->getByte("UseAlternativePorts", 1) > 0; if (useAlternativePorts) this->Log(L"Setting listening of alternative ports (80, 443)"); this->SetInt(SETUPKEY_DISABLE_PORT80, (int)!useAlternativePorts); // Create default group for new contacts DBVARIANT dbv = {0}; - if ( !::db_get_ts(NULL, m_szModuleName, SKYPE_SETTINGS_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0) + if ( !getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv) && lstrlen(dbv.ptszVal) > 0) { this->Log(L"Setting default group for new contacts"); ::CallService(MS_CLIST_GROUPCREATE, 0, (LPARAM)dbv.ptszVal); diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index bf9fae9136..4f29a2e8cf 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -88,10 +88,8 @@ INT_PTR __cdecl CSkypeProto::GetAvatarInfo(WPARAM, LPARAM lParam) { PROTO_AVATAR_INFORMATIONW *pai = (PROTO_AVATAR_INFORMATIONW *)lParam; - if (::db_get_dw(pai->hContact, this->m_szModuleName, "AvatarTS", 0)) - { + if (this->getDword(pai->hContact, "AvatarTS", 0)) return GAIR_NOAVATAR; - } ptrW sid = ::db_get_wsa(pai->hContact, this->m_szModuleName, SKYPE_SETTINGS_SID); if (sid) @@ -205,12 +203,12 @@ INT_PTR __cdecl CSkypeProto::SetMyAvatar(WPARAM, LPARAM lParam) } uint newTS = this->account->GetUintProp(Account::P_AVATAR_IMAGE); - ::db_set_dw(NULL, this->m_szModuleName, "AvatarTS", newTS); + this->setDword("AvatarTS", newTS); return 0; } this->account->SetBinProperty(Account::P_AVATAR_IMAGE, SEBinary()); - ::db_unset(NULL, this->m_szModuleName, "AvatarTS"); + this->delSetting("AvatarTS"); return 0; } diff --git a/protocols/Skype/src/skype_blocked.cpp b/protocols/Skype/src/skype_blocked.cpp index a60e25b282..511c0fd423 100644 --- a/protocols/Skype/src/skype_blocked.cpp +++ b/protocols/Skype/src/skype_blocked.cpp @@ -27,15 +27,15 @@ int CSkypeProto::BlockCommand(WPARAM wParam, LPARAM lParam) this->contactList.remove_val(contact); ::CallService(MS_DB_CONTACT_DELETE, wParam, 0); } - else if (::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) > 0) - ::db_set_w(hContact, this->m_szModuleName, "Status", ID_STATUS_OFFLINE); + else if (this->getByte(hContact, "IsSkypeOut", 0) > 0) + this->setWord(hContact, "Status", ID_STATUS_OFFLINE); } } else { if (contact->SetBlocked(false)) - if (::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) > 0) - ::db_set_w(hContact, this->m_szModuleName, "Status", ID_STATUS_ONTHEPHONE); + if (this->getByte(hContact, "IsSkypeOut", 0) > 0) + this->setWord(hContact, "Status", ID_STATUS_ONTHEPHONE); } } diff --git a/protocols/Skype/src/skype_chat.cpp b/protocols/Skype/src/skype_chat.cpp index d22de3c118..ef9ce957a8 100644 --- a/protocols/Skype/src/skype_chat.cpp +++ b/protocols/Skype/src/skype_chat.cpp @@ -1226,7 +1226,7 @@ INT_PTR CALLBACK CSkypeProto::ChatRoomProc(HWND hwndDlg, UINT msg, WPARAM wParam bool CSkypeProto::IsChatRoom(HANDLE hContact) { - return ::db_get_b(hContact, this->m_szModuleName, "ChatRoom", 0) == 1; + return this->getByte(hContact, "ChatRoom", 0) == 1; } INT_PTR CSkypeProto::CreateChatRoomCommand(WPARAM, LPARAM) @@ -1515,7 +1515,7 @@ int __cdecl CSkypeProto::OnGCMenuHook(WPARAM, LPARAM lParam) HANDLE hContact = this->GetContactBySid(gcmi->pszUID); if (hContact == NULL) DisableChatMenuItem(ICM_DETAILS); - else if(::db_get_b(hContact, this->m_szModuleName, "Auth", 0) == 0) + else if(this->getByte(hContact, "Auth", 0) == 0) DisableChatMenuItem(ICM_AUTH_REQUEST); } else diff --git a/protocols/Skype/src/skype_contacts.cpp b/protocols/Skype/src/skype_contacts.cpp index b6a3183e9c..a1320dd145 100644 --- a/protocols/Skype/src/skype_contacts.cpp +++ b/protocols/Skype/src/skype_contacts.cpp @@ -4,24 +4,22 @@ void CSkypeProto::UpdateContactAuthState(HANDLE hContact, const ContactRef &cont { uint newTS = 0; contact->GetPropAuthreqTimestamp(newTS); - DWORD oldTS = ::db_get_dw(NULL, this->m_szModuleName, "AuthTS", 0); + DWORD oldTS = this->getDword("AuthTS", 0); if (newTS > oldTS) { bool result; if (contact->HasAuthorizedMe(result) && !result) - { - ::db_set_b(hContact, this->m_szModuleName, "Auth", !result); - } + this->setByte(hContact, "Auth", !result); else { - ::db_unset(hContact, this->m_szModuleName, "Auth"); + this->delSetting(hContact, "Auth"); if (contact->IsMemberOfHardwiredGroup(CContactGroup::ALL_BUDDIES, result) && !result) - ::db_set_b(hContact, this->m_szModuleName, "Grant", !result); + this->setByte(hContact, "Grant", !result); else - ::db_unset(hContact, this->m_szModuleName, "Grant"); + this->delSetting(hContact, "Grant"); } - ::db_set_dw(hContact, this->m_szModuleName, "AuthTS", newTS); + this->setDword(hContact, "AuthTS", newTS); } } @@ -29,16 +27,16 @@ void CSkypeProto::UpdateContactStatus(HANDLE hContact, const ContactRef &contact { Contact::AVAILABILITY availability; contact->GetPropAvailability(availability); - ::db_set_w(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, CSkypeProto::SkypeToMirandaStatus(availability)); + this->setWord(hContact, SKYPE_SETTINGS_STATUS, CSkypeProto::SkypeToMirandaStatus(availability)); if (availability == Contact::SKYPEOUT) - ::db_set_w(hContact, this->m_szModuleName, SKYPE_SETTINGS_STATUS, ID_STATUS_ONTHEPHONE); + this->setWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_ONTHEPHONE); else { if (availability == Contact::PENDINGAUTH) - ::db_set_b(hContact, this->m_szModuleName, "Auth", 1); + this->setByte(hContact, "Auth", 1); else - ::db_unset(hContact, this->m_szModuleName, "Auth"); + this->delSetting(hContact, "Auth"); } } @@ -47,7 +45,7 @@ void CSkypeProto::UpdateContactClient(HANDLE hContact, const ContactRef &contact bool isMobile = false; contact->HasCapability(Contact::CAPABILITY_MOBILE_DEVICE, isMobile/*, true*/); - ::db_set_ws(hContact, this->m_szModuleName, "MirVer", isMobile ? L"SkypeMobile" : L"Skype"); + this->setTString(hContact, "MirVer", isMobile ? L"SkypeMobile" : L"Skype"); } void CSkypeProto::UpdateContactOnlineSinceTime(HANDLE hContact, const ContactRef &contact) @@ -56,16 +54,16 @@ void CSkypeProto::UpdateContactOnlineSinceTime(HANDLE hContact, const ContactRef contact->GetPropLastonlineTimestamp(newTS); DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "OnlineSinceTS", 0); if (newTS > oldTS) - ::db_set_dw(hContact, this->m_szModuleName, "OnlineSinceTS", newTS); + this->setDword(hContact, "OnlineSinceTS", newTS); } void CSkypeProto::UpdateContactLastEventDate(HANDLE hContact, const ContactRef &contact) { uint newTS = 0; contact->GetPropLastusedTimestamp(newTS); - DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "LastEventDateTS", 0); + DWORD oldTS = this->getDword(hContact, "LastEventDateTS", 0); if (newTS > oldTS) - ::db_set_dw(hContact, this->m_szModuleName, "LastEventDateTS", newTS); + this->setDword(hContact, "LastEventDateTS", newTS); } void CSkypeProto::OnContactChanged(const ContactRef &contact, int prop) @@ -86,7 +84,7 @@ void CSkypeProto::OnContactChanged(const ContactRef &contact, int prop) { uint newTS = 0; contact->GetPropAuthreqTimestamp(newTS); - DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "AuthTS", 0); + DWORD oldTS = this->getDword(hContact, "AuthTS", 0); if (newTS > oldTS) this->RaiseAuthRequestEvent(newTS, contact); } @@ -153,7 +151,6 @@ void CSkypeProto::OnContactListChanged(const ContactRef &contact) bool CSkypeProto::IsProtoContact(HANDLE hContact) { return ::lstrcmpiA(::GetContactProto(hContact), this->m_szModuleName) == 0; - //return ::CallService(MS_PROTO_ISPROTOONCONTACT, (WPARAM)hContact, (LPARAM)this->m_szModuleName) < 0; } HANDLE CSkypeProto::GetContactBySid(const wchar_t *sid) @@ -212,7 +209,7 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary) switch(availability) { case CContact::SKYPEOUT: - ::db_set_b(hContact, this->m_szModuleName, "IsSkypeOut", 1); + this->setByte(hContact, "IsSkypeOut", 1); break; case CContact::PENDINGAUTH: @@ -225,16 +222,16 @@ HANDLE CSkypeProto::AddContact(CContact::Ref contact, bool isTemporary) break; default: - ::db_unset(hContact, this->m_szModuleName, "IsSkypeOut"); + this->delSetting(hContact, "IsSkypeOut"); ::db_unset(hContact, "CList", "Hidden"); ::db_unset(hContact, "CList", "NotOnList"); } - ::db_set_ws(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID, sid); - ::db_set_ws(hContact, this->m_szModuleName, "Nick", nick); + this->setTString(hContact, SKYPE_SETTINGS_SID, sid); + this->setTString(hContact, "Nick", nick); DBVARIANT dbv; - if ( !::db_get_ts(NULL, this->m_szModuleName, SKYPE_SETTINGS_DEF_GROUP, &dbv)) + if ( !this->getTString(SKYPE_SETTINGS_DEF_GROUP, &dbv)) { ::db_set_ts(hContact, "CList", "Group", dbv.ptszVal); ::db_free(&dbv); @@ -299,11 +296,7 @@ void __cdecl CSkypeProto::LoadAuthWaitList(void*) bool CSkypeProto::IsContactOnline(HANDLE hContact) { - return ::db_get_w( - hContact, - this->m_szModuleName, - SKYPE_SETTINGS_STATUS, - ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE; + return this->getWord(hContact, SKYPE_SETTINGS_STATUS, ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE; } void CSkypeProto::SetAllContactStatus(int status) @@ -312,7 +305,7 @@ void CSkypeProto::SetAllContactStatus(int status) for (HANDLE hContact = ::db_find_first(this->m_szModuleName); hContact; hContact = ::db_find_next(hContact, this->m_szModuleName)) { - if (::db_get_b(hContact, this->m_szModuleName, "IsSkypeOut", 0) != 0) + if (this->getByte(hContact, "IsSkypeOut", 0) != 0) continue; if (this->IsChatRoom(hContact)) continue; diff --git a/protocols/Skype/src/skype_dialogs.cpp b/protocols/Skype/src/skype_dialogs.cpp index 010e599ec4..f907eedb90 100644 --- a/protocols/Skype/src/skype_dialogs.cpp +++ b/protocols/Skype/src/skype_dialogs.cpp @@ -585,7 +585,7 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA // nick DBVARIANT dbv; - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "Nick", &dbv)) + if ( !ppro->getTString("Nick", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_FULLNAME, dbv.ptszVal); ::db_free(&dbv); @@ -594,7 +594,7 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA ::SetDlgItemText(hwndDlg, IDC_FULLNAME, _T("")); // homepage - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "Homepage", &dbv)) + if ( !ppro->getTString("Homepage", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_HOMEPAGE, dbv.ptszVal); ::db_free(&dbv); @@ -603,7 +603,7 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA ::SetDlgItemText(hwndDlg, IDC_HOMEPAGE, _T("")); // about - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "About", &dbv)) { + if ( !ppro->getTString("About", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_ABOUT, dbv.ptszVal); ::db_free(&dbv); } @@ -611,7 +611,7 @@ INT_PTR CALLBACK CSkypeProto::PersonalSkypeDlgProc(HWND hwndDlg, UINT msg, WPARA ::SetDlgItemText(hwndDlg, IDC_ABOUT, _T("")); // mood - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "XStatusMsg", &dbv)) { + if ( !ppro->getTString("XStatusMsg", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_MOOD, dbv.ptszVal); ::db_free(&dbv); } @@ -664,42 +664,42 @@ INT_PTR CALLBACK CSkypeProto::ContactSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); DBVARIANT dbv; - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "Cellular", &dbv)) { + if ( !ppro->getTString("Cellular", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_MOBPHONE, dbv.ptszVal); ::db_free(&dbv); } else ::SetDlgItemText(hwndDlg, IDC_MOBPHONE, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "Phone", &dbv)) { + if ( !ppro->getTString("Phone", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_HOMEPHONE, dbv.ptszVal); ::db_free(&dbv); } else ::SetDlgItemText(hwndDlg, IDC_HOMEPHONE, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "CompanyPhone", &dbv)) { + if ( !ppro->getTString("CompanyPhone", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_OFFICEPHONE, dbv.ptszVal); ::db_free(&dbv); } else ::SetDlgItemText(hwndDlg, IDC_OFFICEPHONE, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "e-mail0", &dbv)) { + if ( !ppro->getTString("e-mail0", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_EMAIL1, dbv.ptszVal); ::db_free(&dbv); } else ::SetDlgItemText(hwndDlg, IDC_EMAIL1, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "e-mail1", &dbv)) { + if ( !ppro->getTString("e-mail1", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_EMAIL2, dbv.ptszVal); ::db_free(&dbv); } else ::SetDlgItemText(hwndDlg, IDC_EMAIL2, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "e-mail2", &dbv)) { + if ( !ppro->getTString("e-mail2", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_EMAIL3, dbv.ptszVal); ::db_free(&dbv); } @@ -749,19 +749,17 @@ INT_PTR CALLBACK CSkypeProto::HomeSkypeDlgProc(HWND hwndDlg, UINT msg, WPARAM wP ::SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); DBVARIANT dbv; - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "City", &dbv)) { + if ( !ppro->getTString("City", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_CITY, dbv.ptszVal); ::db_free(&dbv); } - else - ::SetDlgItemText(hwndDlg, IDC_CITY, _T("")); + else ::SetDlgItemText(hwndDlg, IDC_CITY, _T("")); - if ( !::db_get_ts(NULL, ppro->m_szModuleName, "State", &dbv)) { + if ( !ppro->getTString("State", &dbv)) { ::SetDlgItemText(hwndDlg, IDC_STATE, dbv.ptszVal); ::db_free(&dbv); } - else - ::SetDlgItemText(hwndDlg, IDC_STATE, _T("")); + else ::SetDlgItemText(hwndDlg, IDC_STATE, _T("")); ptrW countr(::db_get_wsa(NULL, ppro->m_szModuleName, "Country")); for (int i = 0; i < g_cbCountries; i++) diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index e9d5846fd6..d1b46c376d 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -24,8 +24,8 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM) { bool ctrlPressed = (::GetKeyState(VK_CONTROL) & 0x8000) != 0; - bool authNeed = ::db_get_b(hContact, this->m_szModuleName, "Auth", 0) > 0; - bool grantNeed = ::db_get_b(hContact, this->m_szModuleName, "Grant", 0) > 0; + bool authNeed = this->getByte(hContact, "Auth", 0) > 0; + bool grantNeed = this->getByte(hContact, "Grant", 0) > 0; ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_REQUEST], ctrlPressed || authNeed); ::Menu_ShowItem(CSkypeProto::contactMenuItems[CMI_AUTH_GRANT], ctrlPressed || grantNeed); @@ -84,8 +84,8 @@ int CSkypeProto::GrantAuth(WPARAM wParam, LPARAM lParam) { if (contact->SetBuddyStatus(true)) { - ::db_unset(hContact, this->m_szModuleName, "Auth"); - ::db_unset(hContact, this->m_szModuleName, "Grant"); + this->delSetting(hContact, "Auth"); + this->delSetting(hContact, "Grant"); } } @@ -100,7 +100,7 @@ int CSkypeProto::RevokeAuth(WPARAM wParam, LPARAM lParam) if (this->GetContact(sid, contact)) { if (contact->SetBuddyStatus(false)) - ::db_set_b(hContact, this->m_szModuleName, "Grant", 1); + this->setByte(hContact, "Grant", 1); this->contactList.remove_val(contact); } diff --git a/protocols/Skype/src/skype_own_info.cpp b/protocols/Skype/src/skype_own_info.cpp index 57e2da24f5..f56178229a 100644 --- a/protocols/Skype/src/skype_own_info.cpp +++ b/protocols/Skype/src/skype_own_info.cpp @@ -45,7 +45,7 @@ void CSkypeProto::SaveOwnInfoToServer(HWND hwndPage, int iPage) { ::GetDlgItemText(hwndPage, IDC_FULLNAME, text, SIZEOF(text)); if (this->account->SetStrProperty(Account::P_FULLNAME, (char *)ptrA(::mir_utf8encodeW(text)))) - ::db_set_ws(NULL, this->m_szModuleName, "Nick", text); + this->setTString("Nick", text); ::GetDlgItemText(hwndPage, IDC_MOOD, text, SIZEOF(text)); this->account->SetStrProperty(Account::P_MOOD_TEXT, (char *)ptrA(::mir_utf8encodeW(text))); diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index b1870c5856..699f667491 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -6,7 +6,7 @@ void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) uint newTS = obj->GetUintProp(/* *::P_AVATAR_TIMESTAMP */ 182); //if (!newTS) return; //uncomment when skypekit will be work correctly - DWORD oldTS = ::db_get_dw(hContact, this->m_szModuleName, "AvatarTS", 0); + DWORD oldTS = this->getDword(hContact, "AvatarTS", 0); ptrW path( this->GetContactAvatarFilePath(hContact)); bool isAvatarFileExists = CSkypeProto::FileExists(path); @@ -21,7 +21,7 @@ void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) ::fwrite(data.data(), sizeof(char), data.size(), fp); ::fclose(fp); - ::db_set_dw(hContact, this->m_szModuleName, "AvatarTS", newTS); + this->setDword(hContact, "AvatarTS", newTS); if (hContact) { @@ -55,9 +55,9 @@ void CSkypeProto::UpdateProfileAboutText(SEObject *obj, HANDLE hContact) { ptrW aboutText(::mir_utf8decodeW(obj->GetStrProp(/* *::P_ABOUT */ 18))); if ( !::wcslen(aboutText)) - ::db_unset(hContact, this->m_szModuleName, "About"); + this->delSetting(hContact, "About"); else - ::db_set_ws(hContact, this->m_szModuleName, "About", aboutText); + this->setTString(hContact, "About", aboutText); } void CSkypeProto::UpdateProfileBirthday(SEObject *obj, HANDLE hContact) @@ -78,22 +78,22 @@ void CSkypeProto::UpdateProfileBirthday(SEObject *obj, HANDLE hContact) else if(sToday.wYear == year && sToday.wMonth > month) return; else if(sToday.wYear == year && sToday.wMonth == month && sToday.wDay >= day) return; - ::db_set_b(hContact, this->m_szModuleName, "BirthDay", day); - ::db_set_b(hContact, this->m_szModuleName, "BirthMonth", month); - ::db_set_w(hContact, this->m_szModuleName, "BirthYear", year); + this->setByte(hContact, "BirthDay", day); + this->setByte(hContact, "BirthMonth", month); + this->setWord(hContact, "BirthYear", year); int nAge = sToday.wYear - year; if (sToday.wMonth < month || (sToday.wMonth == month && sToday.wDay < day)) nAge--; if (nAge) - ::db_set_w(hContact, this->m_szModuleName, "Age", ( WORD )nAge ); + this->setWord(hContact, "Age", (WORD)nAge ); } else { - ::db_unset(hContact, this->m_szModuleName, "BirthDay"); - ::db_unset(hContact, this->m_szModuleName, "BirthMonth"); - ::db_unset(hContact, this->m_szModuleName, "BirthYear"); - ::db_unset(hContact, this->m_szModuleName, "Age"); + this->delSetting(hContact, "BirthDay"); + this->delSetting(hContact, "BirthMonth"); + this->delSetting(hContact, "BirthYear"); + this->delSetting(hContact, "Age"); } } @@ -101,9 +101,9 @@ void CSkypeProto::UpdateProfileCity(SEObject *obj, HANDLE hContact) { ptrW city(::mir_utf8decodeW(obj->GetStrProp(/* *::P_CITY */ 12))); if ( !::wcslen(city)) - ::db_unset(hContact, this->m_szModuleName, "City"); + this->delSetting(hContact, "City"); else - ::db_set_ws(hContact, this->m_szModuleName, "City", city); + this->setTString(hContact, "City", city); } void CSkypeProto::UpdateProfileCountry(SEObject *obj, HANDLE hContact) @@ -111,13 +111,11 @@ void CSkypeProto::UpdateProfileCountry(SEObject *obj, HANDLE hContact) char *country; ptrA isocode(::mir_strdup(obj->GetStrProp(/* *::P_COUNTRY */ 10))); if ( !::strlen(isocode)) - { - ::db_unset(hContact, this->m_szModuleName, "Country"); - } + this->delSetting(hContact, "Country"); else { country = (char *)CallService(MS_UTILS_GETCOUNTRYBYISOCODE, (WPARAM)isocode, 0); - ::db_set_ws(hContact, this->m_szModuleName, "Country", _A2T(country)); + this->setTString(hContact, "Country", _A2T(country)); } } @@ -126,9 +124,9 @@ void CSkypeProto::UpdateProfileEmails(SEObject *obj, HANDLE hContact) ptrW emails(::mir_utf8decodeW(obj->GetStrProp(/* *::P_EMAILS */ 16))); if (::wcscmp(emails, L"") == 0) { - ::db_unset(hContact, this->m_szModuleName, "e-mail0"); - ::db_unset(hContact, this->m_szModuleName, "e-mail1"); - ::db_unset(hContact, this->m_szModuleName, "e-mail2"); + this->delSetting(hContact, "e-mail0"); + this->delSetting(hContact, "e-mail1"); + this->delSetting(hContact, "e-mail2"); } else { @@ -139,7 +137,7 @@ void CSkypeProto::UpdateProfileEmails(SEObject *obj, HANDLE hContact) ss << "e-mail" << i; std::string key = ss.str(); - ::db_set_ws(hContact, this->m_szModuleName, key.c_str(), emls[i]); + this->setTString(hContact, key.c_str(), emls[i]); } } } @@ -149,16 +147,16 @@ void CSkypeProto::UpdateProfileFullName(SEObject *obj, HANDLE hContact) ptrW fullname(::mir_utf8decodeW(obj->GetStrProp(/* *::P_FULLNAME */ 5))); if ( !::wcslen(fullname)) { - ::db_unset(hContact, this->m_szModuleName, "FirstName"); - ::db_unset(hContact, this->m_szModuleName, "LastName"); + this->delSetting(hContact, "FirstName"); + this->delSetting(hContact, "LastName"); } else { StringList names = fullname; - ::db_set_ws(hContact, this->m_szModuleName, "FirstName", names[0]); + this->setTString(hContact, "FirstName", names[0]); if (names.size() > 1) - ::db_set_ws(hContact, this->m_szModuleName, "LastName", names[1]); + this->setTString(hContact, "LastName", names[1]); } } @@ -166,27 +164,27 @@ void CSkypeProto::UpdateProfileGender(SEObject *obj, HANDLE hContact) { uint data = obj->GetUintProp(/* *::P_GENDER */ 8); if (data) - ::db_set_b(hContact, this->m_szModuleName, "Gender", (BYTE)(data == 1 ? 'M' : 'F')); + this->setByte(hContact, "Gender", (BYTE)(data == 1 ? 'M' : 'F')); else - ::db_unset(hContact, this->m_szModuleName, "Gender"); + this->delSetting(hContact, "Gender"); } void CSkypeProto::UpdateProfileHomepage(SEObject *obj, HANDLE hContact) { ptrW homepage(::mir_utf8decodeW(obj->GetStrProp(/* *::P_HOMEPAGE */ 17))); if (::wcscmp(homepage, L"") == 0) - ::db_unset(hContact, this->m_szModuleName, "Homepage"); + this->delSetting(hContact, "Homepage"); else - ::db_set_ws(hContact, this->m_szModuleName, "Homepage", homepage); + this->setTString(hContact, "Homepage", homepage); } void CSkypeProto::UpdateProfileLanguages(SEObject *obj, HANDLE hContact) { ptrW isocodes(::mir_utf8decodeW(obj->GetStrProp(/* *::P_LANGUAGES */ 9))); - ::db_unset(hContact, this->m_szModuleName, "Language1"); - ::db_unset(hContact, this->m_szModuleName, "Language2"); - ::db_unset(hContact, this->m_szModuleName, "Language3"); + this->delSetting(hContact, "Language1"); + this->delSetting(hContact, "Language2"); + this->delSetting(hContact, "Language3"); StringList langs = isocodes; for (size_t i = 0; i < langs.size(); i++) @@ -197,7 +195,7 @@ void CSkypeProto::UpdateProfileLanguages(SEObject *obj, HANDLE hContact) 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()); + this->setTString(hContact, key.c_str(), val.c_str()); } } } @@ -206,9 +204,9 @@ void CSkypeProto::UpdateProfileMobilePhone(SEObject *obj, HANDLE hContact) { ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_MOBILE */ 15))); if ( !::wcslen(phone)) - ::db_unset(hContact, this->m_szModuleName, "Cellular"); + this->delSetting(hContact, "Cellular"); else - ::db_set_ws(hContact, this->m_szModuleName, "Cellular", phone); + this->setTString(hContact, "Cellular", phone); } void CSkypeProto::UpdateProfileNick(SEObject *obj, HANDLE hContact) @@ -223,45 +221,45 @@ void CSkypeProto::UpdateProfileNick(SEObject *obj, HANDLE hContact) nick = ::mir_utf8decodeW(obj->GetStrProp(Account::P_FULLNAME)); if ( !::wcslen(nick)) - ::db_unset(hContact, this->m_szModuleName, "Nick"); + this->delSetting(hContact, "Nick"); else - ::db_set_ws(hContact, this->m_szModuleName, "Nick", nick); + this->setTString(hContact, "Nick", nick); } void CSkypeProto::UpdateProfilePhone(SEObject *obj, HANDLE hContact) { ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_MOBILE */ 13))); if ( !::wcslen(phone)) - ::db_unset(hContact, this->m_szModuleName, "Phone"); + this->delSetting(hContact, "Phone"); else - ::db_set_ws(hContact, this->m_szModuleName, "Phone", phone); + this->setTString(hContact, "Phone", phone); } void CSkypeProto::UpdateProfileOfficePhone(SEObject *obj, HANDLE hContact) { ptrW phone(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PHONE_OFFICE */ 14))); if ( !::wcslen(phone)) - ::db_unset(hContact, this->m_szModuleName, "CompanyPhone"); + this->delSetting(hContact, "CompanyPhone"); else - ::db_set_ws(hContact, this->m_szModuleName, "CompanyPhone", phone); + this->setTString(hContact, "CompanyPhone", phone); } void CSkypeProto::UpdateProfileState(SEObject *obj, HANDLE hContact) { ptrW state(::mir_utf8decodeW(obj->GetStrProp(/* *::P_PROVINCE */ 11))); if ( !::wcslen(state)) - ::db_unset(hContact, this->m_szModuleName, "State"); + this->delSetting(hContact, "State"); else - ::db_set_ws(hContact, this->m_szModuleName, "State", state); + this->setTString(hContact, "State", state); } void CSkypeProto::UpdateProfileStatusMessage(SEObject *obj, HANDLE hContact) { ptrW statusMessage(::mir_utf8decodeW(obj->GetStrProp(/* *::P_MOOD_TEXT */ 26))); if ( !::wcslen(statusMessage)) - ::db_unset(hContact, this->m_szModuleName, "XStatusMsg"); + this->delSetting(hContact, "XStatusMsg"); else - ::db_set_ws(hContact, this->m_szModuleName, "XStatusMsg", statusMessage); + this->setTString(hContact, "XStatusMsg", statusMessage); } void CSkypeProto::UpdateProfileTimezone(SEObject *obj, HANDLE hContact) @@ -284,10 +282,9 @@ void CSkypeProto::UpdateProfileTimezone(SEObject *obj, HANDLE hContact) int nTz = ::_wtoi(timeshift) * -2; nTz += (nTz < 0 ? -1 : 1) * (szMin ? _ttoi( szMin + 1 ) / 30 : 0); - ::db_set_b(hContact, this->m_szModuleName, "Timezone", (signed char)nTz); + this->setByte(hContact, "Timezone", (signed char)nTz); } - else - ::db_unset(hContact, this->m_szModuleName, "Timezone"); + else this->delSetting(hContact, "Timezone"); } void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) @@ -296,33 +293,30 @@ void CSkypeProto::UpdateProfile(SEObject *obj, HANDLE hContact) this->UpdateProfileAvatar(obj, hContact); uint newTS = hContact ? obj->GetUintProp(Contact::P_PROFILE_TIMESTAMP) : obj->GetUintProp(Account::P_PROFILE_TIMESTAMP); - //if (newTS > ::db_get_dw(hContact, this->m_szModuleName, "ProfileTS", 0)) - //{ - 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->UpdateProfileNick(obj, hContact); - this->UpdateProfilePhone(obj, hContact); - this->UpdateProfileOfficePhone(obj, hContact); - this->UpdateProfileState(obj, hContact); - this->UpdateProfileStatusMessage(obj, hContact); - this->UpdateProfileTimezone(obj, hContact); - - if (hContact) - { - ContactRef ref(obj->getOID()); - this->UpdateContactClient(hContact, ref); - this->UpdateContactLastEventDate(hContact, ref); - this->UpdateContactOnlineSinceTime(hContact, ref); - } + 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->UpdateProfileNick(obj, hContact); + this->UpdateProfilePhone(obj, hContact); + this->UpdateProfileOfficePhone(obj, hContact); + this->UpdateProfileState(obj, hContact); + this->UpdateProfileStatusMessage(obj, hContact); + this->UpdateProfileTimezone(obj, hContact); + + if (hContact) + { + ContactRef ref(obj->getOID()); + this->UpdateContactClient(hContact, ref); + this->UpdateContactLastEventDate(hContact, ref); + this->UpdateContactOnlineSinceTime(hContact, ref); + } - ::db_set_dw(hContact, this->m_szModuleName, "ProfileTS", newTS); - //} + this->setDword(hContact, "ProfileTS", newTS); } \ No newline at end of file -- cgit v1.2.3