static void EnableDisableOKButton (HWND hwnd) { HWND hwndGrantees = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_GRANTEES); HWND hwndDBevents = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_DBEVENT); BOOL check [2]; BOOL B [3]; BOOL C [2]; check [0] = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_RAISE )); check [1] = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_REGISTER)); B[0] = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_PUBLIC)); B[1] = (CAListBox_GetSelCount (hwndGrantees) >= 1); B[2] = (CAListBox_GetSelCount (hwndDBevents) >= 1); C[0] = !B[0] && B[1] && B[2] && (check [0] || check [1]); C[1] = B[0] && B[2] && (check [0] || check [1]); if (C[0] || C[1]) EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); else EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); if (B[0]) { CAListBox_ResetContent (hwndGrantees); EnableWindow (hwndGrantees, FALSE); } else EnableWindow (hwndGrantees, TRUE); }
static void EnableDisableOKButton (HWND hwnd) { HWND hwndGrantees = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_GRANTEES); HWND hwndProcedure = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_PROCEDURES); BOOL B [3]; BOOL C [2]; B[0] = Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_PUBLIC)); B[1] = (CAListBox_GetSelCount (hwndGrantees) >= 1); B[2] = (CAListBox_GetSelCount (hwndProcedure) >= 1); C[0] = !B[0] && B[1] && B[2]; C[1] = B[0] && B[2]; if (C[0] || C[1]) EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); else EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); if (B[0]) { CAListBox_ResetContent (hwndGrantees); EnableWindow (hwndGrantees, FALSE); } else EnableWindow (hwndGrantees, TRUE); }
static BOOL FillStructureFromControls (HWND hwnd, LPGRANTPARAMS lpgrant) { HWND hwndGrantees = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_GRANTEES); HWND hwndDBevents = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_DBEVENT); int max_item_number = CAListBox_GetSelCount (hwndDBevents); if (max_item_number >= 1) { lpgrant->lpobject = AddItemToListWithOwner (hwndDBevents); if (!lpgrant->lpobject) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT) IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } max_item_number = CAListBox_GetSelCount (hwndGrantees); if (max_item_number >= 1) { lpgrant->lpgrantee = AddItemToListQuoted (hwndGrantees); if (!lpgrant->lpgrantee) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); EndDialog (hwnd, FALSE); return FALSE; } } if (Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_USER))) lpgrant->GranteeType = OT_USER; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_GROUP))) lpgrant->GranteeType = OT_GROUP; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_ROLE))) lpgrant->GranteeType = OT_ROLE; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_PUBLIC))) { lpgrant->GranteeType = OT_PUBLIC; // Public FreeObjectList (lpgrant->lpgrantee); lpgrant->lpgrantee= NULL; lpgrant->lpgrantee = APublicUser (); if (!lpgrant->lpgrantee) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } lpgrant->Privileges [GRANT_RAISE] = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_RAISE)); lpgrant->Privileges [GRANT_REGISTER] = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_REGISTER)); lpgrant->grant_option = Button_GetCheck (GetDlgItem (hwnd, IDC_GRANT_DBEVENT_OPTION)); return TRUE; }
static void EnableDisableOKButton2 (HWND hwnd) { HWND hwndGrantees = GetDlgItem (hwnd, IDC_REVOKE_TABLE_GRANTEES); if (CAListBox_GetSelCount (hwndGrantees) >= 1) EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); else EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); }
static void EnableDisableOKButton (HWND hwnd) { if (Edit_GetTextLength (GetDlgItem (hwnd, IDC_STARTTIME)) == 0 || CAListBox_GetSelCount(GetDlgItem (hwnd, IDC_CDDSNUMBER)) == 0 || ComboBox_GetCurSel(GetDlgItem (hwnd, IDC_DBNUMBER)) == CB_ERR ) EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); else EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); }
static void EnableDisableOKButton (HWND hwnd) { HWND hwndUsers = GetDlgItem (hwnd, IDC_REFALARM_BYUSER ); HWND hwndTables = GetDlgItem (hwnd, IDC_REFALARM_ONTABLE); HWND hwndSuccess = GetDlgItem (hwnd, IDC_REFALARM_SUCCESS); HWND hwndFailure = GetDlgItem (hwnd, IDC_REFALARM_FAILURE); HWND hwndSelect = GetDlgItem (hwnd, IDC_REFALARM_SELECT); HWND hwndDelete = GetDlgItem (hwnd, IDC_REFALARM_DELETE); HWND hwndInsert = GetDlgItem (hwnd, IDC_REFALARM_INSERT); HWND hwndUpdate = GetDlgItem (hwnd, IDC_REFALARM_UPDATE); int table_sel_count = CAListBox_GetSelCount (hwndTables); int user_sel_count = CAListBox_GetSelCount (hwndUsers); BOOL rb = Button_GetCheck (hwndSuccess) || Button_GetCheck (hwndFailure); BOOL tb = Button_GetCheck (hwndSelect) || Button_GetCheck (hwndDelete) \ || Button_GetCheck (hwndInsert) || Button_GetCheck (hwndUpdate); if ((table_sel_count == 0) || (user_sel_count == 0) || (!tb) || (!rb)) EnableWindow (GetDlgItem (hwnd, IDOK), FALSE); else EnableWindow (GetDlgItem (hwnd, IDOK), TRUE); }
static BOOL FillStructureFromControls (HWND hwnd, LPGRANTPARAMS lpgrant) { int max_item_number; HWND hwndDatabases = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_DATABASES); HWND hwndGrantees = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_GRANTEES); HWND hwndProcedures= GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_PROCEDURES); max_item_number = CAListBox_GetSelCount (hwndProcedures); if (max_item_number >= 1) { lpgrant->lpobject = AddItemToList (hwndProcedures); if (!lpgrant->lpobject) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT) IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } max_item_number = CAListBox_GetSelCount (hwndGrantees); if (max_item_number >= 1) { lpgrant->lpgrantee = AddItemToList (hwndGrantees); if (!lpgrant->lpgrantee) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } if (Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_USER))) lpgrant->GranteeType = OT_USER; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_GROUP))) lpgrant->GranteeType = OT_GROUP; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_ROLE))) lpgrant->GranteeType = OT_ROLE; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_PUBLIC))) { lpgrant->GranteeType = OT_PUBLIC; // Public FreeObjectList (lpgrant->lpgrantee); lpgrant->lpgrantee = APublicUser (); if (!lpgrant->lpgrantee) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } if (lpgrant->ObjectType == OT_SEQUENCE) { lpgrant->grant_option = FALSE; lpgrant->Privileges[GRANT_NEXT_SEQUENCE] = TRUE; return TRUE; } lpgrant->grant_option = Button_GetCheck (GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_OPTION)); return TRUE; }
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { LPSECURITYALARMPARAMS lpsecurity = GetDlgProp (hwnd); HWND hwndUsers = GetDlgItem (hwnd, IDC_SALARM_BYUSER ); HWND hwndTables = GetDlgItem (hwnd, IDC_SALARM_ONTABLE ); HWND hwndName = GetDlgItem (hwnd, IDC_SALARM_NAME ); int idu; int i, n, idt; int ires; char szName [MAXOBJECTNAME]; switch (id) { case IDOK: if (!FillStructureFromControls (hwnd, lpsecurity)) break; // // Call the low level function to write data on disk // ires = DBAAddObject (GetVirtNodeName (GetCurMdiNodeHandle ()), OTLL_SECURITYALARM, (void *) lpsecurity ); if (ires != RES_SUCCESS) { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CREATE_SECURITY_FAILED, ires); break; } else EndDialog (hwnd, TRUE); FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); break; case IDCANCEL: EndDialog (hwnd, FALSE); FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); break; case IDC_SALARM_BYUSER: if (Edit_GetText (hwndName, szName, sizeof (szName)) != 0 && CAListBox_GetSelCount (hwndUsers) > 1) { idu=CAListBox_GetCurSel (hwndUsers); n = CAListBox_GetCount (hwndUsers); for (i=0; i<n; i++) CAListBox_SetSel (hwndUsers, FALSE, i); CAListBox_SetCurSel (hwndUsers, idu); CAListBox_SetSel (hwndUsers, TRUE, idu); //"Multiple auth-id is not allowed if the security alarm has a name." MessageBox(hwnd, ResourceString(IDS_ERR_USING_CHECKPOINT), NULL, MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL); EnableDisableOKButton (hwnd); } else if (CAListBox_GetSelCount (hwndUsers) > 1) Edit_Enable(hwndName,FALSE); else Edit_Enable(hwndName,TRUE); EnableDisableOKButton (hwnd); break; case IDC_SALARM_ONTABLE: if (codeNotify == CALBN_CHECKCHANGE) { idt = CAListBox_GetCurSel (hwndTables); n = CAListBox_GetCount (hwndTables); for (i=0; i<n; i++) CAListBox_SetSel (hwndTables, FALSE, i); CAListBox_SetCurSel (hwndTables, idt); CAListBox_SetSel (hwndTables, TRUE, idt); if (bNoDisplayMessageDB == FALSE) { int iret; //"Only one database can be checked. Previous database, if any, was unchecked.\nDon't display this message any more?" iret = MessageBox(hwnd, ResourceString(IDS_ERR_DATABASE_BE_CHECKED), NULL, MB_OKCANCEL | MB_ICONEXCLAMATION | MB_TASKMODAL); if (iret == IDOK) bNoDisplayMessageDB=TRUE; } } EnableDisableOKButton (hwnd); break; case IDC_SALARM_SUCCESS: case IDC_SALARM_FAILURE: case IDC_SALARM_SUCCESSFAILURE: case IDC_SALARM_SELECT: case IDC_SALARM_DELETE: case IDC_SALARM_INSERT: case IDC_SALARM_UPDATE: case IDC_SALARM_CONNECT: case IDC_SALARM_DISCONNECT: EnableDisableOKButton (hwnd); break; case IDC_SALARM_USER: if (Button_GetCheck (hwndCtl)) { CAListBox_ResetContent (hwndUsers); CAListBoxFillUsers (hwndUsers); EnableDisableOKButton (hwnd); } break; case IDC_SALARM_GROUP: if (Button_GetCheck (hwndCtl)) { CAListBox_ResetContent (hwndUsers); CAListBoxFillGroups (hwndUsers); EnableDisableOKButton (hwnd); } break; case IDC_SALARM_ROLE: if (Button_GetCheck (hwndCtl)) { CAListBox_ResetContent (hwndUsers); CAListBoxFillRoles (hwndUsers); EnableDisableOKButton (hwnd); } break; case IDC_SALARM_PUBLIC: if (Button_GetCheck (hwndCtl)) { CAListBox_ResetContent (hwndUsers); EnableDisableOKButton (hwnd); } break; case IDC_SALARM_DBEVENT: if (codeNotify == CBN_SELCHANGE) { char szItem [MAXOBJECTNAME]; ZEROINIT (szItem); ComboBox_GetText (hwndCtl, szItem, sizeof (szItem)); if (x_strcmp (szItem, szSecurityDBEvent) == 0) { lpsecurity->bDBEvent = FALSE; EnableControl (hwnd, FALSE); } else EnableControl (hwnd, TRUE); } break; } }
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { LPREVOKEPARAMS lprevoke = GetDlgProp (hwnd); HWND hwndGrantees = GetDlgItem (hwnd, IDC_REVOKE_TABLE_GRANTEES); switch (id) { case IDOK: { TCHAR tchNameObject[MAXOBJECTNAME]; int ires; int max_item_number; max_item_number = CAListBox_GetSelCount (hwndGrantees); if (max_item_number >= 1) { lprevoke->lpgrantee = AddItemToListQuoted (hwndGrantees); if (!lprevoke->lpgrantee) { ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); break; } } if (Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_USER))) lprevoke->GranteeType = OT_USER; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_GROUP))) lprevoke->GranteeType = OT_GROUP; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_ROLE))) lprevoke->GranteeType = OT_ROLE; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_PUBLIC))) { lprevoke->GranteeType = OT_PUBLIC; // Public FreeObjectList (lprevoke->lpgrantee); lprevoke->lpgrantee = NULL; lprevoke->lpgrantee = APublicUser (); if (!lprevoke->lpgrantee) { ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); break; } } lprevoke->grant_option = Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_GRANT_OPTION)); lprevoke->cascade = Button_GetCheck (GetDlgItem (hwnd, IDC_REVOKE_TABLE_CASCADE)); wsprintf(tchNameObject,"%s.%s",QuoteIfNeeded(lprevoke->PreselectObjectOwner),QuoteIfNeeded(lprevoke->PreselectObject)); lprevoke->lpobject = InsertTableName (tchNameObject); if (!lprevoke->lpobject) { FreeObjectList (lprevoke->lpobject); lprevoke->lpobject = NULL; ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); break; } ires = DBADropObject ( GetVirtNodeName ( GetCurMdiNodeHandle ()), OTLL_GRANT, (void *) lprevoke); if (ires != RES_SUCCESS) { FreeObjectList (lprevoke->lpgrantee); FreeObjectList (lprevoke->lpobject); lprevoke->lpobject = NULL; lprevoke->lpgrantee= NULL; switch (lprevoke->ObjectType) { case OT_TABLE: ErrorMessage ((UINT)IDS_E_REVOKE_TABLE_FAILED, ires); break; case OT_PROCEDURE: ErrorMessage ((UINT)IDS_E_REVOKE_PROCEDURE_FAILED, ires); break; case OT_DBEVENT: ErrorMessage ((UINT)IDS_E_REVOKE_DBEVENT_FAILED, ires); break; case OT_SEQUENCE: ErrorMessage ((UINT)IDS_E_REVOKE_SEQUENCE_FAILED, ires); break; } break; } else { EndDialog (hwnd, TRUE); } FreeObjectList (lprevoke->lpgrantee); FreeObjectList (lprevoke->lpobject); lprevoke->lpobject = NULL; lprevoke->lpgrantee= NULL; } break; case IDCANCEL: FreeObjectList (lprevoke->lpgrantee); FreeObjectList (lprevoke->lpobject); lprevoke->lpobject = NULL; lprevoke->lpgrantee= NULL; EndDialog (hwnd, FALSE); break; case IDC_REVOKE_TABLE_USER: CAListBox_ResetContent (hwndGrantees); lprevoke->GranteeType = OT_USER; FillGrantedUsers (hwndGrantees, lprevoke, HaveBeenGranted); EnableDisableOKButton (hwnd); break; case IDC_REVOKE_TABLE_GROUP: CAListBox_ResetContent (hwndGrantees); lprevoke->GranteeType = OT_GROUP; FillGrantedUsers (hwndGrantees, lprevoke, HaveBeenGranted); EnableDisableOKButton (hwnd); break; case IDC_REVOKE_TABLE_ROLE: CAListBox_ResetContent (hwndGrantees); lprevoke->GranteeType = OT_ROLE; FillGrantedUsers (hwndGrantees, lprevoke, HaveBeenGranted); EnableDisableOKButton (hwnd); break; case IDC_REVOKE_TABLE_PUBLIC: CAListBox_ResetContent (hwndGrantees); EnableDisableOKButton (hwnd); break; case IDC_REVOKE_TABLE_GRANTEES: if (lprevoke->GranteeType != OT_UNKNOWN) EnableDisableOKButton (hwnd); else EnableDisableOKButton2 (hwnd); break; } }
static void OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { switch (id) { case IDOK: { int nIndex; int nCount; int nLast=0; int max; int i; int first=0; UCHAR buf[MAXOBJECTNAME]; HWND hwndCdds = GetDlgItem (hwnd, IDC_CDDSNUMBER); HWND hwndDbNumber = GetDlgItem (hwnd, IDC_DBNUMBER); HWND hwndStartTime= GetDlgItem (hwnd, IDC_STARTTIME); LPRECONCILER lpreconciler = GetDlgProp(hwnd); // fill structure with CDDS values nCount = 0; ZEROINIT (lpreconciler->CddsNo); nCount = CAListBox_GetSelCount(hwndCdds); max = CAListBox_GetCount(hwndCdds); if (nCount != max) { for (i=0;i<max;i++) { if (CAListBox_GetSel (hwndCdds, i)) { char szName[MAX_DBNAME_LEN]; CAListBox_GetText(hwndCdds, i, szName); if (first==0 && nCount>1) { x_strcat(lpreconciler->CddsNo,"'("); first=1; } x_strcat(lpreconciler->CddsNo,szName); nLast++; if ( nLast == nCount && nCount>1 ) x_strcat(lpreconciler->CddsNo,")'"); else { if (nCount>1) x_strcat(lpreconciler->CddsNo,","); } } } } else x_strcat(lpreconciler->CddsNo,"all "); // Fill structure with Targetdbnumber nIndex=ComboBox_GetCurSel(hwndDbNumber); ComboBox_GetLBText(hwndDbNumber, nIndex, buf); GetIntFromStartofString( buf, lpreconciler->TarGetDbNumber); //sscanf (buf,"%s",lpreconciler->TarGetDbNumber ); //Fill structure with the Start time Edit_GetText(hwndStartTime, buf, MAXOBJECTNAME ); x_strcpy (lpreconciler->StarTime,buf); if (SendCommand(hwnd)==TRUE) EndDialog(hwnd, TRUE); break; } case IDCANCEL: EndDialog(hwnd, FALSE); break; case IDC_DBNUMBER: if ( codeNotify == CBN_SELCHANGE) EnableDisableOKButton (hwnd); break; case IDC_CDDSNUMBER: if ( codeNotify == CALBN_CHECKCHANGE || codeNotify == CALBN_SELCHANGE || codeNotify == CALBN_KILLFOCUS ) EnableDisableOKButton (hwnd); break; case IDC_STARTTIME: if (codeNotify == EN_CHANGE) EnableDisableOKButton (hwnd); break; } }