Git commit ccfcefbdd8dad8e43f722174db604e326a57e1dc by Montel Laurent. Committed on 02/04/2016 at 17:25. Pushed by mlaurent into branch 'master'.
Remove kioslave mbox M +0 -1 kioslave/docs/CMakeLists.txt D +0 -3 kioslave/docs/mbox/CMakeLists.txt D +0 -28 kioslave/docs/mbox/index.docbook M +0 -1 kioslave/src/CMakeLists.txt D +0 -1 kioslave/src/mbox/AUTHORS D +0 -24 kioslave/src/mbox/CMakeLists.txt D +0 -1 kioslave/src/mbox/Mainpage.dox D +0 -2 kioslave/src/mbox/Messages.sh D +0 -7 kioslave/src/mbox/README D +0 -158 kioslave/src/mbox/mbox.cpp D +0 -79 kioslave/src/mbox/mbox.h D +0 -14 kioslave/src/mbox/mbox.protocol D +0 -43 kioslave/src/mbox/mboxfile.cpp D +0 -74 kioslave/src/mbox/mboxfile.h D +0 -207 kioslave/src/mbox/readmbox.cpp D +0 -135 kioslave/src/mbox/readmbox.h D +0 -95 kioslave/src/mbox/stat.cpp D +0 -66 kioslave/src/mbox/stat.h D +0 -135 kioslave/src/mbox/urlinfo.cpp D +0 -93 kioslave/src/mbox/urlinfo.h http://commits.kde.org/kdepimlibs/ccfcefbdd8dad8e43f722174db604e326a57e1dc diff --git a/kioslave/docs/CMakeLists.txt b/kioslave/docs/CMakeLists.txt index 61a43d4..87b341a 100644 --- a/kioslave/docs/CMakeLists.txt +++ b/kioslave/docs/CMakeLists.txt @@ -3,5 +3,4 @@ add_subdirectory(ldap) add_subdirectory(nntp) add_subdirectory(pop3) add_subdirectory(smtp) -add_subdirectory(mbox) add_subdirectory(sieve) diff --git a/kioslave/docs/mbox/CMakeLists.txt b/kioslave/docs/mbox/CMakeLists.txt deleted file mode 100644 index 4285df8..0000000 --- a/kioslave/docs/mbox/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -########### install files ############### -kdoctools_create_handbook(index.docbook INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en SUBDIR kioslave5/mbox) - diff --git a/kioslave/docs/mbox/index.docbook b/kioslave/docs/mbox/index.docbook deleted file mode 100644 index 3b0647f..0000000 --- a/kioslave/docs/mbox/index.docbook +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" ?> -<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" -"dtd/kdedbx45.dtd" [ -<!ENTITY % addindex "IGNORE"> -<!ENTITY % English "INCLUDE" > <!-- change language only here --> -]> - -<article lang="&language;" id="mbox"> -<title>mbox</title> -<articleinfo> - -<authorgroup> -<author><personname><firstname>Bertjan</firstname><surname>Broeksema</surname></personname> -<email>[email protected]</email></author> -<!-- TRANS:ROLES_OF_TRANSLATORS --> -</authorgroup> - -<date>2009-11-05</date> - - -</articleinfo> - -<para>The mbox file format is an simple but rather inefficient way to store email -messages. All messages are appended after each other in the same file -separated by a special separator line. This gets especially expensive when -you have many emails in the same file.</para> - -</article> diff --git a/kioslave/src/CMakeLists.txt b/kioslave/src/CMakeLists.txt index 70a4695..de3ea2c 100644 --- a/kioslave/src/CMakeLists.txt +++ b/kioslave/src/CMakeLists.txt @@ -1,7 +1,6 @@ #remove it remove_definitions(-DQT_NO_CAST_FROM_BYTEARRAY) add_subdirectory(ldap) -add_subdirectory(mbox) add_subdirectory(nntp) add_subdirectory(sieve) add_subdirectory(smtp) diff --git a/kioslave/src/mbox/AUTHORS b/kioslave/src/mbox/AUTHORS deleted file mode 100644 index 333010f..0000000 --- a/kioslave/src/mbox/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Mart Kelder <[email protected]> diff --git a/kioslave/src/mbox/CMakeLists.txt b/kioslave/src/mbox/CMakeLists.txt deleted file mode 100644 index dff1884..0000000 --- a/kioslave/src/mbox/CMakeLists.txt +++ /dev/null @@ -1,24 +0,0 @@ - -########### next target ############### - -set(kio_mbox_PART_SRCS - mbox.cpp - mboxfile.cpp - readmbox.cpp - stat.cpp - urlinfo.cpp ) - - -add_library(kio_mbox MODULE ${kio_mbox_PART_SRCS}) - -target_link_libraries(kio_mbox KF5::KIOCore KF5::I18n) -set_target_properties(kio_mbox PROPERTIES OUTPUT_NAME "mbox") - -install(TARGETS kio_mbox DESTINATION ${KDE_INSTALL_PLUGINDIR}/kf5/kio/) - - -########### install files ############### - -install( FILES mbox.protocol DESTINATION ${KDE_INSTALL_KSERVICES5DIR}) - - diff --git a/kioslave/src/mbox/Mainpage.dox b/kioslave/src/mbox/Mainpage.dox deleted file mode 100644 index 57b7f27..0000000 --- a/kioslave/src/mbox/Mainpage.dox +++ /dev/null @@ -1 +0,0 @@ -// DOXYGEN_REFERENCES = kdecore kdeui kio diff --git a/kioslave/src/mbox/Messages.sh b/kioslave/src/mbox/Messages.sh deleted file mode 100755 index 3f6d40a..0000000 --- a/kioslave/src/mbox/Messages.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -$XGETTEXT *.cpp -o $podir/kio_mbox.pot diff --git a/kioslave/src/mbox/README b/kioslave/src/mbox/README deleted file mode 100644 index f044166..0000000 --- a/kioslave/src/mbox/README +++ /dev/null @@ -1,7 +0,0 @@ -This is a simple kioslave for accessing mbox-files with kio. - -At the moment, it doesn't support locking or writing, it is just reading and listing messages. - -Usage: - mbox:/path/to/mbox/file For listing the files in a mbox-file - mbox:/path/to/mbox/file/id For getting an id out of a mbox-file. diff --git a/kioslave/src/mbox/mbox.cpp b/kioslave/src/mbox/mbox.cpp deleted file mode 100644 index a64ce8a..0000000 --- a/kioslave/src/mbox/mbox.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 "mbox.h" - -#include "readmbox.h" -#include "stat.h" -#include "urlinfo.h" - -#include <QString> - -#include <qdebug.h> -#include <KLocalizedString> -#include <QCoreApplication> - -#include <kio/global.h> -#include <QUrl> - -#include <stdlib.h> - -extern "C" { - Q_DECL_EXPORT int kdemain(int argc, char *argv[]); -} - -int kdemain(int argc, char *argv[]) -{ - QCoreApplication app(argc, argv); - app.setApplicationName(QStringLiteral("kio_mbox")); - - if (argc != 4) { - fprintf(stderr, "Usage: kio_mbox protocol " - "domain-socket1 domain-socket2\n"); - exit(-1); - } - - MBoxProtocol slave(argv[2], argv[3]); - slave.dispatchLoop(); - - return 0; -} - -MBoxProtocol::MBoxProtocol(const QByteArray &arg1, const QByteArray &arg2) - : KIO::SlaveBase("mbox2", arg1, arg2) - , m_errorState(true) -{ -} - -MBoxProtocol::~MBoxProtocol() -{ -} - -void MBoxProtocol::get(const QUrl &url) -{ - m_errorState = false; - - UrlInfo info(url, UrlInfo::message); - QString line; - QByteArray ba_line; - - if (info.type() == UrlInfo::invalid && !m_errorState) { - error(KIO::ERR_DOES_NOT_EXIST, info.url()); - return; - } - - ReadMBox mbox(&info, this); - - while (!mbox.atEnd() && !m_errorState) { - line = mbox.currentLine(); - line += QLatin1Char('\n'); - ba_line = QByteArray(line.toUtf8()); - ba_line.truncate(ba_line.size() - 1); //Removing training '\0' - data(ba_line); - mbox.nextLine(); - }; - - if (!m_errorState) { - data(QByteArray()); - finished(); - } -} - -void MBoxProtocol::listDir(const QUrl &url) -{ - m_errorState = false; - - KIO::UDSEntry entry; - UrlInfo info(url, UrlInfo::directory); - ReadMBox mbox(&info, this, hasMetaData(QStringLiteral("onlynew")), hasMetaData(QStringLiteral("savetime"))); - - if (m_errorState) { - return; - } - - if (info.type() != UrlInfo::directory) { - error(KIO::ERR_DOES_NOT_EXIST, info.url()); - return; - } - - while (!mbox.atEnd() && !m_errorState) { - entry = Stat::stat(mbox, info); - if (mbox.inListing()) { - listEntry(entry); - } - } - - finished(); -} - -void MBoxProtocol::stat(const QUrl &url) -{ - UrlInfo info(url); - if (info.type() == UrlInfo::invalid) { - error(KIO::ERR_DOES_NOT_EXIST, url.path()); - return; - } else { - statEntry(Stat::stat(info)); - } - finished(); -} - -void MBoxProtocol::mimetype(const QUrl &url) -{ - m_errorState = false; - - UrlInfo info(url); - - if (m_errorState) { - return; - } - - if (info.type() == UrlInfo::invalid) { - error(KIO::ERR_DOES_NOT_EXIST, i18n("Invalid URL")); - } else { - mimeType(info.mimetype()); - } - finished(); -} - -void MBoxProtocol::emitError(int _errno, const QString &arg) -{ - m_errorState = true; - error(_errno, arg); -} diff --git a/kioslave/src/mbox/mbox.h b/kioslave/src/mbox/mbox.h deleted file mode 100644 index 48e2bf4..0000000 --- a/kioslave/src/mbox/mbox.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 - */ -#ifndef MBOX_H -#define MBOX_H - -#include <kio/slavebase.h> - -class QByteArray; - -/** - * This class is the main class and implements all function - * which can be called through the user. - */ -class MBoxProtocol : public KIO::SlaveBase -{ -public: - /** - * Constructor, for the parameters, See KIO::SlaveBase - */ - MBoxProtocol(const QByteArray &arg1, const QByteArray &arg2); - /** - * Empty destructor - */ - virtual ~MBoxProtocol(); - - /** - * This functions is used when an user or a program wants to - * get a file from a mbox-file - * @param url The url which points to the virtual file to get - */ - void get(const QUrl &url) Q_DECL_OVERRIDE; - - /** - * This functions gives a listing back. - * @param url The url to the mbox-file. - */ - void listDir(const QUrl &url) Q_DECL_OVERRIDE; - - /** - * This functions gives general properties about a mbox-file, - * or mbox-email back. - */ - void stat(const QUrl &url) Q_DECL_OVERRIDE; - - /** - * This functions determinate the mimetype of a given mbox-file or mbox-email. - * @param url The url to get the mimetype from - */ - void mimetype(const QUrl &url) Q_DECL_OVERRIDE; - - /** - * Through this functions, other class which have an instance to this - * class (classes which are part of kio_mbox) can emit an error with - * this function - * @param errno The error number to be thrown - * @param arg The argument of the error message of the error number. - */ - void emitError(int _errno, const QString &arg); -private: - bool m_errorState; -}; - -#endif diff --git a/kioslave/src/mbox/mbox.protocol b/kioslave/src/mbox/mbox.protocol deleted file mode 100644 index 30217d9..0000000 --- a/kioslave/src/mbox/mbox.protocol +++ /dev/null @@ -1,14 +0,0 @@ -[Protocol] -exec=kf5/kio/mbox -protocol=mbox -input=none -output=filesystem -listing=Name,Type,Size -reading=true -writing=false -makedir=false -deleting=false -Icon=mail-folder-inbox -maxInstances=2 -X-DocPath=kioslave5/mbox/index.html -Class=:local diff --git a/kioslave/src/mbox/mboxfile.cpp b/kioslave/src/mbox/mboxfile.cpp deleted file mode 100644 index c4af311..0000000 --- a/kioslave/src/mbox/mboxfile.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 "mboxfile.h" - -#include <assert.h> - -MBoxFile::MBoxFile(const UrlInfo *info, MBoxProtocol *parent) - : m_info(info) - , m_mbox(parent) -{ - assert(m_info); -} - -MBoxFile::~MBoxFile() -{ -} - -bool MBoxFile::lock() -{ - //Not implemented - return true; -} - -void MBoxFile::unlock() -{ - //Not implemented -} diff --git a/kioslave/src/mbox/mboxfile.h b/kioslave/src/mbox/mboxfile.h deleted file mode 100644 index 61896dd..0000000 --- a/kioslave/src/mbox/mboxfile.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 - */ -#ifndef MBOXFILE_H -#define MBOXFILE_H - -#include <qglobal.h> - -class MBoxProtocol; -class UrlInfo; - -/** - * This class can be used to lock files when implemented. - * It is a base class for all classes that needs locking and/ir - * an UrlInfo*. - */ -class MBoxFile -{ -public: - /** - * Constructor - * @param info The urlinfo which must be used - * @param parent The MBoxProtocol parent instance, used to throw errors. - */ - MBoxFile(const UrlInfo *info, MBoxProtocol *parent); - - /** - * Empty destructor - */ - ~MBoxFile(); - -protected: - /** - * When implemented, this function handles the locking of the file. - * @return true if the locking was done successfully. - */ - bool lock(); - - /** - * When implemented, this function unlocks the file. - */ - void unlock(); - -protected: - /** - * This can be used to get information about the file. - * The file specified here is the file that must be used. - */ - const UrlInfo *const m_info; - - /** - * A instance of the parent protocol, meant to throw errors if neccesairy. - */ - MBoxProtocol *const m_mbox; -private: - Q_DISABLE_COPY(MBoxFile) -}; - -#endif diff --git a/kioslave/src/mbox/readmbox.cpp b/kioslave/src/mbox/readmbox.cpp deleted file mode 100644 index 3b9f7a9..0000000 --- a/kioslave/src/mbox/readmbox.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 "readmbox.h" -#include "mbox.h" -#include "urlinfo.h" - -#include <qdebug.h> -#include <kio/global.h> - -#include <QDateTime> -#include <QFile> -#include <QFileInfo> -#include <QString> -#include <QTextStream> - -#include <utime.h> - -ReadMBox::ReadMBox(const UrlInfo *info, MBoxProtocol *parent, bool onlynew, bool savetime) - : MBoxFile(info, parent) - , m_file(0) - , m_stream(0) - , m_atend(true) - , m_prev_time(0) - , m_only_new(onlynew) - , m_savetime(savetime) - , m_status(false) - , m_prev_status(false) - , m_header(true) -{ - if (m_info->type() == UrlInfo::invalid) { - m_mbox->emitError(KIO::ERR_DOES_NOT_EXIST, info->url()); - } - - if (!open(savetime)) { - m_mbox->emitError(KIO::ERR_CANNOT_OPEN_FOR_READING, info->url()); - } - - if (m_info->type() == UrlInfo::message) { - if (!searchMessage(m_info->id())) { - m_mbox->emitError(KIO::ERR_DOES_NOT_EXIST, info->url()); - } - } -} - -ReadMBox::~ReadMBox() -{ - close(); -} - -QString ReadMBox::currentLine() const -{ - return m_current_line; -} - -QString ReadMBox::currentID() const -{ - return m_current_id; -} - -bool ReadMBox::nextLine() -{ - if (!m_stream) { - return true; - } - - m_current_line = m_stream->readLine(); - m_atend = m_current_line.isNull(); - if (m_atend) { // Cursor was at EOF - m_current_id.clear(); - m_prev_status = m_status; - return true; - } - - //New message - if (m_current_line.left(5) == QLatin1String("From ")) { - m_current_id = m_current_line; - m_prev_status = m_status; - m_status = true; - m_header = true; - return true; - } else if (m_only_new) { - if (m_header && m_current_line.left(7) == QLatin1String("Status:") && - ! m_current_line.contains(QLatin1String("U")) && ! m_current_line.contains(QLatin1String("N"))) { - m_status = false; - } - } - - if (m_current_line.trimmed().isEmpty()) { - m_header = false; - } - - return false; -} - -bool ReadMBox::searchMessage(const QString &id) -{ - if (!m_stream) { - return false; - } - - while (!m_atend && m_current_id != id) { - nextLine(); - } - - return m_current_id == id; -} - -unsigned int ReadMBox::skipMessage() -{ - unsigned int result = m_current_line.length(); - - if (!m_stream) { - return 0; - } - - while (!nextLine()) { - result += m_current_line.length(); - } - - return result; -} - -void ReadMBox::rewind() -{ - if (!m_stream) { - return; - } - - m_stream->device()->reset(); - m_atend = m_stream->atEnd(); -} - -bool ReadMBox::atEnd() const -{ - if (!m_stream) { - return true; - } - - return m_atend || (m_info->type() == UrlInfo::message && m_current_id != m_info->id()); -} - -bool ReadMBox::inListing() const -{ - return !m_only_new || m_prev_status; -} - -bool ReadMBox::open(bool savetime) -{ - if (savetime) { - QFileInfo info(m_info->filename()); - - m_prev_time = new utimbuf; - m_prev_time->actime = info.lastRead().toTime_t(); - m_prev_time->modtime = info.lastModified().toTime_t(); - } - - if (m_file) { - return false; //File already open - } - - m_file = new QFile(m_info->filename()); - if (!m_file->open(QIODevice::ReadOnly)) { - delete m_file; - m_file = 0; - return false; - } - m_stream = new QTextStream(m_file); - skipMessage(); - - return true; -} - -void ReadMBox::close() -{ - if (!m_stream) { - return; - } - - delete m_stream; - m_stream = 0; - m_file->close(); - delete m_file; - m_file = 0; - - if (m_prev_time) { - const QByteArray ba = QFile::encodeName(m_info->filename()); - utime(ba.constData(), m_prev_time); - delete m_prev_time; - m_prev_time = 0; - } -} diff --git a/kioslave/src/mbox/readmbox.h b/kioslave/src/mbox/readmbox.h deleted file mode 100644 index b6181cf..0000000 --- a/kioslave/src/mbox/readmbox.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 - */ -#ifndef READMBOX_H -#define READMBOX_H - -#include "mboxfile.h" -//Added by qt3to4: -#include <QTextStream> - -class UrlInfo; -class MBox; - -class QFile; -class QString; -class QTextStream; - -struct utimbuf; - -/** - * This class handels reading from a mbox-file. - */ -class ReadMBox : public MBoxFile -{ -public: - /** - * Constructor - * - * @param info The information of the file to read - * @param parent The instance of the parent MBoxProtocol. - * @param onlynew Only read new messages from the MBox file. - * @param savetime If true, the atime of the mbox-file is preserved (note that this touch the ctime). - */ - ReadMBox(const UrlInfo *info, MBoxProtocol *parent, bool onlynew = false, bool savetime = false); - - /** - * Destructor - */ - ~ReadMBox(); - - /** - * This functions return the current line - * @return The line last read, or QString() if there wasn't such last line - */ - QString currentLine() const; - - /** - * This function returns the current id. The id is the first line of an email, - * and is used in filenaming. The id normally starts with "From ". - * @return The current ID, or QString() if no id was found yet. - */ - QString currentID() const; - - /** - * This function reads the next line. The next line can be read by the currentLine() - * function call. - * - * @return true if succesfull, otherwise false. - */ - bool nextLine(); - - /** - * This function search the file for a certain id. - * If not found, the position is EOF. - * @param id The id of the message to be found. - * @return true if the message was found, false otherwise. - */ - bool searchMessage(const QString &id); - - /** - * Skips all lines which belongs to the current message. The cursor is on the first line - * of a new message message at the end of this function, or at EOF if the cursor was already - * on the last message. - * @return The number of bytes read while skipping the message. - */ - unsigned int skipMessage(); - - /** - * Sets the cursor back to the beginning of the file - */ - void rewind(); - - /** - * Returns true if the cursor is at EOF. - * @return true if and only if the cursor is at EOF. - */ - bool atEnd() const; - - /** - * Return true if the message is a new message, or all messages are listed - * @return true if it must be listed - */ - bool inListing() const; -private: - /** - * Opens a file - * @return true Returns true if opening was successful. - */ - bool open(bool savetime); - - /** - * Closes a file. - */ - void close(); - -private: - Q_DISABLE_COPY(ReadMBox) - QFile *m_file; - QTextStream *m_stream; - QString m_current_line; - QString m_current_id; - bool m_atend; - - struct utimbuf *m_prev_time; - - bool m_only_new, m_savetime; - - bool m_status, m_prev_status, m_header; -}; -#endif diff --git a/kioslave/src/mbox/stat.cpp b/kioslave/src/mbox/stat.cpp deleted file mode 100644 index 78b4b7f..0000000 --- a/kioslave/src/mbox/stat.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 <qdebug.h> -#include <kio/global.h> - -#include <sys/stat.h> - -KIO::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 KIO::UDSEntry(); - } -} - -KIO::UDSEntry Stat::stat(ReadMBox &mbox, const UrlInfo &info) -{ - qDebug() << "Stat::stat()"; - KIO::UDSEntry entry; - QString url; - - if (info.type() == UrlInfo::invalid) { - return entry; - } else if (info.type() == UrlInfo::message) { - mbox.searchMessage(info.id()); - } - - entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); - entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("message/rfc822")); - - url = QStringLiteral("mbox:%1/%2").arg(info.filename(), mbox.currentID()); - entry.insert(KIO::UDSEntry::UDS_URL, url); - if (mbox.currentID().isEmpty()) { - entry.insert(KIO::UDSEntry::UDS_NAME, QLatin1String("")); - } else { - entry.insert(KIO::UDSEntry::UDS_NAME, mbox.currentID()); - } - - entry.insert(KIO::UDSEntry::UDS_SIZE, mbox.skipMessage()); - - return entry; -} - -KIO::UDSEntry Stat::statDirectory(const UrlInfo &info) -{ - qDebug() << "statDirectory()"; - KIO::UDSEntry entry; - - //Specific things for a directory - entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); - entry.insert(KIO::UDSEntry::UDS_NAME, info.filename()); - - return entry; -} - -KIO::UDSEntry Stat::statMessage(const UrlInfo &info) -{ - qDebug() << "statMessage(" << info.url() << " )"; - KIO::UDSEntry entry; - QString url = QStringLiteral("mbox:%1").arg(info.url()); - - //Specific things for a message - entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); - entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("message/rfc822")); - - entry.insert(KIO::UDSEntry::UDS_URL, url); - url = url.right(url.length() - url.lastIndexOf(QLatin1Char('/')) - 1); - entry.insert(KIO::UDSEntry::UDS_NAME, url); - - return entry; -} diff --git a/kioslave/src/mbox/stat.h b/kioslave/src/mbox/stat.h deleted file mode 100644 index 3265054..0000000 --- a/kioslave/src/mbox/stat.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 - */ -#ifndef STAT_H -#define STAT_H - -#include <kio/global.h> -#include <kio/udsentry.h> - -class ReadMBox; -class UrlInfo; - -/** - * This class is used to get the stats of a mbox-email or mbox-file. - * This class only uses static members. - */ -class Stat -{ -public: - /** - * This functions gives information with a given UrlInfo. - * @param info The file information - * @return The information of the file as destribed in UrlInfo. - */ - static KIO::UDSEntry stat(const UrlInfo &info); - /** - * This function gives information with a given ReadMBox and UrlInfo. - * Through this, it is possible to ask the stats of the next message, - * without reopening the mbox-file. - * @param mbox The ReadMBox instance, used to search the mbox-email in. - * @param info The url information. - * @return The requesteds information. - */ - static KIO::UDSEntry stat(ReadMBox &mbox, const UrlInfo &info); - - /** - * This function gets the stats of a given mbox-file in an UDSEntry. - * @param info The location of the mbox-file. - * @return A list of Atoms. - */ - static KIO::UDSEntry statDirectory(const UrlInfo &info); - - /** - * This function gets the stats of a geven mbox-message in a UDSEntry. - * @param info The url of the mbox-message. - * @return Information shipped in an UDSEntry. - */ - static KIO::UDSEntry statMessage(const UrlInfo &info); -}; - -#endif diff --git a/kioslave/src/mbox/urlinfo.cpp b/kioslave/src/mbox/urlinfo.cpp deleted file mode 100644 index 5e9cbb6..0000000 --- a/kioslave/src/mbox/urlinfo.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 "urlinfo.h" - -#include <qdebug.h> -#include <qurl.h> - -#include <QFileInfo> -#include <QString> - -UrlInfo::UrlInfo(const QUrl &url, const UrlType type) - : m_type(invalid) - , m_filename(new QString) - , m_id(new QString) -{ - calculateInfo(url, type); -} - -UrlInfo::~UrlInfo() -{ - delete m_filename; - delete m_id; -} - -QString UrlInfo::mimetype() const -{ - switch (m_type) { - case message: - return QStringLiteral("message/rfc822"); - case directory: - return QStringLiteral("inode/directory"); - case invalid: - default: - return QStringLiteral("invalid"); - } -} - -QString UrlInfo::filename() const -{ - return *m_filename; -} - -QString UrlInfo::id() const -{ - return *m_id; -} - -QString UrlInfo::url() const -{ - return *m_filename + QLatin1Char('/') + *m_id; -} - -void UrlInfo::calculateInfo(const QUrl &url, const UrlType type) -{ - bool found = false; - - if (!found && type & UrlInfo::message) { - found = isMessage(url); - } - if (!found && type & UrlInfo::directory) { - found = isDirectory(url); - } - if (!found) { - m_type = invalid; - *m_filename = QLatin1String(""); - *m_id = QLatin1String(""); - } -} - -bool UrlInfo::isDirectory(const QUrl &url) -{ - //Check is url is in the form mbox://{filename} - QString filename = url.path(); - QFileInfo info; - - //Remove ending / - while (filename.length() > 1 && filename.right(1) == QLatin1String("/")) { - filename.remove(filename.length() - 2, 1); - } - - //Is this a directory? - info.setFile(filename); - if (!info.isFile()) { - return false; - } - - //Setting parameters - *m_filename = filename; - (*m_id).clear(); - m_type = directory; - qDebug() << "urlInfo::isDirectory(" << url << " )"; - return true; -} - -bool UrlInfo::isMessage(const QUrl &url) -{ - QString path = url.path(); - QFileInfo info; - int cutindex = path.lastIndexOf(QLatin1Char('/')); - - //Does it contain at least one /? - if (cutindex < 0) { - return false; - } - - //Does the mbox-file exists? - info.setFile(path.left(cutindex)); - if (!info.isFile()) { - return false; - } - - //Settings parameters - qDebug() << "urlInfo::isMessage(" << url << " )"; - m_type = message; - *m_id = path.right(path.length() - cutindex - 1); - *m_filename = path.left(cutindex); - - return true; -} diff --git a/kioslave/src/mbox/urlinfo.h b/kioslave/src/mbox/urlinfo.h deleted file mode 100644 index 78787b0..0000000 --- a/kioslave/src/mbox/urlinfo.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * This is a simple kioslave to handle mbox-files. - * Copyright (C) 2004 Mart Kelder ([email protected]) - * - * 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 - */ -#ifndef URLINFO_H -#define URLINFO_H - -#include <qglobal.h> - -class QUrl; -class QString; - -class UrlInfo -{ -public: - /** - * This enum is used to determe the url type. - */ - enum UrlType { - invalid = 0, - message = 1, - directory = 2 - }; - - /** - * Constructor - * - * @param url The url: this url is used to split the location data off. - * @param type The possible types of the url - */ - explicit UrlInfo(const QUrl &url, const UrlType type = (UrlType)(message | directory)); - - /** - * Destructor - */ - ~UrlInfo(); - - /** - * Returns the type of the url - * @return the type of the url - */ - UrlType type() const - { - return m_type; - } - - /** - * @return the mimetype of the url - */ - QString mimetype() const; - - /** - * @return The location of the mbox-file - */ - QString filename() const; - /** - * @return The id given in the url. - */ - QString id() const; - - /** - * @return the while url as QString - */ - QString url() const; - -private: - void calculateInfo(const QUrl &url, const UrlType type); - - bool isDirectory(const QUrl &url); - bool isMessage(const QUrl &url); - -private: - Q_DISABLE_COPY(UrlInfo) - UrlType m_type; - QString *m_filename; - QString *m_id; -}; - -#endif _______________________________________________ kde-doc-english mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-doc-english
