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 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) { 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; } }