summaryrefslogtreecommitdiff
path: root/protocols/Gadu-Gadu/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Gadu-Gadu/src')
-rw-r--r--protocols/Gadu-Gadu/src/core.cpp38
-rw-r--r--protocols/Gadu-Gadu/src/dialogs.cpp6
-rw-r--r--protocols/Gadu-Gadu/src/import.cpp41
-rw-r--r--protocols/Gadu-Gadu/src/oauth.cpp15
-rw-r--r--protocols/Gadu-Gadu/src/userutils.cpp8
5 files changed, 28 insertions, 80 deletions
diff --git a/protocols/Gadu-Gadu/src/core.cpp b/protocols/Gadu-Gadu/src/core.cpp
index f8e44b03f8..074c2128ba 100644
--- a/protocols/Gadu-Gadu/src/core.cpp
+++ b/protocols/Gadu-Gadu/src/core.cpp
@@ -284,45 +284,37 @@ void __cdecl GGPROTO::mainthread(void *)
// Setup proxy
nlus.cbSize = sizeof(nlus);
- if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus))
- {
+ if (CallService(MS_NETLIB_GETUSERSETTINGS, (WPARAM)m_hNetlibUser, (LPARAM)&nlus)) {
if (nlus.useProxy)
debugLogA("mainthread() (%x): Using proxy %s:%d.", this, nlus.szProxyServer, nlus.wProxyPort);
gg_proxy_enabled = nlus.useProxy;
gg_proxy_host = nlus.szProxyServer;
gg_proxy_port = nlus.wProxyPort;
- if (nlus.useProxyAuth)
- {
+ if (nlus.useProxyAuth) {
gg_proxy_username = nlus.szProxyAuthUser;
gg_proxy_password = nlus.szProxyAuthPassword;
}
else gg_proxy_username = gg_proxy_password = NULL;
}
- else
- {
+ else {
debugLogA("mainthread() (%x): Failed loading proxy settings.", this);
gg_proxy_enabled = 0;
}
// Check out manual host setting
- if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST))
- {
- if (!getString(GG_KEY_SERVERHOSTS, &dbv))
- {
+ if (getByte(GG_KEY_MANUALHOST, GG_KEYDEF_MANUALHOST)) {
+ if (!getString(GG_KEY_SERVERHOSTS, &dbv)) {
hostcount = gg_decodehosts(dbv.pszVal, hosts, 64);
db_free(&dbv);
}
}
// Readup password
- if (!getString(GG_KEY_PASSWORD, &dbv))
- {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
+ if (!getString(GG_KEY_PASSWORD, &dbv)) {
p.password = mir_strdup(dbv.pszVal);
db_free(&dbv);
}
- else
- {
+ else {
debugLogA("mainthread() (%x): No password specified. Exiting.", this);
broadcastnewstatus(ID_STATUS_OFFLINE);
#ifdef DEBUGMODE
@@ -332,8 +324,7 @@ void __cdecl GGPROTO::mainthread(void *)
}
// Readup number
- if (!(p.uin = getDword(GG_KEY_UIN, 0)))
- {
+ if (!(p.uin = getDword(GG_KEY_UIN, 0))) {
debugLogA("mainthread() (%x): No Gadu-Gadu number specified. Exiting.", this);
broadcastnewstatus(ID_STATUS_OFFLINE);
mir_free(p.password);
@@ -352,8 +343,7 @@ void __cdecl GGPROTO::mainthread(void *)
////////////////////////////// DCC STARTUP /////////////////////////////
// Uin is ok so startup dcc if not started already
- if (!dcc)
- {
+ if (!dcc) {
hEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
dccstart();
@@ -364,13 +354,11 @@ void __cdecl GGPROTO::mainthread(void *)
while (WaitForSingleObjectEx(hEvent, INFINITE, TRUE) != WAIT_OBJECT_0);
CloseHandle(hEvent); hEvent = NULL;
}
+
// Check if dcc is running and setup forwarding port
- if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING))
- {
- if (!getString(GG_KEY_FORWARDHOST, &dbv))
- {
- if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal)))
- {
+ if (dcc && getByte(GG_KEY_FORWARDING, GG_KEYDEF_FORWARDING)) {
+ if (!getString(GG_KEY_FORWARDHOST, &dbv)) {
+ if (!(p.external_addr = gg_dnslookup(this, dbv.pszVal))) {
TCHAR error[128];
TCHAR* forwardHostT = mir_a2t(dbv.pszVal);
mir_sntprintf(error, SIZEOF(error), TranslateT("External direct connections hostname %s is invalid. Disabling external host forwarding."), forwardHostT);
diff --git a/protocols/Gadu-Gadu/src/dialogs.cpp b/protocols/Gadu-Gadu/src/dialogs.cpp
index eb47f96fab..2e9093015c 100644
--- a/protocols/Gadu-Gadu/src/dialogs.cpp
+++ b/protocols/Gadu-Gadu/src/dialogs.cpp
@@ -252,7 +252,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
ShowWindow(GetDlgItem(hwndDlg, IDC_LOSTPASS), SW_HIDE);
}
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);
}
@@ -414,7 +413,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
// 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);
}
@@ -462,7 +460,6 @@ static INT_PTR CALLBACK gg_genoptsdlgproc(HWND hwndDlg, UINT msg, WPARAM wParam,
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);
@@ -957,7 +954,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
if (num = gg->getDword(GG_KEY_UIN, 0))
SetDlgItemTextA(hwndDlg, IDC_UIN, ditoa(num));
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);
}
@@ -1000,7 +996,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
// 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);
}
@@ -1030,7 +1025,6 @@ INT_PTR CALLBACK gg_acc_mgr_guidlgproc(HWND hwndDlg, UINT msg, WPARAM wParam, LP
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);
diff --git a/protocols/Gadu-Gadu/src/import.cpp b/protocols/Gadu-Gadu/src/import.cpp
index 7c28acd9df..12233c226c 100644
--- a/protocols/Gadu-Gadu/src/import.cpp
+++ b/protocols/Gadu-Gadu/src/import.cpp
@@ -253,10 +253,6 @@ void GGPROTO::parsecontacts(char *contacts)
INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)
{
- char *password;
- uin_t uin;
- DBVARIANT dbv;
-
// Check if connected
if (!isonline())
{
@@ -268,14 +264,11 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)
}
// Readup password
- if (!getString(GG_KEY_PASSWORD, &dbv))
- {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
- password = _strdup(dbv.pszVal);
- db_free(&dbv);
- }
- else return 0;
+ char *password = getStringA(GG_KEY_PASSWORD);
+ if (password == NULL)
+ return 0;
+ uin_t uin;
if (!(uin = getDword(GG_KEY_UIN, 0)))
return 0;
@@ -300,13 +293,8 @@ INT_PTR GGPROTO::import_server(WPARAM wParam, LPARAM lParam)
INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam)
{
- char *password;
- uin_t uin;
- DBVARIANT dbv;
-
// Check if connected
- if (!isonline())
- {
+ if (!isonline()) {
MessageBox(NULL,
TranslateT("You have to be connected before you can import/export contacts from/to server."),
m_tszUserName, MB_OK | MB_ICONSTOP
@@ -315,14 +303,11 @@ INT_PTR GGPROTO::remove_server(WPARAM wParam, LPARAM lParam)
}
// Readup password
- if (!getString(GG_KEY_PASSWORD, &dbv))
- {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
- password = _strdup(dbv.pszVal);
- db_free(&dbv);
- }
- else return 0;
+ char *password = getStringA(GG_KEY_PASSWORD);
+ if (password == NULL)
+ return 0;
+ uin_t uin;
if (!(uin = getDword(GG_KEY_UIN, 0)))
return 0;
@@ -491,14 +476,10 @@ INT_PTR GGPROTO::export_server(WPARAM wParam, LPARAM lParam)
}
// Readup password
- DBVARIANT dbv;
- if (getString(GG_KEY_PASSWORD, &dbv))
+ char *password = getStringA(GG_KEY_PASSWORD);
+ if (password == NULL)
return 0;
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal) + 1, (LPARAM) dbv.pszVal);
- char *password = _strdup(dbv.pszVal);
- db_free(&dbv);
-
uin_t uin = getDword(GG_KEY_UIN, 0);
if (!uin)
return 0;
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp
index db2a8220f9..4b6f07e295 100644
--- a/protocols/Gadu-Gadu/src/oauth.cpp
+++ b/protocols/Gadu-Gadu/src/oauth.cpp
@@ -295,28 +295,18 @@ char* GGPROTO::oauth_header(const char *httpmethod, const char *url)
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( getStringA(GG_KEY_TOKENSECRET));
- if (token_secret != NULL)
- CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(token_secret) + 1, (LPARAM)token_secret);
-
return oauth_auth_header(httpmethod, url, HMACSHA1, uin, password, token, token_secret);
}
int GGPROTO::oauth_receivetoken()
{
- char szUrl[256], uin[32], *password = NULL, *str, *token = NULL, *token_secret = NULL;
- DBVARIANT dbv;
+ char szUrl[256], uin[32], *str, *token = NULL, *token_secret = NULL;
int res = 0;
HANDLE nlc = NULL;
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);
- }
+ char *password = getStringA(GG_KEY_PASSWORD);
// 1. Obtaining an Unauthorized Request Token
debugLogA("oauth_receivetoken(): Obtaining an Unauthorized Request Token...");
@@ -435,7 +425,6 @@ int GGPROTO::oauth_receivetoken()
if (token != NULL && token_secret != NULL) {
setString(GG_KEY_TOKEN, token);
- CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)(int)strlen(token_secret) + 1, (LPARAM) token_secret);
setString(GG_KEY_TOKENSECRET, token_secret);
debugLogA("oauth_receivetoken(): Access Token obtained successfully.");
res = 1;
diff --git a/protocols/Gadu-Gadu/src/userutils.cpp b/protocols/Gadu-Gadu/src/userutils.cpp
index b33dcd33bc..d7b4643de8 100644
--- a/protocols/Gadu-Gadu/src/userutils.cpp
+++ b/protocols/Gadu-Gadu/src/userutils.cpp
@@ -38,8 +38,7 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail)
// Load token
if (!gg->gettoken(&token)) return NULL;
- if (!(h = gg_register3(newEmail, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || !s->uin)
- {
+ if (!(h = gg_register3(newEmail, newPass, token.id, token.val, 0)) || !(s = (gg_pubdir*)h->data) || !s->success || !s->uin) {
TCHAR error[128];
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) :
@@ -47,10 +46,8 @@ void *gg_doregister(GGPROTO *gg, char *newPass, char *newEmail)
MessageBox(NULL, error, gg->m_tszUserName, MB_OK | MB_ICONSTOP);
gg->debugLogA("gg_doregister(): Cannot register. errno=%d: %s", errno, strerror(errno));
}
- else
- {
+ else {
gg->setDword(GG_KEY_UIN, s->uin);
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
gg->checknewuser(s->uin, newPass);
gg->setString(GG_KEY_PASSWORD, newPass);
gg->setString(GG_KEY_EMAIL, newEmail);
@@ -149,7 +146,6 @@ void *gg_dochpass(GGPROTO *gg, uin_t uin, char *password, char *newPass)
else
{
gg_pubdir_free(h);
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(newPass) + 1, (LPARAM) newPass);
gg->setString(GG_KEY_PASSWORD, newPass);
gg->debugLogA("gg_dochpass(): Password change succesful.");
MessageBox(NULL, TranslateT("Your password has been changed."), gg->m_tszUserName, MB_OK | MB_ICONINFORMATION);