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

kioslave/mbox

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 
40 KIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info )
41 {
42  kDebug() <<"Stat::stat()";
43  KIO::UDSEntry entry;
44  QString url;
45 
46  if( info.type() == UrlInfo::invalid ) {
47  return entry;
48  } else if( info.type() == UrlInfo::message ) {
49  mbox.searchMessage( info.id() );
50  }
51 
52  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG );
53  entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) );
54 
55  url = QString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() );
56  entry.insert( KIO::UDSEntry::UDS_URL, url );
57  if( mbox.currentID().isEmpty() ) {
58  entry.insert( KIO::UDSEntry::UDS_NAME, QString( "" ) );
59  } else {
60  entry.insert( KIO::UDSEntry::UDS_NAME, mbox.currentID() );
61  }
62 
63  entry.insert( KIO::UDSEntry::UDS_SIZE, mbox.skipMessage() );
64 
65  return entry;
66 }
67 
68 KIO::UDSEntry Stat::statDirectory( const UrlInfo& info )
69 {
70  kDebug() <<"statDirectory()";
71  KIO::UDSEntry entry;
72 
73  //Specific things for a directory
74  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
75  entry.insert( KIO::UDSEntry::UDS_NAME, info.filename() );
76 
77  return entry;
78 }
79 
80 KIO::UDSEntry Stat::statMessage( const UrlInfo& info )
81 {
82  kDebug() <<"statMessage(" << info.url() <<" )";
83  KIO::UDSEntry entry;
84  QString url = QString( "mbox:%1" ).arg( info.url() );
85 
86  //Specific things for a message
87  entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG );
88  entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) );
89 
90  entry.insert( KIO::UDSEntry::UDS_URL, url );
91  url = url.right( url.length() - url.lastIndexOf( "/" ) - 1 );
92  entry.insert( KIO::UDSEntry::UDS_NAME, url );
93 
94  return entry;
95 }
ReadMBox::currentID
QString currentID() const
This function returns the current id.
Definition: readmbox.cpp:71
Stat::stat
static KIO::UDSEntry stat(const UrlInfo &info)
This functions gives information with a given UrlInfo.
Definition: stat.cpp:29
QString::lastIndexOf
int lastIndexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
ReadMBox
This class handels reading from a mbox-file.
Definition: readmbox.h:38
QString::insert
QString & insert(int position, QChar ch)
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:68
QString::isEmpty
bool isEmpty() const
QString
ReadMBox::skipMessage
unsigned int skipMessage()
Skips all lines which belongs to the current message.
Definition: readmbox.cpp:124
QString::right
QString right(int n) const
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:80
ReadMBox::searchMessage
bool searchMessage(const QString &id)
This function search the file for a certain id.
Definition: readmbox.cpp:111
QString::length
int length() const
QString::arg
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:11 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs 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

Search



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