kioslave/mbox
stat.cpp
00001 /* 00002 * This is a simple kioslave to handle mbox-files. 00003 * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl) 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Lesser General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Lesser General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Lesser General Public 00016 * License along with this library; if not, write to the Free Software 00017 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00018 */ 00019 #include "stat.h" 00020 00021 #include "readmbox.h" 00022 #include "urlinfo.h" 00023 00024 #include <kdebug.h> 00025 #include <kio/global.h> 00026 00027 #include <sys/stat.h> 00028 00029 KIO::UDSEntry Stat::stat( const UrlInfo& info ) 00030 { 00031 if( info.type() == UrlInfo::message ) 00032 return Stat::statMessage( info ); 00033 else if( info.type() == UrlInfo::directory ) 00034 return Stat::statDirectory( info ); 00035 else 00036 return KIO::UDSEntry(); 00037 } 00038 00039 KIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info ) 00040 { 00041 kDebug() <<"Stat::stat()"; 00042 KIO::UDSEntry entry; 00043 QString url; 00044 00045 if( info.type() == UrlInfo::invalid ) 00046 return entry; 00047 else if( info.type() == UrlInfo::message ) 00048 mbox.searchMessage( info.id() ); 00049 00050 entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG ); 00051 entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) ); 00052 00053 url = QString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() ); 00054 entry.insert( KIO::UDSEntry::UDS_URL, url ); 00055 if( mbox.currentID().isEmpty() ) 00056 entry.insert( KIO::UDSEntry::UDS_NAME, QString( "" ) ); 00057 else 00058 entry.insert( KIO::UDSEntry::UDS_NAME, mbox.currentID() ); 00059 00060 00061 entry.insert( KIO::UDSEntry::UDS_SIZE, mbox.skipMessage() ); 00062 00063 return entry; 00064 } 00065 00066 KIO::UDSEntry Stat::statDirectory( const UrlInfo& info ) 00067 { 00068 kDebug() <<"statDirectory()"; 00069 KIO::UDSEntry entry; 00070 00071 //Specific things for a directory 00072 entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR ); 00073 entry.insert( KIO::UDSEntry::UDS_NAME, info.filename() ); 00074 00075 return entry; 00076 } 00077 00078 KIO::UDSEntry Stat::statMessage( const UrlInfo& info ) 00079 { 00080 kDebug() <<"statMessage(" << info.url() <<" )"; 00081 KIO::UDSEntry entry; 00082 QString url = QString( "mbox:%1" ).arg( info.url() ); 00083 00084 //Specific things for a message 00085 entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG ); 00086 entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, QString( "message/rfc822" ) ); 00087 00088 entry.insert( KIO::UDSEntry::UDS_URL, url ); 00089 url = url.right( url.length() - url.lastIndexOf( "/" ) - 1 ); 00090 entry.insert( KIO::UDSEntry::UDS_NAME, url ); 00091 00092 return entry; 00093 } 00094
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:24 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:24 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.