void CxDlgObjectComment::GenerateSyntaxComment4Object (CString &csText) { // // Comment on Object if (m_iCurObjType == OT_TABLE || m_iCurObjType == OT_VIEW) { csText.Format("comment on table %s.%s is '%s'", (LPTSTR)QuoteIfNeeded(m_csObjectOwner), (LPTSTR)QuoteIfNeeded(m_csObjectName), (LPCTSTR)m_csCommentObject); } }
static BOOL FillStructureFromControls (HWND hwnd, LPSECURITYALARMPARAMS lpsecurity) { char buf [MAXOBJECTNAME]; // char buffowner [MAXOBJECTNAME]; // char bufftable [MAXOBJECTNAME]; char szDBE [MAXOBJECTNAME]; char szName [MAXOBJECTNAME]; LPCHECKEDOBJECTS obj; LPCHECKEDOBJECTS list = NULL; int i, max_database_number, checked; HWND hwndDB = GetDlgItem (hwnd, IDC_SALARM_ONTABLE); HWND hwndUsers = GetDlgItem (hwnd, IDC_SALARM_BYUSER ); HWND hwndSuccess = GetDlgItem (hwnd, IDC_SALARM_SUCCESS); HWND hwndFailure = GetDlgItem (hwnd, IDC_SALARM_FAILURE); HWND hwndSelect = GetDlgItem (hwnd, IDC_SALARM_SELECT); HWND hwndDelete = GetDlgItem (hwnd, IDC_SALARM_DELETE); HWND hwndInsert = GetDlgItem (hwnd, IDC_SALARM_INSERT); HWND hwndUpdate = GetDlgItem (hwnd, IDC_SALARM_UPDATE); HWND hwndConnect = GetDlgItem (hwnd, IDC_SALARM_CONNECT); HWND hwndDisconnect = GetDlgItem (hwnd, IDC_SALARM_DISCONNECT); HWND hwndDBE = GetDlgItem (hwnd, IDC_SALARM_DBEVENT); HWND hwndDBEText = GetDlgItem (hwnd, IDC_SALARM_DBEVENT_TEXT); HWND hwndName = GetDlgItem (hwnd, IDC_SALARM_NAME); x_strcpy (lpsecurity->DBName, "iidbdb"); ZEROINIT (szName); Edit_GetText (hwndName, szName, sizeof (szName)); x_strcpy (lpsecurity->ObjectName, szName); lpsecurity->bsuccfail [SECALARMSUCCESS] = Button_GetCheck (hwndSuccess); lpsecurity->bsuccfail [SECALARMFAILURE] = Button_GetCheck (hwndFailure); // // Get selection from // toggle buttons (Select, Delete, Insert, Update) // lpsecurity->baccesstype [SECALARMSEL] = Button_GetCheck (hwndSelect); lpsecurity->baccesstype [SECALARMDEL] = Button_GetCheck (hwndDelete); lpsecurity->baccesstype [SECALARMINS] = Button_GetCheck (hwndInsert); lpsecurity->baccesstype [SECALARMUPD] = Button_GetCheck (hwndUpdate); lpsecurity->baccesstype [SECALARMCONNECT] = Button_GetCheck (hwndConnect ); lpsecurity->baccesstype [SECALARMDISCONN] = Button_GetCheck (hwndDisconnect); // // Get the names of users that have been checked and // insert into the list // if (Button_GetCheck (GetDlgItem (hwnd, IDC_SALARM_USER))) lpsecurity->iAuthIdType = OT_USER; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_SALARM_GROUP))) lpsecurity->iAuthIdType = OT_GROUP; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_SALARM_ROLE))) lpsecurity->iAuthIdType = OT_ROLE; else if (Button_GetCheck (GetDlgItem (hwnd, IDC_SALARM_PUBLIC))) lpsecurity->iAuthIdType = OT_PUBLIC; else lpsecurity->iAuthIdType = OT_USER; max_database_number = CAListBox_GetCount (hwndUsers); if (Button_GetCheck (GetDlgItem (hwnd, IDC_SALARM_PUBLIC))) { obj = ESL_AllocMem (sizeof (CHECKEDOBJECTS)); if (!obj) { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } else { x_strcpy (obj->dbname, lppublicsysstring()); obj->bchecked = TRUE; list = AddCheckedObject (list, obj); } } for (i = 0; i < max_database_number; i++) { checked = CAListBox_GetSel (hwndUsers, i); if (checked == 1) { CAListBox_GetText (hwndUsers, i, buf); obj = ESL_AllocMem (sizeof (CHECKEDOBJECTS)); if (!obj) { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } else { if (x_strcmp (buf, lppublicdispstring()) == 0) x_strcpy (obj->dbname, lppublicsysstring()); else x_strcpy (obj->dbname, QuoteIfNeeded(buf)); obj->bchecked = TRUE; list = AddCheckedObject (list, obj); } } } lpsecurity->lpfirstUser = list; // // Get the names of Database that have been checked and // insert into the list // max_database_number = CAListBox_GetCount (hwndDB); list = NULL; for (i=0; i<max_database_number; i++) { checked = CAListBox_GetSel (hwndDB, i); if (checked) { CAListBox_GetText (hwndDB, i, buf); obj = ESL_AllocMem (sizeof (CHECKEDOBJECTS)); if (!obj) { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } else { x_strcpy (obj->dbname, buf); obj->bchecked = TRUE; list = AddCheckedObject (list, obj); } } } lpsecurity->lpfirstTable = list; ComboBox_GetText (hwndDBE, szDBE, sizeof (szDBE)); if ((x_strlen (szDBE) > 0 ) && (x_strcmp (szDBE, szSecurityDBEvent) != 0)) { char szOwner [MAXOBJECTNAME]; char szAll [MAXOBJECTNAME]; int len, nSel; nSel = ComboBox_GetCurSel (hwndDBE); x_strcpy (szOwner, (char *) ComboBox_GetItemData (hwndDBE, nSel)); StringWithOwner (szDBE, szOwner, szAll); x_strcpy (lpsecurity->DBEvent, szAll); len = Edit_GetTextLength (hwndDBEText); if (len > 0) { lpsecurity->lpDBEventText = ESL_AllocMem ((len*sizeof(TCHAR)) + sizeof(TCHAR)); if (lpsecurity->lpDBEventText) { Edit_GetText (hwndDBEText, lpsecurity->lpDBEventText, len+1); // Emb 26/06/97: +1 was missing --> lost character if (EscapedSimpleQuote(&lpsecurity->lpDBEventText) == RES_ERR) { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } else { FreeAttachedPointers (lpsecurity, OTLL_SECURITYALARM); ErrorMessage ((UINT)IDS_E_CANNOT_ALLOCATE_MEMORY, RES_ERR); return FALSE; } } lpsecurity->bDBEvent = TRUE; } else if (lpsecurity->lpDBEventText) { ESL_FreeMem (lpsecurity->lpDBEventText); lpsecurity->lpDBEventText = NULL; } 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; } }
void CxDlgObjectComment::OnOK() { CString csTempo,csNameCol,csSyntaxObject,csVNodeName,csSQLSyntax; LPCOMMENTCOLUMN lpCommentCol; LPSTRINGLIST lpStrList = NULL; BOOL bGenerate; int i,iret,nCount = m_cListCtrl.GetItemCount(); csVNodeName = (LPTSTR)GetVirtNodeName(m_nNodeHandle); csSyntaxObject.Empty(); m_cListCtrl.HideProperty(TRUE); m_cEditTableComment.GetWindowText(m_csCommentObject); if (!m_tcObjComment && !m_csCommentObject.IsEmpty()) // new comment on general object GenerateSyntaxComment4Object(csSyntaxObject); else if (m_tcObjComment && (x_strcmp(m_csCommentObject,m_tcObjComment)!=0) ) // comment exist GenerateSyntaxComment4Object(csSyntaxObject); for (i=0; i<nCount; i++) { csSQLSyntax.Empty(); bGenerate = FALSE; csNameCol = m_cListCtrl.GetItemText (i,0); csTempo = m_cListCtrl.GetItemText (i,1); lpCommentCol = FindCurrentColumn(csNameCol); ASSERT(lpCommentCol != NULL); if (lpCommentCol->lpszComment) { if (x_strcmp(lpCommentCol->lpszComment,(LPTSTR)(LPCTSTR)csTempo)!=0) bGenerate = TRUE; } else { if (!csTempo.IsEmpty()) bGenerate = TRUE; } if (bGenerate) { csSQLSyntax.Format("comment on column %s.%s.%s is '%s'", QuoteIfNeeded((LPTSTR)(LPCTSTR)m_csObjectOwner), QuoteIfNeeded((LPTSTR)(LPCTSTR)m_csObjectName), QuoteIfNeeded((LPTSTR)lpCommentCol->szColumnName), (LPCTSTR)csTempo); lpStrList = StringList_Add (lpStrList, (LPTSTR)(LPCTSTR)csSQLSyntax); } } // execute the SQL statements iret = VDBA20xGenCommentObject ( (LPSTR)(LPCTSTR)csVNodeName,(LPSTR)(LPCTSTR)m_csDBName, (LPSTR)(LPCTSTR)csSyntaxObject, lpStrList); if (lpStrList) lpStrList = StringList_Done (lpStrList); if (iret != RES_SUCCESS) { ErrorMessage ((UINT) IDS_E_COMMENT_ON_FAILED, RES_ERR); return; } CDialog::OnOK(); }