34 #include "folderdiaacltab.h"
36 #include "kmfolderimap.h"
37 #include "kmfoldercachedimap.h"
38 #include "kmacctcachedimap.h"
41 #include <addressesdialog.h>
42 #include <tdeabc/addresseelist.h>
43 #ifdef TDEPIM_NEW_DISTRLISTS
44 #include <libtdepim/distributionlist.h>
46 #include <tdeabc/distributionlist.h>
48 #include <tdeabc/stdaddressbook.h>
49 #include <kaddrbook.h>
50 #include <kpushbutton.h>
52 #include <tdelocale.h>
57 #include <tqvbuttongroup.h>
58 #include <tqwidgetstack.h>
59 #include <tqradiobutton.h>
60 #include <tqwhatsthis.h>
63 #include <tdemessagebox.h>
65 using namespace KMail;
69 #define I18N_NOOP2( comment,x ) x
74 unsigned int permissions;
75 const char* userString;
76 } standardPermissions[] = {
77 { 0, I18N_NOOP2(
"Permissions",
"None" ) },
78 { ACLJobs::List | ACLJobs::Read | ACLJobs::WriteSeenFlag, I18N_NOOP2(
"Permissions",
"Read" ) },
79 { ACLJobs::List | ACLJobs::Read | ACLJobs::WriteSeenFlag | ACLJobs::Insert | ACLJobs::Post, I18N_NOOP2(
"Permissions",
"Append" ) },
80 { ACLJobs::AllWrite, I18N_NOOP2(
"Permissions",
"Write" ) },
81 { ACLJobs::All, I18N_NOOP2(
"Permissions",
"All" ) }
85 KMail::ACLEntryDialog::ACLEntryDialog( IMAPUserIdFormat userIdFormat,
const TQString& caption, TQWidget* parent,
const char* name )
86 : KDialogBase( parent, name, true , caption,
87 KDialogBase::
Ok|KDialogBase::Cancel, KDialogBase::
Ok, true )
88 , mUserIdFormat( userIdFormat )
90 TQWidget *page =
new TQWidget(
this );
92 TQGridLayout *topLayout =
new TQGridLayout( page, 4 , 3 , 0, spacingHint() );
94 TQLabel *label =
new TQLabel( i18n(
"&User identifier:" ), page );
95 topLayout->addWidget( label, 0, 0 );
97 mUserIdLineEdit =
new KLineEdit( page );
98 topLayout->addWidget( mUserIdLineEdit, 0, 1 );
99 label->setBuddy( mUserIdLineEdit );
100 TQWhatsThis::add( mUserIdLineEdit, i18n(
"The User Identifier is the login of the user on the IMAP server. This can be a simple user name or the full email address of the user; the login for your own account on the server will tell you which one it is." ) );
102 TQPushButton* kabBtn =
new TQPushButton( i18n(
"Se&lect..." ), page );
103 topLayout->addWidget( kabBtn, 0, 2 );
105 mButtonGroup =
new TQVButtonGroup( i18n(
"Permissions" ), page );
106 topLayout->addMultiCellWidget( mButtonGroup, 1, 1, 0, 2 );
108 for (
unsigned int i = 0;
109 i <
sizeof( standardPermissions ) /
sizeof( *standardPermissions );
111 TQRadioButton* cb =
new TQRadioButton( i18n(
"Permissions", standardPermissions[i].userString ), mButtonGroup );
113 mButtonGroup->insert( cb, standardPermissions[i].permissions );
115 topLayout->setRowStretch(2, 10);
117 TQLabel *noteLabel =
new TQLabel( i18n(
"<b>Note: </b>Renaming requires write permissions on the parent folder." ), page );
118 topLayout->addMultiCellWidget( noteLabel, 2, 2, 0, 2 );
120 connect( mUserIdLineEdit, TQ_SIGNAL( textChanged(
const TQString& ) ), TQ_SLOT( slotChanged() ) );
121 connect( kabBtn, TQ_SIGNAL( clicked() ), TQ_SLOT( slotSelectAddresses() ) );
122 connect( mButtonGroup, TQ_SIGNAL( clicked(
int ) ), TQ_SLOT( slotChanged() ) );
123 enableButtonOK(
false );
125 mUserIdLineEdit->setFocus();
127 incInitialSize( TQSize( 200, 0 ) );
130 void KMail::ACLEntryDialog::slotChanged()
132 enableButtonOK( !mUserIdLineEdit->text().isEmpty() && mButtonGroup->selected() != 0 );
135 static TQString addresseeToUserId(
const TDEABC::Addressee& addr, IMAPUserIdFormat userIdFormat )
137 TQString email = addr.preferredEmail();
138 if ( userIdFormat == FullEmail )
141 email.truncate( email.find(
'@' ) );
146 void KMail::ACLEntryDialog::slotSelectAddresses()
148 KPIM::AddressesDialog dlg(
this );
149 dlg.setShowCC(
false );
150 dlg.setShowBCC(
false );
151 if ( mUserIdFormat == FullEmail )
152 dlg.setSelectedTo( userIds() );
153 if ( dlg.exec() != TQDialog::Accepted )
156 const TQStringList distrLists = dlg.toDistributionLists();
157 TQString txt = distrLists.join(
", " );
158 const TDEABC::Addressee::List lst = dlg.toAddresses();
159 if ( !lst.isEmpty() ) {
160 for( TQValueList<TDEABC::Addressee>::ConstIterator it = lst.begin(); it != lst.end(); ++it ) {
161 if ( !txt.isEmpty() )
163 txt += addresseeToUserId( *it, mUserIdFormat );
166 mUserIdLineEdit->setText( txt );
169 void KMail::ACLEntryDialog::setValues(
const TQString& userId,
unsigned int permissions )
171 mUserIdLineEdit->setText( userId );
172 mButtonGroup->setButton( permissions );
173 enableButtonOK( !userId.isEmpty() );
176 TQString KMail::ACLEntryDialog::userId()
const
178 return mUserIdLineEdit->text();
181 TQStringList KMail::ACLEntryDialog::userIds()
const
183 return KPIM::splitEmailAddrList( mUserIdLineEdit->text() );
186 unsigned int KMail::ACLEntryDialog::permissions()
const
188 return mButtonGroup->selectedId();
197 class KMail::FolderDiaACLTab::ListViewItem :
public TDEListViewItem
200 ListViewItem( TQListView* listview )
201 : TDEListViewItem( listview, listview->lastItem() ),
202 mModified( false ), mNew( false ) {}
205 void save( ACLList& list,
206 #ifdef TDEPIM_NEW_DISTRLISTS
207 TDEABC::AddressBook* abook,
209 TDEABC::DistributionListManager& manager,
211 IMAPUserIdFormat userIdFormat );
213 TQString userId()
const {
return text( 0 ); }
214 void setUserId(
const TQString& userId ) { setText( 0, userId ); }
216 unsigned int permissions()
const {
return mPermissions; }
217 void setPermissions(
unsigned int permissions );
219 bool isModified()
const {
return mModified; }
220 void setModified(
bool b ) { mModified = b; }
224 bool isNew()
const {
return mNew; }
225 void setNew(
bool b ) { mNew = b; }
228 unsigned int mPermissions;
229 TQString mInternalRightsList;
235 static TQString permissionsToUserString(
unsigned int permissions,
const TQString& internalRightsList )
237 for (
unsigned int i = 0;
238 i <
sizeof( standardPermissions ) /
sizeof( *standardPermissions );
240 if ( permissions == standardPermissions[i].permissions )
241 return i18n(
"Permissions", standardPermissions[i].userString );
243 if ( internalRightsList.isEmpty() )
244 return i18n(
"Custom Permissions" );
246 return i18n(
"Custom Permissions (%1)" ).arg( internalRightsList );
249 void KMail::FolderDiaACLTab::ListViewItem::setPermissions(
unsigned int permissions )
251 mPermissions = permissions;
252 setText( 1, permissionsToUserString( permissions, TQString() ) );
255 void KMail::FolderDiaACLTab::ListViewItem::load(
const ACLListEntry& entry )
261 if ( entry.userId.contains(
' ' ) )
262 kdWarning(5006) <<
"Userid contains a space!!! '" << entry.userId <<
"'" << endl;
264 setUserId( entry.userId );
271 void KMail::FolderDiaACLTab::ListViewItem::save( ACLList& aclList,
272 #ifdef TDEPIM_NEW_DISTRLISTS
273 TDEABC::AddressBook* addressBook,
275 TDEABC::DistributionListManager& manager,
277 IMAPUserIdFormat userIdFormat )
280 #ifdef TDEPIM_NEW_DISTRLISTS
281 KPIM::DistributionList list = KPIM::DistributionList::findByName( addressBook, userId(),
false );
282 if ( !list.isEmpty() ) {
283 Q_ASSERT( mModified );
284 KPIM::DistributionList::Entry::List entryList = list.entries(addressBook);
285 KPIM::DistributionList::Entry::List::ConstIterator it;
289 TDEABC::DistributionList* list = manager.list( userId() );
291 Q_ASSERT( mModified );
292 TDEABC::DistributionList::Entry::List entryList = list->entries();
293 TDEABC::DistributionList::Entry::List::ConstIterator it;
295 for( it = entryList.begin(); it != entryList.end(); ++it ) {
296 TQString email = (*it).email;
297 if ( email.isEmpty() )
298 email = addresseeToUserId( (*it).addressee, userIdFormat );
301 aclList.append( entry );
304 ACLListEntry entry( userId(), mInternalRightsList, mPermissions );
309 aclList.append( entry );
315 KMail::FolderDiaACLTab::FolderDiaACLTab(
KMFolderDialog* dlg, TQWidget* parent,
const char* name )
321 mChanged( false ), mAccepting( false ), mSaving( false )
323 TQVBoxLayout* topLayout =
new TQVBoxLayout(
this );
326 mStack =
new TQWidgetStack(
this );
327 topLayout->addWidget( mStack );
329 mLabel =
new TQLabel( mStack );
330 mLabel->setAlignment( AlignHCenter | AlignVCenter | WordBreak );
331 mStack->addWidget( mLabel );
333 mACLWidget =
new TQHBox( mStack );
334 mACLWidget->setSpacing( KDialog::spacingHint() );
335 mListView =
new TDEListView( mACLWidget );
336 mListView->setAllColumnsShowFocus(
true );
337 mStack->addWidget( mACLWidget );
338 mListView->addColumn( i18n(
"User Id" ) );
339 mListView->addColumn( i18n(
"Permissions" ) );
341 connect( mListView, TQ_SIGNAL(doubleClicked(TQListViewItem*,
const TQPoint&,
int)),
342 TQ_SLOT(slotEditACL(TQListViewItem*)) );
343 connect( mListView, TQ_SIGNAL(returnPressed(TQListViewItem*)),
344 TQ_SLOT(slotEditACL(TQListViewItem*)) );
345 connect( mListView, TQ_SIGNAL(currentChanged(TQListViewItem*)),
346 TQ_SLOT(slotSelectionChanged(TQListViewItem*)) );
348 TQVBox* buttonBox =
new TQVBox( mACLWidget );
349 buttonBox->setSpacing( KDialog::spacingHint() );
350 mAddACL =
new KPushButton( i18n(
"Add Entry..." ), buttonBox );
351 mEditACL =
new KPushButton( i18n(
"Modify Entry..." ), buttonBox );
352 mRemoveACL =
new KPushButton( i18n(
"Remove Entry" ), buttonBox );
353 TQWidget *spacer =
new TQWidget( buttonBox );
354 spacer->setSizePolicy( TQSizePolicy::Minimum, TQSizePolicy::Expanding );
356 connect( mAddACL, TQ_SIGNAL( clicked() ), TQ_SLOT( slotAddACL() ) );
357 connect( mEditACL, TQ_SIGNAL( clicked() ), TQ_SLOT( slotEditACL() ) );
358 connect( mRemoveACL, TQ_SIGNAL( clicked() ), TQ_SLOT( slotRemoveACL() ) );
359 mEditACL->setEnabled(
false );
360 mRemoveACL->setEnabled(
false );
362 connect(
this, TQ_SIGNAL( changed(
bool) ), TQ_SLOT( slotChanged(
bool) ) );
366 KURL KMail::FolderDiaACLTab::imapURL()
const
368 KURL url = mImapAccount->getUrl();
369 url.setPath( mImapPath );
373 void KMail::FolderDiaACLTab::initializeWithValuesFromFolder(
KMFolder* folder )
377 if ( mFolderType == KMFolderTypeImap ) {
378 KMFolderImap* folderImap =
static_cast<KMFolderImap*
>( folder->storage() );
379 mImapPath = folderImap->imapPath();
380 mImapAccount = folderImap->account();
381 mUserRights = folderImap->userRights();
382 mUserRightsState = folderImap->userRightsState();
384 else if ( mFolderType == KMFolderTypeCachedImap ) {
385 KMFolderCachedImap* folderImap =
static_cast<KMFolderCachedImap*
>( folder->storage() );
386 mImapPath = folderImap->imapPath();
387 mImapAccount = folderImap->account();
388 mUserRights = folderImap->userRights();
389 mUserRightsState = folderImap->userRightsState();
395 void KMail::FolderDiaACLTab::load()
397 if ( mDlg->folder() ) {
399 initializeWithValuesFromFolder( mDlg->folder() );
400 }
else if ( mDlg->parentFolder() ) {
402 initializeWithValuesFromFolder( mDlg->parentFolder() );
412 TQString defaultFormat =
"fullemail";
414 if ( mImapAccount && mImapAccount->login().find(
'@') == -1 )
415 defaultFormat =
"username";
416 TDEConfigGroup configGroup( kmkernel->config(),
"IMAP" );
417 TQString str = configGroup.readEntry(
"UserIdFormat", defaultFormat );
418 mUserIdFormat = FullEmail;
419 if ( str ==
"username" )
420 mUserIdFormat = UserName;
422 if ( mFolderType == KMFolderTypeCachedImap ) {
423 KMFolder* folder = mDlg->folder() ? mDlg->folder() : mDlg->parentFolder();
424 KMFolderCachedImap* folderImap =
static_cast<KMFolderCachedImap*
>( folder->storage() );
427 TQString text = i18n(
"Error retrieving user permissions." );
429 text +=
"\n" + i18n(
"You might not have enough permissions to see the permissions of this folder." );
431 mLabel->setText( text );
434 mLabel->setText( i18n(
"Information not retrieved from server, you need to use \"Check Mail\" and have administrative privileges on the folder."));
436 loadFinished( folderImap->aclList() );
447 mStack->raiseWidget( mLabel );
448 if ( !mImapAccount ) {
449 mLabel->setText( i18n(
"Error: no IMAP account defined for this folder" ) );
452 KMFolder* folder = mDlg->folder() ? mDlg->folder() : mDlg->parentFolder();
453 if ( folder && folder->storage() == mImapAccount->rootFolder() )
455 mLabel->setText( i18n(
"Connecting to server %1, please wait..." ).arg( mImapAccount->host() ) );
456 ImapAccountBase::ConnectionState state = mImapAccount->makeConnection();
457 if ( state == ImapAccountBase::Error ) {
458 slotConnectionResult( -1, TQString() );
459 }
else if ( state == ImapAccountBase::Connecting ) {
460 connect( mImapAccount, TQ_SIGNAL( connectionResult(
int,
const TQString&) ),
461 this, TQ_SLOT( slotConnectionResult(
int,
const TQString&) ) );
463 slotConnectionResult( 0, TQString() );
467 void KMail::FolderDiaACLTab::slotConnectionResult(
int errorCode,
const TQString& errorMsg )
469 disconnect( mImapAccount, TQ_SIGNAL( connectionResult(
int,
const TQString&) ),
470 this, TQ_SLOT( slotConnectionResult(
int,
const TQString&) ) );
472 if ( errorCode == -1 )
473 mLabel->setText( i18n(
"Error connecting to server %1" ).arg( mImapAccount->host() ) );
476 mLabel->setText( TDEIO::buildErrorString( errorCode, errorMsg ) );
481 connect( mImapAccount, TQ_SIGNAL( receivedUserRights(
KMFolder* ) ),
482 this, TQ_SLOT( slotReceivedUserRights(
KMFolder* ) ) );
483 KMFolder* folder = mDlg->folder() ? mDlg->folder() : mDlg->parentFolder();
484 mImapAccount->getUserRights( folder, mImapPath );
490 void KMail::FolderDiaACLTab::slotReceivedUserRights(
KMFolder* folder )
492 if ( !mImapAccount->hasACLSupport() ) {
493 mLabel->setText( i18n(
"This IMAP server does not have support for access control lists (ACL)" ) );
497 if ( folder == mDlg->folder() ? mDlg->folder() : mDlg->parentFolder() ) {
498 KMFolderImap* folderImap =
static_cast<KMFolderImap*
>( folder->storage() );
499 mUserRights = folderImap->userRights();
500 mUserRightsState = folderImap->userRightsState();
505 void KMail::FolderDiaACLTab::startListing()
508 mImapAccount->getACL( mDlg->folder() ? mDlg->folder() : mDlg->parentFolder(), mImapPath );
509 connect( mImapAccount, TQ_SIGNAL(receivedACL(
KMFolder*, TDEIO::Job*,
const KMail::ACLList& )),
510 this, TQ_SLOT(slotReceivedACL(
KMFolder*, TDEIO::Job*,
const KMail::ACLList& )) );
513 void KMail::FolderDiaACLTab::slotReceivedACL(
KMFolder* folder, TDEIO::Job* job,
const KMail::ACLList& aclList )
515 if ( folder == ( mDlg->folder() ? mDlg->folder() : mDlg->parentFolder() ) ) {
516 disconnect( mImapAccount, TQ_SIGNAL(receivedACL(
KMFolder*, TDEIO::Job*,
const KMail::ACLList& )),
517 this, TQ_SLOT(slotReceivedACL(
KMFolder*, TDEIO::Job*,
const KMail::ACLList& )) );
519 if ( job && job->error() ) {
520 if ( job->error() == TDEIO::ERR_UNSUPPORTED_ACTION )
521 mLabel->setText( i18n(
"This IMAP server does not have support for access control lists (ACL)" ) );
523 mLabel->setText( i18n(
"Error retrieving access control list (ACL) from server\n%1" ).arg( job->errorString() ) );
527 loadFinished( aclList );
531 void KMail::FolderDiaACLTab::loadListView(
const ACLList& aclList )
534 for( ACLList::const_iterator it = aclList.begin(); it != aclList.end(); ++it ) {
536 if ( (*it).permissions > -1 ) {
537 ListViewItem* item =
new ListViewItem( mListView );
539 if ( !mDlg->folder() )
540 item->setModified(
true );
545 void KMail::FolderDiaACLTab::loadFinished(
const ACLList& aclList )
547 loadListView( aclList );
548 if ( mDlg->folder() )
549 mInitialACLList = aclList;
550 mStack->raiseWidget( mACLWidget );
551 slotSelectionChanged( mListView->selectedItem() );
554 void KMail::FolderDiaACLTab::slotEditACL(TQListViewItem* item)
557 bool canAdmin = ( mUserRights & ACLJobs::Administer );
559 if ( canAdmin && mImapAccount && item ) {
561 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( item );
562 if ( mImapAccount->login() == ACLitem->userId() && ACLitem->permissions() == ACLJobs::All )
565 if ( !canAdmin )
return;
567 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( mListView->currentItem() );
568 ACLEntryDialog dlg( mUserIdFormat, i18n(
"Modify Permissions" ),
this );
569 dlg.setValues( ACLitem->userId(), ACLitem->permissions() );
570 if ( dlg.exec() == TQDialog::Accepted ) {
571 TQStringList userIds = dlg.userIds();
572 Q_ASSERT( !userIds.isEmpty() );
573 ACLitem->setUserId( dlg.userIds().front() );
574 ACLitem->setPermissions( dlg.permissions() );
575 ACLitem->setModified(
true );
577 if ( userIds.count() > 1 ) {
579 addACLs( userIds, dlg.permissions() );
584 void KMail::FolderDiaACLTab::slotEditACL()
586 slotEditACL( mListView->currentItem() );
589 void KMail::FolderDiaACLTab::addACLs(
const TQStringList& userIds,
unsigned int permissions )
591 for( TQStringList::const_iterator it = userIds.begin(); it != userIds.end(); ++it ) {
592 ListViewItem* ACLitem =
new ListViewItem( mListView );
593 ACLitem->setUserId( *it );
594 ACLitem->setPermissions( permissions );
595 ACLitem->setModified(
true );
596 ACLitem->setNew(
true );
600 void KMail::FolderDiaACLTab::slotAddACL()
602 ACLEntryDialog dlg( mUserIdFormat, i18n(
"Add Permissions" ),
this );
603 if ( dlg.exec() == TQDialog::Accepted ) {
604 const TQStringList userIds = dlg.userIds();
605 addACLs( dlg.userIds(), dlg.permissions() );
610 void KMail::FolderDiaACLTab::slotSelectionChanged(TQListViewItem* item)
612 bool canAdmin = ( mUserRights & ACLJobs::Administer );
613 bool canAdminThisItem = canAdmin;
614 if ( canAdmin && mImapAccount && item ) {
616 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( item );
617 if ( mImapAccount->login() == ACLitem->userId() && ACLitem->permissions() == ACLJobs::All )
618 canAdminThisItem =
false;
621 bool lvVisible = mStack->visibleWidget() == mACLWidget;
622 mAddACL->setEnabled( lvVisible && canAdmin && !mSaving );
623 mEditACL->setEnabled( item && lvVisible && canAdminThisItem && !mSaving );
624 mRemoveACL->setEnabled( item && lvVisible && canAdminThisItem && !mSaving );
627 void KMail::FolderDiaACLTab::slotRemoveACL()
629 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( mListView->currentItem() );
632 if ( !ACLitem->isNew() ) {
633 if ( mImapAccount && mImapAccount->login() == ACLitem->userId() ) {
634 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel( topLevelWidget(),
635 i18n(
"Do you really want to remove your own permissions for this folder? You will not be able to access it afterwards." ), i18n(
"Remove" ) ) )
638 mRemovedACLs.append( ACLitem->userId() );
646 if ( !mChanged || !mImapAccount )
650 if ( mFolderType == KMFolderTypeCachedImap )
659 if ( !mChanged || !mImapAccount )
661 assert( mDlg->folder() );
676 TDEABC::AddressBook *addressBook = TDEABC::StdAddressBook::self(
true );
677 #ifndef TDEPIM_NEW_DISTRLISTS
678 TDEABC::DistributionListManager manager( addressBook );
682 for ( TQListViewItem* item = mListView->firstChild(); item; item = item->nextSibling() ) {
683 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( item );
684 ACLitem->save( aclList,
685 #ifdef TDEPIM_NEW_DISTRLISTS
692 loadListView( aclList );
696 for( ACLList::ConstIterator init = mInitialACLList.begin(); init != mInitialACLList.end(); ++init ) {
697 bool isInNewList =
false;
698 TQString uid = (*init).userId;
699 for( ACLList::ConstIterator it = aclList.begin(); it != aclList.end() && !isInNewList; ++it )
700 isInNewList = uid == (*it).userId;
701 if ( !isInNewList && !mRemovedACLs.contains(uid) )
702 mRemovedACLs.append( uid );
705 for ( TQStringList::ConstIterator rit = mRemovedACLs.begin(); rit != mRemovedACLs.end(); ++rit ) {
710 aclList.append( entry );
715 if ( mFolderType == KMFolderTypeCachedImap ) {
718 KMFolderCachedImap* folderImap =
static_cast<KMFolderCachedImap*
>( mDlg->folder()->storage() );
719 folderImap->setACLList( aclList );
725 KMFolderImap* parentImap = mDlg->parentFolder() ?
static_cast<KMFolderImap*
>( mDlg->parentFolder()->storage() ) : 0;
727 if ( mDlg->isNewFolder() ) {
730 connect( parentImap, TQ_SIGNAL( directoryListingFinished(KMFolderImap*) ),
731 this, TQ_SLOT( slotDirectoryListingFinished(KMFolderImap*) ) );
733 slotDirectoryListingFinished( parentImap );
738 void KMail::FolderDiaACLTab::slotDirectoryListingFinished(KMFolderImap* f)
741 f !=
static_cast<KMFolderImap*
>( mDlg->parentFolder()->storage() ) ||
743 !mDlg->folder()->storage() ) {
744 emit readyForAccept();
749 KMFolderImap* folderImap =
static_cast<KMFolderImap*
>( mDlg->folder()->storage() );
750 if ( !folderImap || folderImap->imapPath().isEmpty() )
752 mImapPath = folderImap->imapPath();
756 jd.total = 1; jd.done = 0; jd.parent = 0;
757 mImapAccount->insertJob(job, jd);
759 connect(job, TQ_SIGNAL(result(TDEIO::Job *)),
760 TQ_SLOT(slotMultiSetACLResult(TDEIO::Job *)));
761 connect(job, TQ_SIGNAL(aclChanged(
const TQString&,
int )),
762 TQ_SLOT(slotACLChanged(
const TQString&,
int )) );
765 void KMail::FolderDiaACLTab::slotMultiSetACLResult(TDEIO::Job* job)
767 ImapAccountBase::JobIterator it = mImapAccount->findJob( job );
768 if ( it == mImapAccount->jobsEnd() )
return;
769 mImapAccount->removeJob( it );
771 if ( job->error() ) {
772 job->showErrorDialog(
this );
779 emit readyForAccept();
783 void KMail::FolderDiaACLTab::slotACLChanged(
const TQString& userId,
int permissions )
788 if ( permissions > -1 ) {
789 for ( TQListViewItem* item = mListView->firstChild(); item; item = item->nextSibling() ) {
790 ListViewItem* ACLitem =
static_cast<ListViewItem *
>( item );
791 if ( ACLitem->userId() == userId ) {
792 ACLitem->setModified(
false );
793 ACLitem->setNew(
false );
799 uint nr = mRemovedACLs.remove( userId );
803 kdWarning(5006) << k_funcinfo <<
" no item found for userId " << userId << endl;
806 void KMail::FolderDiaACLTab::slotChanged(
bool b )
811 bool KMail::FolderDiaACLTab::supports(
KMFolder* refFolder )
813 ImapAccountBase* imapAccount = 0;
814 if ( refFolder->
folderType() == KMFolderTypeImap )
815 imapAccount =
static_cast<KMFolderImap*
>( refFolder->storage() )->account();
817 imapAccount =
static_cast<KMFolderCachedImap*
>( refFolder->storage() )->account();
818 return imapAccount && imapAccount->hasACLSupport();
821 #include "folderdiaacltab.moc"
Dialog for handling the properties of a mail folder.
KMFolderType folderType() const
Returns the type of this folder.
"New Access Control Entry" dialog.
virtual bool save()
Unlike ConfigModuleTab, we return a bool from save.
virtual AccepStatus accept()
Called when clicking OK.
This is the base class for tabs in the folder dialog.
@ NotFetchedYet
The user rights/ACL have not been fetched from the server yet, we don't know them.
@ Ok
The user rights/ACL have been fetched from the server sucessfully.
@ FetchFailed
The attempt to fetch the user rights/ACL from the server failed.
MultiSetACLJob * multiSetACL(TDEIO::Slave *slave, const KURL &url, const ACLList &acl)
Set and delete a list of permissions for different users on a given url.
One entry in the ACL list: user and permissions.
TQString internalRightsList
protocol-dependent string (e.g. IMAP rights list)
int permissions
based on the ACLPermissions enum
bool changed
special flag for KMFolderCachedImap