• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.11.3 API Reference
  • KDE Home
  • Contact Us
 

kioslave/mbox

  • kioslave
  • mbox
stat.cpp
1 /*
2  * This is a simple kioslave to handle mbox-files.
3  * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl)
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 #include "stat.h"
20 
21 #include "readmbox.h"
22 #include "urlinfo.h"
23 
24 #include <kdebug.h>
25 #include <kio/global.h>
26 
27 #include <sys/stat.h>
28 
29 KIO::UDSEntry Stat::stat( const UrlInfo& info )
30 {
31  if( info.type() == UrlInfo::message )
32  return Stat::statMessage( info );
33  else if( info.type() == UrlInfo::directory )
34  return Stat::statDirectory( info );
35  else
36  return KIO::UDSEntry();
37 }
38 
39 KIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info )
40 {
41  kDebug() <<"Stat::stat()";
42  KIO::UDSEntry entry;
43  QString url;
44 
45  if( info.type() == UrlInfo::invalid )
46  return entry;
47  else if( info.type() == UrlInfo::message )
48  mbox.searchMessage( info.id() );
49 
50  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG );
51  entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) );
52 
53  url = QString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() );
54  entry.insert( KIO::UDSEntry::UDS_URL, url );
55  if( mbox.currentID().isEmpty() )
56  entry.insert( KIO::UDSEntry::UDS_NAME, QString( "" ) );
57  else
58  entry.insert( KIO::UDSEntry::UDS_NAME, mbox.currentID() );
59 
60 
61  entry.insert( KIO::UDSEntry::UDS_SIZE, mbox.skipMessage() );
62 
63  return entry;
64 }
65 
66 KIO::UDSEntry Stat::statDirectory( const UrlInfo& info )
67 {
68  kDebug() <<"statDirectory()";
69  KIO::UDSEntry entry;
70 
71  //Specific things for a directory
72  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
73  entry.insert( KIO::UDSEntry::UDS_NAME, info.filename() );
74 
75  return entry;
76 }
77 
78 KIO::UDSEntry Stat::statMessage( const UrlInfo& info )
79 {
80  kDebug() <<"statMessage(" << info.url() <<" )";
81  KIO::UDSEntry entry;
82  QString url = QString( "mbox:%1" ).arg( info.url() );
83 
84  //Specific things for a message
85  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG );
86  entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) );
87 
88  entry.insert( KIO::UDSEntry::UDS_URL, url );
89  url = url.right( url.length() - url.lastIndexOf( "/" ) - 1 );
90  entry.insert( KIO::UDSEntry::UDS_NAME, url );
91 
92  return entry;
93 }
94 
ReadMBox::currentID
QString currentID() const
This function returns the current id.
Definition: readmbox.cpp:68
Stat::stat
static KIO::UDSEntry stat(const UrlInfo &info)
This functions gives information with a given UrlInfo.
Definition: stat.cpp:29
ReadMBox
This class handels reading from a mbox-file.
Definition: readmbox.h:38
Stat::statDirectory
static KIO::UDSEntry statDirectory(const UrlInfo &info)
This function gets the stats of a given mbox-file in an UDSEntry.
Definition: stat.cpp:66
ReadMBox::skipMessage
unsigned int skipMessage()
Skips all lines which belongs to the current message.
Definition: readmbox.cpp:121
Stat::statMessage
static KIO::UDSEntry statMessage(const UrlInfo &info)
This function gets the stats of a geven mbox-message in a UDSEntry.
Definition: stat.cpp:78
ReadMBox::searchMessage
bool searchMessage(const QString &id)
This function search the file for a certain id.
Definition: readmbox.cpp:110
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:02:20 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kioslave/mbox

Skip menu "kioslave/mbox"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal