From c5bee2a602f3b6a9ca58c247df52b834ea50d0ed Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 21:04:28 -0600 Subject: Rename kiobuffer and KHTML --- akregator/ChangeLog | 2 +- akregator/src/Makefile.am | 4 +- akregator/src/mainwindow.cpp | 2 +- akregator/src/pageviewer.cpp | 8 +- akregator/src/tabwidget.cpp | 4 +- akregator/src/viewer.cpp | 6 +- akregator/src/viewer.h | 2 +- cmake | 2 +- kaddressbook/Makefile.am | 2 +- kitchensync/src/Makefile.am | 4 +- kitchensync/src/aboutpage.cpp | 2 +- kmail/Mainpage.dox | 2 +- kmail/Makefile.am | 2 +- kmail/interfaces/htmlwriter.h | 2 +- kmail/kmmessage.cpp | 2 +- kmail/kmmessage.h | 2 +- kmail/kmreaderwin.cpp | 8 +- kmail/kmreaderwin.h | 10 +- kmail/tdehtmlparthtmlwriter.cpp | 2 +- kmail/tdehtmlparthtmlwriter.h | 12 +- kmobile/tdeioslave/kio_mobile.cpp | 636 ------------------------------------ kmobile/tdeioslave/kio_mobile.h | 70 ---- kmobile/tdeioslave/tdeio_mobile.cpp | 636 ++++++++++++++++++++++++++++++++++++ kmobile/tdeioslave/tdeio_mobile.h | 70 ++++ knode/Makefile.am | 2 +- knode/articlewidget.cpp | 4 +- knode/articlewidget.h | 4 +- kontact/src/Makefile.am | 2 +- kontact/src/mainwindow.cpp | 2 +- kontact/src/mainwindow.h | 4 +- korganizer/Makefile.am | 2 +- korn/kio_count.cpp | 330 ------------------- korn/kio_count.h | 82 ----- korn/kio_delete.cpp | 201 ------------ korn/kio_delete.h | 70 ---- korn/kio_proto.cpp | 81 ----- korn/kio_proto.h | 157 --------- korn/kio_read.cpp | 97 ------ korn/kio_read.h | 61 ---- korn/kio_single_subject.cpp | 155 --------- korn/kio_single_subject.h | 68 ---- korn/kio_subjects.cpp | 176 ---------- korn/kio_subjects.h | 75 ----- korn/tdeio_count.cpp | 330 +++++++++++++++++++ korn/tdeio_count.h | 82 +++++ korn/tdeio_delete.cpp | 201 ++++++++++++ korn/tdeio_delete.h | 70 ++++ korn/tdeio_proto.cpp | 81 +++++ korn/tdeio_proto.h | 157 +++++++++ korn/tdeio_read.cpp | 97 ++++++ korn/tdeio_read.h | 61 ++++ korn/tdeio_single_subject.cpp | 155 +++++++++ korn/tdeio_single_subject.h | 68 ++++ korn/tdeio_subjects.cpp | 176 ++++++++++ korn/tdeio_subjects.h | 75 +++++ libtdepim/csshelper.cpp | 2 +- 56 files changed, 2310 insertions(+), 2310 deletions(-) delete mode 100644 kmobile/tdeioslave/kio_mobile.cpp delete mode 100644 kmobile/tdeioslave/kio_mobile.h create mode 100644 kmobile/tdeioslave/tdeio_mobile.cpp create mode 100644 kmobile/tdeioslave/tdeio_mobile.h delete mode 100644 korn/kio_count.cpp delete mode 100644 korn/kio_count.h delete mode 100644 korn/kio_delete.cpp delete mode 100644 korn/kio_delete.h delete mode 100644 korn/kio_proto.cpp delete mode 100644 korn/kio_proto.h delete mode 100644 korn/kio_read.cpp delete mode 100644 korn/kio_read.h delete mode 100644 korn/kio_single_subject.cpp delete mode 100644 korn/kio_single_subject.h delete mode 100644 korn/kio_subjects.cpp delete mode 100644 korn/kio_subjects.h create mode 100644 korn/tdeio_count.cpp create mode 100644 korn/tdeio_count.h create mode 100644 korn/tdeio_delete.cpp create mode 100644 korn/tdeio_delete.h create mode 100644 korn/tdeio_proto.cpp create mode 100644 korn/tdeio_proto.h create mode 100644 korn/tdeio_read.cpp create mode 100644 korn/tdeio_read.h create mode 100644 korn/tdeio_single_subject.cpp create mode 100644 korn/tdeio_single_subject.h create mode 100644 korn/tdeio_subjects.cpp create mode 100644 korn/tdeio_subjects.h diff --git a/akregator/ChangeLog b/akregator/ChangeLog index 9da56ce79..217f7c031 100644 --- a/akregator/ChangeLog +++ b/akregator/ChangeLog @@ -418,7 +418,7 @@ Changes from 0.9 to 1.0b1: #000002 FIX [x] update ArticleList when selecting another feed #000026 CHG [x] unless someone offers me some icons, Fetch and Fetch all will be 'down' and 'bottom' respectively #000023 FIX [x] implement fetch all -#000024 CHG [x] replace generic HTML part with strictly KHTMLPart (saves some static_cast<>s) +#000024 CHG [x] replace generic HTML part with strictly TDEHTMLPart (saves some static_cast<>s) #000018 ADD [x] provide .desktop file #000017 ADD [x] provide .lsm file #000016 ADD [x] provide standard AUTHORS, ChangeLog, README, and TODO files diff --git a/akregator/src/Makefile.am b/akregator/src/Makefile.am index e212b260c..f88d0eabb 100644 --- a/akregator/src/Makefile.am +++ b/akregator/src/Makefile.am @@ -78,7 +78,7 @@ libakregatorprivate_la_SOURCES = akregatorconfig.kcfgc \ libakregatorprivate_la_LDFLAGS = $(all_libraries) -avoid-version -no-undefined libakregatorprivate_la_LIBADD = $(top_builddir)/libtdepim/libtdepim.la \ - $(top_builddir)/akregator/src/librss/librsslocal.la $(LIB_KHTML) + $(top_builddir)/akregator/src/librss/librsslocal.la $(LIB_TDEHTML) ######################################################################### # KPART SECTION @@ -146,7 +146,7 @@ libakregatorpart_la_SOURCES = \ kspeech.stub libakregatorpart_la_LDFLAGS = $(KDE_RPATH) $(KDE_PLUGIN) $(LIB_KUTILS) -avoid-version -no-undefined $(all_libraries) -libakregatorpart_la_LIBADD = libakregatorprivate.la $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_KHTML) $(LIB_KIO) $(LIB_KPARTS) -lDCOP -L$(top_builddir)/libtdepim -ltdepim +libakregatorpart_la_LIBADD = libakregatorprivate.la $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEHTML) $(LIB_KIO) $(LIB_KPARTS) -lDCOP -L$(top_builddir)/libtdepim -ltdepim # this is where the desktop file will go partdesktopdir = $(kde_servicesdir) diff --git a/akregator/src/mainwindow.cpp b/akregator/src/mainwindow.cpp index 293d60ada..065d02480 100644 --- a/akregator/src/mainwindow.cpp +++ b/akregator/src/mainwindow.cpp @@ -237,7 +237,7 @@ bool MainWindow::queryExit() kdDebug() << "MainWindow::queryExit()" << endl; if ( !kapp->sessionSaving() ) { - delete m_part; // delete that here instead of dtor to ensure nested tdehtmlparts are deleted before singleton objects like KHTMLPageCache + delete m_part; // delete that here instead of dtor to ensure nested tdehtmlparts are deleted before singleton objects like TDEHTMLPageCache m_part = 0; } else diff --git a/akregator/src/pageviewer.cpp b/akregator/src/pageviewer.cpp index 195237220..63d944c6b 100644 --- a/akregator/src/pageviewer.cpp +++ b/akregator/src/pageviewer.cpp @@ -100,7 +100,7 @@ PageViewer::PageViewer(TQWidget *parent, const char *name) { // this hack is necessary since the part looks for []HTML Settings] in // TDEGlobal::config() by default, which is wrong when running in Kontact - KHTMLSettings* s = const_cast (settings()); + TDEHTMLSettings* s = const_cast (settings()); s->init(Settings::self()->config()); setXMLFile(locate("data", "akregator/pageviewer.rc"), true); @@ -251,7 +251,7 @@ bool PageViewer::openURL(const KURL& url) updateHistoryEntry(); // update old history entry before switching to the new one emit started(0); - bool val = KHTMLPart::openURL(url); + bool val = TDEHTMLPart::openURL(url); addHistoryEntry(url); // add new URL to history @@ -358,7 +358,7 @@ void PageViewer::urlSelected(const TQString &url, int button, int state, const T { if (url.startsWith(TQString::fromLatin1( "javascript:" ), /*case-sensitive=*/false) ) { - KHTMLPart::urlSelected(url,button,state,_target,args); + TDEHTMLPart::urlSelected(url,button,state,_target,args); } else { @@ -400,7 +400,7 @@ void PageViewer::slotPaletteOrFontChanged() // this hack is necessary since the part looks for []HTML Settings] in // TDEGlobal::config() by default, which is wrong when running in Kontact // NOTE: when running in Kontact, immediate updating doesn't work - KHTMLSettings* s = const_cast (settings()); + TDEHTMLSettings* s = const_cast (settings()); s->init(Settings::self()->config()); } diff --git a/akregator/src/tabwidget.cpp b/akregator/src/tabwidget.cpp index 6e7527d2a..492e440ac 100644 --- a/akregator/src/tabwidget.cpp +++ b/akregator/src/tabwidget.cpp @@ -262,7 +262,7 @@ void TabWidget::slotDetachTab() return; KURL url; - KHTMLView* view = dynamic_cast(d->currentItem); + TDEHTMLView* view = dynamic_cast(d->currentItem); if (!view) return; @@ -281,7 +281,7 @@ void TabWidget::slotCopyLinkAddress() return; KURL url; - KHTMLView* view = dynamic_cast(d->currentItem); + TDEHTMLView* view = dynamic_cast(d->currentItem); if (!view) return; diff --git a/akregator/src/viewer.cpp b/akregator/src/viewer.cpp index 74f2ca2a4..20cf59244 100644 --- a/akregator/src/viewer.cpp +++ b/akregator/src/viewer.cpp @@ -48,7 +48,7 @@ namespace Akregator { Viewer::Viewer(TQWidget *parent, const char *name) - : KHTMLPart(parent, name), m_url(0) + : TDEHTMLPart(parent, name), m_url(0) { setZoomFactor(100); setMetaRefreshEnabled(true); @@ -89,7 +89,7 @@ bool Viewer::closeURL() { emit browserExtension()->loadingProgress(-1); emit canceled(TQString()); - return KHTMLPart::closeURL(); + return TDEHTMLPart::closeURL(); } int Viewer::pointsToPixel(int pointSize) const @@ -162,7 +162,7 @@ void Viewer::urlSelected(const TQString &url, int button, int state, const TQStr } return; } - KHTMLPart::urlSelected(url,button,state,_target,args); + TDEHTMLPart::urlSelected(url,button,state,_target,args); } void Viewer::slotPopupMenu(KXMLGUIClient*, const TQPoint& p, const KURL& kurl, const KParts::URLArgs&, KParts::BrowserExtension::PopupFlags kpf, mode_t) diff --git a/akregator/src/viewer.h b/akregator/src/viewer.h index d1d407f97..af89fee2a 100644 --- a/akregator/src/viewer.h +++ b/akregator/src/viewer.h @@ -36,7 +36,7 @@ namespace TDEIO namespace Akregator { - class Viewer : public KHTMLPart + class Viewer : public TDEHTMLPart { Q_OBJECT diff --git a/cmake b/cmake index 9a217903f..274366fb8 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 9a217903f9fa35ca12213a6e9ee3d2cb87d1131d +Subproject commit 274366fb8b90704586d7beef216b765cc0688b08 diff --git a/kaddressbook/Makefile.am b/kaddressbook/Makefile.am index 4b2d1befb..b411e6189 100644 --- a/kaddressbook/Makefile.am +++ b/kaddressbook/Makefile.am @@ -45,7 +45,7 @@ libkaddressbook_la_LIBADD = $(top_builddir)/kaddressbook/printing/libprinter.la $(top_builddir)/kaddressbook/interfaces/libkabinterfaces.la \ $(top_builddir)/libtdepim/libtdepim.la \ $(top_builddir)/libkcal/libkcal.la \ - -lkabc_file $(LIB_KABC) $(LIB_KHTML) \ + -lkabc_file $(LIB_KABC) $(LIB_TDEHTML) \ $(top_builddir)/kaddressbook/common/libkabcommon.la \ $(top_builddir)/kaddressbook/editors/libkabim.la \ -ltdeprint diff --git a/kitchensync/src/Makefile.am b/kitchensync/src/Makefile.am index 779aec82e..e04755d44 100644 --- a/kitchensync/src/Makefile.am +++ b/kitchensync/src/Makefile.am @@ -32,7 +32,7 @@ libkitchensync_la_SOURCES = aboutpage.cpp mainwidget.cpp groupconfigdialog.cpp \ configguijescs.cpp configguievo2.cpp configguimoto.cpp configguisynce.cpp \ configguisunbird.cpp libkitchensync_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -no-undefined -libkitchensync_la_LIBADD = $(LIB_KIO) $(LIB_KHTML) $(top_builddir)/kitchensync/libqopensync/libqopensync.la \ +libkitchensync_la_LIBADD = $(LIB_KIO) $(LIB_TDEHTML) $(top_builddir)/kitchensync/libqopensync/libqopensync.la \ $(LIB_KABC) $(top_builddir)/libtdepim/libtdepim.la $(top_builddir)/libkcal/libkcal.la \ $(LIB_QT) @@ -41,7 +41,7 @@ kde_module_LTLIBRARIES = libkitchensyncpart.la libkitchensyncpart_la_SOURCES = part.cpp libkitchensyncpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(KDE_RPATH) $(all_libraries) -no-undefined -libkitchensyncpart_la_LIBADD = $(LIB_KPARTS) libkitchensync.la $(LIB_QT) $(LIB_KIO) $(LIB_KHTML) $(LIB_KABC) $(LIB_TDECORE) $(LIB_TDEUI) +libkitchensyncpart_la_LIBADD = $(LIB_KPARTS) libkitchensync.la $(LIB_QT) $(LIB_KIO) $(LIB_TDEHTML) $(LIB_KABC) $(LIB_TDECORE) $(LIB_TDEUI) # Resources kitchensyncdatadir = $(kde_datadir)/kitchensync diff --git a/kitchensync/src/aboutpage.cpp b/kitchensync/src/aboutpage.cpp index 50f4d1de6..b337fbbaf 100644 --- a/kitchensync/src/aboutpage.cpp +++ b/kitchensync/src/aboutpage.cpp @@ -61,7 +61,7 @@ AboutPage::AboutPage( TQWidget *parent ) else content = content.arg( "" ); - KHTMLPart *part = new KHTMLPart( this ); + TDEHTMLPart *part = new TDEHTMLPart( this ); layout->addWidget( part->view() ); part->begin( KURL( location ) ); diff --git a/kmail/Mainpage.dox b/kmail/Mainpage.dox index 42201dadc..3121e2d97 100644 --- a/kmail/Mainpage.dox +++ b/kmail/Mainpage.dox @@ -776,7 +776,7 @@ What happens when a message is to displayed in the reader window? new way - by using AttachmentStrategy::Hidden). The HTML generation is delegated to BodyPartFormatters, while the HTML is written to HTMLWriters, which abstract away HTML sinks. One of those is - KHTMLPartHTMLWriter, which writes to the KHTMLPart in the + TDEHTMLPartHTMLWriter, which writes to the TDEHTMLPart in the readerwindow. This is the current state of the code. The goal of the ongoing refactoring is to make the HTML generation blissfully ignorant of the readerwindow and to allow display plugins that can diff --git a/kmail/Makefile.am b/kmail/Makefile.am index 5f8cc6e4f..1f398140e 100644 --- a/kmail/Makefile.am +++ b/kmail/Makefile.am @@ -32,7 +32,7 @@ libkmailprivate_la_LIBADD = \ ../libksieve/libksieve.la ../libemailfunctions/libemailfunctions.la \ ../certmanager/lib/libkleopatra.la $(INDEXLIB) \ ../libkcal/libkcal.la \ - $(LIB_KHTML) $(LIB_KSPELL) $(LIB_KABC) + $(LIB_TDEHTML) $(LIB_KSPELL) $(LIB_KABC) kde_module_LTLIBRARIES = kcm_kmail.la libkmailpart.la libkmail_bodypartformatter_application_octetstream.la libkmailpart_la_LDFLAGS = $(all_libraries) $(KDE_RPATH) -module -avoid-version -no-undefined diff --git a/kmail/interfaces/htmlwriter.h b/kmail/interfaces/htmlwriter.h index 932350166..179841c1a 100644 --- a/kmail/interfaces/htmlwriter.h +++ b/kmail/interfaces/htmlwriter.h @@ -64,7 +64,7 @@ namespace KMail { * @deprecated KMail should be ported to Interface::HtmlWriter. This * interface exposes internal working models. The queueing * vs. writing() issues exposed here should be hidden by using two - * different implementations of KHTMLPartHtmlWriter: one for + * different implementations of TDEHTMLPartHtmlWriter: one for * queueing, and one for writing. This should be fixed before the * release, so we an keep the plugin interface stable. * diff --git a/kmail/kmmessage.cpp b/kmail/kmmessage.cpp index 5b4f8cf96..da63f2034 100644 --- a/kmail/kmmessage.cpp +++ b/kmail/kmmessage.cpp @@ -800,7 +800,7 @@ TQString KMMessage::asPlainTextFromObjectTree( partNode *root, bool aStripSignat // html -> plaintext conversion, if necessary: if ( isHTML && mDecodeHTML ) { - KHTMLPart htmlPart; + TDEHTMLPart htmlPart; htmlPart.setOnlyLocalReferences( true ); htmlPart.setMetaRefreshEnabled( false ); htmlPart.setPluginsEnabled( false ); diff --git a/kmail/kmmessage.h b/kmail/kmmessage.h index 5045b0e6c..a16006575 100644 --- a/kmail/kmmessage.h +++ b/kmail/kmmessage.h @@ -678,7 +678,7 @@ public: static TQString generateMessageId( const TQString& addr ); /** Convert '<' into "<" resp. '>' into ">" in order to - * prevent their interpretation by KHTML. + * prevent their interpretation by TDEHTML. * Does *not* use the TQt replace function but runs a very fast C code * the same way as lf2crlf() does. */ diff --git a/kmail/kmreaderwin.cpp b/kmail/kmreaderwin.cpp index 2405a3e56..d1c6c0a12 100644 --- a/kmail/kmreaderwin.cpp +++ b/kmail/kmreaderwin.cpp @@ -393,7 +393,7 @@ void KMReaderWin::createWidgets() { setStyleDependantFrameWidth(); mBox->setFrameStyle( mMimePartTree->frameStyle() ); mColorBar = new HtmlStatusBar( mBox, "mColorBar" ); - mViewer = new KHTMLPart( mBox, "mViewer" ); + mViewer = new TDEHTMLPart( mBox, "mViewer" ); mSplitter->setOpaqueResize( TDEGlobalSettings::opaqueResize() ); mSplitter->setResizeMode( mMimePartTree, TQSplitter::KeepSize ); } @@ -1033,7 +1033,7 @@ void KMReaderWin::contactStatusChanged( const TQString &uid) kdDebug( 5006 ) << "name is " << n.nodeName().string() << endl; kdDebug( 5006 ) << "value of content was " << n.firstChild().nodeValue().string() << endl; TQString newPresence = kmkernel->imProxy()->presenceString( uid ); - if ( newPresence.isNull() ) // KHTML crashes if you setNodeValue( TQString() ) + if ( newPresence.isNull() ) // TDEHTML crashes if you setNodeValue( TQString() ) newPresence = TQString::fromLatin1( "ENOIMRUNNING" ); n.firstChild().setNodeValue( newPresence ); // kdDebug( 5006 ) << "value of content is now " << n.firstChild().nodeValue().string() << endl; @@ -2685,7 +2685,7 @@ bool KMReaderWin::eventFilter( TQObject *, TQEvent *e ) if ( e->type() == TQEvent::MouseMove ) { TQMouseEvent* me = TQT_TQMOUSEEVENT( e ); - // Handle this ourselves instead of connecting to mViewer::onURL(), since KHTML misses some + // Handle this ourselves instead of connecting to mViewer::onURL(), since TDEHTML misses some // notifications in case we started a drag ourselves slotUrlOn( linkForNode( mViewer->nodeUnderMouse() ) ); @@ -2695,7 +2695,7 @@ bool KMReaderWin::eventFilter( TQObject *, TQEvent *e ) mCanStartDrag = false; slotUrlOn( TQString() ); - // HACK: Send a mouse release event to the KHTMLView, as otherwise that will be missed in + // HACK: Send a mouse release event to the TDEHTMLView, as otherwise that will be missed in // case we started a drag. If the event is missed, the HTML view gets into a wrong // state, in which funny things like unsolicited drags start to happen. TQMouseEvent mouseEvent( TQEvent::MouseButtonRelease, me->pos(), Qt::NoButton, Qt::NoButton ); diff --git a/kmail/kmreaderwin.h b/kmail/kmreaderwin.h index b8dd3f9ff..961994526 100644 --- a/kmail/kmreaderwin.h +++ b/kmail/kmreaderwin.h @@ -35,7 +35,7 @@ class KSelectAction; class KRadioAction; class KToggleAction; class TDEConfigBase; -class KHTMLPart; +class TDEHTMLPart; class KURL; class KMFolder; @@ -239,7 +239,7 @@ public: bool isFixedFont() { return mUseFixedFont; } void setUseFixedFont( bool useFixedFont ) { mUseFixedFont = useFixedFont; } - /** Return the HtmlWriter connected to the KHTMLPart we use */ + /** Return the HtmlWriter connected to the TDEHTMLPart we use */ KMail::HtmlWriter * htmlWriter() { return mHtmlWriter; } // Action to reply to a message @@ -279,9 +279,9 @@ public: void setUpdateAttachment( bool update = true ) { mAtmUpdate = update; } - /** Access to the KHTMLPart used for the viewer. Use with + /** Access to the TDEHTMLPart used for the viewer. Use with care! */ - KHTMLPart * htmlPart() const { return mViewer; } + TDEHTMLPart * htmlPart() const { return mViewer; } /** Returns the current message or 0 if none. */ KMMessage* message(KMFolder** folder=0) const; @@ -554,7 +554,7 @@ private: TQHBox *mBox; KMail::HtmlStatusBar *mColorBar; KMMimePartTree* mMimePartTree; - KHTMLPart *mViewer; + TDEHTMLPart *mViewer; const KMail::AttachmentStrategy * mAttachmentStrategy; const KMail::HeaderStrategy * mHeaderStrategy; diff --git a/kmail/tdehtmlparthtmlwriter.cpp b/kmail/tdehtmlparthtmlwriter.cpp index 7321e1285..5450509ec 100644 --- a/kmail/tdehtmlparthtmlwriter.cpp +++ b/kmail/tdehtmlparthtmlwriter.cpp @@ -46,7 +46,7 @@ namespace KMail { - KHtmlPartHtmlWriter::KHtmlPartHtmlWriter( KHTMLPart * part, + KHtmlPartHtmlWriter::KHtmlPartHtmlWriter( TDEHTMLPart * part, TQObject * parent, const char * name ) : TQObject( parent, name ), HtmlWriter(), mHtmlPart( part ), mHtmlTimer( 0, "mHtmlTimer" ), mState( Ended ) diff --git a/kmail/tdehtmlparthtmlwriter.h b/kmail/tdehtmlparthtmlwriter.h index 52f16fd4b..5d9af2e10 100644 --- a/kmail/tdehtmlparthtmlwriter.h +++ b/kmail/tdehtmlparthtmlwriter.h @@ -29,8 +29,8 @@ your version. */ -#ifndef __KMAIL_KHTMLPARTHTMLWRITER_H__ -#define __KMAIL_KHTMLPARTHTMLWRITER_H__ +#ifndef __KMAIL_TDEHTMLPARTHTMLWRITER_H__ +#define __KMAIL_TDEHTMLPARTHTMLWRITER_H__ #include "interfaces/htmlwriter.h" #include @@ -39,7 +39,7 @@ #include class TQString; -class KHTMLPart; +class TDEHTMLPart; namespace KMail { @@ -49,7 +49,7 @@ namespace KMail { public: // Key is Content-Id, value is URL typedef TQMap EmbeddedPartMap; - KHtmlPartHtmlWriter( KHTMLPart * part, + KHtmlPartHtmlWriter( TDEHTMLPart * part, TQObject * parent=0, const char * name = 0 ); virtual ~KHtmlPartHtmlWriter(); @@ -68,7 +68,7 @@ namespace KMail { void resolveCidUrls(); private: - KHTMLPart * mHtmlPart; + TDEHTMLPart * mHtmlPart; TQStringList mHtmlQueue; TQTimer mHtmlTimer; enum State { @@ -81,4 +81,4 @@ namespace KMail { } // namespace KMail -#endif // __KMAIL_KHTMLPARTHTMLWRITER_H__ +#endif // __KMAIL_TDEHTMLPARTHTMLWRITER_H__ diff --git a/kmobile/tdeioslave/kio_mobile.cpp b/kmobile/tdeioslave/kio_mobile.cpp deleted file mode 100644 index bb70b264e..000000000 --- a/kmobile/tdeioslave/kio_mobile.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/* This file is part of the KDE KMobile library - Copyright (C) 2003 Helge Deller - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#include -#include - -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include "tdeio_mobile.h" - -#include - -using namespace TDEIO; - -#define KIO_MOBILE_DEBUG_AREA 7126 -#define PRINT_DEBUG kdDebug(KIO_MOBILE_DEBUG_AREA) << "tdeio_mobile: " - -extern "C" { KDE_EXPORT int kdemain(int argc, char **argv); } - -/** - * The main program. - */ -int kdemain(int argc, char **argv) -{ - TDEInstance instance( "tdeio_mobile" ); - - PRINT_DEBUG << "Starting " << getpid() << endl; - - if (argc != 4) { - fprintf(stderr, "Usage tdeio_mobile protocol pool app\n"); - return -1; - } - // let the protocol class do its work - KMobileProtocol slave(argv[2], argv[3]); - - slave.dispatchLoop(); - - PRINT_DEBUG << "Done" << endl; - return 0; -} - - -/** - * Initialize the mobile slave - */ -KMobileProtocol::KMobileProtocol(const TQCString &pool, const TQCString &app) - : SlaveBase( "mobile", pool, app) -{ -} - -KMobileProtocol::~KMobileProtocol() -{ -} - -/* - * getDeviceAndRessource("mobile:///...") - split - */ -int KMobileProtocol::getDeviceAndRessource(const TQString &_path, - TQString &devName, TQString &resource, TQString &devPath, - KMobileDevice::Capabilities &devCaps) -{ -// PRINT_DEBUG << TQString("###getDeviceAndRessource### %1\n").arg(_path); - TQStringList path = TQStringList::split('/', _path, false); - - devName = resource = devPath = TQString(); - devCaps = KMobileDevice::hasNothing; - - if (path.count() >= 1) { devName = path[0]; path.pop_front(); }; - if (path.count() >= 1) { resource = path[0]; path.pop_front(); }; - if (path.count() >= 1) devPath = path.join("/"); - - if (devName.isEmpty()) - return 0; - - int _caps = m_dev.capabilities(devName); - - if (resource.isEmpty()) { - devCaps = (KMobileDevice::Capabilities) _caps; - return 0; - } - - for (int i=0; i<31; i++) { - int cap = 1UL << i; - if ((_caps & cap) == 0) - continue; - TQString capname = m_dev.nameForCap(devName,cap); - if (capname != resource) - continue; - devCaps = (KMobileDevice::Capabilities) cap; - return 0; - } - - return TDEIO::ERR_DOES_NOT_EXIST; -} - - -static -void addAtom(TDEIO::UDSEntry& entry, unsigned int ID, long l, const TQString& s = TQString()) -{ - TDEIO::UDSAtom atom; - atom.m_uds = ID; - atom.m_long = l; - atom.m_str = s; - entry.append(atom); -} - -static -void createDirEntry(TDEIO::UDSEntry& entry, const TQString& name, const TQString& url, const TQString& mime) -{ - entry.clear(); - addAtom(entry, TDEIO::UDS_NAME, 0, name); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); - addAtom(entry, TDEIO::UDS_ACCESS, 0500); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, mime); - addAtom(entry, TDEIO::UDS_URL, 0, url); - addAtom(entry, TDEIO::UDS_USER, 0, getenv("USER")); - addAtom(entry, TDEIO::UDS_GROUP, 0, getenv("USER")); - PRINT_DEBUG << TQString("createDirEntry: File: %1 MIME: %2 URL: %3\n").arg(name).arg(mime).arg(url); -// addAtom(entry, TDEIO::UDS_SIZE, 0); - addAtom(entry, TDEIO::UDS_GUESSED_MIME_TYPE, 0, mime); -} - -static -void createFileEntry(TDEIO::UDSEntry& entry, const TQString& name, const TQString& url, const TQString& mime, - const unsigned long size = 0) -{ - entry.clear(); - addAtom(entry, TDEIO::UDS_NAME, 0, name); - addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); - addAtom(entry, TDEIO::UDS_URL, 0, url); - addAtom(entry, TDEIO::UDS_ACCESS, 0400); - addAtom(entry, TDEIO::UDS_USER, 0, getenv("USER")); - addAtom(entry, TDEIO::UDS_GROUP, 0, getenv("USER")); - addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, mime); - if (size) addAtom(entry, TDEIO::UDS_SIZE, size); - addAtom(entry, TDEIO::UDS_GUESSED_MIME_TYPE, 0, mime); - PRINT_DEBUG << TQString("createFileEntry: File: %1, Size: %2, MIME: %3\n").arg(name).arg(size).arg(mime); -} - - -/** - * Get the information contained in the URL. - */ -void KMobileProtocol::get(const KURL &url) -{ - PRINT_DEBUG << "###############################\n"; - PRINT_DEBUG << TQString("get(%1)\n").arg(url.path()); - - KMobileDevice::Capabilities devCaps; - TQString devName, resource, devPath; - - int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); - if (err) { - error(err, url.path()); - return; - } - - if (devName.isEmpty() || resource.isEmpty()) { - error(TDEIO::ERR_DOES_NOT_EXIST, url.path()); - return; - } - - // collect the result - TQCString result; - TQString mime; - switch (devCaps) { - case KMobileDevice::hasAddressBook: err = getVCard(devName, result, mime, devPath); - break; - case KMobileDevice::hasCalendar: err = getCalendar(devName, result, mime, devPath); - break; - case KMobileDevice::hasNotes: err = getNote(devName, result, mime, devPath); - break; - case KMobileDevice::hasFileStorage: err = getFileStorage(devName, result, mime, devPath); - break; - default: err = TDEIO::ERR_CANNOT_ENTER_DIRECTORY; /* TODO */ - } - - if (err) { - error(err, url.path()); - return; - } - - // tell the mimetype - mimeType(mime); - - // tell the length - TDEIO::filesize_t processed_size = result.length(); - totalSize(processed_size); - - // tell the contents of the URL - TQByteArray array; - array.setRawData( result.data(), result.length() ); - data(array); - array.resetRawData( result.data(), result.length() ); - processedSize( processed_size ); - // tell we are finished - data(TQByteArray()); - - // tell we are finished - finished(); -} - - -/* - * listRoot() - gives listing of all devices - */ -void KMobileProtocol::listRoot(const KURL& url) -{ - PRINT_DEBUG << TQString("########## listRoot(%1) for %2:/\n").arg(url.path()).arg(url.protocol()); - - TDEIO::UDSEntry entry; - - TQStringList deviceNames = m_dev.deviceNames(); - unsigned int dirs = deviceNames.count(); - totalSize(dirs); - - int classMask = KMobileDevice::Unclassified; - /* handle all possible protocols here and just add a .protocol file */ - if (url.protocol() == "cellphone") // cellphone:/ - classMask = KMobileDevice::Phone; - if (url.protocol() == "organizer" || // organizer:/ - url.protocol() == "pda") // pda:/ - classMask = KMobileDevice::Organizer; - if (url.protocol() == "phonecamera") // camera:/ - classMask = KMobileDevice::Camera; - - for (unsigned int i=0; i") - sub-directory of a devices - */ - -void KMobileProtocol::listTopDeviceDir(const TQString &devName) -{ - PRINT_DEBUG << TQString("listTopDeviceDir(%1)\n").arg(devName); - - TDEIO::UDSEntry entry; - unsigned int caps = m_dev.capabilities(devName); - - for (int i=0; i<31; i++) { - unsigned int cap = 1UL</") - resources of a device - */ -void KMobileProtocol::listEntries(const TQString &devName, - const TQString &resource, const TQString &devPath, - const KMobileDevice::Capabilities devCaps) -{ - PRINT_DEBUG << TQString("listEntries(%1,%2,%3)\n").arg(devName).arg(resource).arg(devPath); - switch (devCaps) { - case KMobileDevice::hasAddressBook: listAddressBook(devName, resource); - break; - case KMobileDevice::hasCalendar: listCalendar(devName, resource); - break; - case KMobileDevice::hasNotes: listNotes(devName, resource); - break; - case KMobileDevice::hasFileStorage: listFileStorage(devName, resource, devPath); - break; - default: error( ERR_CANNOT_ENTER_DIRECTORY, - TQString("/%1/%2").arg(devName).arg(resource) ); - } -} - -/* - * listAddressBook("mobile://Addressbook) - list the addressbook - */ -void KMobileProtocol::listAddressBook(const TQString &devName, const TQString &resource) -{ - PRINT_DEBUG << TQString("listAddressBook(%1)\n").arg(devName); - - TDEIO::UDSEntry entry; - - int fieldwidth; - int entries = m_dev.numAddresses(devName); - if (entries>=1000) fieldwidth=4; else - if (entries>=100) fieldwidth=3; else - if (entries>=10) fieldwidth=2; else fieldwidth=1; - totalSize(entries); -// TQRegExp rx; rx.setPattern( ".*FN:([\\w\\s]*)[\\n\\r]{2}.*" ); - TQString name; - for (int i=0; i0) - index = path.left(index).toInt(); - if (index<0 || index>=m_dev.numAddresses(devName)) - return TDEIO::ERR_DOES_NOT_EXIST; - - TQString str = m_dev.readAddress(devName, index); - if (str.isEmpty()) - return TDEIO::ERR_INTERNAL; - result = str.utf8(); - mime = entryMimeType(KMobileDevice::hasAddressBook); -// setMetaData("plugin", "const TQString &key, const TQString &value); - return 0; -} - -/* - * listCalendar("mobile://Calendar) - list the calendar entries - */ -void KMobileProtocol::listCalendar( const TQString &devName, const TQString &resource) -{ - PRINT_DEBUG << TQString("listCalendar(%1)\n").arg(devName); - - TDEIO::UDSEntry entry; - - int entries = m_dev.numCalendarEntries(devName); - totalSize(entries); - for (int i=0; i/Notes) - list the notes - */ -void KMobileProtocol::listNotes( const TQString &devName, const TQString &resource) -{ - PRINT_DEBUG << TQString("listNotes(%1)\n").arg(devName); - - TDEIO::UDSEntry entry; - - int entries = m_dev.numNotes(devName); - totalSize(entries); - for (int i=0; i0) - index = path.left(index).toInt(); - if (index<0 || index>=m_dev.numNotes(devName)) - return TDEIO::ERR_DOES_NOT_EXIST; - - TQString note = m_dev.readNote(devName, index); - if (note.isEmpty()) - return TDEIO::ERR_DOES_NOT_EXIST; - - result = note.utf8(); - mime = entryMimeType(KMobileDevice::hasNotes); - return 0; -} - -/* - * listFileStorage("mobile://Files) - list the files on the device - */ -void KMobileProtocol::listFileStorage(const TQString &devName, const TQString &resource, const TQString &devPath) -{ - PRINT_DEBUG << TQString("listFileStorage(%1,%2)\n").arg(devName).arg(devPath); - - /* TODO */ - error( TDEIO::ERR_DOES_NOT_EXIST, TQString("/%1/%2/%3").arg(devName).arg(resource).arg(devPath) ); -} - -/* - * getFileStorage() - gives the file contents of the given file - */ -int KMobileProtocol::getFileStorage(const TQString &devName, TQCString &result, TQString &mime, const TQString &path) -{ - PRINT_DEBUG << TQString("getFileStorage(%1)\n").arg(path); - - /* TODO */ - Q_UNUSED(devName); - Q_UNUSED(result); - Q_UNUSED(mime); - return TDEIO::ERR_CANNOT_ENTER_DIRECTORY; -} - - -/** - * Test if the url contains a directory or a file. - */ -void KMobileProtocol::stat( const KURL &url ) -{ - PRINT_DEBUG << "###############################\n"; - PRINT_DEBUG << TQString("stat(%1)\n").arg(url.path()); - - KMobileDevice::Capabilities devCaps; - TQString devName, resource, devPath; - - int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); - if (err) { - error(err, url.path()); - return; - } - - TQStringList path = TQStringList::split('/', url.path(), false); - TQString filename = (path.count()>0) ? path[path.count()-1] : "/"; - TQString fullPath = path.join("/"); - TQString fullUrl = TQString("mobile:/%1").arg(fullPath); - - UDSEntry entry; - - bool isDir = devPath.isEmpty(); - - if (isDir) { - createDirEntry(entry, filename, fullUrl, folderMimeType(devCaps)); - } else { - createFileEntry(entry, filename, fullUrl, entryMimeType(devCaps)); - } - - statEntry(entry); - finished(); -} - -/** - * Get the mimetype. - */ -void KMobileProtocol::mimetype(const KURL &url) -{ - PRINT_DEBUG << "###############################\n"; - PRINT_DEBUG << TQString("mimetype(%1)\n").arg(url.path()); - - KMobileDevice::Capabilities devCaps; - TQString devName, resource, devPath; - - int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); - if (err) { - error(err, url.path()); - return; - } - - // tell the mimetype - mimeType(entryMimeType(devCaps)); - finished(); -} - -/** - * List the contents of a directory. - */ -void KMobileProtocol::listDir(const KURL &url) -{ - PRINT_DEBUG << "###############################\n"; - PRINT_DEBUG << TQString("listDir(%1)\n").arg(url.path()); - - if (!m_dev.isKMobileAvailable()) { - error( TDEIO::ERR_CONNECTION_BROKEN, i18n("TDE Mobile Device Manager") ); - return; - } - - KMobileDevice::Capabilities devCaps; - TQString devName, resource, devPath; - - int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); - if (err) { - error(err, url.path()); - return; - } - - if (devName.isEmpty()) { - listRoot(url); - return; - } - -#if 0 - if (!dev) { - error( TDEIO::ERR_DOES_NOT_EXIST, TQString("/%1").arg(devName) ); - return; - } -#endif - - if (resource.isEmpty()) { - listTopDeviceDir(devName); - return; - } - - listEntries(devName, resource, devPath, devCaps); -} diff --git a/kmobile/tdeioslave/kio_mobile.h b/kmobile/tdeioslave/kio_mobile.h deleted file mode 100644 index 05a30a22f..000000000 --- a/kmobile/tdeioslave/kio_mobile.h +++ /dev/null @@ -1,70 +0,0 @@ -/* This file is part of the KDE mobile library. - Copyright (C) 2004 Helge Deller - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License version 2 as published by the Free Software Foundation. - - 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public License - along with this library; see the file COPYING.LIB. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef __KIO_MOBILE_H__ -#define __KIO_MOBILE_H__ - -#include -#include - -#include -#include -#include - -class KMobileProtocol : public TDEIO::SlaveBase -{ -public: - KMobileProtocol( const TQCString &pool, const TQCString &app ); - ~KMobileProtocol(); - - void get( const KURL& url ); - void stat( const KURL& url ); - void mimetype( const KURL& url ); - void listDir( const KURL& url ); - -protected: - int getDeviceAndRessource(const TQString &_path, - TQString &devName, TQString &resource, TQString &devPath, - KMobileDevice::Capabilities &devCaps); - - TQString folderMimeType(int cap); - TQString entryMimeType(int cap); - - void listRoot(const KURL& url); - void listTopDeviceDir(const TQString &devName); - void listEntries(const TQString &devName, - const TQString &resource, const TQString &devPath, - const KMobileDevice::Capabilities devCaps); - - void listAddressBook(const TQString &devName, const TQString &resource); - int getVCard( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); - - void listCalendar(const TQString &devName, const TQString &resource); - int getCalendar( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); - - void listNotes(const TQString &devName, const TQString &resource); - int getNote( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); - - void listFileStorage(const TQString &devName, const TQString &resource, const TQString &devPath); - int getFileStorage( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); - -private: - KMobileClient m_dev; -}; - -#endif diff --git a/kmobile/tdeioslave/tdeio_mobile.cpp b/kmobile/tdeioslave/tdeio_mobile.cpp new file mode 100644 index 000000000..bb70b264e --- /dev/null +++ b/kmobile/tdeioslave/tdeio_mobile.cpp @@ -0,0 +1,636 @@ +/* This file is part of the KDE KMobile library + Copyright (C) 2003 Helge Deller + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. + +*/ + +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include "tdeio_mobile.h" + +#include + +using namespace TDEIO; + +#define KIO_MOBILE_DEBUG_AREA 7126 +#define PRINT_DEBUG kdDebug(KIO_MOBILE_DEBUG_AREA) << "tdeio_mobile: " + +extern "C" { KDE_EXPORT int kdemain(int argc, char **argv); } + +/** + * The main program. + */ +int kdemain(int argc, char **argv) +{ + TDEInstance instance( "tdeio_mobile" ); + + PRINT_DEBUG << "Starting " << getpid() << endl; + + if (argc != 4) { + fprintf(stderr, "Usage tdeio_mobile protocol pool app\n"); + return -1; + } + // let the protocol class do its work + KMobileProtocol slave(argv[2], argv[3]); + + slave.dispatchLoop(); + + PRINT_DEBUG << "Done" << endl; + return 0; +} + + +/** + * Initialize the mobile slave + */ +KMobileProtocol::KMobileProtocol(const TQCString &pool, const TQCString &app) + : SlaveBase( "mobile", pool, app) +{ +} + +KMobileProtocol::~KMobileProtocol() +{ +} + +/* + * getDeviceAndRessource("mobile:///...") - split + */ +int KMobileProtocol::getDeviceAndRessource(const TQString &_path, + TQString &devName, TQString &resource, TQString &devPath, + KMobileDevice::Capabilities &devCaps) +{ +// PRINT_DEBUG << TQString("###getDeviceAndRessource### %1\n").arg(_path); + TQStringList path = TQStringList::split('/', _path, false); + + devName = resource = devPath = TQString(); + devCaps = KMobileDevice::hasNothing; + + if (path.count() >= 1) { devName = path[0]; path.pop_front(); }; + if (path.count() >= 1) { resource = path[0]; path.pop_front(); }; + if (path.count() >= 1) devPath = path.join("/"); + + if (devName.isEmpty()) + return 0; + + int _caps = m_dev.capabilities(devName); + + if (resource.isEmpty()) { + devCaps = (KMobileDevice::Capabilities) _caps; + return 0; + } + + for (int i=0; i<31; i++) { + int cap = 1UL << i; + if ((_caps & cap) == 0) + continue; + TQString capname = m_dev.nameForCap(devName,cap); + if (capname != resource) + continue; + devCaps = (KMobileDevice::Capabilities) cap; + return 0; + } + + return TDEIO::ERR_DOES_NOT_EXIST; +} + + +static +void addAtom(TDEIO::UDSEntry& entry, unsigned int ID, long l, const TQString& s = TQString()) +{ + TDEIO::UDSAtom atom; + atom.m_uds = ID; + atom.m_long = l; + atom.m_str = s; + entry.append(atom); +} + +static +void createDirEntry(TDEIO::UDSEntry& entry, const TQString& name, const TQString& url, const TQString& mime) +{ + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, name); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0500); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, mime); + addAtom(entry, TDEIO::UDS_URL, 0, url); + addAtom(entry, TDEIO::UDS_USER, 0, getenv("USER")); + addAtom(entry, TDEIO::UDS_GROUP, 0, getenv("USER")); + PRINT_DEBUG << TQString("createDirEntry: File: %1 MIME: %2 URL: %3\n").arg(name).arg(mime).arg(url); +// addAtom(entry, TDEIO::UDS_SIZE, 0); + addAtom(entry, TDEIO::UDS_GUESSED_MIME_TYPE, 0, mime); +} + +static +void createFileEntry(TDEIO::UDSEntry& entry, const TQString& name, const TQString& url, const TQString& mime, + const unsigned long size = 0) +{ + entry.clear(); + addAtom(entry, TDEIO::UDS_NAME, 0, name); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFREG); + addAtom(entry, TDEIO::UDS_URL, 0, url); + addAtom(entry, TDEIO::UDS_ACCESS, 0400); + addAtom(entry, TDEIO::UDS_USER, 0, getenv("USER")); + addAtom(entry, TDEIO::UDS_GROUP, 0, getenv("USER")); + addAtom(entry, TDEIO::UDS_MIME_TYPE, 0, mime); + if (size) addAtom(entry, TDEIO::UDS_SIZE, size); + addAtom(entry, TDEIO::UDS_GUESSED_MIME_TYPE, 0, mime); + PRINT_DEBUG << TQString("createFileEntry: File: %1, Size: %2, MIME: %3\n").arg(name).arg(size).arg(mime); +} + + +/** + * Get the information contained in the URL. + */ +void KMobileProtocol::get(const KURL &url) +{ + PRINT_DEBUG << "###############################\n"; + PRINT_DEBUG << TQString("get(%1)\n").arg(url.path()); + + KMobileDevice::Capabilities devCaps; + TQString devName, resource, devPath; + + int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); + if (err) { + error(err, url.path()); + return; + } + + if (devName.isEmpty() || resource.isEmpty()) { + error(TDEIO::ERR_DOES_NOT_EXIST, url.path()); + return; + } + + // collect the result + TQCString result; + TQString mime; + switch (devCaps) { + case KMobileDevice::hasAddressBook: err = getVCard(devName, result, mime, devPath); + break; + case KMobileDevice::hasCalendar: err = getCalendar(devName, result, mime, devPath); + break; + case KMobileDevice::hasNotes: err = getNote(devName, result, mime, devPath); + break; + case KMobileDevice::hasFileStorage: err = getFileStorage(devName, result, mime, devPath); + break; + default: err = TDEIO::ERR_CANNOT_ENTER_DIRECTORY; /* TODO */ + } + + if (err) { + error(err, url.path()); + return; + } + + // tell the mimetype + mimeType(mime); + + // tell the length + TDEIO::filesize_t processed_size = result.length(); + totalSize(processed_size); + + // tell the contents of the URL + TQByteArray array; + array.setRawData( result.data(), result.length() ); + data(array); + array.resetRawData( result.data(), result.length() ); + processedSize( processed_size ); + // tell we are finished + data(TQByteArray()); + + // tell we are finished + finished(); +} + + +/* + * listRoot() - gives listing of all devices + */ +void KMobileProtocol::listRoot(const KURL& url) +{ + PRINT_DEBUG << TQString("########## listRoot(%1) for %2:/\n").arg(url.path()).arg(url.protocol()); + + TDEIO::UDSEntry entry; + + TQStringList deviceNames = m_dev.deviceNames(); + unsigned int dirs = deviceNames.count(); + totalSize(dirs); + + int classMask = KMobileDevice::Unclassified; + /* handle all possible protocols here and just add a .protocol file */ + if (url.protocol() == "cellphone") // cellphone:/ + classMask = KMobileDevice::Phone; + if (url.protocol() == "organizer" || // organizer:/ + url.protocol() == "pda") // pda:/ + classMask = KMobileDevice::Organizer; + if (url.protocol() == "phonecamera") // camera:/ + classMask = KMobileDevice::Camera; + + for (unsigned int i=0; i") - sub-directory of a devices + */ + +void KMobileProtocol::listTopDeviceDir(const TQString &devName) +{ + PRINT_DEBUG << TQString("listTopDeviceDir(%1)\n").arg(devName); + + TDEIO::UDSEntry entry; + unsigned int caps = m_dev.capabilities(devName); + + for (int i=0; i<31; i++) { + unsigned int cap = 1UL</") - resources of a device + */ +void KMobileProtocol::listEntries(const TQString &devName, + const TQString &resource, const TQString &devPath, + const KMobileDevice::Capabilities devCaps) +{ + PRINT_DEBUG << TQString("listEntries(%1,%2,%3)\n").arg(devName).arg(resource).arg(devPath); + switch (devCaps) { + case KMobileDevice::hasAddressBook: listAddressBook(devName, resource); + break; + case KMobileDevice::hasCalendar: listCalendar(devName, resource); + break; + case KMobileDevice::hasNotes: listNotes(devName, resource); + break; + case KMobileDevice::hasFileStorage: listFileStorage(devName, resource, devPath); + break; + default: error( ERR_CANNOT_ENTER_DIRECTORY, + TQString("/%1/%2").arg(devName).arg(resource) ); + } +} + +/* + * listAddressBook("mobile://Addressbook) - list the addressbook + */ +void KMobileProtocol::listAddressBook(const TQString &devName, const TQString &resource) +{ + PRINT_DEBUG << TQString("listAddressBook(%1)\n").arg(devName); + + TDEIO::UDSEntry entry; + + int fieldwidth; + int entries = m_dev.numAddresses(devName); + if (entries>=1000) fieldwidth=4; else + if (entries>=100) fieldwidth=3; else + if (entries>=10) fieldwidth=2; else fieldwidth=1; + totalSize(entries); +// TQRegExp rx; rx.setPattern( ".*FN:([\\w\\s]*)[\\n\\r]{2}.*" ); + TQString name; + for (int i=0; i0) + index = path.left(index).toInt(); + if (index<0 || index>=m_dev.numAddresses(devName)) + return TDEIO::ERR_DOES_NOT_EXIST; + + TQString str = m_dev.readAddress(devName, index); + if (str.isEmpty()) + return TDEIO::ERR_INTERNAL; + result = str.utf8(); + mime = entryMimeType(KMobileDevice::hasAddressBook); +// setMetaData("plugin", "const TQString &key, const TQString &value); + return 0; +} + +/* + * listCalendar("mobile://Calendar) - list the calendar entries + */ +void KMobileProtocol::listCalendar( const TQString &devName, const TQString &resource) +{ + PRINT_DEBUG << TQString("listCalendar(%1)\n").arg(devName); + + TDEIO::UDSEntry entry; + + int entries = m_dev.numCalendarEntries(devName); + totalSize(entries); + for (int i=0; i/Notes) - list the notes + */ +void KMobileProtocol::listNotes( const TQString &devName, const TQString &resource) +{ + PRINT_DEBUG << TQString("listNotes(%1)\n").arg(devName); + + TDEIO::UDSEntry entry; + + int entries = m_dev.numNotes(devName); + totalSize(entries); + for (int i=0; i0) + index = path.left(index).toInt(); + if (index<0 || index>=m_dev.numNotes(devName)) + return TDEIO::ERR_DOES_NOT_EXIST; + + TQString note = m_dev.readNote(devName, index); + if (note.isEmpty()) + return TDEIO::ERR_DOES_NOT_EXIST; + + result = note.utf8(); + mime = entryMimeType(KMobileDevice::hasNotes); + return 0; +} + +/* + * listFileStorage("mobile://Files) - list the files on the device + */ +void KMobileProtocol::listFileStorage(const TQString &devName, const TQString &resource, const TQString &devPath) +{ + PRINT_DEBUG << TQString("listFileStorage(%1,%2)\n").arg(devName).arg(devPath); + + /* TODO */ + error( TDEIO::ERR_DOES_NOT_EXIST, TQString("/%1/%2/%3").arg(devName).arg(resource).arg(devPath) ); +} + +/* + * getFileStorage() - gives the file contents of the given file + */ +int KMobileProtocol::getFileStorage(const TQString &devName, TQCString &result, TQString &mime, const TQString &path) +{ + PRINT_DEBUG << TQString("getFileStorage(%1)\n").arg(path); + + /* TODO */ + Q_UNUSED(devName); + Q_UNUSED(result); + Q_UNUSED(mime); + return TDEIO::ERR_CANNOT_ENTER_DIRECTORY; +} + + +/** + * Test if the url contains a directory or a file. + */ +void KMobileProtocol::stat( const KURL &url ) +{ + PRINT_DEBUG << "###############################\n"; + PRINT_DEBUG << TQString("stat(%1)\n").arg(url.path()); + + KMobileDevice::Capabilities devCaps; + TQString devName, resource, devPath; + + int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); + if (err) { + error(err, url.path()); + return; + } + + TQStringList path = TQStringList::split('/', url.path(), false); + TQString filename = (path.count()>0) ? path[path.count()-1] : "/"; + TQString fullPath = path.join("/"); + TQString fullUrl = TQString("mobile:/%1").arg(fullPath); + + UDSEntry entry; + + bool isDir = devPath.isEmpty(); + + if (isDir) { + createDirEntry(entry, filename, fullUrl, folderMimeType(devCaps)); + } else { + createFileEntry(entry, filename, fullUrl, entryMimeType(devCaps)); + } + + statEntry(entry); + finished(); +} + +/** + * Get the mimetype. + */ +void KMobileProtocol::mimetype(const KURL &url) +{ + PRINT_DEBUG << "###############################\n"; + PRINT_DEBUG << TQString("mimetype(%1)\n").arg(url.path()); + + KMobileDevice::Capabilities devCaps; + TQString devName, resource, devPath; + + int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); + if (err) { + error(err, url.path()); + return; + } + + // tell the mimetype + mimeType(entryMimeType(devCaps)); + finished(); +} + +/** + * List the contents of a directory. + */ +void KMobileProtocol::listDir(const KURL &url) +{ + PRINT_DEBUG << "###############################\n"; + PRINT_DEBUG << TQString("listDir(%1)\n").arg(url.path()); + + if (!m_dev.isKMobileAvailable()) { + error( TDEIO::ERR_CONNECTION_BROKEN, i18n("TDE Mobile Device Manager") ); + return; + } + + KMobileDevice::Capabilities devCaps; + TQString devName, resource, devPath; + + int err = getDeviceAndRessource(url.path(), devName, resource, devPath, devCaps); + if (err) { + error(err, url.path()); + return; + } + + if (devName.isEmpty()) { + listRoot(url); + return; + } + +#if 0 + if (!dev) { + error( TDEIO::ERR_DOES_NOT_EXIST, TQString("/%1").arg(devName) ); + return; + } +#endif + + if (resource.isEmpty()) { + listTopDeviceDir(devName); + return; + } + + listEntries(devName, resource, devPath, devCaps); +} diff --git a/kmobile/tdeioslave/tdeio_mobile.h b/kmobile/tdeioslave/tdeio_mobile.h new file mode 100644 index 000000000..05a30a22f --- /dev/null +++ b/kmobile/tdeioslave/tdeio_mobile.h @@ -0,0 +1,70 @@ +/* This file is part of the KDE mobile library. + Copyright (C) 2004 Helge Deller + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef __KIO_MOBILE_H__ +#define __KIO_MOBILE_H__ + +#include +#include + +#include +#include +#include + +class KMobileProtocol : public TDEIO::SlaveBase +{ +public: + KMobileProtocol( const TQCString &pool, const TQCString &app ); + ~KMobileProtocol(); + + void get( const KURL& url ); + void stat( const KURL& url ); + void mimetype( const KURL& url ); + void listDir( const KURL& url ); + +protected: + int getDeviceAndRessource(const TQString &_path, + TQString &devName, TQString &resource, TQString &devPath, + KMobileDevice::Capabilities &devCaps); + + TQString folderMimeType(int cap); + TQString entryMimeType(int cap); + + void listRoot(const KURL& url); + void listTopDeviceDir(const TQString &devName); + void listEntries(const TQString &devName, + const TQString &resource, const TQString &devPath, + const KMobileDevice::Capabilities devCaps); + + void listAddressBook(const TQString &devName, const TQString &resource); + int getVCard( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); + + void listCalendar(const TQString &devName, const TQString &resource); + int getCalendar( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); + + void listNotes(const TQString &devName, const TQString &resource); + int getNote( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); + + void listFileStorage(const TQString &devName, const TQString &resource, const TQString &devPath); + int getFileStorage( const TQString &devName, TQCString &result, TQString &mime, const TQString &path ); + +private: + KMobileClient m_dev; +}; + +#endif diff --git a/knode/Makefile.am b/knode/Makefile.am index 7d043e7bf..74981dfb3 100644 --- a/knode/Makefile.am +++ b/knode/Makefile.am @@ -26,7 +26,7 @@ kcm_knode_la_LIBADD = libknodecommon.la $(LIB_TDECORE) knconfigpages.lo: smtpaccountwidget_base.h libknodecommon_la_LDFLAGS = -version-info 3:0:0 -no-undefined $(all_libraries) -libknodecommon_la_LIBADD = $(top_builddir)/libkmime/libkmime.la $(top_builddir)/libkpgp/libkpgp.la $(top_builddir)/libtdepim/libtdepim.la $(LIB_KSPELL) $(LIB_KABC) $(LIB_KFILE) $(LIB_KUTILS) $(LIBRESOLV) $(LIB_KHTML) +libknodecommon_la_LIBADD = $(top_builddir)/libkmime/libkmime.la $(top_builddir)/libkpgp/libkpgp.la $(top_builddir)/libtdepim/libtdepim.la $(LIB_KSPELL) $(LIB_KABC) $(LIB_KFILE) $(LIB_KUTILS) $(LIBRESOLV) $(LIB_TDEHTML) libknodecommon_la_SOURCES = knconfigmanager.cpp \ knconfig.cpp \ knconfigwidgets.cpp \ diff --git a/knode/articlewidget.cpp b/knode/articlewidget.cpp index ae4ab2cbe..91ba87ac5 100644 --- a/knode/articlewidget.cpp +++ b/knode/articlewidget.cpp @@ -96,7 +96,7 @@ ArticleWidget::ArticleWidget( TQWidget *parent, mInstances.append( this ); TQHBoxLayout *box = new TQHBoxLayout( this ); - mViewer = new KHTMLPart( this, "mViewer" ); + mViewer = new TDEHTMLPart( this, "mViewer" ); box->addWidget( mViewer->widget() ); mViewer->widget()->setFocusPolicy( TQ_WheelFocus ); mViewer->setPluginsEnabled( false ); @@ -1105,7 +1105,7 @@ void ArticleWidget::cleanup() bool ArticleWidget::atBottom() const { - const KHTMLView *view = mViewer->view(); + const TDEHTMLView *view = mViewer->view(); return view->contentsY() + view->visibleHeight() >= view->contentsHeight(); } diff --git a/knode/articlewidget.h b/knode/articlewidget.h index da2968e83..2a508ee72 100644 --- a/knode/articlewidget.h +++ b/knode/articlewidget.h @@ -30,7 +30,7 @@ class TQTimer; class KAction; class KActionCollection; class KActionMenu; -class KHTMLPart; +class TDEHTMLPart; class KURL; class KSelectAction; class KToggleAction; @@ -221,7 +221,7 @@ class ArticleWidget : public TQWidget, public KNJobConsumer { /// mapping of temporary file names to part numbers TQMap mAttachementMap; - KHTMLPart *mViewer; + TDEHTMLPart *mViewer; CSSHelper *mCSSHelper; TQStringList mTempDirs, mTempFiles; diff --git a/kontact/src/Makefile.am b/kontact/src/Makefile.am index daec1fa3a..96513a5ac 100644 --- a/kontact/src/Makefile.am +++ b/kontact/src/Makefile.am @@ -13,7 +13,7 @@ kontact_METASOURCES = AUTO kontact_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(LIB_QT) -lDCOP $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx $(LIB_KIO) -ltdetexteditor kontact_LDADD = $(top_builddir)/libtdepim/libtdepim.la \ $(top_builddir)/kontact/interfaces/libkpinterfaces.la libkontact.la \ - $(LIB_KPARTS) $(LIB_KUTILS) $(LIB_KHTML) + $(LIB_KPARTS) $(LIB_KUTILS) $(LIB_TDEHTML) kontact_SOURCES = main.cpp mainwindow.cpp sidepanebase.cpp \ iconsidepane.cpp aboutdialog.cpp profilemanager.cpp profiledialog.cpp \ kontactiface.skel diff --git a/kontact/src/mainwindow.cpp b/kontact/src/mainwindow.cpp index e914fe07d..ec1e6b0bb 100644 --- a/kontact/src/mainwindow.cpp +++ b/kontact/src/mainwindow.cpp @@ -312,7 +312,7 @@ void MainWindow::initAboutScreen() TQHBox *introbox = new TQHBox( mPartsStack ); mPartsStack->addWidget( introbox ); mPartsStack->raiseWidget( introbox ); - mIntroPart = new KHTMLPart( introbox ); + mIntroPart = new TDEHTMLPart( introbox ); mIntroPart->widget()->setFocusPolicy( TQ_WheelFocus ); // Let's better be paranoid and disable plugins (it defaults to enabled): mIntroPart->setPluginsEnabled( false ); diff --git a/kontact/src/mainwindow.h b/kontact/src/mainwindow.h index de23b19a8..e9ddc121f 100644 --- a/kontact/src/mainwindow.h +++ b/kontact/src/mainwindow.h @@ -46,7 +46,7 @@ class KAction; class TDEConfig; class KPluginInfo; class KRSqueezedTextLabel; -class KHTMLPart; +class TDEHTMLPart; class KeyPressEater; namespace KPIM @@ -156,7 +156,7 @@ class MainWindow : public Kontact::Core, public KDCOPServiceStarter, public Kont PluginList mDelayedPreload; ActionPluginList mActionPlugins; TQValueList mPluginInfos; - KHTMLPart *mIntroPart; + TDEHTMLPart *mIntroPart; KRSqueezedTextLabel* mStatusMsgLabel; KPIM::StatusbarProgressWidget *mLittleProgress; diff --git a/korganizer/Makefile.am b/korganizer/Makefile.am index 59daa828e..fed0db81b 100644 --- a/korganizer/Makefile.am +++ b/korganizer/Makefile.am @@ -29,7 +29,7 @@ kcm_korganizer_la_LIBADD = libkorganizer.la $(top_builddir)/libtdepim/libtdepim. kcm_korganizer_la_COMPILE_FIRST = koprefs_base.h kogroupwareprefspage.h libkorganizerpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -libkorganizerpart_la_LIBADD = libkorganizer.la $(LIB_QT) $(LIB_TDECORE) $(LIB_KPARTS) $(LIB_KIO) $(LIB_KHTML) $(LIB_TDEUI) -L$(top_builddir)/libtdepim/ -ltdepim -L$(top_builddir)/libkcal/ -lkcal -lkorganizer_calendar +libkorganizerpart_la_LIBADD = libkorganizer.la $(LIB_QT) $(LIB_TDECORE) $(LIB_KPARTS) $(LIB_KIO) $(LIB_TDEHTML) $(LIB_TDEUI) -L$(top_builddir)/libtdepim/ -ltdepim -L$(top_builddir)/libkcal/ -lkcal -lkorganizer_calendar libkorganizerpart_la_SOURCES = korganizer_part.cpp libkorganizerpart_la_COMPILE_FIRST = publishdialog_base.h koprefs_base.h diff --git a/korn/kio_count.cpp b/korn/kio_count.cpp deleted file mode 100644 index 1531a9b9e..000000000 --- a/korn/kio_count.cpp +++ /dev/null @@ -1,330 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "kio_count.h" - -#include "kio.h" -#include "kio_proto.h" -#include "kio_single_subject.h" -#include "mailsubject.h" -#include "sortedmailsubject.h" - -#include -#include -#include -#include -#include -#include -#include - -#include - -KIO_Count::KIO_Count( TQObject * parent, const char * name ) - : TQObject ( parent, name ), - _kurl( 0 ), - _metadata( 0 ), - _protocol( 0 ), - _valid( true ), - _new_mailurls( 0 ), - _subjects_pending( 0 ), - _total_new_messages( 0 ), - _popup_subjects( 0 ) -{ -} - -KIO_Count::~KIO_Count() -{ - // Delete copies of urls. - delete _kurl; - delete _metadata; -} - -void KIO_Count::count( KKioDrop *drop ) -{ - if( _new_mailurls ) - return; //A counting is pending, so no new one is started. - - delete _kurl; - delete _metadata; - _kio = drop; - - /* - * Saving current settings: all actions are asynchroon, so if someone - * use slow servers, settings could been changed before this class is - * finished with counten. To be able to track back te staring values; - * these are saved in the class. - */ - _kurl = new KURL( *_kio->_kurl ); - _metadata = new TDEIO::MetaData( *_kio->_metadata ); - _protocol = _kio->_protocol; - - KURL kurl = *_kurl; - TDEIO::MetaData metadata = *_metadata; - - // Serup a connection - if( _protocol->connectionBased( ) ) - { - _protocol->recheckConnectKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); - - if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) //Forcing reload - { - kdWarning() << i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) << endl; - _kio->emitShowPassivePopup( i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) ); - _valid = false; - _kio->emitValidChanged(); - _slave = 0; - //delete _new_mailurls; _new_mailurls = 0; //No connection pending - return; - } - - connect( _slave, TQT_SIGNAL( error( int, const TQString& ) ), _kio, TQT_SLOT( slotConnectionError( int, const TQString& ) ) ); - connect( _slave, TQT_SIGNAL( warning( const TQString& ) ), _kio, TQT_SLOT( slotConnectionWarning( const TQString& ) ) ); - connect( _slave, TQT_SIGNAL( infoMessage( const TQString& ) ), _kio, TQT_SLOT( slotConnectionInfoMessage( const TQString& ) ) ); - - /* - * _protocol->recheckConnectKURL could have change kurl and metadata in order to have the right - * settings to connect. But some other functions assumed unmodified settings, - * so the settings are set back to his originals. - */ - kurl = *_kurl; - metadata = *_metadata; - } - else - { - _slave = 0; //Prevent disconnecting not-existing slave - } - - /* Blocking this function: no new counts can be started from now */ - _new_mailurls = new TQValueList< KKioDrop::FileInfo >; - - _protocol->recheckKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); - - //Making job to fetch file-list - - _job = TDEIO::listDir( kurl, false ); - _job->addMetaData( metadata ); - - connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); - connect( _job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), - this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); - - if( _protocol->connectionBased() ) - TDEIO::Scheduler::assignJobToSlave( _slave, _job ); - else - TDEIO::Scheduler::scheduleJob( _job ); -} - -void KIO_Count::stopActiveCount() -{ - if( !_new_mailurls ) - return; - - disconnect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); - disconnect( _job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), - this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); - - TDEIO::Scheduler::cancelJob( _job ); - - if( _slave ) - { - //Slave seems to be disconnected by canceling the last job of the slave - //TDEIO::Scheduler::disconnectSlave( _slave ); - _slave = 0; - } - - //Deletings settings - delete _kurl; _kurl = 0; - delete _metadata; _metadata = 0; - - delete _new_mailurls; _new_mailurls = 0; -} - -void KIO_Count::showPassive( const TQString& id ) -{ - KURL kurl = *_kio->_kurl; - TDEIO::MetaData metadata = *_kio->_metadata; - kurl = id; - //TDEIO::Slave *slave = 0; - - _kio->_protocol->readSubjectKURL( kurl, metadata ); - if( kurl.port() == 0 ) - kurl.setPort( _kio->_protocol->defaultPort( _kio->_ssl ) ); - - KIO_Single_Subject *subject = new KIO_Single_Subject( this, id.latin1(), kurl, metadata, _kio->_protocol, _slave, id, 0 ); - - _subjects_pending++; - - connect( subject, TQT_SIGNAL( readSubject( KornMailSubject* ) ), this, TQT_SLOT( addtoPassivePopup( KornMailSubject* ) ) ); - connect( subject, TQT_SIGNAL( finished( KIO_Single_Subject* ) ), this, TQT_SLOT( deleteSingleSubject( KIO_Single_Subject* ) ) ); -} - -void KIO_Count::disconnectSlave() -{ - if( _subjects_pending > 0 ) - return; //Still getting data - - if( !_protocol->connectionBased() ) - return; //Protocol doesn't have a connection - - if( !_slave ) - return; //Slave doens't exist - - //Disconnect slave - TDEIO::Scheduler::disconnectSlave( _slave ); - _slave = 0; - _protocol = 0; -} - -//This function is called when fetching is over -void KIO_Count::result( TDEIO::Job* job ) -{ - //job should be the latest job; elsewise: print an error. - if( job != _job ) - kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl; - - //look of an error occurred. If there is, print the error. - //This could be very useful by resolving bugs. - if( job->error() ) - { - kdError() << i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) << endl; - _kio->emitShowPassivePopup( i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) ); - _valid = false; - _kio->emitValidChanged(); - } - - disconnect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); - disconnect( job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), - this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); - - disconnectSlave(); - - //Deletings settings - delete _kurl; _kurl = 0; - delete _metadata; _metadata = 0; - - if( _kio->_mailurls->count() != _new_mailurls->count() ) - { - *_kio->_mailurls = *_new_mailurls; - _kio->emitChanged(_kio->_mailurls->count()); - } - else - { - *_kio->_mailurls = *_new_mailurls; - } - delete _new_mailurls; _new_mailurls = 0; - - _valid = true; - _kio->emitValidChanged(); - _kio->emitRechecked(); -} - -//An file list is ready; now save it in _kio->_mailurls. -void KIO_Count::entries( TDEIO::Job* job, const TDEIO::UDSEntryList &list ) -{ - TQStringList old_list; - TDEIO::UDSEntryListConstIterator it1 ; - TDEIO::UDSEntry::ConstIterator it2 ; - TDEIO::MetaData metadata; - KURL kurl; - bool isFile; - - //job should be the latest job - if( job != _job ) - kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl; - - for( TQValueListConstIterator it = _kio->_mailurls->begin(); it != _kio->_mailurls->end(); ++it ) - old_list.append( (*it).name ); - - for ( it1 = list.begin() ; it1 != list.end() ; it1++ ) - { - /* - * The list contains multiple objects. Each object could be a file. - * Settings about it are saved in this scope until it is added to the list. - */ - isFile=false; - KKioDrop::FileInfo fileinfo; - fileinfo.name = TQString(); - fileinfo.size = 0; - - for ( it2 = (*it1).begin() ; it2 != (*it1).end() ; it2++ ) - { - if( (*it2).m_uds == TDEIO::UDS_FILE_TYPE && - ((long)(*it2).m_long & S_IFREG ) ) - isFile=true; - else if( (*it2).m_uds == TDEIO::UDS_URL ) - fileinfo.name = (*it2).m_str; - else if( (*it2).m_uds == TDEIO::UDS_NAME ) - { //The file tdeioslave doesn't return UDS_URL. - kurl = *_kurl; - metadata = *_metadata; - _protocol->recheckKURL( kurl, metadata ); - kurl.setPath ( kurl.path() + '/' + (*it2).m_str ); - fileinfo.name = kurl.url(); - } - else if( (*it2).m_uds == TDEIO::UDS_SIZE ) - { - fileinfo.size = (*it2).m_long; - } - } - - //Add the entry. - if( ! fileinfo.name.isNull() && isFile ) - { - _new_mailurls->append( fileinfo ); - if( ! old_list.contains( fileinfo.name ) && _kio->passivePopup() ) - showPassive( fileinfo.name ); - } - } -} - -void KIO_Count::addtoPassivePopup( KornMailSubject* subject ) -{ - if( ! _popup_subjects ) - { - _popup_subjects = new SortedMailSubject; - _popup_subjects->setAutoDelete( true ); - } - - _popup_subjects->inSort( subject ); - if( _popup_subjects->count() > 5 ) - _popup_subjects->removeFirst(); //Overhead: subject is downloaded - - _subjects_pending--; - _total_new_messages++; - if( _subjects_pending == 0 ) - { - _kio->emitShowPassivePopup( dynamic_cast< TQPtrList* >( _popup_subjects ), _total_new_messages ); - delete _popup_subjects; _popup_subjects = 0; - _total_new_messages = 0; - - disconnectSlave(); - } -} - -void KIO_Count::deleteSingleSubject( KIO_Single_Subject* single_subject ) -{ - delete single_subject; -} - -#include "kio_count.moc" diff --git a/korn/kio_count.h b/korn/kio_count.h deleted file mode 100644 index e575864e4..000000000 --- a/korn/kio_count.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIOCOUNT_H -#define MK_KIOCOUNT_H - -//This class count the number of message available. - -#include - -#include "kio.h" //Alsewise, no access to KKioDrop::FileInfo (needed in template) - -#include //FIXME: without this, moc-compiler fails. - -class KIO_Protocol; -class KIO_Single_Subject; -class KKioDrop; - -class KornMailSubject; -class SortedMailSubject; - -template class TQValueList; -namespace TDEIO { class Job; class ListJob; class MetaData; class Slave; } - -class KURL; - -class TQString; - -class KIO_Count : public TQObject -{ Q_OBJECT - -public: - KIO_Count( TQObject * parent = 0, const char * name = 0 ); - ~KIO_Count(); - - //This function starts counting - void count( KKioDrop* ); - - //This functions returns true of no error has occurred. - bool valid( ) { return _valid; } - - void stopActiveCount(); -private: - KKioDrop *_kio; - TDEIO::ListJob *_job; - TDEIO::Slave *_slave; - KURL *_kurl; - TDEIO::MetaData *_metadata; - const KIO_Protocol *_protocol; - bool _valid; - TQValueList *_new_mailurls; //entries can come with more function calls. - int _subjects_pending; - int _total_new_messages; - SortedMailSubject *_popup_subjects; -private: - void showPassive( const TQString& ); - void disconnectSlave(); - -private slots: - void result( TDEIO::Job* ); - void entries( TDEIO::Job*, const TDEIO::UDSEntryList &list ); - - void addtoPassivePopup( KornMailSubject* ); - void deleteSingleSubject( KIO_Single_Subject* ); -}; - -#endif diff --git a/korn/kio_delete.cpp b/korn/kio_delete.cpp deleted file mode 100644 index a73b0dd40..000000000 --- a/korn/kio_delete.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "kio_delete.h" - -#include "mailid.h" -#include "stringid.h" -#include "kio.h" -#include "kio_proto.h" - -#include -#include -#include -#include -#include -#include - -#include - -KIO_Delete::KIO_Delete( TQObject * parent, const char * name ) : TQObject( parent, name ), - _kio( 0 ), - _total( 0 ), - _jobs( 0 ), - _slave( 0 ), - _valid( true ) -{ - _jobs = new TQPtrList< TDEIO::Job >; -} - -KIO_Delete::~KIO_Delete( ) -{ - disConnect( ); - delete _jobs; -} - -bool KIO_Delete::deleteMails( TQPtrList< const KornMailId > * ids, KKioDrop *drop ) -{ - KURL kurl = *drop->_kurl; - TDEIO::MetaData metadata = *drop->_metadata; - - _kio = drop; - _valid = true; - - //disConnect earlier operations - disConnect( ); - if( _kio->_protocol->connectionBased( ) ) - { - if( ! setupSlave( kurl, metadata, _kio->_protocol ) ) - { - _valid = false; - return false; - } - } - - _total = ids->count( ); - - for( const KornMailId * item = ids->first(); item; item = ids->next() ) - deleteItem( item, kurl, metadata, _kio->_protocol ); - - if( _jobs->count() == 0 ) - { - _kio->emitDeleteMailsReady( true ); - disConnect( ); - return true; - } - - if( _kio->_protocol->commitDelete() ) - commitDelete( kurl, metadata, _kio->_protocol ); - - _kio->emitDeleteMailsTotalSteps( _total ); - - return true; -} - -void KIO_Delete::disConnect( ) -{ - _jobs->clear( ); - - if( _slave ) - { - TDEIO::Scheduler::disconnectSlave( _slave ); - _slave = 0; - } -} - -bool KIO_Delete::setupSlave( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) -{ - protocol->deleteMailConnectKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); - - if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) - { - kdWarning() << i18n( "Could not get a connected slave; I cannot delete this way..." ) << endl; - _valid = false; - return false; - } - - return true; -} - -void KIO_Delete::deleteItem( const KornMailId *item, KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) -{ - TDEIO::Job* job = 0; - - kurl = dynamic_cast( item )->getId(); - - protocol->deleteMailKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); - - if( protocol->deleteFunction() == KIO_Protocol::get ) - { - job = TDEIO::get( kurl, true, false ); - - if( protocol->connectionBased() ) - TDEIO::Scheduler::assignJobToSlave( _slave, dynamic_cast< TDEIO::SimpleJob* >( job ) ); - else - TDEIO::Scheduler::scheduleJob( dynamic_cast< TDEIO::SimpleJob* >( job ) ); - } - else if( protocol->deleteFunction() == KIO_Protocol::del ) - { - job = TDEIO::del( kurl, false, false ); - } - else - return; //Unknown deleteFunction - - connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); - - job->addMetaData( metadata ); - - _jobs->append( dynamic_cast< TDEIO::Job* >( job ) ); -} - -/* - * Some protocols needs to a command to commit protocols. - */ -void KIO_Delete::commitDelete( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) -{ - protocol->deleteCommitKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); - - TDEIO::TransferJob *job = TDEIO::get( kurl, true, false ); - job->addMetaData( metadata ); - connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); - - _jobs->append( dynamic_cast< TDEIO::Job* >( job ) ); - - if( protocol->connectionBased() ) - TDEIO::Scheduler::assignJobToSlave( _slave, job ); - else - TDEIO::Scheduler::scheduleJob( job ); - - _total++; -} - -void KIO_Delete::canceled( ) -{ - disConnect( ); -} - -void KIO_Delete::slotResult( TDEIO::Job* job ) -{ - if( job->error() ) - { - kdWarning() << i18n( "An error occurred when deleting email: %1." ).arg( job->errorString() ) << endl; - _valid = false; - } - - _jobs->remove( job ); - - _kio->emitDeleteMailsProgress( _total - _jobs->count() ); - - if( _jobs->isEmpty() ) - { - _kio->emitDeleteMailsReady( _valid ); - disConnect(); - } -} - - -#include "kio_delete.moc" diff --git a/korn/kio_delete.h b/korn/kio_delete.h deleted file mode 100644 index c084a58de..000000000 --- a/korn/kio_delete.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIO_DELETE_H -#define MK_KIO_DELETE_H - -/* - * This class handles removing of selected messages. - * This class starts working when deleteMails() is called. - */ - -#include -class KKioDrop; -class KIO_Protocol; -class KornMailId; - -class KURL; -namespace TDEIO { class MetaData; class Job; class Slave; } - -template class TQPtrList; - -class KIO_Delete : public TQObject -{ Q_OBJECT - -public: - //constructors - KIO_Delete( TQObject * parent = 0, const char * name = 0 ); - ~KIO_Delete( ); - - //This function should be called if there are messages to be deleted. - bool deleteMails( TQPtrList< const KornMailId > *, KKioDrop* ); - - //This function should return false then and only then if an error occurred. - bool valid( ) { return _valid; } - -public slots: - //If this slot is called, the whole deletion is canceled. - void canceled( ); -private slots: - void slotResult( TDEIO::Job* ); - -private: - void disConnect( ); - bool setupSlave( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ); - void deleteItem( const KornMailId *item, KURL, TDEIO::MetaData, const KIO_Protocol *&); - void commitDelete( KURL, TDEIO::MetaData, const KIO_Protocol *& ); - - KKioDrop *_kio; - unsigned int _total; - TQPtrList< TDEIO::Job > *_jobs; - TDEIO::Slave *_slave; - bool _valid; -}; - -#endif //MK_KIO_DELETE_H diff --git a/korn/kio_proto.cpp b/korn/kio_proto.cpp deleted file mode 100644 index e63a71666..000000000 --- a/korn/kio_proto.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - - -#include "kio_proto.h" - -#include -#include - -#include - -TQMap< TQString, TQString >* KIO_Protocol::createConfig( TDEConfigGroup * group, const TQString& password ) const -{ - TQMap< TQString, TQString > *result = new TQMap< TQString, TQString >; - - result->insert( "name", group->readEntry( "name", "" ) ); - result->insert( "server", group->readEntry( "server", "" ) ); - result->insert( "port", group->readEntry( "port", "" ) ); - result->insert( "username", group->readEntry( "username", "" ) ); - result->insert( "password", password ); - result->insert( "mailbox", group->readEntry( "mailbox", "" ) ); - result->insert( "savepassword", group->readEntry( "savepassword", "false" ) ); - result->insert( "ssl", group->readEntry( "ssl", "false" ) ); - result->insert( "metadata", group->readEntry( "metadata", "" ) ); - - return result; -} - -void KIO_Protocol::clearFields( TQMap *map, const KIO_Protocol::Fields fields ) const -{ - if( fields & server ) - map->insert( "server", "" ); - if( fields & port ) - map->insert( "port", "" ); - if( fields & username ) - map->insert( "username", "" ); - if( fields & password ) - map->insert( "password", "" ); - if( fields & mailbox ) - map->insert( "mailbox", "" ); - if( fields & save_password ) - map->insert( "savepassword", "" ); - if( fields & metadata ) - map->insert( "metadata", "" ); -} - -void KIO_Protocol::readEntries( TQMap< TQString, TQString >* map ) const -{ - TQMap< TQString, TQString> *metadata = new TQMap< TQString, TQString >; - - if( map->contains( "metadata" ) ) - { - TQStringList list = TQStringList::split( ",", *map->find( "metadata" ) ); - TQStringList::Iterator it; - for( it = list.begin(); it != list.end(); ++it ) - { - int split = (*it).find( '=' ); - - metadata->insert( (*it).left( split ), (*it).right( (*it).length() - split - 1 ) ); - } - } - - this->readEntries( map, metadata ); - - delete metadata; -} diff --git a/korn/kio_proto.h b/korn/kio_proto.h deleted file mode 100644 index 510e97d37..000000000 --- a/korn/kio_proto.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIO_PROTO_H -#define MK_KIO_PROTO_H - -/* - * KIO can handle multiple protocols. But some protocols have their own - * manipulations of KURL or MetaData , and some protocols could do more then other - * protocols. So, this class is the generic class of a class specified - * by a protocol. - */ - -class TQString; -#include -#include -#include -#include "protocol.h" - -#include "kio.h" - -class KIO_Protocol : public Protocol -{ -public: - /* - * Constuctor; empty - */ - KIO_Protocol() {} - - /* - * Destructor; empty too - */ - virtual ~KIO_Protocol() {} - - /* - * Public enumeration - */ - enum DeleteTypeEnum { get, del }; - /** - * This are the implementation of the Protocol-functions - */ - virtual const Protocol* getProtocol( TDEConfigGroup* ) const { return this; } - - virtual KMailDrop* createMaildrop( TDEConfigGroup* config ) const { return new KKioDrop( config ); } - - virtual TQMap< TQString, TQString >* createConfig( TDEConfigGroup *group, const TQString& password ) const; - - /* - * @return: the name of the kio_slave - */ - virtual TQString protocol( bool ) const { return "file"; } - - /* - * @return: the name of the protocol used by the configuration - */ - virtual TQString configName() const { return "not specified"; } - - virtual bool connectionBased() const { return false; } - - /* - * The next four functions return the [capebilities] of a protocol. - * fullMessage means that by downloaden, the whole message is downloaded. - * if it is false, only the headers should be downloaded. - */ - virtual bool canReadSubjects() const { return false; } - virtual bool canDeleteMail() const { return false; } - virtual bool canReadMail() const { return false; } - virtual bool fullMessage() const { return false; } - - /* - * The following lines are the options in the configuration; - * true means that an option is enabled; - * false means that the option is disabled. - */ - //virtual int fields() const { return server | port | username | password | mailbox; } - //virtual int urlFields() const { return no_fields; } - virtual unsigned short defaultPort( bool ) const { return 0; } - - /* - * This sets the string of such fields in Configuration - */ - virtual TQString serverName() const { return i18n( "Server:" ); } - virtual TQString portName() const { return i18n( "Port:" ); } - virtual TQString usernameName() const { return i18n( "Username:" ); } - virtual TQString mailboxName() const { return i18n( "Mailbox:" ); } - virtual TQString passwordName() const { return i18n( "Password:" ); } - virtual TQString savePasswordName() const { return i18n( "Save password" ); } - virtual TQString authName() const { return i18n( "Authentication:" ); } - - /* - * The next function returns the method of deleting: some protoocols - * like to delete files with TDEIO::get; other with TDEIO::del - */ - virtual DeleteTypeEnum deleteFunction() const { return del; } - - /* - * The next options are the input for the Authentication Combo, seperated by '|'. - * The name should be the same as the auth-metadata. - */ - virtual TQStringList authList() const { return TQStringList::split( '|', "Plain", false ); } - - /* - * The next functions are manipulations of an KURL. - * At some points in the code, a KURL is used. But sometimes, - * these have to had a little retouch. That is possible with these function. - * - * For example, by imap, by default, the whole message is downloaded and marked as reed. - * By changing an option to the KURL path, this can be prevented. - * - * The most functions are recognized by name. - * commitDelete return true if a protocol has to confirm a deletion. - * It will be called after marking the messages for deletion. - * deleteCommitKURL is the KURL manipulator; the KURL is as in the settings. - * That KURL isn't retouch by deleteMailKURL. - */ - virtual void recheckConnectKURL( KURL &, TDEIO::MetaData & ) const { } - virtual void recheckKURL ( KURL &, TDEIO::MetaData & ) const { }; - virtual void readSubjectConnectKURL ( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); } - virtual void readSubjectKURL ( KURL &, TDEIO::MetaData & ) const { } //For editing a kurl (adding extra options) - virtual void deleteMailConnectKURL( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); } - virtual void deleteMailKURL ( KURL &, TDEIO::MetaData & ) const { } - virtual bool commitDelete() const { return false; } - virtual void deleteCommitKURL( KURL &, TDEIO::MetaData & ) const { } - virtual void readMailKURL ( KURL &, TDEIO::MetaData & ) const { } - - - virtual const KIO_Protocol* getKIOProtocol() const { return this; } - - virtual void readEntries( TQMap< TQString, TQString >* ) const; - virtual void readEntries( TQMap< TQString, TQString >*, TQMap< TQString, TQString >* ) const = 0; - -protected: - /* - * This enumeration is used when returning the capebilitys of a protocol - */ - enum Fields { no_fields = 0, server = 1, port = 2, username = 4, password = 8, - mailbox = 16, save_password = 32, metadata = 64 }; - - void clearFields( TQMap< TQString, TQString > *map, const Fields fields ) const; -}; - -#endif //MK_KIO_PROTO_H diff --git a/korn/kio_read.cpp b/korn/kio_read.cpp deleted file mode 100644 index f98669d8d..000000000 --- a/korn/kio_read.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "kio_read.h" - -#include "kio.h" -#include "kio_proto.h" -#include "mailid.h" -#include "stringid.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -KIO_Read::KIO_Read( TQObject * parent, const char * name ) - : TQObject( parent, name ), - _job( 0 ), - _message( 0 ) -{ - _message = new TQString; -} - -KIO_Read::~KIO_Read() -{ - delete _message; - delete _job; -} - -void KIO_Read::readMail( const KornMailId *& mailid, KKioDrop* drop ) -{ - _kio = drop; - KURL kurl = *_kio->_kurl; - TDEIO::MetaData metadata = *_kio->_metadata; - - kurl = dynamic_cast(mailid)->getId( ); - - _kio->_protocol->readMailKURL( kurl, metadata ); - - _job = TDEIO::get( kurl, false, false ); - _job->addMetaData( metadata ); - - connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); - connect( _job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), this, TQT_SLOT( slotData( TDEIO::Job*, const TQByteArray & ) ) ); -} - -void KIO_Read::canceled( ) -{ - if( _job ) - delete _job; - _job = 0; -} - -void KIO_Read::slotResult( TDEIO::Job* job ) -{ - if( job != _job ) - kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl; - - if( job->error() ) - kdWarning() << i18n( "An error occurred when fetching the requested email: %1." ).arg( job->errorString() ) << endl; - - _kio->emitReadMailReady( _message ); - - *_message = ""; - _job = 0; -} - -void KIO_Read::slotData( TDEIO::Job* job, const TQByteArray & data ) -{ - if( job != _job ) - kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl; - - if( !data.isEmpty() ) - _message->append( data ); -} - -#include "kio_read.moc" diff --git a/korn/kio_read.h b/korn/kio_read.h deleted file mode 100644 index 3b1ddec8e..000000000 --- a/korn/kio_read.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIO_READ_H -#define MK_KIO_READ_H - -//This class should be used if someone wants to read the Full Message - -#include - -class KKioDrop; -class KornMailId; - -class KURL; -namespace TDEIO { class MetaData; class Job; } -class KIO_Protocol; - -class TQString; - -class KIO_Read : public TQObject -{ Q_OBJECT - -public: - KIO_Read( TQObject * parent = 0, const char * name = 0 ); - ~KIO_Read(); - -public slots: - //This is the function which makes the nessesairy slaves for reading a message - void readMail( const KornMailId *&, KKioDrop* ); - //This function should be called if the user presses canceled. - void canceled(); -private: - KKioDrop *_kio; - TDEIO::Job *_job; - TQString *_message; - -signals: - //This signal is emitted when the whole message is read; the message got passed as TQString* - void ready( TQString* ); - -private slots: - void slotResult( TDEIO::Job* ); - void slotData( TDEIO::Job*, const TQByteArray& ); -}; - -#endif //MK_KIO_READ_H diff --git a/korn/kio_single_subject.cpp b/korn/kio_single_subject.cpp deleted file mode 100644 index 0c20b1ab4..000000000 --- a/korn/kio_single_subject.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "kio_single_subject.h" - -#include "mailsubject.h" -#include "kio_proto.h" -#include "stringid.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -KIO_Single_Subject::KIO_Single_Subject( TQObject * parent, const char * name, - KURL &kurl, TDEIO::MetaData &metadata, const KIO_Protocol * protocol, TDEIO::Slave *& slave, - const TQString &url, const long size ) - : TQObject( parent, name ) -{ - _kurl = new KURL( kurl ); - _metadata = new TDEIO::MetaData( metadata ); - _protocol = protocol; - _name = new TQString( url ); - _size = size; - _message = new TQString; - - init( slave ); -} - -KIO_Single_Subject::~KIO_Single_Subject( ) -{ - if( _job ) - TDEIO::Scheduler::cancelJob( _job ); - delete _kurl; - delete _metadata; - delete _name; - delete _message; -} - -void KIO_Single_Subject::init( TDEIO::Slave *& slave) -{ - _job = TDEIO::get( *_kurl, false, false ); - _job->addMetaData( *_metadata ); - - connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); - connect( _job, TQT_SIGNAL( data (TDEIO::Job *, const TQByteArray &) ), - this, TQT_SLOT( slotData(TDEIO::Job *, const TQByteArray &) ) ); - - if( _protocol->connectionBased( ) && slave ) - TDEIO::Scheduler::assignJobToSlave( slave , _job ); - else - TDEIO::Scheduler::scheduleJob( _job ); - -} - -void KIO_Single_Subject::parseMail( TQString * message, KornMailSubject *subject, bool fullMessage ) -{ - TQTextStream stream( message, IO_ReadOnly ); - TQString line; - TQRegExp rx_sender( "^[fF]rom: " ); //Ex: From: ... - TQRegExp rx_sender_has_name1( "^[fF]rom:\\s*(\\w+[\\w\\s]*)\\<" ); //Ex: From: A name - TQRegExp rx_sender_has_name2( "^[fF]rom:\\s*\\\"\\s*(\\w+[\\w\\s]*)\\\""); //Ex: From: "A name" - TQRegExp rx_subject( "^[sS]ubject: " ); //Ex: Subject: ... - TQRegExp rx_date ( "^[dD]ate: "); - bool inheader = true; - int fieldnumber = 0; - - while ( ! stream.atEnd() ) - { - line = stream.readLine(); - if( line.isEmpty() && fieldnumber >= 2 ) - inheader = false; - - if( inheader ) - { - if( rx_sender.search( line ) == 0 ) - { - if( rx_sender_has_name1.search( line ) == 0 ) - subject->setSender( rx_sender_has_name1.cap( 1 ) ); - else if(rx_sender_has_name2.search( line ) == 0) - subject->setSender( rx_sender_has_name2.cap( 1 ) ); - else - subject->setSender( line.remove( rx_sender ) ); - ++fieldnumber; - } - else if( rx_subject.search( line ) == 0 ) - { - subject->setSubject( line.remove( rx_subject ) ); - ++fieldnumber; - } - else if( rx_date.search( line ) == 0 ) - { - subject->setDate( KRFCDate::parseDate( line.right( line.length() - 6 ) ) ); - ++fieldnumber; - } - } - } - - subject->setHeader( *message, fullMessage ); -} - -void KIO_Single_Subject::slotData( TDEIO::Job* job, const TQByteArray& data ) -{ - if( job != _job ) - kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl; - if( !data.isEmpty() ) - _message->append( data ); -} - -//TDEIO::Scheduler::disconnectSlave missing if connection stops -void KIO_Single_Subject::slotResult( TDEIO::Job *job ) -{ - if( job != _job ) - kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl; - - if( job->error() ) - { - kdWarning() << i18n( "Error when fetching %1: %2" ).arg( *_name ).arg( job->errorString() ) << endl; - } else { - KornMailSubject * mailSubject = new KornMailSubject( new KornStringId( *_name ), 0 ); - parseMail( _message, mailSubject, _protocol->fullMessage() ); - mailSubject->decodeHeaders(); - mailSubject->setSize( _size ); - emit readSubject( mailSubject ); - } - - _job = 0; - - emit finished( this ); -} - -#include "kio_single_subject.moc" diff --git a/korn/kio_single_subject.h b/korn/kio_single_subject.h deleted file mode 100644 index 9aac8baae..000000000 --- a/korn/kio_single_subject.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIO_SINGEL_SUBJECT_H -#define MK_KIO_SINGEL_SUBJECT_H - -//This function reads a single subject - -#include -#include - -class KornMailSubject; - -class KURL; -namespace TDEIO { class MetaData; class Job; class TransferJob; class Slave; } -class KIO_Protocol; - -class TQString; - -class KIO_Single_Subject : public TQObject -{ Q_OBJECT - -public: - KIO_Single_Subject( TQObject * parent, const char * name, KURL &, TDEIO::MetaData &, const KIO_Protocol *, - TDEIO::Slave *&, const TQString &, const long ); - ~KIO_Single_Subject( ); - - //This functions try's te parse EMail; data, sender names and so on... - static void parseMail( TQString * message, KornMailSubject *subject, bool ); - -private: - TQString *_message; - TQString *_name; - KURL *_kurl; - const KIO_Protocol *_protocol; - TDEIO::MetaData *_metadata; - TDEIO::TransferJob* _job; - long _size; - - void init( TDEIO::Slave*& ); - -private slots: - void slotResult( TDEIO::Job* ); - void slotData( TDEIO::Job*, const TQByteArray& ); - -signals: - //This signal is emitted if the headers are read and put into a KornMailSubject* - void readSubject( KornMailSubject* ); - //This signal is emitted if this class could be destroyed. - void finished( KIO_Single_Subject* ); -}; - -#endif diff --git a/korn/kio_subjects.cpp b/korn/kio_subjects.cpp deleted file mode 100644 index f40a86f64..000000000 --- a/korn/kio_subjects.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "kio_subjects.h" - -#include "kio.h" -#include "kio_single_subject.h" -#include "kio_proto.h" -#include "mailsubject.h" - -#include -#include -#include - -#include -#include -#include - -KIO_Subjects::KIO_Subjects( TQObject * parent, const char * name ) - : TQObject( parent, name ), - _protocol( 0 ), - _slave( 0 ), - _valid( true ) -{ - _jobs = new TQPtrList; - _kurl = new KURL; - _metadata = new TDEIO::MetaData; - - _jobs->setAutoDelete( true ); -} - -KIO_Subjects::~KIO_Subjects( ) -{ - delete _jobs; - delete _kurl; - delete _metadata; - _protocol = 0; -} - -void KIO_Subjects::doReadSubjects( KKioDrop *drop ) -{ - TQValueList::ConstIterator it; - TQValueList::ConstIterator end_it = drop->_mailurls->end(); - - _kio = drop; - _protocol = _kio->_protocol; - *_kurl = *_kio->_kurl; - *_metadata = *_kio->_metadata; - - if( _jobs->count() > 0 ) - kdWarning() << i18n( "Already a slave pending." ) << endl; - - _jobs->clear( ); - - //Open connection - getConnection( ); - - //Open jobs for easy item in the list - for( it = _kio->_mailurls->begin(); it != end_it; it++ ) - startJob( (*it).name, (*it).size ); - - //close connection for trivial situations (empty list) - disConnect( true ); - - //passing number of subjects for progress bar. - _kio->emitReadSubjectsTotalSteps( _jobs->count() ); -} - -void KIO_Subjects::getConnection( ) -{ - KURL kurl = *_kurl; - TDEIO::MetaData metadata = *_metadata; - - if( _slave ) - { - TDEIO::Scheduler::disconnectSlave( _slave ); - _slave = 0; - } - - if( _protocol->connectionBased( ) ) - { - _protocol->readSubjectConnectKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); - - if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) - { - kdWarning() << i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() ); - _kio->emitShowPassivePopup( i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() ) ); - _valid = false; - _kio->emitValidChanged(); - _slave = 0; - _kio->emitReadSubjectsReady( false ); - return; - } - } -} - -void KIO_Subjects::startJob( const TQString &name, const long size ) -{ - KURL kurl = *_kurl; - TDEIO::MetaData metadata = *_metadata; - KIO_Single_Subject *subject; - - kurl = name; - - _protocol->readSubjectKURL( kurl, metadata ); - - if( kurl.port() == 0 ) - kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); - - subject = new KIO_Single_Subject( this, name.latin1(), kurl, metadata, _protocol, _slave, name, size ); - - connect( subject, TQT_SIGNAL( readSubject( KornMailSubject* ) ), this, TQT_SLOT( slotReadSubject( KornMailSubject* ) ) ); - connect( subject, TQT_SIGNAL( finished( KIO_Single_Subject* ) ), this, TQT_SLOT( slotFinished( KIO_Single_Subject* ) ) ); - - _jobs->append( subject ); -} - -void KIO_Subjects::disConnect( bool result ) -{ - if( _jobs->isEmpty() ) - { - if( _slave ) - { - TDEIO::Scheduler::disconnectSlave( _slave ); - _slave = 0; - } - _kio->emitReadSubjectsReady( result ); - } -} - -void KIO_Subjects::cancelled( ) -{ - _jobs->clear(); - //_slave died in cancelJob with is by called from the destructor of KIO_Single_Subject, - //withs is by called by _jobs->clear because autoRemove equals true. - _slave = 0; - disConnect( false ); -} - -void KIO_Subjects::slotReadSubject( KornMailSubject* subject ) -{ - _valid = true; - _kio->emitValidChanged(); - subject->setMailDrop( _kio ); - _kio->emitReadSubjectsRead( subject ); -} - -void KIO_Subjects::slotFinished( KIO_Single_Subject* item ) -{ - //Remove sender.... I didn't know of the computer gonna like me, but it seems he does :) - _jobs->remove( item ); - - _kio->emitReadSubjectsProgress( _jobs->count( ) ); - - disConnect( true ); //Only works when all jobs are finished. -} - -#include "kio_subjects.moc" diff --git a/korn/kio_subjects.h b/korn/kio_subjects.h deleted file mode 100644 index 018369de6..000000000 --- a/korn/kio_subjects.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program 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 General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef MK_KIO_SUBJECTS_H -#define MK_KIO_SUBJECTS_H - -//This class calls other class to read all the subjects - -#include -class KKioDrop; -class KIO_Single_Subject; -class KIO_Protocol; -class KornMailSubject; - -namespace TDEIO { class MetaData; class Slave; } -class KURL; - -template class TQPtrList; -class TQString; -template class TQValueList; - -class KIO_Subjects : public TQObject -{ Q_OBJECT - -public: - KIO_Subjects( TQObject * parent, const char * name ); - ~KIO_Subjects( ); - - //This function let it start fetching headers. - void doReadSubjects( KKioDrop* ); - - //This function should return true then and only then of no error occurred. - bool valid( ) { return _valid; } - -private: - KKioDrop *_kio; - KURL *_kurl; - TDEIO::MetaData *_metadata; - const KIO_Protocol *_protocol; - TQPtrList *_jobs; - TDEIO::Slave *_slave; - bool _valid; - - //Opens a connection. - void getConnection( ); - //Start a job; the job itself is executed in KIO_Single_Subject - void startJob( const TQString&, const long ); - //Disconnect the connection - void disConnect( bool ); - -public slots: - //This function called the fetching of headers. - void cancelled( ); - -private slots: - void slotReadSubject( KornMailSubject* ); - void slotFinished( KIO_Single_Subject* ); -}; - -#endif diff --git a/korn/tdeio_count.cpp b/korn/tdeio_count.cpp new file mode 100644 index 000000000..1531a9b9e --- /dev/null +++ b/korn/tdeio_count.cpp @@ -0,0 +1,330 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "kio_count.h" + +#include "kio.h" +#include "kio_proto.h" +#include "kio_single_subject.h" +#include "mailsubject.h" +#include "sortedmailsubject.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +KIO_Count::KIO_Count( TQObject * parent, const char * name ) + : TQObject ( parent, name ), + _kurl( 0 ), + _metadata( 0 ), + _protocol( 0 ), + _valid( true ), + _new_mailurls( 0 ), + _subjects_pending( 0 ), + _total_new_messages( 0 ), + _popup_subjects( 0 ) +{ +} + +KIO_Count::~KIO_Count() +{ + // Delete copies of urls. + delete _kurl; + delete _metadata; +} + +void KIO_Count::count( KKioDrop *drop ) +{ + if( _new_mailurls ) + return; //A counting is pending, so no new one is started. + + delete _kurl; + delete _metadata; + _kio = drop; + + /* + * Saving current settings: all actions are asynchroon, so if someone + * use slow servers, settings could been changed before this class is + * finished with counten. To be able to track back te staring values; + * these are saved in the class. + */ + _kurl = new KURL( *_kio->_kurl ); + _metadata = new TDEIO::MetaData( *_kio->_metadata ); + _protocol = _kio->_protocol; + + KURL kurl = *_kurl; + TDEIO::MetaData metadata = *_metadata; + + // Serup a connection + if( _protocol->connectionBased( ) ) + { + _protocol->recheckConnectKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); + + if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) //Forcing reload + { + kdWarning() << i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) << endl; + _kio->emitShowPassivePopup( i18n( "Not able to open a kio slave for %1." ).arg( _protocol->configName() ) ); + _valid = false; + _kio->emitValidChanged(); + _slave = 0; + //delete _new_mailurls; _new_mailurls = 0; //No connection pending + return; + } + + connect( _slave, TQT_SIGNAL( error( int, const TQString& ) ), _kio, TQT_SLOT( slotConnectionError( int, const TQString& ) ) ); + connect( _slave, TQT_SIGNAL( warning( const TQString& ) ), _kio, TQT_SLOT( slotConnectionWarning( const TQString& ) ) ); + connect( _slave, TQT_SIGNAL( infoMessage( const TQString& ) ), _kio, TQT_SLOT( slotConnectionInfoMessage( const TQString& ) ) ); + + /* + * _protocol->recheckConnectKURL could have change kurl and metadata in order to have the right + * settings to connect. But some other functions assumed unmodified settings, + * so the settings are set back to his originals. + */ + kurl = *_kurl; + metadata = *_metadata; + } + else + { + _slave = 0; //Prevent disconnecting not-existing slave + } + + /* Blocking this function: no new counts can be started from now */ + _new_mailurls = new TQValueList< KKioDrop::FileInfo >; + + _protocol->recheckKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); + + //Making job to fetch file-list + + _job = TDEIO::listDir( kurl, false ); + _job->addMetaData( metadata ); + + connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); + connect( _job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), + this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); + + if( _protocol->connectionBased() ) + TDEIO::Scheduler::assignJobToSlave( _slave, _job ); + else + TDEIO::Scheduler::scheduleJob( _job ); +} + +void KIO_Count::stopActiveCount() +{ + if( !_new_mailurls ) + return; + + disconnect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); + disconnect( _job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), + this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); + + TDEIO::Scheduler::cancelJob( _job ); + + if( _slave ) + { + //Slave seems to be disconnected by canceling the last job of the slave + //TDEIO::Scheduler::disconnectSlave( _slave ); + _slave = 0; + } + + //Deletings settings + delete _kurl; _kurl = 0; + delete _metadata; _metadata = 0; + + delete _new_mailurls; _new_mailurls = 0; +} + +void KIO_Count::showPassive( const TQString& id ) +{ + KURL kurl = *_kio->_kurl; + TDEIO::MetaData metadata = *_kio->_metadata; + kurl = id; + //TDEIO::Slave *slave = 0; + + _kio->_protocol->readSubjectKURL( kurl, metadata ); + if( kurl.port() == 0 ) + kurl.setPort( _kio->_protocol->defaultPort( _kio->_ssl ) ); + + KIO_Single_Subject *subject = new KIO_Single_Subject( this, id.latin1(), kurl, metadata, _kio->_protocol, _slave, id, 0 ); + + _subjects_pending++; + + connect( subject, TQT_SIGNAL( readSubject( KornMailSubject* ) ), this, TQT_SLOT( addtoPassivePopup( KornMailSubject* ) ) ); + connect( subject, TQT_SIGNAL( finished( KIO_Single_Subject* ) ), this, TQT_SLOT( deleteSingleSubject( KIO_Single_Subject* ) ) ); +} + +void KIO_Count::disconnectSlave() +{ + if( _subjects_pending > 0 ) + return; //Still getting data + + if( !_protocol->connectionBased() ) + return; //Protocol doesn't have a connection + + if( !_slave ) + return; //Slave doens't exist + + //Disconnect slave + TDEIO::Scheduler::disconnectSlave( _slave ); + _slave = 0; + _protocol = 0; +} + +//This function is called when fetching is over +void KIO_Count::result( TDEIO::Job* job ) +{ + //job should be the latest job; elsewise: print an error. + if( job != _job ) + kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl; + + //look of an error occurred. If there is, print the error. + //This could be very useful by resolving bugs. + if( job->error() ) + { + kdError() << i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) << endl; + _kio->emitShowPassivePopup( i18n( "The next KIO-error occurred by counting: %1" ).arg( job->errorString() ) ); + _valid = false; + _kio->emitValidChanged(); + } + + disconnect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( result( TDEIO::Job* ) ) ); + disconnect( job, TQT_SIGNAL( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ), + this, TQT_SLOT( entries( TDEIO::Job*, const TDEIO::UDSEntryList& ) ) ); + + disconnectSlave(); + + //Deletings settings + delete _kurl; _kurl = 0; + delete _metadata; _metadata = 0; + + if( _kio->_mailurls->count() != _new_mailurls->count() ) + { + *_kio->_mailurls = *_new_mailurls; + _kio->emitChanged(_kio->_mailurls->count()); + } + else + { + *_kio->_mailurls = *_new_mailurls; + } + delete _new_mailurls; _new_mailurls = 0; + + _valid = true; + _kio->emitValidChanged(); + _kio->emitRechecked(); +} + +//An file list is ready; now save it in _kio->_mailurls. +void KIO_Count::entries( TDEIO::Job* job, const TDEIO::UDSEntryList &list ) +{ + TQStringList old_list; + TDEIO::UDSEntryListConstIterator it1 ; + TDEIO::UDSEntry::ConstIterator it2 ; + TDEIO::MetaData metadata; + KURL kurl; + bool isFile; + + //job should be the latest job + if( job != _job ) + kdError() << i18n( "Got unknown job; something must be wrong..." ) << endl; + + for( TQValueListConstIterator it = _kio->_mailurls->begin(); it != _kio->_mailurls->end(); ++it ) + old_list.append( (*it).name ); + + for ( it1 = list.begin() ; it1 != list.end() ; it1++ ) + { + /* + * The list contains multiple objects. Each object could be a file. + * Settings about it are saved in this scope until it is added to the list. + */ + isFile=false; + KKioDrop::FileInfo fileinfo; + fileinfo.name = TQString(); + fileinfo.size = 0; + + for ( it2 = (*it1).begin() ; it2 != (*it1).end() ; it2++ ) + { + if( (*it2).m_uds == TDEIO::UDS_FILE_TYPE && + ((long)(*it2).m_long & S_IFREG ) ) + isFile=true; + else if( (*it2).m_uds == TDEIO::UDS_URL ) + fileinfo.name = (*it2).m_str; + else if( (*it2).m_uds == TDEIO::UDS_NAME ) + { //The file tdeioslave doesn't return UDS_URL. + kurl = *_kurl; + metadata = *_metadata; + _protocol->recheckKURL( kurl, metadata ); + kurl.setPath ( kurl.path() + '/' + (*it2).m_str ); + fileinfo.name = kurl.url(); + } + else if( (*it2).m_uds == TDEIO::UDS_SIZE ) + { + fileinfo.size = (*it2).m_long; + } + } + + //Add the entry. + if( ! fileinfo.name.isNull() && isFile ) + { + _new_mailurls->append( fileinfo ); + if( ! old_list.contains( fileinfo.name ) && _kio->passivePopup() ) + showPassive( fileinfo.name ); + } + } +} + +void KIO_Count::addtoPassivePopup( KornMailSubject* subject ) +{ + if( ! _popup_subjects ) + { + _popup_subjects = new SortedMailSubject; + _popup_subjects->setAutoDelete( true ); + } + + _popup_subjects->inSort( subject ); + if( _popup_subjects->count() > 5 ) + _popup_subjects->removeFirst(); //Overhead: subject is downloaded + + _subjects_pending--; + _total_new_messages++; + if( _subjects_pending == 0 ) + { + _kio->emitShowPassivePopup( dynamic_cast< TQPtrList* >( _popup_subjects ), _total_new_messages ); + delete _popup_subjects; _popup_subjects = 0; + _total_new_messages = 0; + + disconnectSlave(); + } +} + +void KIO_Count::deleteSingleSubject( KIO_Single_Subject* single_subject ) +{ + delete single_subject; +} + +#include "kio_count.moc" diff --git a/korn/tdeio_count.h b/korn/tdeio_count.h new file mode 100644 index 000000000..e575864e4 --- /dev/null +++ b/korn/tdeio_count.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIOCOUNT_H +#define MK_KIOCOUNT_H + +//This class count the number of message available. + +#include + +#include "kio.h" //Alsewise, no access to KKioDrop::FileInfo (needed in template) + +#include //FIXME: without this, moc-compiler fails. + +class KIO_Protocol; +class KIO_Single_Subject; +class KKioDrop; + +class KornMailSubject; +class SortedMailSubject; + +template class TQValueList; +namespace TDEIO { class Job; class ListJob; class MetaData; class Slave; } + +class KURL; + +class TQString; + +class KIO_Count : public TQObject +{ Q_OBJECT + +public: + KIO_Count( TQObject * parent = 0, const char * name = 0 ); + ~KIO_Count(); + + //This function starts counting + void count( KKioDrop* ); + + //This functions returns true of no error has occurred. + bool valid( ) { return _valid; } + + void stopActiveCount(); +private: + KKioDrop *_kio; + TDEIO::ListJob *_job; + TDEIO::Slave *_slave; + KURL *_kurl; + TDEIO::MetaData *_metadata; + const KIO_Protocol *_protocol; + bool _valid; + TQValueList *_new_mailurls; //entries can come with more function calls. + int _subjects_pending; + int _total_new_messages; + SortedMailSubject *_popup_subjects; +private: + void showPassive( const TQString& ); + void disconnectSlave(); + +private slots: + void result( TDEIO::Job* ); + void entries( TDEIO::Job*, const TDEIO::UDSEntryList &list ); + + void addtoPassivePopup( KornMailSubject* ); + void deleteSingleSubject( KIO_Single_Subject* ); +}; + +#endif diff --git a/korn/tdeio_delete.cpp b/korn/tdeio_delete.cpp new file mode 100644 index 000000000..a73b0dd40 --- /dev/null +++ b/korn/tdeio_delete.cpp @@ -0,0 +1,201 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "kio_delete.h" + +#include "mailid.h" +#include "stringid.h" +#include "kio.h" +#include "kio_proto.h" + +#include +#include +#include +#include +#include +#include + +#include + +KIO_Delete::KIO_Delete( TQObject * parent, const char * name ) : TQObject( parent, name ), + _kio( 0 ), + _total( 0 ), + _jobs( 0 ), + _slave( 0 ), + _valid( true ) +{ + _jobs = new TQPtrList< TDEIO::Job >; +} + +KIO_Delete::~KIO_Delete( ) +{ + disConnect( ); + delete _jobs; +} + +bool KIO_Delete::deleteMails( TQPtrList< const KornMailId > * ids, KKioDrop *drop ) +{ + KURL kurl = *drop->_kurl; + TDEIO::MetaData metadata = *drop->_metadata; + + _kio = drop; + _valid = true; + + //disConnect earlier operations + disConnect( ); + if( _kio->_protocol->connectionBased( ) ) + { + if( ! setupSlave( kurl, metadata, _kio->_protocol ) ) + { + _valid = false; + return false; + } + } + + _total = ids->count( ); + + for( const KornMailId * item = ids->first(); item; item = ids->next() ) + deleteItem( item, kurl, metadata, _kio->_protocol ); + + if( _jobs->count() == 0 ) + { + _kio->emitDeleteMailsReady( true ); + disConnect( ); + return true; + } + + if( _kio->_protocol->commitDelete() ) + commitDelete( kurl, metadata, _kio->_protocol ); + + _kio->emitDeleteMailsTotalSteps( _total ); + + return true; +} + +void KIO_Delete::disConnect( ) +{ + _jobs->clear( ); + + if( _slave ) + { + TDEIO::Scheduler::disconnectSlave( _slave ); + _slave = 0; + } +} + +bool KIO_Delete::setupSlave( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) +{ + protocol->deleteMailConnectKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); + + if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) + { + kdWarning() << i18n( "Could not get a connected slave; I cannot delete this way..." ) << endl; + _valid = false; + return false; + } + + return true; +} + +void KIO_Delete::deleteItem( const KornMailId *item, KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) +{ + TDEIO::Job* job = 0; + + kurl = dynamic_cast( item )->getId(); + + protocol->deleteMailKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); + + if( protocol->deleteFunction() == KIO_Protocol::get ) + { + job = TDEIO::get( kurl, true, false ); + + if( protocol->connectionBased() ) + TDEIO::Scheduler::assignJobToSlave( _slave, dynamic_cast< TDEIO::SimpleJob* >( job ) ); + else + TDEIO::Scheduler::scheduleJob( dynamic_cast< TDEIO::SimpleJob* >( job ) ); + } + else if( protocol->deleteFunction() == KIO_Protocol::del ) + { + job = TDEIO::del( kurl, false, false ); + } + else + return; //Unknown deleteFunction + + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); + + job->addMetaData( metadata ); + + _jobs->append( dynamic_cast< TDEIO::Job* >( job ) ); +} + +/* + * Some protocols needs to a command to commit protocols. + */ +void KIO_Delete::commitDelete( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ) +{ + protocol->deleteCommitKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( protocol->defaultPort( _kio->_ssl ) ); + + TDEIO::TransferJob *job = TDEIO::get( kurl, true, false ); + job->addMetaData( metadata ); + connect( job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); + + _jobs->append( dynamic_cast< TDEIO::Job* >( job ) ); + + if( protocol->connectionBased() ) + TDEIO::Scheduler::assignJobToSlave( _slave, job ); + else + TDEIO::Scheduler::scheduleJob( job ); + + _total++; +} + +void KIO_Delete::canceled( ) +{ + disConnect( ); +} + +void KIO_Delete::slotResult( TDEIO::Job* job ) +{ + if( job->error() ) + { + kdWarning() << i18n( "An error occurred when deleting email: %1." ).arg( job->errorString() ) << endl; + _valid = false; + } + + _jobs->remove( job ); + + _kio->emitDeleteMailsProgress( _total - _jobs->count() ); + + if( _jobs->isEmpty() ) + { + _kio->emitDeleteMailsReady( _valid ); + disConnect(); + } +} + + +#include "kio_delete.moc" diff --git a/korn/tdeio_delete.h b/korn/tdeio_delete.h new file mode 100644 index 000000000..c084a58de --- /dev/null +++ b/korn/tdeio_delete.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIO_DELETE_H +#define MK_KIO_DELETE_H + +/* + * This class handles removing of selected messages. + * This class starts working when deleteMails() is called. + */ + +#include +class KKioDrop; +class KIO_Protocol; +class KornMailId; + +class KURL; +namespace TDEIO { class MetaData; class Job; class Slave; } + +template class TQPtrList; + +class KIO_Delete : public TQObject +{ Q_OBJECT + +public: + //constructors + KIO_Delete( TQObject * parent = 0, const char * name = 0 ); + ~KIO_Delete( ); + + //This function should be called if there are messages to be deleted. + bool deleteMails( TQPtrList< const KornMailId > *, KKioDrop* ); + + //This function should return false then and only then if an error occurred. + bool valid( ) { return _valid; } + +public slots: + //If this slot is called, the whole deletion is canceled. + void canceled( ); +private slots: + void slotResult( TDEIO::Job* ); + +private: + void disConnect( ); + bool setupSlave( KURL kurl, TDEIO::MetaData metadata, const KIO_Protocol *& protocol ); + void deleteItem( const KornMailId *item, KURL, TDEIO::MetaData, const KIO_Protocol *&); + void commitDelete( KURL, TDEIO::MetaData, const KIO_Protocol *& ); + + KKioDrop *_kio; + unsigned int _total; + TQPtrList< TDEIO::Job > *_jobs; + TDEIO::Slave *_slave; + bool _valid; +}; + +#endif //MK_KIO_DELETE_H diff --git a/korn/tdeio_proto.cpp b/korn/tdeio_proto.cpp new file mode 100644 index 000000000..e63a71666 --- /dev/null +++ b/korn/tdeio_proto.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include "kio_proto.h" + +#include +#include + +#include + +TQMap< TQString, TQString >* KIO_Protocol::createConfig( TDEConfigGroup * group, const TQString& password ) const +{ + TQMap< TQString, TQString > *result = new TQMap< TQString, TQString >; + + result->insert( "name", group->readEntry( "name", "" ) ); + result->insert( "server", group->readEntry( "server", "" ) ); + result->insert( "port", group->readEntry( "port", "" ) ); + result->insert( "username", group->readEntry( "username", "" ) ); + result->insert( "password", password ); + result->insert( "mailbox", group->readEntry( "mailbox", "" ) ); + result->insert( "savepassword", group->readEntry( "savepassword", "false" ) ); + result->insert( "ssl", group->readEntry( "ssl", "false" ) ); + result->insert( "metadata", group->readEntry( "metadata", "" ) ); + + return result; +} + +void KIO_Protocol::clearFields( TQMap *map, const KIO_Protocol::Fields fields ) const +{ + if( fields & server ) + map->insert( "server", "" ); + if( fields & port ) + map->insert( "port", "" ); + if( fields & username ) + map->insert( "username", "" ); + if( fields & password ) + map->insert( "password", "" ); + if( fields & mailbox ) + map->insert( "mailbox", "" ); + if( fields & save_password ) + map->insert( "savepassword", "" ); + if( fields & metadata ) + map->insert( "metadata", "" ); +} + +void KIO_Protocol::readEntries( TQMap< TQString, TQString >* map ) const +{ + TQMap< TQString, TQString> *metadata = new TQMap< TQString, TQString >; + + if( map->contains( "metadata" ) ) + { + TQStringList list = TQStringList::split( ",", *map->find( "metadata" ) ); + TQStringList::Iterator it; + for( it = list.begin(); it != list.end(); ++it ) + { + int split = (*it).find( '=' ); + + metadata->insert( (*it).left( split ), (*it).right( (*it).length() - split - 1 ) ); + } + } + + this->readEntries( map, metadata ); + + delete metadata; +} diff --git a/korn/tdeio_proto.h b/korn/tdeio_proto.h new file mode 100644 index 000000000..510e97d37 --- /dev/null +++ b/korn/tdeio_proto.h @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIO_PROTO_H +#define MK_KIO_PROTO_H + +/* + * KIO can handle multiple protocols. But some protocols have their own + * manipulations of KURL or MetaData , and some protocols could do more then other + * protocols. So, this class is the generic class of a class specified + * by a protocol. + */ + +class TQString; +#include +#include +#include +#include "protocol.h" + +#include "kio.h" + +class KIO_Protocol : public Protocol +{ +public: + /* + * Constuctor; empty + */ + KIO_Protocol() {} + + /* + * Destructor; empty too + */ + virtual ~KIO_Protocol() {} + + /* + * Public enumeration + */ + enum DeleteTypeEnum { get, del }; + /** + * This are the implementation of the Protocol-functions + */ + virtual const Protocol* getProtocol( TDEConfigGroup* ) const { return this; } + + virtual KMailDrop* createMaildrop( TDEConfigGroup* config ) const { return new KKioDrop( config ); } + + virtual TQMap< TQString, TQString >* createConfig( TDEConfigGroup *group, const TQString& password ) const; + + /* + * @return: the name of the kio_slave + */ + virtual TQString protocol( bool ) const { return "file"; } + + /* + * @return: the name of the protocol used by the configuration + */ + virtual TQString configName() const { return "not specified"; } + + virtual bool connectionBased() const { return false; } + + /* + * The next four functions return the [capebilities] of a protocol. + * fullMessage means that by downloaden, the whole message is downloaded. + * if it is false, only the headers should be downloaded. + */ + virtual bool canReadSubjects() const { return false; } + virtual bool canDeleteMail() const { return false; } + virtual bool canReadMail() const { return false; } + virtual bool fullMessage() const { return false; } + + /* + * The following lines are the options in the configuration; + * true means that an option is enabled; + * false means that the option is disabled. + */ + //virtual int fields() const { return server | port | username | password | mailbox; } + //virtual int urlFields() const { return no_fields; } + virtual unsigned short defaultPort( bool ) const { return 0; } + + /* + * This sets the string of such fields in Configuration + */ + virtual TQString serverName() const { return i18n( "Server:" ); } + virtual TQString portName() const { return i18n( "Port:" ); } + virtual TQString usernameName() const { return i18n( "Username:" ); } + virtual TQString mailboxName() const { return i18n( "Mailbox:" ); } + virtual TQString passwordName() const { return i18n( "Password:" ); } + virtual TQString savePasswordName() const { return i18n( "Save password" ); } + virtual TQString authName() const { return i18n( "Authentication:" ); } + + /* + * The next function returns the method of deleting: some protoocols + * like to delete files with TDEIO::get; other with TDEIO::del + */ + virtual DeleteTypeEnum deleteFunction() const { return del; } + + /* + * The next options are the input for the Authentication Combo, seperated by '|'. + * The name should be the same as the auth-metadata. + */ + virtual TQStringList authList() const { return TQStringList::split( '|', "Plain", false ); } + + /* + * The next functions are manipulations of an KURL. + * At some points in the code, a KURL is used. But sometimes, + * these have to had a little retouch. That is possible with these function. + * + * For example, by imap, by default, the whole message is downloaded and marked as reed. + * By changing an option to the KURL path, this can be prevented. + * + * The most functions are recognized by name. + * commitDelete return true if a protocol has to confirm a deletion. + * It will be called after marking the messages for deletion. + * deleteCommitKURL is the KURL manipulator; the KURL is as in the settings. + * That KURL isn't retouch by deleteMailKURL. + */ + virtual void recheckConnectKURL( KURL &, TDEIO::MetaData & ) const { } + virtual void recheckKURL ( KURL &, TDEIO::MetaData & ) const { }; + virtual void readSubjectConnectKURL ( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); } + virtual void readSubjectKURL ( KURL &, TDEIO::MetaData & ) const { } //For editing a kurl (adding extra options) + virtual void deleteMailConnectKURL( KURL & kurl, TDEIO::MetaData & ) const { kurl.setPath( "" ); } + virtual void deleteMailKURL ( KURL &, TDEIO::MetaData & ) const { } + virtual bool commitDelete() const { return false; } + virtual void deleteCommitKURL( KURL &, TDEIO::MetaData & ) const { } + virtual void readMailKURL ( KURL &, TDEIO::MetaData & ) const { } + + + virtual const KIO_Protocol* getKIOProtocol() const { return this; } + + virtual void readEntries( TQMap< TQString, TQString >* ) const; + virtual void readEntries( TQMap< TQString, TQString >*, TQMap< TQString, TQString >* ) const = 0; + +protected: + /* + * This enumeration is used when returning the capebilitys of a protocol + */ + enum Fields { no_fields = 0, server = 1, port = 2, username = 4, password = 8, + mailbox = 16, save_password = 32, metadata = 64 }; + + void clearFields( TQMap< TQString, TQString > *map, const Fields fields ) const; +}; + +#endif //MK_KIO_PROTO_H diff --git a/korn/tdeio_read.cpp b/korn/tdeio_read.cpp new file mode 100644 index 000000000..f98669d8d --- /dev/null +++ b/korn/tdeio_read.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "kio_read.h" + +#include "kio.h" +#include "kio_proto.h" +#include "mailid.h" +#include "stringid.h" + +#include +#include +#include +#include +#include +#include + +#include +#include + +KIO_Read::KIO_Read( TQObject * parent, const char * name ) + : TQObject( parent, name ), + _job( 0 ), + _message( 0 ) +{ + _message = new TQString; +} + +KIO_Read::~KIO_Read() +{ + delete _message; + delete _job; +} + +void KIO_Read::readMail( const KornMailId *& mailid, KKioDrop* drop ) +{ + _kio = drop; + KURL kurl = *_kio->_kurl; + TDEIO::MetaData metadata = *_kio->_metadata; + + kurl = dynamic_cast(mailid)->getId( ); + + _kio->_protocol->readMailKURL( kurl, metadata ); + + _job = TDEIO::get( kurl, false, false ); + _job->addMetaData( metadata ); + + connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); + connect( _job, TQT_SIGNAL( data( TDEIO::Job*, const TQByteArray& ) ), this, TQT_SLOT( slotData( TDEIO::Job*, const TQByteArray & ) ) ); +} + +void KIO_Read::canceled( ) +{ + if( _job ) + delete _job; + _job = 0; +} + +void KIO_Read::slotResult( TDEIO::Job* job ) +{ + if( job != _job ) + kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl; + + if( job->error() ) + kdWarning() << i18n( "An error occurred when fetching the requested email: %1." ).arg( job->errorString() ) << endl; + + _kio->emitReadMailReady( _message ); + + *_message = ""; + _job = 0; +} + +void KIO_Read::slotData( TDEIO::Job* job, const TQByteArray & data ) +{ + if( job != _job ) + kdWarning() << i18n( "Unknown job returned; I will try if this one will do... " ) << endl; + + if( !data.isEmpty() ) + _message->append( data ); +} + +#include "kio_read.moc" diff --git a/korn/tdeio_read.h b/korn/tdeio_read.h new file mode 100644 index 000000000..3b1ddec8e --- /dev/null +++ b/korn/tdeio_read.h @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIO_READ_H +#define MK_KIO_READ_H + +//This class should be used if someone wants to read the Full Message + +#include + +class KKioDrop; +class KornMailId; + +class KURL; +namespace TDEIO { class MetaData; class Job; } +class KIO_Protocol; + +class TQString; + +class KIO_Read : public TQObject +{ Q_OBJECT + +public: + KIO_Read( TQObject * parent = 0, const char * name = 0 ); + ~KIO_Read(); + +public slots: + //This is the function which makes the nessesairy slaves for reading a message + void readMail( const KornMailId *&, KKioDrop* ); + //This function should be called if the user presses canceled. + void canceled(); +private: + KKioDrop *_kio; + TDEIO::Job *_job; + TQString *_message; + +signals: + //This signal is emitted when the whole message is read; the message got passed as TQString* + void ready( TQString* ); + +private slots: + void slotResult( TDEIO::Job* ); + void slotData( TDEIO::Job*, const TQByteArray& ); +}; + +#endif //MK_KIO_READ_H diff --git a/korn/tdeio_single_subject.cpp b/korn/tdeio_single_subject.cpp new file mode 100644 index 000000000..0c20b1ab4 --- /dev/null +++ b/korn/tdeio_single_subject.cpp @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "kio_single_subject.h" + +#include "mailsubject.h" +#include "kio_proto.h" +#include "stringid.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +KIO_Single_Subject::KIO_Single_Subject( TQObject * parent, const char * name, + KURL &kurl, TDEIO::MetaData &metadata, const KIO_Protocol * protocol, TDEIO::Slave *& slave, + const TQString &url, const long size ) + : TQObject( parent, name ) +{ + _kurl = new KURL( kurl ); + _metadata = new TDEIO::MetaData( metadata ); + _protocol = protocol; + _name = new TQString( url ); + _size = size; + _message = new TQString; + + init( slave ); +} + +KIO_Single_Subject::~KIO_Single_Subject( ) +{ + if( _job ) + TDEIO::Scheduler::cancelJob( _job ); + delete _kurl; + delete _metadata; + delete _name; + delete _message; +} + +void KIO_Single_Subject::init( TDEIO::Slave *& slave) +{ + _job = TDEIO::get( *_kurl, false, false ); + _job->addMetaData( *_metadata ); + + connect( _job, TQT_SIGNAL( result( TDEIO::Job* ) ), this, TQT_SLOT( slotResult( TDEIO::Job* ) ) ); + connect( _job, TQT_SIGNAL( data (TDEIO::Job *, const TQByteArray &) ), + this, TQT_SLOT( slotData(TDEIO::Job *, const TQByteArray &) ) ); + + if( _protocol->connectionBased( ) && slave ) + TDEIO::Scheduler::assignJobToSlave( slave , _job ); + else + TDEIO::Scheduler::scheduleJob( _job ); + +} + +void KIO_Single_Subject::parseMail( TQString * message, KornMailSubject *subject, bool fullMessage ) +{ + TQTextStream stream( message, IO_ReadOnly ); + TQString line; + TQRegExp rx_sender( "^[fF]rom: " ); //Ex: From: ... + TQRegExp rx_sender_has_name1( "^[fF]rom:\\s*(\\w+[\\w\\s]*)\\<" ); //Ex: From: A name + TQRegExp rx_sender_has_name2( "^[fF]rom:\\s*\\\"\\s*(\\w+[\\w\\s]*)\\\""); //Ex: From: "A name" + TQRegExp rx_subject( "^[sS]ubject: " ); //Ex: Subject: ... + TQRegExp rx_date ( "^[dD]ate: "); + bool inheader = true; + int fieldnumber = 0; + + while ( ! stream.atEnd() ) + { + line = stream.readLine(); + if( line.isEmpty() && fieldnumber >= 2 ) + inheader = false; + + if( inheader ) + { + if( rx_sender.search( line ) == 0 ) + { + if( rx_sender_has_name1.search( line ) == 0 ) + subject->setSender( rx_sender_has_name1.cap( 1 ) ); + else if(rx_sender_has_name2.search( line ) == 0) + subject->setSender( rx_sender_has_name2.cap( 1 ) ); + else + subject->setSender( line.remove( rx_sender ) ); + ++fieldnumber; + } + else if( rx_subject.search( line ) == 0 ) + { + subject->setSubject( line.remove( rx_subject ) ); + ++fieldnumber; + } + else if( rx_date.search( line ) == 0 ) + { + subject->setDate( KRFCDate::parseDate( line.right( line.length() - 6 ) ) ); + ++fieldnumber; + } + } + } + + subject->setHeader( *message, fullMessage ); +} + +void KIO_Single_Subject::slotData( TDEIO::Job* job, const TQByteArray& data ) +{ + if( job != _job ) + kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl; + if( !data.isEmpty() ) + _message->append( data ); +} + +//TDEIO::Scheduler::disconnectSlave missing if connection stops +void KIO_Single_Subject::slotResult( TDEIO::Job *job ) +{ + if( job != _job ) + kdWarning() << i18n( "Got invalid job; something strange happened?" ) << endl; + + if( job->error() ) + { + kdWarning() << i18n( "Error when fetching %1: %2" ).arg( *_name ).arg( job->errorString() ) << endl; + } else { + KornMailSubject * mailSubject = new KornMailSubject( new KornStringId( *_name ), 0 ); + parseMail( _message, mailSubject, _protocol->fullMessage() ); + mailSubject->decodeHeaders(); + mailSubject->setSize( _size ); + emit readSubject( mailSubject ); + } + + _job = 0; + + emit finished( this ); +} + +#include "kio_single_subject.moc" diff --git a/korn/tdeio_single_subject.h b/korn/tdeio_single_subject.h new file mode 100644 index 000000000..9aac8baae --- /dev/null +++ b/korn/tdeio_single_subject.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIO_SINGEL_SUBJECT_H +#define MK_KIO_SINGEL_SUBJECT_H + +//This function reads a single subject + +#include +#include + +class KornMailSubject; + +class KURL; +namespace TDEIO { class MetaData; class Job; class TransferJob; class Slave; } +class KIO_Protocol; + +class TQString; + +class KIO_Single_Subject : public TQObject +{ Q_OBJECT + +public: + KIO_Single_Subject( TQObject * parent, const char * name, KURL &, TDEIO::MetaData &, const KIO_Protocol *, + TDEIO::Slave *&, const TQString &, const long ); + ~KIO_Single_Subject( ); + + //This functions try's te parse EMail; data, sender names and so on... + static void parseMail( TQString * message, KornMailSubject *subject, bool ); + +private: + TQString *_message; + TQString *_name; + KURL *_kurl; + const KIO_Protocol *_protocol; + TDEIO::MetaData *_metadata; + TDEIO::TransferJob* _job; + long _size; + + void init( TDEIO::Slave*& ); + +private slots: + void slotResult( TDEIO::Job* ); + void slotData( TDEIO::Job*, const TQByteArray& ); + +signals: + //This signal is emitted if the headers are read and put into a KornMailSubject* + void readSubject( KornMailSubject* ); + //This signal is emitted if this class could be destroyed. + void finished( KIO_Single_Subject* ); +}; + +#endif diff --git a/korn/tdeio_subjects.cpp b/korn/tdeio_subjects.cpp new file mode 100644 index 000000000..f40a86f64 --- /dev/null +++ b/korn/tdeio_subjects.cpp @@ -0,0 +1,176 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "kio_subjects.h" + +#include "kio.h" +#include "kio_single_subject.h" +#include "kio_proto.h" +#include "mailsubject.h" + +#include +#include +#include + +#include +#include +#include + +KIO_Subjects::KIO_Subjects( TQObject * parent, const char * name ) + : TQObject( parent, name ), + _protocol( 0 ), + _slave( 0 ), + _valid( true ) +{ + _jobs = new TQPtrList; + _kurl = new KURL; + _metadata = new TDEIO::MetaData; + + _jobs->setAutoDelete( true ); +} + +KIO_Subjects::~KIO_Subjects( ) +{ + delete _jobs; + delete _kurl; + delete _metadata; + _protocol = 0; +} + +void KIO_Subjects::doReadSubjects( KKioDrop *drop ) +{ + TQValueList::ConstIterator it; + TQValueList::ConstIterator end_it = drop->_mailurls->end(); + + _kio = drop; + _protocol = _kio->_protocol; + *_kurl = *_kio->_kurl; + *_metadata = *_kio->_metadata; + + if( _jobs->count() > 0 ) + kdWarning() << i18n( "Already a slave pending." ) << endl; + + _jobs->clear( ); + + //Open connection + getConnection( ); + + //Open jobs for easy item in the list + for( it = _kio->_mailurls->begin(); it != end_it; it++ ) + startJob( (*it).name, (*it).size ); + + //close connection for trivial situations (empty list) + disConnect( true ); + + //passing number of subjects for progress bar. + _kio->emitReadSubjectsTotalSteps( _jobs->count() ); +} + +void KIO_Subjects::getConnection( ) +{ + KURL kurl = *_kurl; + TDEIO::MetaData metadata = *_metadata; + + if( _slave ) + { + TDEIO::Scheduler::disconnectSlave( _slave ); + _slave = 0; + } + + if( _protocol->connectionBased( ) ) + { + _protocol->readSubjectConnectKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); + + if( ! ( _slave = TDEIO::Scheduler::getConnectedSlave( kurl, metadata ) ) ) + { + kdWarning() << i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() ); + _kio->emitShowPassivePopup( i18n( "Not able to open a kio-slave for %1." ).arg( _protocol->configName() ) ); + _valid = false; + _kio->emitValidChanged(); + _slave = 0; + _kio->emitReadSubjectsReady( false ); + return; + } + } +} + +void KIO_Subjects::startJob( const TQString &name, const long size ) +{ + KURL kurl = *_kurl; + TDEIO::MetaData metadata = *_metadata; + KIO_Single_Subject *subject; + + kurl = name; + + _protocol->readSubjectKURL( kurl, metadata ); + + if( kurl.port() == 0 ) + kurl.setPort( _protocol->defaultPort( _kio->_ssl ) ); + + subject = new KIO_Single_Subject( this, name.latin1(), kurl, metadata, _protocol, _slave, name, size ); + + connect( subject, TQT_SIGNAL( readSubject( KornMailSubject* ) ), this, TQT_SLOT( slotReadSubject( KornMailSubject* ) ) ); + connect( subject, TQT_SIGNAL( finished( KIO_Single_Subject* ) ), this, TQT_SLOT( slotFinished( KIO_Single_Subject* ) ) ); + + _jobs->append( subject ); +} + +void KIO_Subjects::disConnect( bool result ) +{ + if( _jobs->isEmpty() ) + { + if( _slave ) + { + TDEIO::Scheduler::disconnectSlave( _slave ); + _slave = 0; + } + _kio->emitReadSubjectsReady( result ); + } +} + +void KIO_Subjects::cancelled( ) +{ + _jobs->clear(); + //_slave died in cancelJob with is by called from the destructor of KIO_Single_Subject, + //withs is by called by _jobs->clear because autoRemove equals true. + _slave = 0; + disConnect( false ); +} + +void KIO_Subjects::slotReadSubject( KornMailSubject* subject ) +{ + _valid = true; + _kio->emitValidChanged(); + subject->setMailDrop( _kio ); + _kio->emitReadSubjectsRead( subject ); +} + +void KIO_Subjects::slotFinished( KIO_Single_Subject* item ) +{ + //Remove sender.... I didn't know of the computer gonna like me, but it seems he does :) + _jobs->remove( item ); + + _kio->emitReadSubjectsProgress( _jobs->count( ) ); + + disConnect( true ); //Only works when all jobs are finished. +} + +#include "kio_subjects.moc" diff --git a/korn/tdeio_subjects.h b/korn/tdeio_subjects.h new file mode 100644 index 000000000..018369de6 --- /dev/null +++ b/korn/tdeio_subjects.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2004, Mart Kelder (mart.kde@hccnet.nl) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef MK_KIO_SUBJECTS_H +#define MK_KIO_SUBJECTS_H + +//This class calls other class to read all the subjects + +#include +class KKioDrop; +class KIO_Single_Subject; +class KIO_Protocol; +class KornMailSubject; + +namespace TDEIO { class MetaData; class Slave; } +class KURL; + +template class TQPtrList; +class TQString; +template class TQValueList; + +class KIO_Subjects : public TQObject +{ Q_OBJECT + +public: + KIO_Subjects( TQObject * parent, const char * name ); + ~KIO_Subjects( ); + + //This function let it start fetching headers. + void doReadSubjects( KKioDrop* ); + + //This function should return true then and only then of no error occurred. + bool valid( ) { return _valid; } + +private: + KKioDrop *_kio; + KURL *_kurl; + TDEIO::MetaData *_metadata; + const KIO_Protocol *_protocol; + TQPtrList *_jobs; + TDEIO::Slave *_slave; + bool _valid; + + //Opens a connection. + void getConnection( ); + //Start a job; the job itself is executed in KIO_Single_Subject + void startJob( const TQString&, const long ); + //Disconnect the connection + void disConnect( bool ); + +public slots: + //This function called the fetching of headers. + void cancelled( ); + +private slots: + void slotReadSubject( KornMailSubject* ); + void slotFinished( KIO_Single_Subject* ); +}; + +#endif diff --git a/libtdepim/csshelper.cpp b/libtdepim/csshelper.cpp index d2180e1a2..d3c648096 100644 --- a/libtdepim/csshelper.cpp +++ b/libtdepim/csshelper.cpp @@ -509,7 +509,7 @@ namespace KPIM { " padding: 0px ! important;\n" " font-size:0.8em ! important;\n" " border:1px solid %6 ! important;\n" - // FIXME: InfoBackground crashes KHTML + // FIXME: InfoBackground crashes TDEHTML //" background-color:InfoBackground ! important;\n" " background-color:%5 ! important;\n" "}\n\n" -- cgit v1.2.1