void KACLListView::setDefaultACL( const KACL &acl ) { if ( !acl.isValid() ) return; m_defaultACL = acl; fillItemsFromACL( m_defaultACL, true ); calculateEffectiveRights(); }
void KACLListView::slotEditEntry() { QTreeWidgetItem * current = currentItem(); if ( !current ) return; KACLListViewItem *item = static_cast<KACLListViewItem*>( current ); int allowedTypes = item->type | NamedUser | NamedGroup; bool itemWasMask = item->type == Mask; if ( !m_hasMask || itemWasMask ) allowedTypes |= Mask; int allowedDefaultTypes = item->type | NamedUser | NamedGroup; if ( !findDefaultItemByType( Mask ) ) allowedDefaultTypes |= Mask; if ( !hasDefaultEntries() ) allowedDefaultTypes |= User | Group; EditACLEntryDialog dlg( this, item, allowedUsers( false, item ), allowedGroups( false, item ), allowedUsers( true, item ), allowedGroups( true, item ), allowedTypes, allowedDefaultTypes, m_allowDefaults ); dlg.exec(); if ( itemWasMask && item->type != Mask ) { m_hasMask = false; m_mask = 0; } if ( !itemWasMask && item->type == Mask ) { m_mask = item->value; m_hasMask = true; } calculateEffectiveRights(); sortItems( sortColumn(), Qt::AscendingOrder ); }
void KACLListView::slotAddEntry() { int allowedTypes = NamedUser | NamedGroup; if ( !m_hasMask ) allowedTypes |= Mask; int allowedDefaultTypes = NamedUser | NamedGroup; if ( !findDefaultItemByType( Mask ) ) allowedDefaultTypes |= Mask; if ( !hasDefaultEntries() ) allowedDefaultTypes |= User | Group; EditACLEntryDialog dlg( this, 0, allowedUsers( false ), allowedGroups( false ), allowedUsers( true ), allowedGroups( true ), allowedTypes, allowedDefaultTypes, m_allowDefaults ); dlg.exec(); KACLListViewItem *item = dlg.item(); if ( !item ) return; // canceled if ( item->type == Mask && !item->isDefault ) { m_hasMask = true; m_mask = item->value; } if ( item->isDefault && !hasDefaultEntries() ) { // first default entry, fill in what is needed if ( item->type != User ) { unsigned short v = findDefaultItemByType( User )->value; new KACLListViewItem( this, User, v, true ); } if ( item->type != Group ) { unsigned short v = findDefaultItemByType( Group )->value; new KACLListViewItem( this, Group, v, true ); } if ( item->type != Others ) { unsigned short v = findDefaultItemByType( Others )->value; new KACLListViewItem( this, Others, v, true ); } } const KACLListViewItem *defaultMaskItem = findDefaultItemByType( Mask ); if ( item->isDefault && !defaultMaskItem ) { unsigned short v = calculateMaskValue( true ); new KACLListViewItem( this, Mask, v, true ); } if ( !item->isDefault && !m_hasMask && ( item->type == Group || item->type == NamedUser || item->type == NamedGroup ) ) { // auto-add a mask entry unsigned short v = calculateMaskValue( false ); new KACLListViewItem( this, Mask, v, false ); m_hasMask = true; m_mask = v; } calculateEffectiveRights(); sortItems( sortColumn(), Qt::AscendingOrder ); setCurrentItem( item ); // QTreeWidget doesn't seem to emit, in this case, and we need to update // the buttons... if ( topLevelItemCount() == 1 ) emit currentItemChanged( item, item ); }
void KACLListView::setACL( const KACL &acl ) { if ( !acl.isValid() ) return; // Remove any entries left over from displaying a previous ACL m_ACL = acl; fillItemsFromACL( m_ACL ); m_mask = acl.maskPermissions( m_hasMask ); calculateEffectiveRights(); }
void KACLListView::slotRemoveEntry() { QListViewItemIterator it(this, QListViewItemIterator::Selected); while(it.current()) { KACLListViewItem *item = static_cast< KACLListViewItem * >(it.current()); ++it; /* First check if it's a mask entry and if so, make sure that there is * either no name user or group entry, which means the mask can be * removed, or don't remove it, but reset it. That is allowed. */ if(item->type == Mask) { bool itemWasDefault = item->isDefault; if(!itemWasDefault && maskCanBeDeleted()) { m_hasMask = false; m_mask = 0; delete item; } else if(itemWasDefault && defaultMaskCanBeDeleted()) { delete item; } else { item->value = 0; item->repaint(); } if(!itemWasDefault) calculateEffectiveRights(); } else { // for the base permissions, disable them, which is what libacl does if(!item->isDefault && (item->type == User || item->type == Group || item->type == Others)) { item->value = 0; item->repaint(); } else { delete item; } } } }
void KACLListView::setMaskPartialPermissions( acl_perm_t /*maskPartialPerms*/ ) { //m_pMaskEntry->m_partialPerms = maskPartialPerms; calculateEffectiveRights(); }
void KACLListView::setMaskPermissions( unsigned short maskPerms ) { m_mask = maskPerms; calculateEffectiveRights(); }