00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include <config.h>
00034 #endif
00035
00036 #include <kdebug.h>
00037 #include <klocale.h>
00038 #include <kmessagebox.h>
00039
00040 #include "localsubscriptiondialog.h"
00041 #include "kmkernel.h"
00042 #include "kmacctmgr.h"
00043 #include "kmmessage.h"
00044 #include "imapaccountbase.h"
00045 #include "listjob.h"
00046
00047 namespace KMail {
00048
00049 LocalSubscriptionDialog::LocalSubscriptionDialog( QWidget *parent, const QString &caption,
00050 ImapAccountBase *acct, QString startPath )
00051 : SubscriptionDialog( parent, caption, acct, startPath ),
00052 mAccount( acct )
00053 {
00054 }
00055
00056
00057 LocalSubscriptionDialog::~LocalSubscriptionDialog()
00058 {
00059
00060 }
00061
00062
00063
00064 void LocalSubscriptionDialog::listAllAvailableAndCreateItems()
00065 {
00066
00067
00068 bool complete = (mAccount->prefix() == "/") ? true : false;
00069
00070 ImapAccountBase::ListType type = ImapAccountBase::List;
00071 if ( mAccount->onlySubscribedFolders() )
00072 type = ImapAccountBase::ListSubscribedNoCheck;
00073 ListJob* job = new ListJob( 0, mAccount, type, false,
00074 complete, false, mAccount->prefix() );
00075 connect( job, SIGNAL(receivedFolders(const QStringList&, const QStringList&,
00076 const QStringList&, const QStringList&, const ImapAccountBase::jobData&)),
00077 this, SLOT(slotListDirectory(const QStringList&, const QStringList&,
00078 const QStringList&, const QStringList&, const ImapAccountBase::jobData&)));
00079 job->start();
00080 }
00081
00082
00083 void LocalSubscriptionDialog::processFolderListing()
00084 {
00085 uint done = 0;
00086 for (uint i = mCount; i < mFolderNames.count(); ++i) {
00087
00088 if (done == 1000) {
00089 emit listChanged();
00090 QTimer::singleShot(0, this, SLOT(processFolderListing()));
00091 return;
00092 }
00093 ++mCount;
00094 ++done;
00095 createListViewItem( i );
00096 }
00097 if ( mJobData.inboxOnly ) {
00098
00099
00100
00101 ImapAccountBase::ListType type = ImapAccountBase::List;
00102 if ( mAccount->onlySubscribedFolders() )
00103 type = ImapAccountBase::ListSubscribedNoCheck;
00104 ListJob* job = new ListJob( 0, mAccount, type, true, true,
00105 false, mAccount->prefix() );
00106 connect( job, SIGNAL(receivedFolders(const QStringList&, const QStringList&,
00107 const QStringList&, const QStringList&, const ImapAccountBase::jobData&)),
00108 this, SLOT(slotListDirectory(const QStringList&, const QStringList&,
00109 const QStringList&, const QStringList&, const ImapAccountBase::jobData&)));
00110 job->start();
00111 } else {
00112
00113
00114 setCheckedStateOfAllItems();
00115 }
00116 }
00117
00118 void LocalSubscriptionDialog::setCheckedStateOfAllItems()
00119 {
00120
00121
00122 QDictIterator<GroupItem> it( mItemDict );
00123 for ( ; it.current(); ++it ) {
00124 GroupItem *item = it.current();
00125 QString path = it.currentKey();
00126 item->setOn( mAccount->locallySubscribedTo( path ) );
00127 }
00128 slotLoadingComplete();
00129 }
00130
00131
00132 void LocalSubscriptionDialog::doSave()
00133 {
00134 bool somethingHappened = false;
00135
00136 QListViewItemIterator it(subView);
00137 for ( ; it.current(); ++it) {
00138 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
00139 static_cast<GroupItem*>(it.current())->info().path, true );
00140 somethingHappened = true;
00141 }
00142
00143
00144 QListViewItemIterator it2(unsubView);
00145 if ( unsubView->childCount() > 0 ) {
00146 const QString message = i18n("Locally unsubscribing from folders will remove all "
00147 "information that is present locally about those folders. The folders will "
00148 "not be changed on the server. Press cancel now if you want to make sure "
00149 "all local changes have been written to the server by checking mail first.");
00150 const QString caption = i18n("Local changes will be lost when unsubscribing");
00151 if ( KMessageBox::warningContinueCancel( this, message, caption )
00152 != KMessageBox::Cancel ) {
00153 somethingHappened = true;
00154 for ( ; it2.current(); ++it2) {
00155 static_cast<ImapAccountBase*>(account())->changeLocalSubscription(
00156 static_cast<GroupItem*>(it2.current())->info().path, false );
00157 }
00158
00159 }
00160 }
00161 if ( somethingHappened ) {
00162 kmkernel->acctMgr()->singleCheckMail( mAccount, true);
00163 }
00164 }
00165
00166 }
00167
00168 #include "localsubscriptiondialog.moc"