This allows unidirectional and bidirectional file transfer via rsync and unison, respectively git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1252392 283d02a7-25f6-0310-bc7c-ecb5cbfe19dav3.5.13-sru
parent
5c83bfc539
commit
e7e6e20dfe
@ -0,0 +1,50 @@
|
||||
#################################################
|
||||
#
|
||||
# (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}
|
||||
${CMAKE_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}/kdecore
|
||||
${CMAKE_SOURCE_DIR}/dcop
|
||||
${CMAKE_SOURCE_DIR}/kdecore
|
||||
${CMAKE_SOURCE_DIR}/kdeui
|
||||
${CMAKE_SOURCE_DIR}/kdefx
|
||||
${CMAKE_SOURCE_DIR}/kio
|
||||
${CMAKE_SOURCE_DIR}/kio/kio
|
||||
)
|
||||
|
||||
link_directories(
|
||||
${TQT_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
|
||||
##### headers ###################################
|
||||
|
||||
install( FILES
|
||||
krsync.h
|
||||
DESTINATION ${INCLUDE_INSTALL_DIR}/libkrsync )
|
||||
|
||||
|
||||
##### krandr ####################################
|
||||
|
||||
set( target krsync )
|
||||
|
||||
set( ${target}_SRCS
|
||||
krsync.cpp rsyncconfigdialog.cpp
|
||||
)
|
||||
|
||||
tde_add_library( ${target} SHARED AUTOMOC
|
||||
SOURCES ${${target}_SRCS}
|
||||
VERSION 0.0.1
|
||||
LINK kdeui-shared kio-shared
|
||||
DESTINATION ${LIB_INSTALL_DIR}
|
||||
)
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,134 @@
|
||||
/*
|
||||
Copyright (C) 2000, 2001, 2002 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _LIBKRSYNC_H
|
||||
#define _LIBKRSYNC_H
|
||||
|
||||
#include <tqmap.h>
|
||||
#include <tqstringlist.h>
|
||||
|
||||
#include <kurl.h>
|
||||
#include <kprocess.h>
|
||||
#include <kfileitem.h>
|
||||
#include <klibloader.h>
|
||||
#include <kparts/plugin.h>
|
||||
#include <kio/global.h>
|
||||
#include <kio/slavebase.h>
|
||||
|
||||
class KActionMenu;
|
||||
class KonqDirPart;
|
||||
class KLineEdit;
|
||||
class RsyncConfigDialog;
|
||||
|
||||
namespace KParts
|
||||
{
|
||||
struct URLArgs;
|
||||
}
|
||||
|
||||
class KRsync : public TQObject
|
||||
{
|
||||
Q_OBJECT
|
||||
TQ_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
KRsync (TQObject* parent, const char* name);
|
||||
virtual ~KRsync();
|
||||
|
||||
public:
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
TQString findLocalFolderByName(TQString folderurl);
|
||||
TQString findLoginSyncEnabledByName(TQString folderurl);
|
||||
TQString findLogoutSyncEnabledByName(TQString folderurl);
|
||||
TQString findTimedSyncEnabledByName(TQString folderurl);
|
||||
int deleteLocalFolderByName(TQString folderurl);
|
||||
int addLocalFolderByName(TQString folderurl, TQString remoteurl, TQString syncmethod, TQString excludelist, TQString sync_on_login, TQString sync_on_logout, TQString sync_timed_interval);
|
||||
TQString findSyncMethodByName(TQString folderurl);
|
||||
/** manages initial communication setup including password queries */
|
||||
int establishConnectionRsync(char *buffer, KIO::fileoffset_t len);
|
||||
/** manages initial communication setup including password queries */
|
||||
int establishConnectionUnison(char *buffer, KIO::fileoffset_t len, TQString localfolder, TQString remotepath);
|
||||
/** creates the unidirectional sync subprocess */
|
||||
bool syncUnidirectional(TQString synccommand, TQString syncflags, int parameter_order, TQString localfolder, TQString remotepath);
|
||||
/** creates the bidirectional sync subprocess */
|
||||
bool syncBidirectional(TQString synccommand, TQString syncflags, int parameter_order, TQString localfolder, TQString remotepath);
|
||||
/** writes one chunk of data to stdin of child process */
|
||||
void writeChild(const char *buf, KIO::fileoffset_t len);
|
||||
/** AuthInfo object used for logging in */
|
||||
KIO::AuthInfo connectionAuth;
|
||||
/**
|
||||
Clean up connection
|
||||
*/
|
||||
void shutdownConnection(bool forced=false, bool wait=false);
|
||||
/** Forced close of the connection */
|
||||
void closeConnection();
|
||||
/** Set current local directory URL */
|
||||
void setCurrentDirectoryURL(KURL url);
|
||||
|
||||
public slots:
|
||||
void slotSync();
|
||||
void slotSetup();
|
||||
void slotSetupOK();
|
||||
void slotSetupCancelled();
|
||||
void slotRsyncCancelled();
|
||||
void slotUnisonCancelled();
|
||||
|
||||
signals:
|
||||
void setupDone();
|
||||
void transferDone();
|
||||
|
||||
private:
|
||||
KURL m_pURL;
|
||||
KProgressBoxDialog* m_progressDialog;
|
||||
RsyncConfigDialog* m_configDialog;
|
||||
|
||||
TQStringList cfgfolderlist;
|
||||
TQStringList cfgautosync_onlogout_list;
|
||||
bool m_progressDialogExists;
|
||||
|
||||
bool m_bSettingsLoaded;
|
||||
|
||||
/** true if connection is logged in successfully */
|
||||
bool isLoggedIn;
|
||||
/** the rsync process used to communicate with the remote end */
|
||||
pid_t childPid;
|
||||
/** fd for reading and writing to the process */
|
||||
int childFd;
|
||||
/** buffer for data to be written */
|
||||
const char *outBuf;
|
||||
/** current write position in buffer */
|
||||
KIO::fileoffset_t outBufPos;
|
||||
/** length of buffer */
|
||||
KIO::fileoffset_t outBufLen;
|
||||
/** use su if true else use ssh */
|
||||
//bool local;
|
||||
/** // FIXME: just a workaround for konq deficiencies */
|
||||
bool isStat;
|
||||
/** // FIXME: just a workaround for konq deficiencies */
|
||||
TQString redirectUser, redirectPass;
|
||||
/** user name of current connection */
|
||||
TQString connectionUser;
|
||||
/** password of current connection */
|
||||
TQString connectionPassword;
|
||||
/** true if this is the first login attempt (== use cached password) */
|
||||
bool firstLogin;
|
||||
|
||||
TQString thisFn;
|
||||
};
|
||||
#endif
|
@ -0,0 +1,205 @@
|
||||
/*
|
||||
Copyright (C) 2000, 2001, 2002 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
#include <errno.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define HAVE_TERMIOS_H 1
|
||||
#define HAVE_GRANTPT 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#ifdef HAVE_PTY_H
|
||||
#include <pty.h>
|
||||
#endif
|
||||
#ifdef HAVE_TERMIOS_H
|
||||
#include <termios.h>
|
||||
#endif
|
||||
#ifdef HAVE_STROPTS
|
||||
#include <stropts.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
#ifdef HAVE_LIBUTIL_H
|
||||
#include <libutil.h>
|
||||
#endif
|
||||
#ifdef HAVE_UTIL_H
|
||||
#include <util.h>
|
||||
#endif
|
||||
|
||||
#include <tqfile.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqapplication.h>
|
||||
#include <tqpushbutton.h>
|
||||
#include <tqhbox.h>
|
||||
#include <tqwhatsthis.h>
|
||||
#include <tqiconview.h>
|
||||
#include <tqpainter.h>
|
||||
#include <tqpixmap.h>
|
||||
#include <tqlabel.h>
|
||||
#include <tqlayout.h>
|
||||
#include <tqpushbutton.h>
|
||||
#include <tqstring.h>
|
||||
#include <tqregexp.h>
|
||||
#include <tqstyle.h>
|
||||
#include <tqtimer.h>
|
||||
#include <tqgroupbox.h>
|
||||
#include <tqradiobutton.h>
|
||||
#include <tqbuttongroup.h>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <kinstance.h>
|
||||
|
||||
#include <kwin.h>
|
||||
#include <kaction.h>
|
||||
#include <kpopupmenu.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kiconloader.h>
|
||||
#include <kprogressbox.h>
|
||||
#include <kpassdlg.h>
|
||||
#include <klistview.h>
|
||||
#include <kapplication.h>
|
||||
#include <kconfigdialog.h>
|
||||
|
||||
#include <kdirlister.h>
|
||||
#include <kstandarddirs.h>
|
||||
#include <klistviewsearchline.h>
|
||||
#include <kiconviewsearchline.h>
|
||||
#include <kstaticdeleter.h>
|
||||
#include <kgenericfactory.h>
|
||||
#include <kparts/browserextension.h>
|
||||
|
||||
#include "rsyncconfigdialog.h"
|
||||
|
||||
/*
|
||||
* RsyncConfigDialog implementation
|
||||
*/
|
||||
RsyncConfigDialog::RsyncConfigDialog(TQWidget* parent, const char* name,
|
||||
const TQString& caption, const TQString& text,
|
||||
const TQString& localfolder, const TQString& remotefolder,
|
||||
int syncmode, bool modal)
|
||||
: KDialogBase(KDialogBase::Plain, caption, KDialogBase::Cancel | KDialogBase::Ok,
|
||||
KDialogBase::Ok, parent, name, modal),
|
||||
mAutoClose(true),
|
||||
mAutoReset(false),
|
||||
mCancelled(false),
|
||||
mAllowCancel(true),
|
||||
mAllowTextEdit(false),
|
||||
mShown(false),
|
||||
mSyncAutoLogout(false)
|
||||
{
|
||||
#ifdef TQ_WS_X11
|
||||
KWin::setIcons(winId(), kapp->icon(), kapp->miniIcon());
|
||||
#endif
|
||||
mShowTimer = new TQTimer(this);
|
||||
|
||||
showButton(KDialogBase::Close, false);
|
||||
mCancelText = actionButton(KDialogBase::Cancel)->text();
|
||||
|
||||
TQFrame* mainWidget = plainPage();
|
||||
TQVBoxLayout* tqlayout = new TQVBoxLayout(mainWidget, 10);
|
||||
mLabel = new TQLabel(TQString("<b>") + text + TQString("</b><br>")+i18n("Setting up synchronization for local folder")+TQString("<br><i>") + localfolder, mainWidget);
|
||||
tqlayout->addWidget(mLabel);
|
||||
|
||||
// Create an exclusive button group
|
||||
TQButtonGroup *layoutg = new TQButtonGroup( 1, Qt::Horizontal, i18n("Synchronization Method")+TQString(":"), mainWidget);
|
||||
tqlayout->addWidget( layoutg );
|
||||
layoutg->setExclusive( TRUE );
|
||||
|
||||
// Insert radiobuttons
|
||||
rsync_rb1 = new TQRadioButton(i18n("&Utilize rsync + ssh for upload to remote server\nExample: servername:/path/to/remote/folder"), layoutg);
|
||||
rsync_rb2 = new TQRadioButton(i18n("&Utilize rsync + ssh for download from remote server\nExample: servername:/path/to/remote/folder"), layoutg);
|
||||
rsync_rb3 = new TQRadioButton(i18n("&Utilize unison + ssh for bidirectional synchronization with remote server\nExample: ssh://servername//path/to/remote/folder"), layoutg);
|
||||
|
||||
if (syncmode == 1)
|
||||
rsync_rb1->setChecked( TRUE );
|
||||
else if (syncmode == 2)
|
||||
rsync_rb2->setChecked( TRUE );
|
||||
else if (syncmode == 3)
|
||||
rsync_rb3->setChecked( TRUE );
|
||||
|
||||
//(void)new TQRadioButton( "R&adiobutton 2", layoutg );
|
||||
//(void)new TQRadioButton( "Ra&diobutton 3", layoutg );
|
||||
|
||||
// Create an exclusive button group
|
||||
TQButtonGroup *layoutm = new TQButtonGroup( 1, Qt::Horizontal, i18n("Remote Folder")+TQString(":"), mainWidget);
|
||||
tqlayout->addWidget( layoutm );
|
||||
layoutg->setExclusive( TRUE );
|
||||
|
||||
m_rsync_txt = new TQLineEdit(layoutm);
|
||||
if (remotefolder.isEmpty() == false) {
|
||||
m_rsync_txt->setText(remotefolder);
|
||||
}
|
||||
|
||||
// Create an exclusive button group
|
||||
TQButtonGroup *layouta = new TQButtonGroup( 1, Qt::Horizontal, i18n("Automatic Synchronization")+TQString(":"), mainWidget);
|
||||
tqlayout->addWidget( layouta );
|
||||
layouta->setExclusive( FALSE );
|
||||
|
||||
m_sync_auto_logout_cb = new TQCheckBox(layouta);
|
||||
m_sync_auto_logout_cb->setText(i18n("Synchronize on logout"));
|
||||
m_sync_auto_logout_cb->setChecked(mSyncAutoLogout);
|
||||
|
||||
setFixedSize( sizeHint() );
|
||||
|
||||
m_rsync_txt->setFocus();
|
||||
}
|
||||
|
||||
int RsyncConfigDialog::getSyncMode()
|
||||
{
|
||||
if (rsync_rb1->isChecked() == true)
|
||||
return 1;
|
||||
else if (rsync_rb2->isChecked() == true)
|
||||
return 2;
|
||||
else if (rsync_rb3->isChecked() == true)
|
||||
return 3;
|
||||
}
|
||||
|
||||
int RsyncConfigDialog::getAutoSyncFlags()
|
||||
{
|
||||
int flags = 0;
|
||||
if (m_sync_auto_logout_cb->isChecked() == true)
|
||||
flags = flags | 0x1;
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
void RsyncConfigDialog::setAutoSyncFlags(int flags) {
|
||||
m_sync_auto_logout_cb->setChecked((flags & 0x1) != 0);
|
||||
}
|
||||
|
||||
TQLineEdit* RsyncConfigDialog::lineEdit()
|
||||
{
|
||||
return m_rsync_txt;
|
||||
}
|
||||
|
||||
const TQLineEdit* RsyncConfigDialog::lineEdit() const
|
||||
{
|
||||
return m_rsync_txt;
|
||||
}
|
||||
|
||||
#include "rsyncconfigdialog.moc"
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
Copyright (C) 2000, 2001, 2002 Dawit Alemayehu <adawit@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License version 2 as published by the Free Software Foundation.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public License
|
||||
along with this library; see the file COPYING.LIB. If not, write to
|
||||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef __RSYNC_CONFIG_DIALOG_H
|
||||
#define __RSYNC_CONFIG_DIALOG_H
|
||||
|
||||
#include <tqmap.h>
|
||||
#include <tqstringlist.h>
|
||||
#include <tqlineedit.h>
|
||||
#include <tqcheckbox.h>
|
||||
#include <tqradiobutton.h>
|
||||
|
||||
#include <kurl.h>
|
||||
#include <kprocess.h>
|
||||
#include <kfileitem.h>
|
||||
#include <klibloader.h>
|
||||
#include <kdialogbase.h>
|
||||
|
||||
// NOTE: If ANY of these functions are not utilized in the C file,
|
||||
// and in a manner identical to these declarations, the plugin will
|
||||
// mysteriously fail when launched with kshell but work fine under BASH
|
||||
|
||||
class RsyncConfigDialog : public KDialogBase
|
||||
{
|
||||
Q_OBJECT
|
||||
TQ_OBJECT
|
||||
|
||||
public:
|
||||
RsyncConfigDialog(TQWidget* parent = 0, const char* name = 0,
|
||||
const TQString& caption = TQString(),
|
||||
const TQString& text = TQString(),
|
||||
const TQString& localfolder = TQString(),
|
||||
const TQString& remotefolder = TQString(),
|
||||
int syncmode = 1, bool modal = false);
|
||||
|
||||
/**
|
||||
* Returns the TQLineEdit used in this dialog.
|
||||
* To set the number of lines or other text box related
|
||||
* settings, access the KTextEdit object directly via this method.
|
||||
*/
|
||||
TQLineEdit* lineEdit();
|
||||
|
||||
/**
|
||||
* Returns the TQLineEdit used in this dialog.
|
||||
* To set the number of lines or other text box related
|
||||
* settings, access the KTextEdit object directly via this method.
|
||||
*/
|
||||
const TQLineEdit* lineEdit() const;
|
||||
|
||||
/**
|
||||
* Returns index of selected synchronization mode
|
||||
* 1: Upload
|
||||
* 2: Download
|
||||
* 3: Bidirectional
|
||||
*/
|
||||
int getSyncMode();
|
||||
|
||||
/**
|
||||
* Returns the selected autosync flags
|
||||
* Bit 0: Sync on logout
|
||||
*/
|
||||
int getAutoSyncFlags();
|
||||
|
||||
/**
|
||||
* Sets the selected autosync flags
|
||||
*
|
||||
* @see getAutoSyncFlags()
|
||||
*/
|
||||
void setAutoSyncFlags(int flags);
|
||||
|
||||
private:
|
||||
bool mAutoClose;
|
||||
bool mAutoReset;
|
||||
bool mCancelled;
|
||||
bool mAllowCancel;
|
||||
bool mAllowTextEdit;
|
||||
bool mShown;
|
||||
bool mSyncAutoLogout;
|
||||
TQString mCancelText;
|
||||
TQLabel* mLabel;
|
||||
KProgress* mProgressBar;
|
||||
KTextEdit* mTextBox;
|
||||
TQTimer* mShowTimer;
|
||||
TQLineEdit* m_rsync_txt;
|
||||
TQCheckBox* m_sync_auto_logout_cb;
|
||||
TQRadioButton *rsync_rb1;
|
||||
TQRadioButton *rsync_rb2;
|
||||
TQRadioButton *rsync_rb3;
|
||||
};
|
||||
#endif
|
Loading…
Reference in new issue