• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.14.10 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
29KIO::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
40KIO::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
68KIO::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
80KIO::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
This class handels reading from a mbox-file.
Definition: readmbox.h:39
ReadMBox::searchMessage
bool searchMessage(const QString &id)
This function search the file for a certain id.
Definition: readmbox.cpp:111
ReadMBox::skipMessage
unsigned int skipMessage()
Skips all lines which belongs to the current message.
Definition: readmbox.cpp:124
ReadMBox::currentID
QString currentID() const
This function returns the current id.
Definition: readmbox.cpp:71
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
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
Stat::stat
static KIO::UDSEntry stat(const UrlInfo &info)
This functions gives information with a given UrlInfo.
Definition: stat.cpp:29
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Jul 21 2022 00:00:00 by doxygen 1.9.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.14.10 API Reference

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