From ca705978d11b2e0bdcaf8186b0addff48d851483 Mon Sep 17 00:00:00 2001 From: Darrell Anderson Date: Thu, 6 Feb 2014 17:54:49 -0600 Subject: Reorganize tdeioslave help handbooks, fix related protocol files and issues, update and add handbooks. --- tdeioslaves/mbox/AUTHORS | 1 - tdeioslaves/mbox/CMakeLists.txt | 36 ------- tdeioslaves/mbox/Makefile.am | 30 ------ tdeioslaves/mbox/README | 7 -- tdeioslaves/mbox/mbox.cc | 168 --------------------------------- tdeioslaves/mbox/mbox.h | 81 ---------------- tdeioslaves/mbox/mbox.protocol | 14 --- tdeioslaves/mbox/mboxfile.cc | 45 --------- tdeioslaves/mbox/mboxfile.h | 68 -------------- tdeioslaves/mbox/readmbox.cc | 204 ---------------------------------------- tdeioslaves/mbox/readmbox.h | 132 -------------------------- tdeioslaves/mbox/stat.cc | 115 ---------------------- tdeioslaves/mbox/stat.h | 82 ---------------- tdeioslaves/mbox/urlinfo.cc | 133 -------------------------- tdeioslaves/mbox/urlinfo.h | 82 ---------------- 15 files changed, 1198 deletions(-) delete mode 100644 tdeioslaves/mbox/AUTHORS delete mode 100644 tdeioslaves/mbox/CMakeLists.txt delete mode 100644 tdeioslaves/mbox/Makefile.am delete mode 100644 tdeioslaves/mbox/README delete mode 100644 tdeioslaves/mbox/mbox.cc delete mode 100644 tdeioslaves/mbox/mbox.h delete mode 100644 tdeioslaves/mbox/mbox.protocol delete mode 100644 tdeioslaves/mbox/mboxfile.cc delete mode 100644 tdeioslaves/mbox/mboxfile.h delete mode 100644 tdeioslaves/mbox/readmbox.cc delete mode 100644 tdeioslaves/mbox/readmbox.h delete mode 100644 tdeioslaves/mbox/stat.cc delete mode 100644 tdeioslaves/mbox/stat.h delete mode 100644 tdeioslaves/mbox/urlinfo.cc delete mode 100644 tdeioslaves/mbox/urlinfo.h (limited to 'tdeioslaves/mbox') diff --git a/tdeioslaves/mbox/AUTHORS b/tdeioslaves/mbox/AUTHORS deleted file mode 100644 index 333010f6..00000000 --- a/tdeioslaves/mbox/AUTHORS +++ /dev/null @@ -1 +0,0 @@ -Mart Kelder diff --git a/tdeioslaves/mbox/CMakeLists.txt b/tdeioslaves/mbox/CMakeLists.txt deleted file mode 100644 index e74682fa..00000000 --- a/tdeioslaves/mbox/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -################################################# -# -# (C) 2010-2011 Serghei Amelian -# serghei (DOT) amelian (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR}/libtdepim - ${TDE_INCLUDE_DIR} - ${TQT_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### other data ################################ - -install( FILES mbox.protocol DESTINATION ${SERVICES_INSTALL_DIR} ) - - -##### tdeio_mbox (module) ######################### - -tde_add_kpart( tdeio_mbox - SOURCES - mbox.cc mboxfile.cc readmbox.cc stat.cc urlinfo.cc - LINK tdeio-shared - DESTINATION ${PLUGIN_INSTALL_DIR} -) diff --git a/tdeioslaves/mbox/Makefile.am b/tdeioslaves/mbox/Makefile.am deleted file mode 100644 index 4dea4644..00000000 --- a/tdeioslaves/mbox/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -INCLUDES= $(all_includes) - -####### Files - -METASOURCES = AUTO - -kde_module_LTLIBRARIES = tdeio_mbox.la - -tdeio_mbox_la_SOURCES = \ - mbox.cc \ - mboxfile.cc \ - readmbox.cc \ - stat.cc \ - urlinfo.cc -tdeio_mbox_la_LIBADD = $(LIB_TDEIO) $(LIB_QT) $(LIB_TDECORE) -tdeio_mbox_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module $(KDE_PLUGIN) - -noinst_HEADERS = \ - mbox.h \ - mboxfile.h \ - readmbox.h \ - stat.h \ - urlinfo.h - -kdelnk_DATA = mbox.protocol -kdelnkdir = $(kde_servicesdir) - - -include $(top_srcdir)/admin/Doxyfile.am - diff --git a/tdeioslaves/mbox/README b/tdeioslaves/mbox/README deleted file mode 100644 index d09e8179..00000000 --- a/tdeioslaves/mbox/README +++ /dev/null @@ -1,7 +0,0 @@ -This is a simple tdeioslave for accessing mbox-files with tdeio. - -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/tdeioslaves/mbox/mbox.cc b/tdeioslaves/mbox/mbox.cc deleted file mode 100644 index 5742baff..00000000 --- a/tdeioslaves/mbox/mbox.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* - * 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 "mbox.h" - -#include "readmbox.h" -#include "stat.h" -#include "urlinfo.h" - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include - -#include "tdepimmacros.h" - -#include "mbox.h" - -extern "C" { KDE_EXPORT int kdemain(int argc, char* argv[]); } - -int kdemain( int argc, char * argv[] ) -{ - TDELocale::setMainCatalogue("tdelibs"); - TDEInstance instance("tdeio_mbox"); - (void) TDEGlobal::locale(); - - if (argc != 4) { - fprintf(stderr, "Usage: tdeio_mbox protocol " - "domain-socket1 domain-socket2\n"); - exit(-1); - } - - MBoxProtocol slave(argv[2], argv[3]); - slave.dispatchLoop(); - - return 0; -} - -MBoxProtocol::MBoxProtocol( const TQCString& arg1, const TQCString& arg2 ) - : TDEIO::SlaveBase( "mbox2", arg1, arg2 ), - m_errorState( true ) -{ - -} - -MBoxProtocol::~MBoxProtocol() -{ -} - -void MBoxProtocol::get( const KURL& url ) -{ - m_errorState = false; - - UrlInfo info( url, UrlInfo::message ); - TQString line; - TQByteArray ba_line; - - if( info.type() == UrlInfo::invalid && !m_errorState ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); - return; - } - - ReadMBox mbox( &info, this ); - - while( !mbox.atEnd() && !m_errorState) - { - line = mbox.currentLine(); - line += '\n'; - ba_line = TQCString( line.utf8() ); - ba_line.truncate( ba_line.size() - 1 ); //Removing training '\0' - data( ba_line ); - mbox.nextLine(); - }; - - if( !m_errorState ) - { - data( TQByteArray() ); - finished(); - } -} - -void MBoxProtocol::listDir( const KURL& url ) -{ - m_errorState = false; - - TDEIO::UDSEntry entry; - UrlInfo info( url, UrlInfo::directory ); - ReadMBox mbox( &info, this, hasMetaData( "onlynew" ), hasMetaData( "savetime" ) ); - - if( m_errorState ) - return; - - if( info.type() != UrlInfo::directory ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, info.url() ); - return; - } - - while( !mbox.atEnd() && !m_errorState ) - { - entry = Stat::stat( mbox, info ); - if( mbox.inListing() ) - listEntry( entry, false ); - } - - listEntry( TDEIO::UDSEntry(), true ); - finished(); -} - -void MBoxProtocol::stat( const KURL& url ) -{ - UrlInfo info( url ); - if( info.type() == UrlInfo::invalid ) - { - error( TDEIO::ERR_DOES_NOT_EXIST, url.path() ); - return; - } else - { - statEntry( Stat::stat( info ) ); - } - finished(); -} - -void MBoxProtocol::mimetype( const KURL& url ) -{ - m_errorState = false; - - UrlInfo info( url ); - - if( m_errorState ) - return; - - if( info.type() == UrlInfo::invalid ) - error( TDEIO::ERR_DOES_NOT_EXIST, i18n( "Invalid URL" ) ); - else - mimeType( info.mimetype() ); - finished(); -} - -void MBoxProtocol::emitError( int errno, const TQString& arg ) -{ - m_errorState = true; - error( errno, arg ); -} - diff --git a/tdeioslaves/mbox/mbox.h b/tdeioslaves/mbox/mbox.h deleted file mode 100644 index 5834b5a0..00000000 --- a/tdeioslaves/mbox/mbox.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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 - */ -#ifndef MBOX_H -#define MBOX_H - -#include - -class TQCString; -class KURL; - -/** - * This class is the main class and implements all function - * which can be called through the user. - */ -class MBoxProtocol : public TDEIO::SlaveBase -{ -public: - /** - * Constructor, for the parameters, See TDEIO::SlaveBase - */ - MBoxProtocol( const TQCString&, const TQCString& ); - /** - * 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 - */ - virtual void get( const KURL& url ); - - /** - * This functions gives a listing back. - * @param url The url to the mbox-file. - */ - virtual void listDir( const KURL& url ); - - /** - * This functions gives general properties about a mbox-file, - * or mbox-email back. - */ - virtual void stat( const KURL& url ); - - /** - * This functions determinate the mimetype of a given mbox-file or mbox-email. - * @param url The url to get the mimetype from - */ - virtual void mimetype( const KURL& url ); - - /** - * Through this functions, other class which have an instance to this - * class (classes which are part of tdeio_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 TQString& arg ); -private: - bool m_errorState; -}; - -#endif - diff --git a/tdeioslaves/mbox/mbox.protocol b/tdeioslaves/mbox/mbox.protocol deleted file mode 100644 index 5b5447dc..00000000 --- a/tdeioslaves/mbox/mbox.protocol +++ /dev/null @@ -1,14 +0,0 @@ -[Protocol] -exec=tdeio_mbox -protocol=mbox -input=none -output=filesystem -listing=Name,Type,Size -reading=true -writing=false -makedir=false -deleting=false -Icon=folder_inbox -maxInstances=2 -DocPath=tdeioslave/mbox/index.html -Class=:local diff --git a/tdeioslaves/mbox/mboxfile.cc b/tdeioslaves/mbox/mboxfile.cc deleted file mode 100644 index 7297457e..00000000 --- a/tdeioslaves/mbox/mboxfile.cc +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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 "mboxfile.h" - -#include - -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/tdeioslaves/mbox/mboxfile.h b/tdeioslaves/mbox/mboxfile.h deleted file mode 100644 index 1defafc9..00000000 --- a/tdeioslaves/mbox/mboxfile.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 - */ -#ifndef MBOXFILE_H -#define MBOXFILE_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 succesfully. - */ - 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; -}; -#endif diff --git a/tdeioslaves/mbox/readmbox.cc b/tdeioslaves/mbox/readmbox.cc deleted file mode 100644 index 942f369e..00000000 --- a/tdeioslaves/mbox/readmbox.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * 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 - -#include "readmbox.h" - -#include "mbox.h" -#include "urlinfo.h" - -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#include - -ReadMBox::ReadMBox( const UrlInfo* info, MBoxProtocol* parent, bool onlynew, bool savetime ) - : MBoxFile( info, parent ), - m_file( 0 ), - m_stream( 0 ), - m_current_line( new TQString( TQString() ) ), - m_current_id( new TQString( TQString() ) ), - 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( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); - - if( !open( savetime ) ) - m_mbox->emitError( TDEIO::ERR_CANNOT_OPEN_FOR_READING, info->url() ); - - if( m_info->type() == UrlInfo::message ) - if( !searchMessage( m_info->id() ) ) - m_mbox->emitError( TDEIO::ERR_DOES_NOT_EXIST, info->url() ); -} - -ReadMBox::~ReadMBox() -{ - delete m_current_line; - close(); -} - -TQString ReadMBox::currentLine() const -{ - return *m_current_line; -} - -TQString 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 = TQString(); - m_prev_status = m_status; - return true; - } - - //New message - if( m_current_line->left( 5 ) == "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 ) == "Status:" && - ! m_current_line->contains( "U" ) && ! m_current_line->contains( "N" ) ) - { - m_status = false; - } - } - - if( m_current_line->stripWhiteSpace().isEmpty() ) - m_header = false; - - return false; -} - -bool ReadMBox::searchMessage( const TQString& 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; //Rewinding not possible - - 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 ) - { - TQFileInfo 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 TQFile( m_info->filename() ); - if( !m_file->open( IO_ReadOnly ) ) - { - delete m_file; - m_file = 0; - return false; - } - m_stream = new TQTextStream( 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 ) - utime( TQFile::encodeName( m_info->filename() ), m_prev_time ); -} - diff --git a/tdeioslaves/mbox/readmbox.h b/tdeioslaves/mbox/readmbox.h deleted file mode 100644 index 0b887276..00000000 --- a/tdeioslaves/mbox/readmbox.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * 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 - */ -#ifndef READMBOX_H -#define READMBOX_H - -#include "mboxfile.h" - -class UrlInfo; -class MBox; - -class TQFile; -class TQString; -class TQTextStream; - -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 TQString() if there wasn't such last line - */ - TQString 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 TQString() if no id was found yet. - */ - TQString 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 TQString& 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 succesful. - */ - bool open( bool savetime ); - - /** - * Closes a file. - */ - void close(); - -private: - TQFile* m_file; - TQTextStream* m_stream; - TQString* m_current_line; - TQString* 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/tdeioslaves/mbox/stat.cc b/tdeioslaves/mbox/stat.cc deleted file mode 100644 index 99267ca7..00000000 --- a/tdeioslaves/mbox/stat.cc +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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 -#include - -#include - -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 ); -} - diff --git a/tdeioslaves/mbox/stat.h b/tdeioslaves/mbox/stat.h deleted file mode 100644 index 4e2c1f02..00000000 --- a/tdeioslaves/mbox/stat.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - */ -#ifndef STAT_H -#define STAT_H - -#include - -class ReadMBox; -class UrlInfo; - -class KURL; - -class TQString; - -/** - * This class is used to get the stats of a mbox-email or mbox-file. - * This class only uses static members. - */ -class Stat -{ -public: - /** - * Empty constructor - */ - Stat() {} - - /** - * Emtpy destructor - */ - ~Stat() {} - - /** - * This functions gives information with a given UrlInfo. - * @param info The file information - * @return The information of the file as destribed in UrlInfo. - */ - static TDEIO::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 TDEIO::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 TDEIO::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 TDEIO::UDSEntry statMessage( const UrlInfo& info ); -private: - static void addAtom( TDEIO::UDSEntry& entry, unsigned int key, const TQString& value ); - static void addAtom( TDEIO::UDSEntry& entry, unsigned int key, const long value ); -}; - -#endif diff --git a/tdeioslaves/mbox/urlinfo.cc b/tdeioslaves/mbox/urlinfo.cc deleted file mode 100644 index 4b359e40..00000000 --- a/tdeioslaves/mbox/urlinfo.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* - * 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 "urlinfo.h" - -#include -#include - -#include -#include - -UrlInfo::UrlInfo( const KURL& url, const UrlType type ) - : m_type( invalid ), - m_filename( new TQString ), - m_id( new TQString ) -{ - calculateInfo( url, type ); -} - -UrlInfo::~UrlInfo() -{ - delete m_filename; - delete m_id; -} - -TQString UrlInfo::mimetype() const -{ - switch( m_type ) - { - case message: - return "message/rfc822"; - case directory: - return "inode/directory"; - case invalid: - default: - return "invalid"; - } -} - -TQString UrlInfo::filename() const -{ - return *m_filename; -} - -TQString UrlInfo::id() const -{ - return *m_id; -} - -TQString UrlInfo::url() const -{ - return *m_filename + "/" + *m_id; -} - - -void UrlInfo::calculateInfo( const KURL& 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 = ""; - *m_id = ""; - } -} - -bool UrlInfo::isDirectory( const KURL& url ) -{ - //Check is url is in the form mbox://{filename} - TQString filename = url.path(); - TQFileInfo info; - - //Remove ending / - while( filename.length() > 1 && filename.right( 1 ) == "/" ) - filename.remove( filename.length()-2, 1 ); - - //Is this a directory? - info.setFile( filename ); - if( !info.isFile() ) - return false; - - //Setting paramaters - *m_filename = filename; - *m_id = TQString(); - m_type = directory; - kdDebug() << "urlInfo::isDirectory( " << url << " )" << endl; - return true; -} - -bool UrlInfo::isMessage( const KURL& url ) -{ - TQString path = url.path(); - TQFileInfo info; - int cutindex = path.findRev( '/' ); - - //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 - kdDebug() << "urlInfo::isMessage( " << url << " )" << endl; - m_type = message; - *m_id = path.right( path.length() - cutindex - 1 ); - *m_filename = path.left( cutindex ); - - return true; -} - diff --git a/tdeioslaves/mbox/urlinfo.h b/tdeioslaves/mbox/urlinfo.h deleted file mode 100644 index 5de7804f..00000000 --- a/tdeioslaves/mbox/urlinfo.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * 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 - */ -#ifndef URLINFO_H -#define URLINFO_H -class KURL; - -class TQString; - -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 - */ - UrlInfo( const KURL &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 - */ - TQString mimetype() const; - - /** - * @return The location of the mbox-file - */ - TQString filename() const; - /** - * @return The id given in the url. - */ - TQString id() const; - - /** - * @return the while url as TQString - */ - TQString url() const; -private: - void calculateInfo( const KURL& url, const UrlType type ); - - bool isDirectory( const KURL& url ); - bool isMessage( const KURL& url ); - -private: - UrlType m_type; - TQString *m_filename; - TQString *m_id; -}; - -#endif -- cgit v1.2.3