kmail Library API Documentation

folderIface.cpp

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  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 "kmkernel.h"
00037 #include "kmmainwin.h"
00038 #include "kmmainwidget.h"
00039 #include "kmfoldertree.h"
00040 #include "kmfoldermgr.h"
00041 #include "kmfolder.h"
00042 
00043 #include <kapplication.h>
00044 #include <kdebug.h>
00045 
00046 #include <stdlib.h>
00047 
00048 namespace KMail {
00049 
00050 FolderIface::FolderIface( const QString& vpath )
00051   : DCOPObject( "FolderIface" ), mPath( vpath )
00052 {
00053   //kdDebug(5006)<<"FolderIface folder = "<< mPath <<endl;
00054   mFolder = kmkernel->folderMgr()->getFolderByURL( mPath );
00055   if ( !mFolder )
00056     mFolder = kmkernel->imapFolderMgr()->getFolderByURL( mPath );
00057   if ( !mFolder )
00058     mFolder = kmkernel->dimapFolderMgr()->getFolderByURL( mPath );
00059   Q_ASSERT( mFolder );
00060 }
00061 
00062 QString
00063 FolderIface::path() const
00064 {
00065   return mPath;
00066 }
00067 
00068 QString
00069 FolderIface::displayName() const
00070 {
00071   return mFolder->label();
00072 }
00073 
00074 QString
00075 FolderIface::displayPath() const
00076 {
00077   return mFolder->prettyURL();
00078 }
00079 
00080 bool
00081 FolderIface::usesCustomIcons() const
00082 {
00083   return mFolder->useCustomIcons();
00084 }
00085 
00086 QString
00087 FolderIface::normalIconPath() const
00088 {
00089   return mFolder->normalIconPath();
00090 }
00091 
00092 QString
00093 FolderIface::unreadIconPath() const
00094 {
00095   return mFolder->unreadIconPath();
00096 }
00097 
00098 int
00099 FolderIface::messages()
00100 {
00101   // if the folder isn't open then return the cached count
00102   return mFolder->count( !mFolder->isOpened() );
00103 }
00104 
00105 int
00106 FolderIface::unreadMessages()
00107 {
00108     return mFolder->countUnread();
00109 }
00110 
00111 int
00112 FolderIface::unreadRecursiveMessages()
00113 {
00114     return mFolder->countUnreadRecursive();
00115 }
00116 
00117 //The reason why this function is disabled is that we loose
00118 //the message as soon as we get it (after we switch folders,
00119 //it's being unget. We need a reference count on message to make it work
00120 /*
00121 QValueList<DCOPRef>
00122 FolderIface::messageRefs()
00123 {
00124     QValueList<DCOPRef> refList;
00125     KMMsgList messageCache;
00126     KMFolderIndex *indexFolder = static_cast<KMFolderIndex*>( mFolder);
00127 
00128     if ( indexFolder ) {
00129       mFolder->open();
00130       indexFolder->readIndex();
00131       messageCache = indexFolder->mMsgList;
00132       mFolder->close();
00133     } else
00134       return refList;
00135 
00136     kdDebug(5006)<<"refList == "<<messageCache.count()<<endl;
00137 
00138     for( int i = 0; i < messageCache.size(); ++i ) {
00139       KMMsgBase *msg = messageCache[i];
00140       if ( msg ) {
00141         KMMessage *fmsg = msg->parent()->getMsg( msg->parent()->find( msg ) );
00142         refList.append( DCOPRef( new MessageIface( fmsg ) ) );
00143       }
00144     }
00145 
00146     kdDebug(5006)<<"Reflist size = "<<refList.count()<<endl;
00147     return refList;
00148 }*/
00149 
00150 }
00151 
00152 #include "folderIface.moc"
KDE Logo
This file is part of the documentation for kmail Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 4 14:42:11 2007 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003