summaryrefslogtreecommitdiff
path: root/patch/opensource/KDE-Ultracopier.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch/opensource/KDE-Ultracopier.patch')
-rw-r--r--patch/opensource/KDE-Ultracopier.patch290
1 files changed, 290 insertions, 0 deletions
diff --git a/patch/opensource/KDE-Ultracopier.patch b/patch/opensource/KDE-Ultracopier.patch
new file mode 100644
index 0000000..4130c08
--- /dev/null
+++ b/patch/opensource/KDE-Ultracopier.patch
@@ -0,0 +1,290 @@
+diff -U 3 -H -d -r -N -- kde-baseapps-4.8.4/lib/konq/CMakeLists.txt kde-baseapps-4.8.4-ultracopier/lib/konq/CMakeLists.txt
+--- kde-baseapps-4.8.4/lib/konq/CMakeLists.txt 2011-09-26 11:43:17.390868969 +0200
++++ kde-baseapps-4.8.4-ultracopier/lib/konq/CMakeLists.txt 2012-06-27 09:54:15.909492978 +0200
+@@ -9,6 +9,7 @@
+ include_directories( ${ZLIB_INCLUDE_DIR} )
+
+ set(konq_LIB_SRCS
++ ClientCatchcopy.cpp
+ konq_popupmenu.cpp # used by konqueror, kfind, folderview, kickoff
+ konq_popupmenuplugin.cpp # for KonqPopupMenu and its plugins
+ konq_dndpopupmenuplugin.cpp # for KonqDndPopupMenu and its plugins
+@@ -53,6 +54,7 @@
+
+ install( FILES directory_bookmarkbar.desktop DESTINATION ${DATA_INSTALL_DIR}/kbookmark )
+ install( FILES
++ ClientCatchcopy.h
+ konq_popupmenu.h
+ konq_popupmenuinformation.h
+ konq_popupmenuplugin.h
+diff -U 3 -H -d -r -N -- kde-baseapps-4.8.4/lib/konq/ClientCatchcopy.cpp kde-baseapps-4.8.4-ultracopier/lib/konq/ClientCatchcopy.cpp
+--- kde-baseapps-4.8.4/lib/konq/ClientCatchcopy.cpp 1970-01-01 01:00:00.000000000 +0100
++++ kde-baseapps-4.8.4-ultracopier/lib/konq/ClientCatchcopy.cpp 2012-06-27 10:28:25.049457581 +0200
+@@ -0,0 +1,142 @@
++/** \file ClientCatchcopy.cpp
++\brief Define the catchcopy client
++\author alpha_one_x86
++\version 0002
++\date 2010 */
++
++#include "ClientCatchcopy.h"
++
++ClientCatchcopy::ClientCatchcopy()
++{
++ disconnectedFromSocket();
++ connect(&socket, SIGNAL(disconnected()), this, SLOT(disconnectedFromSocket()));
++ connect(&socket, SIGNAL(readyRead()), this, SLOT(readyRead()));
++ connect(&socket, SIGNAL(connected()), this, SLOT(socketIsConnected()));
++}
++
++void ClientCatchcopy::socketIsConnected()
++{
++ sendProtocol();
++}
++
++void ClientCatchcopy::connectToServer()
++{
++ socket.connectToServer(pathSocket());
++ socket.waitForConnected();
++}
++
++const QString ClientCatchcopy::pathSocket()
++{
++#ifdef Q_OS_UNIX
++ return "advanced-copier-"+QString::number(getuid());
++#else
++ QString userName;
++ DWORD size=0;
++ if(GetUserNameW(NULL,&size) || (GetLastError()!=ERROR_INSUFFICIENT_BUFFER))
++ {
++ }
++ else
++ {
++ WCHAR * userNameW=new WCHAR[size];
++ if(GetUserNameW(userNameW,&size))
++ {
++ userName.fromWCharArray(userNameW,size*2);
++ userName=QString(QByteArray((char*)userNameW,size*2-2).toHex());
++ }
++ delete userNameW;
++ }
++ return "advanced-copier-"+userName;
++#endif
++}
++
++void ClientCatchcopy::disconnectFromServer()
++{
++ socket.abort();
++ socket.disconnectFromServer();
++}
++
++/// \brief to send stream of string list
++quint32 ClientCatchcopy::sendRawOrderList(const QStringList & order)
++{
++ if(!socket.isValid())
++ return -1;
++ if(socket.state()!=QLocalSocket::ConnectedState)
++ return -1;
++ idNextOrder++;
++ if(idNextOrder>2000000000)
++ idNextOrder=0;
++ QByteArray block;
++ QDataStream out(&block, QIODevice::WriteOnly);
++ out.setVersion(QDataStream::Qt_4_4);
++ out << int(0);
++ out << idNextOrder;
++ out << order;
++ out.device()->seek(0);
++ out << block.size();
++ do //cut string list and send it as block of 32KB
++ {
++ QByteArray blockToSend;
++ int byteWriten;
++ blockToSend=block.left(32*1024);//32KB
++ block.remove(0,blockToSend.size());
++ byteWriten = socket.write(blockToSend);
++ if(!socket.isValid())
++ return -1;
++ if(socket.errorString()!="Unknown error" && socket.errorString()!="")
++ return -1;
++ if(blockToSend.size()!=byteWriten)
++ return -1;
++ }
++ while(block.size());
++ return idNextOrder;
++}
++
++void ClientCatchcopy::readyRead()
++{
++ while(socket.bytesAvailable()>0)
++ {
++ socket.readAll();
++ }
++}
++
++void ClientCatchcopy::disconnectedFromSocket()
++{
++ idNextOrder = 0;
++}
++
++/// \brief to send the protocol version used
++void ClientCatchcopy::sendProtocol()
++{
++ sendRawOrderList(QStringList() << "protocol" << "0002");
++}
++
++void ClientCatchcopy::setClientName(const QString & name)
++{
++ sendRawOrderList(QStringList() << "client" << name);
++}
++
++bool ClientCatchcopy::addCopyWithDestination(const QStringList & sources,const QString & destination)
++{
++ if(socket.state()==QLocalSocket::UnconnectedState)
++ connectToServer();
++ if(socket.state()==QLocalSocket::ConnectedState)
++ {
++ sendRawOrderList(QStringList() << "cp" << sources << destination);
++ return true;
++ }
++ else
++ return false;
++}
++
++bool ClientCatchcopy::addMoveWithDestination(const QStringList & sources,const QString & destination)
++{
++ if(socket.state()==QLocalSocket::UnconnectedState)
++ connectToServer();
++ if(socket.state()==QLocalSocket::ConnectedState)
++ {
++ sendRawOrderList(QStringList() << "mv" << sources << destination);
++ return true;
++ }
++ else
++ return false;
++}
+diff -U 3 -H -d -r -N -- kde-baseapps-4.8.4/lib/konq/ClientCatchcopy.h kde-baseapps-4.8.4-ultracopier/lib/konq/ClientCatchcopy.h
+--- kde-baseapps-4.8.4/lib/konq/ClientCatchcopy.h 1970-01-01 01:00:00.000000000 +0100
++++ kde-baseapps-4.8.4-ultracopier/lib/konq/ClientCatchcopy.h 2012-06-27 10:28:52.169457112 +0200
+@@ -0,0 +1,58 @@
++/** \file ClientCatchcopy.h
++\brief Define the catchcopy client
++\author alpha_one_x86
++\version 0002
++\date 2010 */
++
++#ifndef CLIENTCATCHCOPY_H
++#define CLIENTCATCHCOPY_H
++
++#include <QObject>
++#include <QLocalSocket>
++#include <QStringList>
++#include <QString>
++#include <QByteArray>
++
++#ifdef Q_OS_UNIX
++ #include <unistd.h>
++ #include <sys/types.h>
++#else
++ #include <windows.h>
++#endif
++
++/// \brief Define the catchcopy client
++class ClientCatchcopy : public QObject
++{
++ Q_OBJECT
++ public:
++ ClientCatchcopy();
++ public slots:
++ void connectToServer();
++ void disconnectFromServer();
++ //to test and internal use
++ /// \brief set the client name
++ void setClientName(const QString & name);
++ /// \brief add copy with destination
++ bool addCopyWithDestination(const QStringList & sources,const QString & destination);
++ /// \brief add move with destination
++ bool addMoveWithDestination(const QStringList & sources,const QString & destination);
++ private:
++ /// \brief to send order
++ void sendProtocol();
++
++ const QString pathSocket();
++ quint32 idNextOrder;
++ //the local socket
++ QLocalSocket socket;
++
++ /// \brief to send stream of string list
++ quint32 sendRawOrderList(const QStringList & order);
++ private slots:
++ void readyRead();
++ void disconnectedFromSocket();
++ void socketIsConnected();
++ protected:
++ bool parseReply(quint32 orderId,quint32 returnCode,QStringList returnList);
++};
++
++#endif // CLIENTCATCHCOPY_H
+diff -U 3 -H -d -r -N -- kde-baseapps-4.8.4/lib/konq/konq_operations.cpp kde-baseapps-4.8.4-ultracopier/lib/konq/konq_operations.cpp
+--- kde-baseapps-4.8.4/lib/konq/konq_operations.cpp 2011-09-26 11:43:17.392868951 +0200
++++ kde-baseapps-4.8.4-ultracopier/lib/konq/konq_operations.cpp 2012-06-27 10:29:32.879456409 +0200
+@@ -154,6 +154,8 @@
+ }
+ }
+
++ClientCatchcopy KonqOperations::clientCatchcopy;
++
+ void KonqOperations::copy( QWidget * parent, Operation method, const KUrl::List & selectedUrls, const KUrl& destUrl )
+ {
+ kDebug(1203) << parent->metaObject()->className() << selectedUrls << destUrl;
+@@ -175,7 +177,30 @@
+ else if (method == MOVE)
+ job = KIO::move( selectedUrls, destUrl );
+ else
++ {
++ QStringList selectedFiles;
++ bool isLocal=true;
++ int index=0;
++ while(index<selectedUrls.size())
++ {
++ if(!selectedUrls.at(index).isLocalFile())
++ {
++ isLocal=false;
++ break;
++ }
++ selectedFiles << selectedUrls.at(index).toLocalFile();
++ index++;
++ }
++ isLocal&=destUrl.isLocalFile();
++ if(isLocal)
++ {
++ if(clientCatchcopy.addCopyWithDestination(selectedFiles,destUrl.toLocalFile()))
++ return;
++ }
++ else
+ job = KIO::copy( selectedUrls, destUrl );
++
++ }
+
+ op->setOperation( job, method, destUrl );
+
+diff -U 3 -H -d -r -N -- kde-baseapps-4.8.4/lib/konq/konq_operations.h kde-baseapps-4.8.4-ultracopier/lib/konq/konq_operations.h
+--- kde-baseapps-4.8.4/lib/konq/konq_operations.h 2011-07-27 20:36:39.112044764 +0200
++++ kde-baseapps-4.8.4-ultracopier/lib/konq/konq_operations.h 2012-06-27 09:31:29.109516591 +0200
+@@ -23,6 +23,8 @@
+ #ifndef __konq_operations_h__
+ #define __konq_operations_h__
+
++#include "ClientCatchcopy.h"
++
+ #include <kurl.h>
+ #include <libkonq_export.h>
+
+@@ -221,6 +223,7 @@
+
+ private:
+ QWidget* parentWidget() const;
++ static ClientCatchcopy clientCatchcopy;
+ void _del( Operation method, const KUrl::List & selectedUrls, ConfirmationType confirmation );
+ void _restoreTrashedItems( const KUrl::List& urls );
+ void _statUrl( const KUrl & url, const QObject *receiver, const char *member );