diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-09 22:02:18 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-09 22:02:18 +0000 |
commit | d5d50b471277d5d69f59a8f29bf87201149ce191 (patch) | |
tree | 92d10ad5b0a1116ba08eca98cf025cb07578784e /protocols/AimOscar | |
parent | 9dd56da9d9ccbce2f1e1539acb5cfcad7650916a (diff) |
applied protocol helpers
git-svn-id: http://svn.miranda-ng.org/main/trunk@5305 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/AimOscar')
-rw-r--r-- | protocols/AimOscar/src/avatars.cpp | 12 | ||||
-rw-r--r-- | protocols/AimOscar/src/connection.cpp | 2 | ||||
-rw-r--r-- | protocols/AimOscar/src/proto.cpp | 2 | ||||
-rw-r--r-- | protocols/AimOscar/src/proto.h | 30 | ||||
-rw-r--r-- | protocols/AimOscar/src/server.cpp | 12 | ||||
-rw-r--r-- | protocols/AimOscar/src/ui.cpp | 9 | ||||
-rw-r--r-- | protocols/AimOscar/src/utility.cpp | 113 |
7 files changed, 17 insertions, 163 deletions
diff --git a/protocols/AimOscar/src/avatars.cpp b/protocols/AimOscar/src/avatars.cpp index 721488c6f2..a25188706b 100644 --- a/protocols/AimOscar/src/avatars.cpp +++ b/protocols/AimOscar/src/avatars.cpp @@ -22,12 +22,12 @@ void __cdecl CAimProto::avatar_request_thread(void* param) {
HANDLE hContact = (HANDLE)param;
- char *sn = getSetting(hContact, AIM_KEY_SN);
+ char *sn = getStringA(hContact, AIM_KEY_SN);
LOG("Starting avatar request thread for %s)", sn);
if (wait_conn(hAvatarConn, hAvatarEvent, 0x10))
{
- char *hash_str = getSetting(hContact, AIM_KEY_AH);
+ char *hash_str = getStringA(hContact, AIM_KEY_AH);
char type = getByte(hContact, AIM_KEY_AHT, 1);
size_t len = (strlen(hash_str) + 1) / 2;
@@ -67,7 +67,7 @@ void CAimProto::avatar_request_handler(HANDLE hContact, char* hash, unsigned cha type = hash_lg ? 12 : 1;
}
- char* saved_hash = getSetting(hContact, AIM_KEY_AH);
+ char* saved_hash = getStringA(hContact, AIM_KEY_AH);
if (hash && _stricmp(hash, "0201d20472") && _stricmp(hash, "2b00003341")) //gaim default icon fix- we don't want their blank icon displaying.
{
if (_strcmps(saved_hash, hash))
@@ -82,8 +82,8 @@ void CAimProto::avatar_request_handler(HANDLE hContact, char* hash, unsigned cha {
if (saved_hash)
{
- deleteSetting(hContact, AIM_KEY_AHT);
- deleteSetting(hContact, AIM_KEY_AH);
+ db_unset(hContact, m_szModuleName, AIM_KEY_AHT);
+ db_unset(hContact, m_szModuleName, AIM_KEY_AH);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
}
@@ -112,7 +112,7 @@ void CAimProto::avatar_retrieval_handler(const char* sn, const char* hash, const _close(fileId);
res = true;
- char *my_sn = getSetting(AIM_KEY_SN);
+ char *my_sn = getStringA(AIM_KEY_SN);
if (!_strcmps(sn, my_sn))
CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
mir_free(my_sn);
diff --git a/protocols/AimOscar/src/connection.cpp b/protocols/AimOscar/src/connection.cpp index a7fb998ca1..327274dac4 100644 --- a/protocols/AimOscar/src/connection.cpp +++ b/protocols/AimOscar/src/connection.cpp @@ -95,7 +95,7 @@ void CAimProto::aim_connection_authorization(void) goto exit;
mir_free(username);
- username = getSetting(AIM_KEY_SN);
+ username = getStringA(AIM_KEY_SN);
if (username == NULL)
goto exit;
diff --git a/protocols/AimOscar/src/proto.cpp b/protocols/AimOscar/src/proto.cpp index 2d13a60e8b..e3821fed42 100644 --- a/protocols/AimOscar/src/proto.cpp +++ b/protocols/AimOscar/src/proto.cpp @@ -572,7 +572,7 @@ int __cdecl CAimProto::SendMsg(HANDLE hContact, int flags, const char* pszSrc) ForkThread(&CAimProto::msg_ack_success, msg_ack);
}
- char *sn = getSetting(hContact, AIM_KEY_SN);
+ char *sn = getStringA(hContact, AIM_KEY_SN);
if (sn == NULL)
{
msg_ack_param *msg_ack = (msg_ack_param*)mir_calloc(sizeof(msg_ack_param));
diff --git a/protocols/AimOscar/src/proto.h b/protocols/AimOscar/src/proto.h index 3cb22c28d2..c829c64ec8 100644 --- a/protocols/AimOscar/src/proto.h +++ b/protocols/AimOscar/src/proto.h @@ -452,36 +452,6 @@ struct CAimProto : public PROTO<CAimProto> unsigned short* get_members_of_group(unsigned short group_id, unsigned short& size);
void ShowPopup( const char* msg, int flags, char* url = 0 );
-
- //////////////////////////////////////////////////////////////////////////////////////
- HANDLE CreateProtoEvent(const char* szEvent);
-
- int deleteSetting(HANDLE hContact, const char* setting);
-
- bool getBool(HANDLE hContact, const char* name, bool defaultValue);
- int getByte(const char* name, BYTE defaultValue );
- int getByte(HANDLE hContact, const char* name, BYTE defaultValue);
- int getDword(const char* name, DWORD defaultValue);
- int getDword(HANDLE hContact, const char* name, DWORD defaultValue);
- int getString(const char* name, DBVARIANT*);
- int getString(HANDLE hContact, const char* name, DBVARIANT*);
- int getTString(const char* name, DBVARIANT*);
- int getTString(HANDLE hContact, const char* name, DBVARIANT*);
- WORD getWord(const char* name, WORD defaultValue);
- WORD getWord(HANDLE hContact, const char* name, WORD defaultValue);
- char* getSetting(HANDLE hContact, const char* setting);
- char* getSetting(const char* setting);
-
- void setByte(const char* name, BYTE value);
- void setByte(HANDLE hContact, const char* name, BYTE value);
- void setDword(const char* name, DWORD value);
- void setDword(HANDLE hContact, const char* name, DWORD value);
- void setString(const char* name, const char* value);
- void setString(HANDLE hContact, const char* name, const char* value);
- void setTString(const char* name, const TCHAR* value);
- void setTString(HANDLE hContact, const char* name, const TCHAR* value);
- void setWord(const char* name, WORD value);
- void setWord(HANDLE hContact, const char* name, WORD value);
};
#endif
diff --git a/protocols/AimOscar/src/server.cpp b/protocols/AimOscar/src/server.cpp index 7c42ff979b..9726d9468e 100644 --- a/protocols/AimOscar/src/server.cpp +++ b/protocols/AimOscar/src/server.cpp @@ -265,28 +265,18 @@ void CAimProto::snac_user_online(SNAC &snac)//family 0x0003 if (icq)
setString(hContact, "Transport", "ICQ");
else
- deleteSetting(hContact, "Transport" );
+ db_unset(hContact, m_szModuleName, "Transport" );
if (admin_aol)
- {
setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_ADMIN);
- }
else if (aol)
- {
setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_AOL);
- }
else if (icq)
- {
setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_ICQ);
- }
else if (unconfirmed)
- {
setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_UNCONFIRMED);
- }
else
- {
setByte(hContact, AIM_KEY_AC, ACCOUNT_TYPE_CONFIRMED);
- }
if (bot)
{
diff --git a/protocols/AimOscar/src/ui.cpp b/protocols/AimOscar/src/ui.cpp index f98f643db2..7011320cab 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
- ppro->deleteSetting(NULL, AIM_KEY_SN);
+ db_unset(NULL, ppro->m_szModuleName, AIM_KEY_SN);
//END SN
//NK
@@ -900,8 +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
- ppro->deleteSetting(NULL, AIM_KEY_PW);
+ else db_unset(NULL, ppro->m_szModuleName, AIM_KEY_PW);
//END PW
//HN
@@ -909,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
- ppro->deleteSetting(NULL, AIM_KEY_HN);
+ db_unset(NULL, ppro->m_szModuleName, AIM_KEY_HN);
//END HN
//Delivery Confirmation
@@ -937,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
- ppro->deleteSetting(NULL, AIM_KEY_PN);
+ db_unset(NULL, ppro->m_szModuleName, AIM_KEY_PN);
//END PN
//Disable Account Type Icons
diff --git a/protocols/AimOscar/src/utility.cpp b/protocols/AimOscar/src/utility.cpp index be6ac0b388..db6dba0590 100644 --- a/protocols/AimOscar/src/utility.cpp +++ b/protocols/AimOscar/src/utility.cpp @@ -112,7 +112,7 @@ void CAimProto::start_connection(void *arg) bool use_ssl = !getByte(AIM_KEY_DSSL, 0);
- char* login_url = getSetting(AIM_KEY_HN);
+ char* login_url = getStringA(AIM_KEY_HN);
if (login_url == NULL) login_url = mir_strdup(use_ssl ? AIM_DEFAULT_SERVER : AIM_DEFAULT_SERVER_NS);
hServerConn = aim_connect(login_url, get_default_port(), use_ssl, login_url);
@@ -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);
- deleteSetting(hContact, AIM_KEY_NIL);
+ db_unset(hContact, m_szModuleName, AIM_KEY_NIL);
}
aim_ssi_update(hServerConn, seqno, false);
@@ -516,7 +516,7 @@ 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 deleteSetting(hContact, item);
+ return db_unset(hContact, m_szModuleName, item);
}
unsigned short CAimProto::getGroupId(HANDLE hContact, int i)
@@ -537,7 +537,7 @@ 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 deleteSetting(hContact, item);
+ return db_unset(hContact, m_szModuleName, item);
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -699,108 +699,3 @@ unsigned short get_random(void) id &= 0x7fff;
return id;
}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-// Standard functions
-
-int CAimProto::deleteSetting(HANDLE hContact, const char* setting)
-{ return db_unset(hContact, m_szModuleName, setting);
-}
-
-bool CAimProto::getBool(HANDLE hContact, const char* name, bool defaultValue)
-{ return db_get_b(hContact, m_szModuleName, name, defaultValue) != 0;
-}
-
-int CAimProto::getByte(const char* name, BYTE defaultValue)
-{ return db_get_b(NULL, m_szModuleName, name, defaultValue);
-}
-
-int CAimProto::getByte(HANDLE hContact, const char* name, BYTE defaultValue)
-{ return db_get_b(hContact, m_szModuleName, name, defaultValue);
-}
-
-int CAimProto::getDword(const char* name, DWORD defaultValue)
-{ return db_get_dw(NULL, m_szModuleName, name, defaultValue);
-}
-
-int CAimProto::getDword(HANDLE hContact, const char* name, DWORD defaultValue)
-{ return db_get_dw(hContact, m_szModuleName, name, defaultValue);
-}
-
-int CAimProto::getString(const char* name, DBVARIANT* result)
-{ return db_get_s(NULL, m_szModuleName, name, result);
-}
-
-int CAimProto::getString(HANDLE hContact, const char* name, DBVARIANT* result)
-{ return db_get_s(hContact, m_szModuleName, name, result);
-}
-
-int CAimProto::getTString(const char* name, DBVARIANT* result)
-{ return db_get_ts(NULL, m_szModuleName, name, result);
-}
-
-int CAimProto::getTString(HANDLE hContact, const char* name, DBVARIANT* result)
-{ return db_get_ts(hContact, m_szModuleName, name, result);
-}
-
-WORD CAimProto::getWord(const char* name, WORD defaultValue)
-{ return (WORD)db_get_w(NULL, m_szModuleName, name, defaultValue);
-}
-
-WORD CAimProto::getWord(HANDLE hContact, const char* name, WORD defaultValue)
-{ return (WORD)db_get_w(hContact, m_szModuleName, name, defaultValue);
-}
-
-char* CAimProto::getSetting(HANDLE hContact, const char* setting)
-{
- DBVARIANT dbv;
- return db_get_s(hContact, m_szModuleName, setting, &dbv) ?
- NULL : dbv.pszVal;
-}
-
-char* CAimProto::getSetting(const char* setting)
-{
- DBVARIANT dbv;
- return db_get_s(NULL, m_szModuleName, setting, &dbv) ?
- NULL : dbv.pszVal;
-}
-
-void CAimProto::setByte(const char* name, BYTE value)
-{ db_set_b(NULL, m_szModuleName, name, value);
-}
-
-void CAimProto::setByte(HANDLE hContact, const char* name, BYTE value)
-{ db_set_b(hContact, m_szModuleName, name, value);
-}
-
-void CAimProto::setDword(const char* name, DWORD value)
-{ db_set_dw(NULL, m_szModuleName, name, value);
-}
-
-void CAimProto::setDword(HANDLE hContact, const char* name, DWORD value)
-{ db_set_dw(hContact, m_szModuleName, name, value);
-}
-
-void CAimProto::setString(const char* name, const char* value)
-{ db_set_s(NULL, m_szModuleName, name, value);
-}
-
-void CAimProto::setString(HANDLE hContact, const char* name, const char* value)
-{ db_set_s(hContact, m_szModuleName, name, value);
-}
-
-void CAimProto::setTString(const char* name, const TCHAR* value)
-{ db_set_ts(NULL, m_szModuleName, name, value);
-}
-
-void CAimProto::setTString(HANDLE hContact, const char* name, const TCHAR* value)
-{ db_set_ts(hContact, m_szModuleName, name, value);
-}
-
-void CAimProto::setWord(const char* name, WORD value)
-{ db_set_w(NULL, m_szModuleName, name, value);
-}
-
-void CAimProto::setWord(HANDLE hContact, const char* name, WORD value)
-{ db_set_w(hContact, m_szModuleName, name, value);
-}
|