kmail

subscriptiondialog.h
00001 /*  -*- c++ -*-
00002     subscriptiondialog.h
00003 
00004     This file is part of KMail, the KDE mail client.
00005     Copyright (C) 2002 Carsten Burghardt <burghardt@kde.org>
00006 
00007     KMail is free software; you can redistribute it and/or modify it
00008     under the terms of the GNU General Public License, version 2, as
00009     published by the Free Software Foundation.
00010 
00011     KMail is distributed in the hope that it will be useful, but
00012     WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020     In addition, as a special exception, the copyright holders give
00021     permission to link the code of this program with any edition of
00022     the TQt library by Trolltech AS, Norway (or with modified versions
00023     of TQt that use the same license as TQt), and distribute linked
00024     combinations including the two.  You must obey the GNU General
00025     Public License in all respects for all of the code used other than
00026     TQt.  If you modify this file, you may extend this exception to
00027     your version of the file, but you are not obligated to do so.  If
00028     you do not wish to do so, delete this exception statement from
00029     your version.
00030 */
00031 
00032 #ifndef __SUBSCRIPTIONDIALOG
00033 #define __SUBSCRIPTIONDIALOG
00034 
00035 #include <tqdict.h>
00036 #include <ksubscription.h>
00037 #include "imapaccountbase.h"
00038 
00039 class KMMessage;
00040 class FolderStorage;
00041 
00042 namespace KMail {
00043 
00044   // Abstract base class for the server side and client side subscription dialogs.
00045   // Scott Meyers says: "Make non-leaf classes abstract" and he is right, I think.
00046   // (More Effective C++, Item 33)
00047   class SubscriptionDialogBase : public KSubscription
00048   {
00049     Q_OBJECT
00050   
00051 
00052     public:
00053       SubscriptionDialogBase( TQWidget *parent,
00054                               const TQString &caption,
00055                               KAccount* acct,
00056                               TQString startPath = TQString() );
00057       virtual ~SubscriptionDialogBase() {}
00058 
00059       void show();
00060 
00061     protected:
00065       void findParentItem ( TQString &name, TQString &path, TQString &compare,
00066                        GroupItem **parent, GroupItem **oldItem );
00067 
00071       void processNext();
00072 
00076       void initPrefixList();
00077 
00078       virtual void loadingComplete();
00079 
00080     public slots:
00084       void slotListDirectory(const TQStringList&, const TQStringList&,
00085           const TQStringList&, const TQStringList&, const ImapAccountBase::jobData &);
00086 
00090       void slotSave();
00091 
00095       void slotConnectionResult( int errorCode, const TQString& errorMsg );
00096 
00097     protected slots:
00101       void slotLoadFolders();
00102 
00103     protected:
00104       virtual void listAllAvailableAndCreateItems() = 0;
00105       virtual void processFolderListing() = 0;
00106       virtual void doSave() = 0;
00107 
00108       // helpers
00110       void moveChildrenToNewParent( GroupItem *oldItem, GroupItem *item  );
00111 
00114       void createListViewItem( int i );
00115 
00116       TQString mDelimiter;
00117       TQStringList mFolderNames, mFolderPaths,
00118                   mFolderMimeTypes, mFolderAttributes;
00119       ImapAccountBase::jobData mJobData;
00120       uint mCount;
00121       TQDict<GroupItem> mItemDict;
00122       TQString mStartPath;
00123       bool mSubscribed, mForceSubscriptionEnable;
00124       TQStringList mPrefixList;
00125       TQString mCurrentNamespace;
00126   };
00127 
00128   class SubscriptionDialog : public SubscriptionDialogBase
00129   {
00130     Q_OBJECT
00131   
00132     public:
00133 
00134       SubscriptionDialog( TQWidget *parent,
00135                           const TQString &caption,
00136                           KAccount* acct,
00137                           TQString startPath = TQString() );
00138       virtual ~SubscriptionDialog();
00139      protected:
00141       virtual void listAllAvailableAndCreateItems();
00143       virtual void processFolderListing();
00145       virtual void doSave();
00146 
00147     private:
00152       void processItems();
00153 
00154   };
00155 
00156 } // namespace KMail
00157 
00158 #endif