diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-26 22:26:19 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-26 22:26:19 +0000 |
commit | c8ae2a45d384650fb562b078a06f024dc85caae8 (patch) | |
tree | be95e85aedbedc2f60897ca1fa20359fe831f9b0 /plugins/MetaContacts/src/meta_utils.cpp | |
parent | 8cf41c81a5445f29198fdc214544dd27259187bc (diff) |
MC became virtual
git-svn-id: http://svn.miranda-ng.org/main/trunk@2514 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MetaContacts/src/meta_utils.cpp')
-rw-r--r-- | plugins/MetaContacts/src/meta_utils.cpp | 550 |
1 files changed, 270 insertions, 280 deletions
diff --git a/plugins/MetaContacts/src/meta_utils.cpp b/plugins/MetaContacts/src/meta_utils.cpp index 8df0479440..3160e67543 100644 --- a/plugins/MetaContacts/src/meta_utils.cpp +++ b/plugins/MetaContacts/src/meta_utils.cpp @@ -36,7 +36,7 @@ INT_PTR MyDBWriteContactSetting(HANDLE hContact, const char *szModule, const cha return CallService(MS_DB_CONTACT_WRITESETTING, (WPARAM)hContact, (LPARAM)&dcws);
}
-INT_PTR MyDBGetContactSetting(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
+INT_PTR Mydb_get(HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
static BOOL strsvc, strsvcset = FALSE;
memset(dbv, 0, sizeof(DBVARIANT));
@@ -45,14 +45,14 @@ INT_PTR MyDBGetContactSetting(HANDLE hContact, const char *szModule, const char // preserve unicode strings - this service should return other data types unchanged
if (strsvc) return DBGetContactSettingW(hContact, szModule, szSetting, dbv);
- return DBGetContactSetting(hContact, szModule, szSetting, dbv);
+ return db_get(hContact, szModule, szSetting, dbv);
}
int Meta_EqualDBV(DBVARIANT *dbv, DBVARIANT *id) {
DWORD res = 1;
int i;
if (dbv->type == id->type)
- { // If the id parameter and the value returned by the DBGetContactSetting
+ { // If the id parameter and the value returned by the db_get
// are the same, this is the correct HANDLE, return it.
switch(dbv->type)
{
@@ -115,72 +115,62 @@ HANDLE Meta_GetHandle(const char *protocol, DBVARIANT *id) field = (char *)CallProtoService(protocol,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
hUser = db_find_first();
- while(hUser)
- { // Scan the database and retrieve the field for each contact
- if (!DBGetContactSetting(hUser,protocol,field,&dbv))
- {
- if (dbv.type == id->type)
- { // If the id parameter and the value returned by the DBGetContactSetting
+ while(hUser) {
+ // Scan the database and retrieve the field for each contact
+ if (!db_get(hUser,protocol,field,&dbv)) {
+ if (dbv.type == id->type) {
+ // If the id parameter and the value returned by the db_get
// are the same, this is the correct HANDLE, return it.
- switch(dbv.type)
- {
- case DBVT_DELETED:
- break;
- case DBVT_BYTE:
- if (dbv.bVal == id->bVal)
- return hUser;
- break;
- case DBVT_WORD:
- if (dbv.wVal == id->wVal)
- return hUser;
- break;
- case DBVT_DWORD:
- if (dbv.dVal == id->dVal)
- return hUser;
- break;
- case DBVT_ASCIIZ:
- case DBVT_UTF8:
- if (!strcmp(dbv.pszVal,id->pszVal))
- {
- DBFreeVariant(&dbv);
- return hUser;
- }
- else
- {
- DBFreeVariant(&dbv);
- break;
- }
- case DBVT_WCHAR:
- if (!wcscmp(dbv.pwszVal,id->pwszVal))
- {
- DBFreeVariant(&dbv);
+ switch(dbv.type) {
+ case DBVT_DELETED:
+ break;
+ case DBVT_BYTE:
+ if (dbv.bVal == id->bVal)
+ return hUser;
+ break;
+ case DBVT_WORD:
+ if (dbv.wVal == id->wVal)
+ return hUser;
+ break;
+ case DBVT_DWORD:
+ if (dbv.dVal == id->dVal)
+ return hUser;
+ break;
+ case DBVT_ASCIIZ:
+ case DBVT_UTF8:
+ if (!strcmp(dbv.pszVal,id->pszVal)) {
+ db_free(&dbv);
+ return hUser;
+ }
+ db_free(&dbv);
+ break;
+
+ case DBVT_WCHAR:
+ if (!wcscmp(dbv.pwszVal,id->pwszVal)) {
+ db_free(&dbv);
+ return hUser;
+ }
+ db_free(&dbv);
+ break;
+
+ case DBVT_BLOB:
+ if (dbv.cpbVal == id->cpbVal) {
+ for (i=dbv.cpbVal;res && i<=0;i--)
+ res = (dbv.pbVal[i] == id->pbVal[i]);
+ if (res) {
+ db_free(&dbv);
return hUser;
}
- else
- {
- DBFreeVariant(&dbv);
- break;
- }
- case DBVT_BLOB:
- if (dbv.cpbVal == id->cpbVal)
- {
- for (i=dbv.cpbVal;res && i<=0;i--)
- res = (dbv.pbVal[i] == id->pbVal[i]);
- if (res)
- {
- DBFreeVariant(&dbv);
- return hUser;
- }
- }
- DBFreeVariant(&dbv);
- break;
+ }
+ db_free(&dbv);
+ break;
} // end switch
- } else
- DBFreeVariant(&dbv);
- } // end if (!DBGetContactSetting(hUser,protocol,field,&dbv))
+ }
+ else db_free(&dbv);
+ }
// This contact wasn't the good one, go to the next.
hUser = db_find_next(hUser);
- } // end while
+ }
return NULL;
}
@@ -203,29 +193,29 @@ int Meta_SetNick(char *proto) ci.szProto = proto;
if (CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ci))
return 1;
- switch(ci.type)
- {
- case CNFT_BYTE:
- if (DBWriteContactSettingByte(NULL,META_PROTO,"Nick",ci.bVal))
- return 1;
- break;
- case CNFT_WORD:
- if (DBWriteContactSettingWord(NULL,META_PROTO,"Nick",ci.wVal))
- return 1;
- break;
- case CNFT_DWORD:
- if (DBWriteContactSettingDword(NULL,META_PROTO,"Nick",ci.dVal))
- return 1;
- break;
- case CNFT_ASCIIZ:
- if (DBWriteContactSettingString(NULL,META_PROTO,"Nick",ci.pszVal))
- return 1;
- mir_free(ci.pszVal);
- break;
- default:
- if (DBWriteContactSettingString(NULL,META_PROTO,"Nick",(char *)Translate("Sender")))
- return 1;
- break;
+
+ switch(ci.type) {
+ case CNFT_BYTE:
+ if ( db_set_b(NULL,META_PROTO,"Nick",ci.bVal))
+ return 1;
+ break;
+ case CNFT_WORD:
+ if ( db_set_w(NULL,META_PROTO,"Nick",ci.wVal))
+ return 1;
+ break;
+ case CNFT_DWORD:
+ if ( db_set_dw(NULL,META_PROTO,"Nick",ci.dVal))
+ return 1;
+ break;
+ case CNFT_ASCIIZ:
+ if ( db_set_s(NULL,META_PROTO,"Nick",ci.pszVal))
+ return 1;
+ mir_free(ci.pszVal);
+ break;
+ default:
+ if ( db_set_s(NULL,META_PROTO,"Nick",(char *)Translate("Sender")))
+ return 1;
+ break;
}
return 0;
}
@@ -249,11 +239,11 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) WORD status;
HANDLE most_online;
- if ((metaID=DBGetContactSettingDword(dest,META_PROTO,META_ID,(DWORD)-1))==-1) {
+ if ((metaID=db_get_dw(dest,META_PROTO,META_ID,(DWORD)-1))==-1) {
MessageBox(0, Translate("Could not get MetaContact id"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
- if ((num_contacts=DBGetContactSettingDword(dest,META_PROTO,"NumContacts",(DWORD)-1))==-1) {
+ if ((num_contacts=db_get_dw(dest,META_PROTO,"NumContacts",(DWORD)-1))==-1) {
MessageBox(0, Translate("Could not retreive MetaContact contact count"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
@@ -264,22 +254,22 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // Get the login of the subcontact
field = (char *)CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
- if (DBGetContactSetting(src,proto,field,&cws.value)) {
+ if ( db_get(src,proto,field,&cws.value)) {
MessageBox(0, Translate("Could not get unique id of contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
// Check that is is 'on the list'
- if (DBGetContactSettingByte(src, "CList", "NotOnList", 0) == 1) {
+ if ( db_get_b(src, "CList", "NotOnList", 0) == 1) {
MessageBox(0, Translate("Contact is 'Not on List' - please add the contact to your contact list before assigning."), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
return FALSE;
}
num_contacts++;
if (num_contacts >= MAX_CONTACTS) {
MessageBox(0, Translate("MetaContact is full"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
return FALSE;
}
@@ -287,9 +277,9 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) strcpy(buffer, "Protocol");
strcat(buffer, _itoa((int)(num_contacts -1), buffer2, 10));
- if (DBWriteContactSettingString(dest, META_PROTO, buffer, proto)) {
+ if ( db_set_s(dest, META_PROTO, buffer, proto)) {
MessageBox(0, Translate("Could not write contact protocol to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
return FALSE;
}
@@ -300,16 +290,16 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) cws.szModule=META_PROTO;
cws.szSetting=buffer;
- if (CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) {
+ if ( CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)dest,(LPARAM)&cws)) {
MessageBox(0, Translate("Could not write unique id of contact to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
return FALSE;
}
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
// If we can get the nickname of the subcontact...
- if (!DBGetContactSetting(src,proto,"Nick",&cws.value)) {
+ if (!db_get(src,proto,"Nick",&cws.value)) {
// write the nickname
strcpy(buffer, "Nick");
strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10));
@@ -322,7 +312,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) return FALSE;
}
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
}
{
@@ -337,19 +327,19 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) if (wname && strncmp(name, (char *)wname, strlen(name)) != 0) {
DBWriteContactSettingWString(dest, META_PROTO, buffer, wname);
} else
- DBWriteContactSettingString(dest, META_PROTO, buffer, name);
+ db_set_s(dest, META_PROTO, buffer, name);
// Get the status
if (!proto)
status = ID_STATUS_OFFLINE;
else
- status = DBGetContactSettingWord(src, proto, "Status", ID_STATUS_OFFLINE);
+ status = db_get_w(src, proto, "Status", ID_STATUS_OFFLINE);
}
// write the status
strcpy(buffer, "Status");
strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10));
- if (DBWriteContactSettingWord(dest, META_PROTO, buffer, status)) {
+ if (db_set_w(dest, META_PROTO, buffer, status)) {
MessageBox(0, Translate("Could not write contact status to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
@@ -357,7 +347,7 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) // write the handle
strcpy(buffer, "Handle");
strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10));
- if (DBWriteContactSettingDword(dest, META_PROTO, buffer, (DWORD)src)) {
+ if (db_set_dw(dest, META_PROTO, buffer, (DWORD)src)) {
MessageBox(0, Translate("Could not write contact handle to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
@@ -366,41 +356,41 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) strcpy(buffer, "StatusString");
strcat(buffer, _itoa((int)(num_contacts - 1), buffer2, 10));
Meta_GetStatusString(status, buffer2, 512);
- if (DBWriteContactSettingString(dest, META_PROTO, buffer, buffer2)) {
+ if (db_set_s(dest, META_PROTO, buffer, buffer2)) {
MessageBox(0, Translate("Could not write contact status string to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
// Write the link in the contact
- if (DBWriteContactSettingDword(src,META_PROTO,META_LINK,metaID)) {
+ if (db_set_dw(src,META_PROTO,META_LINK,metaID)) {
MessageBox(0, Translate("Could not write MetaContact id to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
// Write the contact number in the contact
- if (DBWriteContactSettingDword(src,META_PROTO,"ContactNumber",(DWORD)(num_contacts - 1))) {
+ if (db_set_dw(src,META_PROTO,"ContactNumber",(DWORD)(num_contacts - 1))) {
MessageBox(0, Translate("Could not write MetaContact contact number to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
// Write the handle in the contact
- if (DBWriteContactSettingDword(src,META_PROTO,"Handle",(DWORD)dest)) {
+ if (db_set_dw(src,META_PROTO,"Handle",(DWORD)dest)) {
MessageBox(0, Translate("Could not write MetaContact contact number to contact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
// update count of contacts
- if (DBWriteContactSettingDword(dest,META_PROTO,"NumContacts",num_contacts)) {
+ if (db_set_dw(dest,META_PROTO,"NumContacts",num_contacts)) {
MessageBox(0, Translate("Could not write contact count to MetaContact"), Translate("Assignment Error"), MB_OK | MB_ICONWARNING);
return FALSE;
}
if (set_as_default) {
- DBWriteContactSettingDword(dest, META_PROTO, "Default", (WORD)(num_contacts - 1));
+ db_set_dw(dest, META_PROTO, "Default", (WORD)(num_contacts - 1));
NotifyEventHooks(hEventDefaultChanged, (WPARAM)dest, (LPARAM)src);
}
- DBWriteContactSettingByte(src, META_PROTO, "IsSubcontact", 1);
+ db_set_b(src, META_PROTO, "IsSubcontact", 1);
// set nick to most online contact that can message
most_online = Meta_GetMostOnline(dest);
Meta_CopyContactNick(dest, most_online);
@@ -440,7 +430,6 @@ BOOL Meta_Assign(HANDLE src, HANDLE dest, BOOL set_as_default) return TRUE;
}
-
/**
* Convenience method - get most online contact supporting messaging
*
@@ -464,7 +453,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca char *proto, *most_online_proto;
// you can't get more online than having the default contact ONLINE - so check that first
- if ((default_contact_number = DBGetContactSettingDword(hMeta,META_PROTO,"Default",(DWORD)-1)) == (DWORD)-1)
+ if ((default_contact_number = db_get_dw(hMeta,META_PROTO,"Default",(DWORD)-1)) == (DWORD)-1)
{
// This is a simple contact - return NULL to signify error.
// (this should normally not happen, since all meta contacts have a default contact)
@@ -472,7 +461,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca }
// if the default is beyond the end of the list (eek!) return null
- if (default_contact_number >= (num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0)))
+ if (default_contact_number >= (num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", 0)))
return NULL;
most_online_contact = Meta_GetContactHandle(hMeta, default_contact_number);
@@ -480,11 +469,11 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM;
// we are forced to do use default for sending - '-1' capability indicates no specific capability, but respect 'Force Default'
- if (proto && DBGetContactSettingByte(hMeta, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status
+ if (proto && db_get_b(hMeta, META_PROTO, "ForceDefault", 0) && capability != 0 && (capability == -1 || (caps & capability) == capability)) // capability is 0 when we're working out status
return most_online_contact;
// a subcontact is being temporarily 'forced' to do sending
- if ((most_online_contact = (HANDLE)DBGetContactSettingDword(hMeta, META_PROTO, "ForceSend", 0))) {
+ if ((most_online_contact = (HANDLE)db_get_dw(hMeta, META_PROTO, "ForceSend", 0))) {
caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM;
if (proto && (caps & capability) == capability && capability != 0) // capability is 0 when we're working out status
@@ -497,7 +486,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca caps = proto ? CallProtoService(proto, PS_GETCAPS, (WPARAM)pflagnum, 0) : 0;
if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM;
if (proto && (capability == -1 || (caps & capability) == capability)) {
- most_online_status = DBGetContactSettingWord(most_online_contact, proto, "Status", ID_STATUS_OFFLINE);
+ most_online_status = db_get_w(most_online_contact, proto, "Status", ID_STATUS_OFFLINE);
// if our default is not offline, and option to use default is set - return default
// and also if our default is online, return it
@@ -525,7 +514,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca if (proto && strcmp(proto, "IRC") == 0) caps |= PF1_IM;
if (proto && (capability == -1 || (caps & capability) == capability)) {
- status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE);
+ status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
if (status == ID_STATUS_ONLINE) {
most_online_contact = hContact;
@@ -545,7 +534,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca // no online contacts? if we're trying to message, use 'send offline' contact
if (most_online_status == ID_STATUS_OFFLINE && capability == PF1_IM) {
- HANDLE hOffline = Meta_GetContactHandle(hMeta, DBGetContactSettingDword(hMeta, META_PROTO, "OfflineSend", (DWORD)-1));
+ HANDLE hOffline = Meta_GetContactHandle(hMeta, db_get_dw(hMeta, META_PROTO, "OfflineSend", (DWORD)-1));
if (hOffline)
most_online_contact = hOffline;
}
@@ -554,7 +543,7 @@ HANDLE Meta_GetMostOnlineSupporting(HANDLE hMeta, int pflagnum, unsigned long ca }
int Meta_GetContactNumber(HANDLE hContact) {
- return DBGetContactSettingDword(hContact, META_PROTO, "ContactNumber", -1);
+ return db_get_dw(hContact, META_PROTO, "ContactNumber", -1);
}
BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) {
@@ -578,8 +567,8 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { }
void copy_settings_array(HANDLE hMeta, char *module, const char *settings[], int num_settings) {
- int num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
- default_contact = DBGetContactSettingDword(hMeta, META_PROTO, "Default", (DWORD)-1),
+ int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
+ default_contact = db_get_dw(hMeta, META_PROTO, "Default", (DWORD)-1),
most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
HANDLE hContact;
@@ -608,27 +597,27 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { if (hContact) {
if (!module) {
used_mod = GetContactProto(hContact);
- if (!used_mod) continue; // next contact
- } else
- used_mod = module;
-
- if (j == 0 && strcmp(settings[i], "MirVer") == 0) { //Always reset MirVer
- DBDeleteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i]);
+ if (!used_mod)
+ continue; // next contact
}
+ else used_mod = module;
+
+ if (j == 0 && strcmp(settings[i], "MirVer") == 0) //Always reset MirVer
+ db_unset(hMeta, (module ? used_mod : META_PROTO), settings[i]);
- got_val = !MyDBGetContactSetting(hContact, used_mod, settings[i], &dbv2);
+ got_val = !Mydb_get(hContact, used_mod, settings[i], &dbv2);
if (got_val) {
- free = !MyDBGetContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv1);
+ free = !Mydb_get(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv1);
if (strcmp(settings[i], "MirVer") == 0) {
- if (DBGetContactSettingWord(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
+ if (db_get_w(hContact, used_mod, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) {
if (!free || (dbv1.pszVal == NULL || strcmp(dbv1.pszVal, "") == 0 || strlen(dbv1.pszVal) < 2)) {
MyDBWriteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
bDataWritten = TRUE; //only break if found something to copy
}
}
-
- } else {
+ }
+ else {
if (!free || !dbv_same(&dbv1, &dbv2)) {
MyDBWriteContactSetting(hMeta, (module ? used_mod : META_PROTO), settings[i], &dbv2);
if (dbv2.type == DBVT_ASCIIZ || dbv2.type == DBVT_UTF8) {
@@ -644,8 +633,8 @@ BOOL dbv_same(DBVARIANT *dbv1, DBVARIANT *dbv2) { bDataWritten = TRUE;
}
- DBFreeVariant(&dbv2);
- if (free)DBFreeVariant(&dbv1);
+ db_free(&dbv2);
+ if (free)db_free(&dbv1);
}
}
}
@@ -680,17 +669,17 @@ const char *MBirthdaySettings[3] = // copy from first subcontact with any of these values that has the same status as the most online contact
// proto:
// clist: "StatusMsg"
-void CopyStatusData(HANDLE hMeta) {
- int num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
- most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
- WORD status = DBGetContactSettingWord(hMeta, META_PROTO, "Status", ID_STATUS_OFFLINE);
+
+void CopyStatusData(HANDLE hMeta)
+{
+ int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", (DWORD)-1),
+ most_online = Meta_GetContactNumber(Meta_GetMostOnline(hMeta));
+ WORD status = db_get_w(hMeta, META_PROTO, "Status", ID_STATUS_OFFLINE);
HANDLE hContact;
DBVARIANT dbv;
- char *proto;
BOOL bDoneStatus = FALSE, bDoneXStatus = FALSE;
- int i;
- for (i = 0; i < num_contacts; i++) {
+ for (int i = 0; i < num_contacts; i++) {
if (i == 0)
hContact = Meta_GetContactHandle(hMeta, most_online);
else if (i <= most_online)
@@ -698,26 +687,26 @@ void CopyStatusData(HANDLE hMeta) { else
hContact = Meta_GetContactHandle(hMeta, i);
- proto = GetContactProto(hContact);
+ char *proto = GetContactProto(hContact);
- if (proto && DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE) == status) {
- if (!bDoneStatus && !MyDBGetContactSetting(hContact, "CList", "StatusMsg", &dbv)) {
+ if (proto && db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE) == status) {
+ if (!bDoneStatus && !Mydb_get(hContact, "CList", "StatusMsg", &dbv)) {
MyDBWriteContactSetting(hMeta, "CList", "StatusMsg", &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
bDoneStatus = TRUE;
}
- if ((!bDoneXStatus) && (!MyDBGetContactSetting(hContact, proto, "XStatusId", &dbv)) && dbv.type != DBVT_DELETED) {
- DBWriteContactSettingString(hMeta, META_PROTO, "XStatusProto", proto);
+ if ((!bDoneXStatus) && (!Mydb_get(hContact, proto, "XStatusId", &dbv)) && dbv.type != DBVT_DELETED) {
+ db_set_s(hMeta, META_PROTO, "XStatusProto", proto);
MyDBWriteContactSetting(hMeta, META_PROTO, "XStatusId", &dbv);
- DBFreeVariant(&dbv);
- if (!MyDBGetContactSetting(hContact, proto, "XStatusMsg", &dbv)) {
+ db_free(&dbv);
+ if (!Mydb_get(hContact, proto, "XStatusMsg", &dbv)) {
MyDBWriteContactSetting(hMeta, META_PROTO, "XStatusMsg", &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
- if (!MyDBGetContactSetting(hContact, proto, "XStatusName", &dbv)) {
+ if (!Mydb_get(hContact, proto, "XStatusName", &dbv)) {
MyDBWriteContactSetting(hMeta, META_PROTO, "XStatusName", &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
bDoneXStatus = TRUE;
}
@@ -726,15 +715,16 @@ void CopyStatusData(HANDLE hMeta) { if (bDoneStatus && bDoneXStatus) break;
}
- if (!bDoneStatus) DBDeleteContactSetting(hMeta, "CList", "StatusMsg");
+ if (!bDoneStatus) db_unset(hMeta, "CList", "StatusMsg");
if (!bDoneXStatus) {
- DBDeleteContactSetting(hMeta, META_PROTO, "XStatusId");
- DBDeleteContactSetting(hMeta, META_PROTO, "XStatusMsg");
- DBDeleteContactSetting(hMeta, META_PROTO, "XStatusName");
+ db_unset(hMeta, META_PROTO, "XStatusId");
+ db_unset(hMeta, META_PROTO, "XStatusMsg");
+ db_unset(hMeta, META_PROTO, "XStatusName");
}
}
-void Meta_CopyData(HANDLE hMeta) {
+void Meta_CopyData(HANDLE hMeta)
+{
if (options.copydata) {
CopyStatusData(hMeta);
@@ -748,16 +738,16 @@ void Meta_CopyData(HANDLE hMeta) { }
-HANDLE Meta_GetContactHandle(HANDLE hMeta, int contact_number) {
+HANDLE Meta_GetContactHandle(HANDLE hMeta, int contact_number)
+{
char buffer[512], buffer2[512];
- int num_contacts = DBGetContactSettingDword(hMeta, META_PROTO, "NumContacts", 0);
+ int num_contacts = db_get_dw(hMeta, META_PROTO, "NumContacts", 0);
if (contact_number >= num_contacts || contact_number < 0) return 0;
strcpy(buffer, "Handle");
strcat(buffer, _itoa(contact_number, buffer2, 10));
- return (HANDLE)DBGetContactSettingDword(hMeta, META_PROTO, buffer, 0);
-
+ return (HANDLE)db_get_dw(hMeta, META_PROTO, buffer, 0);
}
int Meta_SetHandles(void) {
@@ -768,14 +758,14 @@ int Meta_SetHandles(void) { BOOL found;
while ( hContact != NULL ) {
- if ((meta_id = DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1))!=(DWORD)-1) {
+ if ((meta_id = db_get_dw(hContact,META_PROTO,META_LINK,(DWORD)-1))!=(DWORD)-1) {
// is a subcontact
// get nick for debug messages
strcpy(nick_buffer, "meta_id: ");
strcat(nick_buffer, _itoa(meta_id, buffer2, 10));
- contact_number = DBGetContactSettingDword(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
+ contact_number = db_get_dw(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
strcat(nick_buffer, ", contact num: ");
strcat(nick_buffer, _itoa(contact_number, buffer2, 10));
@@ -791,7 +781,7 @@ int Meta_SetHandles(void) { }
// ensure the window open flag is not present
- DBDeleteContactSetting(hContact, META_PROTO, "WindowOpen");
+ db_unset(hContact, META_PROTO, "WindowOpen");
// find metacontact
@@ -799,22 +789,22 @@ int Meta_SetHandles(void) { hContact2 = db_find_first();
while ( hContact2 != NULL ) {
- if (DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) {
+ if (db_get_dw(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) {
found = TRUE;
// set handle
- DBWriteContactSettingDword(hContact, META_PROTO, "Handle", (DWORD)hContact2);
+ db_set_dw(hContact, META_PROTO, "Handle", (DWORD)hContact2);
// increment contact counter (cleared in Load function)
- DBWriteContactSettingByte(hContact2, META_PROTO, "ContactCountCheck",
- (unsigned char)(DBGetContactSettingByte(hContact2, META_PROTO, "ContactCountCheck", 0) + 1));
+ db_set_b(hContact2, META_PROTO, "ContactCountCheck",
+ (unsigned char)(db_get_b(hContact2, META_PROTO, "ContactCountCheck", 0) + 1));
- num_contacts = DBGetContactSettingDword(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
+ num_contacts = db_get_dw(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
if (contact_number >= 0 && contact_number < num_contacts) {
// set metacontact's handle to us
strcpy(buffer, "Handle");
strcat(buffer, _itoa((int)contact_number, buffer2, 10));
- DBWriteContactSettingDword(hContact2, META_PROTO, buffer, (DWORD)hContact);
+ db_set_dw(hContact2, META_PROTO, buffer, (DWORD)hContact);
} else {
char buff[256];
// problem - contact number is greater than meta's number of contacts
@@ -837,12 +827,12 @@ int Meta_SetHandles(void) { MessageBox(0, Translate("Subcontact's MetaContact not found - deleting MetaContact data"), nick_buffer, MB_OK | MB_ICONERROR);
// delete meta data
- DBDeleteContactSetting(hContact,META_PROTO,"IsSubcontact");
- DBDeleteContactSetting(hContact,META_PROTO,META_LINK);
- DBDeleteContactSetting(hContact,META_PROTO,"Handle");
- DBDeleteContactSetting(hContact,META_PROTO,"ContactNumber");
+ db_unset(hContact,META_PROTO,"IsSubcontact");
+ db_unset(hContact,META_PROTO,META_LINK);
+ db_unset(hContact,META_PROTO,"Handle");
+ db_unset(hContact,META_PROTO,"ContactNumber");
Meta_RestoreGroup(hContact);
- DBDeleteContactSetting(hContact,META_PROTO,"OldCListGroup");
+ db_unset(hContact,META_PROTO,"OldCListGroup");
CallService(MS_PROTO_REMOVEFROMCONTACT, (WPARAM)hContact, (LPARAM)META_FILTER);
// stop ignoring, if we were
@@ -850,14 +840,14 @@ int Meta_SetHandles(void) { CallService(MS_IGNORE_UNIGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE);
} else {
- if (!DBGetContactSettingByte(hContact, META_PROTO, "IsSubcontact", 0))
- DBWriteContactSettingByte(hContact, META_PROTO, "IsSubcontact", 1);
+ if (!db_get_b(hContact, META_PROTO, "IsSubcontact", 0))
+ db_set_b(hContact, META_PROTO, "IsSubcontact", 1);
}
} else
- DBDeleteContactSetting(hContact, META_PROTO, "Handle");
+ db_unset(hContact, META_PROTO, "Handle");
- if ((meta_id = DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1))!=(DWORD)-1) {
+ if ((meta_id = db_get_dw(hContact,META_PROTO,META_ID,(DWORD)-1))!=(DWORD)-1) {
// is a metacontact
// get nick for debug messages
@@ -865,11 +855,11 @@ int Meta_SetHandles(void) { strcat(nick_buffer, _itoa(meta_id, buffer2, 10));
// ensure the window open flag is not present
- DBDeleteContactSetting(hContact, META_PROTO, "WindowOpen");
+ db_unset(hContact, META_PROTO, "WindowOpen");
// ensure default is reasonable
- contact_number = DBGetContactSettingDword(hContact, META_PROTO, "Default", -1);
- num_contacts = DBGetContactSettingDword(hContact, META_PROTO, "NumContacts", (DWORD)-1);
+ contact_number = db_get_dw(hContact, META_PROTO, "Default", -1);
+ num_contacts = db_get_dw(hContact, META_PROTO, "NumContacts", (DWORD)-1);
if (num_contacts < 0) {
// problem
@@ -900,13 +890,13 @@ int Meta_SetHandles(void) { // loop through one more time - check contact counts match
hContact = db_find_first();
while ( hContact != NULL ) {
- if ((meta_id = DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1))!=(DWORD)-1) {
+ if ((meta_id = db_get_dw(hContact,META_PROTO,META_ID,(DWORD)-1))!=(DWORD)-1) {
// get nick for debug messages
strcpy(nick_buffer, Translate("MetaId: "));
strcat(nick_buffer, _itoa(meta_id, buffer2, 10));
- num_contacts = DBGetContactSettingByte(hContact, META_PROTO, "ContactCountCheck", -2);
- if (num_contacts != (DWORD)DBGetContactSettingDword(hContact, META_PROTO, "NumContacts", (DWORD)-1)) {
+ num_contacts = db_get_b(hContact, META_PROTO, "ContactCountCheck", -2);
+ if (num_contacts != (DWORD)db_get_dw(hContact, META_PROTO, "NumContacts", (DWORD)-1)) {
// mismatch
//if (MessageBox(0, Translate("MetaContact corrupted - the number of subcontacts is incorrect.\nDelete MetaContact?"), nick_buffer, MB_YESNO | MB_ICONERROR) == IDYES) {
// Meta_Delete((WPARAM)hContact, (LPARAM)1); // second param prevents confirm dialog
@@ -962,7 +952,7 @@ int Meta_HideLinkedContacts(void) { while ( hContact != NULL ) {
- if ((meta_id = DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1))!=(DWORD)-1) {
+ if ((meta_id = db_get_dw(hContact,META_PROTO,META_LINK,(DWORD)-1))!=(DWORD)-1) {
// is a subcontact
// * ensure filter present
@@ -971,7 +961,7 @@ int Meta_HideLinkedContacts(void) { // get contact number
- contact_number = DBGetContactSettingDword(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
+ contact_number = db_get_dw(hContact, META_PROTO, "ContactNumber", (DWORD)-1);
// prepare to update metacontact record of subcontat status
proto = GetContactProto(hContact);
@@ -983,42 +973,42 @@ int Meta_HideLinkedContacts(void) { hContact2 = db_find_first();
while ( hContact2 != NULL ) {
- if (DBGetContactSettingDword(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) {
- num_contacts = DBGetContactSettingDword(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
+ if (db_get_dw(hContact2,META_PROTO,META_ID,(DWORD)-1) == meta_id) {
+ num_contacts = db_get_dw(hContact2, META_PROTO, "NumContacts", (DWORD)-1);
if (contact_number >= 0 && contact_number < num_contacts) {
if (!proto)
status = ID_STATUS_OFFLINE;
else
- status = DBGetContactSettingWord(hContact, proto, "Status", ID_STATUS_OFFLINE);
+ status = db_get_w(hContact, proto, "Status", ID_STATUS_OFFLINE);
// update metacontact's record of status for this contact
strcpy(buffer, "Status");
strcat(buffer, _itoa(contact_number, buffer2, 10));
- DBWriteContactSettingWord(hContact2, META_PROTO, buffer, status);
+ db_set_w(hContact2, META_PROTO, buffer, status);
// update metacontact's record of nick for this contact
- if (proto && !DBGetContactSetting(hContact, proto, "Nick", &dbv)) {
+ if (proto && !db_get(hContact, proto, "Nick", &dbv)) {
strcpy(buffer, "Nick");
strcat(buffer, _itoa(contact_number, buffer2, 10));
MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv);
strcpy(buffer, "CListName");
strcat(buffer, _itoa(contact_number, buffer2, 10));
- if (DBGetContactSetting(hContact, "CList", "MyHandle", &dbv2)) {
+ if (db_get(hContact, "CList", "MyHandle", &dbv2)) {
MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv);
} else {
MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
} else {
- if (!DBGetContactSetting(hContact, "CList", "MyHandle", &dbv)) {
+ if (!db_get(hContact, "CList", "MyHandle", &dbv)) {
strcpy(buffer, "CListName");
strcat(buffer, _itoa(contact_number, buffer2, 10));
MyDBWriteContactSetting(hContact2, META_PROTO, buffer, &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
}
}
@@ -1037,7 +1027,7 @@ int Meta_HideLinkedContacts(void) { // do metacontacts after handles set properly above
hContact = db_find_first();
while ( hContact != NULL ) {
- if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
+ if (db_get_dw(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
// is a meta contact
HANDLE hMostOnline = Meta_GetMostOnline(hContact); // set nick
Meta_CopyContactNick(hContact, hMostOnline);
@@ -1060,7 +1050,7 @@ int Meta_UnhideLinkedContacts(void) { HANDLE hContact = db_find_first();
while ( hContact != NULL ) {
- if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
+ if (db_get_dw(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
// has a link - unhide it
// restore old group
Meta_RestoreGroup(hContact);
@@ -1082,15 +1072,15 @@ int Meta_HideMetaContacts(int hide) { else Meta_SuppressStatus(options.suppress_status);
while ( hContact != NULL ) {
- if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
+ if (db_get_dw(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
// is a meta contact
if (hide)
- DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
+ db_set_b(hContact, "CList", "Hidden", 1);
else
- DBDeleteContactSetting(hContact, "CList", "Hidden");
+ db_unset(hContact, "CList", "Hidden");
- } else if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
+ } else if (db_get_dw(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
// when metacontacts are hidden, show subcontacts, and vice versa
if (hide) {
Meta_RestoreGroup(hContact);
@@ -1116,20 +1106,20 @@ void Meta_RestoreGroup(HANDLE hContact) { // show it anyway - users are reporting contacts removed from meta remain 'hidden'
// possible suspect - server side groups cause hidden group hack to fail, users hide contacts via clist->delete->hide option
- DBDeleteContactSetting(hContact, META_PROTO, "Hidden");
+ db_unset(hContact, META_PROTO, "Hidden");
- if (DBGetContactSettingByte(hContact, META_PROTO, "Hidden", 0) == 1)
+ if (db_get_b(hContact, META_PROTO, "Hidden", 0) == 1)
{
// if we hid it, unhide it
- DBDeleteContactSetting(hContact, META_PROTO, "Hidden");
- DBDeleteContactSetting(hContact, "CList", "Hidden");
+ db_unset(hContact, META_PROTO, "Hidden");
+ db_unset(hContact, "CList", "Hidden");
} else {
DBCONTACTWRITESETTING cws;
- if (!DBGetContactSetting(hContact, META_PROTO, "OldCListGroup", &cws.value)) {
+ if (!db_get(hContact, META_PROTO, "OldCListGroup", &cws.value)) {
if ((cws.value.type == DBVT_ASCIIZ || cws.value.type == DBVT_UTF8) && !strcmp(cws.value.pszVal, META_HIDDEN_GROUP)) {
- DBDeleteContactSetting(hContact, "CList", "Group");
+ db_unset(hContact, "CList", "Group");
} else {
int hGroup = 1;
char *name = 0;
@@ -1148,32 +1138,32 @@ void Meta_RestoreGroup(HANDLE hContact) { cws.szSetting = "Group";
CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws);
} else {
- //DBDeleteContactSetting(hContact, "CList", "Group");
+ //db_unset(hContact, "CList", "Group");
// put back into metacontact's group
DBVARIANT dbv;
- HANDLE hMeta = (HANDLE)DBGetContactSettingDword(hContact, META_PROTO, "Handle", 0);
- if (hMeta && !MyDBGetContactSetting(hMeta, "CList", "Group", &dbv)) {
+ HANDLE hMeta = (HANDLE)db_get_dw(hContact, META_PROTO, "Handle", 0);
+ if (hMeta && !Mydb_get(hMeta, "CList", "Group", &dbv)) {
MyDBWriteContactSetting(hContact, "CList", "Group", &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
} else
- DBDeleteContactSetting(hContact, "CList", "Group");
+ db_unset(hContact, "CList", "Group");
}
}
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
}
- DBDeleteContactSetting(hContact, META_PROTO, "OldCListGroup");
+ db_unset(hContact, META_PROTO, "OldCListGroup");
- if (!DBGetContactSetting(hContact, "CList", "Group", &cws.value)) {
+ if (!db_get(hContact, "CList", "Group", &cws.value)) {
if ((cws.value.type == DBVT_ASCIIZ || cws.value.type == DBVT_UTF8) && !strcmp(cws.value.pszVal, META_HIDDEN_GROUP)) {
- DBDeleteContactSetting(hContact, "CList", "Group");
+ db_unset(hContact, "CList", "Group");
}
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
}
}
// show it anyway - users are reporting contacts removed from meta remain 'hidden'
// possible suspect - server side groups cause hidden group hack to fail, users hide contacts via clist->delete->hide option
- DBDeleteContactSetting(hContact, "CList", "Hidden");
+ db_unset(hContact, "CList", "Hidden");
}
void Meta_SetGroup(HANDLE hContact) {
@@ -1190,12 +1180,12 @@ void Meta_SetGroup(HANDLE hContact) { if (proto && uid && (INT_PTR)uid != CALLSERVICE_NOTFOUND && !strcmp(JABBER_UNIQUE_ID_SETTING, uid)) {
// if it's a jabber contact, hide it, and record the fact that it was us who did
- DBWriteContactSettingByte(hContact, META_PROTO, "Hidden", 1);
- DBWriteContactSettingByte(hContact, "CList", "Hidden", 1);
+ db_set_b(hContact, META_PROTO, "Hidden", 1);
+ db_set_b(hContact, "CList", "Hidden", 1);
} else {
DBCONTACTWRITESETTING cws;
// save old group and move to invisible group (i.e. non-existent group)
- if (!MyDBGetContactSetting(hContact, "CList", "Group", &cws.value)) {
+ if (!Mydb_get(hContact, "CList", "Group", &cws.value)) {
if ((cws.value.type == DBVT_ASCIIZ || cws.value.type == DBVT_UTF8) && !strcmp(cws.value.pszVal, META_HIDDEN_GROUP)) {
// it's already in the group (shouldn't be - but maybe a crash)
} else {
@@ -1203,11 +1193,11 @@ void Meta_SetGroup(HANDLE hContact) { cws.szSetting = "OldCListGroup";
CallService(MS_DB_CONTACT_WRITESETTING,(WPARAM)hContact,(LPARAM)&cws);
}
- DBFreeVariant(&cws.value);
+ db_free(&cws.value);
} else
- DBDeleteContactSetting(hContact, META_PROTO, "OldCListGroup");
+ db_unset(hContact, META_PROTO, "OldCListGroup");
- DBWriteContactSettingString(hContact, "CList", "Group", META_HIDDEN_GROUP);
+ db_set_s(hContact, "CList", "Group", META_HIDDEN_GROUP);
}
}
@@ -1256,7 +1246,7 @@ int Meta_SuppressStatus(BOOL suppress) { HANDLE hContact = db_find_first();
while ( hContact != NULL ) {
- if (DBGetContactSettingDword(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
+ if (db_get_dw(hContact,META_PROTO,META_LINK,(DWORD)-1)!=(DWORD)-1) {
// is a subcontact
if (suppress)
CallService(MS_IGNORE_IGNORE, (WPARAM)hContact, (WPARAM)IGNOREEVENT_USERONLINE);
@@ -1282,16 +1272,16 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { //proto = GetContactProto(hContact);
// read proto direct from db, since we do this on load and other proto plugins may not be loaded yet
- if (!DBGetContactSetting(hContact, "Protocol", "p", &dbv_proto)) {
+ if (!db_get(hContact, "Protocol", "p", &dbv_proto)) {
proto = dbv_proto.pszVal;
if (options.clist_contact_name == CNNT_NICK && proto) {
- if (!MyDBGetContactSetting(hContact, proto, "Nick", &dbv)) {
+ if (!Mydb_get(hContact, proto, "Nick", &dbv)) {
MyDBWriteContactSetting(hMeta, META_PROTO, "Nick", &dbv);
- DBFreeVariant(&dbv);
+ db_free(&dbv);
//CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)hMeta, 0);
//CallService(MS_CLUI_CONTACTRENAMED, (WPARAM)hMeta, 0);
- DBFreeVariant(&dbv_proto);
+ db_free(&dbv_proto);
return 0;
}
} else if (options.clist_contact_name == CNNT_DISPLAYNAME) {
@@ -1306,14 +1296,14 @@ int Meta_CopyContactNick(HANDLE hMeta, HANDLE hContact) { MyDBWriteContactSetting(hMeta, META_PROTO, "Nick", &dbv);
} else
- DBWriteContactSettingString(hMeta, META_PROTO, "Nick", name);
+ db_set_s(hMeta, META_PROTO, "Nick", name);
//CallService(MS_CLIST_INVALIDATEDISPLAYNAME, (WPARAM)hMeta, 0);
//CallService(MS_CLUI_CONTACTRENAMED, (WPARAM)hMeta, 0);
- DBFreeVariant(&dbv_proto);
+ db_free(&dbv_proto);
return 0;
}
}
- DBFreeVariant(&dbv_proto);
+ db_free(&dbv_proto);
}
return 1;
}
@@ -1322,7 +1312,7 @@ int Meta_SetAllNicks() { HANDLE hContact = db_find_first(), most_online;
while ( hContact != NULL ) {
- if (DBGetContactSettingDword(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
+ if (db_get_dw(hContact,META_PROTO,META_ID,(DWORD)-1)!=(DWORD)-1) {
most_online = Meta_GetMostOnline(hContact);
Meta_CopyContactNick(hContact, most_online);
Meta_FixStatus(hContact);
@@ -1353,15 +1343,15 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "Protocol");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
}
// swap the status
@@ -1369,15 +1359,15 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "Status");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
}
// swap the status string
@@ -1385,15 +1375,15 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "StatusString");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
}
// swap the login
@@ -1401,17 +1391,17 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "Login");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
- DBDeleteContactSetting(hMeta, META_PROTO, buff2);
+ db_unset(hMeta, META_PROTO, buff2);
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
}
if (ok2) {
- DBDeleteContactSetting(hMeta, META_PROTO, buff1);
+ db_unset(hMeta, META_PROTO, buff1);
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
}
// swap the nick
@@ -1419,19 +1409,19 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "Nick");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff2);
+ db_unset(hMeta, META_PROTO, buff2);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff1);
+ db_unset(hMeta, META_PROTO, buff1);
}
// swap the clist name
@@ -1439,19 +1429,19 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "CListName");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff2);
+ db_unset(hMeta, META_PROTO, buff2);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff1);
+ db_unset(hMeta, META_PROTO, buff1);
}
// swap the handle
@@ -1459,24 +1449,24 @@ int Meta_SwapContacts(HANDLE hMeta, DWORD contact_number1, DWORD contact_number2 strcat(buff1, _itoa(contact_number1, buff12, 10));
strcpy(buff2, "Handle");
strcat(buff2, _itoa(contact_number2, buff22, 10));
- ok1 = !MyDBGetContactSetting(hMeta, META_PROTO, buff1, &dbv1);
- ok2 = !MyDBGetContactSetting(hMeta, META_PROTO, buff2, &dbv2);
+ ok1 = !Mydb_get(hMeta, META_PROTO, buff1, &dbv1);
+ ok2 = !Mydb_get(hMeta, META_PROTO, buff2, &dbv2);
if (ok1) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff2, &dbv1);
- DBFreeVariant(&dbv1);
+ db_free(&dbv1);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff2);
+ db_unset(hMeta, META_PROTO, buff2);
}
if (ok2) {
MyDBWriteContactSetting(hMeta, META_PROTO, buff1, &dbv2);
- DBFreeVariant(&dbv2);
+ db_free(&dbv2);
} else {
- DBDeleteContactSetting(hMeta, META_PROTO, buff1);
+ db_unset(hMeta, META_PROTO, buff1);
}
// finally, inform the contacts of their change in position
- DBWriteContactSettingDword(hContact1, META_PROTO, "ContactNumber", (DWORD)contact_number2);
- DBWriteContactSettingDword(hContact2, META_PROTO, "ContactNumber", (DWORD)contact_number1);
+ db_set_dw(hContact1, META_PROTO, "ContactNumber", (DWORD)contact_number2);
+ db_set_dw(hContact2, META_PROTO, "ContactNumber", (DWORD)contact_number1);
return 0;
}
@@ -1655,7 +1645,7 @@ char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { field = (char *)CallProtoService(proto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
if (!field) return 0;
- DBGetContactSetting(hContact,proto,field,&dbv);
+ db_get(hContact,proto,field,&dbv);
switch(dbv.type)
{
case DBVT_ASCIIZ:
@@ -1673,7 +1663,7 @@ char *Meta_GetUniqueIdentifier(HANDLE hContact, DWORD *pused) { default:
sprintf(buff,"bugger this");
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
strncpy(id + used, buff, 256 - used);
if (used) {
@@ -1689,16 +1679,16 @@ void Meta_FixStatus(HANDLE hMeta) { if (most_online) {
char *proto = GetContactProto(most_online);
if (proto) {
- WORD status = (WORD)DBGetContactSettingWord(most_online, proto, "Status", (WORD)ID_STATUS_OFFLINE);
- DBWriteContactSettingWord(hMeta, META_PROTO, "Status", status);
+ WORD status = (WORD)db_get_w(most_online, proto, "Status", (WORD)ID_STATUS_OFFLINE);
+ db_set_w(hMeta, META_PROTO, "Status", status);
}
- else DBWriteContactSettingWord(hMeta, META_PROTO, "Status", (WORD)ID_STATUS_OFFLINE);
+ else db_set_w(hMeta, META_PROTO, "Status", (WORD)ID_STATUS_OFFLINE);
}
- else DBWriteContactSettingWord(hMeta, META_PROTO, "Status", (WORD)ID_STATUS_OFFLINE);
+ else db_set_w(hMeta, META_PROTO, "Status", (WORD)ID_STATUS_OFFLINE);
}
INT_PTR Meta_IsEnabled() {
- return DBGetContactSettingByte(0, META_PROTO, "Enabled", 1) && (meta_group_hack_disabled || DBGetContactSettingByte(NULL, "CList", "UseGroups", 1));
+ return db_get_b(0, META_PROTO, "Enabled", 1) && (meta_group_hack_disabled || db_get_b(NULL, "CList", "UseGroups", 1));
}
|