summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
authorTobias Weimer <wishmaster51@googlemail.com>2015-11-06 20:36:32 +0000
committerTobias Weimer <wishmaster51@googlemail.com>2015-11-06 20:36:32 +0000
commitde03f80b99cb8560ffb59d065e72c8aa8af160dc (patch)
treede95c2314f8ef105f6c59ec3f8893947f7657a92 /src/mir_app
parent65f7574ffc302e2749a922ada3aa2ea9513dd02e (diff)
Core: Minor cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@15693 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/src/path.cpp14
-rw-r--r--src/mir_app/src/proto_accs.cpp35
-rw-r--r--src/mir_app/src/proto_chains.cpp4
3 files changed, 19 insertions, 34 deletions
diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp
index 4cf88ade76..e6d38ada83 100644
--- a/src/mir_app/src/path.cpp
+++ b/src/mir_app/src/path.cpp
@@ -34,15 +34,9 @@ static TCHAR tszAvatarRoot[MAX_PATH];
TCHAR* GetContactID(MCONTACT hContact)
{
- TCHAR *theValue = {0};
char *szProto = GetContactProto(hContact);
if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1) {
- DBVARIANT dbv;
- if (!db_get_ts(hContact, szProto, "ChatRoomID", &dbv)) {
- theValue = (TCHAR *)mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- return theValue;
- }
+ return db_get_tsa(hContact, szProto, "ChatRoomID");
}
else {
CONTACTINFO ci = {0};
@@ -54,14 +48,12 @@ TCHAR* GetContactID(MCONTACT hContact)
switch (ci.type) {
case CNFT_ASCIIZ:
return (TCHAR *)ci.pszVal;
- break;
case CNFT_DWORD:
return _itot(ci.dVal, (TCHAR *)mir_alloc(sizeof(TCHAR)*32), 10);
- break;
}
}
+ return NULL;
}
- return NULL;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -80,7 +72,7 @@ static __forceinline char *mir_a2x(const char*, const char *s) { return mir_strd
static __forceinline char *GetContactNickX(const char*, MCONTACT hContact)
{
- return mir_strdup(_T2A(cli.pfnGetContactDisplayName(hContact, 0)));
+ return mir_t2a(cli.pfnGetContactDisplayName(hContact, 0));
}
static __forceinline char *GetContactIDX(const char*, MCONTACT hContact)
diff --git a/src/mir_app/src/proto_accs.cpp b/src/mir_app/src/proto_accs.cpp
index 86fbbf713f..10f0299705 100644
--- a/src/mir_app/src/proto_accs.cpp
+++ b/src/mir_app/src/proto_accs.cpp
@@ -45,44 +45,44 @@ LIST<PROTOACCOUNT> accounts(10, CompareAccounts);
static int EnumDbModules(const char *szModuleName, DWORD, LPARAM)
{
- DBVARIANT dbv;
- if (!db_get_s(NULL, szModuleName, "AM_BaseProto", &dbv)) {
+ char *szProtoName = db_get_sa(NULL, szModuleName, "AM_BaseProto");
+ if (szProtoName) {
if (!Proto_GetAccount(szModuleName)) {
PROTOACCOUNT *pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
pa->cbSize = sizeof(*pa);
pa->szModuleName = mir_strdup(szModuleName);
- pa->szProtoName = mir_strdup(dbv.pszVal);
+ pa->szProtoName = szProtoName;
pa->tszAccountName = mir_a2t(szModuleName);
pa->bIsVisible = TRUE;
pa->bIsEnabled = FALSE;
pa->iOrder = accounts.getCount();
accounts.insert(pa);
}
- db_free(&dbv);
+ else
+ mir_free(szProtoName);
}
return 0;
}
void LoadDbAccounts(void)
{
- DBVARIANT dbv;
int ver = db_get_dw(NULL, "Protocols", "PrVer", -1);
int count = db_get_dw(NULL, "Protocols", "ProtoCount", 0);
for (int i = 0; i < count; i++) {
char buf[10];
_itoa(i, buf, 10);
- if (db_get_s(NULL, "Protocols", buf, &dbv))
+ char *szModuleName = db_get_sa(NULL, "Protocols", buf);
+ if (szModuleName == NULL)
continue;
PROTOACCOUNT *pa = (PROTOACCOUNT*)mir_calloc(sizeof(PROTOACCOUNT));
if (pa == NULL) {
- db_free(&dbv);
+ mir_free(szModuleName);
continue;
}
pa->cbSize = sizeof(*pa);
- pa->szModuleName = mir_strdup(dbv.pszVal);
- db_free(&dbv);
+ pa->szModuleName = szModuleName;
_itoa(OFFSET_VISIBLE + i, buf, 10);
pa->bIsVisible = db_get_dw(NULL, "Protocols", buf, 1) != 0;
@@ -91,30 +91,23 @@ void LoadDbAccounts(void)
pa->iOrder = db_get_dw(NULL, "Protocols", buf, 1);
if (ver >= 4) {
- db_free(&dbv);
_itoa(OFFSET_NAME + i, buf, 10);
- if (!db_get_ts(NULL, "Protocols", buf, &dbv)) {
- pa->tszAccountName = mir_tstrdup(dbv.ptszVal);
- db_free(&dbv);
- }
+ pa->tszAccountName = db_get_tsa(NULL, "Protocols", buf);
_itoa(OFFSET_ENABLED + i, buf, 10);
pa->bIsEnabled = db_get_dw(NULL, "Protocols", buf, 1) != 0;
- if (!db_get_s(NULL, pa->szModuleName, "AM_BaseProto", &dbv)) {
- pa->szProtoName = mir_strdup(dbv.pszVal);
- db_free(&dbv);
- }
+ pa->szProtoName = db_get_sa(NULL, szModuleName, "AM_BaseProto");
}
else pa->bIsEnabled = true;
if (!pa->szProtoName) {
- pa->szProtoName = mir_strdup(pa->szModuleName);
- db_set_s(NULL, pa->szModuleName, "AM_BaseProto", pa->szProtoName);
+ pa->szProtoName = mir_strdup(szModuleName);
+ db_set_s(NULL, szModuleName, "AM_BaseProto", pa->szProtoName);
}
if (!pa->tszAccountName)
- pa->tszAccountName = mir_a2t(pa->szModuleName);
+ pa->tszAccountName = mir_a2t(szModuleName);
accounts.insert(pa);
}
diff --git a/src/mir_app/src/proto_chains.cpp b/src/mir_app/src/proto_chains.cpp
index b06553c45d..ec7d9ba659 100644
--- a/src/mir_app/src/proto_chains.cpp
+++ b/src/mir_app/src/proto_chains.cpp
@@ -127,7 +127,7 @@ MIR_APP_DLL(INT_PTR) Proto_ChainRecv(int iOrder, CCSDATA *ccs)
//end of chain, call network protocol again
char szProto[40];
- if (GetProtocolP((MCONTACT)ccs->hContact, szProto, sizeof(szProto)))
+ if (GetProtocolP(ccs->hContact, szProto, sizeof(szProto)))
return 1;
PROTOACCOUNT *pa = Proto_GetAccount(szProto);
@@ -150,7 +150,7 @@ PROTOACCOUNT* __fastcall Proto_GetAccount(MCONTACT hContact)
return NULL;
char szProto[40];
- if (GetProtocolP((MCONTACT)hContact, szProto, sizeof(szProto)))
+ if (GetProtocolP(hContact, szProto, sizeof(szProto)))
return NULL;
return Proto_GetAccount(szProto);