diff options
author | George Hazan <george.hazan@gmail.com> | 2013-07-10 20:18:54 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-07-10 20:18:54 +0000 |
commit | 6ce6a5277e749cf6082ae42f005b68b3ec763c6c (patch) | |
tree | b9cde795c6ed4863d97428f05482bf44576c031b /protocols/Gadu-Gadu | |
parent | 00c866aaa0b79c354f9c71ca5d61f57daeec6e6a (diff) |
protocol DB helpers for GG
git-svn-id: http://svn.miranda-ng.org/main/trunk@5314 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Gadu-Gadu')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 53 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/core.cpp | 178 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/dialogs.cpp | 725 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/filetransfer.cpp | 24 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/gg_proto.cpp | 18 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/groupchat.cpp | 38 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/image.cpp | 6 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/import.cpp | 28 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/keepalive.cpp | 2 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 24 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/services.cpp | 36 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/userutils.cpp | 23 |
13 files changed, 562 insertions, 605 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 2bc6dc0aab..66a249b92c 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -51,7 +51,7 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) }
}
- switch (db_get_b(hContact, m_szModuleName, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE)) {
+ switch (getByte(hContact, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE)) {
case PA_FORMAT_JPEG: avatartype = _T("jpg"); break;
case PA_FORMAT_GIF: avatartype = _T("gif"); break;
case PA_FORMAT_PNG: avatartype = _T("png"); break;
@@ -59,7 +59,7 @@ void GGPROTO::getAvatarFilename(HANDLE hContact, TCHAR *pszDest, int cbLen) if (hContact != NULL) {
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, GG_KEY_AVATARHASH, &dbv, DBVT_ASCIIZ)) {
+ if (!getString(hContact, GG_KEY_AVATARHASH, &dbv)) {
TCHAR* avatarHashT = mir_a2t(dbv.pszVal);
mir_sntprintf(pszDest + tPathLen, cbLen - tPathLen, _T("\\%s.%s"), avatarHashT, avatartype);
mir_free(avatarHashT);
@@ -152,7 +152,7 @@ void GGPROTO::requestAvatarInfo(HANDLE hContact, int iWaitFor) return;
}
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS))
+ if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS))
return;
GGREQUESTAVATARDATA *data = NULL;
@@ -166,7 +166,7 @@ void GGPROTO::requestAvatarInfo(HANDLE hContact, int iWaitFor) gg_LeaveCriticalSection(&avatar_mutex, "requestAvatarInfo", 2, 1, "avatar_mutex", 1);
if (data != NULL)
- db_set_b(hContact, m_szModuleName, GG_KEY_AVATARREQUESTED, 1);
+ setByte(hContact, GG_KEY_AVATARREQUESTED, 1);
}
void __cdecl GGPROTO::avatarrequestthread(void*)
@@ -183,7 +183,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) mir_free(data);
gg_LeaveCriticalSection(&avatar_mutex, "avatarrequestthread", 3, 1, "avatar_mutex", 1);
- uin_t uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0);
netlog("avatarrequestthread() new avatar_requests item for uin=%d.", uin);
char *AvatarURL, *AvatarTs;
@@ -193,14 +193,14 @@ void __cdecl GGPROTO::avatarrequestthread(void*) }
else {
if (AvatarURL == NULL && AvatarTs == NULL){
- db_unset(hContact, m_szModuleName, GG_KEY_AVATARURL);
- db_unset(hContact, m_szModuleName, GG_KEY_AVATARTS);
+ delSetting(hContact, GG_KEY_AVATARURL);
+ delSetting(hContact, GG_KEY_AVATARTS);
if (iWaitFor)
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, NULL, 0);
}
else {
- db_set_s(hContact, m_szModuleName, GG_KEY_AVATARURL, AvatarURL);
- db_set_s(hContact, m_szModuleName, GG_KEY_AVATARTS, AvatarTs);
+ setString(hContact, GG_KEY_AVATARURL, AvatarURL);
+ setString(hContact, GG_KEY_AVATARTS, AvatarTs);
mir_free(AvatarURL); mir_free(AvatarTs);
if (iWaitFor) {
@@ -214,7 +214,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_SUCCESS, (HANDLE)&pai, 0);
}
else ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, 0, 0);
- db_unset(hContact, m_szModuleName, GG_KEY_AVATARREQUESTED);
+ delSetting(hContact, GG_KEY_AVATARREQUESTED);
}
}
}
@@ -231,7 +231,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) PROTO_AVATAR_INFORMATIONT pai = { sizeof(pai) };
pai.hContact = data->hContact;
- pai.format = db_get_b(pai.hContact, m_szModuleName, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE);
+ pai.format = getByte(pai.hContact, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE);
NETLIBHTTPREQUEST req = { sizeof(req) };
req.requestType = REQUEST_GET;
@@ -256,7 +256,7 @@ void __cdecl GGPROTO::avatarrequestthread(void*) avatarType = PA_FORMAT_PNG;
}
}
- db_set_b(data->hContact, m_szModuleName, GG_KEY_AVATARTYPE, (BYTE)avatarType);
+ setByte(data->hContact, GG_KEY_AVATARTYPE, (BYTE)avatarType);
getAvatarFilename(pai.hContact, pai.filename, sizeof(pai.filename));
file_fd = _topen(pai.filename, _O_WRONLY | _O_TRUNC | _O_BINARY | _O_CREAT, _S_IREAD | _S_IWRITE);
@@ -320,16 +320,16 @@ void __cdecl GGPROTO::getOwnAvatarThread(void*) netlog("getOwnAvatarThread() started");
char *AvatarURL, *AvatarTs;
- if (getAvatarFileInfo( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), &AvatarURL, &AvatarTs)) {
+ if (getAvatarFileInfo( getDword(GG_KEY_UIN, 0), &AvatarURL, &AvatarTs)) {
if (AvatarURL != NULL && AvatarTs != NULL > 0) {
- db_set_s(NULL, m_szModuleName, GG_KEY_AVATARURL, AvatarURL);
- db_set_s(NULL, m_szModuleName, GG_KEY_AVATARTS, AvatarTs);
+ setString(GG_KEY_AVATARURL, AvatarURL);
+ setString(GG_KEY_AVATARTS, AvatarTs);
mir_free(AvatarURL); mir_free(AvatarTs);
} else {
- db_unset(NULL, m_szModuleName, GG_KEY_AVATARURL);
- db_unset(NULL, m_szModuleName, GG_KEY_AVATARTS);
+ delSetting(GG_KEY_AVATARURL);
+ delSetting(GG_KEY_AVATARTS);
}
- db_set_b(NULL, m_szModuleName, GG_KEY_AVATARREQUESTED, 1);
+ setByte(GG_KEY_AVATARREQUESTED, 1);
PROTO_AVATAR_INFORMATIONT pai = {0};
pai.cbSize = sizeof(pai);
@@ -342,8 +342,7 @@ void __cdecl GGPROTO::getOwnAvatarThread(void*) void GGPROTO::getOwnAvatar()
{
- if (db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)
- && db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)){
+ if (getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS) && getDword(GG_KEY_UIN, 0)){
#ifdef DEBUGMODE
netlog("getOwnAvatar(): ForkThread 2 GGPROTO::getOwnAvatarThread");
#endif
@@ -362,7 +361,7 @@ void __cdecl GGPROTO::setavatarthread(void *param) int file_fd, avatardatalen, datalen, contentlen, contentendlen, res = 0, repeat = 0;
netlog("setavatarthread(): started. Trying to set user avatar.");
- UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
+ UIN2IDA( getDword(GG_KEY_UIN, 0), uin);
file_fd = _topen(szFilename, _O_RDONLY | _O_BINARY, _S_IREAD);
if (file_fd == -1) {
@@ -371,10 +370,10 @@ void __cdecl GGPROTO::setavatarthread(void *param) mir_sntprintf(error, SIZEOF(error), TranslateT("Can not open avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), szFilename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
mir_free(szFilename);
- int prevType = db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, -1);
+ int prevType = getByte(GG_KEY_AVATARTYPEPREV, -1);
if (prevType != -1)
- db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, prevType);
- db_unset(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV);
+ setByte(GG_KEY_AVATARTYPE, prevType);
+ delSetting(GG_KEY_AVATARTYPEPREV);
getOwnAvatar();
#ifdef DEBUGMODE
netlog("setavatarthread(): end. err1");
@@ -485,12 +484,12 @@ void __cdecl GGPROTO::setavatarthread(void *param) if (res) {
netlog("setavatarthread(): User avatar set successfully.");
} else {
- int prevType = db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, -1);
+ int prevType = getByte(GG_KEY_AVATARTYPEPREV, -1);
if (prevType != -1)
- db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, prevType);
+ setByte(GG_KEY_AVATARTYPE, prevType);
netlog("setavatarthread(): Failed to set user avatar.");
}
- db_unset(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV);
+ delSetting(GG_KEY_AVATARTYPEPREV);
mir_free(szFilename);
getOwnAvatar();
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp index 72385df3cf..03d23031ed 100644 --- a/protocols/Gadu-Gadu/src/core.cpp +++ b/protocols/Gadu-Gadu/src/core.cpp @@ -61,10 +61,10 @@ void GGPROTO::disconnect() char *szMsg = NULL;
// Loadup status
- if (db_get_b(NULL, m_szModuleName, GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG))
+ if (getByte(GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG))
{
DBVARIANT dbv;
- switch (db_get_w(NULL, m_szModuleName, GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
+ switch (getWord(GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
case ID_STATUS_ONLINE:
gg_EnterCriticalSection(&modemsg_mutex, "disconnect", 6, "modemsg_mutex", 1);
szMsg = mir_utf8encodeT(modemsg.online);
@@ -251,7 +251,7 @@ void __cdecl GGPROTO::mainthread(void *) { 0, LPGENT("Unknown") }
};
time_t logonTime = 0;
- time_t timeDeviation = db_get_w(NULL, m_szModuleName, GG_KEY_TIMEDEVIATION, GG_KEYDEF_TIMEDEVIATION);
+ time_t timeDeviation = getWord(GG_KEY_TIMEDEVIATION, GG_KEYDEF_TIMEDEVIATION);
int gg_failno = 0;
netlog("mainthread(): started. (%x) Server Thread Starting", this);
@@ -270,7 +270,7 @@ void __cdecl GGPROTO::mainthread(void *) p.protocol_features = GG_FEATURE_DND_FFC | GG_FEATURE_UNKNOWN_100 | GG_FEATURE_USER_DATA | GG_FEATURE_MSG_ACK | GG_FEATURE_TYPING_NOTIFICATION | GG_FEATURE_MULTILOGON;
p.encoding = GG_ENCODING_UTF8;
p.status_flags = GG_STATUS_FLAG_UNKNOWN;
- if (db_get_b(NULL, m_szModuleName, GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS))
+ if (getByte(GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS))
p.status_flags |= GG_STATUS_FLAG_SPAM;
// Use audio
@@ -280,7 +280,7 @@ void __cdecl GGPROTO::mainthread(void *) /* p.async = 1; */
// Send Era Omnix info if set
- p.era_omnix = db_get_b(NULL, m_szModuleName, "EraOmnix", 0);
+ p.era_omnix = getByte("EraOmnix", 0);
// Setup proxy
nlus.cbSize = sizeof(nlus);
@@ -296,8 +296,7 @@ void __cdecl GGPROTO::mainthread(void *) gg_proxy_username = nlus.szProxyAuthUser;
gg_proxy_password = nlus.szProxyAuthPassword;
}
- else
- gg_proxy_username = gg_proxy_password = NULL;
+ else gg_proxy_username = gg_proxy_password = NULL;
}
else
{
@@ -306,9 +305,9 @@ void __cdecl GGPROTO::mainthread(void *) }
// Check out manual host setting
- if (db_get_b(NULL, m_szModuleName, GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST))
+ if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST))
{
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_SERVERHOSTS, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_SERVERHOSTS, &dbv))
{
hostcount = gg_decodehosts(dbv.pszVal, hosts, 64);
db_free(&dbv);
@@ -316,7 +315,7 @@ void __cdecl GGPROTO::mainthread(void *) }
// Readup password
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_PASSWORD, &dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
p.password = mir_strdup(dbv.pszVal);
@@ -333,7 +332,7 @@ void __cdecl GGPROTO::mainthread(void *) }
// Readup number
- if (!(p.uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
+ if (!(p.uin = getDword(GG_KEY_UIN, 0)))
{
netlog("mainthread() (%x): No Gadu-Gadu number specified. Exiting.", this);
broadcastnewstatus(ID_STATUS_OFFLINE);
@@ -345,7 +344,7 @@ void __cdecl GGPROTO::mainthread(void *) }
// Readup SSL/TLS setting
- if (p.tls = db_get_b(NULL, m_szModuleName, GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN))
+ if (p.tls = getByte(GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN))
netlog("mainthread() (%x): Using TLS/SSL for connections.", this);
// Gadu-Gadu accepts image sizes upto 255
@@ -366,9 +365,9 @@ void __cdecl GGPROTO::mainthread(void *) CloseHandle(hEvent); hEvent = NULL;
}
// Check if dcc is running and setup forwarding port
- if (dcc && db_get_b(NULL, m_szModuleName, GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING))
+ if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING))
{
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_FORWARDHOST, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_FORWARDHOST, &dbv))
{
if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal)))
{
@@ -380,7 +379,7 @@ void __cdecl GGPROTO::mainthread(void *) }
else
netlog("mainthread() (%x): Loading forwarding host %s and port %d.", dbv.pszVal, p.external_port, this);
- if (p.external_addr) p.external_port = db_get_w(NULL, m_szModuleName, GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT);
+ if (p.external_addr) p.external_port = getWord(GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT);
db_free(&dbv);
}
}
@@ -440,15 +439,15 @@ retry: perror = error;
}
netlog("mainthread() (%x): %s", this, perror);
- if (db_get_b(NULL, m_szModuleName, GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS))
+ if (getByte(GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS))
showpopup(m_tszUserName, perror, GG_POPUP_ERROR | GG_POPUP_ALLOW_MSGBOX | GG_POPUP_ONCE);
// Check if we should reconnect
if ((gg_failno >= GG_FAILURE_RESOLVING && gg_failno != GG_FAILURE_PASSWORD && gg_failno != GG_FAILURE_INTRUDER && gg_failno != GG_FAILURE_UNAVAILABLE)
&& errno == EACCES
- && (db_get_b(NULL, m_szModuleName, GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT) || (hostnum < hostcount - 1)))
+ && (getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT) || (hostnum < hostcount - 1)))
{
- DWORD dwInterval = db_get_dw(NULL, m_szModuleName, GG_KEY_RECONNINTERVAL, GG_KEYDEF_RECONNINTERVAL), dwResult;
+ DWORD dwInterval = getDword(GG_KEY_RECONNINTERVAL, GG_KEYDEF_RECONNINTERVAL), dwResult;
BOOL bRetry = TRUE;
hConnStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
@@ -480,7 +479,7 @@ retry: {
// Successfully connected
logonTime = time(NULL);
- db_set_dw(NULL, m_szModuleName, GG_KEY_LOGONTIME, logonTime);
+ setDword(GG_KEY_LOGONTIME, logonTime);
gg_EnterCriticalSection(&sess_mutex, "mainthread", 15, "sess_mutex", 1);
sess = local_sess;
gg_LeaveCriticalSection(&sess_mutex, "mainthread", 15, 1, "sess_mutex", 1);
@@ -584,7 +583,7 @@ retry: // Statuslist notify (version >= 6.0)
case GG_EVENT_NOTIFY60:
{
- uin_t uin = (uin_t)db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = (uin_t)getDword(GG_KEY_UIN, 0);
int i;
for(i = 0; e->event.notify60[i].uin; i++) {
if (e->event.notify60[i].uin == uin) continue;
@@ -684,41 +683,39 @@ retry: || res->seq == GG_SEQ_CHINFO)
{
// Change nickname if it's not present
- if (__nickname && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO)){
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, __nickname);
- }
+ if (__nickname && (res->seq == GG_SEQ_GETNICK || res->seq == GG_SEQ_CHINFO))
+ setTString(hContact, GG_KEY_NICK, __nickname);
- if (__nickname){
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_NICKNAME, __nickname);
- } else if (res->seq == GG_SEQ_CHINFO) {
- db_unset(NULL, m_szModuleName, GG_KEY_PD_NICKNAME);
- }
+ if (__nickname)
+ setTString(hContact, GG_KEY_PD_NICKNAME, __nickname);
+ else if (res->seq == GG_SEQ_CHINFO)
+ delSetting(GG_KEY_PD_NICKNAME);
// Change other info
if (__city)
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_CITY, __city);
+ setTString(hContact, GG_KEY_PD_CITY, __city);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, GG_KEY_PD_CITY);
+ delSetting(GG_KEY_PD_CITY);
if (__firstname)
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FIRSTNAME, __firstname);
+ setTString(hContact, GG_KEY_PD_FIRSTNAME, __firstname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, GG_KEY_PD_FIRSTNAME);
+ delSetting(GG_KEY_PD_FIRSTNAME);
if (__lastname)
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_LASTNAME, __lastname);
+ setTString(hContact, GG_KEY_PD_LASTNAME, __lastname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, GG_KEY_PD_LASTNAME);
+ delSetting(GG_KEY_PD_LASTNAME);
if (__familyname)
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FAMILYNAME, __familyname);
+ setTString(hContact, GG_KEY_PD_FAMILYNAME, __familyname);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, GG_KEY_PD_FAMILYNAME);
+ delSetting(GG_KEY_PD_FAMILYNAME);
if (__familycity)
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FAMILYCITY, __familycity);
+ setTString(hContact, GG_KEY_PD_FAMILYCITY, __familycity);
else if (res->seq == GG_SEQ_CHINFO)
- db_unset(NULL, m_szModuleName, GG_KEY_PD_FAMILYCITY);
+ delSetting(GG_KEY_PD_FAMILYCITY);
if (__birthyear)
{
@@ -727,31 +724,31 @@ retry: int br = atoi(__birthyear);
if (br > 0)
{
- db_set_w(hContact, m_szModuleName, GG_KEY_PD_AGE, (WORD)(lt->tm_year + 1900 - br));
- db_set_w(hContact, m_szModuleName, GG_KEY_PD_BIRTHYEAR, (WORD)br);
+ setWord(hContact, GG_KEY_PD_AGE, (WORD)(lt->tm_year + 1900 - br));
+ setWord(hContact, GG_KEY_PD_BIRTHYEAR, (WORD)br);
}
}
else if (res->seq == GG_SEQ_CHINFO)
{
- db_unset(NULL, m_szModuleName, GG_KEY_PD_AGE);
- db_unset(NULL, m_szModuleName, GG_KEY_PD_BIRTHYEAR);
+ delSetting(GG_KEY_PD_AGE);
+ delSetting(GG_KEY_PD_BIRTHYEAR);
}
// Gadu-Gadu Male <-> Female
if (__gender)
{
if (res->seq == GG_SEQ_CHINFO)
- db_set_b(hContact, m_szModuleName, GG_KEY_PD_GANDER,
+ setByte(hContact, GG_KEY_PD_GANDER,
(BYTE)(!strcmp(__gender, GG_PUBDIR50_GENDER_SET_MALE) ? 'M' :
(!strcmp(__gender, GG_PUBDIR50_GENDER_SET_FEMALE) ? 'F' : '?')));
else
- db_set_b(hContact, m_szModuleName, GG_KEY_PD_GANDER,
+ setByte(hContact, GG_KEY_PD_GANDER,
(BYTE)(!strcmp(__gender, GG_PUBDIR50_GENDER_MALE) ? 'M' :
(!strcmp(__gender, GG_PUBDIR50_GENDER_FEMALE) ? 'F' : '?')));
}
else if (res->seq == GG_SEQ_CHINFO)
{
- db_unset(NULL, m_szModuleName, GG_KEY_PD_GANDER);
+ delSetting(GG_KEY_PD_GANDER);
}
netlog("mainthread() (%x): Setting user info for uin %d.", this, uin);
@@ -785,8 +782,8 @@ retry: case GG_EVENT_STATUS60:
{
HANDLE hContact = getcontact(e->event.status60.uin, 0, 0, NULL);
- int oldstatus = db_get_w(hContact, m_szModuleName, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE);
- uin_t uin = (uin_t)db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
+ int oldstatus = getWord(hContact, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE);
+ uin_t uin = (uin_t)getDword(GG_KEY_UIN, 0);
TCHAR *descrT = mir_utf8decodeT(e->event.status60.descr);
@@ -803,7 +800,7 @@ retry: mir_free(descrT);
- if (oldstatus == ID_STATUS_OFFLINE && db_get_w(hContact, m_szModuleName, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ if (oldstatus == ID_STATUS_OFFLINE && getWord(hContact, GG_KEY_STATUS, (WORD)ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
requestAvatarInfo(hContact, 0);
}
break;
@@ -838,7 +835,7 @@ retry: else if (!e->event.msg.recipients_count || gc_enabled)
{
// Check if groupchat
- if (e->event.msg.recipients_count && gc_enabled && !db_get_b(NULL, m_szModuleName, GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
+ if (e->event.msg.recipients_count && gc_enabled && !getByte(GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
{
TCHAR *chat = gc_getchat(e->event.msg.sender, e->event.msg.recipients, e->event.msg.recipients_count);
if (chat)
@@ -875,7 +872,7 @@ retry: // RichEdit format included (image)
if (e->event.msg.formats_length &&
- db_get_b(NULL, m_szModuleName, GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE) &&
+ getByte(GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE) &&
!(db_get_dw(getcontact(e->event.msg.sender, 1, 0, NULL), "Ignore", "Mask1", 0) & IGNOREEVENT_MESSAGE))
{
char *formats = (char*)e->event.msg.formats;
@@ -905,7 +902,7 @@ retry: // Message sent from concurrent user session
case GG_EVENT_MULTILOGON_MSG:
- if (e->event.multilogon_msg.recipients_count && gc_enabled && !db_get_b(NULL, m_szModuleName, GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
+ if (e->event.multilogon_msg.recipients_count && gc_enabled && !getByte(GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF))
{
TCHAR *chat = gc_getchat(e->event.multilogon_msg.sender, e->event.multilogon_msg.recipients, e->event.multilogon_msg.recipients_count);
if (chat)
@@ -917,12 +914,12 @@ retry: gcdest.ptszID = chat;
gcdest.iType = GC_EVENT_MESSAGE;
GCEVENT gcevent = {sizeof(GCEVENT), &gcdest};
- UIN2IDT(db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), id);
+ UIN2IDT(getDword(GG_KEY_UIN, 0), id);
gcevent.ptszUID = id;
TCHAR* messageT = mir_utf8decodeT(e->event.multilogon_msg.message);
gcevent.ptszText = messageT;
TCHAR* nickT;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)){
+ if (!getTString(GG_KEY_NICK, &dbv)){
nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
} else {
@@ -1020,11 +1017,11 @@ retry: if (!img)
break;
- if (db_get_b(NULL, m_szModuleName, GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD) == 1 || img_opened(e->event.image_reply.sender))
+ if (getByte(GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD) == 1 || img_opened(e->event.image_reply.sender))
{
img_display(hContact, img);
}
- else if (db_get_b(NULL, m_szModuleName, GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD) == 2)
+ else if (getByte(GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD) == 2)
{
img_displayasmsg(hContact, img);
}
@@ -1061,7 +1058,7 @@ retry: dcc7->contact = getcontact(dcc7->peer_uin, 0, 0, NULL);
// Check if user is on the list and if it is my uin
- if (!dcc7->contact || db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, -1) != dcc7->uin) {
+ if (!dcc7->contact || getDword(GG_KEY_UIN, -1) != dcc7->uin) {
gg_dcc7_free(dcc7);
e->event.dcc7_new = NULL;
break;
@@ -1170,7 +1167,7 @@ retry: break;
case GG_EVENT_XML_ACTION:
- if (db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
+ if (getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
HXML hXml;
TCHAR *xmlAction;
TCHAR *tag;
@@ -1225,11 +1222,11 @@ retry: broadcastnewstatus(ID_STATUS_OFFLINE);
setalloffline();
- db_set_dw(NULL, m_szModuleName, GG_KEY_LOGONTIME, 0);
+ setDword(GG_KEY_LOGONTIME, 0);
// If it was unwanted disconnection reconnect
if (m_iDesiredStatus != ID_STATUS_OFFLINE
- && db_get_b(NULL, m_szModuleName, GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT))
+ && getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT))
{
netlog("mainthread() (%x): Unintentional disconnection detected. Going to reconnect...", this);
hostnum = 0;
@@ -1299,13 +1296,12 @@ int GGPROTO::contactdeleted(WPARAM wParam, LPARAM lParam) uin_t uin; int type;
DBVARIANT dbv;
- uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
- type = db_get_b(hContact, m_szModuleName, "ChatRoom", 0);
+ uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0);
+ type = getByte(hContact, "ChatRoom", 0);
// Terminate conference if contact is deleted
- if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR) && gc_enabled)
+ if (type && !getTString(hContact, "ChatRoomID", &dbv) && gc_enabled)
{
-
GCDEST gcdest = {0};
gcdest.pszModule = m_szModuleName;
gcdest.ptszID = dbv.ptszVal;
@@ -1382,8 +1378,8 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) // Groupchat window contact is being renamed
DBVARIANT dbv;
- int type = db_get_b(hContact, m_szModuleName, "ChatRoom", 0);
- if (type && !db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR))
+ int type = getByte(hContact, "ChatRoom", 0);
+ if (type && !getTString(hContact, "ChatRoomID", &dbv))
{
// Most important... check redundancy (fucking cascading)
static int cascade = 0;
@@ -1417,7 +1413,7 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) if (!strcmp(cws->szSetting, "MyHandle")){
TCHAR* ptszVal = sttSettingToTchar(&(cws->value));
if(ptszVal==NULL) return 0;
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, ptszVal);
+ setTString(hContact, GG_KEY_NICK, ptszVal);
mir_free(ptszVal);
}
@@ -1445,13 +1441,13 @@ int GGPROTO::dbsettingchanged(WPARAM wParam, LPARAM lParam) void GGPROTO::setalloffline()
{
netlog("setalloffline(): started. Setting buddies offline");
- db_set_w(NULL, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
+ setWord(GG_KEY_STATUS, ID_STATUS_OFFLINE);
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
+ setWord(hContact, GG_KEY_STATUS, ID_STATUS_OFFLINE);
// Clear IP and port settings
- db_unset(hContact, m_szModuleName, GG_KEY_CLIENTIP);
- db_unset(hContact, m_szModuleName, GG_KEY_CLIENTPORT);
+ delSetting(hContact, GG_KEY_CLIENTIP);
+ delSetting(hContact, GG_KEY_CLIENTPORT);
// Delete status descr
db_unset(hContact, "CList", GG_KEY_STATUSDESCR);
}
@@ -1467,11 +1463,11 @@ void GGPROTO::notifyuser(HANDLE hContact, int refresh) {
uin_t uin;
if (!hContact) return;
- if (isonline() && (uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)))
+ if (isonline() && (uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0)))
{
// Check if user should be invisible
// Or be blocked ?
- if ((db_get_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
+ if ((getWord(hContact, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
db_get_b(hContact, "CList", "NotOnList", 0))
{
gg_EnterCriticalSection(&sess_mutex, "notifyuser", 77, "sess_mutex", 1);
@@ -1483,7 +1479,7 @@ void GGPROTO::notifyuser(HANDLE hContact, int refresh) gg_add_notify_ex(sess, uin, GG_USER_OFFLINE);
gg_LeaveCriticalSection(&sess_mutex, "notifyuser", 77, 1, "sess_mutex", 1);
}
- else if (db_get_b(hContact, m_szModuleName, GG_KEY_BLOCK, 0))
+ else if (getByte(hContact, GG_KEY_BLOCK, 0))
{
gg_EnterCriticalSection(&sess_mutex, "notifyuser", 78, "sess_mutex", 1);
if (refresh)
@@ -1530,11 +1526,11 @@ void GGPROTO::notifyall() types = (char*)calloc(sizeof(char), count);
for (hContact = db_find_first(m_szModuleName); hContact && cc < count; hContact = db_find_next(hContact, m_szModuleName)) {
- if (uins[cc] = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)) {
- if ((db_get_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
+ if (uins[cc] = getDword(hContact, GG_KEY_UIN, 0)) {
+ if ((getWord(hContact, GG_KEY_APPARENT, (WORD) ID_STATUS_ONLINE) == ID_STATUS_OFFLINE) ||
db_get_b(hContact, "CList", "NotOnList", 0))
types[cc] = GG_USER_OFFLINE;
- else if (db_get_b(hContact, m_szModuleName, GG_KEY_BLOCK, 0))
+ else if (getByte(hContact, GG_KEY_BLOCK, 0))
types[cc] = GG_USER_BLOCKED;
else
types[cc] = GG_USER_NORMAL;
@@ -1565,7 +1561,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) #endif
// Look for contact in DB
for (HANDLE hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if ((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0) == uin && !db_get_b(hContact, m_szModuleName, "ChatRoom", 0)) {
+ if ((uin_t)getDword(hContact, GG_KEY_UIN, 0) == uin && !getByte(hContact, "ChatRoom", 0)) {
if (inlist) {
db_unset(hContact, "CList", "NotOnList");
db_unset(hContact, "CList", "Hidden");
@@ -1593,13 +1589,13 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) if (!inlist)
db_set_b(hContact, "CList", "NotOnList", 1);
- db_set_dw(hContact, m_szModuleName, GG_KEY_UIN, (DWORD) uin);
- db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, ID_STATUS_OFFLINE);
+ setDword(hContact, GG_KEY_UIN, (DWORD) uin);
+ setWord(hContact, GG_KEY_STATUS, ID_STATUS_OFFLINE);
// If nick specified use it
- if (szNick) {
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, szNick);
- } else if (isonline()) {
+ if (szNick)
+ setTString(hContact, GG_KEY_NICK, szNick);
+ else if (isonline()) {
gg_pubdir50_t req;
// Search for that nick
@@ -1612,7 +1608,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) gg_LeaveCriticalSection(&sess_mutex, "getcontact", 31, 1, "sess_mutex", 1);
gg_pubdir50_free(req);
TCHAR* uinT = mir_a2t(ditoa(uin));
- db_set_ts(hContact, m_szModuleName, GG_KEY_NICK, uinT);
+ setTString(hContact, GG_KEY_NICK, uinT);
mir_free(uinT);
netlog("getcontact(): Search for nick on uin: %d", uin);
}
@@ -1632,7 +1628,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) getavatarinfo((WPARAM)GAIF_FORCE, (LPARAM)&pai);
// Change status of the contact with our own UIN (if got yourself added to the contact list)
- if (db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0) == uin) {
+ if (getDword(GG_KEY_UIN, 0) == uin) {
TCHAR *szMsg;
gg_EnterCriticalSection(&modemsg_mutex, "getcontact", 33, "modemsg_mutex", 1);
szMsg = mir_tstrdup(getstatusmsg(m_iStatus));
@@ -1652,7 +1648,7 @@ HANDLE GGPROTO::getcontact(uin_t uin, int create, int inlist, TCHAR *szNick) int GGPROTO::status_m2gg(int status, int descr)
{
// check frends only
- int mask = db_get_b(NULL, m_szModuleName, GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY) ? GG_STATUS_FRIENDS_MASK : 0;
+ int mask = getByte(GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY) ? GG_STATUS_FRIENDS_MASK : 0;
if (descr)
{
@@ -1688,7 +1684,7 @@ int GGPROTO::status_gg2m(int status) status = GG_S(status);
// when user has status description but is offline (show it invisible)
- if (status == GG_STATUS_NOT_AVAIL_DESCR && db_get_b(NULL, m_szModuleName, GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE))
+ if (status == GG_STATUS_NOT_AVAIL_DESCR && getByte(GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE))
return ID_STATUS_INVISIBLE;
// rest of cases
@@ -1740,7 +1736,7 @@ void GGPROTO::changecontactstatus(uin_t uin, int status, const TCHAR *idescr, in if (!hContact) return;
// Write contact status
- db_set_w(hContact, m_szModuleName, GG_KEY_STATUS, (WORD)status_gg2m(status));
+ setWord(hContact, GG_KEY_STATUS, (WORD)status_gg2m(status));
// Check if there's description and if it's not empty
if (idescr && *idescr)
@@ -1753,14 +1749,14 @@ void GGPROTO::changecontactstatus(uin_t uin, int status, const TCHAR *idescr, in }
// Store contact ip and port
- if (remote_ip) db_set_dw(hContact, m_szModuleName, GG_KEY_CLIENTIP, (DWORD) swap32(remote_ip));
- if (remote_port) db_set_w(hContact, m_szModuleName, GG_KEY_CLIENTPORT, (WORD) remote_port);
+ if (remote_ip) setDword(hContact, GG_KEY_CLIENTIP, (DWORD) swap32(remote_ip));
+ if (remote_port) setWord(hContact, GG_KEY_CLIENTPORT, (WORD) remote_port);
if (version)
{
char sversion[48];
- db_set_dw(hContact, m_szModuleName, GG_KEY_CLIENTVERSION, (DWORD) version);
+ setDword(hContact, GG_KEY_CLIENTVERSION, (DWORD) version);
mir_snprintf(sversion, sizeof(sversion), "%sGadu-Gadu %s", (version & 0x00ffffff) > 0x2b ? "Nowe " : "", gg_version2string(version));
- db_set_s(hContact, m_szModuleName, "MirVer", sversion);
+ setString(hContact, "MirVer", sversion);
}
}
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp index 78acff5c01..55d531e6af 100644 --- a/protocols/Gadu-Gadu/src/dialogs.cpp +++ b/protocols/Gadu-Gadu/src/dialogs.cpp @@ -187,10 +187,10 @@ void GGPROTO::checknewuser(uin_t uin, const char* passwd) {
char oldpasswd[128];
DBVARIANT dbv;
- uin_t olduin = (uin_t)db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t olduin = (uin_t)getDword(GG_KEY_UIN, 0);
oldpasswd[0] = '\0';
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_PASSWORD, &dbv))
{
if (dbv.pszVal) strcpy(oldpasswd, dbv.pszVal);
db_free(&dbv);
@@ -242,7 +242,7 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
TranslateDialogDefault(hwndDlg);
- if (num = db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
+ if (num = gg->getDword(GG_KEY_UIN, 0))
{
SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
ShowWindow(GetDlgItem(hwndDlg, IDC_CREATEACCOUNT), SW_HIDE);
@@ -253,12 +253,12 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, ShowWindow(GetDlgItem(hwndDlg, IDC_REMOVEACCOUNT), SW_HIDE);
ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
}
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
@@ -268,19 +268,19 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, ShowWindow(GetDlgItem(hwndDlg, IDC_CHPASS), SW_HIDE);
}
- CheckDlgButton(hwndDlg, IDC_FRIENDSONLY, db_get_b(NULL, gg->m_szModuleName, GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY));
- CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLE, db_get_b(NULL, gg->m_szModuleName, GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE));
- CheckDlgButton(hwndDlg, IDC_LEAVESTATUSMSG, db_get_b(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG));
+ CheckDlgButton(hwndDlg, IDC_FRIENDSONLY, gg->getByte(GG_KEY_FRIENDSONLY, GG_KEYDEF_FRIENDSONLY));
+ CheckDlgButton(hwndDlg, IDC_SHOWINVISIBLE, gg->getByte(GG_KEY_SHOWINVISIBLE, GG_KEYDEF_SHOWINVISIBLE));
+ CheckDlgButton(hwndDlg, IDC_LEAVESTATUSMSG, gg->getByte(GG_KEY_LEAVESTATUSMSG, GG_KEYDEF_LEAVESTATUSMSG));
if (gg->gc_enabled)
- CheckDlgButton(hwndDlg, IDC_IGNORECONF, db_get_b(NULL, gg->m_szModuleName, GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF));
+ CheckDlgButton(hwndDlg, IDC_IGNORECONF, gg->getByte(GG_KEY_IGNORECONF, GG_KEYDEF_IGNORECONF));
else
{
EnableWindow(GetDlgItem(hwndDlg, IDC_IGNORECONF), FALSE);
CheckDlgButton(hwndDlg, IDC_IGNORECONF, TRUE);
}
- CheckDlgButton(hwndDlg, IDC_IMGRECEIVE, db_get_b(NULL, gg->m_szModuleName, GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE));
- CheckDlgButton(hwndDlg, IDC_SHOWLINKS, db_get_b(NULL, gg->m_szModuleName, GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS));
- CheckDlgButton(hwndDlg, IDC_ENABLEAVATARS, db_get_b(NULL, gg->m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS));
+ CheckDlgButton(hwndDlg, IDC_IMGRECEIVE, gg->getByte(GG_KEY_IMGRECEIVE, GG_KEYDEF_IMGRECEIVE));
+ CheckDlgButton(hwndDlg, IDC_SHOWLINKS, gg->getByte(GG_KEY_SHOWLINKS, GG_KEYDEF_SHOWLINKS));
+ CheckDlgButton(hwndDlg, IDC_ENABLEAVATARS, gg->getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS));
EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
@@ -290,7 +290,7 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_DND,GSMDF_TCHAR));
SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_FREECHAT,GSMDF_TCHAR));
SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_ADDSTRING, 0, (LPARAM)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,ID_STATUS_INVISIBLE,GSMDF_TCHAR));
- switch(db_get_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
+ switch(gg->getWord(GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS)) {
case ID_STATUS_ONLINE:
SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_SETCURSEL, 1, 0);
break;
@@ -313,213 +313,205 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("System tray icon"));
SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Popup window"));
SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_ADDSTRING, 0, (LPARAM)TranslateT("Message with [img] BBCode"));
- SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_SETCURSEL,
- db_get_b(NULL, gg->m_szModuleName, GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD), 0);
- break;
+ SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_SETCURSEL, gg->getByte(GG_KEY_IMGMETHOD, GG_KEYDEF_IMGMETHOD), 0);
}
+ break;
+
case WM_COMMAND:
- {
- if ((LOWORD(wParam) == IDC_UIN || LOWORD(wParam) == IDC_PASSWORD || LOWORD(wParam) == IDC_EMAIL)
- && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
- return 0;
-
- switch (LOWORD(wParam)) {
- case IDC_EMAIL:
- case IDC_UIN:
- gg_optsdlgcheck(hwndDlg);
- break;
+ if ((LOWORD(wParam) == IDC_UIN || LOWORD(wParam) == IDC_PASSWORD || LOWORD(wParam) == IDC_EMAIL)
+ && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
+ return 0;
- case IDC_LEAVESTATUSMSG:
- EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
- break;
+ switch (LOWORD(wParam)) {
+ case IDC_EMAIL:
+ case IDC_UIN:
+ gg_optsdlgcheck(hwndDlg);
+ break;
- case IDC_IMGRECEIVE:
- EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
- break;
+ case IDC_LEAVESTATUSMSG:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LEAVESTATUS), IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
+ break;
- case IDC_LOSTPASS:
+ case IDC_IMGRECEIVE:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_IMGMETHOD), IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
+ break;
+
+ case IDC_LOSTPASS:
+ {
+ char email[128];
+ uin_t uin;
+ GetDlgItemTextA(hwndDlg, IDC_UIN, email, sizeof(email));
+ uin = atoi(email);
+ GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, sizeof(email));
+ if (!strlen(email))
+ MessageBox(NULL, TranslateT("You need to specify your registration e-mail first."),
+ gg->m_tszUserName, MB_OK | MB_ICONEXCLAMATION);
+ else if (MessageBox(NULL,
+ TranslateT("Your password will be sent to your registration e-mail.\nDo you want to continue ?"),
+ gg->m_tszUserName,
+ MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
+ gg->remindpassword(uin, email);
+ return FALSE;
+ }
+ case IDC_CREATEACCOUNT:
+ case IDC_REMOVEACCOUNT:
+ if (gg->isonline())
+ {
+ if (MessageBox(
+ NULL,
+ TranslateT("You should disconnect before making any permanent changes with your account.\nDo you want to disconnect now ?"),
+ gg->m_tszUserName,
+ MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
+ break;
+ else
+ gg->disconnect();
+ }
+ case IDC_CHPASS:
+ case IDC_CHEMAIL:
+ {
+ // Readup data
+ GGUSERUTILDLGDATA dat;
+ int ret;
+ char pass[128], email[128];
+ GetDlgItemTextA(hwndDlg, IDC_UIN, pass, sizeof(pass));
+ dat.uin = atoi(pass);
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, pass, sizeof(pass));
+ GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, sizeof(email));
+ dat.pass = pass;
+ dat.email = email;
+ dat.gg = gg;
+ if (LOWORD(wParam) == IDC_CREATEACCOUNT)
{
- char email[128];
- uin_t uin;
- GetDlgItemTextA(hwndDlg, IDC_UIN, email, sizeof(email));
- uin = atoi(email);
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, sizeof(email));
- if (!strlen(email))
- MessageBox(NULL, TranslateT("You need to specify your registration e-mail first."),
- gg->m_tszUserName, MB_OK | MB_ICONEXCLAMATION);
- else if (MessageBox(NULL,
- TranslateT("Your password will be sent to your registration e-mail.\nDo you want to continue ?"),
- gg->m_tszUserName,
- MB_OKCANCEL | MB_ICONQUESTION) == IDOK)
- gg->remindpassword(uin, email);
- return FALSE;
+ dat.mode = GG_USERUTIL_CREATE;
+ ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
- case IDC_CREATEACCOUNT:
- case IDC_REMOVEACCOUNT:
- if (gg->isonline())
+ else if (LOWORD(wParam) == IDC_CHPASS)
{
- if (MessageBox(
- NULL,
- TranslateT("You should disconnect before making any permanent changes with your account.\nDo you want to disconnect now ?"),
- gg->m_tszUserName,
- MB_OKCANCEL | MB_ICONEXCLAMATION) == IDCANCEL)
- break;
- else
- gg->disconnect();
+ dat.mode = GG_USERUTIL_PASS;
+ ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
}
- case IDC_CHPASS:
- case IDC_CHEMAIL:
+ else if (LOWORD(wParam) == IDC_CHEMAIL)
{
- // Readup data
- GGUSERUTILDLGDATA dat;
- int ret;
- char pass[128], email[128];
- GetDlgItemTextA(hwndDlg, IDC_UIN, pass, sizeof(pass));
- dat.uin = atoi(pass);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, pass, sizeof(pass));
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, email, sizeof(email));
- dat.pass = pass;
- dat.email = email;
- dat.gg = gg;
- if (LOWORD(wParam) == IDC_CREATEACCOUNT)
- {
- dat.mode = GG_USERUTIL_CREATE;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CREATEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
- }
- else if (LOWORD(wParam) == IDC_CHPASS)
- {
- dat.mode = GG_USERUTIL_PASS;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHPASS), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
- }
- else if (LOWORD(wParam) == IDC_CHEMAIL)
- {
- dat.mode = GG_USERUTIL_EMAIL;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
- }
+ dat.mode = GG_USERUTIL_EMAIL;
+ ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHEMAIL), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ }
+ else
+ {
+ dat.mode = GG_USERUTIL_REMOVE;
+ ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ }
+
+ if (ret == IDOK)
+ {
+ DBVARIANT dbv;
+ DWORD num;
+ // Show reload required window
+ ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
+
+ // Update uin
+ if (num = gg->getDword(GG_KEY_UIN, 0))
+ SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
else
- {
- dat.mode = GG_USERUTIL_REMOVE;
- ret = DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_REMOVEACCOUNT), hwndDlg, gg_userutildlgproc, (LPARAM)&dat);
+ SetDlgItemTextA(hwndDlg, IDC_UIN, "");
+
+ // Update password
+ if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
+ db_free(&dbv);
}
+ else SetDlgItemTextA(hwndDlg, IDC_PASSWORD, "");
- if (ret == IDOK)
- {
- DBVARIANT dbv;
- DWORD num;
- // Show reload required window
- ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
-
- // Update uin
- if (num = db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
- SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
- else
- SetDlgItemTextA(hwndDlg, IDC_UIN, "");
-
- // Update password
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
- db_free(&dbv);
- }
- else SetDlgItemTextA(hwndDlg, IDC_PASSWORD, "");
-
- // Update e-mail
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
- db_free(&dbv);
- }
- else SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
-
- // Update links
- gg_optsdlgcheck(hwndDlg);
-
- // Remove details
- if (LOWORD(wParam) != IDC_CHPASS && LOWORD(wParam) != IDC_CHEMAIL)
- {
- db_unset(NULL, gg->m_szModuleName, GG_KEY_NICK);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_NICKNAME);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_CITY);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_LASTNAME);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FAMILYNAME);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_FAMILYCITY );
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_AGE);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_BIRTHYEAR);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PD_GANDER);
- }
+ // Update e-mail
+ if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
+ db_free(&dbv);
}
- }
- break;
- }
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->code) {
- case PSN_APPLY:
- {
- int status_flags = GG_STATUS_FLAG_UNKNOWN;
- char str[128];
- uin_t uin;
+ else SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
- // Write Gadu-Gadu number & password
- GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
- uin = atoi(str);
- GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str));
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
- gg->checknewuser(uin, str);
- db_set_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, uin);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, str);
+ // Update links
+ gg_optsdlgcheck(hwndDlg);
- // Write Gadu-Gadu email
- GetDlgItemTextA(hwndDlg, IDC_EMAIL, str, sizeof(str));
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, str);
-
- // Write checkboxes
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_FRIENDSONLY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FRIENDSONLY));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_SHOWINVISIBLE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWINVISIBLE));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUSMSG, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
- if (gg->gc_enabled)
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_IGNORECONF, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_IGNORECONF));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_IMGRECEIVE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_SHOWLINKS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS));
- if (IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS))
- status_flags |= GG_STATUS_FLAG_SPAM;
- gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, "sess_mutex", 1);
- gg_change_status_flags(gg->sess, status_flags);
- gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, 1, "sess_mutex", 1);
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_ENABLEAVATARS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS));
-
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_IMGMETHOD,
- (BYTE)SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_GETCURSEL, 0, 0));
-
- // Write leave status
- switch(SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_GETCURSEL, 0, 0))
+ // Remove details
+ if (LOWORD(wParam) != IDC_CHPASS && LOWORD(wParam) != IDC_CHEMAIL)
{
- case 1:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, ID_STATUS_ONLINE);
- break;
- case 2:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, ID_STATUS_AWAY);
- break;
- case 3:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, ID_STATUS_DND);
- break;
- case 4:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, ID_STATUS_FREECHAT);
- break;
- case 5:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, ID_STATUS_INVISIBLE);
- break;
- default:
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS);
+ gg->delSetting(GG_KEY_NICK);
+ gg->delSetting(GG_KEY_PD_NICKNAME);
+ gg->delSetting(GG_KEY_PD_CITY);
+ gg->delSetting(GG_KEY_PD_FIRSTNAME);
+ gg->delSetting(GG_KEY_PD_LASTNAME);
+ gg->delSetting(GG_KEY_PD_FAMILYNAME);
+ gg->delSetting(GG_KEY_PD_FAMILYCITY );
+ gg->delSetting(GG_KEY_PD_AGE);
+ gg->delSetting(GG_KEY_PD_BIRTHYEAR);
+ gg->delSetting(GG_KEY_PD_GANDER);
}
- break;
}
}
break;
}
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case WM_NOTIFY:
+ switch (((LPNMHDR) lParam)->code) {
+ case PSN_APPLY:
+ int status_flags = GG_STATUS_FLAG_UNKNOWN;
+ char str[128];
+ uin_t uin;
+
+ // Write Gadu-Gadu number & password
+ GetDlgItemTextA(hwndDlg, IDC_UIN, str, sizeof(str));
+ uin = atoi(str);
+ GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str));
+ CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
+ gg->checknewuser(uin, str);
+ gg->setDword(GG_KEY_UIN, uin);
+ gg->setString(GG_KEY_PASSWORD, str);
+
+ // Write Gadu-Gadu email
+ GetDlgItemTextA(hwndDlg, IDC_EMAIL, str, sizeof(str));
+ gg->setString(GG_KEY_EMAIL, str);
+
+ // Write checkboxes
+ gg->setByte(GG_KEY_FRIENDSONLY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FRIENDSONLY));
+ gg->setByte(GG_KEY_SHOWINVISIBLE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWINVISIBLE));
+ gg->setByte(GG_KEY_LEAVESTATUSMSG, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_LEAVESTATUSMSG));
+ if (gg->gc_enabled)
+ gg->setByte(GG_KEY_IGNORECONF, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_IGNORECONF));
+ gg->setByte(GG_KEY_IMGRECEIVE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_IMGRECEIVE));
+ gg->setByte(GG_KEY_SHOWLINKS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS));
+ if (IsDlgButtonChecked(hwndDlg, IDC_SHOWLINKS))
+ status_flags |= GG_STATUS_FLAG_SPAM;
+ gg->gg_EnterCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, "sess_mutex", 1);
+ gg_change_status_flags(gg->sess, status_flags);
+ gg->gg_LeaveCriticalSection(&gg->sess_mutex, "gg_genoptsdlgproc", 34, 1, "sess_mutex", 1);
+ gg->setByte(GG_KEY_ENABLEAVATARS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLEAVATARS));
+
+ gg->setByte(GG_KEY_IMGMETHOD, (BYTE)SendDlgItemMessage(hwndDlg, IDC_IMGMETHOD, CB_GETCURSEL, 0, 0));
+
+ // Write leave status
+ switch(SendDlgItemMessage(hwndDlg, IDC_LEAVESTATUS, CB_GETCURSEL, 0, 0)) {
+ case 1:
+ gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_ONLINE);
+ break;
+ case 2:
+ gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_AWAY);
+ break;
+ case 3:
+ gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_DND);
+ break;
+ case 4:
+ gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_FREECHAT);
+ break;
+ case 5:
+ gg->setWord(GG_KEY_LEAVESTATUS, ID_STATUS_INVISIBLE);
+ break;
+ default:
+ gg->setWord(GG_KEY_LEAVESTATUS, GG_KEYDEF_LEAVESTATUS);
+ }
+ }
+ break;
}
return FALSE;
}
@@ -530,73 +522,59 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, static INT_PTR CALLBACK gg_confoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ DWORD num;
switch (msg) {
case WM_INITDIALOG:
- {
- DWORD num;
- GGPROTO *gg = (GGPROTO *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ gg = (GGPROTO *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
- TranslateDialogDefault(hwndDlg);
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_SETCURSEL,
- db_get_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL), 0);
-
- if (num = db_get_w(NULL, gg->m_szModuleName, GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL))
- SetDlgItemTextA(hwndDlg, IDC_GC_COUNT_TOTAL, ditoa(num));
-
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_SETCURSEL,
- db_get_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN), 0);
-
- if (num = db_get_w(NULL, gg->m_szModuleName, GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))
- SetDlgItemTextA(hwndDlg, IDC_GC_COUNT_UNKNOWN, ditoa(num));
-
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
- SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_SETCURSEL,
- db_get_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT), 0);
- break;
- }
- case WM_COMMAND:
- {
- if ((LOWORD(wParam) == IDC_GC_COUNT_TOTAL || LOWORD(wParam) == IDC_GC_COUNT_UNKNOWN)
- && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
- return 0;
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->code) {
- case PSN_APPLY:
- {
- char str[128];
-
- // Write groupchat policy
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_TOTAL,
- (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_GETCURSEL, 0, 0));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_UNKNOWN,
- (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_GETCURSEL, 0, 0));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_GC_POLICY_DEFAULT,
- (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_GETCURSEL, 0, 0));
+ TranslateDialogDefault(hwndDlg);
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_SETCURSEL, gg->getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL), 0);
+
+ if (num = gg->getWord(GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL))
+ SetDlgItemTextA(hwndDlg, IDC_GC_COUNT_TOTAL, ditoa(num));
+
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_SETCURSEL, gg->getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN), 0);
+
+ if (num = gg->getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))
+ SetDlgItemTextA(hwndDlg, IDC_GC_COUNT_UNKNOWN, ditoa(num));
+
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Allow"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ask"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_ADDSTRING, 0, (LPARAM)TranslateT("Ignore"));
+ SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_SETCURSEL, gg->getWord(GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT), 0);
+ break;
- GetDlgItemTextA(hwndDlg, IDC_GC_COUNT_TOTAL, str, sizeof(str));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_GC_COUNT_TOTAL, (WORD)atoi(str));
- GetDlgItemTextA(hwndDlg, IDC_GC_COUNT_UNKNOWN, str, sizeof(str));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_GC_COUNT_UNKNOWN, (WORD)atoi(str));
+ case WM_COMMAND:
+ if ((LOWORD(wParam) == IDC_GC_COUNT_TOTAL || LOWORD(wParam) == IDC_GC_COUNT_UNKNOWN)
+ && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
+ return 0;
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
- break;
- }
- }
- break;
+ case WM_NOTIFY:
+ switch (((LPNMHDR) lParam)->code) {
+ case PSN_APPLY:
+ char str[128];
+
+ // Write groupchat policy
+ gg->setWord(GG_KEY_GC_POLICY_TOTAL, (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_TOTAL, CB_GETCURSEL, 0, 0));
+ gg->setWord(GG_KEY_GC_POLICY_UNKNOWN, (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_UNKNOWN, CB_GETCURSEL, 0, 0));
+ gg->setWord(GG_KEY_GC_POLICY_DEFAULT, (WORD)SendDlgItemMessage(hwndDlg, IDC_GC_POLICY_DEFAULT, CB_GETCURSEL, 0, 0));
+
+ GetDlgItemTextA(hwndDlg, IDC_GC_COUNT_TOTAL, str, sizeof(str));
+ gg->setWord(GG_KEY_GC_COUNT_TOTAL, (WORD)atoi(str));
+ GetDlgItemTextA(hwndDlg, IDC_GC_COUNT_UNKNOWN, str, sizeof(str));
+ gg->setWord(GG_KEY_GC_COUNT_UNKNOWN, (WORD)atoi(str));
}
+ break;
}
return FALSE;
}
@@ -606,110 +584,106 @@ static INT_PTR CALLBACK gg_confoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam static INT_PTR CALLBACK gg_advoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
GGPROTO *gg = (GGPROTO *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ DBVARIANT dbv;
+ DWORD num;
switch (msg) {
case WM_INITDIALOG:
- {
- DBVARIANT dbv;
- DWORD num;
- GGPROTO *gg = (GGPROTO *)lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
+ gg = (GGPROTO *)lParam;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
- TranslateDialogDefault(hwndDlg);
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_SERVERHOSTS, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_HOST, dbv.pszVal);
- db_free(&dbv);
- }
- else SetDlgItemTextA(hwndDlg, IDC_HOST, GG_KEYDEF_SERVERHOSTS);
-
- CheckDlgButton(hwndDlg, IDC_KEEPALIVE, db_get_b(NULL, gg->m_szModuleName, GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE));
- CheckDlgButton(hwndDlg, IDC_SHOWCERRORS, db_get_b(NULL, gg->m_szModuleName, GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS));
- CheckDlgButton(hwndDlg, IDC_ARECONNECT, db_get_b(NULL, gg->m_szModuleName, GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT));
- CheckDlgButton(hwndDlg, IDC_MSGACK, db_get_b(NULL, gg->m_szModuleName, GG_KEY_MSGACK, GG_KEYDEF_MSGACK));
- CheckDlgButton(hwndDlg, IDC_MANUALHOST, db_get_b(NULL, gg->m_szModuleName, GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST));
- CheckDlgButton(hwndDlg, IDC_SSLCONN, db_get_b(NULL, gg->m_szModuleName, GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN));
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
- EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
-
- CheckDlgButton(hwndDlg, IDC_DIRECTCONNS, db_get_b(NULL, gg->m_szModuleName, GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS));
- if (num = db_get_w(NULL, gg->m_szModuleName, GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT))
- SetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, ditoa(num));
- CheckDlgButton(hwndDlg, IDC_FORWARDING, db_get_b(NULL, gg->m_szModuleName, GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING));
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_FORWARDHOST, &dbv, DBVT_ASCIIZ)) {
- SetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, dbv.pszVal);
- db_free(&dbv);
- }
- if (num = db_get_w(NULL, gg->m_szModuleName, GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT))
- SetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, ditoa(num));
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- break;
+ TranslateDialogDefault(hwndDlg);
+ if (!gg->getString(GG_KEY_SERVERHOSTS, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_HOST, dbv.pszVal);
+ db_free(&dbv);
+ }
+ else SetDlgItemTextA(hwndDlg, IDC_HOST, GG_KEYDEF_SERVERHOSTS);
+
+ CheckDlgButton(hwndDlg, IDC_KEEPALIVE, gg->getByte(GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE));
+ CheckDlgButton(hwndDlg, IDC_SHOWCERRORS, gg->getByte(GG_KEY_SHOWCERRORS, GG_KEYDEF_SHOWCERRORS));
+ CheckDlgButton(hwndDlg, IDC_ARECONNECT, gg->getByte(GG_KEY_ARECONNECT, GG_KEYDEF_ARECONNECT));
+ CheckDlgButton(hwndDlg, IDC_MSGACK, gg->getByte(GG_KEY_MSGACK, GG_KEYDEF_MSGACK));
+ CheckDlgButton(hwndDlg, IDC_MANUALHOST, gg->getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST));
+ CheckDlgButton(hwndDlg, IDC_SSLCONN, gg->getByte(GG_KEY_SSLCONN, GG_KEYDEF_SSLCONN));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
+
+ CheckDlgButton(hwndDlg, IDC_DIRECTCONNS, gg->getByte(GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS));
+ if (num = gg->getWord(GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT))
+ SetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, ditoa(num));
+ CheckDlgButton(hwndDlg, IDC_FORWARDING, gg->getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING));
+ if (!gg->getString(GG_KEY_FORWARDHOST, &dbv)) {
+ SetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, dbv.pszVal);
+ db_free(&dbv);
}
+ if (num = gg->getWord(GG_KEY_FORWARDPORT, GG_KEYDEF_FORWARDPORT))
+ SetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, ditoa(num));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ break;
+
case WM_COMMAND:
- {
- if ((LOWORD(wParam) == IDC_DIRECTPORT || LOWORD(wParam) == IDC_FORWARDHOST || LOWORD(wParam) == IDC_FORWARDPORT)
- && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
- return 0;
- switch (LOWORD(wParam)) {
- case IDC_MANUALHOST:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
- EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
- ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
- break;
- }
- case IDC_DIRECTCONNS:
- case IDC_FORWARDING:
- {
- EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
- break;
- }
+ if ((LOWORD(wParam) == IDC_DIRECTPORT || LOWORD(wParam) == IDC_FORWARDHOST || LOWORD(wParam) == IDC_FORWARDPORT)
+ && (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus()))
+ return 0;
+ switch (LOWORD(wParam)) {
+ case IDC_MANUALHOST:
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_HOST), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PORT), IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
+ break;
+ }
+ case IDC_DIRECTCONNS:
+ case IDC_FORWARDING:
+ {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_DIRECTPORT), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDING), IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDPORT), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FORWARDHOST), IsDlgButtonChecked(hwndDlg, IDC_FORWARDING) && IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
+ break;
}
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
}
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
case WM_NOTIFY:
- {
- switch (((LPNMHDR) lParam)->code) {
- case PSN_APPLY:
- {
- char str[512];
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_KEEPALIVE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_SHOWCERRORS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWCERRORS));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_ARECONNECT, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ARECONNECT));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_MSGACK, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MSGACK));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_MANUALHOST, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_SSLCONN, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SSLCONN));
-
- // Transfer settings
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_DIRECTCONNS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
- db_set_b(NULL, gg->m_szModuleName, GG_KEY_FORWARDING, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FORWARDING));
-
- // Write custom servers
- GetDlgItemTextA(hwndDlg, IDC_HOST, str, sizeof(str));
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_SERVERHOSTS, str);
-
- // Write direct port
- GetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, str, sizeof(str));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_DIRECTPORT, (WORD)atoi(str));
- // Write forwarding host
- GetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, str, sizeof(str));
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_FORWARDHOST, str);
- GetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, str, sizeof(str));
- db_set_w(NULL, gg->m_szModuleName, GG_KEY_FORWARDPORT, (WORD)atoi(str));
- break;
- }
+ switch (((LPNMHDR) lParam)->code) {
+ case PSN_APPLY:
+ {
+ char str[512];
+ gg->setByte(GG_KEY_KEEPALIVE, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_KEEPALIVE));
+ gg->setByte(GG_KEY_SHOWCERRORS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SHOWCERRORS));
+ gg->setByte(GG_KEY_ARECONNECT, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ARECONNECT));
+ gg->setByte(GG_KEY_MSGACK, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MSGACK));
+ gg->setByte(GG_KEY_MANUALHOST, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_MANUALHOST));
+ gg->setByte(GG_KEY_SSLCONN, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SSLCONN));
+
+ // Transfer settings
+ gg->setByte(GG_KEY_DIRECTCONNS, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DIRECTCONNS));
+ gg->setByte(GG_KEY_FORWARDING, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FORWARDING));
+
+ // Write custom servers
+ GetDlgItemTextA(hwndDlg, IDC_HOST, str, sizeof(str));
+ gg->setString(GG_KEY_SERVERHOSTS, str);
+
+ // Write direct port
+ GetDlgItemTextA(hwndDlg, IDC_DIRECTPORT, str, sizeof(str));
+ gg->setWord(GG_KEY_DIRECTPORT, (WORD)atoi(str));
+ // Write forwarding host
+ GetDlgItemTextA(hwndDlg, IDC_FORWARDHOST, str, sizeof(str));
+ gg->setString(GG_KEY_FORWARDHOST, str);
+ GetDlgItemTextA(hwndDlg, IDC_FORWARDPORT, str, sizeof(str));
+ gg->setWord(GG_KEY_FORWARDPORT, (WORD)atoi(str));
+ break;
}
- break;
}
+ break;
}
return FALSE;
}
@@ -799,8 +773,7 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, SetValue(hwndDlg, IDC_GENDER, hContact, szProto, GG_KEY_PD_GANDER, SVS_GENDER, hContact != NULL);
SetValue(hwndDlg, IDC_STATUSDESCR, hContact, "CList", GG_KEY_STATUSDESCR, SVS_NORMAL, hContact != NULL);
}
- else switch((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (BYTE)'?'))
- {
+ else switch((char)db_get_b(hContact, gg->m_szModuleName, GG_KEY_PD_GANDER, (BYTE)'?')) {
case 'F':
SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_SETCURSEL, 1, 0);
break;
@@ -820,8 +793,7 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, }
break;
case WM_COMMAND:
- if (dat && !dat->hContact && LOWORD(wParam) == IDC_SAVE && HIWORD(wParam) == BN_CLICKED)
- {
+ if (dat && !dat->hContact && LOWORD(wParam) == IDC_SAVE && HIWORD(wParam) == BN_CLICKED) {
// Save user data
TCHAR text[256];
gg_pubdir50_t req;
@@ -868,8 +840,7 @@ static INT_PTR CALLBACK gg_detailsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, }
// Gadu-Gadu Female <-> Male
- switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0))
- {
+ switch(SendDlgItemMessage(hwndDlg, IDC_GENDER, CB_GETCURSEL, 0, 0)) {
case 1:
gg_pubdir50_add(req, GG_PUBDIR50_GENDER, GG_PUBDIR50_GENDER_SET_FEMALE);
break;
@@ -941,19 +912,15 @@ int GGPROTO::details_init(WPARAM wParam, LPARAM lParam) return 0;
// Here goes init
- {
- OPTIONSDIALOGPAGE odp = {0};
-
- odp.cbSize = sizeof(odp);
- odp.flags = ODPF_DONTTRANSLATE | ODPF_TCHAR;
- odp.hInstance = hInstance;
- odp.pfnDlgProc = gg_detailsdlgproc;
- odp.position = -1900000000;
- odp.pszTemplate = ((HANDLE)lParam != NULL) ? MAKEINTRESOURCEA(IDD_INFO_GG) : MAKEINTRESOURCEA(IDD_CHINFO_GG);
- odp.ptszTitle = m_tszUserName;
- odp.dwInitParam = (LPARAM)this;
- UserInfo_AddPage(wParam, &odp);
- }
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.flags = ODPF_DONTTRANSLATE | ODPF_TCHAR;
+ odp.hInstance = hInstance;
+ odp.pfnDlgProc = gg_detailsdlgproc;
+ odp.position = -1900000000;
+ odp.pszTemplate = ((HANDLE)lParam != NULL) ? MAKEINTRESOURCEA(IDD_INFO_GG) : MAKEINTRESOURCEA(IDD_CHINFO_GG);
+ odp.ptszTitle = m_tszUserName;
+ odp.dwInitParam = (LPARAM)this;
+ UserInfo_AddPage(wParam, &odp);
// Start search for user data
if ((HANDLE)lParam == NULL)
@@ -978,14 +945,14 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam);
TranslateDialogDefault(hwndDlg);
- if (num = db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
+ if (num = gg->getDword(GG_KEY_UIN, 0))
SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
@@ -1017,13 +984,13 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP ShowWindow(GetDlgItem(hwndDlg, IDC_RELOADREQD), SW_SHOW);
// Update uin
- if (num = db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
+ if (num = gg->getDword(GG_KEY_UIN, 0))
SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
else
SetDlgItemTextA(hwndDlg, IDC_UIN, "");
// Update password
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_PASSWORD, &dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
@@ -1031,7 +998,7 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP else SetDlgItemTextA(hwndDlg, IDC_PASSWORD, "");
// Update e-mail
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, &dbv, DBVT_ASCIIZ)) {
+ if (!gg->getString(GG_KEY_EMAIL, &dbv)) {
SetDlgItemTextA(hwndDlg, IDC_EMAIL, dbv.pszVal);
db_free(&dbv);
}
@@ -1056,12 +1023,12 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP GetDlgItemTextA(hwndDlg, IDC_PASSWORD, str, sizeof(str));
CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(str), (LPARAM) str);
gg->checknewuser(uin, str);
- db_set_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, uin);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, str);
+ gg->setDword(GG_KEY_UIN, uin);
+ gg->setString(GG_KEY_PASSWORD, str);
// Write Gadu-Gadu email
GetDlgItemTextA(hwndDlg, IDC_EMAIL, str, sizeof(str));
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, str);
+ gg->setString(GG_KEY_EMAIL, str);
}
}
}
diff --git a/protocols/Gadu-Gadu/src/filetransfer.cpp b/protocols/Gadu-Gadu/src/filetransfer.cpp index bfd23dbd06..6f4f7a9019 100644 --- a/protocols/Gadu-Gadu/src/filetransfer.cpp +++ b/protocols/Gadu-Gadu/src/filetransfer.cpp @@ -43,7 +43,7 @@ void GGPROTO::dccstart() }
// Check if we wan't direct connections
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS))
+ if (!getByte(GG_KEY_DIRECTCONNS, GG_KEYDEF_DIRECTCONNS))
{
netlog("dccstart(): No direct connections setup.");
if (hEvent) SetEvent(hEvent);
@@ -69,9 +69,9 @@ void GGPROTO::dccconnect(uin_t uin) if (!hContact) return;
// Read user IP and port
- ip = swap32(db_get_dw(hContact, m_szModuleName, GG_KEY_CLIENTIP, 0));
- port = db_get_w(hContact, m_szModuleName, GG_KEY_CLIENTPORT, 0);
- myuin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
+ ip = swap32(getDword(hContact, GG_KEY_CLIENTIP, 0));
+ port = getWord(hContact, GG_KEY_CLIENTPORT, 0);
+ myuin = getDword(GG_KEY_UIN, 0);
// If not port nor ip nor my uin (?) specified
if (!ip || !port || !uin) return;
@@ -143,7 +143,7 @@ void __cdecl GGPROTO::dccmainthread(void*) netlog("dccmainthread(): started. DCC Server Thread Starting");
// Readup number
- if (!(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
+ if (!(uin = getDword(GG_KEY_UIN, 0)))
{
netlog("dccmainthread(): No Gadu-Gadu number specified. Exiting.");
if (hEvent) SetEvent(hEvent);
@@ -154,7 +154,7 @@ void __cdecl GGPROTO::dccmainthread(void*) }
// Create listen socket on config direct port
- if (!(dcc = gg_dcc_socket_create(uin, (uint16_t)db_get_w(NULL, m_szModuleName, GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT))))
+ if (!(dcc = gg_dcc_socket_create(uin, (uint16_t)getWord(GG_KEY_DIRECTPORT, GG_KEYDEF_DIRECTPORT))))
{
netlog("dccmainthread(): Cannot create DCC listen socket. Exiting.");
// Signalize mainthread we haven't start
@@ -405,7 +405,7 @@ void __cdecl GGPROTO::dccmainthread(void*) netlog("dccmainthread(): Client: %d, Client accept.", local_dcc->peer_uin);
// Check if user is on the list and if it is my uin
if (getcontact(local_dcc->peer_uin, 0, 0, NULL) &&
- db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, -1) == local_dcc->uin)
+ getDword(GG_KEY_UIN, -1) == local_dcc->uin)
break;
// Kill unauthorized dcc
@@ -927,11 +927,11 @@ HANDLE GGPROTO::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, PROTOC filename = mir_t2a(ppszFiles[0]);
// Read user IP and port
- ip = swap32(db_get_dw(hContact, m_szModuleName, GG_KEY_CLIENTIP, 0));
- port = db_get_w(hContact, m_szModuleName, GG_KEY_CLIENTPORT, 0);
- myuin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0);
- uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
- ver = db_get_dw(hContact, m_szModuleName, GG_KEY_CLIENTVERSION, 0);
+ ip = swap32(getDword(hContact, GG_KEY_CLIENTIP, 0));
+ port = getWord(hContact, GG_KEY_CLIENTPORT, 0);
+ myuin = getDword(GG_KEY_UIN, 0);
+ uin = getDword(hContact, GG_KEY_UIN, 0);
+ ver = getDword(hContact, GG_KEY_CLIENTVERSION, 0);
// Use DCC7 if a contact is using at least version 7.6 or unknown version
if ((ver & 0x00ffffff) >= 0x29 || !ver) {
diff --git a/protocols/Gadu-Gadu/src/gg.cpp b/protocols/Gadu-Gadu/src/gg.cpp index 3bd7b199a6..737a60d1a6 100644 --- a/protocols/Gadu-Gadu/src/gg.cpp +++ b/protocols/Gadu-Gadu/src/gg.cpp @@ -149,7 +149,7 @@ void GGPROTO::cleanuplastplugin(DWORD version) {
// Store current plugin version
- db_set_dw(NULL, m_szModuleName, GG_PLUGINVERSION, pluginInfo.version);
+ setDword(GG_PLUGINVERSION, pluginInfo.version);
//1. clean files: %miranda_avatarcache%\GG\*.(null)
@@ -233,11 +233,11 @@ static int gg_prebuildcontactmenu(WPARAM wParam, LPARAM lParam) CLISTMENUITEM mi = { sizeof(mi) };
mi.flags = CMIM_NAME | CMIM_FLAGS | CMIF_TCHAR;
- if ( db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0) == db_get_b(NULL, gg->m_szModuleName, GG_KEY_UIN, 0)
- || db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0)
- || db_get_b(hContact, "CList", "NotOnList", 0))
+ if ( gg->getDword(hContact, GG_KEY_UIN, 0) == gg->getByte(GG_KEY_UIN, 0) ||
+ gg->getByte(hContact, "ChatRoom", 0) ||
+ db_get_b(hContact, "CList", "NotOnList", 0))
mi.flags |= CMIF_HIDDEN;
- mi.ptszName = db_get_b(hContact, gg->m_szModuleName, GG_KEY_BLOCK, 0) ? LPGENT("&Unblock") : LPGENT("&Block");
+ mi.ptszName = gg->getByte(hContact, GG_KEY_BLOCK, 0) ? LPGENT("&Unblock") : LPGENT("&Block");
Menu_ModifyItem(gg->hBlockMenuItem, &mi);
return 0;
}
@@ -247,7 +247,7 @@ static int gg_prebuildcontactmenu(WPARAM wParam, LPARAM lParam) INT_PTR GGPROTO::blockuser(WPARAM wParam, LPARAM lParam)
{
const HANDLE hContact = (HANDLE)wParam;
- db_set_b(hContact, m_szModuleName, GG_KEY_BLOCK, !db_get_b(hContact, m_szModuleName, GG_KEY_BLOCK, 0));
+ setByte(hContact, GG_KEY_BLOCK, !getByte(hContact, GG_KEY_BLOCK, 0));
notifyuser(hContact, 1);
return 0;
}
diff --git a/protocols/Gadu-Gadu/src/gg_proto.cpp b/protocols/Gadu-Gadu/src/gg_proto.cpp index 6642e2bb61..137c4bb1ef 100644 --- a/protocols/Gadu-Gadu/src/gg_proto.cpp +++ b/protocols/Gadu-Gadu/src/gg_proto.cpp @@ -64,7 +64,7 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) : // Offline contacts and clear logon time
setalloffline();
- db_set_dw(NULL, m_szModuleName, GG_KEY_LOGONTIME, 0);
+ setDword(GG_KEY_LOGONTIME, 0);
db_set_resident(m_szModuleName, GG_KEY_AVATARREQUESTED);
@@ -76,7 +76,7 @@ GGPROTO::GGPROTO(const char* pszProtoName, const TCHAR* tszUserName) : hImagesFolder = FoldersRegisterCustomPathT(LPGEN("Images"), m_szModuleName, szPath, m_tszUserName);
DWORD dwVersion;
- if ((dwVersion = db_get_dw(NULL, m_szModuleName, GG_PLUGINVERSION, 0)) < pluginInfo.version)
+ if ((dwVersion = getDword(GG_PLUGINVERSION, 0)) < pluginInfo.version)
cleanuplastplugin(dwVersion);
links_instance_init();
@@ -215,7 +215,7 @@ int GGPROTO::GetInfo(HANDLE hContact, int infoType) }
// Add uin and search it
- gg_pubdir50_add(req, GG_PUBDIR50_UIN, ditoa((uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0)));
+ gg_pubdir50_add(req, GG_PUBDIR50_UIN, ditoa((uin_t)getDword(hContact, GG_KEY_UIN, 0)));
gg_pubdir50_seq_set(req, GG_SEQ_INFO);
netlog("GetInfo(): Requesting user info.", req->seq);
@@ -606,7 +606,7 @@ void __cdecl GGPROTO::sendackthread(void *ack) int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg)
{
- uin_t uin = (uin_t)db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = (uin_t)getDword(hContact, GG_KEY_UIN, 0);
if (!isonline() || !uin)
return 0;
@@ -624,7 +624,7 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg) gg_EnterCriticalSection(&sess_mutex, "SendMsg", 53, "sess_mutex", 1);
int seq = gg_send_message(sess, GG_CLASS_CHAT, uin, (BYTE*)msg_utf8);
gg_LeaveCriticalSection(&sess_mutex, "SendMsg", 53, 1, "sess_mutex", 1);
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_MSGACK, GG_KEYDEF_MSGACK))
+ if (!getByte(GG_KEY_MSGACK, GG_KEYDEF_MSGACK))
{
// Auto-ack message without waiting for server ack
GG_SEQ_ACK *ack = (GG_SEQ_ACK*)mir_alloc(sizeof(GG_SEQ_ACK));
@@ -647,7 +647,7 @@ int GGPROTO::SendMsg(HANDLE hContact, int flags, const char *msg) int GGPROTO::SetApparentMode(HANDLE hContact, int mode)
{
- db_set_w(hContact, m_szModuleName, GG_KEY_APPARENT, (WORD)mode);
+ setWord(hContact, GG_KEY_APPARENT, (WORD)mode);
notifyuser(hContact, 1);
return 0;
}
@@ -771,9 +771,9 @@ int GGPROTO::SetAwayMsg(int iStatus, const PROTOCHAR *newMsg) int GGPROTO::UserIsTyping(HANDLE hContact, int type)
{
- uin_t uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
-
- if (!uin || !isonline()) return 0;
+ uin_t uin = getDword(hContact, GG_KEY_UIN, 0);
+ if (!uin || !isonline())
+ return 0;
if (type == PROTOTYPE_SELFTYPING_ON || type == PROTOTYPE_SELFTYPING_OFF) {
gg_EnterCriticalSection(&sess_mutex, "UserIsTyping", 56, "sess_mutex", 1);
diff --git a/protocols/Gadu-Gadu/src/groupchat.cpp b/protocols/Gadu-Gadu/src/groupchat.cpp index 542d35adc5..418be65df1 100644 --- a/protocols/Gadu-Gadu/src/groupchat.cpp +++ b/protocols/Gadu-Gadu/src/groupchat.cpp @@ -130,7 +130,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) || !gch->pDest->ptszID
|| !gch->pDest->pszModule
|| lstrcmpiA(gch->pDest->pszModule, m_szModuleName)
- || !(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
+ || !(uin = getDword(GG_KEY_UIN, 0))
|| !(chat = gc_lookup(gch->pDest->ptszID)))
return 0;
@@ -146,7 +146,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) for (HANDLE hContact = db_find_first(); hContact; ) {
HANDLE hNext = db_find_next(hContact);
DBVARIANT dbv;
- if (!db_get_s(hContact, m_szModuleName, "ChatRoomID", &dbv, DBVT_TCHAR)) {
+ if (!getTString(hContact, "ChatRoomID", &dbv)) {
if (dbv.ptszVal && !_tcscmp(gch->pDest->ptszID, dbv.ptszVal))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0);
db_free(&dbv);
@@ -173,7 +173,7 @@ int GGPROTO::gc_event(WPARAM wParam, LPARAM lParam) gcevent.ptszUID = id;
gcevent.ptszText = gch->ptszText;
TCHAR* nickT;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)){
+ if (!getTString(GG_KEY_NICK, &dbv)){
nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
} else {
@@ -280,17 +280,17 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count for(i = 0; i < recipients_count; i++)
if (!getcontact(recipients[i], 0, 0, NULL))
unknown ++;
- if ((db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT) == 2) ||
- (db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 2 &&
- recipients_count >= db_get_w(NULL, m_szModuleName, GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
- (db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 2 &&
- unknown >= db_get_w(NULL, m_szModuleName, GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN)))
+ if ((getWord(GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT) == 2) ||
+ (getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 2 &&
+ recipients_count >= getWord(GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
+ (getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 2 &&
+ unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN)))
chat->ignore = TRUE;
- if (!chat->ignore && ((db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT) == 1) ||
- (db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 1 &&
- recipients_count >= db_get_w(NULL, m_szModuleName, GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
- (db_get_w(NULL, m_szModuleName, GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 1 &&
- unknown >= db_get_w(NULL, m_szModuleName, GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))))
+ if (!chat->ignore && ((getWord(GG_KEY_GC_POLICY_DEFAULT, GG_KEYDEF_GC_POLICY_DEFAULT) == 1) ||
+ (getWord(GG_KEY_GC_POLICY_TOTAL, GG_KEYDEF_GC_POLICY_TOTAL) == 1 &&
+ recipients_count >= getWord(GG_KEY_GC_COUNT_TOTAL, GG_KEYDEF_GC_COUNT_TOTAL)) ||
+ (getWord(GG_KEY_GC_POLICY_UNKNOWN, GG_KEYDEF_GC_POLICY_UNKNOWN) == 1 &&
+ unknown >= getWord(GG_KEY_GC_COUNT_UNKNOWN, GG_KEYDEF_GC_COUNT_UNKNOWN))))
{
TCHAR *senderName = unknownSender ?
TranslateT("Unknown") : pcli->pfnGetContactDisplayName(getcontact(sender, 0, 0, NULL), 0);
@@ -353,12 +353,12 @@ TCHAR* GGPROTO::gc_getchat(uin_t sender, uin_t *recipients, int recipients_count gcdest.iType = GC_EVENT_JOIN;
// Add myself
- if (uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0))
+ if (uin = getDword(GG_KEY_UIN, 0))
{
UIN2IDT(uin, id);
TCHAR* nickT;
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR)) {
+ if (!getTString(GG_KEY_NICK, &dbv)) {
nickT = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
} else {
@@ -549,14 +549,14 @@ static INT_PTR CALLBACK gg_gc_openconfdlg(HWND hwndDlg, UINT message, WPARAM wPa HANDLE hMetaContact = gg_getsubcontact(gg, hContact); // MetaContacts support
if (hMetaContact) {
szProto = gg->m_szModuleName;
- uin = (uin_t)db_get_dw(hMetaContact, gg->m_szModuleName, GG_KEY_UIN, 0);
+ uin = (uin_t)gg->getDword(hMetaContact, GG_KEY_UIN, 0);
}
else {
szProto = GetContactProto(hContact);
- uin = (uin_t)db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
+ uin = (uin_t)gg->getDword(hContact, GG_KEY_UIN, 0);
}
- if (szProto == NULL || lstrcmpA(szProto, gg->m_szModuleName) || !uin || uin == db_get_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, 0))
+ if (szProto == NULL || lstrcmpA(szProto, gg->m_szModuleName) || !uin || uin == gg->getDword(GG_KEY_UIN, 0))
SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_DELETEITEM, (WPARAM)hItem, 0);
}
}
@@ -640,7 +640,7 @@ INT_PTR GGPROTO::gc_openconf(WPARAM wParam, LPARAM lParam) int GGPROTO::gc_changenick(HANDLE hContact, TCHAR *ptszNick)
{
list_t l;
- uin_t uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = getDword(hContact, GG_KEY_UIN, 0);
if (!uin || !ptszNick) return 0;
netlog("gc_changenick(): Nickname for uin %d changed. Lookup for chats having this nick", uin);
diff --git a/protocols/Gadu-Gadu/src/image.cpp b/protocols/Gadu-Gadu/src/image.cpp index f970b9eb87..8df70b2cfc 100644 --- a/protocols/Gadu-Gadu/src/image.cpp +++ b/protocols/Gadu-Gadu/src/image.cpp @@ -617,7 +617,7 @@ static INT_PTR CALLBACK gg_img_dlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP if (dat->lpImages && gg->isonline())
{
- uin_t uin = (uin_t)db_get_dw(dat->hContact, gg->m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = (uin_t)gg->getDword(dat->hContact, GG_KEY_UIN, 0);
struct gg_msg_richtext_format *r = NULL;
struct gg_msg_richtext_image *p = NULL;
LPVOID pvData = NULL;
@@ -920,7 +920,7 @@ int GGPROTO::img_display(HANDLE hContact, void *img) if (!dat)
{
dat = gg_img_recvdlg(this, hContact);
- dat->uin = db_get_dw(hContact, m_szModuleName, GG_KEY_UIN, 0);
+ dat->uin = getDword(hContact, GG_KEY_UIN, 0);
while (WaitForSingleObjectEx(dat->hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
CloseHandle(dat->hEvent);
@@ -1140,7 +1140,7 @@ GGIMAGEDLGDATA* gg_img_find(GGPROTO *gg, uin_t uin, uint32_t crc32) dat = (GGIMAGEDLGDATA *)l->data;
if (!dat) break;
- c_uin = db_get_dw(dat->hContact, dat->gg->m_szModuleName, GG_KEY_UIN, 0);
+ c_uin = dat->gg->getDword(dat->hContact, GG_KEY_UIN, 0);
if (!dat->bReceiving && dat->lpImages && dat->lpImages->crc32 == crc32 && c_uin == uin)
{
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp index 53623916ae..d6b2e84afd 100644 --- a/protocols/Gadu-Gadu/src/import.cpp +++ b/protocols/Gadu-Gadu/src/import.cpp @@ -102,12 +102,12 @@ char *gg_makecontacts(GGPROTO *gg, int cr) // Readup contacts
for (HANDLE hContact = db_find_first(gg->m_szModuleName); hContact; hContact = db_find_next(hContact, gg->m_szModuleName)) {
- if (db_get_b(hContact, gg->m_szModuleName, "ChatRoom", 0))
+ if (gg->getByte(hContact, "ChatRoom", 0))
continue;
// Readup FirstName
DBVARIANT dbv;
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_FIRSTNAME, &dbv, DBVT_WCHAR))
+ if (!gg->getTString(hContact, GG_KEY_PD_FIRSTNAME, &dbv))
{
char* pszValA = mir_t2a(dbv.ptszVal);
string_append(s, dbv.pszVal);
@@ -116,7 +116,7 @@ char *gg_makecontacts(GGPROTO *gg, int cr) }
string_append_c(s, ';');
// Readup LastName
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_LASTNAME, &dbv, DBVT_WCHAR))
+ if (!gg->getTString(hContact, GG_KEY_PD_LASTNAME, &dbv))
{
char* pszValA = mir_t2a(dbv.ptszVal);
string_append(s, dbv.pszVal);
@@ -126,11 +126,11 @@ char *gg_makecontacts(GGPROTO *gg, int cr) string_append_c(s, ';');
// Readup Nick
- if (!db_get_s(hContact, "CList", "MyHandle", &dbv, DBVT_TCHAR) || !db_get_s(hContact, gg->m_szModuleName, GG_KEY_NICK, &dbv, DBVT_TCHAR))
+ if (!db_get_ts(hContact, "CList", "MyHandle", &dbv) || !gg->getTString(hContact, GG_KEY_NICK, &dbv))
{
char* dbvA = mir_t2a(dbv.ptszVal);
DBVARIANT dbv2;
- if (!db_get_s(hContact, gg->m_szModuleName, GG_KEY_PD_NICKNAME, &dbv2, DBVT_WCHAR))
+ if (!gg->getTString(hContact, GG_KEY_PD_NICKNAME, &dbv2))
{
char* pszValA = mir_t2a(dbv2.ptszVal);
string_append(s, pszValA);
@@ -167,7 +167,7 @@ char *gg_makecontacts(GGPROTO *gg, int cr) }
string_append_c(s, ';');
// Readup Uin
- string_append(s, ditoa(db_get_dw(hContact, gg->m_szModuleName, GG_KEY_UIN, 0)));
+ string_append(s, ditoa(gg->getDword(hContact, GG_KEY_UIN, 0)));
string_append_c(s, ';');
// Readup Mail (fixed: uses stored editable mails)
if (!db_get_s(hContact, "UserInfo", "Mye-mail0", &dbv, DBVT_ASCIIZ))
@@ -296,12 +296,12 @@ void GGPROTO::parsecontacts(char *contacts) // Write misc data
if (hContact && strFirstName){
TCHAR *tstrFirstName = mir_a2t(strFirstName);
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_FIRSTNAME, tstrFirstName);
+ setTString(hContact, GG_KEY_PD_FIRSTNAME, tstrFirstName);
mir_free(tstrFirstName);
}
if (hContact && strLastName){
TCHAR *tstrLastName = mir_a2t(strLastName);
- db_set_ts(hContact, m_szModuleName, GG_KEY_PD_LASTNAME, tstrLastName);
+ setTString(hContact, GG_KEY_PD_LASTNAME, tstrLastName);
mir_free(tstrLastName);
}
if (hContact && strPhone) db_set_s(hContact, "UserInfo", "MyPhone0", strPhone); // Store now in User Info
@@ -340,7 +340,7 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam) }
// Readup password
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_PASSWORD, &dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
password = _strdup(dbv.pszVal);
@@ -348,7 +348,7 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam) }
else return 0;
- if (!(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
+ if (!(uin = getDword(GG_KEY_UIN, 0)))
return 0;
// Making contacts list
@@ -387,7 +387,7 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam) }
// Readup password
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_PASSWORD, &dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
password = _strdup(dbv.pszVal);
@@ -395,7 +395,7 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam) }
else return 0;
- if (!(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
+ if (!(uin = getDword(GG_KEY_UIN, 0)))
return 0;
// Making contacts list
@@ -568,7 +568,7 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam) }
// Readup password
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ))
+ if (!getString(GG_KEY_PASSWORD, &dbv))
{
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
password = _strdup(dbv.pszVal);
@@ -576,7 +576,7 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam) }
else return 0;
- if (!(uin = db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0)))
+ if (!(uin = getDword(GG_KEY_UIN, 0)))
return 0;
// Making contacts list
diff --git a/protocols/Gadu-Gadu/src/keepalive.cpp b/protocols/Gadu-Gadu/src/keepalive.cpp index d7b0dbc685..7cc179d2d0 100644 --- a/protocols/Gadu-Gadu/src/keepalive.cpp +++ b/protocols/Gadu-Gadu/src/keepalive.cpp @@ -52,7 +52,7 @@ static VOID CALLBACK gg_keepalive(HWND hwnd, UINT message, UINT_PTR idEvent, DWO void GGPROTO::keepalive_init()
{
- if (db_get_b(NULL, m_szModuleName, GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE))
+ if (getByte(GG_KEY_KEEPALIVE, GG_KEYDEF_KEEPALIVE))
{
int i;
for(i = 0; i < MAX_TIMERS && g_timers[i] != NULL; i++);
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index 6d0bbc9c7b..f172b5ba8d 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -338,12 +338,12 @@ char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD char* GGPROTO::oauth_header(const char *httpmethod, const char *url)
{
char uin[32];
- UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
- ptrA token( db_get_sa(NULL, m_szModuleName, GG_KEY_TOKEN));
- ptrA password( db_get_sa(NULL, m_szModuleName, GG_KEY_PASSWORD));
+ UIN2IDA( getDword(GG_KEY_UIN, 0), uin);
+ ptrA token( getStringA(GG_KEY_TOKEN));
+ ptrA password( getStringA(GG_KEY_PASSWORD));
if (password != NULL)
CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(password) + 1, (LPARAM)password);
- ptrA token_secret( db_get_sa(NULL, m_szModuleName, GG_KEY_TOKENSECRET));
+ ptrA token_secret( getStringA(GG_KEY_TOKENSECRET));
if (token_secret != NULL)
CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(token_secret) + 1, (LPARAM)token_secret);
@@ -357,8 +357,8 @@ int GGPROTO::oauth_receivetoken() int res = 0;
HANDLE nlc = NULL;
- UIN2IDA( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), uin);
- if (!db_get_s(NULL, m_szModuleName, GG_KEY_PASSWORD, &dbv, DBVT_ASCIIZ)) {
+ UIN2IDA( getDword(GG_KEY_UIN, 0), uin);
+ if (!getString(GG_KEY_PASSWORD, &dbv)) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM)dbv.pszVal);
password = mir_strdup(dbv.pszVal);
db_free(&dbv);
@@ -480,15 +480,15 @@ int GGPROTO::oauth_receivetoken() mir_free(str);
if (token != NULL && token_secret != NULL) {
- db_set_s(NULL, m_szModuleName, GG_KEY_TOKEN, token);
+ setString(GG_KEY_TOKEN, token);
CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)(int)strlen(token_secret) + 1, (LPARAM) token_secret);
- db_set_s(NULL, m_szModuleName, GG_KEY_TOKENSECRET, token_secret);
+ setString(GG_KEY_TOKENSECRET, token_secret);
netlog("oauth_receivetoken(): Access Token obtained successfully.");
res = 1;
}
else {
- db_unset(NULL, m_szModuleName, GG_KEY_TOKEN);
- db_unset(NULL, m_szModuleName, GG_KEY_TOKENSECRET);
+ delSetting(GG_KEY_TOKEN);
+ delSetting(GG_KEY_TOKENSECRET);
netlog("oauth_receivetoken(): Failed to obtain Access Token.");
}
mir_free(token);
@@ -502,8 +502,8 @@ int GGPROTO::oauth_checktoken(int force) if (force)
return oauth_receivetoken();
- ptrA token( db_get_sa(NULL, m_szModuleName, GG_KEY_TOKEN));
- ptrA token_secret( db_get_sa(NULL, m_szModuleName, GG_KEY_TOKENSECRET));
+ ptrA token( getStringA(GG_KEY_TOKEN));
+ ptrA token_secret( getStringA(GG_KEY_TOKENSECRET));
if (token == NULL || token_secret == NULL)
return oauth_receivetoken();
diff --git a/protocols/Gadu-Gadu/src/services.cpp b/protocols/Gadu-Gadu/src/services.cpp index e2560c557f..adb9e792d6 100644 --- a/protocols/Gadu-Gadu/src/services.cpp +++ b/protocols/Gadu-Gadu/src/services.cpp @@ -121,7 +121,7 @@ int GGPROTO::refreshstatus(int status) gg_LeaveCriticalSection(&sess_mutex, "refreshstatus", 71, 1, "sess_mutex", 1);
}
// Change status of the contact with our own UIN (if got yourself added to the contact list)
- changecontactstatus( db_get_dw(NULL, m_szModuleName, GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
+ changecontactstatus( getDword(GG_KEY_UIN, 0), status_m2gg(status, szMsg != NULL), szMsg, 0, 0, 0, 0);
broadcastnewstatus(status);
mir_free(szMsg_utf8);
}
@@ -157,7 +157,7 @@ INT_PTR GGPROTO::getavatarcaps(WPARAM wParam, LPARAM lParam) case AF_FORMATSUPPORTED:
return (lParam == PA_FORMAT_JPEG || lParam == PA_FORMAT_GIF || lParam == PA_FORMAT_PNG);
case AF_ENABLED:
- return db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS);
+ return getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS);
case AF_DONTNEEDDELAYS:
return 1;
case AF_MAXFILESIZE:
@@ -209,13 +209,13 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) pai->filename[0] = 0;
pai->format = PA_FORMAT_UNKNOWN;
- uin_t uin = (uin_t)db_get_dw(pai->hContact, m_szModuleName, GG_KEY_UIN, 0);
+ uin_t uin = (uin_t)getDword(pai->hContact, GG_KEY_UIN, 0);
if (!uin) {
netlog("getavatarinfo(): Incoming request for avatar information. No uin found. return GAIR_NOAVATAR");
return GAIR_NOAVATAR;
}
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
+ if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
netlog("getavatarinfo(): Incoming request for avatar information. GG_KEY_ENABLEAVATARS == 0. return GAIR_NOAVATAR");
return GAIR_NOAVATAR;
}
@@ -233,7 +233,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) db_free(&dbv);
}
- if (!db_get_b(pai->hContact, m_szModuleName, GG_KEY_AVATARREQUESTED, GG_KEYDEF_AVATARREQUESTED)) {
+ if (!getByte(pai->hContact, GG_KEY_AVATARREQUESTED, GG_KEYDEF_AVATARREQUESTED)) {
requestAvatarInfo(pai->hContact, 1);
if ((wParam & GAIF_FORCE) != 0) {
netlog("getavatarinfo(): Incoming request for avatar information. uin=%d. requestAvatarInfo() fired. return GAIR_WAITFOR", uin);
@@ -244,11 +244,11 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) }
}
- pai->format = db_get_b(pai->hContact, m_szModuleName, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE);
+ pai->format = getByte(pai->hContact, GG_KEY_AVATARTYPE, GG_KEYDEF_AVATARTYPE);
ptrA AvatarHash(NULL);
- ptrA AvatarURL( db_get_sa(pai->hContact, m_szModuleName, GG_KEY_AVATARURL));
- ptrA AvatarTs( db_get_sa(pai->hContact, m_szModuleName, GG_KEY_AVATARTS));
+ ptrA AvatarURL( getStringA(pai->hContact, GG_KEY_AVATARURL));
+ ptrA AvatarTs( getStringA(pai->hContact, GG_KEY_AVATARTS));
if (AvatarURL != NULL && AvatarTs != NULL) {
char *AvatarName = strrchr(AvatarURL, '/');
AvatarName++;
@@ -257,7 +257,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) AvatarHash = gg_avatarhash(AvatarNameWithTS);
}
- ptrA AvatarSavedHash( db_get_sa(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH));
+ ptrA AvatarSavedHash( getStringA(pai->hContact, GG_KEY_AVATARHASH));
if (AvatarHash != NULL && AvatarSavedHash != NULL) {
getAvatarFilename(pai->hContact, pai->filename, SIZEOF(pai->filename));
if (!strcmp(AvatarHash, AvatarSavedHash)) {
@@ -277,7 +277,7 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) mir_sntprintf(error, SIZEOF(error), TranslateT("Can not remove old avatar file before refresh. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pai->filename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
}
- db_set_s(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH, AvatarHash);
+ setString(pai->hContact, GG_KEY_AVATARHASH, AvatarHash);
requestAvatarTransfer(pai->hContact, AvatarURL);
netlog("getavatarinfo(): Incoming request for avatar information. uin=%d. Avatar hash changed, requestAvatarTransfer() fired. return GAIR_WAITFOR", uin);
return GAIR_WAITFOR;
@@ -292,13 +292,13 @@ INT_PTR GGPROTO::getavatarinfo(WPARAM wParam, LPARAM lParam) mir_sntprintf(error, SIZEOF(error), TranslateT("Can not remove old avatar file. ERROR: %d: %s\n%s"), errno, _tcserror(errno), pai->filename);
showpopup(m_tszUserName, error, GG_POPUP_ERROR);
}
- db_unset(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH);
- db_unset(pai->hContact, m_szModuleName, GG_KEY_AVATARURL);
- db_unset(pai->hContact, m_szModuleName, GG_KEY_AVATARTYPE);
+ delSetting(pai->hContact, GG_KEY_AVATARHASH);
+ delSetting(pai->hContact, GG_KEY_AVATARURL);
+ delSetting(pai->hContact, GG_KEY_AVATARTYPE);
netlog("getavatarinfo(): Incoming request for avatar information. Contact %d deleted avatar. return GAIR_NOAVATAR", uin);
}
else if (AvatarHash != NULL && AvatarSavedHash == NULL) {
- db_set_s(pai->hContact, m_szModuleName, GG_KEY_AVATARHASH, AvatarHash);
+ setString(pai->hContact, GG_KEY_AVATARHASH, AvatarHash);
requestAvatarTransfer(pai->hContact, AvatarURL);
netlog("getavatarinfo(): Incoming request for avatar information. Contact %d set avatar. requestAvatarTransfer() fired. return GAIR_WAITFOR", uin);
return GAIR_WAITFOR;
@@ -324,7 +324,7 @@ INT_PTR GGPROTO::getmyavatar(WPARAM wParam, LPARAM lParam) return -1;
}
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
+ if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS)) {
netlog("getmyavatar(): Incoming request for self avatar information. GG_KEY_ENABLEAVATARS==0. return -2 (error)");
return -2;
}
@@ -348,7 +348,7 @@ INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam) {
TCHAR *szFilename = (TCHAR*)lParam;
- if (!db_get_b(NULL, m_szModuleName, GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS))
+ if (!getByte(GG_KEY_ENABLEAVATARS, GG_KEYDEF_ENABLEAVATARS))
return -2;
if (szFilename == NULL) {
@@ -374,8 +374,8 @@ INT_PTR GGPROTO::setmyavatar(WPARAM wParam, LPARAM lParam) return -1;
}
- db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPEPREV, db_get_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, -1));
- db_set_b(NULL, m_szModuleName, GG_KEY_AVATARTYPE, (BYTE)iAvType);
+ setByte(GG_KEY_AVATARTYPEPREV, getByte(GG_KEY_AVATARTYPE, -1));
+ setByte(GG_KEY_AVATARTYPE, (BYTE)iAvType);
TCHAR szMyFilename[MAX_PATH];
getAvatarFilename(NULL, szMyFilename, SIZEOF(szMyFilename));
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp index de73cb5e52..8c213563d2 100644 --- a/protocols/Gadu-Gadu/src/userutils.cpp +++ b/protocols/Gadu-Gadu/src/userutils.cpp @@ -44,21 +44,16 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail) mir_sntprintf(error, SIZEOF(error), TranslateT("Cannot register new account because of error:\n\t%s"),
(h && !s) ? http_error_string(h ? h->error : 0) :
(s ? TranslateT("Registration rejected") : _tcserror(errno)));
- MessageBox(
- NULL,
- error,
- gg->m_tszUserName,
- MB_OK | MB_ICONSTOP
- );
+ MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
gg->netlog("gg_doregister(): Cannot register. errno=%d: %s", errno, strerror(errno));
}
else
{
- db_set_dw(NULL, gg->m_szModuleName, GG_KEY_UIN, s->uin);
+ gg->setDword(GG_KEY_UIN, s->uin);
CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
gg->checknewuser(s->uin, newPass);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, newPass);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, newEmail);
+ gg->setString(GG_KEY_PASSWORD, newPass);
+ gg->setString(GG_KEY_EMAIL, newEmail);
gg_pubdir_free(h);
gg->netlog("gg_doregister(): Account registration succesful.");
MessageBox( NULL,
@@ -102,8 +97,8 @@ void *gg_dounregister(GGPROTO *gg, uin_t uin, char *password) else
{
gg_pubdir_free(h);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_PASSWORD);
- db_unset(NULL, gg->m_szModuleName, GG_KEY_UIN);
+ gg->delSetting(GG_KEY_PASSWORD);
+ gg->delSetting(GG_KEY_UIN);
gg->netlog("gg_dounregister(): Account %d has been removed.", uin);
MessageBox(NULL, TranslateT("Your account has been removed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
@@ -132,7 +127,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) #endif
if (!uin || !password || !newPass) return NULL;
- if (!db_get_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, &dbv_email, DBVT_ASCIIZ))
+ if (!gg->getString(GG_KEY_EMAIL, &dbv_email))
{
strncpy(email, dbv_email.pszVal, sizeof(email));
db_free(&dbv_email);
@@ -155,7 +150,7 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass) {
gg_pubdir_free(h);
CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_PASSWORD, newPass);
+ gg->setString(GG_KEY_PASSWORD, newPass);
gg->netlog("gg_dochpass(): Password change succesful.");
MessageBox(NULL, TranslateT("Your password has been changed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
@@ -196,7 +191,7 @@ void *gg_dochemail(GGPROTO *gg, uin_t uin, char *password, char *email, char *ne else
{
gg_pubdir_free(h);
- db_set_s(NULL, gg->m_szModuleName, GG_KEY_EMAIL, newEmail);
+ gg->setString(GG_KEY_EMAIL, newEmail);
gg->netlog("gg_dochemail(): E-mail change succesful.");
MessageBox(NULL, TranslateT("Your e-mail has been changed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);
}
|