summaryrefslogtreecommitdiffstats
path: root/tdeioslaves/mbox/mbox.cc
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:05:15 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-01-27 01:05:15 -0600
commit64df902cf71a8ee258fb85f6be26248f399aa01f (patch)
treedba58f705042c22cea26b678d5b0e4e9a34bf202 /tdeioslaves/mbox/mbox.cc
parentde53c98cab07e9c4b0f5e25dab82830fb6fc67ec (diff)
downloadtdepim-64df902cf71a8ee258fb85f6be26248f399aa01f.tar.gz
tdepim-64df902cf71a8ee258fb85f6be26248f399aa01f.zip
Rename a number of libraries and executables to avoid conflicts with KDE4
Diffstat (limited to 'tdeioslaves/mbox/mbox.cc')
-rw-r--r--tdeioslaves/mbox/mbox.cc168
1 files changed, 168 insertions, 0 deletions
diff --git a/tdeioslaves/mbox/mbox.cc b/tdeioslaves/mbox/mbox.cc
new file mode 100644
index 000000000..477ef3502
--- /dev/null
+++ b/tdeioslaves/mbox/mbox.cc
@@ -0,0 +1,168 @@
+/*
+ * 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 <tqstring.h>
+#include <tqcstring.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+#include <kinstance.h>
+#include <kglobal.h>
+#include <kurl.h>
+#include <tdeio/global.h>
+
+#include <stdlib.h>
+
+#include "tdepimmacros.h"
+
+#include "mbox.h"
+
+extern "C" { KDE_EXPORT int kdemain(int argc, char* argv[]); }
+
+int kdemain( int argc, char * argv[] )
+{
+ KLocale::setMainCatalogue("tdelibs");
+ TDEInstance instance("kio_mbox");
+ (void) TDEGlobal::locale();
+
+ 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 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 );
+}
+