summaryrefslogtreecommitdiffstats
path: root/tdeioslave/mbox/stat.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <michele.calgaro@yahoo.it>2020-12-15 11:30:44 +0900
committerMichele Calgaro <michele.calgaro@yahoo.it>2020-12-15 22:26:33 +0900
commit3a75bdfe83b71ef1dbc2fbf52f2d18b8174e22e5 (patch)
treeac71fb25d43d090e8073c77891c40697d47877d7 /tdeioslave/mbox/stat.cpp
parent2df45fd65d407b089967e948fa4a24439ef09458 (diff)
downloadtdepim-3a75bdfe83b71ef1dbc2fbf52f2d18b8174e22e5.tar.gz
tdepim-3a75bdfe83b71ef1dbc2fbf52f2d18b8174e22e5.zip
Renaming of files in preparation for code style tools.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeioslave/mbox/stat.cpp')
-rw-r--r--tdeioslave/mbox/stat.cpp115
1 files changed, 115 insertions, 0 deletions
diff --git a/tdeioslave/mbox/stat.cpp b/tdeioslave/mbox/stat.cpp
new file mode 100644
index 000000000..99267ca7d
--- /dev/null
+++ b/tdeioslave/mbox/stat.cpp
@@ -0,0 +1,115 @@
+/*
+ * This is a simple tdeioslave to handle mbox-files.
+ * Copyright (C) 2004 Mart Kelder (mart.kde@hccnet.nl)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include "stat.h"
+
+#include "readmbox.h"
+#include "urlinfo.h"
+
+#include <kdebug.h>
+#include <tdeio/global.h>
+
+#include <sys/stat.h>
+
+TDEIO::UDSEntry Stat::stat( const UrlInfo& info )
+{
+ if( info.type() == UrlInfo::message )
+ return Stat::statMessage( info );
+ else if( info.type() == UrlInfo::directory )
+ return Stat::statDirectory( info );
+ else
+ return TDEIO::UDSEntry();
+}
+
+TDEIO::UDSEntry Stat::stat( ReadMBox& mbox, const UrlInfo& info )
+{
+ kdDebug() << "Stat::stat()" << endl;
+ TDEIO::UDSEntry entry;
+ TQString url;
+
+ if( info.type() == UrlInfo::invalid )
+ return entry;
+ else if( info.type() == UrlInfo::message )
+ mbox.searchMessage( info.id() );
+
+ Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG );
+ Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" );
+
+ url = TQString( "mbox:%1/%2" ).arg( info.filename(), mbox.currentID() );
+ Stat::addAtom( entry, TDEIO::UDS_URL, url );
+ if( mbox.currentID().isEmpty() )
+ Stat::addAtom( entry, TDEIO::UDS_NAME, "foobar" );
+ else
+ Stat::addAtom( entry, TDEIO::UDS_NAME, mbox.currentID() );
+
+
+ Stat::addAtom( entry, TDEIO::UDS_SIZE, mbox.skipMessage() );
+
+ return entry;
+}
+
+TDEIO::UDSEntry Stat::statDirectory( const UrlInfo& info )
+{
+ kdDebug() << "statDirectory()" << endl;
+ TDEIO::UDSEntry entry;
+
+ //Specific things for a directory
+ Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFDIR );
+ Stat::addAtom( entry, TDEIO::UDS_NAME, info.filename() );
+
+ return entry;
+}
+
+TDEIO::UDSEntry Stat::statMessage( const UrlInfo& info )
+{
+ kdDebug() << "statMessage( " << info.url() << " )" << endl;
+ TDEIO::UDSEntry entry;
+ TQString url = TQString( "mbox:%1" ).arg( info.url() );
+
+ //Specific things for a message
+ Stat::addAtom( entry, TDEIO::UDS_FILE_TYPE, S_IFREG );
+ Stat::addAtom( entry, TDEIO::UDS_MIME_TYPE, "message/rfc822" );
+
+ Stat::addAtom( entry, TDEIO::UDS_URL, url );
+ url = url.right( url.length() - url.findRev( "/" ) - 1 );
+ Stat::addAtom( entry, TDEIO::UDS_NAME, url );
+
+ return entry;
+}
+
+void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, const TQString& str )
+{
+ TDEIO::UDSAtom atom;
+ atom.m_uds = uds;
+ atom.m_str = str;
+ atom.m_long = 0;
+
+ entry.append( atom );
+}
+
+
+void Stat::addAtom( TDEIO::UDSEntry& entry, unsigned int uds, long lng )
+{
+ TDEIO::UDSAtom atom;
+ atom.m_uds = uds;
+ atom.m_str = TQString();
+ atom.m_long = lng;
+
+ entry.append( atom );
+}
+