diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-07 21:56:20 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-07 21:56:20 +0000 |
commit | c874769aaa91b110d87eb7b8d267680eb2008bbf (patch) | |
tree | 9f6ce320043d84a2da32a4bb96c8558895e10581 /plugins | |
parent | 204e6f3fb56cd033bc02d19959a7994ad2002f4b (diff) |
Sessions: contacts are HANDLEs, not DWORDs
git-svn-id: http://svn.miranda-ng.org/main/trunk@4381 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/Sessions/Src/Main.cpp | 199 | ||||
-rw-r--r-- | plugins/Sessions/Src/Options.cpp | 286 | ||||
-rw-r--r-- | plugins/Sessions/Src/Sessions.h | 4 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 250 | ||||
-rw-r--r-- | plugins/Sessions/Src/Utils.h | 6 |
5 files changed, 318 insertions, 427 deletions
diff --git a/plugins/Sessions/Src/Main.cpp b/plugins/Sessions/Src/Main.cpp index 8058d452d7..f422608a58 100644 --- a/plugins/Sessions/Src/Main.cpp +++ b/plugins/Sessions/Src/Main.cpp @@ -23,7 +23,6 @@ HINSTANCE hinstance = NULL; WNDPROC mainProc;
-HANDLE hServiceOpenManager, hServiceShowFavMenu, hServiceCloseCurrentSession, hServiceSaveUserSession, hServiceLoadLastSession;
HGENMENU hmSaveCurrentSession, hmLoadLastSession, hmLoadSession, hmSessionsManager;
HANDLE hmTBButton[2],hiTBbutton[2],iTBbutton[2];
@@ -45,9 +44,9 @@ HWND g_hSDlg; BOOL DONT = FALSE;
BOOL StartUp, isLastTRUE = FALSE, g_mode,bSC = FALSE;
-DWORD session_list[255] = {0};
-DWORD user_session_list[255] = {0};
-DWORD session_list_recovered[255];
+HANDLE session_list[255] = {0};
+HANDLE user_session_list[255] = {0};
+HANDLE session_list_recovered[255];
int count = 0;
unsigned int ses_count = 0;
@@ -234,9 +233,8 @@ INT_PTR CALLBACK SaveSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar for (i=0; hContact; hContact = db_find_next(hContact))
{
BYTE res =(BYTE)SendMessage(hClistControl, CLM_GETCHECKMARK, SendMessage(hClistControl, CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
- if (res)
- {
- user_session_list[i]=(DWORD)hContact;
+ if (res) {
+ user_session_list[i] = hContact;
i++;
}
}
@@ -287,16 +285,16 @@ 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
{
ses_count=0;
TranslateDialogDefault(hdlg);
- if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
+ 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])
@@ -353,12 +351,12 @@ 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])
{
- db_set_b((HANDLE)session_list_recovered[i], MODNAME, "wasInLastSession", 0);
+ db_set_b(session_list_recovered[i], MODNAME, "wasInLastSession", 0);
i++;
}
ZeroMemory(session_list_recovered,SIZEOF(session_list_recovered));
@@ -367,10 +365,10 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- if ((ses_count=LoadSessionToCombobox(hdlg,1,ses_limit,"SessionDate",0))==ses_limit)
+ 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);
@@ -383,10 +381,10 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
+ 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;
@@ -398,10 +396,10 @@ INT_PTR CALLBACK LoadSessionDlgProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lpar DeleteAutoSession(ses_count);
EnableWindow(GetDlgItem(hdlg,IDC_SESSDEL),FALSE);
SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- if ((ses_count=LoadSessionToCombobox(hdlg,0,ses_limit,"SessionDate",0))==ses_limit)
+ 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;
@@ -449,7 +447,7 @@ INT_PTR CloseCurrentSession(WPARAM wparam,LPARAM lparam) while(session_list[0]!=0)
{
mwid.cbSize = sizeof(MessageWindowInputData);
- mwid.hContact=(HANDLE)session_list[i];
+ mwid.hContact=session_list[i];
mwid.uFlags=MSG_WINDOW_UFLAG_MSG_BOTH;
mwd.cbSize = sizeof(MessageWindowData);
@@ -462,8 +460,7 @@ INT_PTR CloseCurrentSession(WPARAM wparam,LPARAM lparam) hWnd=GetAncestor(mwd.hwndWindow,GA_ROOT);
SendMessage(hWnd,WM_CLOSE,0,1);
}
- else
- SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0);
+ else SendMessage(mwd.hwndWindow, WM_CLOSE, 0, 0);
}
ZeroMemory(session_list,SIZEOF(session_list));
return 0;
@@ -471,34 +468,25 @@ INT_PTR CloseCurrentSession(WPARAM wparam,LPARAM lparam) int SaveSessionHandles(WPARAM wparam,LPARAM lparam)
{
- int k=0;
+ if (session_list[0] == 0)
+ return 1;
- if (session_list[0]!=0)
- {
- for (HANDLE hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
- if ((k=CheckForDuplicate(session_list,(DWORD)hContact))!=-1
- &&!(g_bExclHidden&&!CheckContactVisibility(hContact)))
- {
- AddSessionMark((HANDLE)hContact,lparam,'1');
- AddInSessionOrder((HANDLE)hContact,lparam,k,1);
- }
- else
- {
- AddSessionMark((HANDLE)hContact,lparam,'0');
- AddInSessionOrder((HANDLE)hContact,lparam,0,0);
- }
+ int k=0;
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if ((k=CheckForDuplicate(session_list,hContact)) != -1 && !(g_bExclHidden && !CheckContactVisibility(hContact))) {
+ AddSessionMark(hContact,lparam,'1');
+ AddInSessionOrder(hContact,lparam,k,1);
}
- if (lparam==1)
- {
- g_ses_count++;
- db_set_b(0, MODNAME, "UserSessionsCount", (BYTE)g_ses_count);
+ else {
+ AddSessionMark(hContact,lparam,'0');
+ AddInSessionOrder(hContact,lparam,0,0);
}
- return 0;
}
- else
- return 1;
+ if (lparam == 1) {
+ g_ses_count++;
+ db_set_b(0, MODNAME, "UserSessionsCount", (BYTE)g_ses_count);
+ }
+ return 0;
}
INT_PTR SaveUserSessionHandles(WPARAM wparam,LPARAM lparam)
@@ -614,7 +602,7 @@ int LoadSession(WPARAM wparam,LPARAM lparam) int dup=0;
int hidden[255]={'0'};
HANDLE hContact;
- DWORD session_list_t[255]={0};
+ HANDLE session_list_t[255]={0};
int mode=0;
int i=0,j=0;
if ((UINT)lparam>=ses_limit&&lparam!=256)
@@ -622,27 +610,24 @@ 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))
- {
+ for (hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (LoadContactsFromMask(hContact,mode,lparam)) {
i=GetInSessionOrder(hContact,mode, lparam);
- session_list_t[i]=(DWORD)hContact;
+ session_list_t[i] = hContact;
}
}
i=0;
//TODO: change to "switch"
while(session_list_t[i]!=0)
{
- if (CheckForDuplicate(session_list,session_list_t[i])==-1)
+ if (CheckForDuplicate(session_list, session_list_t[i]) == -1)
CallService(MS_CLIST_CONTACTDOUBLECLICKED, (WPARAM)session_list_t[i], 0);
else if (g_bWarnOnHidden)
{
- if (!CheckContactVisibility((HANDLE)session_list_t[i]))
+ if (!CheckContactVisibility(session_list_t[i]))
{
hidden[j]=i+1;
j++;
@@ -652,13 +637,13 @@ int LoadSession(WPARAM wparam,LPARAM lparam) i++;
}
- if (i==0)
+ if (i == 0)
{
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)
{
@@ -673,7 +658,7 @@ int LoadSession(WPARAM wparam,LPARAM lparam) }
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)
@@ -768,11 +753,6 @@ int DeleteAutoSession(int ses_count) int SessionPreShutdown(WPARAM wparam,LPARAM lparam)
{
DONT=1;
- DestroyServiceFunction(hServiceOpenManager);
- DestroyServiceFunction(hServiceCloseCurrentSession);
- DestroyServiceFunction(hServiceShowFavMenu);
- DestroyServiceFunction(hServiceLoadLastSession);
- DestroyServiceFunction(hServiceSaveUserSession);
if (g_hDlg) DestroyWindow(g_hDlg);
if (g_hSDlg) DestroyWindow(g_hSDlg);
@@ -780,7 +760,7 @@ int SessionPreShutdown(WPARAM wparam,LPARAM lparam) if (g_bIncompletedSave) {
int i=0;
while(session_list_recovered[i]) {
- db_set_b((HANDLE)session_list_recovered[i], MODNAME, "wasInLastSession", 0);
+ db_set_b(session_list_recovered[i], MODNAME, "wasInLastSession", 0);
i++;
}
}
@@ -793,17 +773,16 @@ 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);
}
- else db_set_b(NULL, MODNAME, "lastempty", 1);
+ else db_set_b(NULL, MODNAME, "lastempty", 1);
return 0;
}
@@ -811,15 +790,13 @@ 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);
+ AddToCurSession(MWeventdata->hContact,0);
if (g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 1);
}
- else if (MWeventdata->uType == MSG_WINDOW_EVT_CLOSE)
- {
- if (!DONT) DelFromCurSession((DWORD)MWeventdata->hContact,0);
+ else if (MWeventdata->uType == MSG_WINDOW_EVT_CLOSE) {
+ if (!DONT) DelFromCurSession(MWeventdata->hContact,0);
if (g_bCrashRecovery) db_set_b(MWeventdata->hContact, MODNAME, "wasInLastSession", 0);
}
@@ -835,7 +812,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;
}
@@ -875,50 +852,14 @@ static int PluginInit(WPARAM wparam,LPARAM lparam) HookEvent(ME_OPT_INITIALISE, OptionsInit);
HookEvent(ME_TTB_MODULELOADED, CreateButtons);
- hServiceShowFavMenu = CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu);
- hServiceOpenManager = CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow);
- hServiceLoadLastSession = CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/);
- hServiceSaveUserSession = CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles);
- hServiceCloseCurrentSession = CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession);
-
- g_ses_count = db_get_b(0, MODNAME, "UserSessionsCount", 0);
- if (!g_ses_count)
- g_ses_count = db_get_b(0, "Sessions (Unicode)", "UserSessionsCount", 0);
- ses_limit = db_get_b(0, MODNAME, "TrackCount", 10);
- g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0);
- g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0);
- g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1);
- g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0);
-
- if (g_bCrashRecovery)
- g_bIncompletedSave=!db_get_b(NULL, MODNAME, "lastSaveCompleted", 0);
-
- if (g_bIncompletedSave)
- {
- int i=0;
- HANDLE hContact;
- ZeroMemory(session_list_recovered,255);
-
- for (hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
- if (db_get_b(hContact, MODNAME, "wasInLastSession", 0))
- session_list_recovered[i++]=(DWORD)hContact;
- }
- }
- if (!session_list_recovered[0]) g_bIncompletedSave=FALSE;
- db_set_b(NULL, MODNAME, "lastSaveCompleted", 0);
-
- if (!db_get_b(NULL, MODNAME, "lastempty", 1)||g_bIncompletedSave) isLastTRUE=TRUE;
-
startup=db_get_b(NULL, MODNAME, "StartupMode", 3);
- if (startup==1||(startup==3&&isLastTRUE==TRUE))
+ if (startup == 1||(startup == 3&&isLastTRUE == TRUE))
{
StartUp=TRUE;
g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
}
- else if (startup==2&&isLastTRUE==TRUE)
+ else if (startup == 2&&isLastTRUE == TRUE)
{
g_hghostw=TRUE;
g_hDlg=CreateDialog(hinstance,MAKEINTRESOURCE(IDD_WLCMDIALOG), 0, LoadSessionDlgProc);
@@ -1007,6 +948,38 @@ extern "C" __declspec(dllexport) int Load(void) {
mir_getLP(&pluginInfo);
+ CreateServiceFunction(MS_SESSIONS_SHOWFAVORITESMENU, BuildFavMenu);
+ CreateServiceFunction(MS_SESSIONS_OPENMANAGER, OpenSessionsManagerWindow);
+ CreateServiceFunction(MS_SESSIONS_RESTORELASTSESSION, LoadLastSession/*LoadSession*/);
+ CreateServiceFunction(MS_SESSIONS_SAVEUSERSESSION, SaveUserSessionHandles);
+ CreateServiceFunction(MS_SESSIONS_CLOSESESSION, CloseCurrentSession);
+
+ g_ses_count = db_get_b(0, MODNAME, "UserSessionsCount", 0);
+ if (!g_ses_count)
+ g_ses_count = db_get_b(0, "Sessions (Unicode)", "UserSessionsCount", 0);
+ ses_limit = db_get_b(0, MODNAME, "TrackCount", 10);
+ g_bExclHidden = db_get_b(NULL, MODNAME, "ExclHidden", 0);
+ g_bWarnOnHidden = db_get_b(NULL, MODNAME, "WarnOnHidden", 0);
+ g_bOtherWarnings = db_get_b(NULL, MODNAME, "OtherWarnings", 1);
+ g_bCrashRecovery = db_get_b(NULL, MODNAME, "CrashRecovery", 0);
+
+ if (g_bCrashRecovery)
+ g_bIncompletedSave=!db_get_b(NULL, MODNAME, "lastSaveCompleted", 0);
+
+ if (g_bIncompletedSave) {
+ int i=0;
+ ZeroMemory(session_list_recovered, sizeof(session_list_recovered));
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ if (db_get_b(hContact, MODNAME, "wasInLastSession", 0))
+ session_list_recovered[i++] = hContact;
+ }
+ if (!session_list_recovered[0]) g_bIncompletedSave=FALSE;
+ db_set_b(NULL, MODNAME, "lastSaveCompleted", 0);
+
+ if (!db_get_b(NULL, MODNAME, "lastempty", 1)||g_bIncompletedSave)
+ isLastTRUE = TRUE;
+
HookEvent(ME_SYSTEM_MODULESLOADED, PluginInit);
HookEvent(ME_SYSTEM_OKTOEXIT, OkToExit);
HookEvent(ME_SYSTEM_PRESHUTDOWN, SessionPreShutdown);
diff --git a/plugins/Sessions/Src/Options.cpp b/plugins/Sessions/Src/Options.cpp index e8860f6f6f..926d641226 100644 --- a/plugins/Sessions/Src/Options.cpp +++ b/plugins/Sessions/Src/Options.cpp @@ -31,7 +31,7 @@ static BOOL bOptionsInit; int opses_count;
BOOL bSesssionNameChanged=0;
-DWORD session_list_t[255]={0};
+HANDLE session_list_t[255]={0};
HWND g_opHdlg;
@@ -44,115 +44,100 @@ BOOL bChecked=FALSE; int OpLoadSessionContacts(WPARAM wparam,LPARAM lparam)
{
- HANDLE hContact;
- int i=0;
- ZeroMemory(session_list_t,SIZEOF(session_list_t));
-
- for (hContact = db_find_first(); hContact;
- hContact = db_find_next(hContact))
- {
- if (LoadContactsFromMask(hContact,1,lparam))
- {
- i=GetInSessionOrder(hContact,1, lparam);
- session_list_t[i]=(DWORD)hContact;
+ ZeroMemory(session_list_t, sizeof(session_list_t));
+
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ if (LoadContactsFromMask(hContact,1,lparam)) {
+ int i = GetInSessionOrder(hContact,1, lparam);
+ session_list_t[i] = hContact;
}
}
- i=0;
- while(session_list_t[i]!=0)
- {
- SendDlgItemMessage(g_opHdlg, IDC_OPCLIST, LB_ADDSTRING, 0,
- (LPARAM)(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME,
- (WPARAM)session_list_t[i], GCDNF_TCHAR));
- i++;
- }
+ int i;
+ for (i=0; session_list_t[i] != 0; i++)
+ SendDlgItemMessage(g_opHdlg, IDC_OPCLIST, LB_ADDSTRING, 0, CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)session_list_t[i], GCDNF_TCHAR));
+
return i;
}
static LRESULT CALLBACK ComboBoxSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_ERASEBKGND:
- return TRUE;
-
- case EM_SETSEL:
- if (!hOpClistControl)
- return HideCaret(hwnd);
- break;
-
- case WM_GETDLGCODE:
- if (!hOpClistControl)
- return DLGC_WANTARROWS;
- break;
+ switch (msg) {
+ case WM_ERASEBKGND:
+ return TRUE;
- case WM_SETCURSOR:
- {
- if (!hOpClistControl)
- {
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- return TRUE;
- }
- }break;
+ case EM_SETSEL:
+ if (!hOpClistControl)
+ return HideCaret(hwnd);
+ break;
- case WM_LBUTTONDOWN:
- if (hOpClistControl)
- break;
- HideCaret(hwnd);
+ case WM_GETDLGCODE:
+ if (!hOpClistControl)
+ return DLGC_WANTARROWS;
+ break;
- case WM_LBUTTONDBLCLK:
- case WM_MBUTTONDOWN:
- case WM_MBUTTONDBLCLK:
- SendMessage(hComboBox,CB_SHOWDROPDOWN,1,0);
+ case WM_SETCURSOR:
+ if (!hOpClistControl) {
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
return TRUE;
+ }
+ break;
- case WM_NCLBUTTONDBLCLK:
- case WM_NCLBUTTONDOWN:
- if (!bChecked)
- {
- MarkUserDefSession(opses_count,1);
- hIcon=hMarked;
- bChecked=TRUE;
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME);
- }
- else
- {
- MarkUserDefSession(opses_count,0);
- hIcon=hNotMarked;
- bChecked=FALSE;
- RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME);
- }
+ case WM_LBUTTONDOWN:
+ if (hOpClistControl)
break;
+ HideCaret(hwnd);
+
+ case WM_LBUTTONDBLCLK:
+ case WM_MBUTTONDOWN:
+ case WM_MBUTTONDBLCLK:
+ SendMessage(hComboBox,CB_SHOWDROPDOWN,1,0);
+ return TRUE;
+
+ case WM_NCLBUTTONDBLCLK:
+ case WM_NCLBUTTONDOWN:
+ if (!bChecked) {
+ MarkUserDefSession(opses_count,1);
+ hIcon = hMarked;
+ bChecked = TRUE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME);
+ }
+ else {
+ MarkUserDefSession(opses_count,0);
+ hIcon = hNotMarked;
+ bChecked = FALSE;
+ RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW|RDW_FRAME);
+ }
+ break;
- case WM_MOUSEMOVE:
- if (hOpClistControl)
- break;
-
- case WM_NCMOUSEMOVE:
- return TRUE;
-
- case WM_NCPAINT:
- {
- hdc=GetDC(hwnd);
- GetClientRect(hwnd, &rc);
- rc.left=rc.right;
- rc.right=rc.left+16;
+ case WM_MOUSEMOVE:
+ if (hOpClistControl)
+ break;
- FillRect(hdc, &rc, (HBRUSH)GetSysColor(COLOR_WINDOW));
- DrawIconEx(hdc, rc.left, 0, hIcon, 16, 16, 0, NULL, DI_NORMAL);
- ReleaseDC(hwnd, hdc);
- }break;
+ case WM_NCMOUSEMOVE:
+ return TRUE;
+
+ case WM_NCPAINT:
+ hdc = GetDC(hwnd);
+ GetClientRect(hwnd, &rc);
+ rc.left=rc.right;
+ rc.right=rc.left+16;
+ FillRect(hdc, &rc, (HBRUSH)GetSysColor(COLOR_WINDOW));
+ DrawIconEx(hdc, rc.left, 0, hIcon, 16, 16, 0, NULL, DI_NORMAL);
+ ReleaseDC(hwnd, hdc);
+ break;
- case WM_NCCALCSIZE:
+ case WM_NCCALCSIZE:
{
NCCALCSIZE_PARAMS *ncsParam = (NCCALCSIZE_PARAMS*)lParam;
ncsParam->rgrc[ 0 ].right -= 16;
- }break;
+ }
+ break;
- case WM_NCHITTEST:
+ case WM_NCHITTEST:
{
LRESULT lr = mir_callNextSubclass(hwnd, ComboBoxSubclassProc, msg, wParam, lParam );
- if (lr==HTNOWHERE )
+ if (lr == HTNOWHERE )
lr = HTOBJECT;
return lr;
}
@@ -198,40 +183,38 @@ 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)
- {
+ else if (startupmode == 3) {
CheckDlgButton(hdlg,IDC_STARTDIALOG,BST_CHECKED);
CheckDlgButton(hdlg,IDC_CHECKLAST,BST_CHECKED);
}
- else if (startupmode==2)
- {
+ else if (startupmode == 2) {
CheckDlgButton(hdlg,IDC_RLOADLAST,BST_CHECKED);
EnableWindow(GetDlgItem(hdlg, IDC_CHECKLAST), FALSE);
}
- else if (startupmode==0)
- {
+ else if (startupmode == 0) {
CheckDlgButton(hdlg,IDC_RNOTHING,BST_CHECKED);
EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), FALSE);
EnableWindow(GetDlgItem(hdlg, IDC_STATICOP), FALSE);
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);
EnableWindow(GetDlgItem(hdlg,IDC_EXSTATIC2),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_TRACK),FALSE);
EnableWindow(GetDlgItem(hdlg,IDC_SPIN1),FALSE);
}
- else if (exitmode==1) CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED);
- else if (exitmode==2) CheckDlgButton(hdlg,IDC_REXSAVE,BST_CHECKED);
+ else if (exitmode == 1)
+ CheckDlgButton(hdlg,IDC_REXASK,BST_CHECKED);
+ 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);
if (!OpLoadSessionContacts(0,opses_count))
@@ -247,7 +230,8 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) SetWindowPos( hComboBoxEdit, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED );
bOptionsInit=FALSE;
- }break;
+ }
+ break;
case WM_CTLCOLORLISTBOX:
switch(GetDlgCtrlID((HWND) lparam)) {
@@ -263,31 +247,34 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) {
int iDelay=GetDlgItemInt(hdlg, IDC_STARTDELAY,NULL, FALSE);
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_STARTDIALOG))
- {
+ 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_CHECKLAST))
db_set_b(NULL, MODNAME, "StartupMode", 1);
- else db_set_b(NULL, MODNAME, "StartupMode", 3);
+ 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)));
db_set_b(NULL, MODNAME, "OtherWarnings", (BYTE)(IsDlgButtonChecked(hdlg, IDC_WARNINGS) ? (g_bOtherWarnings = 1) : (g_bOtherWarnings = 0)));
db_set_b(NULL, MODNAME, "CrashRecovery", (BYTE)(IsDlgButtonChecked(hdlg, IDC_CRASHRECOVERY) ? (g_bCrashRecovery = 1) : (g_bCrashRecovery = 0)));
-
- return 1;
}
+ return 1;
case CLN_CHECKCHANGED:
- if (((LPNMHDR)lparam)->idFrom ==IDC_EMCLIST)
+ if (((LPNMHDR)lparam)->idFrom == IDC_EMCLIST)
{
int iSelection = (int)((NMCLISTCONTROL *)lparam)->hItem;
HANDLE hContact = db_find_first();
@@ -350,10 +337,7 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) }break;
case IDC_EDIT:
- if (!hOpClistControl)
- {
- int i;
- HANDLE hItem;
+ if (!hOpClistControl) {
ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_HIDE);
EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
//EnableWindow(GetDlgItem(hdlg,IDC_SAVE),TRUE);
@@ -368,15 +352,12 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) SendMessage(hOpClistControl,WM_TIMER,TIMERID_REBUILDAFTER,0);
- for (i=0 ; session_list_t[i]>0; i++)
- {
- hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
- //hItem=session_list[i];
+ for (int i=0 ; session_list_t[i] > 0; i++) {
+ HANDLE hItem=(HANDLE)SendMessage(hOpClistControl,CLM_FINDCONTACT, (WPARAM)session_list_t[i], 0);
SendMessage(hOpClistControl, CLM_SETCHECKMARK, (WPARAM)hItem,1);
}
}
- else
- {
+ else {
ShowWindow(GetDlgItem(hdlg,IDC_OPCLIST),SW_SHOWNA);
EnableWindow(GetDlgItem(hdlg,IDC_DEL),TRUE);
EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
@@ -388,20 +369,16 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) case IDC_SAVE:
{
- int i;
- HANDLE hContact = db_find_first();
- for (i=0 ; hContact;hContact = db_find_next(hContact))
- {
+ int i=0;
+ for (HANDLE hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
BYTE res =(BYTE)SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_GETCHECKMARK,
SendMessage(GetDlgItem(hdlg,IDC_EMCLIST), CLM_FINDCONTACT, (WPARAM)hContact, 0), 0);
- if (res)
- {
+ if (res) {
SetSessionMark(hContact,1,'1',opses_count);
SetInSessionOrder(hContact,1,opses_count,i);
i++;
}
- else
- {
+ else {
SetSessionMark(hContact,1,'0',opses_count);
SetInSessionOrder(hContact,1,opses_count,0);
}
@@ -417,31 +394,30 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) bSesssionNameChanged=FALSE;
}
EnableWindow(GetDlgItem(hdlg,IDC_SAVE),FALSE);
- }break;
+ }
+ break;
case IDC_DEL:
- {
- int i=0,index=0;
- DelUserDefSession(opses_count);
+ DelUserDefSession(opses_count);
- SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(hdlg, IDC_OPCLIST, LB_RESETCONTENT, 0, 0);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_RESETCONTENT, 0, 0);
- LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
+ LoadSessionToCombobox (hdlg,1,255,"UserSessionDsc",0);
- opses_count=0;
+ opses_count=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))
- EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
- }
- else {
- EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE);
+ 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))
EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
- }
- }break;
+ }
+ else {
+ EnableWindow(GetDlgItem(hdlg,IDC_EDIT),FALSE);
+ EnableWindow(GetDlgItem(hdlg,IDC_DEL),FALSE);
+ }
+ break;
case IDC_STARTDIALOG:
EnableWindow(GetDlgItem(hdlg, IDC_STARTDELAY), TRUE);
@@ -492,14 +468,14 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) break;
}
- if (HIWORD(wparam)==CBN_DROPDOWN&&!hOpClistControl) {
+ if (HIWORD(wparam) == CBN_DROPDOWN&&!hOpClistControl) {
SendMessage(hComboBoxEdit,EM_SETSEL ,0,0);
SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
SendMessage(hComboBoxEdit,WM_KILLFOCUS ,0,0);
HideCaret(hComboBoxEdit);
}
- if ((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam)==IDC_LIST)&&!hOpClistControl) {
+ if ((HIWORD(wparam)!=CBN_DROPDOWN)&&(LOWORD(wparam) == IDC_LIST)&&!hOpClistControl) {
SendMessage(hComboBoxEdit,EM_SCROLLCARET ,0,0);
HideCaret(hComboBoxEdit);
}
@@ -507,8 +483,8 @@ INT_PTR CALLBACK OptionsProc(HWND hdlg,UINT msg,WPARAM wparam,LPARAM lparam) if ((LOWORD(wparam) == IDC_STARTDELAY) && (HIWORD(wparam)!=EN_CHANGE || (HWND)lparam != GetFocus()))
return 0;
- if (lparam&&!bOptionsInit&&(HIWORD(wparam)==BN_CLICKED)&& (GetFocus()==(HWND)lparam)
- &&((LOWORD(wparam)==IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY))))
+ if (lparam&&!bOptionsInit&&(HIWORD(wparam) == BN_CLICKED)&& (GetFocus() == (HWND)lparam)
+ &&((LOWORD(wparam) == IDC_CHECKLAST)||((LOWORD(wparam)>=IDC_EXCLHIDDEN)&&(LOWORD(wparam)<=IDC_CRASHRECOVERY))))
SendMessage(GetParent(hdlg),PSM_CHANGED,0,0);
return 0;
@@ -533,4 +509,4 @@ int OptionsInit(WPARAM wparam,LPARAM lparam) Options_AddPage(wparam,&odp);
return 0;
-}
\ No newline at end of file +}
diff --git a/plugins/Sessions/Src/Sessions.h b/plugins/Sessions/Src/Sessions.h index 7ad107b01d..b7e9186f62 100644 --- a/plugins/Sessions/Src/Sessions.h +++ b/plugins/Sessions/Src/Sessions.h @@ -58,8 +58,8 @@ INT_PTR CloseCurrentSession(WPARAM ,LPARAM ); int SaveSessionDate();
extern HINSTANCE hinstance;
-extern DWORD session_list_recovered[255];
-extern DWORD session_list[255];
+extern HANDLE session_list_recovered[255];
+extern HANDLE session_list[255];
extern unsigned int ses_limit;
extern unsigned int g_ses_count;
extern BOOL g_bExclHidden;
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index d2f5c58c12..480c8d3c0f 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -17,55 +17,43 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include "sessions.h"
-void AddSessionMark(HANDLE hContact,int mode,char bit)
+void AddSessionMark(HANDLE hContact, int mode, char bit)
{
+ DBVARIANT dbv;
unsigned int i;
char temp_1[1]={'\0'},temp_2[1]={'\0'};
char szDst[256]={'\0'};
char* pszBuffer=NULL;
- if (mode==0)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
- {
+ if (mode == 0) {
+ if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
temp_1[0]=dbv.pszVal[0];
- for (i=0;i<ses_limit;i++)
- {
+ for (i=0; i < ses_limit; i++) {
temp_2[0]=dbv.pszVal[i+1];
dbv.pszVal[i+1]=temp_1[0];
temp_1[0]=temp_2[0];
}
- for (i=ses_limit;i<10;i++)
+ for (i=ses_limit; i < 10; i++)
dbv.pszVal[i]='0';
dbv.pszVal[0]=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)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal)
- {
- if (strlen(dbv.pszVal)<g_ses_count)
- {
+ else if (mode == 1) {
+ if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
+ if (strlen(dbv.pszVal)<g_ses_count) {
pszBuffer = (char*)mir_alloc(g_ses_count+1);
ZeroMemory(pszBuffer,g_ses_count+1);
strcpy(pszBuffer,dbv.pszVal);
}
- else
- pszBuffer = mir_strdup(dbv.pszVal);
-
+ else pszBuffer = mir_strdup(dbv.pszVal);
db_free(&dbv);
temp_1[0]=pszBuffer[0];
- for (i=0;i<g_ses_count;i++)
- {
+ for (i=0;i<g_ses_count;i++) {
temp_2[0]=pszBuffer[i+1];
pszBuffer[i+1]=temp_1[0];
temp_1[0]=temp_2[0];
@@ -75,8 +63,10 @@ void AddSessionMark(HANDLE hContact,int mode,char bit) mir_free(pszBuffer);
}
- else if (bit=='1')db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
- else db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000");
+ else if (bit == '1')
+ db_set_s(hContact, MODNAME, "UserSessionsMarks", "10000000000");
+ else
+ db_set_s(hContact, MODNAME, "UserSessionsMarks", "00000000000");
}
}
@@ -85,28 +75,24 @@ 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)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
- {
+ DBVARIANT dbv;
+
+ if (mode == 0) {
+ if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
for (i=marknum;i<ses_limit;i++)
- dbv.pszVal[i]=dbv.pszVal[i+1];
+ dbv.pszVal[i] = dbv.pszVal[i+1];
for (i=ses_limit;i<10;i++)
- dbv.pszVal[i]='0';
+ dbv.pszVal[i] = '0';
db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
}
- if (mode==1)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal)
- {
- for (i=marknum;i<ses_limit;i++)
- dbv.pszVal[i]=dbv.pszVal[i+1];
+ else if (mode == 1) {
+ if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
+ for (i=marknum;i < ses_limit; i++)
+ dbv.pszVal[i] = dbv.pszVal[i+1];
db_set_s(hContact, MODNAME, "UserSessionsMarks", dbv.pszVal);
db_free(&dbv);
@@ -116,25 +102,19 @@ void RemoveSessionMark(HANDLE hContact,int mode,int marknum) void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum)
{
+ DBVARIANT dbv;
char* pszBuffer=NULL;
- if (mode==0)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal)
- {
+ if (mode == 0) {
+ if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv)) {
dbv.pszVal[marknum]=bit;
db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
db_free(&dbv);
}
}
-
- if (mode==1)
- {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal)
- {
+ else if (mode == 1) {
+ if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv)) {
pszBuffer = mir_strdup(dbv.pszVal);
pszBuffer[marknum]=bit;
db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer);
@@ -146,26 +126,20 @@ void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum) BOOL LoadContactsFromMask(HANDLE hContact,int mode,int count)
{
+ DBVARIANT dbv;
if (mode == 0) {
- DBVARIANT dbv;
- if ( db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv))
+ if (db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv))
return 0;
-
- BOOL res = dbv.pszVal[count] == '1';
- db_free(&dbv);
- return res;
}
-
- if (mode == 1) {
- DBVARIANT dbv;
- if ( db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv))
+ else if (mode == 1) {
+ if (db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv))
return 0;
-
- BOOL res = dbv.pszVal[count] == '1';
- db_free(&dbv);
- return res;
}
- return 0;
+ else return 0;
+
+ BOOL res = dbv.pszVal[count] == '1';
+ db_free(&dbv);
+ return res;
}
void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode)
@@ -181,29 +155,25 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode) else
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u", ordernum);
- if (mode==0)
- {
+ if (mode == 0) {
DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv))
- {
+ if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv)) {
char* temp=NULL;
char* temp2=NULL;
int len= (int)strlen(dbv.pszVal);
if (!len)
- len=20;
+ len = 20;
temp2 = (char*)mir_alloc(len-1);
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';
mir_snprintf(temp, len+1, "%u%u%s", 0, ordernum, temp2);
}
- else
- mir_snprintf(temp, len+1, "%u%s", ordernum, temp2);
+ else mir_snprintf(temp, len+1, "%u%s", ordernum, temp2);
for (i=(ses_limit*2);i<20;i++)
temp[i]='0';
@@ -213,8 +183,7 @@ 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)
mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%u%s", 0, ordernum, "000000000000000000");
@@ -224,26 +193,20 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode) db_set_s(hContact, MODNAME, "LastSessionsOrder", szFormNumBuf);
}
}
-
- if (mode==1)
- {
+ else if (mode == 1) {
DBVARIANT dbv;
int advlen=0;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal)
- {
+ if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
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);
strcpy(pszBuffer,dbv.pszVal);
}
- else
- {
- pszBuffer = mir_strdup(dbv.pszVal);
- }
+ else pszBuffer = mir_strdup(dbv.pszVal);
+
if (!(advlen=len= (int)strlen(pszBuffer)))
advlen=len=20;
else
@@ -263,7 +226,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");
@@ -272,27 +235,23 @@ void AddInSessionOrder(HANDLE hContact,int mode,int ordernum,int writemode) int GetInSessionOrder(HANDLE hContact,int mode,int count)
{
- int iOrder=0;
+ 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)
- {
- szTemp[0]=dbv.pszVal[count*2];
- szTemp[1]=dbv.pszVal[count*2+1];
- iOrder=atoi(szTemp);
+ if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) {
+ szTemp[0] = dbv.pszVal[count*2];
+ szTemp[1] = dbv.pszVal[count*2+1];
+ iOrder = atoi(szTemp);
db_free(&dbv);
}
}
- if (mode==1)
- {
+ else if (mode == 1) {
DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal)
- {
- szTemp[0]=dbv.pszVal[count*2];
- szTemp[1]=dbv.pszVal[count*2+1];
- iOrder=atoi(szTemp);
+ if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
+ szTemp[0] = dbv.pszVal[count*2];
+ szTemp[1] = dbv.pszVal[count*2+1];
+ iOrder = atoi(szTemp);
db_free(&dbv);
}
}
@@ -304,28 +263,23 @@ 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)
- {
+ if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) {
dbv.pszVal[count*2]=szTemp[0];
dbv.pszVal[count*2+1]=szTemp[1];
db_set_s(hContact, MODNAME, "LastSessionsOrder", dbv.pszVal);
db_free(&dbv);
}
}
-
- if (mode==1)
- {
+ else if (mode == 1) {
DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal)
- {
+ if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
dbv.pszVal[count*2]=szTemp[0];
dbv.pszVal[count*2+1]=szTemp[1];
db_set_s(hContact, MODNAME, "UserSessionsOrder", dbv.pszVal);
@@ -339,8 +293,7 @@ BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer) BYTE marked,marked_t;
char szNameBuf[256]={0};
- for (int i = iFirst; i < iLimit; i++)
- {
+ for (int i = iFirst; i < iLimit; i++) {
if (szBuffer == NULL)
break;
@@ -352,7 +305,7 @@ BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer) mir_free(szBuffer);
marked = IsMarkedUserDefSession(i);
- MarkUserDefSession(i,(BYTE)((i==iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
+ MarkUserDefSession(i,(BYTE)((i == iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
marked_t = marked;
if (res) // read failed
@@ -366,16 +319,12 @@ BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer) return 1;
}
-int AddToCurSession (DWORD wparam,LPARAM lparam)
+int AddToCurSession (HANDLE wparam,LPARAM lparam)
{
- int i;
- if (CheckForDuplicate(session_list,wparam)==-1)
- {
- for (i=0;;i++)
- {
- if (session_list[i]==0)
- {
- session_list[i]=wparam;
+ if (CheckForDuplicate(session_list,wparam) == -1) {
+ for (int i=0;;i++) {
+ if (session_list[i] == 0) {
+ session_list[i] = wparam;
break;
}
}
@@ -383,64 +332,58 @@ int AddToCurSession (DWORD wparam,LPARAM lparam) return 0;
}
-int DelFromCurSession(DWORD wparam,LPARAM lparam)
+int DelFromCurSession(HANDLE wparam,LPARAM lparam)
{
- int i=0;
- while(session_list[i]!=0)
- {
- if (session_list[i]==wparam)
- {
- while(session_list[i+1]!=0)
- {
+ for (int i=0; session_list[i] != 0; i++) {
+ if (session_list[i] == wparam) {
+ while(session_list[i+1]!=0) {
session_list[i]=session_list[i+1];
i++;
}
- session_list[i]=0;
+ session_list[i] = 0;
}
- i++;
}
return 0;
}
-int CheckForDuplicate(DWORD contact_list[],DWORD lparam)
+int CheckForDuplicate(HANDLE contact_list[], HANDLE lparam)
{
int i=0;
- DWORD s_list[255]={'0'};
+ HANDLE s_list[255] = {0};
memcpy(s_list, contact_list,SIZEOF(s_list));
- for (i=0;;i++)
- {
- if (s_list[i]==lparam)
+ for (i=0;;i++) {
+ if (s_list[i] == lparam)
return i;
- if (s_list[i]==0)
+ if (s_list[i] == 0)
return -1;
}
return 0;
}
-int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum)
+int LoadSessionToCombobox(HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum)
{
- int ses_count=iFirstNum, index;
+ int ses_count = iFirstNum, index;
char szBuffer[256]={0};
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);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, index, 256);
}
for(int i=0; i < iLimit; i++) {
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", pszSetting, i);
TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer);
if (pszBuffer) {
- if (!IsMarkedUserDefSession(i+iFirstNum)||mode==1) {
+ 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);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, i+iFirstNum);
}
else {
SendDlgItemMessage(hdlg, IDC_LIST, CB_INSERTSTRING, 0, (LPARAM)pszBuffer);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, (LPARAM) (DWORD)i+iFirstNum);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, i+iFirstNum);
}
mir_free(pszBuffer);
}
else {
- if (i==0) ses_count=iLimit-iFirstNum;
+ if (i == 0) ses_count=iLimit-iFirstNum;
break;
}
}
@@ -514,8 +457,8 @@ BYTE IsMarkedUserDefSession(int ses_count) void SavePosition(HWND hwnd, char *wndName)
{
RECT rc;
- char buffer[512];
GetWindowRect(hwnd, &rc);
+ char buffer[512];
mir_snprintf(buffer, SIZEOF(buffer), "%sPosX", wndName);
db_set_dw(0, MODNAME, buffer, rc.left);
mir_snprintf(buffer, SIZEOF(buffer), "%sPosY", wndName);
@@ -525,10 +468,9 @@ void SavePosition(HWND hwnd, char *wndName) void LoadPosition(HWND hWnd, char *wndName)
{
char buffer[512];
- int x,y ;
mir_snprintf(buffer, SIZEOF(buffer), "%sPosX", wndName);
- x = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2)-130);
+ int x = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2)-130);
mir_snprintf(buffer, SIZEOF(buffer), "%sPosY", wndName);
- y = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CYSCREEN))/ 2)-80);
+ int y = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CYSCREEN))/ 2)-80);
SetWindowPos(hWnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE);
-}
\ No newline at end of file +}
diff --git a/plugins/Sessions/Src/Utils.h b/plugins/Sessions/Src/Utils.h index 2dc9cbb733..3e5aaaa002 100644 --- a/plugins/Sessions/Src/Utils.h +++ b/plugins/Sessions/Src/Utils.h @@ -27,9 +27,9 @@ void AddSessionMark(HANDLE hContact,int mode,char bit); void RemoveSessionMark(HANDLE hContact,int mode,int marknum);
void SetSessionMark(HANDLE hContact,int mode,char bit,unsigned int marknum);
BOOL LoadContactsFromMask(HANDLE hContact,int mode,int count);
-int AddToCurSession (DWORD wparam,LPARAM lparam);
-int DelFromCurSession(DWORD wparam,LPARAM lparam);
-int CheckForDuplicate(DWORD contact_list[],DWORD lparam);
+int AddToCurSession (HANDLE wparam,LPARAM lparam);
+int DelFromCurSession(HANDLE wparam,LPARAM lparam);
+int CheckForDuplicate(HANDLE contact_list[],HANDLE lparam);
BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* pszPrevSetting);
void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy);
int LoadSessionToCombobox (HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum);
|