diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-25 21:08:33 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-25 21:08:33 +0000 |
commit | 3873ba081f6ef7c725170a469abdd975ab801e03 (patch) | |
tree | b630e152c5c9df1963e24916c2ab9e139ba3c63e /plugins/StatusPlugins/confirmdialog.cpp | |
parent | 4dd41bfe65b206acb2df026d21320ef2659946b0 (diff) |
minor code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@2500 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/StatusPlugins/confirmdialog.cpp')
-rw-r--r-- | plugins/StatusPlugins/confirmdialog.cpp | 129 |
1 files changed, 59 insertions, 70 deletions
diff --git a/plugins/StatusPlugins/confirmdialog.cpp b/plugins/StatusPlugins/confirmdialog.cpp index 1271bd1df3..ab2754d135 100644 --- a/plugins/StatusPlugins/confirmdialog.cpp +++ b/plugins/StatusPlugins/confirmdialog.cpp @@ -241,11 +241,11 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA case IDC_PROFILE:
{
int profile = (int)SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_PROFILE, CB_GETCURSEL, 0, 0), 0);
- for (int i=0; i < confirmSettings->getCount(); i++) {
+ for (int i=0; i < confirmSettings->getCount(); i++)
if ((*confirmSettings)[i].szMsg != NULL) {
free((*confirmSettings)[i].szMsg);
(*confirmSettings)[i].szMsg = NULL;
- } }
+ }
CallService(MS_SS_GETPROFILE, (WPARAM)profile, (LPARAM)confirmSettings);
for (int i=0; i < confirmSettings->getCount(); i++)
@@ -264,7 +264,8 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST),-1,LVNI_SELECTED);
if (lvItem.iItem == -1)
break;
- ListView_GetItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST), &lvItem);
+
+ ListView_GetItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), &lvItem);
PROTOCOLSETTINGEX* proto = (PROTOCOLSETTINGEX*)lvItem.lParam;
int actualStatus = proto->status = (int)SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_GETCURSEL, 0, 0), 0);
@@ -329,79 +330,67 @@ static INT_PTR CALLBACK ConfirmDlgProc(HWND hwndDlg,UINT msg,WPARAM wParam,LPARA case WM_NOTIFY:
switch(((NMHDR*)lParam)->idFrom) {
case IDC_STARTUPLIST:
- switch(((NMHDR*)lParam)->code) {
- // fill combobox
- case NM_CLICK:
- {
- LVITEM lvItem;
- PROTOCOLSETTINGEX* proto;
- TCHAR buf[100];
- int item, flags, i, currentStatus, actualStatus;
-
- KillTimer(hwndDlg, TIMER_ID);
- SetDlgItemText(hwndDlg, IDC_CLOSE, TranslateT("Close"));
-
- memset(&lvItem,0,sizeof(lvItem));
- lvItem.mask=LVIF_TEXT|LVIF_PARAM;
- lvItem.iSubItem=0;
- lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST),-1,LVNI_SELECTED);
+ if (((NMHDR*)lParam)->code == NM_CLICK) {
+ KillTimer(hwndDlg, TIMER_ID);
+ SetDlgItemText(hwndDlg, IDC_CLOSE, TranslateT("Close"));
+
+ LVITEM lvItem = { 0 };
+ lvItem.mask = LVIF_TEXT | LVIF_PARAM;
+ lvItem.iSubItem = 0;
+ lvItem.iItem = ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST),-1,LVNI_SELECTED);
- if ( ListView_GetItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST), &lvItem) == FALSE) {
- SetStatusList(hwndDlg);
- break;
- }
- proto = (PROTOCOLSETTINGEX*)lvItem.lParam;
-
- flags = CallProtoService(proto->szName, PS_GETCAPS,PFLAGNUM_2,0)&~CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0);
- // clear box and add new status, loop status and check if compatible with proto
- SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_RESETCONTENT, 0, 0);
- actualStatus = proto->status;
-
- // last
- mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"),
- TranslateT("<last>"),
- CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)proto->lastStatus, GSMDF_TCHAR));
- item = SendDlgItemMessage( hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)buf );
- SendDlgItemMessage( hwndDlg, IDC_STATUS, CB_SETITEMDATA, item, (LPARAM)ID_STATUS_LAST );
- if (proto->status == ID_STATUS_LAST) {
- SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
- actualStatus = proto->lastStatus;
- }
+ if ( ListView_GetItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST), &lvItem) == FALSE) {
+ SetStatusList(hwndDlg);
+ break;
+ }
- // current
- currentStatus = CallProtoService(proto->szName,PS_GETSTATUS, 0, 0);
- mir_sntprintf( buf, SIZEOF(buf), _T("%s (%s)"),
- TranslateT("<current>"),
- CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)currentStatus, GSMDF_TCHAR));
- item = SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_ADDSTRING,0,(LPARAM)buf);
- SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETITEMDATA,item,(LPARAM)ID_STATUS_CURRENT);
- if (proto->status == ID_STATUS_CURRENT) {
- SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
- actualStatus = currentStatus;
- }
+ PROTOCOLSETTINGEX* proto = (PROTOCOLSETTINGEX*)lvItem.lParam;
+ int flags = CallProtoService(proto->szName, PS_GETCAPS,PFLAGNUM_2,0) & ~CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0);
+ // clear box and add new status, loop status and check if compatible with proto
+ SendDlgItemMessage(hwndDlg, IDC_STATUS, CB_RESETCONTENT, 0, 0);
+ int actualStatus = proto->status;
+
+ // last
+ TCHAR buf[100];
+ mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("<last>"), pcli->pfnGetStatusModeDescription(proto->lastStatus, GSMDF_TCHAR));
+ int item = SendDlgItemMessage( hwndDlg, IDC_STATUS, CB_ADDSTRING, 0, (LPARAM)buf );
+ SendDlgItemMessage( hwndDlg, IDC_STATUS, CB_SETITEMDATA, item, (LPARAM)ID_STATUS_LAST );
+ if (proto->status == ID_STATUS_LAST) {
+ SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
+ actualStatus = proto->lastStatus;
+ }
- for (i=0; i < SIZEOF(statusModeList); i++) {
- if ( ((flags&statusModePf2List[i]) || (statusModePf2List[i] == PF2_OFFLINE)) && (!((!(flags)&Proto_Status2Flag(statusModePf2List[i]))) || ((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0)&Proto_Status2Flag(statusModePf2List[i]))))) {
- TCHAR* statusMode = ( TCHAR* )CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, statusModeList[i], GSMDF_TCHAR);
- item = SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_ADDSTRING,0,(LPARAM)statusMode);
- SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETITEMDATA,item,(LPARAM)statusModeList[i]);
- if (statusModeList[i] == proto->status)
- SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
- }
- }
+ // current
+ int currentStatus = CallProtoService(proto->szName,PS_GETSTATUS, 0, 0);
+ mir_sntprintf( buf, SIZEOF(buf), _T("%s (%s)"),
+ TranslateT("<current>"),
+ CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, (WPARAM)currentStatus, GSMDF_TCHAR));
+ item = SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_ADDSTRING,0,(LPARAM)buf);
+ SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETITEMDATA,item,(LPARAM)ID_STATUS_CURRENT);
+ if (proto->status == ID_STATUS_CURRENT) {
+ SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
+ actualStatus = currentStatus;
+ }
- // enable status box
- EnableWindow(GetDlgItem(hwndDlg,IDC_STATUS), (ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST),-1,LVNI_SELECTED)>=0));
- if ( (!((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))))
- EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), FALSE);
- else if ( proto->status == ID_STATUS_LAST || proto->status == ID_STATUS_CURRENT )
- EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), TRUE);
- else
- EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))?TRUE:FALSE);
+ for (int i=0; i < SIZEOF(statusModeList); i++) {
+ if ( ((flags&statusModePf2List[i]) || (statusModePf2List[i] == PF2_OFFLINE)) && (!((!(flags)&Proto_Status2Flag(statusModePf2List[i]))) || ((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_5, 0)&Proto_Status2Flag(statusModePf2List[i]))))) {
+ TCHAR* statusMode = ( TCHAR* )CallService(MS_CLIST_GETSTATUSMODEDESCRIPTION, statusModeList[i], GSMDF_TCHAR);
+ item = SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_ADDSTRING,0,(LPARAM)statusMode);
+ SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETITEMDATA,item,(LPARAM)statusModeList[i]);
+ if (statusModeList[i] == proto->status)
+ SendDlgItemMessage(hwndDlg,IDC_STATUS,CB_SETCURSEL,(WPARAM)item,0);
+ }
}
- break;
+
+ // enable status box
+ EnableWindow(GetDlgItem(hwndDlg,IDC_STATUS), (ListView_GetNextItem(GetDlgItem(hwndDlg,IDC_STARTUPLIST),-1,LVNI_SELECTED)>=0));
+ if ( (!((CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))))
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), FALSE);
+ else if ( proto->status == ID_STATUS_LAST || proto->status == ID_STATUS_CURRENT )
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), TRUE);
+ else
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SETSTSMSG), (CallProtoService(proto->szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))?TRUE:FALSE);
}
- break;
}
break;
|