summaryrefslogtreecommitdiff
path: root/plugins/SeenPlugin/src/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SeenPlugin/src/utils.cpp')
-rw-r--r--plugins/SeenPlugin/src/utils.cpp799
1 files changed, 401 insertions, 398 deletions
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp
index 5d64f0e7a9..c97c4eb793 100644
--- a/plugins/SeenPlugin/src/utils.cpp
+++ b/plugins/SeenPlugin/src/utils.cpp
@@ -23,9 +23,6 @@ Last change on : $Date: 2007-12-30 01:30:07 +0300 (Вс, 30 дек 2007) $
Last change by : $Author: y_b $
*/
#include "seen.h"
-#include <m_ignore.h>
-#include <time.h>
-
void FileWrite(HANDLE);
void HistoryWrite(HANDLE hcontact);
@@ -34,97 +31,82 @@ void ShowHistory(HANDLE hContact, BYTE isAlert);
char * courProtoName = 0;
-//copied from ..\..\miranda32\protocols\protocols\protocols.c
-PROTOCOLDESCRIPTOR* Proto_IsProtocolLoaded(const char* szProto)
-{
- return (PROTOCOLDESCRIPTOR*) CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)szProto);
-}
-
-
/*
Returns true if the protocols is to be monitored
*/
int IsWatchedProtocol(const char* szProto)
{
- DBVARIANT dbv;
- char *szProtoPointer, *szWatched;
- int iProtoLen, iWatchedLen;
- int retval = 0;
- PROTOCOLDESCRIPTOR *pd;
-
if (szProto == NULL)
return 0;
- pd=Proto_IsProtocolLoaded(szProto);
- if (pd==NULL || pd->type!=PROTOTYPE_PROTOCOL || CallProtoService(pd->szName,PS_GETCAPS,PFLAGNUM_2,0)==0)
+ PROTOACCOUNT *pd = ProtoGetAccount(szProto);
+ if (pd == NULL || CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0)
return 0;
- iProtoLen = (int)_tcslen(szProto);
- if(DBGetContactSetting(NULL, S_MOD, "WatchedProtocols", &dbv))
+ int iProtoLen = (int)strlen(szProto);
+ char *szWatched;
+ DBVARIANT dbv;
+ if ( DBGetContactSettingString(NULL, S_MOD, "WatchedProtocols", &dbv))
szWatched = DEFAULT_WATCHEDPROTOCOLS;
- else
- szWatched = dbv.pszVal;
- iWatchedLen = (int)_tcslen(szWatched);
+ else {
+ szWatched = NEWSTR_ALLOCA(dbv.pszVal);
+ db_free(&dbv);
+ }
if (*szWatched == '\0')
- {
- retval=1; //empty string: all protocols are watched
- }
- else
- {
- char sTemp [MAXMODULELABELLENGTH+1]="";
- strcat(sTemp,szProto);
- strcat(sTemp," ");
- szProtoPointer = strstr(szWatched, sTemp);
- if (szProtoPointer == NULL)
- retval=0;
- else
- retval=1;
- }
+ return 1; //empty string: all protocols are watched
- DBFreeVariant(&dbv);
- return retval;
+ char sTemp[MAXMODULELABELLENGTH+1];
+ mir_snprintf(sTemp, SIZEOF(sTemp), "%s ", szProto);
+ return strstr(szWatched, sTemp) != NULL;
}
-BOOL isYahoo(char * protoname){
+BOOL isYahoo(char *protoname)
+{
if (protoname) {
char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if (pszUniqueSetting){
- return (!strcmp(pszUniqueSetting,"yahoo_id"));
- } }
+ if (pszUniqueSetting)
+ return !strcmp(pszUniqueSetting, "yahoo_id");
+ }
return FALSE;
}
-BOOL isJabber(char * protoname){
+
+BOOL isJabber(char *protoname)
+{
if (protoname) {
char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if (pszUniqueSetting){
- return (!strcmp(pszUniqueSetting,"jid"));
- } }
+ if (pszUniqueSetting)
+ return !strcmp(pszUniqueSetting, "jid");
+ }
return FALSE;
}
-BOOL isICQ(char * protoname){
+
+BOOL isICQ(char *protoname)
+{
if (protoname) {
char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if (pszUniqueSetting){
- return (!strcmp(pszUniqueSetting,"UIN"));
- } }
+ if (pszUniqueSetting)
+ return !strcmp(pszUniqueSetting, "UIN");
+ }
return FALSE;
}
-BOOL isMSN(char * protoname){
+
+BOOL isMSN(char *protoname)
+{
if (protoname) {
char *pszUniqueSetting = (char*)CallProtoService(protoname, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if (pszUniqueSetting){
- return (!strcmp(pszUniqueSetting,"e-mail"));
- } }
+ if (pszUniqueSetting)
+ return !strcmp(pszUniqueSetting, "e-mail");
+ }
return FALSE;
}
-DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){
- DWORD res = 0;
+DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st)
+{
FILETIME ft;
ULONGLONG ll;
- res = DBGetContactSettingDword(hcontact,S_MOD,"seenTS",0);
- if (res){
+ DWORD res = db_get_dw(hcontact,S_MOD,"seenTS",0);
+ if (res) {
if (st) {
ll = UInt32x32To64(CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,res,0), 10000000) + NUM100NANOSEC;
ft.dwLowDateTime = (DWORD)ll;
@@ -132,316 +114,323 @@ DWORD isSeen(HANDLE hcontact, SYSTEMTIME *st){
FileTimeToSystemTime(&ft, st);
}
return res;
- } else {
- SYSTEMTIME lst;
- ZeroMemory(&lst,sizeof(lst));
- if (lst.wYear = DBGetContactSettingWord(hcontact,S_MOD,"Year",0)) {
- if (lst.wMonth = DBGetContactSettingWord(hcontact,S_MOD,"Month",0)) {
- if (lst.wDay = DBGetContactSettingWord(hcontact,S_MOD,"Day",0)) {
- lst.wDayOfWeek = DBGetContactSettingWord(hcontact,S_MOD,"WeekDay",0);
- lst.wHour = DBGetContactSettingWord(hcontact,S_MOD,"Hours",0);
- lst.wMinute = DBGetContactSettingWord(hcontact,S_MOD,"Minutes",0);
- lst.wSecond = DBGetContactSettingWord(hcontact,S_MOD,"Seconds",0);
- if (SystemTimeToFileTime(&lst,&ft)) {
- ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime);
- ll -= NUM100NANOSEC;
- ll /= 10000000;
- //perform LOCALTOTIMESTAMP
- res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0);
- //nevel look for Year/Month/Day/Hour/Minute/Second again
- DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res);
- }
- } } }
- if (st) CopyMemory (st, &lst, sizeof (SYSTEMTIME));
}
+
+ SYSTEMTIME lst;
+ ZeroMemory(&lst,sizeof(lst));
+ if (lst.wYear = db_get_w(hcontact,S_MOD,"Year",0)) {
+ if (lst.wMonth = db_get_w(hcontact,S_MOD,"Month",0)) {
+ if (lst.wDay = db_get_w(hcontact,S_MOD,"Day",0)) {
+ lst.wDayOfWeek = db_get_w(hcontact,S_MOD,"WeekDay",0);
+ lst.wHour = db_get_w(hcontact,S_MOD,"Hours",0);
+ lst.wMinute = db_get_w(hcontact,S_MOD,"Minutes",0);
+ lst.wSecond = db_get_w(hcontact,S_MOD,"Seconds",0);
+ if (SystemTimeToFileTime(&lst,&ft)) {
+ ll = ((LONGLONG)ft.dwHighDateTime<<32)|((LONGLONG)ft.dwLowDateTime);
+ ll -= NUM100NANOSEC;
+ ll /= 10000000;
+ //perform LOCALTOTIMESTAMP
+ res = (DWORD)ll - CallService(MS_DB_TIME_TIMESTAMPTOLOCAL,0,0);
+ //nevel look for Year/Month/Day/Hour/Minute/Second again
+ DBWriteContactSettingDword(hcontact,S_MOD,"seenTS",res);
+ }
+ } } }
+
+ if (st)
+ CopyMemory (st, &lst, sizeof (SYSTEMTIME));
+
return res;
}
-char *ParseString(char *szstring,HANDLE hcontact,BYTE isfile)
+TCHAR *weekdays[] = { _T("Sunday"), _T("Monday"), _T("Tuesday"), _T("Wednesday"), _T("Thursday"), _T("Friday"), _T("Saturday") };
+TCHAR *wdays_short[] = { _T("Sun."), _T("Mon."), _T("Tue."), _T("Wed."), _T("Thu."), _T("Fri."), _T("Sat.") };
+TCHAR *monthnames[] = { _T("January"), _T("February"), _T("March"), _T("April"), _T("May"), _T("June"), _T("July"), _T("August"), _T("September"), _T("October"), _T("November"), _T("December") };
+TCHAR *mnames_short[] = { _T("Jan."), _T("Feb."), _T("Mar."), _T("Apr."), _T("May"), _T("Jun."), _T("Jul."), _T("Aug."), _T("Sep."), _T("Oct."), _T("Nov."), _T("Dec.") };
+
+TCHAR *ParseString(TCHAR *szstring, HANDLE hcontact, BYTE isfile)
{
#define MAXSIZE 1024
- static char sztemp[MAXSIZE+1];
- int sztemplen = 0;
- char szdbsetting[128]="";
- char *charPtr;
- UINT loop=0;
+ static TCHAR sztemp[MAXSIZE+1];
+ TCHAR szdbsetting[128];
+ TCHAR *charPtr;
int isetting=0;
DWORD dwsetting=0;
struct in_addr ia;
- char *weekdays[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
- char *wdays_short[]={"Sun.","Mon.","Tue.","Wed.","Thu.","Fri.","Sat."};
- char *monthnames[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
- char *mnames_short[]={"Jan.","Feb.","Mar.","Apr.","May","Jun.","Jul.","Aug.","Sep.","Oct.","Nov.","Dec."};
- CONTACTINFO ci;
- BOOL wantempty;
- SYSTEMTIME st;
+ DBVARIANT dbv;
sztemp[0] = '\0';
- if (!isSeen(hcontact,&st)) {
- strcat(sztemp,Translate("<never seen>"));
+
+ SYSTEMTIME st;
+ if ( !isSeen(hcontact, &st)) {
+ _tcscat(sztemp, TranslateT("<never seen>"));
return sztemp;
}
- ci.cbSize=sizeof(CONTACTINFO);
- ci.hContact=hcontact;
- ci.szProto=hcontact?(char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0):courProtoName;
- for (;loop<strlen(szstring);loop++)
- {
- if (sztemplen == MAXSIZE) break;
- if ((szstring[loop]!='%')&(szstring[loop]!='#'))
- {
- strncat(sztemp,szstring+loop,1);
- sztemplen++;
+ CONTACTINFO ci = { sizeof(CONTACTINFO) };
+ ci.hContact = hcontact;
+ ci.szProto = hcontact ? (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0) : courProtoName;
+
+ TCHAR *d = sztemp;
+ for (TCHAR *p = szstring; *p; p++) {
+ if (d >= sztemp + MAXSIZE)
+ break;
+
+ if (*p != '%' && *p !='#') {
+ *d++ = *p;
continue;
}
- else
- {
- wantempty = (szstring[loop]=='#');
- switch(szstring[++loop]) {
- case 'Y':
- if (!st.wYear) goto LBL_noData;
- sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%04i",st.wYear);
- break;
+ bool wantempty = *p =='#';
+ switch(*++p) {
+ case 'Y':
+ if (!st.wYear) goto LBL_noData;
+ d += _stprintf(d, _T("%04i"), st.wYear);
+ break;
- case 'y':
- if (!st.wYear) goto LBL_noData;
- wsprintf(szdbsetting,"%04i",st.wYear);
- sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",szdbsetting+2);
- break;
+ case 'y':
+ if (!st.wYear) goto LBL_noData;
+ d += _stprintf(d, _T("%02i"), st.wYear % 100);
+ break;
- case 'm':
- if (!(isetting=st.wMonth)) goto LBL_noData;
+ case 'm':
+ if (!(isetting=st.wMonth)) goto LBL_noData;
LBL_2DigNum:
- sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%02i",isetting);
- break;
+ d += _stprintf(d, _T("%02i"), isetting);
+ break;
- case 'd':
- if (isetting=st.wDay) goto LBL_2DigNum;
- else goto LBL_noData;
+ case 'd':
+ if (isetting = st.wDay) goto LBL_2DigNum;
+ else goto LBL_noData;
- case 'W':
- isetting=st.wDayOfWeek;
- if(isetting==-1){
+ case 'W':
+ isetting = st.wDayOfWeek;
+ if (isetting == -1){
LBL_noData:
- charPtr = wantempty?"":Translate("<unknown>");
- goto LBL_charPtr;
- }
- charPtr = Translate(weekdays[isetting]);
+ charPtr = wantempty ? _T("") : TranslateT("<unknown>");
+ goto LBL_charPtr;
+ }
+ charPtr = TranslateTS(weekdays[isetting]);
LBL_charPtr:
- sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",charPtr);
- break;
+ d += mir_sntprintf(d, MAXSIZE-(d-sztemp), _T("%s"), charPtr);
+ break;
- case 'w':
- isetting=st.wDayOfWeek;
- if(isetting==-1)goto LBL_noData;
- charPtr = Translate(wdays_short[isetting]);
- goto LBL_charPtr;
-
- case 'E':
- if (!(isetting=st.wMonth))goto LBL_noData;
- charPtr = Translate(monthnames[isetting-1]);
- goto LBL_charPtr;
-
- case 'e':
- if (!(isetting=st.wMonth))goto LBL_noData;
- charPtr = Translate(mnames_short[isetting-1]);
- goto LBL_charPtr;
-
- case 'H':
- if ((isetting=st.wHour)==-1)goto LBL_noData;
- goto LBL_2DigNum;
-
- case 'h':
- if ((isetting=st.wHour)==-1)goto LBL_noData;
- if (!isetting) isetting=12;
- isetting = isetting-((isetting>12)?12:0);
- goto LBL_2DigNum;
-
- case 'p':
- if ((isetting=st.wHour)==-1)goto LBL_noData;
- charPtr = (isetting>=12)?"PM":"AM";
- goto LBL_charPtr;
-
- case 'M':
- if ((isetting=st.wMinute)==-1)goto LBL_noData;
- goto LBL_2DigNum;
-
- case 'S':
- if ((isetting=st.wHour)==-1)goto LBL_noData;
- goto LBL_2DigNum;
-
- case 'n':
- charPtr = hcontact?(char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,(WPARAM)hcontact,0):(wantempty?"":"---");
- goto LBL_charPtr;
- case 'N':
- ci.dwFlag=CNF_NICK;
- if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci)) {
- charPtr = ci.pszVal;
- } else goto LBL_noData;
- goto LBL_charPtr;
- case 'G':
- {
- DBVARIANT dbv;
- if (!DBGetContactSetting(hcontact,"CList","Group",&dbv)) {
- strcpy(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- charPtr = szdbsetting;
- goto LBL_charPtr;
- } else; //do nothing
- }
+ case 'w':
+ isetting = st.wDayOfWeek;
+ if (isetting == -1) goto LBL_noData;
+ charPtr = TranslateTS( wdays_short[isetting] );
+ goto LBL_charPtr;
+
+ case 'E':
+ if ( !(isetting = st.wMonth)) goto LBL_noData;
+ charPtr = TranslateTS( monthnames[isetting-1] );
+ goto LBL_charPtr;
+
+ case 'e':
+ if ( !(isetting = st.wMonth)) goto LBL_noData;
+ charPtr = TranslateTS( mnames_short[isetting-1] );
+ goto LBL_charPtr;
+
+ case 'H':
+ if ((isetting = st.wHour) == -1) goto LBL_noData;
+ goto LBL_2DigNum;
+
+ case 'h':
+ if ((isetting = st.wHour) == -1) goto LBL_noData;
+ if (!isetting) isetting = 12;
+ isetting = isetting-((isetting>12)?12:0);
+ goto LBL_2DigNum;
+
+ case 'p':
+ if ((isetting = st.wHour) == -1) goto LBL_noData;
+ charPtr = (isetting >= 12) ? _T("PM") : _T("AM");
+ goto LBL_charPtr;
+
+ case 'M':
+ if ((isetting = st.wMinute) == -1) goto LBL_noData;
+ goto LBL_2DigNum;
+
+ case 'S':
+ if ((isetting = st.wHour) == -1) goto LBL_noData;
+ goto LBL_2DigNum;
+
+ case 'n':
+ charPtr = hcontact ? (TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hcontact, GCDNF_TCHAR) : (wantempty ? _T("") : _T("---"));
+ goto LBL_charPtr;
+
+ case 'N':
+ ci.dwFlag = CNF_NICK | CNF_TCHAR;
+ if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
+ charPtr = ci.pszVal;
+ goto LBL_charPtr;
+ }
+ goto LBL_noData;
+
+ case 'G':
+ if ( !DBGetContactSettingTString(hcontact, "CList", "Group", &dbv)) {
+ _tcscpy(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
+ }
+ break;
+
+ case 'u':
+ ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
+ if ( !CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
+ switch(ci.type) {
+ case CNFT_BYTE:
+ _ltot(ci.bVal, szdbsetting, 10);
+ break;
+ case CNFT_WORD:
+ _ltot(ci.wVal, szdbsetting, 10);
+ break;
+ case CNFT_DWORD:
+ _ltot(ci.dVal, szdbsetting, 10);
break;
+ case CNFT_ASCIIZ:
+ _tcscpy(szdbsetting, ci.pszVal);
+ break;
+ }
+ }
+ else if (ci.szProto != NULL) {
+ if ( isYahoo(ci.szProto)) { // YAHOO support
+ DBGetContactSettingTString(hcontact, ci.szProto, "id", &dbv);
+ _tcscpy(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else if ( isJabber(ci.szProto)) { // JABBER support
+ if ( DBGetContactSettingTString(hcontact, ci.szProto, "LoginName", &dbv))
+ goto LBL_noData;
+
+ _tcscpy(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+
+ DBGetContactSettingTString(hcontact, ci.szProto, "LoginServer", &dbv);
+ _tcscat(szdbsetting, _T("@"));
+ _tcscat(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else goto LBL_noData;
+ }
+ else goto LBL_noData;
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
+
+ case 's':
+ if (isetting = db_get_w(hcontact,S_MOD,hcontact ? "StatusTriger" : courProtoName, 0)) {
+ _tcscpy(szdbsetting, TranslateTS((TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)(isetting|0x8000), GSMDF_TCHAR)));
+ if ( !(isetting & 0x8000)) {
+ _tcscat(szdbsetting, _T("/"));
+ _tcscat(szdbsetting, TranslateT("Idle"));
+ }
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
+ }
+ goto LBL_noData;
- case 'u':
- ci.dwFlag=CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO,(WPARAM)0,(LPARAM)&ci))
- {
- switch(ci.type)
- {
- case CNFT_BYTE:
- _ltot(ci.bVal, szdbsetting, 10);
- break;
- case CNFT_WORD:
- _ltot(ci.wVal, szdbsetting, 10);
- break;
- case CNFT_DWORD:
- _ltot(ci.dVal, szdbsetting, 10);
- break;
- case CNFT_ASCIIZ:
- strcpy(szdbsetting, ci.pszVal);
- break;
- }
+ case 'T':
+ if ( DBGetContactSettingTString(hcontact, "CList", "StatusMsg", &dbv))
+ goto LBL_noData;
- }
- else if (ci.szProto != NULL)
- {
- if (isYahoo(ci.szProto)) // YAHOO support
- {
- DBVARIANT dbv;
- DBGetContactSetting(hcontact,ci.szProto,"id",&dbv);
- strcpy(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- else if (isJabber(ci.szProto)) // JABBER support
- {
- DBVARIANT dbv;
- if (DBGetContactSetting(hcontact,ci.szProto,"LoginName",&dbv)) goto LBL_noData;
- strcpy(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- DBGetContactSetting(hcontact,ci.szProto,"LoginServer",&dbv);
- strcat(szdbsetting,"@");
- strcat(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- } else goto LBL_noData;
- }
- else goto LBL_noData;
- charPtr = szdbsetting;
- goto LBL_charPtr;
-
- case 's':
- if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"StatusTriger":courProtoName,0)) {
- strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)(isetting|0x8000),0)));
- if (!(isetting&0x8000)) {
- strcat(szdbsetting,"/");
- strcat(szdbsetting,Translate("Idle"));
- }
- charPtr = szdbsetting;
- } else goto LBL_noData;
- goto LBL_charPtr;
- case 'T':
- {
- DBVARIANT dbv;
- if (!DBGetContactSetting(hcontact,"CList","StatusMsg",&dbv)) {
- sztemplen += mir_snprintf(sztemp+sztemplen,MAXSIZE-sztemplen,"%s",dbv.pszVal);
- DBFreeVariant(&dbv);
- } else goto LBL_noData;
- }
- break;
- case 'o':
- if (isetting=DBGetContactSettingWord(hcontact,S_MOD,hcontact?"OldStatus":courProtoName,0)) {
- strcpy(szdbsetting,Translate((const char *)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION,(WPARAM)isetting,0)));
- if (includeIdle) if (hcontact) if (DBGetContactSettingByte(hcontact,S_MOD,"OldIdle",0)) {
- strcat(szdbsetting,"/");
- strcat(szdbsetting,Translate("Idle"));
- }
- charPtr = szdbsetting;
- } else goto LBL_noData;
- goto LBL_charPtr;
-
- case 'i':
- case 'r': if (isJabber(ci.szProto)) {
- DBVARIANT dbv;
- if (!DBGetContactSetting(hcontact,ci.szProto,szstring[loop]=='i'?"Resource":"System",&dbv)) {
- strcpy(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- charPtr = szdbsetting;
- } else goto LBL_noData;
- } else {
- dwsetting=DBGetContactSettingDword(hcontact,ci.szProto,szstring[loop]=='i'?"IP":"RealIP",0);
- if(dwsetting){
- ia.S_un.S_addr=htonl(dwsetting);
- charPtr = inet_ntoa(ia);
- } else goto LBL_noData;
- }
- goto LBL_charPtr;
- case 'P':if (ci.szProto) charPtr = ci.szProto; else charPtr = wantempty?"":"ProtoUnknown";
- goto LBL_charPtr;
- case 'b':
- charPtr = /*"\n"*/"\x0D\x0A";
- goto LBL_charPtr;
- case 'C': // Get Client Info
- if (isMSN(ci.szProto)) {
- if (hcontact) {
- dwsetting = (int)DBGetContactSettingDword(hcontact,ci.szProto,"FlagBits",0);
- wsprintf(szdbsetting,"MSNC%i",(dwsetting&0x70000000)>>28);
- if (dwsetting & 0x00000001) strcat(szdbsetting," MobD"); //Mobile Device
- if (dwsetting & 0x00000004) strcat(szdbsetting," InkG"); //GIF Ink Send/Receive
- if (dwsetting & 0x00000008) strcat(szdbsetting," InkI"); //ISF Ink Send/Receive
- if (dwsetting & 0x00000010) strcat(szdbsetting," WCam"); //Webcam
- if (dwsetting & 0x00000020) strcat(szdbsetting," MPkt"); //Multi packet messages
- if (dwsetting & 0x00000040) strcat(szdbsetting," SMSr"); //Paging
- if (dwsetting & 0x00000080) strcat(szdbsetting," DSMS"); //Using MSN Direct
- if (dwsetting & 0x00000200) strcat(szdbsetting," WebM"); //WebMessenger
- if (dwsetting & 0x00001000) strcat(szdbsetting," MS7+"); //Unknown (Msgr 7 always[?] sets it)
- if (dwsetting & 0x00004000) strcat(szdbsetting," DirM"); //DirectIM
- if (dwsetting & 0x00008000) strcat(szdbsetting," Wink"); //Send/Receive Winks
- if (dwsetting & 0x00010000) strcat(szdbsetting," MSrc"); //MSN Search ??
- if (dwsetting & 0x00040000) strcat(szdbsetting," VoiC"); //Voice Clips
- } else strcpy(szdbsetting,"Miranda");
- } else {
- DBVARIANT dbv;
- if (!DBGetContactSetting(hcontact,ci.szProto,"MirVer",&dbv)) {
- strcpy(szdbsetting,dbv.pszVal);
- DBFreeVariant(&dbv);
- } else goto LBL_noData;
- }
- charPtr = szdbsetting;
- goto LBL_charPtr;
- case 't':
- charPtr = "\t";
- goto LBL_charPtr;
-
- default:
- strncpy(szdbsetting,szstring+loop-1,2);
- goto LBL_charPtr;
+ d += mir_sntprintf(d, MAXSIZE-(d-sztemp), _T("%s"), dbv.ptszVal);
+ db_free(&dbv);
+ break;
+
+ case 'o':
+ if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "OldStatus" : courProtoName, 0)) {
+ _tcscpy(szdbsetting, TranslateTS((TCHAR*)CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)isetting, GSMDF_TCHAR)));
+ if (includeIdle) if (hcontact) if ( db_get_b(hcontact, S_MOD, "OldIdle", 0)) {
+ _tcscat(szdbsetting, _T("/"));
+ _tcscat(szdbsetting, TranslateT("Idle"));
+ }
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
}
+ goto LBL_noData;
+
+ case 'i':
+ case 'r':
+ if ( isJabber(ci.szProto)) {
+ if ( DBGetContactSettingTString(hcontact, ci.szProto, *p == 'i' ? "Resource" : "System", &dbv))
+ goto LBL_noData;
+
+ _tcscpy(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+ charPtr = szdbsetting;
+ }
+ else {
+ dwsetting = db_get_dw(hcontact, ci.szProto, *p == 'i' ? "IP" : "RealIP", 0);
+ if (!dwsetting)
+ goto LBL_noData;
+
+ ia.S_un.S_addr = htonl(dwsetting);
+ _tcscpy(szdbsetting, _A2T( inet_ntoa(ia)));
+ charPtr = szdbsetting;
+ }
+ goto LBL_charPtr;
+
+ case 'P':
+ _tcscpy(szdbsetting, _A2T(ci.szProto ? ci.szProto : (wantempty ? "" : "ProtoUnknown")));
+ goto LBL_charPtr;
+
+ case 'b':
+ charPtr = _T("x0D\x0A");
+ goto LBL_charPtr;
+
+ case 'C': // Get Client Info
+ if (isMSN(ci.szProto)) {
+ if (hcontact) {
+ dwsetting = (int)db_get_dw(hcontact,ci.szProto,"FlagBits",0);
+ wsprintf(szdbsetting, _T("MSNC%i"), (dwsetting&0x70000000)>>28);
+ if (dwsetting & 0x00000001) _tcscat(szdbsetting, _T(" MobD")); //Mobile Device
+ if (dwsetting & 0x00000004) _tcscat(szdbsetting, _T(" InkG")); //GIF Ink Send/Receive
+ if (dwsetting & 0x00000008) _tcscat(szdbsetting, _T(" InkI")); //ISF Ink Send/Receive
+ if (dwsetting & 0x00000010) _tcscat(szdbsetting, _T(" WCam")); //Webcam
+ if (dwsetting & 0x00000020) _tcscat(szdbsetting, _T(" MPkt")); //Multi packet messages
+ if (dwsetting & 0x00000040) _tcscat(szdbsetting, _T(" SMSr")); //Paging
+ if (dwsetting & 0x00000080) _tcscat(szdbsetting, _T(" DSMS")); //Using MSN Direct
+ if (dwsetting & 0x00000200) _tcscat(szdbsetting, _T(" WebM")); //WebMessenger
+ if (dwsetting & 0x00001000) _tcscat(szdbsetting, _T(" MS7+")); //Unknown (Msgr 7 always[?] sets it)
+ if (dwsetting & 0x00004000) _tcscat(szdbsetting, _T(" DirM")); //DirectIM
+ if (dwsetting & 0x00008000) _tcscat(szdbsetting, _T(" Wink")); //Send/Receive Winks
+ if (dwsetting & 0x00010000) _tcscat(szdbsetting, _T(" MSrc")); //MSN Search ??
+ if (dwsetting & 0x00040000) _tcscat(szdbsetting, _T(" VoiC")); //Voice Clips
+ }
+ else _tcscpy(szdbsetting, _T("Miranda"));
+ }
+ else {
+ if ( !DBGetContactSettingTString(hcontact, ci.szProto, "MirVer", &dbv)) {
+ _tcscpy(szdbsetting, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else goto LBL_noData;
+ }
+ charPtr = szdbsetting;
+ goto LBL_charPtr;
+
+ case 't':
+ charPtr = _T("\t");
+ goto LBL_charPtr;
+
+ default:
+ _tcsncpy(szdbsetting, p-1, 2);
+ goto LBL_charPtr;
}
}
+ *d = 0;
return sztemp;
}
-
-
void _DBWriteTime(SYSTEMTIME *st,HANDLE hcontact)
{
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Day",st->wDay);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Month",st->wMonth);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Year",st->wYear);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Hours",st->wHour);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond);
- DBWriteContactSettingWord((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek);
+ db_set_w((HANDLE)hcontact,S_MOD,"Day",st->wDay);
+ db_set_w((HANDLE)hcontact,S_MOD,"Month",st->wMonth);
+ db_set_w((HANDLE)hcontact,S_MOD,"Year",st->wYear);
+ db_set_w((HANDLE)hcontact,S_MOD,"Hours",st->wHour);
+ db_set_w((HANDLE)hcontact,S_MOD,"Minutes",st->wMinute);
+ db_set_w((HANDLE)hcontact,S_MOD,"Seconds",st->wSecond);
+ db_set_w((HANDLE)hcontact,S_MOD,"WeekDay",st->wDayOfWeek);
}
@@ -512,45 +501,57 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
return DefWindowProc(hwnd, message, wParam, lParam);
};
-void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus){
- if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return;
- if (ServiceExists(MS_POPUP_QUERY)) {
- if (DBGetContactSettingByte(NULL,S_MOD,"UsePopups",0)) {
- if (!DBGetContactSettingByte(hcontact,"CList","Hidden",0)) {
- POPUPDATAEX ppd = {0};
- DBVARIANT dbv = {0};
- char szstamp[10];
- DWORD sett;
- sprintf(szstamp, "Col_%d",newStatus-ID_STATUS_OFFLINE);
- sett = DBGetContactSettingDword(NULL,S_MOD,szstamp,StatusColors15bits[newStatus-ID_STATUS_OFFLINE]);
- GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett);
- ppd.lchContact = hcontact;
- ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus);
- strncpy(ppd.lpzContactName,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStamp",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMP,hcontact,0),MAX_CONTACTNAME);
- DBFreeVariant(&dbv);
- strncpy(ppd.lpzText,ParseString(!DBGetContactSetting(NULL,S_MOD,"PopupStampText",&dbv)?dbv.pszVal:DEFAULT_POPUPSTAMPTEXT,hcontact,0),MAX_SECONDLINE);
- DBFreeVariant(&dbv);
- ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
- CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0);
- }
- }
+void ShowPopup(HANDLE hcontact, const char * lpzProto, int newStatus)
+{
+ if ( CallService(MS_IGNORE_ISIGNORED, (WPARAM)hcontact, IGNOREEVENT_USERONLINE))
+ return;
+
+ if ( !ServiceExists(MS_POPUP_QUERY))
+ return;
+
+ if ( !db_get_b(NULL, S_MOD, "UsePopups", 0) || !db_get_b(hcontact, "CList", "Hidden", 0))
+ return;
+
+ DBVARIANT dbv;
+ char szSetting[10];
+ sprintf(szSetting, "Col_%d",newStatus-ID_STATUS_OFFLINE);
+ DWORD sett = db_get_dw(NULL, S_MOD, szSetting, StatusColors15bits[newStatus-ID_STATUS_OFFLINE]);
+
+ POPUPDATAT ppd = {0};
+ GetColorsFromDWord(&ppd.colorBack,&ppd.colorText,sett);
+
+ ppd.lchContact = hcontact;
+ ppd.lchIcon = LoadSkinnedProtoIcon(lpzProto, newStatus);
+
+ if ( !DBGetContactSettingTString(NULL, S_MOD, "PopupStamp", &dbv)) {
+ _tcsncpy(ppd.lptzContactName, ParseString(dbv.ptszVal, hcontact, 0), MAX_CONTACTNAME);
+ db_free(&dbv);
+ }
+ else _tcsncpy(ppd.lptzContactName, ParseString(DEFAULT_POPUPSTAMP, hcontact, 0), MAX_CONTACTNAME);
+
+ if ( !DBGetContactSettingTString(NULL, S_MOD, "PopupStampText", &dbv)) {
+ _tcsncpy(ppd.lptzText, ParseString(dbv.ptszVal, hcontact, 0), MAX_SECONDLINE);
+ db_free(&dbv);
}
+ else _tcsncpy(ppd.lptzText, ParseString(DEFAULT_POPUPSTAMPTEXT, hcontact, 0), MAX_SECONDLINE);
+ ppd.PluginWindowProc = (WNDPROC)PopupDlgProc;
+ CallService(MS_POPUP_ADDPOPUPEX, (WPARAM)&ppd, 0);
}
void myPlaySound(HANDLE hcontact, WORD newStatus, WORD oldStatus){
- if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return;
+ if (CallService(MS_IGNORE_ISIGNORED,(WPARAM)hcontact,IGNOREEVENT_USERONLINE)) return;
//oldStatus and hcontact are not used yet
- if (DBGetContactSettingByte(NULL,"Skin","UseSound",1)) {
+ if ( db_get_b(NULL,"Skin","UseSound",1)) {
char * soundname=0;
if ((newStatus==ID_STATUS_ONLINE) || (newStatus==ID_STATUS_FREECHAT)) soundname = "LastSeenTrackedStatusOnline";
else if (newStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusOffline";
else if (oldStatus==ID_STATUS_OFFLINE) soundname = "LastSeenTrackedStatusFromOffline";
else soundname = "LastSeenTrackedStatusChange";
- if (!DBGetContactSettingByte(NULL,"SkinSoundsOff",soundname,0)) {
+ if (!db_get_b(NULL,"SkinSoundsOff",soundname,0)) {
DBVARIANT dbv;
- if (!DBGetContactSetting(NULL,"SkinSounds",soundname,&dbv)) {
- PlaySoundA(dbv.pszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
- DBFreeVariant(&dbv);
+ if ( !DBGetContactSettingTString(NULL, "SkinSounds", soundname, &dbv)) {
+ PlaySound(dbv.ptszVal, NULL, SND_ASYNC | SND_FILENAME | SND_NOWAIT);
+ db_free(&dbv);
} } } }
//will give hContact position or zero
@@ -596,18 +597,18 @@ int addContactToQueue(HANDLE hContact){
static DWORD __stdcall waitThread(logthread_info* infoParam)
{
- WORD prevStatus = DBGetContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
+ WORD prevStatus = db_get_w(infoParam->hContact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
Sleep(1500); // I hope in 1.5 second all the needed info will be set
if (includeIdle)
- if (DBGetContactSettingDword(infoParam->hContact,infoParam->sProtoName,"IdleTS",0))
+ if (db_get_dw(infoParam->hContact,infoParam->sProtoName,"IdleTS",0))
infoParam->courStatus &=0x7FFF;
if (infoParam->courStatus != prevStatus){
- DBWriteContactSettingWord(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000));
+ db_set_w(infoParam->hContact,S_MOD,"OldStatus",(WORD)(prevStatus|0x8000));
if (includeIdle)
- DBWriteContactSettingByte(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0));
+ db_set_b(infoParam->hContact,S_MOD,"OldIdle",(BYTE)((prevStatus&0x8000)==0));
- DBWriteContactSettingWord(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus);
+ db_set_w(infoParam->hContact,S_MOD,"StatusTriger",infoParam->courStatus);
}
contactQueue[infoParam->queueIndex] = 0;
@@ -624,14 +625,14 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
// to make this code faster
if (!wparam) return 0;
cws=(DBCONTACTWRITESETTING *)lparam;
- //if(CallService(MS_IGNORE_ISIGNORED,(WPARAM)hContact,IGNOREEVENT_USERONLINE)) return 0;
+ //if (CallService(MS_IGNORE_ISIGNORED,(WPARAM)hContact,IGNOREEVENT_USERONLINE)) return 0;
isIdleEvent = includeIdle?(strcmp(cws->szSetting,"IdleTS")==0):0;
if (strcmp(cws->szSetting,"Status") && strcmp(cws->szSetting,"StatusTriger") && (isIdleEvent==0)) return 0;
if (!strcmp(cws->szModule,S_MOD)) {
//here we will come when Settings/SeenModule/StatusTriger is changed
- WORD prevStatus=DBGetContactSettingWord((HANDLE)wparam, S_MOD, "OldStatus", ID_STATUS_OFFLINE);
+ WORD prevStatus=db_get_w((HANDLE)wparam, S_MOD, "OldStatus", ID_STATUS_OFFLINE);
if (includeIdle){
- if (DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF;
+ if ( db_get_b((HANDLE)wparam, S_MOD, "OldIdle", 0)) prevStatus &= 0x7FFF;
else prevStatus |= 0x8000;
}
if ((cws->value.wVal|0x8000)<=ID_STATUS_OFFLINE)
@@ -641,21 +642,21 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
if ((prevStatus|0x8000)<=ID_STATUS_OFFLINE)
return 0;
proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0);
- DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 1);
+ db_set_b((HANDLE)wparam, S_MOD, "Offline", 1);
{
DWORD t;
char *str = (char *)malloc(MAXMODULELABELLENGTH+9);
mir_snprintf(str,MAXMODULELABELLENGTH+8,"OffTime-%s",proto);
- t = DBGetContactSettingDword(NULL,S_MOD,str,0);
+ t = db_get_dw(NULL,S_MOD,str,0);
if (!t) t = time(NULL);
free(str);
DBWriteTimeTS(t, (HANDLE)wparam);
}
- if (!DBGetContactSettingByte(NULL,S_MOD,"IgnoreOffline",1))
+ if (!db_get_b(NULL,S_MOD,"IgnoreOffline",1))
{
char * sProto;
- if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0))
+ if ( db_get_b(NULL,S_MOD,"FileOutput",0))
FileWrite((HANDLE)wparam);
if (CallProtoService(sProto =
@@ -663,34 +664,34 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
PS_GETSTATUS,0,0
)>ID_STATUS_OFFLINE) {
myPlaySound((HANDLE)wparam, ID_STATUS_OFFLINE, prevStatus);
- if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0)) {
+ if ( db_get_b(NULL, S_MOD, "UsePopups", 0)) {
ShowPopup((HANDLE)wparam, sProto, ID_STATUS_OFFLINE);
} }
- if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0))
+ if ( db_get_b(NULL, S_MOD, "KeepHistory", 0))
HistoryWrite((HANDLE)wparam);
- if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0))
+ if ( db_get_b((HANDLE)wparam, S_MOD, "OnlineAlert", 0))
ShowHistory((HANDLE)wparam, 1);
}
} else {
- if(cws->value.wVal==prevStatus && !DBGetContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0))
+ if (cws->value.wVal==prevStatus && !db_get_b((HANDLE)wparam, S_MOD, "Offline", 0))
return 0;
DBWriteTimeTS(time(NULL), (HANDLE)wparam);
- //DBWriteContactSettingWord(hContact,S_MOD,"StatusTriger",(WORD)cws->value.wVal);
+ //db_set_w(hContact,S_MOD,"StatusTriger",(WORD)cws->value.wVal);
- if(DBGetContactSettingByte(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam);
+ if ( db_get_b(NULL, S_MOD, "FileOutput", 0)) FileWrite((HANDLE)wparam);
if (prevStatus != cws->value.wVal) myPlaySound((HANDLE)wparam, cws->value.wVal, prevStatus);
- if(DBGetContactSettingByte(NULL, S_MOD, "UsePopups", 0))
+ if ( db_get_b(NULL, S_MOD, "UsePopups", 0))
if (prevStatus != cws->value.wVal) ShowPopup((HANDLE)wparam, (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, wparam, 0), cws->value.wVal|0x8000);
- if(DBGetContactSettingByte(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam);
- if(DBGetContactSettingByte((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1);
- DBWriteContactSettingByte((HANDLE)wparam, S_MOD, "Offline", 0);
+ if ( db_get_b(NULL, S_MOD, "KeepHistory", 0)) HistoryWrite((HANDLE)wparam);
+ if ( db_get_b((HANDLE)wparam, S_MOD, "OnlineAlert", 0)) ShowHistory((HANDLE)wparam, 1);
+ db_set_b((HANDLE)wparam, S_MOD, "Offline", 0);
}
} else if (IsWatchedProtocol(cws->szModule)) {
//here we will come when <User>/<module>/Status is changed or it is idle event and if <module> is watched
@@ -703,7 +704,7 @@ int UpdateValues(WPARAM wparam,LPARAM lparam)
unsigned int dwThreadId;
mir_forkthreadex((pThreadFuncEx)waitThread, contactQueue[index], &dwThreadId);
}
- contactQueue[index]->courStatus = isIdleEvent ? DBGetContactSettingWord((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal;
+ contactQueue[index]->courStatus = isIdleEvent ? db_get_w((HANDLE)wparam, cws->szModule, "Status", ID_STATUS_OFFLINE) : cws->value.wVal;
} }
return 0;
@@ -718,12 +719,12 @@ static DWORD __stdcall cleanThread(logthread_info* infoParam)
char *contactProto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO,(WPARAM)hcontact,0);
if (contactProto) {
if ( !strncmp(infoParam->sProtoName, contactProto, MAXMODULELABELLENGTH)) {
- WORD oldStatus = DBGetContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000;
+ WORD oldStatus = db_get_w(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE) | 0x8000;
if (oldStatus > ID_STATUS_OFFLINE) {
- if (DBGetContactSettingWord(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
- DBWriteContactSettingWord(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000));
- if (includeIdle)DBWriteContactSettingByte(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1));
- DBWriteContactSettingWord(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
+ if (db_get_w(hcontact,contactProto,"Status",ID_STATUS_OFFLINE)==ID_STATUS_OFFLINE){
+ db_set_w(hcontact,S_MOD,"OldStatus",(WORD)(oldStatus|0x8000));
+ if (includeIdle)db_set_b(hcontact,S_MOD,"OldIdle",(BYTE)((oldStatus&0x8000)?0:1));
+ db_set_w(hcontact,S_MOD,"StatusTriger",ID_STATUS_OFFLINE);
}
}
}
@@ -748,7 +749,7 @@ int ModeChange(WPARAM wparam,LPARAM lparam)
ack=(ACKDATA *)lparam;
- if(ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0;
+ if (ack->type!=ACKTYPE_STATUS || ack->result!=ACKRESULT_SUCCESS || ack->hContact!=NULL) return 0;
courProtoName = (char *)ack->szModule;
if (!IsWatchedProtocol(courProtoName) && strncmp(courProtoName,"MetaContacts",12))
{
@@ -784,14 +785,14 @@ int ModeChange(WPARAM wparam,LPARAM lparam)
DBWriteContactSettingDword(NULL,S_MOD,str,t);
free(str);
} }
- if (isetting==DBGetContactSettingWord(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0;
- DBWriteContactSettingWord(NULL,S_MOD,courProtoName,isetting);
+ if (isetting==db_get_w(NULL,S_MOD,courProtoName,ID_STATUS_OFFLINE)) return 0;
+ db_set_w(NULL,S_MOD,courProtoName,isetting);
// log "myself"
- if(DBGetContactSettingByte(NULL,S_MOD,"FileOutput",0))
+ if ( db_get_b(NULL,S_MOD,"FileOutput",0))
FileWrite(NULL);
-// if(isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline
+// if (isetting==ID_STATUS_OFFLINE) //this is removed 'cause I want other contacts to be logged only if the status changed while I was offline
// SetOffline();
courProtoName = NULL;
@@ -799,9 +800,10 @@ int ModeChange(WPARAM wparam,LPARAM lparam)
return 0;
}
-short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name){
+short int isDbZero(HANDLE hContact, const char *module_name, const char *setting_name)
+{
DBVARIANT dbv;
- if (!DBGetContactSetting(hContact, module_name, setting_name, &dbv)) {
+ if ( !DBGetContactSetting(hContact, module_name, setting_name, &dbv)) {
short int res = 0;
switch (dbv.type) {
case DBVT_BYTE: res=dbv.bVal==0; break;
@@ -810,9 +812,10 @@ short int isDbZero(HANDLE hContact, const char *module_name, const char *setting
case DBVT_BLOB: res=dbv.cpbVal==0; break;
default: res=dbv.pszVal[0]==0; break;
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
return res;
- } else return -1;
+ }
+ return -1;
}
WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) {
@@ -827,7 +830,7 @@ WCHAR *any_to_IdleNotidleUnknown(HANDLE hContact, const char *module_name, const
}
WCHAR *any_to_Idle(HANDLE hContact, const char *module_name, const char *setting_name, WCHAR *buff, int bufflen) {
- if(isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists
+ if (isDbZero(hContact, module_name, setting_name)==0) { //DB setting is NOT zero and exists
buff[0] = L'/';
wcsncpy((WCHAR *)&buff[1], TranslateW(L"Idle"), bufflen-1);
} else buff[0] = 0;