From bfad803f0247a7395ed67eb04c190b3dfa511b0c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 10 Jul 2013 20:20:29 +0000 Subject: protocol DB helpers for AimOscar git-svn-id: http://svn.miranda-ng.org/main/trunk@5315 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/AimOscar/src/avatars.cpp | 9 +++------ protocols/AimOscar/src/server.cpp | 2 +- protocols/AimOscar/src/ui.cpp | 8 ++++---- protocols/AimOscar/src/utility.cpp | 24 ++++++++---------------- 4 files changed, 16 insertions(+), 27 deletions(-) diff --git a/protocols/AimOscar/src/avatars.cpp b/protocols/AimOscar/src/avatars.cpp index a25188706b..7f54961398 100644 --- a/protocols/AimOscar/src/avatars.cpp +++ b/protocols/AimOscar/src/avatars.cpp @@ -82,8 +82,8 @@ void CAimProto::avatar_request_handler(HANDLE hContact, char* hash, unsigned cha { if (saved_hash) { - db_unset(hContact, m_szModuleName, AIM_KEY_AHT); - db_unset(hContact, m_szModuleName, AIM_KEY_AH); + delSetting(hContact, AIM_KEY_AHT); + delSetting(hContact, AIM_KEY_AH); ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } @@ -117,11 +117,8 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0); mir_free(my_sn); } -// else -// ShowError("Cannot set avatar. File '%s' could not be created/overwritten", file); } - else - LOG("AIM sent avatar of zero length for %s.(Usually caused by repeated request for the same icon)", sn); + else LOG("AIM sent avatar of zero length for %s.(Usually caused by repeated request for the same icon)", sn); ProtoBroadcastAck(AI.hContact, ACKTYPE_AVATAR, res ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, &AI, 0); } diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp index 9726d9468e..9359813aba 100644 --- a/protocols/AimOscar/src/server.cpp +++ b/protocols/AimOscar/src/server.cpp @@ -265,7 +265,7 @@ void CAimProto::snac_user_online(SNAC &snac)//family 0x0003 if (icq) setString(hContact, "Transport", "ICQ"); else - db_unset(hContact, m_szModuleName, "Transport" ); + delSetting(hContact, "Transport" ); if (admin_aol) setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_ADMIN); diff --git a/protocols/AimOscar/src/ui.cpp b/protocols/AimOscar/src/ui.cpp index 7011320cab..b7bac0cb13 100644 --- a/protocols/AimOscar/src/ui.cpp +++ b/protocols/AimOscar/src/ui.cpp @@ -880,7 +880,7 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (strlen(str)>0) ppro->setString(AIM_KEY_SN, str); else - db_unset(NULL, ppro->m_szModuleName, AIM_KEY_SN); + ppro->delSetting(AIM_KEY_SN); //END SN //NK @@ -900,7 +900,7 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str); ppro->setString(AIM_KEY_PW, str); } - else db_unset(NULL, ppro->m_szModuleName, AIM_KEY_PW); + else ppro->delSetting(AIM_KEY_PW); //END PW //HN @@ -908,7 +908,7 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (strlen(str)>0 && strcmp(str, AIM_DEFAULT_SERVER)) ppro->setString(AIM_KEY_HN, str); else - db_unset(NULL, ppro->m_szModuleName, AIM_KEY_HN); + ppro->delSetting(AIM_KEY_HN); //END HN //Delivery Confirmation @@ -936,7 +936,7 @@ static INT_PTR CALLBACK options_dialog(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (port > 0 && port != ppro->getByte(AIM_KEY_DSSL, 0) ? AIM_DEFAULT_PORT : AIM_DEFAULT_SSL_PORT) ppro->setWord(AIM_KEY_PN, (WORD)port); else - db_unset(NULL, ppro->m_szModuleName, AIM_KEY_PN); + ppro->delSetting(AIM_KEY_PN); //END PN //Disable Account Type Icons diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp index db6dba0590..2e4ed835c3 100644 --- a/protocols/AimOscar/src/utility.cpp +++ b/protocols/AimOscar/src/utility.cpp @@ -292,7 +292,7 @@ void CAimProto::add_contact_to_group(HANDLE hContact, const char* new_group) LOG("Removing buddy %s:%u %s:%u from the serverside list", dbv.pszVal, item_id, old_group, old_group_id); aim_delete_contact(hServerConn, seqno, dbv.pszVal, item_id, old_group_id, 0, is_not_in_list); update_server_group(old_group, old_group_id); - db_unset(hContact, m_szModuleName, AIM_KEY_NIL); + delSetting(hContact, AIM_KEY_NIL); } aim_ssi_update(hServerConn, seqno, false); @@ -516,7 +516,8 @@ int CAimProto::deleteBuddyId(HANDLE hContact, int i) { char item[sizeof(AIM_KEY_BI)+10]; mir_snprintf(item, sizeof(AIM_KEY_BI)+10, AIM_KEY_BI"%d", i); - return db_unset(hContact, m_szModuleName, item); + delSetting(hContact, item); + return 0; } unsigned short CAimProto::getGroupId(HANDLE hContact, int i) @@ -537,7 +538,8 @@ int CAimProto::deleteGroupId(HANDLE hContact, int i) { char item[sizeof(AIM_KEY_GI)+10]; mir_snprintf(item, sizeof(AIM_KEY_GI)+10, AIM_KEY_GI"%d", i); - return db_unset(hContact, m_szModuleName, item); + delSetting(hContact, item); + return 0; } ///////////////////////////////////////////////////////////////////////////////////////// @@ -546,19 +548,9 @@ int CAimProto::open_contact_file(const char* sn, const TCHAR* file, const char* { path = (TCHAR*)mir_alloc(MAX_PATH * sizeof(TCHAR)); - TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_userdata%")); - TCHAR *sztModuleName = mir_a2t(m_szModuleName); - int pos = mir_sntprintf(path, MAX_PATH, _T("%s\\%s"), tmpPath, sztModuleName); - mir_free(sztModuleName); - mir_free(tmpPath); - if (contact_dir) - { - char* norm_sn = normalize_name(sn); - TCHAR *norm_snt = mir_a2t(m_szModuleName); - pos += mir_sntprintf(path + pos, MAX_PATH - pos, _T("\\%s"), norm_snt); - mir_free(norm_snt); - mir_free(norm_sn); - } + int pos = mir_sntprintf(path, MAX_PATH, _T("%s\\%S"), VARST(_T("%miranda_userdata%")), m_szModuleName); + if (contact_dir) + pos += mir_sntprintf(path + pos, MAX_PATH - pos, _T("\\%S"), m_szModuleName); if (_taccess(path, 0)) CreateDirectoryTreeT(path); -- cgit v1.2.3