From 8fa9881c798377013852e9b9e8a87ae8644a03a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 29 Oct 2013 21:18:10 +0000 Subject: Adopted SmartAutoAway plugin First compilable version. git-svn-id: http://svn.miranda-ng.org/main/trunk@6688 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SmartAutoAway/dlgproc.cpp | 281 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 plugins/SmartAutoAway/dlgproc.cpp (limited to 'plugins/SmartAutoAway/dlgproc.cpp') diff --git a/plugins/SmartAutoAway/dlgproc.cpp b/plugins/SmartAutoAway/dlgproc.cpp new file mode 100644 index 0000000000..72836cc6a8 --- /dev/null +++ b/plugins/SmartAutoAway/dlgproc.cpp @@ -0,0 +1,281 @@ +/* + +Miranda IM: the free IM client for Microsoft* Windows* + +Copyright 2000-2006 Miranda ICQ/IM project, +all portions of this codebase are copyrighted to the people +listed in contributors.txt. + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +#include "globals.h" + +INT_PTR CALLBACK DlgProcAutoAwayOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ +// char str[MAXMODULELABELLENGTH]; + static short int tabprotosel; + switch (msg) + { + case WM_INITDIALOG: + { + short int t,p,protoListed; + TCITEM tci; + RECT theTabSpace; + RECT rcClient; + { + RECT rcTab, rcDlg; + TabCtrl_GetItemRect(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB),0,&rcTab); + theTabSpace.top = rcTab.bottom; // the size of the tab + GetWindowRect(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB), &rcTab); + GetWindowRect(hwndDlg, &rcDlg); + theTabSpace.bottom = rcTab.bottom -rcTab.top -theTabSpace.top; + theTabSpace.top = rcTab.top -rcDlg.top +theTabSpace.top; + theTabSpace.left = rcTab.left - rcDlg.left; + theTabSpace.right = rcTab.right-rcTab.left; + } + theDialog = hwndDlg; + TranslateDialogDefault(hwndDlg); + protoListed = 0; + for (p = 0 ; p < protoCount ;p++) { + int caps=0; + if ( !isInterestingProto(p) ) continue; + caps = CallProtoService(accounts[p]->szModuleName, PS_GETCAPS, PFLAGNUM_2, 0); + PROTOACCOUNT* protoAccount=ProtoGetAccount(accounts[p]->szModuleName); + if ((int)protoAccount!=CALLSERVICE_NOTFOUND){ + SendDlgItemMessage(hwndDlg, IDC_AAPROTOCOL, CB_ADDSTRING, 0, (LPARAM)protoAccount->tszAccountName ); + } else SendDlgItemMessageA(hwndDlg, IDC_AAPROTOCOL, CB_ADDSTRING, 0, (LPARAM)accounts[p]->szModuleName ); + protoListed++; + } + tabprotosel = db_get_w(NULL, AA_MODULE, AA_PROTOSELECTION, 0); + t = (tabprotosel&0x0F00) >> 8; if (t>3) t=3; + p = (tabprotosel&0x00FF); + if ((p>=protoListed)) p= protoListed-1; + SendDlgItemMessage(hwndDlg, IDC_AAPROTOCOL, CB_SETCURSEL, p, 0); + SetDlgItems(hwndDlg, courProtocolSelection = GetCourSelProtocol(p)); + + tci.mask = TCIF_PARAM|TCIF_TEXT; + +#ifdef SAA_PLUGIN + theDialogAA = CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_OPT_SAA_AA), hwndDlg, DlgProcOptsAA); +#else + theDialogAA = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_OPT_SAA_AA), hwndDlg, DlgProcOptsAA); +#endif + tci.lParam = (LPARAM)theDialogAA; + tci.pszText = TranslateT("Statuses"); + GetClientRect(theDialogAA,&rcClient); + SendMessage(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB), TCM_INSERTITEM, 0, (LPARAM)&tci); + MoveWindow((HWND)theDialogAA,theTabSpace.left+(theTabSpace.right-rcClient.right)/2, + theTabSpace.top+(theTabSpace.bottom-rcClient.bottom)/2, + rcClient.right,rcClient.bottom,1); + ShowWindow((HWND)tci.lParam, (t==0)?SW_SHOW:SW_HIDE); + + +#ifdef SAA_PLUGIN + theDialogIdle = CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_OPT_SAA_IDLE), hwndDlg, DlgProcOptsIdle); +#else + theDialogIdle = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_OPT_SAA_IDLE), hwndDlg, DlgProcOptsIdle); +#endif + tci.lParam = (LPARAM)theDialogIdle; + tci.pszText = TranslateT("Idle"); + GetClientRect(theDialogIdle,&rcClient); + SendMessage(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB), TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tci); + MoveWindow((HWND)theDialogIdle,theTabSpace.left+(theTabSpace.right-rcClient.right)/2, + theTabSpace.top+(theTabSpace.bottom-rcClient.bottom)/2, + rcClient.right,rcClient.bottom,1); + ShowWindow((HWND)tci.lParam, (t==1)?SW_SHOW:SW_HIDE); + +#ifdef SAA_PLUGIN + theDialogIdleMessages = CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_OPT_SAA_IDLEMESSAGES), hwndDlg, DlgProcOptsIdleMessages); +#else + theDialogIdleMessages = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_OPT_SAA_IDLEMESSAGES), hwndDlg, DlgProcOptsIdleMessages); +#endif + tci.lParam = (LPARAM)theDialogIdleMessages; + tci.pszText = TranslateT("Status Messages"); + GetClientRect(theDialogIdleMessages,&rcClient); + SendMessage(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB), TCM_INSERTITEM, (WPARAM)2, (LPARAM)&tci); + MoveWindow((HWND)theDialogIdleMessages,theTabSpace.left+(theTabSpace.right-rcClient.right)/2, + theTabSpace.top+(theTabSpace.bottom-rcClient.bottom)/2, + rcClient.right,rcClient.bottom,1); + ShowWindow((HWND)tci.lParam, (t==2)?SW_SHOW:SW_HIDE); + +#ifdef SAA_PLUGIN + theDialogReconnect = CreateDialog(g_hInst,MAKEINTRESOURCE(IDD_OPT_SAA_RECONNECT), hwndDlg, DlgProcOptsReconnect); +#else + theDialogReconnect = CreateDialog(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_OPT_SAA_RECONNECT), hwndDlg, DlgProcOptsReconnect); +#endif + tci.lParam = (LPARAM)theDialogReconnect; + tci.pszText = TranslateT("Reconnect"); + GetClientRect(theDialogReconnect,&rcClient); + SendMessage(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB), TCM_INSERTITEM, (WPARAM)3, (LPARAM)&tci); + MoveWindow((HWND)theDialogReconnect,theTabSpace.left+(theTabSpace.right-rcClient.right)/2, + theTabSpace.top+(theTabSpace.bottom-rcClient.bottom)/2, + rcClient.right,rcClient.bottom,1); + ShowWindow((HWND)tci.lParam, (t==3)?SW_SHOW:SW_HIDE); + TabCtrl_SetCurSel(GetDlgItem(hwndDlg, IDC_OPT_SAA_TAB),t); + + if(enableThemeDialogTexture) { + enableThemeDialogTexture(theDialogAA, ETDT_ENABLETAB); + enableThemeDialogTexture(theDialogIdle, ETDT_ENABLETAB); + enableThemeDialogTexture(theDialogIdleMessages, ETDT_ENABLETAB); + enableThemeDialogTexture(theDialogReconnect, ETDT_ENABLETAB); + } + return TRUE; + } + + case WM_COMMAND: + { + switch (LOWORD(wParam)) { + case IDC_AAPROTOCOL: + { + int cour = SendDlgItemMessage(hwndDlg, IDC_AAPROTOCOL, CB_GETCURSEL, 0, 0); + courProtocolSelection = GetCourSelProtocol(cour); + if ( HIWORD(wParam) != CBN_SELCHANGE ) return TRUE; + db_set_w(NULL, AA_MODULE, AA_PROTOSELECTION, + (unsigned short)(tabprotosel=courProtocolSelection|(tabprotosel&0xFF00))); + SetDlgItems(hwndDlg, courProtocolSelection); + SetDlgItemsReconnect(theDialogReconnect,courProtocolSelection); + SetDlgItemsAA(theDialogAA,courProtocolSelection); + SetDlgItemsIdleMessages(theDialogIdleMessages,courProtocolSelection); + break; + } + case IDC_APPLYTOALL: + { + int i; + for (i=0;iidFrom) { + case 0: { + BOOL CommandApply; + if ( (CommandApply = lParam && ((LPNMHDR)lParam)->code == PSN_APPLY) || (lParam && ((LPNMHDR)lParam)->code == PSN_RESET) ) { + int j=0; +#ifdef _DEBUG + //MessageBox(hwndDlg,CommandApply?"Apply":"Cancel","EventHapened",0); +#endif + for (j = 0 ; j < protoCount ; j++) { + if ( isInterestingProto(j) ) { + char str[256]; + if (CommandApply) { + onlyIfBitsPerm[j] = onlyIfBits[j]; + awayStatusesPerm[j] = awayStatuses[j]; + reconnectOptsPerm[j] = reconnectOpts[j]; + sprintf(str,AA_BITSONLYIF,accounts[j]->szModuleName); + db_set_dw(NULL,AA_MODULE,str,onlyIfBitsPerm[j]); + sprintf(str,AA_AWAYSTATUSES,accounts[j]->szModuleName); + db_set_w(NULL,AA_MODULE,str,awayStatusesPerm[j]); + sprintf(str,AA_RECONNECTOPTS,accounts[j]->szModuleName); + db_set_dw(NULL,AA_MODULE,str,reconnectOptsPerm[j]); + if (messCaps[j]) { + idleMessOptsPerm[j] = idleMessOpts[j]; + sprintf(str,idleMsgOptionsName,accounts[j]->szModuleName); + db_set_dw(NULL,AA_MODULE,str,idleMessOptsPerm[j]); + + sprintf(str,idleMsgOptionsTextHere,accounts[j]->szModuleName); + _tcscpy(mesgHerePerm[j],mesgHere[j]); + db_set_ts(NULL,AA_MODULE,str,mesgHerePerm[j]); + + sprintf(str,idleMsgOptionsTextShort,accounts[j]->szModuleName); + _tcscpy(mesgShortPerm[j],mesgShort[j]); + db_set_ts(NULL,AA_MODULE,str,mesgShortPerm[j]); + + sprintf(str,idleMsgOptionsTextLong,accounts[j]->szModuleName); + _tcscpy(mesgLongPerm[j],mesgLong[j]); + db_set_ts(NULL,AA_MODULE,str,mesgLongPerm[j]); + } + } else { + onlyIfBits[j] = onlyIfBitsPerm[j]; + awayStatuses[j] = awayStatusesPerm[j]; + reconnectOpts[j] = reconnectOptsPerm[j]; + idleMessOpts[j] = idleMessOptsPerm[j]; + if (messCaps[j]) { + _tcscpy(mesgHere[j],mesgHerePerm[j]); + _tcscpy(mesgShort[j],mesgShortPerm[j]); + _tcscpy(mesgLong[j],mesgLongPerm[j]); + } + } + } + } + if (CommandApply) { + idleOptsPerm = idleOpts; + db_set_dw(NULL,AA_MODULE,AA_IDLEOPTIONS,idleOptsPerm); + } else { + idleOpts = idleOptsPerm; + } + } //if PSN_APPLY + break; + case IDC_OPT_SAA_TAB: + switch (((LPNMHDR)lParam)->code) + { + case TCN_SELCHANGING: + { + TCITEM tci; + tci.mask = TCIF_PARAM; + TabCtrl_GetItem(GetDlgItem(hwndDlg,IDC_OPT_SAA_TAB),TabCtrl_GetCurSel(GetDlgItem(hwndDlg,IDC_OPT_SAA_TAB)),&tci); + ShowWindow((HWND)tci.lParam,SW_HIDE); + } + break; + case TCN_SELCHANGE: + { + TCITEM tci; + short int t; + tci.mask = TCIF_PARAM; + t = TabCtrl_GetCurSel(GetDlgItem(hwndDlg,IDC_OPT_SAA_TAB)); + TabCtrl_GetItem(GetDlgItem(hwndDlg,IDC_OPT_SAA_TAB),t,&tci); + db_set_w(NULL, AA_MODULE, AA_PROTOSELECTION, + (unsigned short)(tabprotosel=(t<<8)|(tabprotosel&0xF0FF))); + ShowWindow((HWND)tci.lParam,SW_SHOW); + { BOOL enableW = (tci.lParam!=(long)theDialogIdle); + EnableWindow(GetDlgItem(hwndDlg,IDC_AAPROTOCOL),enableW); + EnableWindow(GetDlgItem(hwndDlg,IDC_APPLYTOALL),enableW); + } + } + break; + } + break; + } + }//end case(LPNMHDR)lParam)->idFrom + + } +//WTF??? if(wParam!=0x12345678) SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + return FALSE; +} + + + -- cgit v1.2.3