kmail

folderIface.cpp

Go to the documentation of this file.
00001 /*  -*- mode: C++; c-file-style: "gnu" -*-
00002  *
00003  *  This file is part of KMail, the KDE mail client.
00004  *  Copyright (c) 2003 Zack Rusin <zack@kde.org>
00005  *
00006  *  KMail is free software; you can redistribute it and/or modify it
00007  *  under the terms of the GNU General Public License, version 2, as
00008  *  published by the Free Software Foundation.
00009  *
00010  *  KMail is distributed in the hope that it will be useful, but
00011  *  WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  *  In addition, as a special exception, the copyright holders give
00020  *  permission to link the code of this program with any edition of
00021  *  the Qt library by Trolltech AS, Norway (or with modified versions
00022  *  of Qt that use the same license as Qt), and distribute linked
00023  *  combinations including the two.  You must obey the GNU General
00024  *  Public License in all respects for all of the code used other than
00025  *  Qt.  If you modify this file, you may extend this exception to
00026  *  your version of the file, but you are not obligated to do so.  If
00027  *  you do not wish to do so, delete this exception statement from
00028  *  your version.
00029  */
00030 #ifdef HAVE_CONFIG_H
00031 #include <config.h>
00032 #endif
00033 
00034 #include "folderIface.h"
00035 
00036 #include "kmmainwin.h"
00037 #include "kmfoldertree.h"
00038 #include "kmfoldermgr.h"
00039 #include "kmfolder.h"
00040 
00041 #include <kapplication.h>
00042 #include <kdebug.h>
00043 
00044 #include <stdlib.h>
00045 
00046 namespace KMail {
00047 
00048 FolderIface::FolderIface( const QString& vpath )
00049   : DCOPObject( "FolderIface" ), mPath( vpath )
00050 {
00051   //kdDebug(5006)<<"FolderIface folder = "<< mPath <<endl;
00052   mFolder = kmkernel->folderMgr()->getFolderByURL( mPath );
00053   if ( !mFolder )
00054     mFolder = kmkernel->imapFolderMgr()->getFolderByURL( mPath );
00055   if ( !mFolder )
00056     mFolder = kmkernel->dimapFolderMgr()->getFolderByURL( mPath );
00057   Q_ASSERT( mFolder );
00058 }
00059 
00060 QString
00061 FolderIface::path() const
00062 {
00063   return mPath;
00064 }
00065 
00066 QString
00067 FolderIface::displayName() const
00068 {
00069   return mFolder->label();
00070 }
00071 
00072 QString
00073 FolderIface::displayPath() const
00074 {
00075   return mFolder->prettyURL();
00076 }
00077 
00078 bool
00079 FolderIface::usesCustomIcons() const
00080 {
00081   return mFolder->useCustomIcons();
00082 }
00083 
00084 QString
00085 FolderIface::normalIconPath() const
00086 {
00087   return mFolder->normalIconPath();
00088 }
00089 
00090 QString
00091 FolderIface::unreadIconPath() const
00092 {
00093   return mFolder->unreadIconPath();
00094 }
00095 
00096 int
00097 FolderIface::messages()
00098 {
00099   // if the folder isn't open then return the cached count
00100   return mFolder->count( !mFolder->isOpened() );
00101 }
00102 
00103 int
00104 FolderIface::unreadMessages()
00105 {
00106     return mFolder->countUnread();
00107 }
00108 
00109 int
00110 FolderIface::unreadRecursiveMessages()
00111 {
00112     return mFolder->countUnreadRecursive();
00113 }
00114 
00115 //The reason why this function is disabled is that we loose
00116 //the message as soon as we get it (after we switch folders,
00117 //it's being unget. We need a reference count on message to make it work
00118 /*
00119 QValueList<DCOPRef>
00120 FolderIface::messageRefs()
00121 {
00122     QValueList<DCOPRef> refList;
00123     KMMsgList messageCache;
00124     KMFolderIndex *indexFolder = static_cast<KMFolderIndex*>( mFolder);
00125 
00126     if ( indexFolder ) {
00127       mFolder->open();
00128       indexFolder->readIndex();
00129       messageCache = indexFolder->mMsgList;
00130       mFolder->close();
00131     } else
00132       return refList;
00133 
00134     kdDebug(5006)<<"refList == "<<messageCache.count()<<endl;
00135 
00136     for( int i = 0; i < messageCache.size(); ++i ) {
00137       KMMsgBase *msg = messageCache[i];
00138       if ( msg ) {
00139         KMMessage *fmsg = msg->parent()->getMsg( msg->parent()->find( msg ) );
00140         refList.append( DCOPRef( new MessageIface( fmsg ) ) );
00141       }
00142     }
00143 
00144     kdDebug(5006)<<"Reflist size = "<<refList.count()<<endl;
00145     return refList;
00146 }*/
00147 
00148 }
00149 
00150 #include "folderIface.moc"