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 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 BOOL OccupyCddsControl (HWND hwnd) /* Function: Fills the CDDS number in list box. Parameters: hwnd - Handle to the dialog window. Returns: TRUE if successful. */ { int hNode; UCHAR buffilter[MAXOBJECTNAME]; UCHAR CddsName[MAXOBJECTNAME]; LPUCHAR parentstrings [MAXPLEVEL]; BOOL bSystem=FALSE; int ListErr; int err; BOOL bRetVal = TRUE; HWND hwndCtl = GetDlgItem (hwnd, IDC_CDDSNUMBER); LPRECONCILER lpdb = GetDlgProp(hwnd); ZEROINIT (CddsName); hNode = GetCurMdiNodeHandle(); parentstrings [0] = lpdb->DBName; CAListBox_ResetContent(hwndCtl); err = DOMGetFirstObject(hNode, OT_REPLIC_CDDS, 1, parentstrings, bSystem, NULL, CddsName, NULL, NULL ); while (err == RES_SUCCESS) { ListErr=CAListBox_AddString(hwndCtl, CddsName ); if (ListErr == LB_ERR || ListErr == LB_ERRSPACE) bRetVal=FALSE; err = DOMGetNextObject (CddsName, buffilter, NULL); } return bRetVal; }
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { LPGRANTPARAMS lpgrant = GetDlgProp (hwnd); HWND hwndDatabases = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_DATABASES); HWND hwndGrantees = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_GRANTEES); HWND hwndProcedures = GetDlgItem (hwnd, IDC_GNREF_PROCEDURE_PROCEDURES); int ires; switch (id) { case IDOK: if (!FillStructureFromControls (hwnd, lpgrant)) break; ires = DBAAddObject (GetVirtNodeName ( GetCurMdiNodeHandle ()), OTLL_GRANT, (void *) lpgrant); if (ires != RES_SUCCESS) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_GRANT_PROCEDURE_FAILED, ires); break; } else EndDialog (hwnd, TRUE); FreeAttachedPointers (lpgrant, OTLL_GRANT); break; case IDCANCEL: FreeAttachedPointers (lpgrant, OTLL_GRANT); EndDialog (hwnd, FALSE); break; case IDC_GNREF_PROCEDURE_PROCEDURES: case IDC_GNREF_PROCEDURE_GRANTEES: EnableDisableOKButton (hwnd); break; case IDC_GNREF_PROCEDURE_USER: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_USER); EnableDisableOKButton (hwnd); break; case IDC_GNREF_PROCEDURE_GROUP: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_GROUP); EnableDisableOKButton (hwnd); break; case IDC_GNREF_PROCEDURE_ROLE: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_ROLE); EnableDisableOKButton (hwnd); break; case IDC_GNREF_PROCEDURE_PUBLIC: CAListBox_ResetContent (hwndGrantees); EnableDisableOKButton (hwnd); break; case IDC_GNREF_PROCEDURE_DATABASES: { char selString [MAXOBJECTNAME+1]; if (codeNotify == CBN_SELCHANGE) { CAListBoxDestroyItemData (hwndProcedures); CAListBox_ResetContent (hwndProcedures); ComboBox_GetText (hwndDatabases, selString, sizeof (selString)); x_strcpy (lpgrant->DBName, selString); if (lpgrant->ObjectType == OT_PROCEDURE) { if (!CAListBoxFillProcedures (hwndProcedures, selString)) CAListBoxDestroyItemData (hwndProcedures); } else { if (!CAListBoxFillSequences (hwndProcedures, lpgrant->DBName)) CAListBoxDestroyItemData (hwndProcedures); } } EnableDisableOKButton (hwnd); } break; } }
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) { LPGRANTPARAMS lpgrant = GetDlgProp (hwnd); HWND hwndGrantees = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_GRANTEES); HWND hwndDBevents = GetDlgItem (hwnd, IDC_GRANT_DBEVENT_DBEVENT); int ires; switch (id) { case IDOK: if (!FillStructureFromControls (hwnd, lpgrant)) break; ires = DBAAddObject (GetVirtNodeName (GetCurMdiNodeHandle ()), OTLL_GRANT, (void *) lpgrant); if (ires != RES_SUCCESS) { FreeAttachedPointers (lpgrant, OTLL_GRANT); ErrorMessage ((UINT)IDS_E_GRANT_DBEVENT_FAILED, RES_ERR); break; } else EndDialog (hwnd, TRUE); FreeAttachedPointers (lpgrant, OTLL_GRANT); break; case IDCANCEL: EndDialog (hwnd, FALSE); break; case IDC_GRANT_DBEVENT_RAISE: case IDC_GRANT_DBEVENT_REGISTER: EnableDisableOKButton (hwnd); break; case IDC_GRANT_DBEVENT_GRANTEES: case IDC_GRANT_DBEVENT_DBEVENT: EnableDisableOKButton (hwnd); break; case IDC_GRANT_DBEVENT_USER: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_USER); EnableDisableOKButton (hwnd); break; case IDC_GRANT_DBEVENT_GROUP: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_GROUP); EnableDisableOKButton (hwnd); break; case IDC_GRANT_DBEVENT_ROLE: CAListBox_ResetContent (hwndGrantees); FillGrantees (hwndGrantees, OT_ROLE); EnableDisableOKButton (hwnd); break; case IDC_GRANT_DBEVENT_PUBLIC: CAListBox_ResetContent (hwndGrantees); EnableDisableOKButton (hwnd); break; } }
static void OnCommand (HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) { LPSECURITYALARMPARAMS lpsecurity = GetDlgProp (hwnd); int ires; 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: FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); EndDialog (hwnd, FALSE); break; case IDC_REFALARM_BYUSER: EnableDisableOKButton (hwnd); break; case IDC_REFALARM_DATABASE: { char szDatabaseName [MAXOBJECTNAME]; HWND hwndDatabase = GetDlgItem (hwnd, IDC_REFALARM_DATABASE); HWND hwndTables = GetDlgItem (hwnd, IDC_REFALARM_ONTABLE); switch (codeNotify) { case CBN_SELCHANGE: ComboBox_GetText (hwndDatabase, szDatabaseName, sizeof (szDatabaseName)); if (x_strlen (szDatabaseName) > 0) { x_strcpy (lpsecurity->DBName, szDatabaseName); CAListBoxDestroyItemData (hwndTables); CAListBox_ResetContent (hwndTables); if (!CAListBoxFillTables (hwndTables, lpsecurity->DBName, FALSE)) CAListBoxDestroyItemData (hwndTables); } break; } EnableDisableOKButton (hwnd); } break; case IDC_REFALARM_ONTABLE: EnableDisableOKButton (hwnd); break; case IDC_REFALARM_SUCCESS: case IDC_REFALARM_FAILURE: case IDC_REFALARM_SELECT: case IDC_REFALARM_DELETE: case IDC_REFALARM_INSERT: case IDC_REFALARM_UPDATE: EnableDisableOKButton (hwnd); break; } }