summaryrefslogtreecommitdiff
path: root/plugins/Sessions/Src/Utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/Sessions/Src/Utils.cpp')
-rw-r--r--plugins/Sessions/Src/Utils.cpp83
1 files changed, 34 insertions, 49 deletions
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp
index bab43d06d3..d2f5c58c12 100644
--- a/plugins/Sessions/Src/Utils.cpp
+++ b/plugins/Sessions/Src/Utils.cpp
@@ -26,7 +26,7 @@ void AddSessionMark(HANDLE hContact,int mode,char bit)
char temp_1[1]={'\0'},temp_2[1]={'\0'};
char szDst[256]={'\0'};
char* pszBuffer=NULL;
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
@@ -44,7 +44,7 @@ void AddSessionMark(HANDLE hContact,int mode,char bit)
db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
- else if(bit=='1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
+ else if (bit=='1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
}
if (mode==1)
@@ -52,7 +52,7 @@ void AddSessionMark(HANDLE hContact,int mode,char bit)
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal)
{
- if(strlen(dbv.pszVal)<g_ses_count)
+ if (strlen(dbv.pszVal)<g_ses_count)
{
pszBuffer = (char*)mir_alloc(g_ses_count+1);
ZeroMemory(pszBuffer,g_ses_count+1);
@@ -75,7 +75,7 @@ void AddSessionMark(HANDLE hContact,int mode,char bit)
mir_free(pszBuffer);
}
- else if(bit=='1')db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
+ else if (bit=='1')db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
else db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000");
}
}
@@ -85,7 +85,7 @@ void RemoveSessionMark(HANDLE hContact,int mode,int marknum)
unsigned int i=1;
char temp_1[1]={'\0'},temp_2[1]={'\0'};
char szDst[256]={'\0'};
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
@@ -118,7 +118,7 @@ void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum)
{
char* pszBuffer=NULL;
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
@@ -176,12 +176,12 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
char* pszBuffer=NULL;
char szFormNumBuf[255]={'\0'};
- if(ordernum<10)
+ if (ordernum<10)
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%u", 0, ordernum);
else
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u", ordernum);
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv))
@@ -196,7 +196,7 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
ZeroMemory(temp2,len-1);
temp = (char*)mir_alloc(len+1);
ZeroMemory(temp,len+1);
- if(ordernum<10)
+ if (ordernum<10)
{
strncpy( temp2, dbv.pszVal, len-2 );
temp2[len-2]='\0';
@@ -213,10 +213,10 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
mir_free(temp2);
db_free(&dbv);
}
- else if(writemode==1)
+ else if (writemode==1)
{
ZeroMemory(szFormNumBuf,SIZEOF(szFormNumBuf));
- if(ordernum<10)
+ if (ordernum<10)
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%u%s", 0, ordernum, "000000000000000000");
else
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%s", ordernum, "000000000000000000");
@@ -234,7 +234,7 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
char* temp=NULL;
char* temp2=NULL;
int len=0;
- if(strlen(dbv.pszVal)<(g_ses_count*2))
+ if (strlen(dbv.pszVal)<(g_ses_count*2))
{
pszBuffer = (char*)mir_alloc(g_ses_count*2+1);
ZeroMemory(pszBuffer,g_ses_count*2+1);
@@ -252,7 +252,7 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
temp = (char*)mir_alloc(advlen+1);
ZeroMemory(temp,advlen+1);
- if(ordernum<10)
+ if (ordernum<10)
mir_snprintf(temp, advlen+1, "%u%u%s", 0, ordernum, dbv.pszVal);
else
mir_snprintf(temp, advlen+1, "%u%s", ordernum, dbv.pszVal);
@@ -263,7 +263,7 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
mir_free(temp);
mir_free(pszBuffer);
}
- else if(writemode==1)
+ else if (writemode==1)
db_set_s(hContact, MODNAME, "UserSessionsOrder", szFormNumBuf);
else
db_set_s(hContact, MODNAME, "UserSessionsOrder", "00");
@@ -274,7 +274,7 @@ int GetInSessionOrder(HANDLE hContact,int mode,int count)
{
int iOrder=0;
char szTemp[3]={'\0'};
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal)
@@ -304,12 +304,12 @@ void SetInSessionOrder(HANDLE hContact,int mode,int count,unsigned int ordernum)
int iOrder=0;
char szTemp[3]={'\0'};
- if(ordernum<10)
+ if (ordernum<10)
mir_snprintf(szTemp, SIZEOF(szTemp), "%u%u", 0, ordernum);
else
mir_snprintf(szTemp, SIZEOF(szTemp), "%u", ordernum);
- if(mode==0)
+ if (mode==0)
{
DBVARIANT dbv;
if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal)
@@ -373,7 +373,7 @@ int AddToCurSession (DWORD wparam,LPARAM lparam)
{
for (i=0;;i++)
{
- if(session_list[i]==0)
+ if (session_list[i]==0)
{
session_list[i]=wparam;
break;
@@ -388,7 +388,7 @@ int DelFromCurSession(DWORD wparam,LPARAM lparam)
int i=0;
while(session_list[i]!=0)
{
- if(session_list[i]==wparam)
+ if (session_list[i]==wparam)
{
while(session_list[i+1]!=0)
{
@@ -419,66 +419,51 @@ int CheckForDuplicate(DWORD contact_list[],DWORD lparam)
int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum)
{
- int ses_count=iFirstNum,i, index;
+ int ses_count=iFirstNum, index;
char szBuffer[256]={0};
- TCHAR *pszBuffer=NULL;
- if(session_list_recovered[0]&&!iFirstNum&&!mode)
- {
+ if (session_list_recovered[0] && !iFirstNum && !mode) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)TranslateT("Session Before Last Crash"));
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, (LPARAM) 256);
}
- for(i=0;i < iLimit; i++)
- {
+ for(int i=0; i < iLimit; i++) {
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", pszSetting, i);
- pszBuffer = DBGetStringT(NULL, MODNAME, szBuffer);
- if (pszBuffer)
- {
- if (!IsMarkedUserDefSession(i+iFirstNum)||mode==1)
- {
+ TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer);
+ if (pszBuffer) {
+ if (!IsMarkedUserDefSession(i+iFirstNum)||mode==1) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)pszBuffer);
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, (LPARAM) (DWORD)i+iFirstNum);
}
- else
- {
+ else {
SendDlgItemMessage(hdlg, IDC_LIST, CB_INSERTSTRING, 0, (LPARAM)pszBuffer);
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, (LPARAM) (DWORD)i+iFirstNum);
}
mir_free(pszBuffer);
- pszBuffer=NULL;
}
- else
- {
+ else {
if (i==0) ses_count=iLimit-iFirstNum;
break;
}
}
- if(pszBuffer)mir_free(pszBuffer);
+
return ses_count;
}
int FillFavoritesMenu (HMENU hMenu,int iLimit)
{
- int i, iItems=0;
- char szBuffer[256]={0};
- TCHAR *pszBuffer=NULL;
+ int iItems=0;
- for(i=0;i < iLimit; i++)
- {
- if(IsMarkedUserDefSession(i))
- {
+ for(int i=0;i < iLimit; i++) {
+ if (IsMarkedUserDefSession(i)) {
+ char szBuffer[256];
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", "UserSessionDsc", i);
- pszBuffer = DBGetStringT(NULL, MODNAME, szBuffer);
- if ((pszBuffer = DBGetStringT(NULL, MODNAME, szBuffer)))
- {
+ TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer);
+ if (pszBuffer) {
AppendMenu(hMenu,MF_STRING,i+1,pszBuffer);
iItems++;
- //TODO: test this
mir_free(pszBuffer);
- pszBuffer=NULL;
}
}
}
- if(pszBuffer) mir_free(pszBuffer);
return iItems;
}