kmail

folderIface.cpp
1 /*
2  *
3  * This file is part of KMail, the KDE mail client.
4  * Copyright (c) 2003 Zack Rusin <zack@kde.org>
5  *
6  * KMail is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License, version 2, as
8  * published by the Free Software Foundation.
9  *
10  * KMail is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * In addition, as a special exception, the copyright holders give
20  * permission to link the code of this program with any edition of
21  * the TQt library by Trolltech AS, Norway (or with modified versions
22  * of TQt that use the same license as TQt), and distribute linked
23  * combinations including the two. You must obey the GNU General
24  * Public License in all respects for all of the code used other than
25  * TQt. If you modify this file, you may extend this exception to
26  * your version of the file, but you are not obligated to do so. If
27  * you do not wish to do so, delete this exception statement from
28  * your version.
29  */
30 #ifdef HAVE_CONFIG_H
31 #include <config.h>
32 #endif
33 
34 #include "folderIface.h"
35 
36 #include "kmmainwin.h"
37 #include "kmfoldertree.h"
38 #include "kmfoldermgr.h"
39 #include "kmfolder.h"
40 
41 #include <tdeapplication.h>
42 #include <kdebug.h>
43 
44 #include <stdlib.h>
45 
46 namespace KMail {
47 
48 FolderIface::FolderIface( const TQString& vpath )
49  : DCOPObject( "FolderIface" ), mPath( vpath )
50 {
51  //kdDebug(5006)<<"FolderIface folder = "<< mPath <<endl;
52  mFolder = kmkernel->folderMgr()->getFolderByURL( mPath );
53  if ( !mFolder )
54  mFolder = kmkernel->imapFolderMgr()->getFolderByURL( mPath );
55  if ( !mFolder )
56  mFolder = kmkernel->dimapFolderMgr()->getFolderByURL( mPath );
57  Q_ASSERT( mFolder );
58 }
59 
60 TQString
61 FolderIface::path() const
62 {
63  return mPath;
64 }
65 
66 TQString
67 FolderIface::displayName() const
68 {
69  return mFolder->label();
70 }
71 
72 TQString
73 FolderIface::displayPath() const
74 {
75  return mFolder->prettyURL();
76 }
77 
78 bool
79 FolderIface::usesCustomIcons() const
80 {
81  return mFolder->useCustomIcons();
82 }
83 
84 TQString
85 FolderIface::normalIconPath() const
86 {
87  return mFolder->normalIconPath();
88 }
89 
90 TQString
91 FolderIface::unreadIconPath() const
92 {
93  return mFolder->unreadIconPath();
94 }
95 
96 int
97 FolderIface::messages()
98 {
99  // if the folder isn't open then return the cached count
100  return mFolder->count( !mFolder->isOpened() );
101 }
102 
103 int
104 FolderIface::unreadMessages()
105 {
106  return mFolder->countUnread();
107 }
108 
109 int
110 FolderIface::unreadRecursiveMessages()
111 {
112  return mFolder->countUnreadRecursive();
113 }
114 
115 //The reason why this function is disabled is that we loose
116 //the message as soon as we get it (after we switch folders,
117 //it's being unget. We need a reference count on message to make it work
118 /*
119 TQValueList<DCOPRef>
120 FolderIface::messageRefs()
121 {
122  TQValueList<DCOPRef> refList;
123  KMMsgList messageCache;
124  KMFolderIndex *indexFolder = static_cast<KMFolderIndex*>( mFolder);
125 
126  if ( indexFolder ) {
127  mFolder->open();
128  indexFolder->readIndex();
129  messageCache = indexFolder->mMsgList;
130  mFolder->close();
131  } else
132  return refList;
133 
134  kdDebug(5006)<<"refList == "<<messageCache.count()<<endl;
135 
136  for( int i = 0; i < messageCache.size(); ++i ) {
137  KMMsgBase *msg = messageCache[i];
138  if ( msg ) {
139  KMMessage *fmsg = msg->parent()->getMsg( msg->parent()->find( msg ) );
140  refList.append( DCOPRef( new MessageIface( fmsg ) ) );
141  }
142  }
143 
144  kdDebug(5006)<<"Reflist size = "<<refList.count()<<endl;
145  return refList;
146 }*/
147 
148 }
149 
150 #include "folderIface.moc"
folderdiaquotatab.h
Definition: aboutdata.cpp:40