From c2bb8c935c0b5c921be31d9c51f0d431129523b2 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 10 Feb 2013 01:39:19 -0600 Subject: Rename kiosvn --- src/CMakeLists.txt | 4 +- src/kiosvn/CMakeLists.txt | 28 -- src/kiosvn/kiobytestream.cpp | 63 --- src/kiosvn/kiobytestream.h | 66 --- src/kiosvn/kiolistener.cpp | 408 ----------------- src/kiosvn/kiolistener.h | 83 ---- src/kiosvn/kiosvn.cpp | 954 --------------------------------------- src/kiosvn/kiosvn.h | 120 ----- src/kiosvn/ksvn+file.protocol | 39 -- src/kiosvn/ksvn+http.protocol | 39 -- src/kiosvn/ksvn+https.protocol | 39 -- src/kiosvn/ksvn+ssh.protocol | 39 -- src/kiosvn/ksvn.protocol | 39 -- src/kiosvn/svn+file.protocol | 39 -- src/kiosvn/svn+http.protocol | 39 -- src/kiosvn/svn+https.protocol | 39 -- src/kiosvn/svn+ssh.protocol | 39 -- src/kiosvn/svn.protocol | 39 -- src/tdeiosvn/CMakeLists.txt | 28 ++ src/tdeiosvn/kiobytestream.cpp | 63 +++ src/tdeiosvn/kiobytestream.h | 66 +++ src/tdeiosvn/kiolistener.cpp | 408 +++++++++++++++++ src/tdeiosvn/kiolistener.h | 83 ++++ src/tdeiosvn/ksvn+file.protocol | 39 ++ src/tdeiosvn/ksvn+http.protocol | 39 ++ src/tdeiosvn/ksvn+https.protocol | 39 ++ src/tdeiosvn/ksvn+ssh.protocol | 39 ++ src/tdeiosvn/ksvn.protocol | 39 ++ src/tdeiosvn/svn+file.protocol | 39 ++ src/tdeiosvn/svn+http.protocol | 39 ++ src/tdeiosvn/svn+https.protocol | 39 ++ src/tdeiosvn/svn+ssh.protocol | 39 ++ src/tdeiosvn/svn.protocol | 39 ++ src/tdeiosvn/tdeiosvn.cpp | 954 +++++++++++++++++++++++++++++++++++++++ src/tdeiosvn/tdeiosvn.h | 120 +++++ 35 files changed, 2114 insertions(+), 2114 deletions(-) delete mode 100644 src/kiosvn/CMakeLists.txt delete mode 100644 src/kiosvn/kiobytestream.cpp delete mode 100644 src/kiosvn/kiobytestream.h delete mode 100644 src/kiosvn/kiolistener.cpp delete mode 100644 src/kiosvn/kiolistener.h delete mode 100644 src/kiosvn/kiosvn.cpp delete mode 100644 src/kiosvn/kiosvn.h delete mode 100644 src/kiosvn/ksvn+file.protocol delete mode 100644 src/kiosvn/ksvn+http.protocol delete mode 100644 src/kiosvn/ksvn+https.protocol delete mode 100644 src/kiosvn/ksvn+ssh.protocol delete mode 100644 src/kiosvn/ksvn.protocol delete mode 100644 src/kiosvn/svn+file.protocol delete mode 100644 src/kiosvn/svn+http.protocol delete mode 100644 src/kiosvn/svn+https.protocol delete mode 100644 src/kiosvn/svn+ssh.protocol delete mode 100644 src/kiosvn/svn.protocol create mode 100644 src/tdeiosvn/CMakeLists.txt create mode 100644 src/tdeiosvn/kiobytestream.cpp create mode 100644 src/tdeiosvn/kiobytestream.h create mode 100644 src/tdeiosvn/kiolistener.cpp create mode 100644 src/tdeiosvn/kiolistener.h create mode 100644 src/tdeiosvn/ksvn+file.protocol create mode 100644 src/tdeiosvn/ksvn+http.protocol create mode 100644 src/tdeiosvn/ksvn+https.protocol create mode 100644 src/tdeiosvn/ksvn+ssh.protocol create mode 100644 src/tdeiosvn/ksvn.protocol create mode 100644 src/tdeiosvn/svn+file.protocol create mode 100644 src/tdeiosvn/svn+http.protocol create mode 100644 src/tdeiosvn/svn+https.protocol create mode 100644 src/tdeiosvn/svn+ssh.protocol create mode 100644 src/tdeiosvn/svn.protocol create mode 100644 src/tdeiosvn/tdeiosvn.cpp create mode 100644 src/tdeiosvn/tdeiosvn.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c572c1..30ba625 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -208,7 +208,7 @@ ADD_DEPENDENCIES(ksvnwidgets-shared tdesvnhelpers-shared) ##### tdeio_ksvn ################################## tde_add_kpart( tdeio_ksvn AUTOMOC - SOURCES kiosvn/tdeiosvn.cpp kiosvn/tdeiolistener.cpp kiosvn/tdeiobytestream.cpp ksvnwidgets/pwstorage.cpp + SOURCES tdeiosvn/tdeiosvn.cpp tdeiosvn/tdeiolistener.cpp tdeiosvn/tdeiobytestream.cpp ksvnwidgets/pwstorage.cpp LINK svnqt tdesvnhelpers tdesvncfgreader tdecore-shared tdeui-shared DCOP-shared tdeio-shared DESTINATION ${PLUGIN_INSTALL_DIR} ) @@ -247,6 +247,6 @@ add_subdirectory( settings ) add_subdirectory( svnfrontend ) add_subdirectory( helpers ) add_subdirectory( tdesvnd ) -add_subdirectory( kiosvn ) +add_subdirectory( tdeiosvn ) add_subdirectory( pics ) add_subdirectory( icons ) diff --git a/src/kiosvn/CMakeLists.txt b/src/kiosvn/CMakeLists.txt deleted file mode 100644 index cb84de5..0000000 --- a/src/kiosvn/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -################################################# -# -# (C) 2011 Timothy Pearson -# kb9vqf (AT) pearsoncomputing.net -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -include_directories( - ${TQT_INCLUDE_DIRS} - ${TDE_INCLUDE_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src - ${CMAKE_SOURCE_DIR}/src -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - - -##### protocol files ############################ - -file( GLOB PROTFILES *.protocol ) -install( FILES ${PROTFILES} DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/src/kiosvn/kiobytestream.cpp b/src/kiosvn/kiobytestream.cpp deleted file mode 100644 index 81c6fc8..0000000 --- a/src/kiosvn/kiobytestream.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 "kiobytestream.h" - -KioByteStream::KioByteStream(StreamWrittenCb*aCb,const TQString&filename) - : svn::stream::SvnStream(false,true,0L), - m_Cb(aCb),m_Written(0), - m_mimeSend(false),m_Filename(filename) -{ - m_MessageTick.start(); -} - -KioByteStream::~KioByteStream() -{ -} - -bool KioByteStream::isOk() const -{ - return m_Cb != 0; -} - -long KioByteStream::write(const char* data, const unsigned long max) -{ - bool forceInfo = !m_mimeSend; - if (m_Cb) { - if (!m_mimeSend) { - m_mimeSend = true; - array.setRawData(data, max); - KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType(array,m_Filename); - m_Cb->streamSendMime(result); - array.resetRawData(data, max); - m_Cb->streamTotalSizeNull(); - } - array.setRawData(data, max); - m_Cb->streamPushData(array); - array.resetRawData(data, max); - - m_Written+=max; - if (m_MessageTick.elapsed() >=100 || forceInfo) { - m_Cb->streamWritten(m_Written); - m_MessageTick.restart(); - } - return max; - } - return -1; -} diff --git a/src/kiosvn/kiobytestream.h b/src/kiosvn/kiobytestream.h deleted file mode 100644 index 48addfe..0000000 --- a/src/kiosvn/kiobytestream.h +++ /dev/null @@ -1,66 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2006-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 KIOBYTESTREAM_H -#define KIOBYTESTREAM_H - -#include "svnstream.hpp" - -#include -#include -#include -#include -#include - -class StreamWrittenCb -{ -public: - StreamWrittenCb(){} - virtual ~StreamWrittenCb(){} - virtual void streamWritten(const TDEIO::filesize_t current) = 0; - virtual void streamPushData(TQByteArray)=0; - virtual void streamSendMime(KMimeMagicResult*mt)=0; - virtual void streamTotalSizeNull()=0; -}; - -/** - @author Rajko Albrecht -*/ -class KioByteStream : public svn::stream::SvnStream -{ -public: - KioByteStream(StreamWrittenCb*,const TQString&filename); - - ~KioByteStream(); - - virtual bool isOk() const; - virtual long write(const char* data, const unsigned long max); - - TDEIO::filesize_t written(){return m_Written;} - -protected: - StreamWrittenCb*m_Cb; - TDEIO::filesize_t m_Written; - bool m_mimeSend; - TQString m_Filename; - TQByteArray array; - TQTime m_MessageTick; -}; - -#endif diff --git a/src/kiosvn/kiolistener.cpp b/src/kiosvn/kiolistener.cpp deleted file mode 100644 index 19c63a7..0000000 --- a/src/kiosvn/kiolistener.cpp +++ /dev/null @@ -1,408 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 "kiolistener.h" -#include "kiosvn.h" - -#include -#include -#include - -namespace TDEIO { - -KioListener::KioListener(TDEIO::tdeio_svnProtocol*_par) - : svn::ContextListener(),m_notifyCounter(0),m_External(false),m_HasChanges(false),m_FirstTxDelta(false),m_Canceld(false) -{ - par = _par; -} - - -KioListener::~KioListener() -{ -} - - - - -/*! - \fn KioListener::contextCancel() - */ -bool KioListener::contextCancel() -{ - return par->wasKilled()||m_Canceld; -} - - -/*! - \fn KioListener::contextGetLogMessage (TQString & msg) - */ -bool KioListener::contextGetLogMessage (TQString & msg,const svn::CommitItemList&_items) -{ -#if 1 - TQByteArray reply; - TQByteArray params; - TQCString replyType; - TQDataStream stream(params,IO_WriteOnly); - - if (_items.count()>0) { - TQMap list; - for (unsigned i = 0;i<_items.count();++i) { - if (_items[i].path().isEmpty()) { - list[_items[i].url()]=TQChar(_items[i].actionType()); - } else { - list[_items[i].path()]=TQChar(_items[i].actionType()); - } - } - stream << list; - if (!par->dcopClient()->call("kded","tdesvnd","get_logmsg(TQMap)",params,replyType,reply)) { - msg = "Communication with dcop failed"; - kdWarning()<dcopClient()->call("kded","tdesvnd","get_logmsg()",params,replyType,reply)) { - msg = "Communication with dcop failed"; - kdWarning()<>lt; - if (lt.count()!=1) { - msg = "Wrong or missing log (may cancel pressed)."; - kdDebug()<< msg << endl; - return false; - } - msg = lt[0]; -#else - msg = "Made with a kio::svn client"; -#endif - return true; -} - -/*! the content of that method is taken from the notify in kio::svn in KDE SDK */ -/* this moment we don't use it full 'cause not all is made via KIO */ -void KioListener::contextNotify (const char * path,svn_wc_notify_action_t action,svn_node_kind_t kind ,const char * mime_type ,svn_wc_notify_state_t content_state, svn_wc_notify_state_t prop_state,svn_revnum_t revision) -{ - if (par->wasKilled()) { - return; - } - TQString userstring; - - switch(action) { - case svn_wc_notify_add: - { - if (mime_type && (svn_mime_type_is_binary (mime_type))) - userstring = i18n( "A (bin) %1" ).arg( path ); - else - userstring = i18n( "A %1" ).arg( path ); - break; - } - break; - case svn_wc_notify_copy: //copy - break; - case svn_wc_notify_delete: //delete - m_HasChanges = TRUE; - userstring = i18n( "D %1" ).arg( path ); - break; - case svn_wc_notify_restore : //restore - userstring=i18n( "Restored %1." ).arg( path ); - break; - case svn_wc_notify_revert : //revert - userstring=i18n( "Reverted %1." ).arg( path ); - break; - case svn_wc_notify_failed_revert: //failed revert - userstring=i18n( "Failed to revert %1.\nTry updating instead." ).arg( path ); - break; - case svn_wc_notify_resolved: //resolved - userstring=i18n( "Resolved conflicted state of %1." ).arg( path ); - break; - case svn_wc_notify_skip: //skip - if ( content_state == svn_wc_notify_state_missing ) - userstring=i18n("Skipped missing target %1.").arg( path ); - else - userstring=i18n("Skipped %1.").arg( path ); - break; - case svn_wc_notify_update_delete: //update_delete - m_HasChanges = TRUE; - userstring=i18n( "D %1" ).arg( path ); - break; - case svn_wc_notify_update_add: //update_add - m_HasChanges = TRUE; - userstring=i18n( "A %1" ).arg( path ); - break; - case svn_wc_notify_update_update: //update_update - { - /* If this is an inoperative dir change, do no notification. - An inoperative dir change is when a directory gets closed - without any props having been changed. */ - if (! ((kind == svn_node_dir) - && ((prop_state == svn_wc_notify_state_inapplicable) - || (prop_state == svn_wc_notify_state_unknown) - || (prop_state == svn_wc_notify_state_unchanged)))) { - m_HasChanges = TRUE; - - if (kind == svn_node_file) { - if (content_state == svn_wc_notify_state_conflicted) - userstring = "C"; - else if (content_state == svn_wc_notify_state_merged) - userstring = "G"; - else if (content_state == svn_wc_notify_state_changed) - userstring = "U"; - } - - if (prop_state == svn_wc_notify_state_conflicted) - userstring += "C"; - else if (prop_state == svn_wc_notify_state_merged) - userstring += "G"; - else if (prop_state == svn_wc_notify_state_changed) - userstring += "U"; - else - userstring += " "; - - if (! ((content_state == svn_wc_notify_state_unchanged - || content_state == svn_wc_notify_state_unknown) - && (prop_state == svn_wc_notify_state_unchanged - || prop_state == svn_wc_notify_state_unknown))) - userstring += TQString( " " ) + path; - } - break; - } - case svn_wc_notify_update_completed: //update_completed - { - if (!m_External) { - if (SVN_IS_VALID_REVNUM(revision)) { - userstring = i18n("Finished at revision %1.").arg(revision); - } else { - userstring = i18n("Finished."); - } - } else { - if (SVN_IS_VALID_REVNUM(revision)) { - userstring = i18n("Finished external at revision %1.").arg(revision); - } else { - userstring = i18n("Finished external."); - } - } - } - if (m_External) - m_External = FALSE; - break; - case svn_wc_notify_update_external: //update_external - m_External = TRUE; - userstring = i18n("Fetching external item into %1." ).arg( path ); - break; - case svn_wc_notify_status_completed: //status_completed - if (SVN_IS_VALID_REVNUM (revision)) - userstring = i18n( "Status against revision: %1.").arg( revision ); - break; - case svn_wc_notify_status_external: //status_external - userstring = i18n("Performing status on external item at %1.").arg( path ); - break; - case svn_wc_notify_commit_modified: //commit_modified - userstring = i18n( "Sending %1.").arg( path ); - break; - case svn_wc_notify_commit_added: //commit_added - if (mime_type && svn_mime_type_is_binary (mime_type)) { - userstring = i18n( "Adding (bin) %1.").arg( path ); - } else { - userstring = i18n( "Adding %1.").arg( path ); - } - break; - case svn_wc_notify_commit_deleted: //commit_deleted - userstring = i18n( "Deleting %1.").arg( path ); - break; - case svn_wc_notify_commit_replaced: //commit_replaced - userstring = i18n( "Replacing %1.").arg( path ); - break; - case svn_wc_notify_commit_postfix_txdelta: //commit_postfix_txdelta - if (!m_FirstTxDelta) { - m_FirstTxDelta = TRUE; - // check fullstops! - userstring=i18n("Transmitting file data "); - } else { - userstring="."; - } - break; - - break; - case svn_wc_notify_blame_revision: //blame_revision - break; - default: - break; - } - par->setMetaData(TQString::number(counter()).rightJustify( 10,'0' )+ "path" , TQString::FROMUTF8( path )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "action", TQString::number( action )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "kind", TQString::number( kind )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "mime_t", TQString::FROMUTF8( mime_type )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "content", TQString::number( content_state )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "prop", TQString::number( prop_state )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "rev", TQString::number( revision )); - par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "string", userstring ); - incCounter(); -} - -void KioListener::contextNotify (const svn_wc_notify_t *action) -{ - if (!action) return; -// if (action->actionpath,action->action,action->kind,action->mime_type, - action->content_state,action->prop_state,action->revision); -// return; -// } -// TQString aString = NotifyAction(action->action); -} - -svn::ContextListener::SslServerTrustAnswer -KioListener::contextSslServerTrustPrompt (const SslServerTrustData & data, apr_uint32_t & acceptedFailures) -{ - TQByteArray reply; - TQByteArray params; - TQCString replyType; - TQDataStream stream(params,IO_WriteOnly); - stream << data.hostname - << data.fingerprint - << data.validFrom - << data.validUntil - << data.issuerDName - << data.realm; - - if (!par->dcopClient()->call("kded","tdesvnd", - "get_sslaccept(TQString,TQString,TQString,TQString,TQString,TQString)", - params,replyType,reply)) { - kdWarning()<<"Communication with dcop failed"<>res; - switch (res) { - case -1: - return DONT_ACCEPT; - break; - case 1: - return ACCEPT_PERMANENTLY; - break; - default: - case 0: - return ACCEPT_TEMPORARILY; - break; - } - /* avoid compiler warnings */ - return ACCEPT_TEMPORARILY; -} - -bool KioListener::contextLoadSslClientCertPw(TQString&password,const TQString&realm) -{ - return PwStorage::self()->getCertPw(realm,password); -} - -bool KioListener::contextSslClientCertPrompt (TQString & certFile) -{ - TQByteArray reply; - TQByteArray params; - TQCString replyType; - if (!par->dcopClient()->call("kded","tdesvnd", - "get_sslclientcertfile()", - params,replyType,reply)) { - kdWarning()<<"Communication with dcop failed"<>certFile; - if (certFile.isEmpty()) { - return false; - } - return true; -} - -bool KioListener::contextSslClientCertPwPrompt (TQString & password, - const TQString & realm, bool & maySave) -{ - return false; -} - -bool KioListener::contextGetSavedLogin (const TQString & realm,TQString & username,TQString & password) -{ - PwStorage::self()->getLogin(realm,username,password); - return true; -} - -bool KioListener::contextGetCachedLogin (const TQString & realm,TQString & username,TQString & password) -{ - return true; -} - -bool KioListener::contextGetLogin (const TQString & realm, TQString & username, TQString & password, bool & maySave) -{ - TQByteArray reply; - TQByteArray params; - TQCString replyType; - - TQDataStream stream(params,IO_WriteOnly); - stream << realm; - stream << username; - - if (!par->dcopClient()->call("kded","tdesvnd","get_login(TQString,TQString)",params,replyType,reply)) { - kdWarning()<<"Communication with dcop failed"<>lt; - if (lt.count()!=3) { - kdDebug()<<"Wrong or missing auth list (may cancel pressed)." << endl; - return false; - } - username = lt[0]; - password = lt[1]; - maySave = lt[2]=="true"; - return true; -} - - -/*! - \fn KioListener::contextProgress(long long int current, long long int max) - */ -void KioListener::contextProgress(long long int cur, long long int max) -{ - if (par) { - par->contextProgress(cur,max); - } -} - -} // namespace TDEIO diff --git a/src/kiosvn/kiolistener.h b/src/kiosvn/kiolistener.h deleted file mode 100644 index f836b65..0000000 --- a/src/kiosvn/kiolistener.h +++ /dev/null @@ -1,83 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 KIOLISTENER_H -#define KIOLISTENER_H - -#include "context_listener.hpp" -#include "pwstorage.h" - -namespace TDEIO { - class SlaveBase; - class tdeio_svnProtocol; - -/** -@author Rajko Albrecht -*/ -class KioListener : public svn::ContextListener -{ -public: - KioListener(TDEIO::tdeio_svnProtocol*_par); - virtual ~KioListener(); - - /* context-listener methods */ - virtual bool contextGetLogin (const TQString & realm, - TQString & username, - TQString & password, - bool & maySave); - virtual bool contextGetSavedLogin (const TQString & realm,TQString & username,TQString & password); - virtual bool contextGetCachedLogin (const TQString & realm,TQString & username,TQString & password); - - virtual void contextNotify (const char *path, - svn_wc_notify_action_t action, - svn_node_kind_t kind, - const char *mime_type, - svn_wc_notify_state_t content_state, - svn_wc_notify_state_t prop_state, - svn_revnum_t revision); - virtual void contextNotify (const svn_wc_notify_t *action); - - virtual bool contextCancel(); - virtual bool contextGetLogMessage (TQString & msg,const svn::CommitItemList&); - virtual SslServerTrustAnswer contextSslServerTrustPrompt (const SslServerTrustData & data, - apr_uint32_t & acceptedFailures); - virtual bool contextSslClientCertPrompt (TQString & certFile); - virtual bool contextSslClientCertPwPrompt (TQString & password, - const TQString & realm, bool & maySave); - virtual bool contextLoadSslClientCertPw(TQString&password,const TQString&realm); - /* context listener virtuals end */ - unsigned int counter()const{return m_notifyCounter;} - void incCounter(){++m_notifyCounter;} - virtual void contextProgress(long long int current, long long int max); - - void setCancel(bool value){m_Canceld=value;} - -private: - TDEIO::tdeio_svnProtocol *par; - -protected: - unsigned int m_notifyCounter; - bool m_External; - bool m_HasChanges; - bool m_FirstTxDelta; - bool m_Canceld; -}; -} - -#endif diff --git a/src/kiosvn/kiosvn.cpp b/src/kiosvn/kiosvn.cpp deleted file mode 100644 index 2d8365c..0000000 --- a/src/kiosvn/kiosvn.cpp +++ /dev/null @@ -1,954 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 "tdesvn-config.h" -#include "kiosvn.h" -#include "kiolistener.h" - -#include "svnqttypes.hpp" -#include "dirent.hpp" -#include "url.hpp" -#include "status.hpp" -#include "targets.hpp" -#include "info_entry.hpp" -#include "tdesvnsettings.h" -#include "sub2qt.h" -#include "sshagent.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace TDEIO -{ - -class KioSvnData -{ -public: - KioSvnData(tdeio_svnProtocol*); - virtual ~KioSvnData(); - - void reInitClient(); - - KioListener m_Listener; - bool first_done; - bool dispProgress; - svn::ContextP m_CurrentContext; - svn::Client* m_Svnclient; - - svn::Revision urlToRev(const KURL&); - -}; - -KioSvnData::KioSvnData(tdeio_svnProtocol*par) - : m_Listener(par),first_done(false) -{ - m_Svnclient=svn::Client::getobject(0,0); - m_CurrentContext = 0; - dispProgress = false; - reInitClient(); -} - -void KioSvnData::reInitClient() -{ - if (first_done) { - return; - } - SshAgent ag; - ag.querySshAgent(); - - first_done = true; - m_CurrentContext = new svn::Context(); - m_CurrentContext->setListener(&m_Listener); - m_Svnclient->setContext(m_CurrentContext); -} - -KioSvnData::~KioSvnData() -{ - m_Listener.setCancel(true); - /* wait a little bit */ - sleep(1); - delete m_Svnclient; - m_CurrentContext->setListener(0L); - m_CurrentContext = 0; -} - -svn::Revision KioSvnData::urlToRev(const KURL&url) -{ - TQMap q = url.queryItems(); - - /* we try to check if it is ssh and try to get a password for it */ - TQString proto = url.protocol(); - - if (proto.find("ssh")!=-1) { - SshAgent ag; - ag.addSshIdentities(); - } - - svn::Revision rev,tmp; - rev = svn::Revision::UNDEFINED; - if (q.find("rev")!=q.end()) { - TQString v = q["rev"]; - m_Svnclient->url2Revision(v,rev,tmp); - } - return rev; -} - - -tdeio_svnProtocol::tdeio_svnProtocol(const TQCString &pool_socket, const TQCString &app_socket) - : SlaveBase("tdeio_ksvn", pool_socket, app_socket),StreamWrittenCb() -{ - m_pData=new KioSvnData(this); - TDEGlobal::locale()->insertCatalogue("tdesvn"); -} - -tdeio_svnProtocol::~tdeio_svnProtocol() -{ - kdDebug()<<"Delete kio protocol"<urlToRev(url); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - - try { - dlist = m_pData->m_Svnclient->list(makeSvnUrl(url),rev,rev,svn::DepthImmediates,false); - } catch (const svn::ClientException&e) { - TQString ex = e.msg(); - kdDebug()<name().isEmpty()) { - continue; - } - TQDateTime dt = svn::DateTime(dlist[i]->time()); - if (createUDSEntry(dlist[i]->name(), - dlist[i]->lastAuthor(), - dlist[i]->size(), - dlist[i]->kind()==svn_node_dir?true:false, - dt.toTime_t(), - entry) ) { - listEntry(entry,false); - } - entry.clear(); - } - listEntry(entry, true ); - finished(); -} - -void tdeio_svnProtocol::stat(const KURL& url) -{ - kdDebug()<<"tdeio_svn::stat "<< url << endl; - svn::Revision rev = m_pData->urlToRev(url); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - svn::Revision peg = rev; - bool dummy = false; - svn::InfoEntries e; - try { - e = m_pData->m_Svnclient->info(makeSvnUrl(url),svn::DepthEmpty,rev,peg); - } catch (const svn::ClientException&e) { - TQString ex = e.msg(); - kdDebug()<m_Listener.contextCancel()) { - finished(); - return; - } - svn::Revision rev = m_pData->urlToRev(url); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - KioByteStream dstream(this,url.filename()); - try { - m_pData->m_Svnclient->cat(dstream,makeSvnUrl(url),rev,rev); - } catch (const svn::ClientException&e) { - TQString ex = e.msg(); - kdDebug()<urlToRev(url); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - try { - svn::Path p(makeSvnUrl(url)); - m_pData->m_Svnclient->mkdir(p,getDefaultLog()); - }catch (const svn::ClientException&e) { - error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } - kdDebug()<<"tdeio_svn::mkdir finished " << url << endl; - finished(); -} - -void tdeio_svnProtocol::mkdir(const KURL::List &urls, int) -{ - svn::Pathes p; - for ( TQValueListConstIterator it = urls.begin(); it != urls.end() ; ++it ) { - p.append((*it).path()); - } - try { - m_pData->m_Svnclient->mkdir(svn::Targets(p),getDefaultLog()); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - finished(); -} - -void tdeio_svnProtocol::rename(const KURL&src,const KURL&target,bool force) -{ - kdDebug()<<"tdeio_svn::rename "<< src << " to " << target << endl; - TQString msg; - m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); - try { - m_pData->m_Svnclient->move(makeSvnUrl(src),makeSvnUrl(target),force); - }catch (const svn::ClientException&e) { - error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } - kdDebug()<<"tdeio_svn::rename finished" << endl; - finished(); -} - -void tdeio_svnProtocol::copy(const KURL&src,const KURL&dest,int permissions,bool overwrite) -{ - Q_UNUSED(permissions); - Q_UNUSED(overwrite); - kdDebug()<<"tdeio_svn::copy "<< src << " to " << dest << endl; - svn::Revision rev = m_pData->urlToRev(src); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - m_pData->dispProgress=true; - m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); - try { - m_pData->m_Svnclient->copy(makeSvnUrl(src),rev,makeSvnUrl(dest)); - }catch (const svn::ClientException&e) { - error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } - m_pData->dispProgress=false; - kdDebug()<<"tdeio_svn::copy finished" << endl; - finished(); -} - -void tdeio_svnProtocol::del(const KURL&src,bool isfile) -{ - Q_UNUSED(isfile); - kdDebug()<<"tdeio_svn::del "<< src << endl; - //m_pData->reInitClient(); - svn::Revision rev = m_pData->urlToRev(src); - if (rev == svn::Revision::UNDEFINED) { - rev = svn::Revision::HEAD; - } - m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); - try { - svn::Targets target(makeSvnUrl(src)); - m_pData->m_Svnclient->remove(target,false); - } catch (const svn::ClientException&e) { - TQString ex = e.msg(); - kdDebug()<m_Listener.contextGetLogMessage(t,_items); -} - -bool tdeio_svnProtocol::checkWc(const KURL&url) -{ - if (url.isEmpty()||!url.isLocalFile()) return false; - svn::Revision peg(svn_opt_revision_unspecified); - svn::Revision rev(svn_opt_revision_unspecified); - svn::InfoEntries e; - try { - e = m_pData->m_Svnclient->info(url.prettyURL(),svn::DepthEmpty,rev,peg); - } catch (const svn::ClientException&e) { - if (SVN_ERR_WC_NOT_DIRECTORY==e.apr_err()) - { - return false; - } - return true; - } - return false; -} - -TQString tdeio_svnProtocol::makeSvnUrl(const KURL&url,bool check_Wc) -{ - TQString res; - TQString proto = svn::Url::transformProtokoll(url.protocol()); - if (proto=="file" && check_Wc) - { - if (checkWc(url)) - { - return url.path(); - } - } - - TQStringList s = TQStringList::split("://",res); - TQString base = url.path(); - TQString host = url.host(); - TQString user = (url.hasUser()?url.user()+(url.hasPass()?":"+url.pass():""):""); - if (host.isEmpty()) { - res=proto+"://"+base; - } else { - res = proto+"://"+(user.isEmpty()?"":user+"@")+host+base; - } - if (base.isEmpty()) { - throw svn::ClientException(TQString("'")+res+TQString("' is not a valid subversion url")); - } - return res; -} - -bool tdeio_svnProtocol::createUDSEntry( const TQString& filename, const TQString& user, long long int size, bool isdir, time_t mtime, TDEIO::UDSEntry& entry) -{ -#if 0 - kdDebug() << "MTime : " << ( long )mtime << endl; - kdDebug() << "UDS filename : " << filename << endl; - kdDebug()<< "UDS Size: " << size << endl; - kdDebug()<< "UDS Dir: " << isdir << endl; -#endif - TDEIO::UDSAtom atom; - atom.m_uds = TDEIO::UDS_NAME; - atom.m_str = filename; - entry.append( atom ); - - atom.m_uds = TDEIO::UDS_FILE_TYPE; - atom.m_long = isdir ? S_IFDIR : S_IFREG; - entry.append( atom ); - - atom.m_uds = TDEIO::UDS_ACCESS; - atom.m_long = isdir?0777:0666; - entry.append(atom); - - - atom.m_uds = TDEIO::UDS_SIZE; - atom.m_long = size; - entry.append( atom ); - - atom.m_uds = TDEIO::UDS_MODIFICATION_TIME; - atom.m_long = mtime; - entry.append( atom ); - - atom.m_uds = TDEIO::UDS_USER; - atom.m_str = user; - entry.append( atom ); - - return true; -} - -void tdeio_svnProtocol::special(const TQByteArray& data) -{ - kdDebug()<<"tdeio_svnProtocol::special"<> tmp; - kdDebug() << "tdeio_svnProtocol::special " << tmp << endl; - switch (tmp) { - case SVN_CHECKOUT: - { - KURL repository, wc; - int revnumber; - TQString revkind; - stream >> repository; - stream >> wc; - stream >> revnumber; - stream >> revkind; - kdDebug(0) << "tdeio_svnProtocol CHECKOUT from " << repository.url() << " to " << wc.url() << " at " << revnumber << " or " << revkind << endl; - checkout( repository, wc, revnumber, revkind ); - break; - } - case SVN_UPDATE: - { - KURL wc; - int revnumber; - TQString revkind; - stream >> wc; - stream >> revnumber; - stream >> revkind; - kdDebug(0) << "tdeio_svnProtocol UPDATE " << wc.url() << " at " << revnumber << " or " << revkind << endl; - update(wc, revnumber, revkind ); - break; - } - case SVN_COMMIT: - { - KURL::List wclist; - while ( !stream.atEnd() ) { - KURL tmp; - stream >> tmp; - wclist << tmp; - } - kdDebug(0) << "tdeio_svnProtocol COMMIT" << endl; - commit( wclist ); - break; - } - case SVN_LOG: - { - kdDebug(0) << "tdeio_svnProtocol LOG" << endl; - int revstart, revend; - TQString revkindstart, revkindend; - KURL::List targets; - stream >> revstart; - stream >> revkindstart; - stream >> revend; - stream >> revkindend; - while ( !stream.atEnd() ) { - KURL tmp; - stream >> tmp; - targets << tmp; - } - svnlog( revstart, revkindstart, revend, revkindend, targets ); - break; - } - case SVN_IMPORT: - { - KURL wc,repos; - stream >> repos; - stream >> wc; - kdDebug(0) << "tdeio_ksvnProtocol IMPORT" << endl; - import(repos,wc); - break; - } - case SVN_ADD: - { - KURL wc; - kdDebug(0) << "tdeio_ksvnProtocol ADD" << endl; - stream >> wc; - add(wc); - break; - } - case SVN_DEL: - { - KURL::List wclist; - while ( !stream.atEnd() ) { - KURL tmp; - stream >> tmp; - wclist << tmp; - } - wc_delete(wclist); - break; - } - case SVN_REVERT: - { - KURL::List wclist; - while ( !stream.atEnd() ) { - KURL tmp; - stream >> tmp; - wclist << tmp; - } - kdDebug(7128) << "tdeio_svnProtocol REVERT" << endl; - revert(wclist); - break; - } - case SVN_STATUS: - { - KURL wc; - bool checkRepos=false; - bool fullRecurse=false; - stream >> wc; - stream >> checkRepos; - stream >> fullRecurse; - kdDebug(0) << "tdeio_svnProtocol STATUS" << endl; - status(wc,checkRepos,fullRecurse); - break; - } - case SVN_MKDIR: - { - KURL::List list; - stream >> list; - kdDebug(0) << "tdeio_svnProtocol MKDIR" << endl; - mkdir(list,0); - break; - } - case SVN_RESOLVE: - { - KURL url; - bool recurse; - stream >> url; - stream >> recurse; - kdDebug(7128) << "tdeio_svnProtocol RESOLVE" << endl; - wc_resolve(url,recurse); - break; - } - case SVN_SWITCH: - { - KURL wc,url; - bool recurse; - int revnumber; - TQString revkind; - stream >> wc; - stream >> url; - stream >> recurse; - stream >> revnumber; - stream >> revkind; - kdDebug(7128) << "tdeio_svnProtocol SWITCH" << endl; - wc_switch(wc,url,recurse,revnumber,revkind); - break; - } - case SVN_DIFF: - { - KURL url1,url2; - int rev1, rev2; - bool recurse; - TQString revkind1, revkind2; - stream >> url1; - stream >> url2; - stream >> rev1; - stream >> revkind1; - stream >> rev2; - stream >> revkind2; - stream >> recurse; - diff(url1,url2,rev1,revkind1,rev2,revkind2,recurse); - break; - } - default: - {kdDebug()<<"Unknown special" << endl;} - } - finished(); -} - -void tdeio_svnProtocol::update(const KURL&url,int revnumber,const TQString&revkind) -{ - svn::Revision where(revnumber,revkind); - /* update is always local - so make a path instead URI */ - svn::Path p(url.path()); - try { - svn::Targets pathes(p.path()); - // always update externals, too. (third last parameter) - // no unversioned items allowed (second last parameter) - // sticky depth (last parameter) - m_pData->m_Svnclient->update(pathes, where,svn::DepthInfinity,false,false,true); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } -} - -void tdeio_svnProtocol::status(const KURL&wc,bool cR,bool rec) -{ - svn::Revision where = svn::Revision::UNDEFINED; - svn::StatusEntries dlist; - try { - // rec all up noign - dlist = m_pData->m_Svnclient->status(wc.path(),rec?svn::DepthInfinity:svn::DepthEmpty,false,cR,false,where); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - kdDebug()<<"Status got " << dlist.count() << " entries." << endl; - for (unsigned j=0;jm_Listener.counter()).rightJustify( 10,'0' )+"path",dlist[j]->path()); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"text",TQString::number(dlist[j]->textStatus())); - setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "prop", - TQString::number(dlist[j]->propStatus())); - setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "reptxt", - TQString::number(dlist[j]->reposTextStatus())); - setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "repprop", - TQString::number(dlist[j]->reposPropStatus())); - setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "rev", - TQString::number(dlist[j]->entry().cmtRev())); - m_pData->m_Listener.incCounter(); - } -} - -void tdeio_svnProtocol::commit(const KURL::List&url) -{ - /// @todo replace with direct call to tdesvn? - TQByteArray reply; - TQByteArray params; - TQCString replyType; - TQString msg; - - if (!dcopClient()->call("kded","tdesvnd","get_logmsg()",params,replyType,reply)) { - msg = "Communication with dcop failed"; - kdWarning()<>lt; - if (lt.count()!=1) { - msg = "Wrong or missing log (may cancel pressed)."; - kdDebug()<< msg << endl; - return; - } - msg = lt[0]; - TQValueList targets; - for (unsigned j=0; jm_Svnclient->commit(svn::Targets(targets),msg,svn::DepthInfinity,false); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } - for (unsigned j=0;jm_Listener.counter()).rightJustify( 10,'0' )+ "path", url[j].path() ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "action", "0" ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "kind", "0" ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "mime_t", "" ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "content", "0" ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "prop", "0" ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev" , TQString::number(nnum) ); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "string", userstring ); - m_pData->m_Listener.incCounter(); - } -} - -void tdeio_svnProtocol::checkout(const KURL&src,const KURL&target,const int rev, const TQString&revstring) -{ - svn::Revision where(rev,revstring); - svn::Revision peg = svn::Revision::UNDEFINED; - svn::Path _target(target.path()); - try { - KURL _src = makeSvnUrl(src); - m_pData->m_Svnclient->checkout(_src.url(),_target,where,peg,svn::DepthInfinity,false,false); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } -} - -void tdeio_svnProtocol::svnlog(int revstart,const TQString&revstringstart,int revend, const TQString&revstringend, const KURL::List&urls) -{ - svn::Revision start(revstart,revstringstart); - svn::Revision end(revend,revstringend); - svn::LogEntriesPtr logs; - - for (unsigned j = 0; jm_Svnclient->log(makeSvnUrl(urls[j]),start,end,svn::Revision::UNDEFINED,true,true,0); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - break; - } - if (!logs) { - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify(10,'0')+"path",urls[j].path()); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify(10,'0')+"string", - i18n("Empty logs")); - m_pData->m_Listener.incCounter(); - continue; - } - for (unsigned int i = 0; i < logs->count();++i) { - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "path",urls[j].path()); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev", - TQString::number( (*logs)[i].revision)); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"author", - (*logs)[i].author); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"logmessage", - (*logs)[i].message); - m_pData->m_Listener.incCounter(); - for (unsigned z = 0; z<(*logs)[i].changedPaths.count();++z) { - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev", - TQString::number( (*logs)[i].revision)); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "path",urls[j].path()); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedpath", - (*logs)[i].changedPaths[z].path); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedaction", - TQChar((*logs)[i].changedPaths[z].action)); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedcopyfrompath", - (*logs)[i].changedPaths[z].copyFromPath); - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedcopyfromrevision", - TQString::number((*logs)[i].changedPaths[z].copyFromRevision)); - m_pData->m_Listener.incCounter(); - } - } - } -} - -void tdeio_svnProtocol::revert(const KURL::List&l) -{ - TQValueList list; - for (unsigned j=0; jm_Svnclient->revert(target,svn::DepthEmpty); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } -} - -void tdeio_svnProtocol::wc_switch(const KURL&wc,const KURL&target,bool rec,int rev,const TQString&revstring) -{ - svn::Revision where(rev,revstring); - svn::Path wc_path(wc.path()); - try { - m_pData->m_Svnclient->doSwitch(wc_path,makeSvnUrl(target.url()),where,rec?svn::DepthInfinity:svn::DepthFiles); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - } -} - -void tdeio_svnProtocol::diff(const KURL&uri1,const KURL&uri2,int rnum1,const TQString&rstring1,int rnum2, const TQString&rstring2,bool rec) -{ - TQByteArray ex; - /// @todo read settings for diff (ignore contentype) - try { - svn::Revision r1(rnum1,rstring1); - svn::Revision r2(rnum2,rstring2); - TQString u1 = makeSvnUrl(uri1,true); - TQString u2 = makeSvnUrl(uri2,true); - KTempDir tdir; - kdDebug() << "tdeio_ksvn::diff : " << u1 << " at revision " << r1.toString() << " with " - << u2 << " at revision " << r2.toString() - << endl ; - - tdir.setAutoDelete(true); - ex = m_pData->m_Svnclient->diff(svn::Path(tdir.name()), - u1,u2,svn::Path(),r1, r2,rec?svn::DepthInfinity:svn::DepthEmpty,false,false,false); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - TQString out = TQString::FROMUTF8(ex); - TQTextIStream stream(&out); - while (!stream.atEnd()) { - setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "diffresult",stream.readLine()); - m_pData->m_Listener.incCounter(); - } -} - -void tdeio_svnProtocol::import(const KURL& repos, const KURL& wc) -{ - try { - TQString target = makeSvnUrl(repos); - TQString path = wc.path(); - m_pData->m_Svnclient->import(svn::Path(path),target,TQString(),svn::DepthInfinity,false,false); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - finished(); -} - -void tdeio_svnProtocol::add(const KURL& wc) -{ - TQString path = wc.path(); - try { - /* rec */ - m_pData->m_Svnclient->add(svn::Path(path),svn::DepthInfinity); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - finished(); -} - -void tdeio_svnProtocol::wc_delete(const KURL::List&l) -{ - svn::Pathes p; - for ( TQValueListConstIterator it = l.begin(); it != l.end() ; ++it ) { - p.append((*it).path()); - } - try { - m_pData->m_Svnclient->remove(svn::Targets(p),false); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - finished(); -} - -void tdeio_svnProtocol::wc_resolve(const KURL&url,bool recurse) -{ - try { - svn::Depth depth=recurse?svn::DepthInfinity:svn::DepthEmpty; - m_pData->m_Svnclient->resolve(url.path(),depth); - } catch (const svn::ClientException&e) { - error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); - return; - } - finished(); -} - -void tdeio_svnProtocol::streamWritten(const TDEIO::filesize_t current) -{ - processedSize(current); -} - -void tdeio_svnProtocol::streamSendMime(KMimeMagicResult* mt) -{ - if (mt) { - mimeType(mt->mimeType()); - } -} - -void tdeio_svnProtocol::streamPushData(TQByteArray array) -{ - data(array); -} - -void tdeio_svnProtocol::contextProgress(long long int current, long long int) -{ - if (m_pData->dispProgress) { - processedSize(current); - } -} - -void tdeio_svnProtocol::streamTotalSizeNull() -{ - totalSize(0); -} - - -/*! - \fn tdeio_svnProtocol::getDefaultLog() - */ -TQString tdeio_svnProtocol::getDefaultLog() -{ - TQString res = TQString(); - Kdesvnsettings::self()->readConfig(); - if (Kdesvnsettings::tdeio_use_standard_logmsg()) { - res = Kdesvnsettings::tdeio_standard_logmsg(); - } - return res; -} - -} // namespace TDEIO diff --git a/src/kiosvn/kiosvn.h b/src/kiosvn/kiosvn.h deleted file mode 100644 index eca379a..0000000 --- a/src/kiosvn/kiosvn.h +++ /dev/null @@ -1,120 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2007 by Rajko Albrecht * - * ral@alwins-world.de * - * * - * 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 KIOSVN_H -#define KIOSVN_H - -#include "kiobytestream.h" - -#include -#include -#include - -#include -#include - - -#include -#include - -namespace TDEIO -{ - -class KioSvnData; - -/** -@author Rajko Albrecht -*/ -class tdeio_svnProtocol : public TDEIO::SlaveBase,public StreamWrittenCb -{ -public: - tdeio_svnProtocol(const TQCString &pool_socket, const TQCString &app_socket); - virtual ~tdeio_svnProtocol(); - virtual void listDir (const KURL&url); - virtual void stat(const KURL& url); - virtual void get(const KURL& url); - virtual void mkdir (const KURL &url, int permissions); - virtual void mkdir (const KURL::List &urls, int permissions); - virtual void rename(const KURL&src,const KURL&target,bool force); - virtual void del(const KURL&url,bool isfile); - virtual void copy(const KURL&src,const KURL&dest,int permissions,bool overwrite); - virtual void checkout(const KURL&src,const KURL&target,const int rev, const TQString&revstring); - virtual void svnlog(int,const TQString&,int, const TQString&, const KURL::List&); - virtual void revert(const KURL::List&); - virtual void wc_switch(const KURL&,const KURL&,bool,int,const TQString&); - virtual void diff(const KURL&,const KURL&,int,const TQString&,int, const TQString&,bool); - virtual void import( const KURL& repos, const KURL& wc); - virtual void add(const KURL& wc); - virtual void wc_delete(const KURL::List&); - virtual void special(const TQByteArray& data); - virtual void wc_resolve(const KURL&,bool); - /* looked on kio::svn from tdesdk */ - enum KSVN_METHOD { - /* KURL repository, KURL target, int revnumber, TQString revkind */ - SVN_CHECKOUT = 1, - /* KURL wc, int revnumber, TQString revkind */ - /* refkind may empty or HEAD or START, will get parsed if revnumber is -1 */ - SVN_UPDATE = 2, - /* KURL::List */ - SVN_COMMIT = 3, - /* int revstart, TQString revstartstring, int revend, TQString revendstring, KURL::List */ - SVN_LOG=4, - SVN_IMPORT=5, - /* KURL */ - SVN_ADD=6, - /*KURL::List */ - SVN_DEL=7, - /* KURL::List */ - SVN_REVERT=8, - /* KURL wc,bool checkRepos, bool recurse */ - SVN_STATUS=9, - /* KURL::List */ - SVN_MKDIR=10, - /* KURL, bool */ - SVN_RESOLVE=11, - /* KURL working copy, KURL new_repository_url, bool recurse, int rev, TQString revstring */ - SVN_SWITCH=12, - /* KURL uri1, KURL uri2, int r1, TQString rstring1, int r2, TQString rstring 2, bool recursive */ - SVN_DIFF=13 - }; - - void contextProgress(long long int current, long long int max); - virtual void streamWritten(const TDEIO::filesize_t current); - virtual void streamPushData(TQByteArray); - virtual void streamSendMime(KMimeMagicResult*mt); - virtual void streamTotalSizeNull(); - -protected: - virtual void commit(const KURL::List&); - virtual void status(const KURL&,bool,bool); - virtual void update(const KURL&,int,const TQString&); - -private: - KioSvnData*m_pData; - bool createUDSEntry( const TQString& filename, const TQString& user, long long int size, bool isdir, time_t mtime, TDEIO::UDSEntry& entry); - TQString makeSvnUrl(const KURL&url,bool check_wc=true); - bool checkWc(const KURL&url); - bool getLogMsg(TQString&); -protected: - TQString getDefaultLog(); -}; - -} - -#endif diff --git a/src/kiosvn/ksvn+file.protocol b/src/kiosvn/ksvn+file.protocol deleted file mode 100644 index 290ced2..0000000 --- a/src/kiosvn/ksvn+file.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=ksvn+file -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/ksvn+http.protocol b/src/kiosvn/ksvn+http.protocol deleted file mode 100644 index 433de96..0000000 --- a/src/kiosvn/ksvn+http.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=ksvn+http -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/ksvn+https.protocol b/src/kiosvn/ksvn+https.protocol deleted file mode 100644 index 76a79d1..0000000 --- a/src/kiosvn/ksvn+https.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=ksvn+https -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/ksvn+ssh.protocol b/src/kiosvn/ksvn+ssh.protocol deleted file mode 100644 index 8ed1e97..0000000 --- a/src/kiosvn/ksvn+ssh.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=ksvn+ssh -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/ksvn.protocol b/src/kiosvn/ksvn.protocol deleted file mode 100644 index ff40599..0000000 --- a/src/kiosvn/ksvn.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=ksvn -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/svn+file.protocol b/src/kiosvn/svn+file.protocol deleted file mode 100644 index b6664ba..0000000 --- a/src/kiosvn/svn+file.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=svn+file -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/svn+http.protocol b/src/kiosvn/svn+http.protocol deleted file mode 100644 index 5fec975..0000000 --- a/src/kiosvn/svn+http.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=svn+http -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/svn+https.protocol b/src/kiosvn/svn+https.protocol deleted file mode 100644 index 2f32bdd..0000000 --- a/src/kiosvn/svn+https.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=svn+https -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/svn+ssh.protocol b/src/kiosvn/svn+ssh.protocol deleted file mode 100644 index 90c4ae7..0000000 --- a/src/kiosvn/svn+ssh.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=svn+ssh -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/kiosvn/svn.protocol b/src/kiosvn/svn.protocol deleted file mode 100644 index d461e7f..0000000 --- a/src/kiosvn/svn.protocol +++ /dev/null @@ -1,39 +0,0 @@ -[Protocol] -exec=tdeio_ksvn -protocol=svn -input=none -output=filesystem -reading=true -writing=true -deleting=true -makedir=true -linking=false -moving=true -deleteRecursive=true -listing=Name,Size,Date,Owner -defaultMimetype=application/octet-stream -Icon=remote -Description=Subversion ioslave -Description[br]=Sklav E/D Subversion -Description[ca]=Ioslave de Subversion -Description[cs]=Subversion protokol -Description[de]=Ein-/Ausgabemodul für Subversion -Description[es]=El ioslave de Subversion -Description[et]=Subversioni IO-moodul -Description[fr]=ioslave subversion -Description[ga]=ioslave Subversion -Description[hu]=Subversion KDE-protokoll -Description[it]=Slave I/O di Subversion -Description[pl]=Wtyczka protokołu Subversion -Description[pt]='Ioslave' para Subversion -Description[pt_BR]=ioslave de Subversão -Description[ru]=Доступ к хранилищу Subversion -Description[sl]=ioslave za Subversion -Description[sr]=IOSlave за Subversion -Description[sr@Latn]=IOSlave za Subversion -Description[sv]=Subversion I/O-slav -Description[tr]=Alt Version ioslave -Description[uk]=Підлеглий В/В Subversion -Description[xx]=xxSubversion ioslavexx -maxInstances=5 -class=:internet diff --git a/src/tdeiosvn/CMakeLists.txt b/src/tdeiosvn/CMakeLists.txt new file mode 100644 index 0000000..cb84de5 --- /dev/null +++ b/src/tdeiosvn/CMakeLists.txt @@ -0,0 +1,28 @@ +################################################# +# +# (C) 2011 Timothy Pearson +# kb9vqf (AT) pearsoncomputing.net +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}/src + ${CMAKE_SOURCE_DIR}/src +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### protocol files ############################ + +file( GLOB PROTFILES *.protocol ) +install( FILES ${PROTFILES} DESTINATION ${SERVICES_INSTALL_DIR} ) diff --git a/src/tdeiosvn/kiobytestream.cpp b/src/tdeiosvn/kiobytestream.cpp new file mode 100644 index 0000000..81c6fc8 --- /dev/null +++ b/src/tdeiosvn/kiobytestream.cpp @@ -0,0 +1,63 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 "kiobytestream.h" + +KioByteStream::KioByteStream(StreamWrittenCb*aCb,const TQString&filename) + : svn::stream::SvnStream(false,true,0L), + m_Cb(aCb),m_Written(0), + m_mimeSend(false),m_Filename(filename) +{ + m_MessageTick.start(); +} + +KioByteStream::~KioByteStream() +{ +} + +bool KioByteStream::isOk() const +{ + return m_Cb != 0; +} + +long KioByteStream::write(const char* data, const unsigned long max) +{ + bool forceInfo = !m_mimeSend; + if (m_Cb) { + if (!m_mimeSend) { + m_mimeSend = true; + array.setRawData(data, max); + KMimeMagicResult * result = KMimeMagic::self()->findBufferFileType(array,m_Filename); + m_Cb->streamSendMime(result); + array.resetRawData(data, max); + m_Cb->streamTotalSizeNull(); + } + array.setRawData(data, max); + m_Cb->streamPushData(array); + array.resetRawData(data, max); + + m_Written+=max; + if (m_MessageTick.elapsed() >=100 || forceInfo) { + m_Cb->streamWritten(m_Written); + m_MessageTick.restart(); + } + return max; + } + return -1; +} diff --git a/src/tdeiosvn/kiobytestream.h b/src/tdeiosvn/kiobytestream.h new file mode 100644 index 0000000..48addfe --- /dev/null +++ b/src/tdeiosvn/kiobytestream.h @@ -0,0 +1,66 @@ +/*************************************************************************** + * Copyright (C) 2006-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 KIOBYTESTREAM_H +#define KIOBYTESTREAM_H + +#include "svnstream.hpp" + +#include +#include +#include +#include +#include + +class StreamWrittenCb +{ +public: + StreamWrittenCb(){} + virtual ~StreamWrittenCb(){} + virtual void streamWritten(const TDEIO::filesize_t current) = 0; + virtual void streamPushData(TQByteArray)=0; + virtual void streamSendMime(KMimeMagicResult*mt)=0; + virtual void streamTotalSizeNull()=0; +}; + +/** + @author Rajko Albrecht +*/ +class KioByteStream : public svn::stream::SvnStream +{ +public: + KioByteStream(StreamWrittenCb*,const TQString&filename); + + ~KioByteStream(); + + virtual bool isOk() const; + virtual long write(const char* data, const unsigned long max); + + TDEIO::filesize_t written(){return m_Written;} + +protected: + StreamWrittenCb*m_Cb; + TDEIO::filesize_t m_Written; + bool m_mimeSend; + TQString m_Filename; + TQByteArray array; + TQTime m_MessageTick; +}; + +#endif diff --git a/src/tdeiosvn/kiolistener.cpp b/src/tdeiosvn/kiolistener.cpp new file mode 100644 index 0000000..f4cd940 --- /dev/null +++ b/src/tdeiosvn/kiolistener.cpp @@ -0,0 +1,408 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 "kiolistener.h" +#include "tdeiosvn.h" + +#include +#include +#include + +namespace TDEIO { + +KioListener::KioListener(TDEIO::tdeio_svnProtocol*_par) + : svn::ContextListener(),m_notifyCounter(0),m_External(false),m_HasChanges(false),m_FirstTxDelta(false),m_Canceld(false) +{ + par = _par; +} + + +KioListener::~KioListener() +{ +} + + + + +/*! + \fn KioListener::contextCancel() + */ +bool KioListener::contextCancel() +{ + return par->wasKilled()||m_Canceld; +} + + +/*! + \fn KioListener::contextGetLogMessage (TQString & msg) + */ +bool KioListener::contextGetLogMessage (TQString & msg,const svn::CommitItemList&_items) +{ +#if 1 + TQByteArray reply; + TQByteArray params; + TQCString replyType; + TQDataStream stream(params,IO_WriteOnly); + + if (_items.count()>0) { + TQMap list; + for (unsigned i = 0;i<_items.count();++i) { + if (_items[i].path().isEmpty()) { + list[_items[i].url()]=TQChar(_items[i].actionType()); + } else { + list[_items[i].path()]=TQChar(_items[i].actionType()); + } + } + stream << list; + if (!par->dcopClient()->call("kded","tdesvnd","get_logmsg(TQMap)",params,replyType,reply)) { + msg = "Communication with dcop failed"; + kdWarning()<dcopClient()->call("kded","tdesvnd","get_logmsg()",params,replyType,reply)) { + msg = "Communication with dcop failed"; + kdWarning()<>lt; + if (lt.count()!=1) { + msg = "Wrong or missing log (may cancel pressed)."; + kdDebug()<< msg << endl; + return false; + } + msg = lt[0]; +#else + msg = "Made with a kio::svn client"; +#endif + return true; +} + +/*! the content of that method is taken from the notify in kio::svn in KDE SDK */ +/* this moment we don't use it full 'cause not all is made via KIO */ +void KioListener::contextNotify (const char * path,svn_wc_notify_action_t action,svn_node_kind_t kind ,const char * mime_type ,svn_wc_notify_state_t content_state, svn_wc_notify_state_t prop_state,svn_revnum_t revision) +{ + if (par->wasKilled()) { + return; + } + TQString userstring; + + switch(action) { + case svn_wc_notify_add: + { + if (mime_type && (svn_mime_type_is_binary (mime_type))) + userstring = i18n( "A (bin) %1" ).arg( path ); + else + userstring = i18n( "A %1" ).arg( path ); + break; + } + break; + case svn_wc_notify_copy: //copy + break; + case svn_wc_notify_delete: //delete + m_HasChanges = TRUE; + userstring = i18n( "D %1" ).arg( path ); + break; + case svn_wc_notify_restore : //restore + userstring=i18n( "Restored %1." ).arg( path ); + break; + case svn_wc_notify_revert : //revert + userstring=i18n( "Reverted %1." ).arg( path ); + break; + case svn_wc_notify_failed_revert: //failed revert + userstring=i18n( "Failed to revert %1.\nTry updating instead." ).arg( path ); + break; + case svn_wc_notify_resolved: //resolved + userstring=i18n( "Resolved conflicted state of %1." ).arg( path ); + break; + case svn_wc_notify_skip: //skip + if ( content_state == svn_wc_notify_state_missing ) + userstring=i18n("Skipped missing target %1.").arg( path ); + else + userstring=i18n("Skipped %1.").arg( path ); + break; + case svn_wc_notify_update_delete: //update_delete + m_HasChanges = TRUE; + userstring=i18n( "D %1" ).arg( path ); + break; + case svn_wc_notify_update_add: //update_add + m_HasChanges = TRUE; + userstring=i18n( "A %1" ).arg( path ); + break; + case svn_wc_notify_update_update: //update_update + { + /* If this is an inoperative dir change, do no notification. + An inoperative dir change is when a directory gets closed + without any props having been changed. */ + if (! ((kind == svn_node_dir) + && ((prop_state == svn_wc_notify_state_inapplicable) + || (prop_state == svn_wc_notify_state_unknown) + || (prop_state == svn_wc_notify_state_unchanged)))) { + m_HasChanges = TRUE; + + if (kind == svn_node_file) { + if (content_state == svn_wc_notify_state_conflicted) + userstring = "C"; + else if (content_state == svn_wc_notify_state_merged) + userstring = "G"; + else if (content_state == svn_wc_notify_state_changed) + userstring = "U"; + } + + if (prop_state == svn_wc_notify_state_conflicted) + userstring += "C"; + else if (prop_state == svn_wc_notify_state_merged) + userstring += "G"; + else if (prop_state == svn_wc_notify_state_changed) + userstring += "U"; + else + userstring += " "; + + if (! ((content_state == svn_wc_notify_state_unchanged + || content_state == svn_wc_notify_state_unknown) + && (prop_state == svn_wc_notify_state_unchanged + || prop_state == svn_wc_notify_state_unknown))) + userstring += TQString( " " ) + path; + } + break; + } + case svn_wc_notify_update_completed: //update_completed + { + if (!m_External) { + if (SVN_IS_VALID_REVNUM(revision)) { + userstring = i18n("Finished at revision %1.").arg(revision); + } else { + userstring = i18n("Finished."); + } + } else { + if (SVN_IS_VALID_REVNUM(revision)) { + userstring = i18n("Finished external at revision %1.").arg(revision); + } else { + userstring = i18n("Finished external."); + } + } + } + if (m_External) + m_External = FALSE; + break; + case svn_wc_notify_update_external: //update_external + m_External = TRUE; + userstring = i18n("Fetching external item into %1." ).arg( path ); + break; + case svn_wc_notify_status_completed: //status_completed + if (SVN_IS_VALID_REVNUM (revision)) + userstring = i18n( "Status against revision: %1.").arg( revision ); + break; + case svn_wc_notify_status_external: //status_external + userstring = i18n("Performing status on external item at %1.").arg( path ); + break; + case svn_wc_notify_commit_modified: //commit_modified + userstring = i18n( "Sending %1.").arg( path ); + break; + case svn_wc_notify_commit_added: //commit_added + if (mime_type && svn_mime_type_is_binary (mime_type)) { + userstring = i18n( "Adding (bin) %1.").arg( path ); + } else { + userstring = i18n( "Adding %1.").arg( path ); + } + break; + case svn_wc_notify_commit_deleted: //commit_deleted + userstring = i18n( "Deleting %1.").arg( path ); + break; + case svn_wc_notify_commit_replaced: //commit_replaced + userstring = i18n( "Replacing %1.").arg( path ); + break; + case svn_wc_notify_commit_postfix_txdelta: //commit_postfix_txdelta + if (!m_FirstTxDelta) { + m_FirstTxDelta = TRUE; + // check fullstops! + userstring=i18n("Transmitting file data "); + } else { + userstring="."; + } + break; + + break; + case svn_wc_notify_blame_revision: //blame_revision + break; + default: + break; + } + par->setMetaData(TQString::number(counter()).rightJustify( 10,'0' )+ "path" , TQString::FROMUTF8( path )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "action", TQString::number( action )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "kind", TQString::number( kind )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "mime_t", TQString::FROMUTF8( mime_type )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "content", TQString::number( content_state )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "prop", TQString::number( prop_state )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "rev", TQString::number( revision )); + par->setMetaData(TQString::number( counter() ).rightJustify( 10,'0' )+ "string", userstring ); + incCounter(); +} + +void KioListener::contextNotify (const svn_wc_notify_t *action) +{ + if (!action) return; +// if (action->actionpath,action->action,action->kind,action->mime_type, + action->content_state,action->prop_state,action->revision); +// return; +// } +// TQString aString = NotifyAction(action->action); +} + +svn::ContextListener::SslServerTrustAnswer +KioListener::contextSslServerTrustPrompt (const SslServerTrustData & data, apr_uint32_t & acceptedFailures) +{ + TQByteArray reply; + TQByteArray params; + TQCString replyType; + TQDataStream stream(params,IO_WriteOnly); + stream << data.hostname + << data.fingerprint + << data.validFrom + << data.validUntil + << data.issuerDName + << data.realm; + + if (!par->dcopClient()->call("kded","tdesvnd", + "get_sslaccept(TQString,TQString,TQString,TQString,TQString,TQString)", + params,replyType,reply)) { + kdWarning()<<"Communication with dcop failed"<>res; + switch (res) { + case -1: + return DONT_ACCEPT; + break; + case 1: + return ACCEPT_PERMANENTLY; + break; + default: + case 0: + return ACCEPT_TEMPORARILY; + break; + } + /* avoid compiler warnings */ + return ACCEPT_TEMPORARILY; +} + +bool KioListener::contextLoadSslClientCertPw(TQString&password,const TQString&realm) +{ + return PwStorage::self()->getCertPw(realm,password); +} + +bool KioListener::contextSslClientCertPrompt (TQString & certFile) +{ + TQByteArray reply; + TQByteArray params; + TQCString replyType; + if (!par->dcopClient()->call("kded","tdesvnd", + "get_sslclientcertfile()", + params,replyType,reply)) { + kdWarning()<<"Communication with dcop failed"<>certFile; + if (certFile.isEmpty()) { + return false; + } + return true; +} + +bool KioListener::contextSslClientCertPwPrompt (TQString & password, + const TQString & realm, bool & maySave) +{ + return false; +} + +bool KioListener::contextGetSavedLogin (const TQString & realm,TQString & username,TQString & password) +{ + PwStorage::self()->getLogin(realm,username,password); + return true; +} + +bool KioListener::contextGetCachedLogin (const TQString & realm,TQString & username,TQString & password) +{ + return true; +} + +bool KioListener::contextGetLogin (const TQString & realm, TQString & username, TQString & password, bool & maySave) +{ + TQByteArray reply; + TQByteArray params; + TQCString replyType; + + TQDataStream stream(params,IO_WriteOnly); + stream << realm; + stream << username; + + if (!par->dcopClient()->call("kded","tdesvnd","get_login(TQString,TQString)",params,replyType,reply)) { + kdWarning()<<"Communication with dcop failed"<>lt; + if (lt.count()!=3) { + kdDebug()<<"Wrong or missing auth list (may cancel pressed)." << endl; + return false; + } + username = lt[0]; + password = lt[1]; + maySave = lt[2]=="true"; + return true; +} + + +/*! + \fn KioListener::contextProgress(long long int current, long long int max) + */ +void KioListener::contextProgress(long long int cur, long long int max) +{ + if (par) { + par->contextProgress(cur,max); + } +} + +} // namespace TDEIO diff --git a/src/tdeiosvn/kiolistener.h b/src/tdeiosvn/kiolistener.h new file mode 100644 index 0000000..f836b65 --- /dev/null +++ b/src/tdeiosvn/kiolistener.h @@ -0,0 +1,83 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 KIOLISTENER_H +#define KIOLISTENER_H + +#include "context_listener.hpp" +#include "pwstorage.h" + +namespace TDEIO { + class SlaveBase; + class tdeio_svnProtocol; + +/** +@author Rajko Albrecht +*/ +class KioListener : public svn::ContextListener +{ +public: + KioListener(TDEIO::tdeio_svnProtocol*_par); + virtual ~KioListener(); + + /* context-listener methods */ + virtual bool contextGetLogin (const TQString & realm, + TQString & username, + TQString & password, + bool & maySave); + virtual bool contextGetSavedLogin (const TQString & realm,TQString & username,TQString & password); + virtual bool contextGetCachedLogin (const TQString & realm,TQString & username,TQString & password); + + virtual void contextNotify (const char *path, + svn_wc_notify_action_t action, + svn_node_kind_t kind, + const char *mime_type, + svn_wc_notify_state_t content_state, + svn_wc_notify_state_t prop_state, + svn_revnum_t revision); + virtual void contextNotify (const svn_wc_notify_t *action); + + virtual bool contextCancel(); + virtual bool contextGetLogMessage (TQString & msg,const svn::CommitItemList&); + virtual SslServerTrustAnswer contextSslServerTrustPrompt (const SslServerTrustData & data, + apr_uint32_t & acceptedFailures); + virtual bool contextSslClientCertPrompt (TQString & certFile); + virtual bool contextSslClientCertPwPrompt (TQString & password, + const TQString & realm, bool & maySave); + virtual bool contextLoadSslClientCertPw(TQString&password,const TQString&realm); + /* context listener virtuals end */ + unsigned int counter()const{return m_notifyCounter;} + void incCounter(){++m_notifyCounter;} + virtual void contextProgress(long long int current, long long int max); + + void setCancel(bool value){m_Canceld=value;} + +private: + TDEIO::tdeio_svnProtocol *par; + +protected: + unsigned int m_notifyCounter; + bool m_External; + bool m_HasChanges; + bool m_FirstTxDelta; + bool m_Canceld; +}; +} + +#endif diff --git a/src/tdeiosvn/ksvn+file.protocol b/src/tdeiosvn/ksvn+file.protocol new file mode 100644 index 0000000..290ced2 --- /dev/null +++ b/src/tdeiosvn/ksvn+file.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=ksvn+file +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/ksvn+http.protocol b/src/tdeiosvn/ksvn+http.protocol new file mode 100644 index 0000000..433de96 --- /dev/null +++ b/src/tdeiosvn/ksvn+http.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=ksvn+http +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/ksvn+https.protocol b/src/tdeiosvn/ksvn+https.protocol new file mode 100644 index 0000000..76a79d1 --- /dev/null +++ b/src/tdeiosvn/ksvn+https.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=ksvn+https +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/ksvn+ssh.protocol b/src/tdeiosvn/ksvn+ssh.protocol new file mode 100644 index 0000000..8ed1e97 --- /dev/null +++ b/src/tdeiosvn/ksvn+ssh.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=ksvn+ssh +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/ksvn.protocol b/src/tdeiosvn/ksvn.protocol new file mode 100644 index 0000000..ff40599 --- /dev/null +++ b/src/tdeiosvn/ksvn.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=ksvn +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/svn+file.protocol b/src/tdeiosvn/svn+file.protocol new file mode 100644 index 0000000..b6664ba --- /dev/null +++ b/src/tdeiosvn/svn+file.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=svn+file +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/svn+http.protocol b/src/tdeiosvn/svn+http.protocol new file mode 100644 index 0000000..5fec975 --- /dev/null +++ b/src/tdeiosvn/svn+http.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=svn+http +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/svn+https.protocol b/src/tdeiosvn/svn+https.protocol new file mode 100644 index 0000000..2f32bdd --- /dev/null +++ b/src/tdeiosvn/svn+https.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=svn+https +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/svn+ssh.protocol b/src/tdeiosvn/svn+ssh.protocol new file mode 100644 index 0000000..90c4ae7 --- /dev/null +++ b/src/tdeiosvn/svn+ssh.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=svn+ssh +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/svn.protocol b/src/tdeiosvn/svn.protocol new file mode 100644 index 0000000..d461e7f --- /dev/null +++ b/src/tdeiosvn/svn.protocol @@ -0,0 +1,39 @@ +[Protocol] +exec=tdeio_ksvn +protocol=svn +input=none +output=filesystem +reading=true +writing=true +deleting=true +makedir=true +linking=false +moving=true +deleteRecursive=true +listing=Name,Size,Date,Owner +defaultMimetype=application/octet-stream +Icon=remote +Description=Subversion ioslave +Description[br]=Sklav E/D Subversion +Description[ca]=Ioslave de Subversion +Description[cs]=Subversion protokol +Description[de]=Ein-/Ausgabemodul für Subversion +Description[es]=El ioslave de Subversion +Description[et]=Subversioni IO-moodul +Description[fr]=ioslave subversion +Description[ga]=ioslave Subversion +Description[hu]=Subversion KDE-protokoll +Description[it]=Slave I/O di Subversion +Description[pl]=Wtyczka protokołu Subversion +Description[pt]='Ioslave' para Subversion +Description[pt_BR]=ioslave de Subversão +Description[ru]=Доступ к хранилищу Subversion +Description[sl]=ioslave za Subversion +Description[sr]=IOSlave за Subversion +Description[sr@Latn]=IOSlave za Subversion +Description[sv]=Subversion I/O-slav +Description[tr]=Alt Version ioslave +Description[uk]=Підлеглий В/В Subversion +Description[xx]=xxSubversion ioslavexx +maxInstances=5 +class=:internet diff --git a/src/tdeiosvn/tdeiosvn.cpp b/src/tdeiosvn/tdeiosvn.cpp new file mode 100644 index 0000000..fe17ab1 --- /dev/null +++ b/src/tdeiosvn/tdeiosvn.cpp @@ -0,0 +1,954 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 "tdesvn-config.h" +#include "tdeiosvn.h" +#include "kiolistener.h" + +#include "svnqttypes.hpp" +#include "dirent.hpp" +#include "url.hpp" +#include "status.hpp" +#include "targets.hpp" +#include "info_entry.hpp" +#include "tdesvnsettings.h" +#include "sub2qt.h" +#include "sshagent.h" + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +namespace TDEIO +{ + +class KioSvnData +{ +public: + KioSvnData(tdeio_svnProtocol*); + virtual ~KioSvnData(); + + void reInitClient(); + + KioListener m_Listener; + bool first_done; + bool dispProgress; + svn::ContextP m_CurrentContext; + svn::Client* m_Svnclient; + + svn::Revision urlToRev(const KURL&); + +}; + +KioSvnData::KioSvnData(tdeio_svnProtocol*par) + : m_Listener(par),first_done(false) +{ + m_Svnclient=svn::Client::getobject(0,0); + m_CurrentContext = 0; + dispProgress = false; + reInitClient(); +} + +void KioSvnData::reInitClient() +{ + if (first_done) { + return; + } + SshAgent ag; + ag.querySshAgent(); + + first_done = true; + m_CurrentContext = new svn::Context(); + m_CurrentContext->setListener(&m_Listener); + m_Svnclient->setContext(m_CurrentContext); +} + +KioSvnData::~KioSvnData() +{ + m_Listener.setCancel(true); + /* wait a little bit */ + sleep(1); + delete m_Svnclient; + m_CurrentContext->setListener(0L); + m_CurrentContext = 0; +} + +svn::Revision KioSvnData::urlToRev(const KURL&url) +{ + TQMap q = url.queryItems(); + + /* we try to check if it is ssh and try to get a password for it */ + TQString proto = url.protocol(); + + if (proto.find("ssh")!=-1) { + SshAgent ag; + ag.addSshIdentities(); + } + + svn::Revision rev,tmp; + rev = svn::Revision::UNDEFINED; + if (q.find("rev")!=q.end()) { + TQString v = q["rev"]; + m_Svnclient->url2Revision(v,rev,tmp); + } + return rev; +} + + +tdeio_svnProtocol::tdeio_svnProtocol(const TQCString &pool_socket, const TQCString &app_socket) + : SlaveBase("tdeio_ksvn", pool_socket, app_socket),StreamWrittenCb() +{ + m_pData=new KioSvnData(this); + TDEGlobal::locale()->insertCatalogue("tdesvn"); +} + +tdeio_svnProtocol::~tdeio_svnProtocol() +{ + kdDebug()<<"Delete kio protocol"<urlToRev(url); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + + try { + dlist = m_pData->m_Svnclient->list(makeSvnUrl(url),rev,rev,svn::DepthImmediates,false); + } catch (const svn::ClientException&e) { + TQString ex = e.msg(); + kdDebug()<name().isEmpty()) { + continue; + } + TQDateTime dt = svn::DateTime(dlist[i]->time()); + if (createUDSEntry(dlist[i]->name(), + dlist[i]->lastAuthor(), + dlist[i]->size(), + dlist[i]->kind()==svn_node_dir?true:false, + dt.toTime_t(), + entry) ) { + listEntry(entry,false); + } + entry.clear(); + } + listEntry(entry, true ); + finished(); +} + +void tdeio_svnProtocol::stat(const KURL& url) +{ + kdDebug()<<"tdeio_svn::stat "<< url << endl; + svn::Revision rev = m_pData->urlToRev(url); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + svn::Revision peg = rev; + bool dummy = false; + svn::InfoEntries e; + try { + e = m_pData->m_Svnclient->info(makeSvnUrl(url),svn::DepthEmpty,rev,peg); + } catch (const svn::ClientException&e) { + TQString ex = e.msg(); + kdDebug()<m_Listener.contextCancel()) { + finished(); + return; + } + svn::Revision rev = m_pData->urlToRev(url); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + KioByteStream dstream(this,url.filename()); + try { + m_pData->m_Svnclient->cat(dstream,makeSvnUrl(url),rev,rev); + } catch (const svn::ClientException&e) { + TQString ex = e.msg(); + kdDebug()<urlToRev(url); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + try { + svn::Path p(makeSvnUrl(url)); + m_pData->m_Svnclient->mkdir(p,getDefaultLog()); + }catch (const svn::ClientException&e) { + error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } + kdDebug()<<"tdeio_svn::mkdir finished " << url << endl; + finished(); +} + +void tdeio_svnProtocol::mkdir(const KURL::List &urls, int) +{ + svn::Pathes p; + for ( TQValueListConstIterator it = urls.begin(); it != urls.end() ; ++it ) { + p.append((*it).path()); + } + try { + m_pData->m_Svnclient->mkdir(svn::Targets(p),getDefaultLog()); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + finished(); +} + +void tdeio_svnProtocol::rename(const KURL&src,const KURL&target,bool force) +{ + kdDebug()<<"tdeio_svn::rename "<< src << " to " << target << endl; + TQString msg; + m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); + try { + m_pData->m_Svnclient->move(makeSvnUrl(src),makeSvnUrl(target),force); + }catch (const svn::ClientException&e) { + error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } + kdDebug()<<"tdeio_svn::rename finished" << endl; + finished(); +} + +void tdeio_svnProtocol::copy(const KURL&src,const KURL&dest,int permissions,bool overwrite) +{ + Q_UNUSED(permissions); + Q_UNUSED(overwrite); + kdDebug()<<"tdeio_svn::copy "<< src << " to " << dest << endl; + svn::Revision rev = m_pData->urlToRev(src); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + m_pData->dispProgress=true; + m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); + try { + m_pData->m_Svnclient->copy(makeSvnUrl(src),rev,makeSvnUrl(dest)); + }catch (const svn::ClientException&e) { + error( TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } + m_pData->dispProgress=false; + kdDebug()<<"tdeio_svn::copy finished" << endl; + finished(); +} + +void tdeio_svnProtocol::del(const KURL&src,bool isfile) +{ + Q_UNUSED(isfile); + kdDebug()<<"tdeio_svn::del "<< src << endl; + //m_pData->reInitClient(); + svn::Revision rev = m_pData->urlToRev(src); + if (rev == svn::Revision::UNDEFINED) { + rev = svn::Revision::HEAD; + } + m_pData->m_CurrentContext->setLogMessage(getDefaultLog()); + try { + svn::Targets target(makeSvnUrl(src)); + m_pData->m_Svnclient->remove(target,false); + } catch (const svn::ClientException&e) { + TQString ex = e.msg(); + kdDebug()<m_Listener.contextGetLogMessage(t,_items); +} + +bool tdeio_svnProtocol::checkWc(const KURL&url) +{ + if (url.isEmpty()||!url.isLocalFile()) return false; + svn::Revision peg(svn_opt_revision_unspecified); + svn::Revision rev(svn_opt_revision_unspecified); + svn::InfoEntries e; + try { + e = m_pData->m_Svnclient->info(url.prettyURL(),svn::DepthEmpty,rev,peg); + } catch (const svn::ClientException&e) { + if (SVN_ERR_WC_NOT_DIRECTORY==e.apr_err()) + { + return false; + } + return true; + } + return false; +} + +TQString tdeio_svnProtocol::makeSvnUrl(const KURL&url,bool check_Wc) +{ + TQString res; + TQString proto = svn::Url::transformProtokoll(url.protocol()); + if (proto=="file" && check_Wc) + { + if (checkWc(url)) + { + return url.path(); + } + } + + TQStringList s = TQStringList::split("://",res); + TQString base = url.path(); + TQString host = url.host(); + TQString user = (url.hasUser()?url.user()+(url.hasPass()?":"+url.pass():""):""); + if (host.isEmpty()) { + res=proto+"://"+base; + } else { + res = proto+"://"+(user.isEmpty()?"":user+"@")+host+base; + } + if (base.isEmpty()) { + throw svn::ClientException(TQString("'")+res+TQString("' is not a valid subversion url")); + } + return res; +} + +bool tdeio_svnProtocol::createUDSEntry( const TQString& filename, const TQString& user, long long int size, bool isdir, time_t mtime, TDEIO::UDSEntry& entry) +{ +#if 0 + kdDebug() << "MTime : " << ( long )mtime << endl; + kdDebug() << "UDS filename : " << filename << endl; + kdDebug()<< "UDS Size: " << size << endl; + kdDebug()<< "UDS Dir: " << isdir << endl; +#endif + TDEIO::UDSAtom atom; + atom.m_uds = TDEIO::UDS_NAME; + atom.m_str = filename; + entry.append( atom ); + + atom.m_uds = TDEIO::UDS_FILE_TYPE; + atom.m_long = isdir ? S_IFDIR : S_IFREG; + entry.append( atom ); + + atom.m_uds = TDEIO::UDS_ACCESS; + atom.m_long = isdir?0777:0666; + entry.append(atom); + + + atom.m_uds = TDEIO::UDS_SIZE; + atom.m_long = size; + entry.append( atom ); + + atom.m_uds = TDEIO::UDS_MODIFICATION_TIME; + atom.m_long = mtime; + entry.append( atom ); + + atom.m_uds = TDEIO::UDS_USER; + atom.m_str = user; + entry.append( atom ); + + return true; +} + +void tdeio_svnProtocol::special(const TQByteArray& data) +{ + kdDebug()<<"tdeio_svnProtocol::special"<> tmp; + kdDebug() << "tdeio_svnProtocol::special " << tmp << endl; + switch (tmp) { + case SVN_CHECKOUT: + { + KURL repository, wc; + int revnumber; + TQString revkind; + stream >> repository; + stream >> wc; + stream >> revnumber; + stream >> revkind; + kdDebug(0) << "tdeio_svnProtocol CHECKOUT from " << repository.url() << " to " << wc.url() << " at " << revnumber << " or " << revkind << endl; + checkout( repository, wc, revnumber, revkind ); + break; + } + case SVN_UPDATE: + { + KURL wc; + int revnumber; + TQString revkind; + stream >> wc; + stream >> revnumber; + stream >> revkind; + kdDebug(0) << "tdeio_svnProtocol UPDATE " << wc.url() << " at " << revnumber << " or " << revkind << endl; + update(wc, revnumber, revkind ); + break; + } + case SVN_COMMIT: + { + KURL::List wclist; + while ( !stream.atEnd() ) { + KURL tmp; + stream >> tmp; + wclist << tmp; + } + kdDebug(0) << "tdeio_svnProtocol COMMIT" << endl; + commit( wclist ); + break; + } + case SVN_LOG: + { + kdDebug(0) << "tdeio_svnProtocol LOG" << endl; + int revstart, revend; + TQString revkindstart, revkindend; + KURL::List targets; + stream >> revstart; + stream >> revkindstart; + stream >> revend; + stream >> revkindend; + while ( !stream.atEnd() ) { + KURL tmp; + stream >> tmp; + targets << tmp; + } + svnlog( revstart, revkindstart, revend, revkindend, targets ); + break; + } + case SVN_IMPORT: + { + KURL wc,repos; + stream >> repos; + stream >> wc; + kdDebug(0) << "tdeio_ksvnProtocol IMPORT" << endl; + import(repos,wc); + break; + } + case SVN_ADD: + { + KURL wc; + kdDebug(0) << "tdeio_ksvnProtocol ADD" << endl; + stream >> wc; + add(wc); + break; + } + case SVN_DEL: + { + KURL::List wclist; + while ( !stream.atEnd() ) { + KURL tmp; + stream >> tmp; + wclist << tmp; + } + wc_delete(wclist); + break; + } + case SVN_REVERT: + { + KURL::List wclist; + while ( !stream.atEnd() ) { + KURL tmp; + stream >> tmp; + wclist << tmp; + } + kdDebug(7128) << "tdeio_svnProtocol REVERT" << endl; + revert(wclist); + break; + } + case SVN_STATUS: + { + KURL wc; + bool checkRepos=false; + bool fullRecurse=false; + stream >> wc; + stream >> checkRepos; + stream >> fullRecurse; + kdDebug(0) << "tdeio_svnProtocol STATUS" << endl; + status(wc,checkRepos,fullRecurse); + break; + } + case SVN_MKDIR: + { + KURL::List list; + stream >> list; + kdDebug(0) << "tdeio_svnProtocol MKDIR" << endl; + mkdir(list,0); + break; + } + case SVN_RESOLVE: + { + KURL url; + bool recurse; + stream >> url; + stream >> recurse; + kdDebug(7128) << "tdeio_svnProtocol RESOLVE" << endl; + wc_resolve(url,recurse); + break; + } + case SVN_SWITCH: + { + KURL wc,url; + bool recurse; + int revnumber; + TQString revkind; + stream >> wc; + stream >> url; + stream >> recurse; + stream >> revnumber; + stream >> revkind; + kdDebug(7128) << "tdeio_svnProtocol SWITCH" << endl; + wc_switch(wc,url,recurse,revnumber,revkind); + break; + } + case SVN_DIFF: + { + KURL url1,url2; + int rev1, rev2; + bool recurse; + TQString revkind1, revkind2; + stream >> url1; + stream >> url2; + stream >> rev1; + stream >> revkind1; + stream >> rev2; + stream >> revkind2; + stream >> recurse; + diff(url1,url2,rev1,revkind1,rev2,revkind2,recurse); + break; + } + default: + {kdDebug()<<"Unknown special" << endl;} + } + finished(); +} + +void tdeio_svnProtocol::update(const KURL&url,int revnumber,const TQString&revkind) +{ + svn::Revision where(revnumber,revkind); + /* update is always local - so make a path instead URI */ + svn::Path p(url.path()); + try { + svn::Targets pathes(p.path()); + // always update externals, too. (third last parameter) + // no unversioned items allowed (second last parameter) + // sticky depth (last parameter) + m_pData->m_Svnclient->update(pathes, where,svn::DepthInfinity,false,false,true); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } +} + +void tdeio_svnProtocol::status(const KURL&wc,bool cR,bool rec) +{ + svn::Revision where = svn::Revision::UNDEFINED; + svn::StatusEntries dlist; + try { + // rec all up noign + dlist = m_pData->m_Svnclient->status(wc.path(),rec?svn::DepthInfinity:svn::DepthEmpty,false,cR,false,where); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + kdDebug()<<"Status got " << dlist.count() << " entries." << endl; + for (unsigned j=0;jm_Listener.counter()).rightJustify( 10,'0' )+"path",dlist[j]->path()); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"text",TQString::number(dlist[j]->textStatus())); + setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "prop", + TQString::number(dlist[j]->propStatus())); + setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "reptxt", + TQString::number(dlist[j]->reposTextStatus())); + setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "repprop", + TQString::number(dlist[j]->reposPropStatus())); + setMetaData(TQString::number(m_pData->m_Listener.counter() ).rightJustify( 10,'0' )+ "rev", + TQString::number(dlist[j]->entry().cmtRev())); + m_pData->m_Listener.incCounter(); + } +} + +void tdeio_svnProtocol::commit(const KURL::List&url) +{ + /// @todo replace with direct call to tdesvn? + TQByteArray reply; + TQByteArray params; + TQCString replyType; + TQString msg; + + if (!dcopClient()->call("kded","tdesvnd","get_logmsg()",params,replyType,reply)) { + msg = "Communication with dcop failed"; + kdWarning()<>lt; + if (lt.count()!=1) { + msg = "Wrong or missing log (may cancel pressed)."; + kdDebug()<< msg << endl; + return; + } + msg = lt[0]; + TQValueList targets; + for (unsigned j=0; jm_Svnclient->commit(svn::Targets(targets),msg,svn::DepthInfinity,false); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } + for (unsigned j=0;jm_Listener.counter()).rightJustify( 10,'0' )+ "path", url[j].path() ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "action", "0" ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "kind", "0" ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "mime_t", "" ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "content", "0" ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "prop", "0" ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev" , TQString::number(nnum) ); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "string", userstring ); + m_pData->m_Listener.incCounter(); + } +} + +void tdeio_svnProtocol::checkout(const KURL&src,const KURL&target,const int rev, const TQString&revstring) +{ + svn::Revision where(rev,revstring); + svn::Revision peg = svn::Revision::UNDEFINED; + svn::Path _target(target.path()); + try { + KURL _src = makeSvnUrl(src); + m_pData->m_Svnclient->checkout(_src.url(),_target,where,peg,svn::DepthInfinity,false,false); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } +} + +void tdeio_svnProtocol::svnlog(int revstart,const TQString&revstringstart,int revend, const TQString&revstringend, const KURL::List&urls) +{ + svn::Revision start(revstart,revstringstart); + svn::Revision end(revend,revstringend); + svn::LogEntriesPtr logs; + + for (unsigned j = 0; jm_Svnclient->log(makeSvnUrl(urls[j]),start,end,svn::Revision::UNDEFINED,true,true,0); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + break; + } + if (!logs) { + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify(10,'0')+"path",urls[j].path()); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify(10,'0')+"string", + i18n("Empty logs")); + m_pData->m_Listener.incCounter(); + continue; + } + for (unsigned int i = 0; i < logs->count();++i) { + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "path",urls[j].path()); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev", + TQString::number( (*logs)[i].revision)); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"author", + (*logs)[i].author); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+"logmessage", + (*logs)[i].message); + m_pData->m_Listener.incCounter(); + for (unsigned z = 0; z<(*logs)[i].changedPaths.count();++z) { + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "rev", + TQString::number( (*logs)[i].revision)); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "path",urls[j].path()); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedpath", + (*logs)[i].changedPaths[z].path); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedaction", + TQChar((*logs)[i].changedPaths[z].action)); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedcopyfrompath", + (*logs)[i].changedPaths[z].copyFromPath); + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "loggedcopyfromrevision", + TQString::number((*logs)[i].changedPaths[z].copyFromRevision)); + m_pData->m_Listener.incCounter(); + } + } + } +} + +void tdeio_svnProtocol::revert(const KURL::List&l) +{ + TQValueList list; + for (unsigned j=0; jm_Svnclient->revert(target,svn::DepthEmpty); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } +} + +void tdeio_svnProtocol::wc_switch(const KURL&wc,const KURL&target,bool rec,int rev,const TQString&revstring) +{ + svn::Revision where(rev,revstring); + svn::Path wc_path(wc.path()); + try { + m_pData->m_Svnclient->doSwitch(wc_path,makeSvnUrl(target.url()),where,rec?svn::DepthInfinity:svn::DepthFiles); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + } +} + +void tdeio_svnProtocol::diff(const KURL&uri1,const KURL&uri2,int rnum1,const TQString&rstring1,int rnum2, const TQString&rstring2,bool rec) +{ + TQByteArray ex; + /// @todo read settings for diff (ignore contentype) + try { + svn::Revision r1(rnum1,rstring1); + svn::Revision r2(rnum2,rstring2); + TQString u1 = makeSvnUrl(uri1,true); + TQString u2 = makeSvnUrl(uri2,true); + KTempDir tdir; + kdDebug() << "tdeio_ksvn::diff : " << u1 << " at revision " << r1.toString() << " with " + << u2 << " at revision " << r2.toString() + << endl ; + + tdir.setAutoDelete(true); + ex = m_pData->m_Svnclient->diff(svn::Path(tdir.name()), + u1,u2,svn::Path(),r1, r2,rec?svn::DepthInfinity:svn::DepthEmpty,false,false,false); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + TQString out = TQString::FROMUTF8(ex); + TQTextIStream stream(&out); + while (!stream.atEnd()) { + setMetaData(TQString::number(m_pData->m_Listener.counter()).rightJustify( 10,'0' )+ "diffresult",stream.readLine()); + m_pData->m_Listener.incCounter(); + } +} + +void tdeio_svnProtocol::import(const KURL& repos, const KURL& wc) +{ + try { + TQString target = makeSvnUrl(repos); + TQString path = wc.path(); + m_pData->m_Svnclient->import(svn::Path(path),target,TQString(),svn::DepthInfinity,false,false); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + finished(); +} + +void tdeio_svnProtocol::add(const KURL& wc) +{ + TQString path = wc.path(); + try { + /* rec */ + m_pData->m_Svnclient->add(svn::Path(path),svn::DepthInfinity); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + finished(); +} + +void tdeio_svnProtocol::wc_delete(const KURL::List&l) +{ + svn::Pathes p; + for ( TQValueListConstIterator it = l.begin(); it != l.end() ; ++it ) { + p.append((*it).path()); + } + try { + m_pData->m_Svnclient->remove(svn::Targets(p),false); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + finished(); +} + +void tdeio_svnProtocol::wc_resolve(const KURL&url,bool recurse) +{ + try { + svn::Depth depth=recurse?svn::DepthInfinity:svn::DepthEmpty; + m_pData->m_Svnclient->resolve(url.path(),depth); + } catch (const svn::ClientException&e) { + error(TDEIO::ERR_SLAVE_DEFINED,e.msg()); + return; + } + finished(); +} + +void tdeio_svnProtocol::streamWritten(const TDEIO::filesize_t current) +{ + processedSize(current); +} + +void tdeio_svnProtocol::streamSendMime(KMimeMagicResult* mt) +{ + if (mt) { + mimeType(mt->mimeType()); + } +} + +void tdeio_svnProtocol::streamPushData(TQByteArray array) +{ + data(array); +} + +void tdeio_svnProtocol::contextProgress(long long int current, long long int) +{ + if (m_pData->dispProgress) { + processedSize(current); + } +} + +void tdeio_svnProtocol::streamTotalSizeNull() +{ + totalSize(0); +} + + +/*! + \fn tdeio_svnProtocol::getDefaultLog() + */ +TQString tdeio_svnProtocol::getDefaultLog() +{ + TQString res = TQString(); + Kdesvnsettings::self()->readConfig(); + if (Kdesvnsettings::tdeio_use_standard_logmsg()) { + res = Kdesvnsettings::tdeio_standard_logmsg(); + } + return res; +} + +} // namespace TDEIO diff --git a/src/tdeiosvn/tdeiosvn.h b/src/tdeiosvn/tdeiosvn.h new file mode 100644 index 0000000..eca379a --- /dev/null +++ b/src/tdeiosvn/tdeiosvn.h @@ -0,0 +1,120 @@ +/*************************************************************************** + * Copyright (C) 2005-2007 by Rajko Albrecht * + * ral@alwins-world.de * + * * + * 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 KIOSVN_H +#define KIOSVN_H + +#include "kiobytestream.h" + +#include +#include +#include + +#include +#include + + +#include +#include + +namespace TDEIO +{ + +class KioSvnData; + +/** +@author Rajko Albrecht +*/ +class tdeio_svnProtocol : public TDEIO::SlaveBase,public StreamWrittenCb +{ +public: + tdeio_svnProtocol(const TQCString &pool_socket, const TQCString &app_socket); + virtual ~tdeio_svnProtocol(); + virtual void listDir (const KURL&url); + virtual void stat(const KURL& url); + virtual void get(const KURL& url); + virtual void mkdir (const KURL &url, int permissions); + virtual void mkdir (const KURL::List &urls, int permissions); + virtual void rename(const KURL&src,const KURL&target,bool force); + virtual void del(const KURL&url,bool isfile); + virtual void copy(const KURL&src,const KURL&dest,int permissions,bool overwrite); + virtual void checkout(const KURL&src,const KURL&target,const int rev, const TQString&revstring); + virtual void svnlog(int,const TQString&,int, const TQString&, const KURL::List&); + virtual void revert(const KURL::List&); + virtual void wc_switch(const KURL&,const KURL&,bool,int,const TQString&); + virtual void diff(const KURL&,const KURL&,int,const TQString&,int, const TQString&,bool); + virtual void import( const KURL& repos, const KURL& wc); + virtual void add(const KURL& wc); + virtual void wc_delete(const KURL::List&); + virtual void special(const TQByteArray& data); + virtual void wc_resolve(const KURL&,bool); + /* looked on kio::svn from tdesdk */ + enum KSVN_METHOD { + /* KURL repository, KURL target, int revnumber, TQString revkind */ + SVN_CHECKOUT = 1, + /* KURL wc, int revnumber, TQString revkind */ + /* refkind may empty or HEAD or START, will get parsed if revnumber is -1 */ + SVN_UPDATE = 2, + /* KURL::List */ + SVN_COMMIT = 3, + /* int revstart, TQString revstartstring, int revend, TQString revendstring, KURL::List */ + SVN_LOG=4, + SVN_IMPORT=5, + /* KURL */ + SVN_ADD=6, + /*KURL::List */ + SVN_DEL=7, + /* KURL::List */ + SVN_REVERT=8, + /* KURL wc,bool checkRepos, bool recurse */ + SVN_STATUS=9, + /* KURL::List */ + SVN_MKDIR=10, + /* KURL, bool */ + SVN_RESOLVE=11, + /* KURL working copy, KURL new_repository_url, bool recurse, int rev, TQString revstring */ + SVN_SWITCH=12, + /* KURL uri1, KURL uri2, int r1, TQString rstring1, int r2, TQString rstring 2, bool recursive */ + SVN_DIFF=13 + }; + + void contextProgress(long long int current, long long int max); + virtual void streamWritten(const TDEIO::filesize_t current); + virtual void streamPushData(TQByteArray); + virtual void streamSendMime(KMimeMagicResult*mt); + virtual void streamTotalSizeNull(); + +protected: + virtual void commit(const KURL::List&); + virtual void status(const KURL&,bool,bool); + virtual void update(const KURL&,int,const TQString&); + +private: + KioSvnData*m_pData; + bool createUDSEntry( const TQString& filename, const TQString& user, long long int size, bool isdir, time_t mtime, TDEIO::UDSEntry& entry); + TQString makeSvnUrl(const KURL&url,bool check_wc=true); + bool checkWc(const KURL&url); + bool getLogMsg(TQString&); +protected: + TQString getDefaultLog(); +}; + +} + +#endif -- cgit v1.2.1