diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-07 19:47:13 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-07 19:47:13 +0000 |
commit | 097c52ad9a2928422084bf76cebee58958341574 (patch) | |
tree | 26d6b11e9738fc4e854f68c0ff04eaadf7d849e8 /plugins/Sessions | |
parent | f096b29abb03618ec609ba4acaedaed43eec1fea (diff) |
end of the old database macroses
git-svn-id: http://svn.miranda-ng.org/main/trunk@4373 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Sessions')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 132 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 36 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 83 |
3 files changed, 114 insertions, 137 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 7f2b2f4dbd..8058d452d7 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -175,7 +175,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar GetWindowRect(hdlg, &rWnd);
x=rWnd.right-rWnd.left;
y=rWnd.bottom-rWnd.top;
- if(IsDlgButtonChecked(hdlg,IDC_SELCONTACTS))
+ if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS))
{
EnableWindow(GetDlgItem(hdlg,IDC_SANDCCHECK),FALSE);
dy=20;
@@ -228,7 +228,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar {
GetWindowText(GetDlgItem(hdlg, IDC_LIST), szUserSessionName, SIZEOF(szUserSessionName));
szUserSessionName[lenght+1]='\0';
- if(IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC)
+ if (IsDlgButtonChecked(hdlg,IDC_SELCONTACTS)&&bSC)
{
HANDLE hContact = db_find_first();
for (i=0; hContact; hContact = db_find_next(hContact))
@@ -252,7 +252,7 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar {
SaveSessionHandles(0,1);
- if(IsDlgButtonChecked(hdlg,IDC_SANDCCHECK))
+ if (IsDlgButtonChecked(hdlg,IDC_SANDCCHECK))
CloseCurrentSession(0,0);
DestroyWindow(hdlg);
g_hSDlg=0;
@@ -287,7 +287,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar case WM_INITDIALOG:
{
int iDelay=db_get_w(NULL, MODNAME, "StartupModeDelay", 1500);
- if(g_hghostw==TRUE)
+ if (g_hghostw==TRUE)
SetTimer(hdlg, TIMERID_LOAD, iDelay, NULL);
else
{
@@ -296,15 +296,15 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);
- if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
+ if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
ses_count=0;
- if(session_list_recovered[0])
+ if (session_list_recovered[0])
ses_count=256;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
LoadPosition(hdlg, "LoadDlg");
- if(StartUp)
+ if (StartUp)
SetTimer(hdlg, TIMERID_SHOW, iDelay, NULL);
else
ShowWindow(g_hDlg,SW_SHOW);
@@ -312,7 +312,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar }break;
case WM_TIMER:
- if(wparam == TIMERID_SHOW)
+ if (wparam == TIMERID_SHOW)
{
KillTimer(hdlg, TIMERID_SHOW);
ShowWindow(hdlg,SW_SHOW);
@@ -345,7 +345,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar {
HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
- if(index != CB_ERR)
+ if (index != CB_ERR)
ses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
}break;
}break;
@@ -353,7 +353,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar case IDC_SESSDEL:
{
- if(session_list_recovered[0]&&ses_count==256)
+ if (session_list_recovered[0]&&ses_count==256)
{
int i=0;
while(session_list_recovered[i])
@@ -370,7 +370,7 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar if ((ses_count=LoadSessionToCombobox(hdlg,1,ses_limit,"SessionDate",0))==ses_limit)
EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);
- if(LoadSessionToCombobox(hdlg,1,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
+ if (LoadSessionToCombobox(hdlg,1,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
ses_count=0;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
@@ -386,10 +386,10 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);
- if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
+ if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
ses_count=0;
- if(session_list_recovered[0]) ses_count=256;
+ if (session_list_recovered[0]) ses_count=256;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
}
@@ -401,10 +401,10 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),TRUE);
- if(LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
+ if (LoadSessionToCombobox(hdlg,0,255,"UserSessionDsc",ses_limit)==0 && ses_count!=0)
ses_count=0;
- if(session_list_recovered[0]) ses_count=256;
+ if (session_list_recovered[0]) ses_count=256;
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
}
@@ -473,7 +473,7 @@ int SaveSessionHandles(WPARAM wparam,LPARAM lparam) {
int k=0;
- if(session_list[0]!=0)
+ if (session_list[0]!=0)
{
for (HANDLE hContact = db_find_first(); hContact;
hContact = db_find_next(hContact))
@@ -490,7 +490,7 @@ int SaveSessionHandles(WPARAM wparam,LPARAM lparam) AddInSessionOrder((HANDLE)hContact,lparam,0,0);
}
}
- if(lparam==1)
+ if (lparam==1)
{
g_ses_count++;
db_set_b(0, MODNAME, "UserSessionsCount", (BYTE)g_ses_count);
@@ -503,27 +503,27 @@ int SaveSessionHandles(WPARAM wparam,LPARAM lparam) INT_PTR SaveUserSessionHandles(WPARAM wparam,LPARAM lparam)
{
- if (g_hSDlg)
- {
+ if (g_hSDlg) {
ShowWindow(g_hSDlg,SW_SHOW);
return 1;
}
- else
- g_hSDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SAVEDIALOG), 0, SaveSessionDlgProc);
+ g_hSDlg = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_SAVEDIALOG), 0, SaveSessionDlgProc);
return 0;
}
INT_PTR OpenSessionsManagerWindow(WPARAM wparam,LPARAM lparam)
{
- if (g_hDlg)
- {
+ if (g_hDlg) {
ShowWindow(g_hDlg,SW_SHOW);
return 0;
}
- if(g_bIncompletedSave||DBGetStringT(NULL, MODNAME, "SessionDate_0")||DBGetStringT(NULL, MODNAME, "UserSessionDsc_0"))
- {
- g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
+
+ mir_ptr<TCHAR>
+ tszSession(db_get_tsa(NULL, MODNAME, "SessionDate_0")),
+ tszUserSession(db_get_tsa(NULL, MODNAME, "UserSessionDsc_0"));
+ if (g_bIncompletedSave || tszSession || tszUserSession) {
+ g_hDlg = CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
return 0;
}
if (g_bOtherWarnings)
@@ -533,7 +533,7 @@ INT_PTR OpenSessionsManagerWindow(WPARAM wparam,LPARAM lparam) int SaveSessionDate()
{
- if(session_list[0]!=0)
+ if (session_list[0]!=0)
{
int TimeSize = GetTimeFormat(LOCALE_USER_DEFAULT, 0/*TIME_NOSECONDS*/, NULL, NULL, NULL, 0);
TCHAR *szTimeBuf = (TCHAR*)mir_alloc((TimeSize+1)*sizeof(TCHAR));
@@ -559,12 +559,12 @@ int SaveSessionDate() mir_free(szSessionTime);
ResaveSettings("SessionDate", 1, ses_limit, szSessionDateBuf_1);
- if(szTimeBuf)
+ if (szTimeBuf)
mir_free(szTimeBuf);
- if(szDateBuf)
+ if (szDateBuf)
mir_free(szDateBuf);
}
- if(g_bCrashRecovery)
+ if (g_bCrashRecovery)
db_set_b(NULL, MODNAME, "lastSaveCompleted", 1);
return 0;
}
@@ -578,7 +578,7 @@ int SaveUserSessionName(TCHAR *szUSessionName) TCHAR *szUserSessionName=NULL;
TCHAR *ptr=NULL;
- if(session_list[0]!=0)
+ if (session_list[0]!=0)
{
szUserSessionName = mir_tstrdup(szUSessionName);
mir_snprintf(szUserSessionNameBuf, SIZEOF(szUserSessionNameBuf), "%s_%u", "UserSessionDsc", 0);
@@ -602,7 +602,7 @@ int SaveUserSessionName(TCHAR *szUSessionName) INT_PTR LoadLastSession(WPARAM wparam,LPARAM lparam)
{
int ret=0;
- if(isLastTRUE)
+ if (isLastTRUE)
ret=LoadSession(wparam,lparam);
else if (g_bOtherWarnings)
MessageBox(NULL, TranslateT("Last Sessions is empty"), TranslateT("Sessions Manager"), MB_OK);
@@ -622,13 +622,13 @@ int LoadSession(WPARAM wparam,LPARAM lparam) mode=1;
lparam-=ses_limit;
}
- if(session_list_recovered[0]&&lparam==256&&mode==0)
+ if (session_list_recovered[0]&&lparam==256&&mode==0)
memcpy(session_list_t,session_list_recovered,SIZEOF(session_list_t));
else
for (hContact = db_find_first(); hContact;
hContact = db_find_next(hContact))
{
- if(LoadContactsFromMask(hContact,mode,lparam))
+ if (LoadContactsFromMask(hContact,mode,lparam))
{
i=GetInSessionOrder(hContact,mode, lparam);
session_list_t[i]=(DWORD)hContact;
@@ -640,7 +640,7 @@ int LoadSession(WPARAM wparam,LPARAM lparam) {
if (CheckForDuplicate(session_list,session_list_t[i])==-1)
CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[i], 0);
- else if(g_bWarnOnHidden)
+ else if (g_bWarnOnHidden)
{
if (!CheckContactVisibility((HANDLE)session_list_t[i]))
{
@@ -652,17 +652,17 @@ int LoadSession(WPARAM wparam,LPARAM lparam) i++;
}
- if(i==0)
+ if (i==0)
{
- if(g_bOtherWarnings)
+ if (g_bOtherWarnings)
MessageBox(NULL, TranslateT("No contacts to open"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING);
return 1;
}
- else if(dup==i)
+ else if (dup==i)
{
if (!hidden)
{
- if(g_bOtherWarnings)
+ if (g_bOtherWarnings)
MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING);
return 1;
}
@@ -671,9 +671,9 @@ int LoadSession(WPARAM wparam,LPARAM lparam) MessageBox(NULL, TranslateT("This Session already opened"), TranslateT("Sessions Manager"), MB_OK|MB_ICONWARNING);
return 1;
}
- else if(g_bWarnOnHidden)
+ else if (g_bWarnOnHidden)
{
- if(MessageBox(NULL, TranslateT("This Session already opened(but probably hidden)\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO|MB_ICONQUESTION)==IDYES)
+ if (MessageBox(NULL, TranslateT("This Session already opened(but probably hidden)\nDo you want to show hidden contacts?"), TranslateT("Sessions Manager"), MB_YESNO|MB_ICONQUESTION)==IDYES)
{
j=0;
while(hidden[j]!=0)
@@ -695,9 +695,7 @@ int DelUserDefSession(int ses_count) char szSessionName[256]={0};
TCHAR *szSessionNameBuf=NULL;
- for (hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
RemoveSessionMark(hContact,1,ses_count);
SetInSessionOrder(hContact,1,ses_count,0);
}
@@ -708,18 +706,16 @@ int DelUserDefSession(int ses_count) mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "FavUserSession", ses_count);
db_unset(NULL, MODNAME, szSessionName);
- for (i=(ses_count+1);;i++)
- {
+ for (i=(ses_count+1);;i++) {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i);
- if ((szSessionNameBuf=DBGetStringT(NULL, MODNAME, szSessionName))/*&&(szSessionHandlesBuf=DBGetStringT(NULL,PLGNAME,szSessionHandles))*/)
- {
+ if (szSessionNameBuf = db_get_tsa(NULL, MODNAME, szSessionName)) {
MarkUserDefSession(i-1,IsMarkedUserDefSession(i));
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i-1);
db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf);
+ mir_free(szSessionNameBuf);
}
- else
- {
+ else {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "UserSessionDsc", i-1);
db_unset(NULL, MODNAME, szSessionName);
@@ -730,7 +726,6 @@ int DelUserDefSession(int ses_count) }
g_ses_count--;
db_set_b(0, MODNAME, "UserSessionsCount", (BYTE)g_ses_count);
- mir_free(szSessionNameBuf);
return 0;
}
@@ -752,24 +747,21 @@ int DeleteAutoSession(int ses_count) mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", ses_count);
db_unset(NULL, MODNAME, szSessionName);
- for (i=(ses_count+1);;i++)
- {
+ for (i=(ses_count+1);;i++) {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i);
- if ((szSessionNameBuf=DBGetStringT(NULL, MODNAME, szSessionName))/*&&(szSessionHandlesBuf=DBGetStringT(NULL,PLGNAME,szSessionHandles))*/)
- {
+ if (szSessionNameBuf = db_get_tsa(NULL, MODNAME, szSessionName)) {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1);
db_set_ts(NULL, MODNAME, szSessionName, szSessionNameBuf);
-
+ mir_free(szSessionNameBuf);
}
- else
- {
+ else {
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "SessionDate", i-1);
db_unset(NULL, MODNAME, szSessionName);
break;
}
}
- mir_free(szSessionNameBuf);
+
return 0;
}
@@ -785,7 +777,7 @@ int SessionPreShutdown(WPARAM wparam,LPARAM lparam) if (g_hDlg) DestroyWindow(g_hDlg);
if (g_hSDlg) DestroyWindow(g_hSDlg);
- if(g_bIncompletedSave) {
+ if (g_bIncompletedSave) {
int i=0;
while(session_list_recovered[i]) {
db_set_b((HANDLE)session_list_recovered[i], MODNAME, "wasInLastSession", 0);
@@ -801,13 +793,13 @@ int OkToExit(WPARAM wparam,LPARAM lparam) {
int exitmode=db_get_b(NULL, MODNAME, "ShutdownMode", 2);
DONT=1;
- if(exitmode==2&&session_list[0]!=0)
+ if (exitmode==2&&session_list[0]!=0)
{
SaveSessionDate();
SaveSessionHandles(0,0);
db_set_b(NULL, MODNAME, "lastempty", 0);
}
- else if(exitmode==1&&session_list[0]!=0)
+ else if (exitmode==1&&session_list[0]!=0)
{
DialogBox(hinstance,MAKEINTRESOURCE(IDD_EXDIALOG), 0, ExitDlgProc);
}
@@ -819,16 +811,16 @@ static int GetContactHandle(WPARAM wparam,LPARAM lParam) {
MessageWindowEventData *MWeventdata = (MessageWindowEventData*)lParam;
- if(MWeventdata->uType == MSG_WINDOW_EVT_OPEN)
+ if (MWeventdata->uType == MSG_WINDOW_EVT_OPEN)
{
if (strstr(MWeventdata->szModule,"tabSRMsg")) g_mode=1;
AddToCurSession((DWORD)MWeventdata->hContact,0);
- if(g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 1);
+ if (g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 1);
}
- else if(MWeventdata->uType == MSG_WINDOW_EVT_CLOSE)
+ else if (MWeventdata->uType == MSG_WINDOW_EVT_CLOSE)
{
if (!DONT) DelFromCurSession((DWORD)MWeventdata->hContact,0);
- if(g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 0);
+ if (g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 0);
}
return 0;
@@ -843,7 +835,7 @@ INT_PTR BuildFavMenu(WPARAM wparam,LPARAM lparam) GetCursorPos(&pt);
FillFavoritesMenu(hMenu,g_ses_count);
res = TrackPopupMenu(hMenu, TPM_RETURNCMD|TPM_NONOTIFY, pt.x, pt.y, 0, GetActiveWindow(), NULL);
- if(res==0) return 1;
+ if (res==0) return 1;
LoadSession(0,(res-1)+ses_limit);
return 0;
}
@@ -898,10 +890,10 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1);
g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0);
- if(g_bCrashRecovery)
+ if (g_bCrashRecovery)
g_bIncompletedSave=!db_get_b(NULL, MODNAME, "lastSaveCompleted", 0);
- if(g_bIncompletedSave)
+ if (g_bIncompletedSave)
{
int i=0;
HANDLE hContact;
@@ -910,7 +902,7 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) for (hContact = db_find_first(); hContact;
hContact = db_find_next(hContact))
{
- if(db_get_b(hContact, MODNAME, "wasInLastSession", 0))
+ if (db_get_b(hContact, MODNAME, "wasInLastSession", 0))
session_list_recovered[i++]=(DWORD)hContact;
}
}
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index 86a435c595..e8860f6f6f 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -51,7 +51,7 @@ int OpLoadSessionContacts(WPARAM wparam,LPARAM lparam) for (hContact = db_find_first(); hContact;
hContact = db_find_next(hContact))
{
- if(LoadContactsFromMask(hContact,1,lparam))
+ if (LoadContactsFromMask(hContact,1,lparam))
{
i=GetInSessionOrder(hContact,1, lparam);
session_list_t[i]=(DWORD)hContact;
@@ -96,7 +96,7 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, }break;
case WM_LBUTTONDOWN:
- if(hOpClistControl)
+ if (hOpClistControl)
break;
HideCaret(hwnd);
@@ -125,7 +125,7 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, break;
case WM_MOUSEMOVE:
- if(hOpClistControl)
+ if (hOpClistControl)
break;
case WM_NCMOUSEMOVE:
@@ -152,7 +152,7 @@ static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, case WM_NCHITTEST:
{
LRESULT lr = mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam );
- if(lr==HTNOWHERE )
+ if (lr==HTNOWHERE )
lr = HTOBJECT;
return lr;
}
@@ -198,7 +198,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) CheckDlgButton(hdlg,IDC_CRASHRECOVERY,g_bCrashRecovery?BST_CHECKED:BST_UNCHECKED);
- if(startupmode==1)
+ if (startupmode==1)
CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
else if (startupmode==3)
{
@@ -218,7 +218,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) EnableWindow(GetDlgItem(hdlg, IDC_STATICMS), FALSE);
EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
}
- if(exitmode==0)
+ if (exitmode==0)
{
CheckDlgButton(hdlg,IDC_REXDSAVE,BST_CHECKED);
EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC1),FALSE);
@@ -230,7 +230,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) else if (exitmode==2) CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED);
LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
- if(SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0))
+ if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0))
{
EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
@@ -265,18 +265,18 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) db_set_w(0, MODNAME, "StartupModeDelay", (WORD)iDelay);
db_set_b(0, MODNAME, "TrackCount", (BYTE)(ses_limit=GetDlgItemInt(hdlg, IDC_TRACK,NULL, FALSE)));
- if(IsDlgButtonChecked(hdlg, IDC_REXSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 2);
- else if(IsDlgButtonChecked(hdlg, IDC_REXDSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 0);
- else if(IsDlgButtonChecked(hdlg, IDC_REXASK)) db_set_b(NULL, MODNAME, "ShutdownMode", 1);
+ if (IsDlgButtonChecked(hdlg, IDC_REXSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXDSAVE)) db_set_b(NULL, MODNAME, "ShutdownMode", 0);
+ else if (IsDlgButtonChecked(hdlg, IDC_REXASK)) db_set_b(NULL, MODNAME, "ShutdownMode", 1);
- if(IsDlgButtonChecked(hdlg, IDC_STARTDIALOG))
+ if (IsDlgButtonChecked(hdlg, IDC_STARTDIALOG))
{
if (!IsDlgButtonChecked(hdlg, IDC_CHECKLAST))
db_set_b(NULL, MODNAME, "StartupMode", 1);
else db_set_b(NULL, MODNAME, "StartupMode", 3);
}
- else if(IsDlgButtonChecked(hdlg, IDC_RLOADLAST)) db_set_b(NULL, MODNAME, "StartupMode", 2);
- else if(IsDlgButtonChecked(hdlg, IDC_RNOTHING)) db_set_b(NULL, MODNAME, "StartupMode", 0);
+ else if (IsDlgButtonChecked(hdlg, IDC_RLOADLAST)) db_set_b(NULL, MODNAME, "StartupMode", 2);
+ else if (IsDlgButtonChecked(hdlg, IDC_RNOTHING)) db_set_b(NULL, MODNAME, "StartupMode", 0);
db_set_b(NULL, MODNAME, "ExclHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_EXCLHIDDEN) ? (g_bExclHidden = 1) : (g_bExclHidden = 0)));
db_set_b(NULL, MODNAME, "WarnOnHidden", (BYTE)(IsDlgButtonChecked(hdlg, IDC_LASTHIDDENWARN) ? (g_bWarnOnHidden = 1) : (g_bWarnOnHidden = 0)));
@@ -315,10 +315,10 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) {
HWND hCombo = GetDlgItem(hdlg, IDC_LIST);
int index = SendMessage(hCombo, CB_GETCURSEL, 0, 0);
- if(index != CB_ERR) {
+ if (index != CB_ERR) {
opses_count = SendMessage(hCombo, CB_GETITEMDATA, (WPARAM)index, 0);
SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- if(IsMarkedUserDefSession(opses_count)) {
+ if (IsMarkedUserDefSession(opses_count)) {
hIcon=hMarked;
bChecked=TRUE;
RedrawWindow(hComboBoxEdit, NULL, NULL, RDW_INVALIDATE|RDW_NOCHILDREN|RDW_UPDATENOW|RDW_FRAME);
@@ -406,8 +406,8 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) SetInSessionOrder(hContact,1,opses_count,0);
}
}
- if(bSesssionNameChanged) {
- if(GetWindowTextLength(hComboBoxEdit)) {
+ if (bSesssionNameChanged) {
+ if (GetWindowTextLength(hComboBoxEdit)) {
TCHAR szUserSessionName[MAX_PATH]={'\0'};
GetWindowText(hComboBoxEdit, szUserSessionName, SIZEOF(szUserSessionName));
RenameUserDefSession(opses_count,szUserSessionName);
@@ -431,7 +431,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) opses_count=0;
- if(SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
+ if (SendDlgItemMessage(hdlg, IDC_LIST, CB_GETCOUNT, 0, 0)) {
EnableWindow(GetDlgItem(hdlg,IDC_EDIT),TRUE);
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETCURSEL, 0, 0);
if (!OpLoadSessionContacts(0,opses_count))
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;
}
|