diff options
-rw-r--r-- | src/mir_app/src/path.cpp | 14 | ||||
-rw-r--r-- | src/mir_app/src/proto_accs.cpp | 35 | ||||
-rw-r--r-- | src/mir_app/src/proto_chains.cpp | 4 |
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);
|