summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 11:49:27 -0500
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2013-07-24 11:49:27 -0500
commitc3f8ee64e905cdb103b5bfa07525fb4e85c31120 (patch)
tree46eabe44a1b3af79971dcafb743a104af8e18e69 /src
downloadkasablanca-c3f8ee64e905cdb103b5bfa07525fb4e85c31120.tar.gz
kasablanca-c3f8ee64e905cdb103b5bfa07525fb4e85c31120.zip
Initial import of kasablanca 0.4.0.2
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am37
-rw-r--r--src/Q_bookmarkdialog.cpp214
-rwxr-xr-xsrc/Q_bookmarkdialog.ui420
-rw-r--r--src/Q_colorspreferencesdialog.cpp100
-rw-r--r--src/Q_colorspreferencesdialog.ui131
-rw-r--r--src/Q_customconnectdialog.cpp180
-rwxr-xr-xsrc/Q_customconnectdialog.ui328
-rw-r--r--src/Q_fileexistsdialog.cpp111
-rw-r--r--src/Q_fileexistsdialog.ui118
-rw-r--r--src/Q_generalpreferencesdialog.cpp176
-rw-r--r--src/Q_generalpreferencesdialog.ui284
-rw-r--r--src/Q_importdialog.cpp70
-rw-r--r--src/Q_importdialog.ui49
-rw-r--r--src/Q_mainwindow.cpp185
-rwxr-xr-xsrc/Q_mainwindow.ui380
-rw-r--r--src/Q_userinterfacepreferencesdialog.cpp102
-rw-r--r--src/Q_userinterfacepreferencesdialog.ui142
-rw-r--r--src/about.pngbin0 -> 9961 bytes
-rw-r--r--src/bookmarkdialog.cpp210
-rw-r--r--src/bookmarkdialog.h56
-rwxr-xr-xsrc/customconnectdialog.cpp74
-rwxr-xr-xsrc/customconnectdialog.h47
-rw-r--r--src/eventhandler.cpp301
-rw-r--r--src/eventhandler.h126
-rw-r--r--src/fileexistsdialog.cpp44
-rw-r--r--src/fileexistsdialog.h47
-rwxr-xr-xsrc/ftplib.cpp1562
-rwxr-xr-xsrc/ftplib.h161
-rw-r--r--src/ftpsession.cpp1189
-rw-r--r--src/ftpsession.h165
-rw-r--r--src/ftpthread.cpp1437
-rw-r--r--src/ftpthread.h156
-rw-r--r--src/hi128-app-kasablanca.pngbin0 -> 9133 bytes
-rw-r--r--src/hi16-app-kasablanca.pngbin0 -> 858 bytes
-rw-r--r--src/hi22-app-kasablanca.pngbin0 -> 1252 bytes
-rw-r--r--src/hi32-app-kasablanca.pngbin0 -> 2004 bytes
-rw-r--r--src/hi48-app-kasablanca.pngbin0 -> 3058 bytes
-rw-r--r--src/hi64-app-kasablanca.pngbin0 -> 4241 bytes
-rw-r--r--src/importdialog.cpp177
-rw-r--r--src/importdialog.h40
-rw-r--r--src/kasablanca.cpp632
-rw-r--r--src/kasablanca.desktop26
-rw-r--r--src/kasablanca.h130
-rw-r--r--src/kasablanca.lsm16
-rw-r--r--src/kasablancaui.rc13
-rw-r--r--src/kbbookmarkitem.cpp26
-rw-r--r--src/kbbookmarkitem.h33
-rw-r--r--src/kbconfig.cpp100
-rw-r--r--src/kbconfig.kcfg73
-rw-r--r--src/kbconfig.kcfgc4
-rwxr-xr-xsrc/kbdir.cpp60
-rwxr-xr-xsrc/kbdir.h36
-rw-r--r--src/kbdirinfo.cpp53
-rw-r--r--src/kbdirinfo.h41
-rwxr-xr-xsrc/kbfile.cpp59
-rwxr-xr-xsrc/kbfile.h38
-rw-r--r--src/kbfileinfo.cpp85
-rw-r--r--src/kbfileinfo.h46
-rw-r--r--src/kbitem.cpp76
-rw-r--r--src/kbitem.h50
-rw-r--r--src/kbsiteinfo.cpp194
-rw-r--r--src/kbsiteinfo.h65
-rw-r--r--src/kbstatustip.cpp35
-rw-r--r--src/kbstatustip.h28
-rw-r--r--src/kbtaskview.cpp64
-rw-r--r--src/kbtaskview.h33
-rw-r--r--src/kbtransferdir.cpp51
-rw-r--r--src/kbtransferdir.h39
-rw-r--r--src/kbtransferfile.cpp120
-rw-r--r--src/kbtransferfile.h48
-rw-r--r--src/kbtransferitem.cpp83
-rw-r--r--src/kbtransferitem.h79
-rw-r--r--src/main.cpp72
73 files changed, 11327 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..f5b103d
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,37 @@
+# set the include path for X, qt and KDE
+INCLUDES = $(all_includes)
+
+# these are the headers for your project
+noinst_HEADERS = kasablanca.h bookmarkdialog.h customconnectdialog.h fileexistsdialog.h kbitem.h ftplib.h ftpsession.h kbfileinfo.h kbdirinfo.h kbtransferitem.h kbtransferdir.h kbtransferfile.h kbtaskview.h kbbookmarkitem.h kbsiteinfo.h importdialog.h kbstatustip.h
+
+# let automoc handle all of the meta source files (moc)
+METASOURCES = AUTO
+
+messages: rc.cpp
+ $(XGETTEXT) *.cpp -o $(podir)/kasablanca.pot
+
+KDE_ICON = kasablanca
+
+#########################################################################
+# APPLICATION SECTION
+#########################################################################
+# this is the program that gets installed. it's name is used for all
+# of the other Makefile.am variables
+bin_PROGRAMS = kasablanca
+
+# the application source, library search path, and link libraries
+kasablanca_SOURCES = main.cpp kasablanca.cpp bookmarkdialog.cpp customconnectdialog.cpp fileexistsdialog.cpp kbitem.cpp Q_bookmarkdialog.ui Q_fileexistsdialog.ui Q_mainwindow.ui eventhandler.cpp ftpthread.cpp ftplib.cpp ftpsession.cpp kbfileinfo.cpp kbdirinfo.cpp kbdir.cpp kbfile.cpp kbtransferitem.cpp kbtransferdir.cpp kbtransferfile.cpp kbconfig.kcfgc Q_colorspreferencesdialog.ui Q_generalpreferencesdialog.ui kbtaskview.cpp Q_userinterfacepreferencesdialog.ui kbbookmarkitem.cpp kbsiteinfo.cpp Q_customconnectdialog.ui Q_importdialog.ui importdialog.cpp kbstatustip.cpp
+kasablanca_LDFLAGS = $(KDE_RPATH) $(all_libraries)
+kasablanca_LDADD = -lssl $(LIB_KDEUI)
+
+# this is where the desktop file will go
+shelldesktopdir = $(kde_appsdir)/Utilities
+shelldesktop_DATA = kasablanca.desktop
+
+# this is where the shell's XML-GUI resource file goes
+shellrcdir = $(kde_datadir)/kasablanca
+shellrc_DATA = kasablancaui.rc about.png
+
+# this is the config xml
+kde_kcfg_DATA=kbconfig.kcfg
+
diff --git a/src/Q_bookmarkdialog.cpp b/src/Q_bookmarkdialog.cpp
new file mode 100644
index 0000000..4e60db1
--- /dev/null
+++ b/src/Q_bookmarkdialog.cpp
@@ -0,0 +1,214 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_bookmarkdialog.ui'
+**
+** Created: Mo Jan 31 15:02:05 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_bookmarkdialog.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qsplitter.h>
+#include <qheader.h>
+#include <klistview.h>
+#include <qtabwidget.h>
+#include <klineedit.h>
+#include <qlabel.h>
+#include <kcombobox.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaBookmarkDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KasablancaBookmarkDialog::KasablancaBookmarkDialog( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KasablancaBookmarkDialog" );
+ setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );
+ KasablancaBookmarkDialogLayout = new QGridLayout( this, 1, 1, 2, 6, "KasablancaBookmarkDialogLayout");
+
+ splitter1 = new QSplitter( this, "splitter1" );
+ splitter1->setOrientation( QSplitter::Horizontal );
+
+ BookmarkListView = new KListView( splitter1, "BookmarkListView" );
+ BookmarkListView->addColumn( tr2i18n( "Name" ) );
+ BookmarkListView->header()->setClickEnabled( FALSE, BookmarkListView->header()->count() - 1 );
+ BookmarkListView->setMinimumSize( QSize( 0, 0 ) );
+ BookmarkListView->setAcceptDrops( TRUE );
+ BookmarkListView->setDragEnabled( TRUE );
+
+ SettingsTab = new QTabWidget( splitter1, "SettingsTab" );
+ SettingsTab->setEnabled( TRUE );
+ SettingsTab->setMinimumSize( QSize( 360, 232 ) );
+
+ tab = new QWidget( SettingsTab, "tab" );
+ tabLayout = new QGridLayout( tab, 1, 1, 2, 6, "tabLayout");
+
+ PassEdit = new KLineEdit( tab, "PassEdit" );
+ PassEdit->setEnabled( FALSE );
+ PassEdit->setEchoMode( KLineEdit::Password );
+
+ tabLayout->addMultiCellWidget( PassEdit, 3, 3, 1, 2 );
+
+ UserEdit = new KLineEdit( tab, "UserEdit" );
+ UserEdit->setEnabled( FALSE );
+
+ tabLayout->addMultiCellWidget( UserEdit, 2, 2, 1, 2 );
+
+ InfoEdit = new KLineEdit( tab, "InfoEdit" );
+ InfoEdit->setEnabled( FALSE );
+
+ tabLayout->addMultiCellWidget( InfoEdit, 1, 1, 1, 2 );
+
+ NameEdit = new KLineEdit( tab, "NameEdit" );
+ NameEdit->setEnabled( FALSE );
+ NameEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, NameEdit->sizePolicy().hasHeightForWidth() ) );
+
+ tabLayout->addMultiCellWidget( NameEdit, 0, 0, 1, 2 );
+
+ textLabel1_3 = new QLabel( tab, "textLabel1_3" );
+
+ tabLayout->addWidget( textLabel1_3, 2, 0 );
+
+ textLabel1 = new QLabel( tab, "textLabel1" );
+
+ tabLayout->addWidget( textLabel1, 0, 0 );
+
+ textLabel1_2_2_2 = new QLabel( tab, "textLabel1_2_2_2" );
+
+ tabLayout->addWidget( textLabel1_2_2_2, 4, 0 );
+
+ textLabel1_2 = new QLabel( tab, "textLabel1_2" );
+
+ tabLayout->addWidget( textLabel1_2, 1, 0 );
+
+ textLabel1_2_2 = new QLabel( tab, "textLabel1_2_2" );
+
+ tabLayout->addWidget( textLabel1_2_2, 3, 0 );
+
+ textLabel1_2_2_3 = new QLabel( tab, "textLabel1_2_2_3" );
+
+ tabLayout->addWidget( textLabel1_2_2_3, 5, 0 );
+ spacer8 = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ tabLayout->addItem( spacer8, 6, 2 );
+
+ ModeComboBox = new KComboBox( FALSE, tab, "ModeComboBox" );
+ ModeComboBox->setEnabled( FALSE );
+
+ tabLayout->addWidget( ModeComboBox, 5, 1 );
+
+ EncryptionComboBox = new KComboBox( FALSE, tab, "EncryptionComboBox" );
+ EncryptionComboBox->setEnabled( FALSE );
+
+ tabLayout->addWidget( EncryptionComboBox, 4, 1 );
+ spacer10 = new QSpacerItem( 111, 31, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ tabLayout->addMultiCell( spacer10, 4, 5, 2, 2 );
+ SettingsTab->insertTab( tab, QString("") );
+
+ tab_2 = new QWidget( SettingsTab, "tab_2" );
+ tabLayout_2 = new QGridLayout( tab_2, 1, 1, 2, 6, "tabLayout_2");
+
+ textLabel3 = new QLabel( tab_2, "textLabel3" );
+
+ tabLayout_2->addWidget( textLabel3, 0, 0 );
+
+ DefaultDirectoryEdit = new QLineEdit( tab_2, "DefaultDirectoryEdit" );
+ DefaultDirectoryEdit->setEnabled( FALSE );
+
+ tabLayout_2->addMultiCellWidget( DefaultDirectoryEdit, 0, 0, 1, 3 );
+
+ textLabel2 = new QLabel( tab_2, "textLabel2" );
+
+ tabLayout_2->addWidget( textLabel2, 1, 0 );
+
+ AlternativeFxpCheckBox = new QCheckBox( tab_2, "AlternativeFxpCheckBox" );
+ AlternativeFxpCheckBox->setEnabled( FALSE );
+
+ tabLayout_2->addWidget( AlternativeFxpCheckBox, 1, 3 );
+
+ CorrectPasvCheckBox = new QCheckBox( tab_2, "CorrectPasvCheckBox" );
+ CorrectPasvCheckBox->setEnabled( FALSE );
+
+ tabLayout_2->addWidget( CorrectPasvCheckBox, 2, 3 );
+
+ textLabel1_2_2_2_2 = new QLabel( tab_2, "textLabel1_2_2_2_2" );
+
+ tabLayout_2->addMultiCellWidget( textLabel1_2_2_2_2, 2, 2, 0, 1 );
+ spacer16 = new QSpacerItem( 60, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ tabLayout_2->addMultiCell( spacer16, 1, 2, 2, 2 );
+ spacer7 = new QSpacerItem( 20, 71, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ tabLayout_2->addItem( spacer7, 3, 1 );
+ SettingsTab->insertTab( tab_2, QString("") );
+
+ KasablancaBookmarkDialogLayout->addWidget( splitter1, 0, 0 );
+ languageChange();
+ resize( QSize(541, 240).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // tab order
+ setTabOrder( NameEdit, InfoEdit );
+ setTabOrder( InfoEdit, UserEdit );
+ setTabOrder( UserEdit, PassEdit );
+ setTabOrder( PassEdit, EncryptionComboBox );
+ setTabOrder( EncryptionComboBox, ModeComboBox );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaBookmarkDialog::~KasablancaBookmarkDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaBookmarkDialog::languageChange()
+{
+ setCaption( tr2i18n( "Bookmarks" ) );
+ BookmarkListView->header()->setLabel( 0, tr2i18n( "Name" ) );
+ QWhatsThis::add( PassEdit, tr2i18n( "The user's password. Anonymous ftp servers ussually don't use passwords or accept passwords in the form of \"user@emailaddress.com\"." ) );
+ QWhatsThis::add( UserEdit, tr2i18n( "The ftp Login Username. On open ftp servers you usually login using \"anonymous\"." ) );
+ InfoEdit->setInputMask( QString::null );
+ QWhatsThis::add( InfoEdit, tr2i18n( "This information points to the the ftp server. HOST can either be a standard ip adress like 192.168.2.1 or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a \":\" character. A legit input would be \"ftp.kde.org:21\"." ) );
+ QWhatsThis::add( NameEdit, tr2i18n( "The ftp's name is entered here." ) );
+ textLabel1_3->setText( tr2i18n( "Username:" ) );
+ textLabel1->setText( tr2i18n( "Name:" ) );
+ textLabel1_2_2_2->setText( tr2i18n( "Encryption:" ) );
+ QWhatsThis::add( textLabel1_2_2_2, QString::null );
+ textLabel1_2->setText( tr2i18n( "Host:Port:" ) );
+ textLabel1_2_2->setText( tr2i18n( "Password:" ) );
+ textLabel1_2_2_3->setText( tr2i18n( "Mode:" ) );
+ ModeComboBox->clear();
+ ModeComboBox->insertItem( tr2i18n( "Active Mode" ) );
+ ModeComboBox->insertItem( tr2i18n( "Passive Mode" ) );
+ QWhatsThis::add( ModeComboBox, tr2i18n( "The mode you are using for data transfer. This is quite important in case you're behind a firewall or a router. In these cases you depend on the passive mode, which makes the client connects to the ftp server for data transfer. Passive mode is the standard method today, while active mode is the old way to do data transfers, the client listens for the server to connect in active mode." ) );
+ EncryptionComboBox->clear();
+ EncryptionComboBox->insertItem( tr2i18n( "Unencrypted" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 1" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 2" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 3" ) );
+ QWhatsThis::add( EncryptionComboBox, tr2i18n( "There are 4 encryption levels available. Unencrypted leaves all traffic clear and without encryption. Most ftp servers allow only this mode. Level 1 encryption means that the traffic on the control connection is encrypted while data transfer remains clear. Level 2 is basically the same with the exception of directory information which is transfered on the data channel, but is encrypted too. Eventually Level 3 encrypts everything all communication and all data traffic." ) );
+ SettingsTab->changeTab( tab, tr2i18n( "General" ) );
+ textLabel3->setText( tr2i18n( "Default directory:" ) );
+ textLabel2->setText( tr2i18n( "Alternative fxp:" ) );
+ AlternativeFxpCheckBox->setText( tr2i18n( "Enabled" ) );
+ CorrectPasvCheckBox->setText( tr2i18n( "Enabled" ) );
+ textLabel1_2_2_2_2->setText( tr2i18n( "Correct pasv responses:" ) );
+ SettingsTab->changeTab( tab_2, tr2i18n( "Advanced" ) );
+}
+
+#include "Q_bookmarkdialog.moc"
diff --git a/src/Q_bookmarkdialog.ui b/src/Q_bookmarkdialog.ui
new file mode 100755
index 0000000..347797f
--- /dev/null
+++ b/src/Q_bookmarkdialog.ui
@@ -0,0 +1,420 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaBookmarkDialog</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KasablancaBookmarkDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>541</width>
+ <height>240</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Bookmarks</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QSplitter" row="0" column="0">
+ <property name="name">
+ <cstring>splitter1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <widget class="KListView">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>false</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>BookmarkListView</cstring>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ <property name="dragEnabled">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>SettingsTab</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>360</width>
+ <height>232</height>
+ </size>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="KLineEdit" row="3" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>PassEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The user's password. Anonymous ftp servers ussually don't use passwords or accept passwords in the form of "user@emailaddress.com".</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>UserEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The ftp Login Username. On open ftp servers you usually login using "anonymous".</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>InfoEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="inputMask">
+ <string></string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This information points to the the ftp server. HOST can either be a standard ip adress like 192.168.2.1 or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a ":" character. A legit input would be "ftp.kde.org:21".</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>NameEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The ftp's name is entered here.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Encryption:</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Host:Port:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Mode:</string>
+ </property>
+ </widget>
+ <spacer row="6" column="2">
+ <property name="name">
+ <cstring>spacer8</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KComboBox" row="5" column="1">
+ <item>
+ <property name="text">
+ <string>Active Mode</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Passive Mode</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>ModeComboBox</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The mode you are using for data transfer. This is quite important in case you're behind a firewall or a router. In these cases you depend on the passive mode, which makes the client connects to the ftp server for data transfer. Passive mode is the standard method today, while active mode is the old way to do data transfers, the client listens for the server to connect in active mode.</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="4" column="1">
+ <item>
+ <property name="text">
+ <string>Unencrypted</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>EncryptionComboBox</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>There are 4 encryption levels available. Unencrypted leaves all traffic clear and without encryption. Most ftp servers allow only this mode. Level 1 encryption means that the traffic on the control connection is encrypted while data transfer remains clear. Level 2 is basically the same with the exception of directory information which is transfered on the data channel, but is encrypted too. Eventually Level 3 encrypts everything all communication and all data traffic.</string>
+ </property>
+ </widget>
+ <spacer row="4" column="2" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>111</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Advanced</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Default directory:</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>DefaultDirectoryEdit</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Alternative fxp:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="3">
+ <property name="name">
+ <cstring>AlternativeFxpCheckBox</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="3">
+ <property name="name">
+ <cstring>CorrectPasvCheckBox</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Correct pasv responses:</string>
+ </property>
+ </widget>
+ <spacer row="1" column="2" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>60</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer7</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>71</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<tabstops>
+ <tabstop>NameEdit</tabstop>
+ <tabstop>InfoEdit</tabstop>
+ <tabstop>UserEdit</tabstop>
+ <tabstop>PassEdit</tabstop>
+ <tabstop>EncryptionComboBox</tabstop>
+ <tabstop>ModeComboBox</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="0"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kcombobox.h</includehint>
+ <includehint>kcombobox.h</includehint>
+</includehints>
+</UI>
diff --git a/src/Q_colorspreferencesdialog.cpp b/src/Q_colorspreferencesdialog.cpp
new file mode 100644
index 0000000..a8ef1ab
--- /dev/null
+++ b/src/Q_colorspreferencesdialog.cpp
@@ -0,0 +1,100 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_colorspreferencesdialog.ui'
+**
+** Created: Mo Jan 31 15:02:07 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_colorspreferencesdialog.h"
+
+#include <qvariant.h>
+#include <qlabel.h>
+#include <kcolorbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaColorsPreferencesDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+KasablancaColorsPreferencesDialog::KasablancaColorsPreferencesDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "KasablancaColorsPreferencesDialog" );
+ KasablancaColorsPreferencesDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "KasablancaColorsPreferencesDialogLayout");
+
+ textLabel1_2 = new QLabel( this, "textLabel1_2" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( textLabel1_2, 0, 0 );
+
+ textLabel1_3_3 = new QLabel( this, "textLabel1_3_3" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( textLabel1_3_3, 1, 0 );
+
+ textLabel1_3 = new QLabel( this, "textLabel1_3" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( textLabel1_3, 2, 0 );
+
+ textLabel1_3_2 = new QLabel( this, "textLabel1_3_2" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( textLabel1_3_2, 3, 0 );
+ spacer3 = new QSpacerItem( 30, 60, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ KasablancaColorsPreferencesDialogLayout->addMultiCell( spacer3, 0, 2, 1, 1 );
+
+ kcfg_FailureColor = new KColorButton( this, "kcfg_FailureColor" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( kcfg_FailureColor, 2, 2 );
+
+ kcfg_SuccessColor = new KColorButton( this, "kcfg_SuccessColor" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( kcfg_SuccessColor, 1, 2 );
+
+ kcfg_LocalColor = new KColorButton( this, "kcfg_LocalColor" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( kcfg_LocalColor, 3, 2 );
+
+ kcfg_BackgroundColor = new KColorButton( this, "kcfg_BackgroundColor" );
+
+ KasablancaColorsPreferencesDialogLayout->addWidget( kcfg_BackgroundColor, 0, 2 );
+ spacer5 = new QSpacerItem( 31, 30, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ KasablancaColorsPreferencesDialogLayout->addItem( spacer5, 4, 1 );
+ languageChange();
+ resize( QSize(241, 183).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaColorsPreferencesDialog::~KasablancaColorsPreferencesDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaColorsPreferencesDialog::languageChange()
+{
+ setCaption( tr2i18n( "Colors" ) );
+ textLabel1_2->setText( tr2i18n( "Background:" ) );
+ textLabel1_3_3->setText( tr2i18n( "Success Text:" ) );
+ textLabel1_3->setText( tr2i18n( "Failure Text:" ) );
+ textLabel1_3_2->setText( tr2i18n( "Local Text:" ) );
+ kcfg_FailureColor->setText( QString::null );
+ kcfg_SuccessColor->setText( QString::null );
+ kcfg_LocalColor->setText( QString::null );
+ kcfg_BackgroundColor->setText( QString::null );
+}
+
+#include "Q_colorspreferencesdialog.moc"
diff --git a/src/Q_colorspreferencesdialog.ui b/src/Q_colorspreferencesdialog.ui
new file mode 100644
index 0000000..bfcf2a6
--- /dev/null
+++ b/src/Q_colorspreferencesdialog.ui
@@ -0,0 +1,131 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaColorsPreferencesDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KasablancaColorsPreferencesDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>241</width>
+ <height>183</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Colors</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Background:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_3_3</cstring>
+ </property>
+ <property name="text">
+ <string>Success Text:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Failure Text:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Local Text:</string>
+ </property>
+ </widget>
+ <spacer row="0" column="1" rowspan="3" colspan="1">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>30</width>
+ <height>60</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="KColorButton" row="2" column="2">
+ <property name="name">
+ <cstring>kcfg_FailureColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="1" column="2">
+ <property name="name">
+ <cstring>kcfg_SuccessColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="3" column="2">
+ <property name="name">
+ <cstring>kcfg_LocalColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <widget class="KColorButton" row="0" column="2">
+ <property name="name">
+ <cstring>kcfg_BackgroundColor</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ </widget>
+ <spacer row="4" column="1">
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>31</width>
+ <height>30</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+ <includehint>kcolorbutton.h</includehint>
+</includehints>
+</UI>
diff --git a/src/Q_customconnectdialog.cpp b/src/Q_customconnectdialog.cpp
new file mode 100644
index 0000000..42822e1
--- /dev/null
+++ b/src/Q_customconnectdialog.cpp
@@ -0,0 +1,180 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_customconnectdialog.ui'
+**
+** Created: Mo Jan 31 15:02:09 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_customconnectdialog.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qtabwidget.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaCustomConnectDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KasablancaCustomConnectDialog::KasablancaCustomConnectDialog( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KasablancaCustomConnectDialog" );
+ KasablancaCustomConnectDialogLayout = new QGridLayout( this, 1, 1, 2, 6, "KasablancaCustomConnectDialogLayout");
+
+ Custom = new QTabWidget( this, "Custom" );
+
+ tab = new QWidget( Custom, "tab" );
+ tabLayout = new QGridLayout( tab, 1, 1, 2, 6, "tabLayout");
+
+ textLabel4 = new QLabel( tab, "textLabel4" );
+ textLabel4->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignLeft ) );
+
+ tabLayout->addWidget( textLabel4, 2, 0 );
+
+ UserLineEdit = new QLineEdit( tab, "UserLineEdit" );
+ UserLineEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, UserLineEdit->sizePolicy().hasHeightForWidth() ) );
+
+ tabLayout->addMultiCellWidget( UserLineEdit, 1, 1, 1, 2 );
+
+ PassLineEdit = new QLineEdit( tab, "PassLineEdit" );
+ PassLineEdit->setEchoMode( QLineEdit::Password );
+
+ tabLayout->addMultiCellWidget( PassLineEdit, 2, 2, 1, 2 );
+
+ InfoEdit = new QLineEdit( tab, "InfoEdit" );
+ InfoEdit->setAlignment( int( QLineEdit::AlignAuto ) );
+
+ tabLayout->addMultiCellWidget( InfoEdit, 0, 0, 1, 2 );
+
+ textLabel3 = new QLabel( tab, "textLabel3" );
+ textLabel3->setAlignment( int( QLabel::AlignVCenter ) );
+
+ tabLayout->addWidget( textLabel3, 1, 0 );
+
+ textLabel2 = new QLabel( tab, "textLabel2" );
+ textLabel2->setAlignment( int( QLabel::AlignVCenter ) );
+
+ tabLayout->addWidget( textLabel2, 0, 0 );
+
+ textLabel1 = new QLabel( tab, "textLabel1" );
+ textLabel1->setAlignment( int( QLabel::AlignVCenter ) );
+
+ tabLayout->addWidget( textLabel1, 3, 0 );
+
+ textLabel1_2 = new QLabel( tab, "textLabel1_2" );
+ textLabel1_2->setAlignment( int( QLabel::WordBreak | QLabel::AlignVCenter ) );
+
+ tabLayout->addWidget( textLabel1_2, 4, 0 );
+
+ AnonymousCheckBox = new QCheckBox( tab, "AnonymousCheckBox" );
+
+ tabLayout->addWidget( AnonymousCheckBox, 1, 3 );
+ spacer12 = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ tabLayout->addItem( spacer12, 5, 1 );
+
+ EncryptionComboBox = new QComboBox( FALSE, tab, "EncryptionComboBox" );
+
+ tabLayout->addWidget( EncryptionComboBox, 3, 1 );
+
+ ModeComboBox = new QComboBox( FALSE, tab, "ModeComboBox" );
+
+ tabLayout->addWidget( ModeComboBox, 4, 1 );
+ spacer10 = new QSpacerItem( 120, 31, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ tabLayout->addMultiCell( spacer10, 3, 4, 2, 3 );
+ Custom->insertTab( tab, QString("") );
+
+ tab_2 = new QWidget( Custom, "tab_2" );
+ tabLayout_2 = new QGridLayout( tab_2, 1, 1, 2, 6, "tabLayout_2");
+
+ textLabel2_2 = new QLabel( tab_2, "textLabel2_2" );
+
+ tabLayout_2->addWidget( textLabel2_2, 1, 0 );
+
+ AlternativeFxpCheckBox = new QCheckBox( tab_2, "AlternativeFxpCheckBox" );
+
+ tabLayout_2->addWidget( AlternativeFxpCheckBox, 1, 3 );
+
+ DefaultDirectoryEdit = new QLineEdit( tab_2, "DefaultDirectoryEdit" );
+
+ tabLayout_2->addMultiCellWidget( DefaultDirectoryEdit, 0, 0, 1, 3 );
+
+ textLabel1_2_2_2_2 = new QLabel( tab_2, "textLabel1_2_2_2_2" );
+
+ tabLayout_2->addMultiCellWidget( textLabel1_2_2_2_2, 2, 2, 0, 1 );
+
+ CorrectPasvCheckBox = new QCheckBox( tab_2, "CorrectPasvCheckBox" );
+
+ tabLayout_2->addWidget( CorrectPasvCheckBox, 2, 3 );
+
+ textLabel3_2 = new QLabel( tab_2, "textLabel3_2" );
+
+ tabLayout_2->addWidget( textLabel3_2, 0, 0 );
+ spacer16 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ tabLayout_2->addItem( spacer16, 3, 1 );
+ spacer17 = new QSpacerItem( 21, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ tabLayout_2->addMultiCell( spacer17, 1, 2, 2, 2 );
+ Custom->insertTab( tab_2, QString("") );
+
+ KasablancaCustomConnectDialogLayout->addWidget( Custom, 0, 0 );
+ languageChange();
+ resize( QSize(370, 214).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaCustomConnectDialog::~KasablancaCustomConnectDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaCustomConnectDialog::languageChange()
+{
+ setCaption( tr2i18n( "Custom Site" ) );
+ textLabel4->setText( tr2i18n( "Password:" ) );
+ QWhatsThis::add( UserLineEdit, tr2i18n( "The ftp Login Username. On open ftp servers you usually login using \"anonymous\"." ) );
+ QWhatsThis::add( PassLineEdit, tr2i18n( "The user's password. Anonymous ftp servers ussually don't use passwords or accept passwords in the form of \"user@emailaddress.com\"." ) );
+ InfoEdit->setText( QString::null );
+ QWhatsThis::add( InfoEdit, tr2i18n( "This information points to the the ftp server. HOST can either be a standard ip adress like \"192.168.2.1\" or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a \":\" character. A legit input would be \"ftp.kde.org:21\"." ) );
+ textLabel3->setText( tr2i18n( "Username:" ) );
+ textLabel2->setText( tr2i18n( "Host:Port:" ) );
+ textLabel1->setText( tr2i18n( "Encryption:" ) );
+ textLabel1_2->setText( tr2i18n( "Mode:" ) );
+ AnonymousCheckBox->setText( tr2i18n( "Anonymous" ) );
+ EncryptionComboBox->clear();
+ EncryptionComboBox->insertItem( tr2i18n( "Unencrypted" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 1" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 2" ) );
+ EncryptionComboBox->insertItem( tr2i18n( "Level 3" ) );
+ QWhatsThis::add( EncryptionComboBox, tr2i18n( "There are 4 encryption levels available. Unencrypted leaves all traffic clear and without encryption. Most ftp servers allow only this mode. Level 1 encryption means that the traffic on the control connection is encrypted while data transfer remains clear. Level 2 is basically the same with the exception of directory information which is transfered on the data channel, but is encrypted too. Eventually Level 3 encrypts everything all communication and all data traffic." ) );
+ ModeComboBox->clear();
+ ModeComboBox->insertItem( tr2i18n( "Passive Mode" ) );
+ ModeComboBox->insertItem( tr2i18n( "Active Mode" ) );
+ QWhatsThis::add( ModeComboBox, tr2i18n( "The mode you are using for data transfer. This is quite important in case you're behind a firewall or a router. In these cases you depend on the passive mode, which makes the client connects to the ftp server for data transfer. Passive mode is the standard method today, while active mode is the old way to do data transfers, the client listens for the server to connect in active mode." ) );
+ Custom->changeTab( tab, tr2i18n( "General" ) );
+ textLabel2_2->setText( tr2i18n( "Alternative fxp:" ) );
+ AlternativeFxpCheckBox->setText( tr2i18n( "Enabled" ) );
+ textLabel1_2_2_2_2->setText( tr2i18n( "Correct pasv responses:" ) );
+ CorrectPasvCheckBox->setText( tr2i18n( "Enabled" ) );
+ textLabel3_2->setText( tr2i18n( "Default directory:" ) );
+ Custom->changeTab( tab_2, tr2i18n( "Advanced" ) );
+}
+
+#include "Q_customconnectdialog.moc"
diff --git a/src/Q_customconnectdialog.ui b/src/Q_customconnectdialog.ui
new file mode 100755
index 0000000..926a674
--- /dev/null
+++ b/src/Q_customconnectdialog.ui
@@ -0,0 +1,328 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaCustomConnectDialog</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KasablancaCustomConnectDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>370</width>
+ <height>214</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Custom Site</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QTabWidget" row="0" column="0">
+ <property name="name">
+ <cstring>Custom</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>General</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Password:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignLeft</set>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>UserLineEdit</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The ftp Login Username. On open ftp servers you usually login using "anonymous".</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="2" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>PassLineEdit</cstring>
+ </property>
+ <property name="echoMode">
+ <enum>Password</enum>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The user's password. Anonymous ftp servers ussually don't use passwords or accept passwords in the form of "user@emailaddress.com".</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>InfoEdit</cstring>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="alignment">
+ <set>AlignAuto</set>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This information points to the the ftp server. HOST can either be a standard ip adress like "192.168.2.1" or a domain name. PORT is the port number on which the ftp server listens. In most cases this is 21. Both are seperated by a ":" character. A legit input would be "ftp.kde.org:21".</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Username:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Host:Port:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Encryption:</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Mode:</string>
+ </property>
+ <property name="alignment">
+ <set>WordBreak|AlignVCenter</set>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="3">
+ <property name="name">
+ <cstring>AnonymousCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Anonymous</string>
+ </property>
+ </widget>
+ <spacer row="5" column="1">
+ <property name="name">
+ <cstring>spacer12</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QComboBox" row="3" column="1">
+ <item>
+ <property name="text">
+ <string>Unencrypted</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Level 3</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>EncryptionComboBox</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>There are 4 encryption levels available. Unencrypted leaves all traffic clear and without encryption. Most ftp servers allow only this mode. Level 1 encryption means that the traffic on the control connection is encrypted while data transfer remains clear. Level 2 is basically the same with the exception of directory information which is transfered on the data channel, but is encrypted too. Eventually Level 3 encrypts everything all communication and all data traffic.</string>
+ </property>
+ </widget>
+ <widget class="QComboBox" row="4" column="1">
+ <item>
+ <property name="text">
+ <string>Passive Mode</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Active Mode</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>ModeComboBox</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>The mode you are using for data transfer. This is quite important in case you're behind a firewall or a router. In these cases you depend on the passive mode, which makes the client connects to the ftp server for data transfer. Passive mode is the standard method today, while active mode is the old way to do data transfers, the client listens for the server to connect in active mode.</string>
+ </property>
+ </widget>
+ <spacer row="3" column="2" rowspan="2" colspan="2">
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>120</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Advanced</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Alternative fxp:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="3">
+ <property name="name">
+ <cstring>AlternativeFxpCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>DefaultDirectoryEdit</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Correct pasv responses:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="3">
+ <property name="name">
+ <cstring>CorrectPasvCheckBox</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Default directory:</string>
+ </property>
+ </widget>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer16</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="1" column="2" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer17</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/Q_fileexistsdialog.cpp b/src/Q_fileexistsdialog.cpp
new file mode 100644
index 0000000..5da867b
--- /dev/null
+++ b/src/Q_fileexistsdialog.cpp
@@ -0,0 +1,111 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_fileexistsdialog.ui'
+**
+** Created: Mo Jan 31 15:02:06 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_fileexistsdialog.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaFileExistsDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+KasablancaFileExistsDialog::KasablancaFileExistsDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "KasablancaFileExistsDialog" );
+ setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );
+ setModal( TRUE );
+ KasablancaFileExistsDialogLayout = new QGridLayout( this, 1, 1, 2, 6, "KasablancaFileExistsDialogLayout");
+ KasablancaFileExistsDialogLayout->setResizeMode( QLayout::Fixed );
+
+ SkipButton = new QPushButton( this, "SkipButton" );
+
+ KasablancaFileExistsDialogLayout->addWidget( SkipButton, 0, 3 );
+
+ ResumeButton = new QPushButton( this, "ResumeButton" );
+ ResumeButton->setEnabled( TRUE );
+
+ KasablancaFileExistsDialogLayout->addWidget( ResumeButton, 0, 1 );
+
+ RenameButton = new QPushButton( this, "RenameButton" );
+ RenameButton->setEnabled( TRUE );
+
+ KasablancaFileExistsDialogLayout->addWidget( RenameButton, 0, 2 );
+
+ OverwriteButton = new QPushButton( this, "OverwriteButton" );
+
+ KasablancaFileExistsDialogLayout->addWidget( OverwriteButton, 0, 0 );
+ languageChange();
+ resize( QSize(514, 57).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // signals and slots connections
+ connect( SkipButton, SIGNAL( clicked() ), this, SLOT( Skip() ) );
+ connect( OverwriteButton, SIGNAL( clicked() ), this, SLOT( Overwrite() ) );
+ connect( ResumeButton, SIGNAL( clicked() ), this, SLOT( Resume() ) );
+ connect( RenameButton, SIGNAL( clicked() ), this, SLOT( Rename() ) );
+
+ // tab order
+ setTabOrder( OverwriteButton, ResumeButton );
+ setTabOrder( ResumeButton, RenameButton );
+ setTabOrder( RenameButton, SkipButton );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaFileExistsDialog::~KasablancaFileExistsDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaFileExistsDialog::languageChange()
+{
+ setCaption( tr2i18n( "File Exists" ) );
+ SkipButton->setText( tr2i18n( "Skip" ) );
+ ResumeButton->setText( tr2i18n( "Resume" ) );
+ RenameButton->setText( tr2i18n( "Rename" ) );
+ OverwriteButton->setText( tr2i18n( "Overwrite" ) );
+}
+
+void KasablancaFileExistsDialog::Skip()
+{
+ qWarning( "KasablancaFileExistsDialog::Skip(): Not implemented yet" );
+}
+
+void KasablancaFileExistsDialog::Overwrite()
+{
+ qWarning( "KasablancaFileExistsDialog::Overwrite(): Not implemented yet" );
+}
+
+void KasablancaFileExistsDialog::Resume()
+{
+ qWarning( "KasablancaFileExistsDialog::Resume(): Not implemented yet" );
+}
+
+void KasablancaFileExistsDialog::Rename()
+{
+ qWarning( "KasablancaFileExistsDialog::Rename(): Not implemented yet" );
+}
+
+#include "Q_fileexistsdialog.moc"
diff --git a/src/Q_fileexistsdialog.ui b/src/Q_fileexistsdialog.ui
new file mode 100644
index 0000000..cc27a14
--- /dev/null
+++ b/src/Q_fileexistsdialog.ui
@@ -0,0 +1,118 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaFileExistsDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KasablancaFileExistsDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>514</width>
+ <height>57</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>File Exists</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <property name="resizeMode">
+ <enum>Fixed</enum>
+ </property>
+ <widget class="QPushButton" row="0" column="3">
+ <property name="name">
+ <cstring>SkipButton</cstring>
+ </property>
+ <property name="text">
+ <string>Skip</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="1">
+ <property name="name">
+ <cstring>ResumeButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Resume</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="2">
+ <property name="name">
+ <cstring>RenameButton</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Rename</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" row="0" column="0">
+ <property name="name">
+ <cstring>OverwriteButton</cstring>
+ </property>
+ <property name="text">
+ <string>Overwrite</string>
+ </property>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>SkipButton</sender>
+ <signal>clicked()</signal>
+ <receiver>KasablancaFileExistsDialog</receiver>
+ <slot>Skip()</slot>
+ </connection>
+ <connection>
+ <sender>OverwriteButton</sender>
+ <signal>clicked()</signal>
+ <receiver>KasablancaFileExistsDialog</receiver>
+ <slot>Overwrite()</slot>
+ </connection>
+ <connection>
+ <sender>ResumeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>KasablancaFileExistsDialog</receiver>
+ <slot>Resume()</slot>
+ </connection>
+ <connection>
+ <sender>RenameButton</sender>
+ <signal>clicked()</signal>
+ <receiver>KasablancaFileExistsDialog</receiver>
+ <slot>Rename()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>OverwriteButton</tabstop>
+ <tabstop>ResumeButton</tabstop>
+ <tabstop>RenameButton</tabstop>
+ <tabstop>SkipButton</tabstop>
+</tabstops>
+<slots>
+ <slot>Skip()</slot>
+ <slot>Overwrite()</slot>
+ <slot>Resume()</slot>
+ <slot>Rename()</slot>
+</slots>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/Q_generalpreferencesdialog.cpp b/src/Q_generalpreferencesdialog.cpp
new file mode 100644
index 0000000..0f638ec
--- /dev/null
+++ b/src/Q_generalpreferencesdialog.cpp
@@ -0,0 +1,176 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_generalpreferencesdialog.ui'
+**
+** Created: Mo Jan 31 15:02:08 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_generalpreferencesdialog.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaGeneralPreferencesDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+KasablancaGeneralPreferencesDialog::KasablancaGeneralPreferencesDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "KasablancaGeneralPreferencesDialog" );
+ setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );
+ setSizeGripEnabled( FALSE );
+ KasablancaGeneralPreferencesDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "KasablancaGeneralPreferencesDialogLayout");
+ KasablancaGeneralPreferencesDialogLayout->setResizeMode( QLayout::Minimum );
+ spacer2_2 = new QSpacerItem( 20, 78, QSizePolicy::Minimum, QSizePolicy::Fixed );
+ KasablancaGeneralPreferencesDialogLayout->addItem( spacer2_2, 3, 0 );
+
+ textLabel1_3 = new QLabel( this, "textLabel1_3" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( textLabel1_3, 4, 0 );
+
+ textLabel1 = new QLabel( this, "textLabel1" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( textLabel1, 0, 0 );
+
+ textLabel1_2 = new QLabel( this, "textLabel1_2" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( textLabel1_2, 1, 0 );
+
+ textLabel1_2_2 = new QLabel( this, "textLabel1_2_2" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( textLabel1_2_2, 2, 0 );
+ spacer2 = new QSpacerItem( 20, 78, QSizePolicy::Minimum, QSizePolicy::Fixed );
+ KasablancaGeneralPreferencesDialogLayout->addItem( spacer2, 3, 3 );
+
+ kcfg_Skiplist = new QLineEdit( this, "kcfg_Skiplist" );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( kcfg_Skiplist, 0, 0, 1, 2 );
+
+ kcfg_OnQueueFinished = new QLineEdit( this, "kcfg_OnQueueFinished" );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( kcfg_OnQueueFinished, 1, 1, 1, 2 );
+
+ buttonGroup1 = new QButtonGroup( this, "buttonGroup1" );
+ buttonGroup1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, buttonGroup1->sizePolicy().hasHeightForWidth() ) );
+ buttonGroup1->setColumnLayout(0, Qt::Vertical );
+ buttonGroup1->layout()->setSpacing( 6 );
+ buttonGroup1->layout()->setMargin( 11 );
+ buttonGroup1Layout = new QGridLayout( buttonGroup1->layout() );
+ buttonGroup1Layout->setAlignment( Qt::AlignTop );
+
+ kcfg_OnFileExistsResume = new QRadioButton( buttonGroup1, "kcfg_OnFileExistsResume" );
+
+ buttonGroup1Layout->addWidget( kcfg_OnFileExistsResume, 1, 0 );
+
+ kcfg_OnFileExistsSkip = new QRadioButton( buttonGroup1, "kcfg_OnFileExistsSkip" );
+
+ buttonGroup1Layout->addWidget( kcfg_OnFileExistsSkip, 2, 0 );
+
+ kcfg_OnFileExistsOverwrite = new QRadioButton( buttonGroup1, "kcfg_OnFileExistsOverwrite" );
+
+ buttonGroup1Layout->addWidget( kcfg_OnFileExistsOverwrite, 0, 0 );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( buttonGroup1, 2, 3, 1, 2 );
+
+ kcfg_Prioritylist = new QLineEdit( this, "kcfg_Prioritylist" );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( kcfg_Prioritylist, 4, 4, 1, 2 );
+
+ textLabel1_3_2 = new QLabel( this, "textLabel1_3_2" );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( textLabel1_3_2, 5, 5, 0, 1 );
+
+ textLabel1_3_2_2 = new QLabel( this, "textLabel1_3_2_2" );
+
+ KasablancaGeneralPreferencesDialogLayout->addMultiCellWidget( textLabel1_3_2_2, 6, 6, 0, 1 );
+ spacer9 = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ KasablancaGeneralPreferencesDialogLayout->addItem( spacer9, 7, 2 );
+
+ kcfg_SkiplistIsEnabled = new QCheckBox( this, "kcfg_SkiplistIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_SkiplistIsEnabled, 0, 3 );
+
+ kcfg_OnQueueFinishedIsEnabled = new QCheckBox( this, "kcfg_OnQueueFinishedIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_OnQueueFinishedIsEnabled, 1, 3 );
+
+ kcfg_OnFileExistsIsEnabled = new QCheckBox( this, "kcfg_OnFileExistsIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_OnFileExistsIsEnabled, 2, 3 );
+
+ kcfg_PrioritylistIsEnabled = new QCheckBox( this, "kcfg_PrioritylistIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_PrioritylistIsEnabled, 4, 3 );
+
+ kcfg_DirCachingIsEnabled = new QCheckBox( this, "kcfg_DirCachingIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_DirCachingIsEnabled, 5, 3 );
+
+ kcfg_DeleteMovesIntoTrashIsEnabled = new QCheckBox( this, "kcfg_DeleteMovesIntoTrashIsEnabled" );
+
+ KasablancaGeneralPreferencesDialogLayout->addWidget( kcfg_DeleteMovesIntoTrashIsEnabled, 6, 3 );
+ spacer10 = new QSpacerItem( 81, 51, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ KasablancaGeneralPreferencesDialogLayout->addMultiCell( spacer10, 5, 6, 2, 2 );
+ languageChange();
+ resize( QSize(455, 303).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaGeneralPreferencesDialog::~KasablancaGeneralPreferencesDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaGeneralPreferencesDialog::languageChange()
+{
+ setCaption( tr2i18n( "General" ) );
+ QWhatsThis::add( this, tr2i18n( "Directory caching means that once you browsed a folder on a ftp session the content of that folder is cached, and will be loaded from there in case you enter it again. This can speed up browsing especially with large dirs. If you want a fresh representation of the dir content, you can press the refresh button." ) );
+ textLabel1_3->setText( tr2i18n( "Priority list:" ) );
+ textLabel1->setText( tr2i18n( "Skiplist:" ) );
+ textLabel1_2->setText( tr2i18n( "On queue finished:" ) );
+ textLabel1_2_2->setText( tr2i18n( "On file exist:" ) );
+ QWhatsThis::add( kcfg_Skiplist, tr2i18n( "Here you can enter a Regular Expression. Transfer items which match this Regular Expression are skipped. For example a value of \"^\\.\" excludes every entry beginning with \".\" from transfer." ) );
+ QWhatsThis::add( kcfg_OnQueueFinished, tr2i18n( "This field can hold an executable and its arguments which will be run, when last item of in queue has finished transferring. For Example, on KDE desktops the entry \"dcop ksmserver ksmserver logout 0 0 0\" would shutdown the computer automatically." ) );
+ buttonGroup1->setTitle( QString::null );
+ kcfg_OnFileExistsResume->setText( tr2i18n( "Resume (if possible)" ) );
+ QWhatsThis::add( kcfg_OnFileExistsResume, tr2i18n( "These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature." ) );
+ kcfg_OnFileExistsSkip->setText( tr2i18n( "Skip" ) );
+ QWhatsThis::add( kcfg_OnFileExistsSkip, tr2i18n( "These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature." ) );
+ kcfg_OnFileExistsOverwrite->setText( tr2i18n( "Overwrite" ) );
+ QWhatsThis::add( kcfg_OnFileExistsOverwrite, tr2i18n( "These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature." ) );
+ QWhatsThis::add( kcfg_Prioritylist, tr2i18n( "This Field contains a regular expression, which queues the items matching this regular expression before the items which don't. For example, \".sfv\" would make the common checksum files with this fileending transfer first." ) );
+ textLabel1_3_2->setText( tr2i18n( "Directory caching:" ) );
+ textLabel1_3_2_2->setText( tr2i18n( "Delete moves files into trash:" ) );
+ kcfg_SkiplistIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_OnQueueFinishedIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_OnFileExistsIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_PrioritylistIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_DirCachingIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_DeleteMovesIntoTrashIsEnabled->setText( tr2i18n( "Enabled" ) );
+}
+
+#include "Q_generalpreferencesdialog.moc"
diff --git a/src/Q_generalpreferencesdialog.ui b/src/Q_generalpreferencesdialog.ui
new file mode 100644
index 0000000..d9beaa1
--- /dev/null
+++ b/src/Q_generalpreferencesdialog.ui
@@ -0,0 +1,284 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaGeneralPreferencesDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KasablancaGeneralPreferencesDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>455</width>
+ <height>303</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>General</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Directory caching means that once you browsed a folder on a ftp session the content of that folder is cached, and will be loaded from there in case you enter it again. This can speed up browsing especially with large dirs. If you want a fresh representation of the dir content, you can press the refresh button.</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="resizeMode">
+ <enum>Minimum</enum>
+ </property>
+ <spacer row="3" column="0">
+ <property name="name">
+ <cstring>spacer2_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>78</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="4" column="0">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Priority list:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Skiplist:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>On queue finished:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>On file exist:</string>
+ </property>
+ </widget>
+ <spacer row="3" column="3">
+ <property name="name">
+ <cstring>spacer2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Fixed</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>78</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLineEdit" row="0" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kcfg_Skiplist</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Here you can enter a Regular Expression. Transfer items which match this Regular Expression are skipped. For example a value of "^\." excludes every entry beginning with "." from transfer.</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="1" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kcfg_OnQueueFinished</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This field can hold an executable and its arguments which will be run, when last item of in queue has finished transferring. For Example, on KDE desktops the entry "dcop ksmserver ksmserver logout 0 0 0" would shutdown the computer automatically.</string>
+ </property>
+ </widget>
+ <widget class="QButtonGroup" row="2" column="1" rowspan="2" colspan="2">
+ <property name="name">
+ <cstring>buttonGroup1</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string></string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="1" column="0">
+ <property name="name">
+ <cstring>kcfg_OnFileExistsResume</cstring>
+ </property>
+ <property name="text">
+ <string>Resume (if possible)</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature.</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="2" column="0">
+ <property name="name">
+ <cstring>kcfg_OnFileExistsSkip</cstring>
+ </property>
+ <property name="text">
+ <string>Skip</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature.</string>
+ </property>
+ </widget>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>kcfg_OnFileExistsOverwrite</cstring>
+ </property>
+ <property name="text">
+ <string>Overwrite</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>These Radio Buttons indicate how the application should proceed if a file to be transfered already exists on the destination. Usually the user is asked by the application how to proceed if this occurs, in case you aren't present during the transfer you can enable this feature.</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QLineEdit" row="4" column="1" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>kcfg_Prioritylist</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This Field contains a regular expression, which queues the items matching this regular expression before the items which don't. For example, ".sfv" would make the common checksum files with this fileending transfer first.</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="5" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_3_2</cstring>
+ </property>
+ <property name="text">
+ <string>Directory caching:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="6" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_3_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Delete moves files into trash:</string>
+ </property>
+ </widget>
+ <spacer row="7" column="2">
+ <property name="name">
+ <cstring>spacer9</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QCheckBox" row="0" column="3">
+ <property name="name">
+ <cstring>kcfg_SkiplistIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="3">
+ <property name="name">
+ <cstring>kcfg_OnQueueFinishedIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="3">
+ <property name="name">
+ <cstring>kcfg_OnFileExistsIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="4" column="3">
+ <property name="name">
+ <cstring>kcfg_PrioritylistIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="5" column="3">
+ <property name="name">
+ <cstring>kcfg_DirCachingIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="6" column="3">
+ <property name="name">
+ <cstring>kcfg_DeleteMovesIntoTrashIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <spacer row="5" column="2" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>spacer10</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>81</width>
+ <height>51</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/Q_importdialog.cpp b/src/Q_importdialog.cpp
new file mode 100644
index 0000000..51567ec
--- /dev/null
+++ b/src/Q_importdialog.cpp
@@ -0,0 +1,70 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_importdialog.ui'
+**
+** Created: Mo Jan 31 15:02:10 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_importdialog.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qbuttongroup.h>
+#include <qradiobutton.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaImportDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KasablancaImportDialog::KasablancaImportDialog( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KasablancaImportDialog" );
+ KasablancaImportDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "KasablancaImportDialogLayout");
+
+ ImportGroupBox = new QButtonGroup( this, "ImportGroupBox" );
+ ImportGroupBox->setColumnLayout(0, Qt::Vertical );
+ ImportGroupBox->layout()->setSpacing( 6 );
+ ImportGroupBox->layout()->setMargin( 11 );
+ ImportGroupBoxLayout = new QGridLayout( ImportGroupBox->layout() );
+ ImportGroupBoxLayout->setAlignment( Qt::AlignTop );
+
+ GftpRadioButton = new QRadioButton( ImportGroupBox, "GftpRadioButton" );
+ GftpRadioButton->setChecked( TRUE );
+
+ ImportGroupBoxLayout->addWidget( GftpRadioButton, 0, 0 );
+
+ KasablancaImportDialogLayout->addWidget( ImportGroupBox, 0, 0 );
+ languageChange();
+ resize( QSize(231, 80).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaImportDialog::~KasablancaImportDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaImportDialog::languageChange()
+{
+ setCaption( tr2i18n( "Import Bookmarks" ) );
+ ImportGroupBox->setTitle( tr2i18n( "Import filter" ) );
+ GftpRadioButton->setText( tr2i18n( "gFtp" ) );
+}
+
+#include "Q_importdialog.moc"
diff --git a/src/Q_importdialog.ui b/src/Q_importdialog.ui
new file mode 100644
index 0000000..bbfeef9
--- /dev/null
+++ b/src/Q_importdialog.ui
@@ -0,0 +1,49 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaImportDialog</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KasablancaImportDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>231</width>
+ <height>80</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Import Bookmarks</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QButtonGroup" row="0" column="0">
+ <property name="name">
+ <cstring>ImportGroupBox</cstring>
+ </property>
+ <property name="title">
+ <string>Import filter</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QRadioButton" row="0" column="0">
+ <property name="name">
+ <cstring>GftpRadioButton</cstring>
+ </property>
+ <property name="text">
+ <string>gFtp</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/src/Q_mainwindow.cpp b/src/Q_mainwindow.cpp
new file mode 100644
index 0000000..40ef350
--- /dev/null
+++ b/src/Q_mainwindow.cpp
@@ -0,0 +1,185 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_mainwindow.ui'
+**
+** Created: Mo Jan 31 15:02:06 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_mainwindow.h"
+
+#include <qvariant.h>
+#include <qpushbutton.h>
+#include <qtoolbutton.h>
+#include <qheader.h>
+#include <qlistview.h>
+#include <klineedit.h>
+#include <qsplitter.h>
+#include <qtextedit.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+#include "kbtaskview.h"
+
+/*
+ * Constructs a KasablancaMainWindow as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ */
+KasablancaMainWindow::KasablancaMainWindow( QWidget* parent, const char* name, WFlags fl )
+ : QWidget( parent, name, fl )
+{
+ if ( !name )
+ setName( "KasablancaMainWindow" );
+ setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)5, 0, 0, sizePolicy().hasHeightForWidth() ) );
+ KasablancaMainWindowLayout = new QGridLayout( this, 1, 1, 2, 6, "KasablancaMainWindowLayout");
+
+ ConnectButtonA = new QToolButton( this, "ConnectButtonA" );
+ ConnectButtonA->setEnabled( TRUE );
+ ConnectButtonA->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( ConnectButtonA, 0, 0 );
+
+ RefreshButtonA = new QToolButton( this, "RefreshButtonA" );
+ RefreshButtonA->setEnabled( TRUE );
+ RefreshButtonA->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( RefreshButtonA, 0, 1 );
+
+ TransferButtonA = new QToolButton( this, "TransferButtonA" );
+ TransferButtonA->setEnabled( FALSE );
+ TransferButtonA->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( TransferButtonA, 0, 2 );
+
+ ConnectButtonB = new QToolButton( this, "ConnectButtonB" );
+ ConnectButtonB->setEnabled( TRUE );
+ ConnectButtonB->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( ConnectButtonB, 0, 4 );
+
+ RefreshButtonB = new QToolButton( this, "RefreshButtonB" );
+ RefreshButtonB->setEnabled( TRUE );
+ RefreshButtonB->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( RefreshButtonB, 0, 5 );
+
+ TransferButtonB = new QToolButton( this, "TransferButtonB" );
+ TransferButtonB->setEnabled( FALSE );
+ TransferButtonB->setAutoRaise( FALSE );
+
+ KasablancaMainWindowLayout->addWidget( TransferButtonB, 0, 6 );
+
+ BrowserA = new QListView( this, "BrowserA" );
+ BrowserA->addColumn( tr2i18n( "Name" ) );
+ BrowserA->addColumn( tr2i18n( "Size" ) );
+ BrowserA->addColumn( tr2i18n( "Date" ) );
+ BrowserA->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)2, (QSizePolicy::SizeType)7, 0, 0, BrowserA->sizePolicy().hasHeightForWidth() ) );
+ BrowserA->setResizePolicy( QScrollView::Manual );
+ BrowserA->setSelectionMode( QListView::Extended );
+
+ KasablancaMainWindowLayout->addMultiCellWidget( BrowserA, 1, 1, 0, 3 );
+
+ BrowserB = new QListView( this, "BrowserB" );
+ BrowserB->addColumn( tr2i18n( "Name" ) );
+ BrowserB->addColumn( tr2i18n( "Size" ) );
+ BrowserB->addColumn( tr2i18n( "Date" ) );
+ BrowserB->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)2, (QSizePolicy::SizeType)7, 0, 0, BrowserB->sizePolicy().hasHeightForWidth() ) );
+ BrowserB->setSelectionMode( QListView::Extended );
+
+ KasablancaMainWindowLayout->addMultiCellWidget( BrowserB, 1, 1, 4, 7 );
+
+ CwdLineA = new KLineEdit( this, "CwdLineA" );
+
+ KasablancaMainWindowLayout->addWidget( CwdLineA, 0, 3 );
+
+ CwdLineB = new KLineEdit( this, "CwdLineB" );
+
+ KasablancaMainWindowLayout->addWidget( CwdLineB, 0, 7 );
+
+ CommandLineA = new KLineEdit( this, "CommandLineA" );
+
+ KasablancaMainWindowLayout->addMultiCellWidget( CommandLineA, 2, 2, 0, 3 );
+
+ CommandLineB = new KLineEdit( this, "CommandLineB" );
+
+ KasablancaMainWindowLayout->addMultiCellWidget( CommandLineB, 2, 2, 4, 7 );
+
+ splitter4 = new QSplitter( this, "splitter4" );
+ splitter4->setOrientation( QSplitter::Vertical );
+
+ TaskView = new KbTaskView( splitter4, "TaskView" );
+
+ QWidget* privateLayoutWidget = new QWidget( splitter4, "layout2" );
+ layout2 = new QGridLayout( privateLayoutWidget, 1, 1, 0, 6, "layout2");
+
+ LogWindowB = new QTextEdit( privateLayoutWidget, "LogWindowB" );
+ LogWindowB->setPaletteForegroundColor( QColor( 255, 255, 255 ) );
+ LogWindowB->setPaletteBackgroundColor( QColor( 82, 194, 255 ) );
+ QFont LogWindowB_font( LogWindowB->font() );
+ LogWindowB_font.setFamily( "Dec Terminal" );
+ LogWindowB->setFont( LogWindowB_font );
+ LogWindowB->setHScrollBarMode( QTextEdit::AlwaysOff );
+ LogWindowB->setTextFormat( QTextEdit::PlainText );
+ LogWindowB->setWrapPolicy( QTextEdit::AtWordOrDocumentBoundary );
+ LogWindowB->setReadOnly( TRUE );
+
+ layout2->addWidget( LogWindowB, 0, 1 );
+
+ LogWindowA = new QTextEdit( privateLayoutWidget, "LogWindowA" );
+ LogWindowA->setPaletteForegroundColor( QColor( 255, 255, 255 ) );
+ LogWindowA->setPaletteBackgroundColor( QColor( 82, 194, 255 ) );
+ QFont LogWindowA_font( LogWindowA->font() );
+ LogWindowA_font.setFamily( "Dec Terminal" );
+ LogWindowA->setFont( LogWindowA_font );
+ LogWindowA->setHScrollBarMode( QTextEdit::AlwaysOff );
+ LogWindowA->setTextFormat( QTextEdit::PlainText );
+ LogWindowA->setWrapPolicy( QTextEdit::AtWordOrDocumentBoundary );
+ LogWindowA->setReadOnly( TRUE );
+
+ layout2->addWidget( LogWindowA, 0, 0 );
+
+ KasablancaMainWindowLayout->addMultiCellWidget( splitter4, 3, 3, 0, 7 );
+ languageChange();
+ resize( QSize(689, 626).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+
+ // tab order
+ setTabOrder( BrowserA, BrowserB );
+ setTabOrder( BrowserB, LogWindowA );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaMainWindow::~KasablancaMainWindow()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaMainWindow::languageChange()
+{
+ setCaption( tr2i18n( "Kasablanca x" ) );
+ ConnectButtonA->setText( QString::null );
+ RefreshButtonA->setText( QString::null );
+ TransferButtonA->setText( QString::null );
+ ConnectButtonB->setText( QString::null );
+ RefreshButtonB->setText( QString::null );
+ TransferButtonB->setText( QString::null );
+ BrowserA->header()->setLabel( 0, tr2i18n( "Name" ) );
+ BrowserA->header()->setLabel( 1, tr2i18n( "Size" ) );
+ BrowserA->header()->setLabel( 2, tr2i18n( "Date" ) );
+ BrowserB->header()->setLabel( 0, tr2i18n( "Name" ) );
+ BrowserB->header()->setLabel( 1, tr2i18n( "Size" ) );
+ BrowserB->header()->setLabel( 2, tr2i18n( "Date" ) );
+ LogWindowB->setText( QString::null );
+ LogWindowA->setText( QString::null );
+}
+
+#include "Q_mainwindow.moc"
diff --git a/src/Q_mainwindow.ui b/src/Q_mainwindow.ui
new file mode 100755
index 0000000..2887033
--- /dev/null
+++ b/src/Q_mainwindow.ui
@@ -0,0 +1,380 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaMainWindow</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>KasablancaMainWindow</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>689</width>
+ <height>626</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="caption">
+ <string>Kasablanca x</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <widget class="QToolButton" row="0" column="0">
+ <property name="name">
+ <cstring>ConnectButtonA</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="1">
+ <property name="name">
+ <cstring>RefreshButtonA</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="2">
+ <property name="name">
+ <cstring>TransferButtonA</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="4">
+ <property name="name">
+ <cstring>ConnectButtonB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="5">
+ <property name="name">
+ <cstring>RefreshButtonB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QToolButton" row="0" column="6">
+ <property name="name">
+ <cstring>TransferButtonB</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="autoRaise">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QListView" row="1" column="0" rowspan="1" colspan="4">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Size</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Date</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>BrowserA</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>2</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="resizePolicy">
+ <enum>Manual</enum>
+ </property>
+ <property name="selectionMode">
+ <enum>Extended</enum>
+ </property>
+ </widget>
+ <widget class="QListView" row="1" column="4" rowspan="1" colspan="4">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Size</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Date</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>BrowserB</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>2</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="selectionMode">
+ <enum>Extended</enum>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="3">
+ <property name="name">
+ <cstring>CwdLineA</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="0" column="7">
+ <property name="name">
+ <cstring>CwdLineB</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="0" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>CommandLineA</cstring>
+ </property>
+ </widget>
+ <widget class="KLineEdit" row="2" column="4" rowspan="1" colspan="4">
+ <property name="name">
+ <cstring>CommandLineB</cstring>
+ </property>
+ </widget>
+ <widget class="QSplitter" row="3" column="0" rowspan="1" colspan="8">
+ <property name="name">
+ <cstring>splitter4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <widget class="KbTaskView">
+ <property name="name">
+ <cstring>TaskView</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QTextEdit" row="0" column="1">
+ <property name="name">
+ <cstring>LogWindowB</cstring>
+ </property>
+ <property name="paletteForegroundColor">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>82</red>
+ <green>194</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="font">
+ <font>
+ <family>Dec Terminal</family>
+ </font>
+ </property>
+ <property name="hScrollBarMode">
+ <enum>AlwaysOff</enum>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="wrapPolicy">
+ <enum>AtWordOrDocumentBoundary</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QTextEdit" row="0" column="0">
+ <property name="name">
+ <cstring>LogWindowA</cstring>
+ </property>
+ <property name="paletteForegroundColor">
+ <color>
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="paletteBackgroundColor">
+ <color>
+ <red>82</red>
+ <green>194</green>
+ <blue>255</blue>
+ </color>
+ </property>
+ <property name="font">
+ <font>
+ <family>Dec Terminal</family>
+ </font>
+ </property>
+ <property name="hScrollBarMode">
+ <enum>AlwaysOff</enum>
+ </property>
+ <property name="textFormat">
+ <enum>PlainText</enum>
+ </property>
+ <property name="text">
+ <string></string>
+ </property>
+ <property name="wrapPolicy">
+ <enum>AtWordOrDocumentBoundary</enum>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>KbTaskView</class>
+ <header location="local">kbtaskview.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="826">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000030149444154789cb59531681b5718c77f0e377c070e3c810a3a70e0041eac51852e0a19e45134830a1d9a4c69a04bc8928e990a693a640e1d0c8642b08742321894c1507991b484c890902bb8701a047760c3bd21701fe4201dde49b6a41a32b8df72dcbbeffdbefffbbfefbd5b1b0c07cce266ebe667ae2006c3c1dada0cdc3be87d6e6c35b0d692a409d9c7ec8b20d65ae29398d19b1114e7e3de4ce98b3f5e10dc0053cf0951b4506496e1b964bf7ce6c585d9054c62d01d617ca48be0596553cf496d8f2c8b01c5f795fc93904e85ec4c01a152857a5d9175d0b2805c872080f18595ccc1499a10a225d4e2fbc2877786fe81253ab6c04c8d106e09db5d43ab0d146e5c64d1a23938fb98a185cea1c33eecfd9eba49eb427dcb201e245365f2b7b2fb5b4a3a31dcb927178afe07d86901df870fefa4842aed6f6b74ba42e52b4014d580e1eb9cbd9d94de7e4aad16d2f9be02d805f0b5e532f927a1ffcacea1777f122a8105b164a7c25faf323a5d9f1f1fd600e1e5bec59e2d4b5c7ef5209d0ad17b8b31864e57c0b3e0815ac3ee33253ab664a770ff5185d1a1cb8d2267d3e58aa1dc7d2508cbe597d0e74fdd269aaaf0f52d414c4ea3e9762c996869e42560d7a72e41c4799a2586e74f95e8d8151481fa86efbe7b3398ac58b1a2b8527589f15451ad303ac2293542ad6648a796278f13a27185e4c4754310facb98c53a79e19a3fdc1426ff28c3d7399d1f7cb25343eb96106cf83c790ce9c4f2eb831855c55485663327992eb6dc8a6259874ed700b0b793323cccb9ffa842b30d6133e3e75fea989ac15a8b16ca76b746b0b92278d919774c5b6d48a78697fb29bbcf52468742a32120909c24e899ce67beed5be2db01e22d1e9485bb620e47f9ee9e606a21bd3f5d3744c7e7c54d55e87443867d8b554515ac5db4620e8e4f62263170fd1cdee90aad7640141992891b0f367c9adfe4049bb07d3b7022bd8c687c0978f46684ee084150b65ac1fcca94591b7a90a496e4c095164fb016a2b192a497795cc0f84817aebe25f7bf70ccc54a575c555c03f78ffa5fc0570d1f0c076bff0232285a0901e2257b0000000049454e44ae426082</data>
+ </image>
+</images>
+<tabstops>
+ <tabstop>BrowserA</tabstop>
+ <tabstop>BrowserB</tabstop>
+ <tabstop>LogWindowA</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kbtaskview.h</includehint>
+</includehints>
+</UI>
diff --git a/src/Q_userinterfacepreferencesdialog.cpp b/src/Q_userinterfacepreferencesdialog.cpp
new file mode 100644
index 0000000..5aa2b31
--- /dev/null
+++ b/src/Q_userinterfacepreferencesdialog.cpp
@@ -0,0 +1,102 @@
+#include <kdialog.h>
+#include <klocale.h>
+/****************************************************************************
+** Form implementation generated from reading ui file '/home/mkulke/Development/kasablanca/src/Q_userinterfacepreferencesdialog.ui'
+**
+** Created: Mo Jan 31 15:02:09 2005
+** by: The User Interface Compiler ($Id: qt/main.cpp 3.3.3 edited Nov 24 2003 $)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+
+#include "Q_userinterfacepreferencesdialog.h"
+
+#include <qvariant.h>
+#include <qlabel.h>
+#include <qcheckbox.h>
+#include <kfontrequester.h>
+#include <qlayout.h>
+#include <qtooltip.h>
+#include <qwhatsthis.h>
+
+/*
+ * Constructs a KasablancaUserInterfacePreferencesDialog as a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+KasablancaUserInterfacePreferencesDialog::KasablancaUserInterfacePreferencesDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "KasablancaUserInterfacePreferencesDialog" );
+ KasablancaUserInterfacePreferencesDialogLayout = new QGridLayout( this, 1, 1, 11, 6, "KasablancaUserInterfacePreferencesDialogLayout");
+ spacer4 = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding );
+ KasablancaUserInterfacePreferencesDialogLayout->addItem( spacer4, 4, 3 );
+
+ textLabel1_2_2_2_2 = new QLabel( this, "textLabel1_2_2_2_2" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addMultiCellWidget( textLabel1_2_2_2_2, 0, 0, 0, 1 );
+
+ textLabel1_2_2_2_2_2 = new QLabel( this, "textLabel1_2_2_2_2_2" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addMultiCellWidget( textLabel1_2_2_2_2_2, 1, 1, 0, 1 );
+
+ textLabel1_2_2_2_2_2_3 = new QLabel( this, "textLabel1_2_2_2_2_2_3" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addMultiCellWidget( textLabel1_2_2_2_2_2_3, 2, 2, 0, 2 );
+
+ kcfg_SystrayIsEnabled = new QCheckBox( this, "kcfg_SystrayIsEnabled" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addWidget( kcfg_SystrayIsEnabled, 0, 4 );
+
+ kcfg_CommandLineIsEnabled = new QCheckBox( this, "kcfg_CommandLineIsEnabled" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addWidget( kcfg_CommandLineIsEnabled, 1, 4 );
+
+ kcfg_HideHiddenFilesIsEnabled = new QCheckBox( this, "kcfg_HideHiddenFilesIsEnabled" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addWidget( kcfg_HideHiddenFilesIsEnabled, 2, 4 );
+
+ kcfg_LogwindowFont = new KFontRequester( this, "kcfg_LogwindowFont" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addMultiCellWidget( kcfg_LogwindowFont, 3, 3, 2, 4 );
+
+ textLabel1_2_2_2_2_2_2 = new QLabel( this, "textLabel1_2_2_2_2_2_2" );
+
+ KasablancaUserInterfacePreferencesDialogLayout->addWidget( textLabel1_2_2_2_2_2_2, 3, 0 );
+ spacer3 = new QSpacerItem( 140, 58, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ KasablancaUserInterfacePreferencesDialogLayout->addMultiCell( spacer3, 0, 1, 2, 3 );
+ spacer3_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ KasablancaUserInterfacePreferencesDialogLayout->addItem( spacer3_2, 3, 1 );
+ languageChange();
+ resize( QSize(448, 165).expandedTo(minimumSizeHint()) );
+ clearWState( WState_Polished );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+KasablancaUserInterfacePreferencesDialog::~KasablancaUserInterfacePreferencesDialog()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+/*
+ * Sets the strings of the subwidgets using the current
+ * language.
+ */
+void KasablancaUserInterfacePreferencesDialog::languageChange()
+{
+ setCaption( tr2i18n( "User Interface" ) );
+ textLabel1_2_2_2_2->setText( tr2i18n( "Show system tray icon:" ) );
+ textLabel1_2_2_2_2_2->setText( tr2i18n( "Show command lines:" ) );
+ textLabel1_2_2_2_2_2_3->setText( tr2i18n( "Hide hidden files from view:" ) );
+ kcfg_SystrayIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_CommandLineIsEnabled->setText( tr2i18n( "Enabled" ) );
+ kcfg_HideHiddenFilesIsEnabled->setText( tr2i18n( "Enabled" ) );
+ textLabel1_2_2_2_2_2_2->setText( tr2i18n( "Logwindow Font:" ) );
+}
+
+#include "Q_userinterfacepreferencesdialog.moc"
diff --git a/src/Q_userinterfacepreferencesdialog.ui b/src/Q_userinterfacepreferencesdialog.ui
new file mode 100644
index 0000000..26f537c
--- /dev/null
+++ b/src/Q_userinterfacepreferencesdialog.ui
@@ -0,0 +1,142 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>KasablancaUserInterfacePreferencesDialog</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>KasablancaUserInterfacePreferencesDialog</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>448</width>
+ <height>165</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>User Interface</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <spacer row="4" column="3">
+ <property name="name">
+ <cstring>spacer4</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>16</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Show system tray icon:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Show command lines:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2_2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Hide hidden files from view:</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="0" column="4">
+ <property name="name">
+ <cstring>kcfg_SystrayIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="1" column="4">
+ <property name="name">
+ <cstring>kcfg_CommandLineIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" row="2" column="4">
+ <property name="name">
+ <cstring>kcfg_HideHiddenFilesIsEnabled</cstring>
+ </property>
+ <property name="text">
+ <string>Enabled</string>
+ </property>
+ </widget>
+ <widget class="KFontRequester" row="3" column="2" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>kcfg_LogwindowFont</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="3" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2_2_2_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Logwindow Font:</string>
+ </property>
+ </widget>
+ <spacer row="0" column="2" rowspan="2" colspan="2">
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>140</width>
+ <height>58</height>
+ </size>
+ </property>
+ </spacer>
+ <spacer row="3" column="1">
+ <property name="name">
+ <cstring>spacer3_2</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </grid>
+</widget>
+<customwidgets>
+</customwidgets>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>kfontrequester.h</includehint>
+</includehints>
+</UI>
diff --git a/src/about.png b/src/about.png
new file mode 100644
index 0000000..df8c8a8
--- /dev/null
+++ b/src/about.png
Binary files differ
diff --git a/src/bookmarkdialog.cpp b/src/bookmarkdialog.cpp
new file mode 100644
index 0000000..8bb610c
--- /dev/null
+++ b/src/bookmarkdialog.cpp
@@ -0,0 +1,210 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#include <qdom.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qcheckbox.h>
+#include <qheader.h>
+#include <qtabwidget.h>
+#include <qaction.h>
+
+#include <kcombobox.h>
+#include <kcompletion.h>
+#include <klocale.h>
+#include <klineedit.h>
+#include <kmessagebox.h>
+#include <kpushbutton.h>
+#include <klistview.h>
+
+#include "bookmarkdialog.h"
+#include "kbbookmarkitem.h"
+
+BookmarkDialog::BookmarkDialog(QWidget *parent, const char *name)
+: KDialogBase(parent, name, true, i18n( "Bookmarks" ),
+ KDialogBase::Ok |
+ KDialogBase::Help |
+ KDialogBase::Cancel |
+ KDialogBase::User1 |
+ KDialogBase::User2,
+ KDialogBase::Ok, true , KGuiItem(i18n("New")), KGuiItem(i18n("Remove")))
+{
+ mp_dialog = new KasablancaBookmarkDialog(this);
+ setMainWidget(mp_dialog);
+ setHelp("ftphelp");
+
+ m_bookmarklist = KbSiteInfo::ParseBookmarks();
+ mp_dialog->BookmarkListView->header()->hide();
+ mp_dialog->BookmarkListView->setSorting(-1);
+
+ KbBookmarkItem *after = NULL;
+
+ list<KbSiteInfo>::iterator end_bookmarks = m_bookmarklist.end();
+ for (list<KbSiteInfo>::iterator i = m_bookmarklist.begin(); i != end_bookmarks; i++)
+ after = new KbBookmarkItem(mp_dialog->BookmarkListView, after, &(*i));
+
+ connect(mp_dialog->NameEdit, SIGNAL(textChanged(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->InfoEdit, SIGNAL(textChanged(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->UserEdit, SIGNAL(textChanged(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->PassEdit, SIGNAL(textChanged(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->DefaultDirectoryEdit, SIGNAL(textChanged(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->EncryptionComboBox, SIGNAL(activated(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->ModeComboBox, SIGNAL(activated(const QString&)), SLOT(SLOT_TextChanged(const QString&)));
+ connect(mp_dialog->AlternativeFxpCheckBox, SIGNAL(clicked()), SLOT(SLOT_StateChanged()));
+ connect(mp_dialog->CorrectPasvCheckBox, SIGNAL(clicked()), SLOT(SLOT_StateChanged()));
+
+ connect(mp_dialog->BookmarkListView, SIGNAL(selectionChanged()), SLOT(SLOT_SelectionChanged()));
+
+ m_newitemselected = false;
+
+ enableButton(KDialogBase::User2, false);
+
+ QAction *deleteShortcut = new QAction( QPixmap(), "&Delete",
+ Key_Delete, this, "delete" );
+
+ connect( deleteShortcut, SIGNAL( activated() ) , this, SLOT( slotUser2() ) );
+}
+
+BookmarkDialog::~BookmarkDialog()
+{
+}
+
+#include "bookmarkdialog.moc"
+
+void BookmarkDialog::SLOT_SelectionChanged()
+{
+ KbBookmarkItem *kbb;
+ KbSiteInfo *s;
+ kbb = static_cast<KbBookmarkItem*>(mp_dialog->BookmarkListView->selectedItem());
+ if (!kbb)
+ {
+ EnableInput(false);
+ return;
+ }
+
+ m_newitemselected = true;
+ s = kbb->GetSiteInfo();
+
+ EnableInput(true);
+ RefreshEntry(s);
+}
+
+void BookmarkDialog::EnableInput(bool b)
+{
+ mp_dialog->NameEdit->setEnabled(b);
+ mp_dialog->UserEdit->setEnabled(b);
+ mp_dialog->PassEdit->setEnabled(b);
+ mp_dialog->InfoEdit->setEnabled(b);
+ mp_dialog->EncryptionComboBox->setEnabled(b);
+ mp_dialog->ModeComboBox->setEnabled(b);
+ mp_dialog->AlternativeFxpCheckBox->setEnabled(b);
+ mp_dialog->CorrectPasvCheckBox->setEnabled(b);
+ mp_dialog->DefaultDirectoryEdit->setEnabled(b);
+ enableButton(KDialogBase::User2, b);
+}
+
+void BookmarkDialog::slotOk()
+{
+ list<KbSiteInfo> newbookmarklist;
+
+ slotApply();
+
+ QListViewItemIterator it(mp_dialog->BookmarkListView);
+ while (it.current())
+ {
+ newbookmarklist.push_back(*(static_cast<KbBookmarkItem*>(it.current())->GetSiteInfo()));
+ ++it;
+ }
+
+ KbSiteInfo::WriteBookmarks(newbookmarklist);
+ accept();
+}
+
+void BookmarkDialog::slotUser1()
+{
+ KbBookmarkItem* newentry;
+
+ KbSiteInfo newsite;
+ newsite.SetName("New Site");
+ newsite.SetInfo("newftp:21");
+ newsite.SetUser("anonymous");
+ newsite.SetPass("bla@bla.com");
+ newsite.SetPasv(1);
+ newsite.SetTls(0);
+ newsite.SetAlternativeFxp(0);
+ newsite.SetCorrectPasv(0);
+ newsite.SetDefaultDirectory("");
+
+ m_bookmarklist.push_back(newsite);
+
+ newentry = new KbBookmarkItem(mp_dialog->BookmarkListView, mp_dialog->BookmarkListView->lastItem(), &m_bookmarklist.back());
+ mp_dialog->BookmarkListView->setSelected(newentry, true);
+}
+
+void BookmarkDialog::slotUser2()
+{
+ delete mp_dialog->BookmarkListView->selectedItem();
+}
+
+void BookmarkDialog::RefreshEntry(KbSiteInfo* site)
+{
+ mp_dialog->NameEdit->setText(site->GetName());
+ mp_dialog->UserEdit->setText(site->GetUser());
+ mp_dialog->PassEdit->setText(site->GetPass());
+ mp_dialog->InfoEdit->setText(site->GetInfo());
+ mp_dialog->EncryptionComboBox->setCurrentItem(site->GetTls());
+ mp_dialog->ModeComboBox->setCurrentItem(site->GetPasv());
+ mp_dialog->AlternativeFxpCheckBox->setChecked(site->GetAlternativeFxp());
+ mp_dialog->CorrectPasvCheckBox->setChecked(site->GetCorrectPasv());
+ mp_dialog->DefaultDirectoryEdit->setText(site->GetDefaultDirectory());
+
+ m_newitemselected = false;
+}
+
+void BookmarkDialog::SLOT_StateChanged()
+{
+ if (!m_newitemselected) ApplyChanges();
+}
+
+void BookmarkDialog::SLOT_TextChanged(const QString&)
+{
+ if (!m_newitemselected) ApplyChanges();
+}
+
+void BookmarkDialog::ApplyChanges()
+{
+ KbSiteInfo *siteinfo;
+ KbBookmarkItem *kbb;
+
+ kbb = static_cast<KbBookmarkItem*>(mp_dialog->BookmarkListView->selectedItem());
+ if (!kbb) return;
+ siteinfo = kbb->GetSiteInfo();
+
+ siteinfo->SetName(mp_dialog->NameEdit->text());
+ siteinfo->SetUser(mp_dialog->UserEdit->text());
+ siteinfo->SetPass(mp_dialog->PassEdit->text());
+ siteinfo->SetInfo(mp_dialog->InfoEdit->text());
+ siteinfo->SetTls(mp_dialog->EncryptionComboBox->currentItem());
+ siteinfo->SetPasv(mp_dialog->ModeComboBox->currentItem());
+ siteinfo->SetAlternativeFxp(mp_dialog->AlternativeFxpCheckBox->isOn());
+ siteinfo->SetCorrectPasv(mp_dialog->CorrectPasvCheckBox->isOn());
+ siteinfo->SetDefaultDirectory(mp_dialog->DefaultDirectoryEdit->text());
+
+ kbb->setText(0, mp_dialog->NameEdit->text());
+}
diff --git a/src/bookmarkdialog.h b/src/bookmarkdialog.h
new file mode 100644
index 0000000..006201d
--- /dev/null
+++ b/src/bookmarkdialog.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef BOOKMARKDIALOG_H
+#define BOOKMARKDIALOG_H
+
+#include <Q_bookmarkdialog.h>
+#include <kdialogbase.h>
+
+#include "kbsiteinfo.h"
+#include <list>
+
+using namespace std;
+
+/**
+@author Magnus Kulke
+*/
+class BookmarkDialog : public KDialogBase
+{
+Q_OBJECT
+public:
+ BookmarkDialog(QWidget *parent = 0, const char *name = 0);
+ ~BookmarkDialog();
+public slots:
+ void slotUser1();
+ void slotUser2();
+ void slotOk();
+ void SLOT_TextChanged(const QString& s);
+ void SLOT_StateChanged();
+ void SLOT_SelectionChanged();
+private:
+ void ApplyChanges();
+ void RefreshEntry(KbSiteInfo *site);
+ void EnableInput(bool b);
+ KasablancaBookmarkDialog *mp_dialog;
+ list<KbSiteInfo> m_bookmarklist;
+ bool m_newitemselected;
+};
+
+#endif
diff --git a/src/customconnectdialog.cpp b/src/customconnectdialog.cpp
new file mode 100755
index 0000000..a445780
--- /dev/null
+++ b/src/customconnectdialog.cpp
@@ -0,0 +1,74 @@
+/***************************************************************************
+ customconnectdialog.cpp - description
+ -------------------
+ begin : Mit Aug 20 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#include <klocale.h>
+
+#include <qstring.h>
+#include <qlineedit.h>
+#include <qradiobutton.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+
+#include "kbsiteinfo.h"
+#include "customconnectdialog.h"
+
+CustomConnectDialog::CustomConnectDialog(QWidget *parent, const char *name ) : KDialogBase(parent, name,
+ true, i18n( "Custom Site" ), KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::Help, KDialogBase::Ok, true)
+{
+ setHelp("ftphelp");
+ mp_dialog = new KasablancaCustomConnectDialog(this);
+ setMainWidget(mp_dialog);
+
+ connect(mp_dialog->AnonymousCheckBox, SIGNAL(toggled(bool)), SLOT(SLOT_AnonymousToggled(bool)));
+}
+
+CustomConnectDialog::~CustomConnectDialog()
+{
+}
+
+void CustomConnectDialog::slotOk()
+{
+ mp_site->SetName(mp_dialog->InfoEdit->text());
+ mp_site->SetInfo(mp_dialog->InfoEdit->text());
+ mp_site->SetUser(mp_dialog->UserLineEdit->text());
+ mp_site->SetPass(mp_dialog->PassLineEdit->text());
+ mp_site->SetTls(mp_dialog->EncryptionComboBox->currentItem());
+ mp_site->SetPasv(mp_dialog->ModeComboBox->currentItem() ^ 1);
+ mp_site->SetDefaultDirectory(mp_dialog->DefaultDirectoryEdit->text());
+ mp_site->SetAlternativeFxp(mp_dialog->AlternativeFxpCheckBox->isOn());
+ mp_site->SetCorrectPasv(mp_dialog->CorrectPasvCheckBox->isOn());
+
+ accept();
+}
+
+void CustomConnectDialog::SLOT_AnonymousToggled(bool on)
+{
+ mp_dialog->UserLineEdit->setEnabled(!on);
+ mp_dialog->PassLineEdit->setEnabled(!on);
+
+ if(on) {
+ m_user = mp_dialog->UserLineEdit->text();
+ m_pass = mp_dialog->PassLineEdit->text();
+ mp_dialog->UserLineEdit->setText("anonymous");
+ mp_dialog->PassLineEdit->setText("some@email.org");
+ }
+ else
+ {
+ mp_dialog->UserLineEdit->setText(m_user);
+ mp_dialog->PassLineEdit->setText(m_pass);
+ }
+}
diff --git a/src/customconnectdialog.h b/src/customconnectdialog.h
new file mode 100755
index 0000000..8468d6b
--- /dev/null
+++ b/src/customconnectdialog.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ customconnectdialog.h - description
+ -------------------
+ begin : Mit Aug 20 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef CUSTOMCONNECTDIALOG_H
+#define CUSTOMCONNECTDIALOG_H
+
+#include "Q_customconnectdialog.h"
+
+#include <kdialogbase.h>
+
+class KbSiteInfo;
+
+/**
+ *@author mkulke
+ */
+
+class CustomConnectDialog : public KDialogBase
+{
+ Q_OBJECT
+public:
+ CustomConnectDialog(QWidget *parent=0, const char *name=0);
+ ~CustomConnectDialog();
+ KbSiteInfo *mp_site;
+public slots:
+ void slotOk();
+ void SLOT_AnonymousToggled(bool on);
+private:
+ QString m_user;
+ QString m_pass;
+ KasablancaCustomConnectDialog *mp_dialog;
+};
+
+#endif
diff --git a/src/eventhandler.cpp b/src/eventhandler.cpp
new file mode 100644
index 0000000..7a848c4
--- /dev/null
+++ b/src/eventhandler.cpp
@@ -0,0 +1,301 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include <qevent.h>
+
+#include "ftpthread.h"
+#include "eventhandler.h"
+
+/*
+class description:
+
+the class transforms the events posted by an ftp thread into signals. the signals
+are composed from the type of the arrived event and in certain cases an out_variable.
+*/
+
+/* constructor */
+
+EventHandler::EventHandler(QObject *parent, const char *name)
+ : QObject(parent, name)
+{
+ installEventFilter(this);
+
+ mp_thread = NULL;
+}
+
+/* destructor */
+
+EventHandler::~EventHandler()
+{
+}
+
+/* set ftp thread */
+
+void EventHandler::SetFtpThread(FtpThread* thread)
+{
+ mp_thread = thread;
+}
+
+/* the eventfilter method. when a certain event arrives a signal is emitted, composed
+from the events type and a possible out_ variable from the ftp thread object. */
+
+bool EventHandler::eventFilter(QObject*, QEvent *e )
+{
+ EventType type = (EventType)(e->type());
+
+ if (mp_thread == NULL)
+ {
+ emit ftp_error("mp_thread is NULL");
+ return TRUE;
+ }
+ else if (type == outlog)
+ {
+ QString *line = static_cast<QString*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_log(*line, true);
+ delete line;
+ return TRUE;
+ }
+ else if (type == inlog)
+ {
+ QString *line = static_cast<QString*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_log(*line, false);
+ delete line;
+ return TRUE;
+ }
+ else if (type == xfered)
+ {
+ xferpair* xp = static_cast<xferpair*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_xfered(xp->first, xp->second);
+ delete xp;
+ return TRUE;
+ }
+ else if (type == finished)
+ {
+ emit ftp_finished();
+ return TRUE;
+ }
+ else if (type == connectionlost)
+ {
+ emit ftp_connectionlost();
+ return TRUE;
+ }
+ else if (type == connect_success)
+ {
+ emit ftp_connect(true);
+ return TRUE;
+ }
+ else if (type == connect_failure)
+ {
+ emit ftp_connect(false);
+ return TRUE;
+ }
+ else if (type == misc_success)
+ {
+ emit ftp_misc(true);
+ return TRUE;
+ }
+ else if (type == misc_failure)
+ {
+ emit ftp_misc(false);
+ return TRUE;
+ }
+ else if (type == login_success)
+ {
+ emit ftp_login(true);
+ return TRUE;
+ }
+ else if (type == login_failure)
+ {
+ emit ftp_login(false);
+ return TRUE;
+ }
+ else if (type == quit_success)
+ {
+ emit ftp_quit(true);
+ return TRUE;
+ }
+ else if (type == quit_failure)
+ {
+ emit ftp_quit(false);
+ return TRUE;
+ }
+ else if (type == authtls_success)
+ {
+ emit ftp_authtls(true);
+ return TRUE;
+ }
+ else if (type == authtls_failure)
+ {
+ emit ftp_authtls(false);
+ return TRUE;
+ }
+ else if (type == pwd_success)
+ {
+ QString *path = static_cast<QString*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_pwd(true, *path);
+ delete path;
+ return TRUE;
+ }
+ else if (type == pwd_failure)
+ {
+ emit ftp_pwd(false, "");
+ return TRUE;
+ }
+ else if (type == chdir_success)
+ {
+ emit ftp_chdir(true);
+ return TRUE;
+ }
+ else if (type == chdir_failure)
+ {
+ emit ftp_chdir(false);
+ return TRUE;
+ }
+ else if (type == transfer_success)
+ {
+ emit ftp_transfer(true);
+ return TRUE;
+ }
+ else if (type == transfer_failure)
+ {
+ emit ftp_transfer(false);
+ return TRUE;
+ }
+ else if (type == dir_success)
+ {
+ contentpair *content = static_cast<contentpair*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_dir(true, content->first, content->second);
+ return TRUE;
+ }
+ else if (type == dir_failure)
+ {
+ contentpair *content = static_cast<contentpair*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_dir(false, content->first, content->second);
+ return TRUE;
+ }
+ else if (type == scandir_success)
+ {
+ KbDirInfo *dir = static_cast<KbDirInfo*>(static_cast<QCustomEvent*>(e)->data());
+ emit ftp_scandir(true, dir);
+ return TRUE;
+ }
+ else if (type == scandir_failure)
+ {
+ emit ftp_scandir(false, NULL);
+ return TRUE;
+ }
+ else if (type == rm_success)
+ {
+ emit ftp_rm(true);
+ return TRUE;
+ }
+ else if (type == rm_failure)
+ {
+ emit ftp_rm(false);
+ return TRUE;
+ }
+ else if (type == rmdir_success)
+ {
+ emit ftp_rmdir(true);
+ return TRUE;
+ }
+ else if (type == rmdir_failure)
+ {
+ emit ftp_rmdir(false);
+ return TRUE;
+ }
+ else if (type == encryptdata_success)
+ {
+ emit ftp_encryptdata(true);
+ return TRUE;
+ }
+ else if (type == encryptdata_failure)
+ {
+ emit ftp_encryptdata(false);
+ return TRUE;
+ }
+ else if (type == get_success)
+ {
+ emit ftp_get(true);
+ return TRUE;
+ }
+ else if (type == get_failure)
+ {
+ emit ftp_get(false);
+ return TRUE;
+ }
+ else if (type == mkdir_success)
+ {
+ emit ftp_mkdir(true);
+ return TRUE;
+ }
+ else if (type == mkdir_failure)
+ {
+ emit ftp_mkdir(false);
+ return TRUE;
+ }
+ else if (type == rename_success)
+ {
+ emit ftp_rename(true);
+ return TRUE;
+ }
+ else if (type == rename_failure)
+ {
+ emit ftp_rename(false);
+ return TRUE;
+ }
+ else if (type == raw_success)
+ {
+ emit ftp_raw(true);
+ return TRUE;
+ }
+ else if (type == raw_failure)
+ {
+ emit ftp_raw(false);
+ return TRUE;
+ }
+ else if (type == put_success)
+ {
+ emit ftp_put(true);
+ return TRUE;
+ }
+ else if (type == put_failure)
+ {
+ emit ftp_put(false);
+ return TRUE;
+ }
+ else if (type == fxp_success)
+ {
+ emit ftp_fxp(true);
+ return TRUE;
+ }
+ else if (type == fxp_failure)
+ {
+ emit ftp_fxp(false);
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+}
+
+
+#include "eventhandler.moc"
diff --git a/src/eventhandler.h b/src/eventhandler.h
new file mode 100644
index 0000000..36ccf46
--- /dev/null
+++ b/src/eventhandler.h
@@ -0,0 +1,126 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef EVENTHANDLER_H
+#define EVENTHANDLER_H
+
+#include <qobject.h>
+#include <qvaluelist.h>
+#include <list>
+#include "kbfileinfo.h"
+
+using namespace std;
+
+class KbDirInfo;
+class FtpThread;
+
+/**
+@author Magnus Kulke
+*/
+
+typedef list<KbFileInfo*> filist;
+typedef pair<filist, filist> contentpair;
+
+class EventHandler : public QObject
+{
+Q_OBJECT
+public:
+ EventHandler(QObject *parent = 0, const char *name = 0);
+ ~EventHandler();
+ void SetFtpThread(FtpThread* thread);
+public:
+ enum EventType
+ {
+ error = 1001,
+ outlog,
+ inlog,
+ xfered,
+ finished,
+ connectionlost,
+ misc_success,
+ misc_failure,
+ connect_success,
+ connect_failure,
+ login_success,
+ login_failure,
+ pwd_success,
+ pwd_failure,
+ chdir_success,
+ chdir_failure,
+ dir_success,
+ dir_failure,
+ scandir_success,
+ scandir_failure,
+ rm_success,
+ rm_failure,
+ rmdir_success,
+ rmdir_failure,
+ quit_success,
+ quit_failure,
+ authtls_success,
+ authtls_failure,
+ encryptdata_success,
+ encryptdata_failure,
+ get_success,
+ get_failure,
+ mkdir_success,
+ mkdir_failure,
+ rename_success,
+ rename_failure,
+ raw_success,
+ raw_failure,
+ put_success,
+ put_failure,
+ fxp_success,
+ fxp_failure,
+ transfer_success,
+ transfer_failure
+ };
+private:
+ bool eventFilter(QObject* o, QEvent *e);
+private:
+ FtpThread* mp_thread;
+signals:
+ void ftp_error(QString error);
+ void ftp_log(QString log, bool out);
+ void ftp_xfered(off64_t xfered, bool encrypted);
+ void ftp_misc(bool success);
+ void ftp_finished();
+ void ftp_connect(bool success);
+ void ftp_login(bool success);
+ void ftp_quit(bool success);
+ void ftp_pwd(bool success, QString path);
+ void ftp_chdir(bool success);
+ void ftp_dir(bool success, list<KbFileInfo*> dirlist, list<KbFileInfo*> filelist);
+ void ftp_scandir(bool success, KbDirInfo* dir);
+ void ftp_rm(bool success);
+ void ftp_rmdir(bool success);
+ void ftp_authtls(bool success);
+ void ftp_encryptdata(bool success);
+ void ftp_get(bool success);
+ void ftp_mkdir(bool success);
+ void ftp_rename(bool success);
+ void ftp_raw(bool success);
+ void ftp_put(bool success);
+ void ftp_transfer(bool success);
+ void ftp_fxp(bool success);
+ void ftp_connectionlost();
+};
+
+#endif
diff --git a/src/fileexistsdialog.cpp b/src/fileexistsdialog.cpp
new file mode 100644
index 0000000..284f9b4
--- /dev/null
+++ b/src/fileexistsdialog.cpp
@@ -0,0 +1,44 @@
+/***************************************************************************
+ fileexistsdialog.cpp - description
+ -------------------
+ begin : Mi Nov 19 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#include "fileexistsdialog.h"
+
+FileExistsDialog::FileExistsDialog(QWidget *parent, const char *name ) : KasablancaFileExistsDialog(parent,name)
+{
+}
+FileExistsDialog::~FileExistsDialog(){
+}
+
+void FileExistsDialog::Overwrite()
+{
+ done(overwrite);
+}
+
+void FileExistsDialog::Resume()
+{
+ done(resume);
+}
+
+void FileExistsDialog::Skip()
+{
+ done(skip);
+}
+
+void FileExistsDialog::Rename()
+{
+ done(rename);
+}
diff --git a/src/fileexistsdialog.h b/src/fileexistsdialog.h
new file mode 100644
index 0000000..4c938ec
--- /dev/null
+++ b/src/fileexistsdialog.h
@@ -0,0 +1,47 @@
+/***************************************************************************
+ fileexistsdialog.h - description
+ -------------------
+ begin : Mi Nov 19 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef FILEEXISTSDIALOG_H
+#define FILEEXISTSDIALOG_H
+
+#include <qwidget.h>
+#include "Q_fileexistsdialog.h"
+
+/**
+ *@author mkulke
+ */
+
+class FileExistsDialog : public KasablancaFileExistsDialog {
+ Q_OBJECT
+public:
+ FileExistsDialog(QWidget *parent=0, const char *name=0);
+ ~FileExistsDialog();
+ enum retval
+ {
+ skip = 0,
+ resume,
+ rename,
+ overwrite
+ };
+public slots:
+ void Resume();
+ void Overwrite();
+ void Skip();
+ void Rename();
+};
+
+#endif
diff --git a/src/ftplib.cpp b/src/ftplib.cpp
new file mode 100755
index 0000000..def17f9
--- /dev/null
+++ b/src/ftplib.cpp
@@ -0,0 +1,1562 @@
+/***************************************************************************
+ ftplib.cpp - description
+ -------------------
+ begin : Son Jul 27 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+/* original unmodified copyright notes from Thomas Pfau */
+
+/***************************************************************************/
+/* */
+/* ftplib.c - callable ftp access routines */
+/* Copyright (C) 1996, 1997, 1998 Thomas Pfau, pfau@cnj.digex.net */
+/* 73 Catherine Street, South Bound Brook, NJ, 08880 */
+/* */
+/* This library is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public */
+/* License as published by the Free Software Foundation; either */
+/* version 2 of the License, or (at your option) any later version. */
+/* */
+/* This library is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* Library General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU Library General Public */
+/* License along with this progam; if not, write to the */
+/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
+/* Boston, MA 02111-1307, USA. */
+/* */
+/***************************************************************************/
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include "ftplib.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include <arpa/inet.h>
+#include <string>
+
+using namespace std;
+
+/* socket values */
+#define SETSOCKOPT_OPTVAL_TYPE (void *)
+#define FTPLIB_BUFSIZ 1024
+#define ACCEPT_TIMEOUT 30
+
+/* io types */
+#define FTPLIB_CONTROL 0
+#define FTPLIB_READ 1
+#define FTPLIB_WRITE 2
+
+/*
+ * Constructor
+ */
+
+ftplib::ftplib()
+{
+ SSL_library_init();
+
+ mp_netbuf = static_cast<netbuf *>(calloc(1,sizeof(netbuf)));
+ if (mp_netbuf == NULL) perror("calloc");
+ mp_netbuf->buf = static_cast<char *>(malloc(FTPLIB_BUFSIZ));
+ if (mp_netbuf->buf == NULL)
+ {
+ perror("calloc");
+ free(mp_netbuf);
+ }
+ mp_netbuf->ctx = SSL_CTX_new(SSLv23_method());
+ SSL_CTX_set_verify(mp_netbuf->ctx, SSL_VERIFY_NONE, NULL);
+ mp_netbuf->ssl = SSL_new(mp_netbuf->ctx);
+
+ ClearNetbuf();
+}
+
+/*
+ * Destructor
+ */
+
+ftplib::~ftplib()
+{
+ SSL_free(mp_netbuf->ssl);
+ SSL_CTX_free(mp_netbuf->ctx);
+ free(mp_netbuf->buf);
+ free(mp_netbuf);
+}
+
+/*
+ * socket_wait - wait for socket to receive or flush data
+ *
+ * return 1 if no user callback, otherwise, return value returned by
+ * user callback
+ */
+int ftplib::socket_wait(netbuf *ctl)
+{
+ fd_set fd,*rfd = NULL,*wfd = NULL;
+ struct timeval tv;
+ int rv = 0;
+
+ if (ctl->idlecb == NULL) return 1;
+
+ /*if ((ctl->dir == FTPLIB_CONTROL)
+ || (ctl->idlecb == NULL)
+ || ((ctl->idletime.tv_sec == 0)
+ && //(ctl->idletime.tv_usec 0))
+ return 1;*/
+
+ if (ctl->dir == FTPLIB_WRITE) wfd = &fd;
+ else rfd = &fd;
+
+ FD_ZERO(&fd);
+ do
+ {
+ FD_SET(ctl->handle,&fd);
+ tv = ctl->idletime;
+ rv = select(ctl->handle+1, rfd, wfd, NULL, &tv);
+ if (rv == -1)
+ {
+ rv = 0;
+ strncpy(ctl->ctrl->response, strerror(errno), sizeof(ctl->ctrl->response));
+ break;
+ }
+ else if (rv > 0)
+ {
+ rv = 1;
+ break;
+ }
+ } while ((rv = ctl->idlecb(ctl->cbarg)));
+
+ return rv;
+}
+
+/*
+ * read a line of text
+ *
+ * return -1 on error or bytecount
+ */
+int ftplib::readline(char *buf,int max,netbuf *ctl)
+{
+ int x,retval = 0;
+ char *end,*bp=buf;
+ int eof = 0;
+
+ if ((ctl->dir != FTPLIB_CONTROL) && (ctl->dir != FTPLIB_READ))
+ return -1;
+ if (max == 0)
+ return 0;
+ do
+ {
+ if (ctl->cavail > 0)
+ {
+ x = (max >= ctl->cavail) ? ctl->cavail : max-1;
+ end = static_cast<char*>(memccpy(bp,ctl->cget,'\n',x));
+ if (end != NULL)
+ x = end - bp;
+ retval += x;
+ bp += x;
+ *bp = '\0';
+ max -= x;
+ ctl->cget += x;
+ ctl->cavail -= x;
+ if (end != NULL)
+ {
+ bp -= 2;
+ if (strcmp(bp,"\r\n") == 0)
+ {
+ *bp++ = '\n';
+ *bp++ = '\0';
+ --retval;
+ }
+ break;
+ }
+ }
+ if (max == 1)
+ {
+ *buf = '\0';
+ break;
+ }
+ if (ctl->cput == ctl->cget)
+ {
+ ctl->cput = ctl->cget = ctl->buf;
+ ctl->cavail = 0;
+ ctl->cleft = FTPLIB_BUFSIZ;
+ }
+ if (eof)
+ {
+ if (retval == 0)
+ retval = -1;
+ break;
+ }
+
+ if (!socket_wait(ctl)) return retval;
+
+ if (ctl->tlsdata) x = SSL_read(ctl->ssl, ctl->cput, ctl->cleft);
+ else
+ {
+ if (ctl->tlsctrl) x = SSL_read(ctl->ssl, ctl->cput, ctl->cleft);
+ else x = read(ctl->handle,ctl->cput,ctl->cleft);
+ }
+ if ( x == -1)
+ {
+ perror("read");
+ retval = -1;
+ break;
+ }
+
+ // LOGGING FUNCTIONALITY!!!
+
+ if ((ctl->dir == FTPLIB_CONTROL) && (mp_netbuf->logcb != NULL))
+ {
+ *((ctl->cput)+x) = '\0';
+ mp_netbuf->logcb(ctl->cput, mp_netbuf->cbarg, true);
+ }
+
+ if (x == 0) eof = 1;
+ ctl->cleft -= x;
+ ctl->cavail += x;
+ ctl->cput += x;
+ } while (1);
+ return retval;
+}
+
+/*
+ * write lines of text
+ *
+ * return -1 on error or bytecount
+ */
+int ftplib::writeline(char *buf, int len, netbuf *nData)
+{
+ int x, nb=0, w;
+ char *ubp = buf, *nbp;
+ char lc=0;
+
+ if (nData->dir != FTPLIB_WRITE)
+ return -1;
+ nbp = nData->buf;
+ for (x=0; x < len; x++)
+ {
+ if ((*ubp == '\n') && (lc != '\r'))
+ {
+ if (nb == FTPLIB_BUFSIZ)
+ {
+ if (!socket_wait(nData)) return x;
+
+ if (nData->tlsctrl) w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
+ else w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
+
+ if (w != FTPLIB_BUFSIZ)
+ {
+ printf("write(1) returned %d, errno = %d\n", w, errno);
+ return(-1);
+ }
+ nb = 0;
+ }
+ nbp[nb++] = '\r';
+ }
+ if (nb == FTPLIB_BUFSIZ)
+ {
+ if (!socket_wait(nData))
+ return x;
+
+ if (nData->tlsctrl) w = SSL_write(nData->ssl, nbp, FTPLIB_BUFSIZ);
+ else w = write(nData->handle, nbp, FTPLIB_BUFSIZ);
+
+ if (w != FTPLIB_BUFSIZ)
+ {
+ printf("write(2) returned %d, errno = %d\n", w, errno);
+ return(-1);
+ }
+ nb = 0;
+ }
+ nbp[nb++] = lc = *ubp++;
+ }
+ if (nb)
+ {
+ if (!socket_wait(nData)) return x;
+ if (nData->tlsctrl) w = SSL_write(nData->ssl, nbp, nb);
+ else w = write(nData->handle, nbp, nb);
+ if (w != nb)
+ {
+ printf("write(3) returned %d, errno = %d\n", w, errno);
+ return(-1);
+ }
+ }
+ return len;
+}
+
+/*
+ * read a response from the server
+ *
+ * return 0 if first char doesn't match
+ * return 1 if first char matches
+ */
+int ftplib::readresp(char c, netbuf *nControl)
+{
+ char match[5];
+
+ if (readline(nControl->response,256,nControl) == -1)
+ {
+ perror("Control socket read failed");
+ return 0;
+ }
+
+ if (nControl->response[3] == '-')
+ {
+ strncpy(match,nControl->response,3);
+ match[3] = ' ';
+ match[4] = '\0';
+ do
+ {
+ if (readline(nControl->response,256,nControl) == -1)
+ {
+ perror("Control socket read failed");
+ return 0;
+ }
+ } while (strncmp(nControl->response,match,4));
+ }
+ if (nControl->response[0] == c) return 1;
+ return 0;
+}
+
+/*
+ * FtpLastResponse - return a pointer to the last response received
+ */
+char* ftplib::LastResponse()
+{
+ if ((mp_netbuf) && (mp_netbuf->dir == FTPLIB_CONTROL)) return mp_netbuf->response;
+ return NULL;
+}
+
+/*
+ * ftplib::Connect - connect to remote server
+ *
+ * return 1 if connected, 0 if not
+ */
+int ftplib::Connect(const char *host)
+{
+ int sControl;
+ struct sockaddr_in sin;
+ struct hostent *phe;
+ struct servent *pse;
+ int on=1;
+ int ret;
+ char *lhost;
+ char *pnum;
+
+ mp_netbuf->dir = FTPLIB_CONTROL;
+ mp_netbuf->ctrl = NULL;
+ mp_netbuf->xfered = 0;
+ mp_netbuf->xfered1 = 0;
+ mp_netbuf->tlsctrl = 0;
+ mp_netbuf->tlsdata = 0;
+ mp_netbuf->offset = 0;
+ mp_netbuf->handle = 0;
+
+ memset(&sin,0,sizeof(sin));
+ sin.sin_family = AF_INET;
+ lhost = strdup(host);
+ pnum = strchr(lhost,':');
+ if (pnum == NULL)
+ {
+ if ((pse = getservbyname("ftp","tcp")) == NULL)
+ {
+ perror("getservbyname");
+ return 0;
+ }
+ sin.sin_port = pse->s_port;
+ }
+ else
+ {
+ *pnum++ = '\0';
+ if (isdigit(*pnum)) sin.sin_port = htons(atoi(pnum));
+ else
+ {
+ pse = getservbyname(pnum,"tcp");
+ sin.sin_port = pse->s_port;
+ }
+ }
+
+ ret = inet_aton(lhost, &sin.sin_addr);
+ if (ret == 0)
+ {
+ if ((phe = gethostbyname(lhost)) == NULL)
+ {
+ perror("gethostbyname");
+ return 0;
+ }
+ memcpy((char *)&sin.sin_addr, phe->h_addr, phe->h_length);
+ }
+ free(lhost);
+ sControl = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sControl == -1)
+ {
+ perror("socket");
+ return 0;
+ }
+ if (setsockopt(sControl,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on, sizeof(on)) == -1)
+ {
+ perror("setsockopt");
+ close(sControl);
+ return 0;
+ }
+ if (connect(sControl, (struct sockaddr *)&sin, sizeof(sin)) == -1)
+ {
+ perror("connect");
+ close(sControl);
+ return 0;
+ }
+
+ mp_netbuf->handle = sControl;
+
+ if (readresp('2', mp_netbuf) == 0)
+ {
+ close(sControl);
+ mp_netbuf->handle = 0;
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ * FtpSendCmd - send a command and wait for expected response
+ *
+ * return 1 if proper response received, 0 otherwise
+ */
+int ftplib::FtpSendCmd(const char *cmd, char expresp, netbuf *nControl)
+{
+ char buf[256];
+ int x;
+
+ if (!nControl->handle) return 0;
+
+ if (nControl->dir != FTPLIB_CONTROL) return 0;
+ sprintf(buf,"%s\r\n",cmd);
+
+ if (nControl->tlsctrl) x = SSL_write(nControl->ssl,buf,strlen(buf));
+ else x = write(nControl->handle,buf,strlen(buf));
+
+ if (x <= 0)
+ {
+ perror("write");
+ return 0;
+ }
+
+ if (mp_netbuf->logcb != NULL) mp_netbuf->logcb(buf, mp_netbuf->cbarg, false);
+
+ return readresp(expresp, nControl);
+}
+
+/*
+ * FtpLogin - log in to remote server
+ *
+ * return 1 if logged in, 0 otherwise
+ */
+int ftplib::Login(const char *user, const char *pass)
+{
+ char tempbuf[64];
+
+ if (((strlen(user) + 7) > sizeof(tempbuf)) || ((strlen(pass) + 7) > sizeof(tempbuf))) return 0;
+ sprintf(tempbuf, "USER %s", user);
+ if (!FtpSendCmd(tempbuf,'3',mp_netbuf))
+ {
+ if (mp_netbuf->ctrl != NULL) return 1;
+ if (*LastResponse() == '2') return 1;
+ return 0;
+ }
+ sprintf(tempbuf,"PASS %s",pass);
+ return FtpSendCmd(tempbuf,'2',mp_netbuf);
+}
+
+/*
+ * FtpAcceptConnection - accept connection from server
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::FtpAcceptConnection(netbuf *nData, netbuf *nControl)
+{
+ int sData;
+ struct sockaddr addr;
+ unsigned int l;
+ int i;
+ struct timeval tv;
+ fd_set mask;
+ int rv = 0;
+
+ FD_ZERO(&mask);
+ FD_SET(nControl->handle, &mask);
+ FD_SET(nData->handle, &mask);
+ tv.tv_usec = 0;
+ tv.tv_sec = ACCEPT_TIMEOUT;
+ i = nControl->handle;
+ if (i < nData->handle) i = nData->handle;
+ i = select(i+1, &mask, NULL, NULL, &tv);
+
+ if (i == -1)
+ {
+ strncpy(nControl->response, strerror(errno), sizeof(nControl->response));
+ close(nData->handle);
+ nData->handle = 0;
+ rv = 0;
+ }
+ else if (i == 0)
+ {
+ strcpy(nControl->response, "timed out waiting for connection");
+ close(nData->handle);
+ nData->handle = 0;
+ rv = 0;
+ }
+ else
+ {
+ if (FD_ISSET(nData->handle, &mask))
+ {
+ l = sizeof(addr);
+ sData = accept(nData->handle, &addr, &l);
+ i = errno;
+ close(nData->handle);
+ if (sData > 0)
+ {
+ rv = 1;
+ nData->handle = sData;
+ nData->ctrl = nControl;
+ }
+ else
+ {
+ strncpy(nControl->response, strerror(i), sizeof(nControl->response));
+ nData->handle = 0;
+ rv = 0;
+ }
+ }
+ else if (FD_ISSET(nControl->handle, &mask))
+ {
+ close(nData->handle);
+ nData->handle = 0;
+ readresp('2', nControl);
+ rv = 0;
+ }
+ }
+ return rv;
+}
+
+/*
+ * FtpAccess - return a handle for a data stream
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::FtpAccess(const char *path, int typ, int mode, netbuf *nControl, netbuf **nData)
+//int ftplib::FtpAccess(const char *path, int typ, int mode)
+{
+ char buf[256];
+ int dir, ret;
+
+ if ((path == NULL) && ((typ == FTPLIB_FILE_WRITE)
+ || (typ == FTPLIB_FILE_READ)
+ || (typ == FTPLIB_FILE_READ_APPEND)
+ || (typ == FTPLIB_FILE_WRITE_APPEND)))
+ {
+ sprintf(nControl->response,"Missing path argument for file transfer\n");
+ return 0;
+ }
+ sprintf(buf, "TYPE %c", mode);
+ if (!FtpSendCmd(buf, '2', nControl)) return 0;
+
+ switch (typ)
+ {
+ case FTPLIB_DIR:
+ strcpy(buf,"NLST");
+ dir = FTPLIB_READ;
+ break;
+ case FTPLIB_DIR_VERBOSE:
+ strcpy(buf,"LIST -aL");
+ dir = FTPLIB_READ;
+ break;
+ case FTPLIB_FILE_READ_APPEND:
+ case FTPLIB_FILE_READ:
+ strcpy(buf,"RETR");
+ dir = FTPLIB_READ;
+ break;
+ case FTPLIB_FILE_WRITE_APPEND:
+ case FTPLIB_FILE_WRITE:
+ strcpy(buf,"STOR");
+ dir = FTPLIB_WRITE;
+ break;
+ default:
+ sprintf(nControl->response, "Invalid open type %d\n", typ);
+ return 0;
+ }
+ if (path != NULL)
+ {
+ int i = strlen(buf);
+ buf[i++] = ' ';
+ if ((strlen(path) + i) >= sizeof(buf)) return 0;
+ strcpy(&buf[i],path);
+ }
+
+ if (nControl->cmode == ftplib::pasv)
+ {
+ if (FtpOpenPasv(nControl, nData, mode, dir, buf) == -1) return 0;
+ }
+
+ if (nControl->cmode == ftplib::port)
+ {
+ if (FtpOpenPort(nControl, nData, mode, dir, buf) == -1) return 0;
+ if (!FtpAcceptConnection(*nData,nControl))
+ {
+ FtpClose(*nData);
+ *nData = NULL;
+ return 0;
+ }
+ }
+
+ if (nControl->tlsdata)
+ {
+ (*nData)->ssl = SSL_new(nControl->ctx);
+ (*nData)->sbio = BIO_new_socket((*nData)->handle, BIO_NOCLOSE);
+ SSL_set_bio((*nData)->ssl,(*nData)->sbio,(*nData)->sbio);
+ ret = SSL_connect((*nData)->ssl);
+ if (ret != 1) return 0;
+ (*nData)->tlsdata = 1;
+ }
+
+ return 1;
+}
+
+/*
+ * FtpOpenPort - Establishes a PORT connection for data transfer
+ *
+ * return 1 if successful, -1 otherwise
+ */
+int ftplib::FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir, char *cmd)
+{
+ int sData;
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in in;
+ } sin;
+ struct linger lng = { 0, 0 };
+ unsigned int l;
+ int on=1;
+ netbuf *ctrl;
+ char buf[256];
+
+ if (nControl->dir != FTPLIB_CONTROL) return -1;
+ if ((dir != FTPLIB_READ) && (dir != FTPLIB_WRITE))
+ {
+ sprintf(nControl->response, "Invalid direction %d\n", dir);
+ return -1;
+ }
+ if ((mode != ftplib::ascii) && (mode != ftplib::image))
+ {
+ sprintf(nControl->response, "Invalid mode %c\n", mode);
+ return -1;
+ }
+ l = sizeof(sin);
+
+ if (getsockname(nControl->handle, &sin.sa, &l) < 0)
+ {
+ perror("getsockname");
+ return -1;
+ }
+
+ sData = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
+ if (sData == -1)
+ {
+ perror("socket");
+ return -1;
+ }
+ if (setsockopt(sData,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on,sizeof(on)) == -1)
+ {
+ perror("setsockopt");
+ close(sData);
+ return -1;
+ }
+ if (setsockopt(sData,SOL_SOCKET,SO_LINGER, SETSOCKOPT_OPTVAL_TYPE &lng,sizeof(lng)) == -1)
+ {
+ perror("setsockopt");
+ close(sData);
+ return -1;
+ }
+
+ sin.in.sin_port = 0;
+ if (bind(sData, &sin.sa, sizeof(sin)) == -1)
+ {
+ perror("bind");
+ close(sData);
+ return -1;
+ }
+ if (listen(sData, 1) < 0)
+ {
+ perror("listen");
+ close(sData);
+ return -1;
+ }
+ if (getsockname(sData, &sin.sa, &l) < 0) return 0;
+ sprintf(buf, "PORT %hhu,%hhu,%hhu,%hhu,%hhu,%hhu",
+ (unsigned char) sin.sa.sa_data[2],
+ (unsigned char) sin.sa.sa_data[3],
+ (unsigned char) sin.sa.sa_data[4],
+ (unsigned char) sin.sa.sa_data[5],
+ (unsigned char) sin.sa.sa_data[0],
+ (unsigned char) sin.sa.sa_data[1]);
+ if (!FtpSendCmd(buf,'2',nControl))
+ {
+ close(sData);
+ return -1;
+ }
+
+ if (mp_netbuf->offset != 0)
+ {
+ char buf[256];
+ sprintf(buf,"REST %lld", mp_netbuf->offset);
+ if (!FtpSendCmd(buf,'3',nControl))
+ {
+ close(sData);
+ return 0;
+ }
+ }
+
+ ctrl = static_cast<netbuf*>(calloc(1,sizeof(netbuf)));
+ if (ctrl == NULL)
+ {
+ perror("calloc");
+ close(sData);
+ return -1;
+ }
+ if ((mode == 'A') && ((ctrl->buf = static_cast<char*>(malloc(FTPLIB_BUFSIZ))) == NULL))
+ {
+ perror("calloc");
+ close(sData);
+ free(ctrl);
+ return -1;
+ }
+
+ if (!FtpSendCmd(cmd, '1', nControl))
+ {
+ FtpClose(*nData);
+ *nData = NULL;
+ return -1;
+ }
+
+ ctrl->handle = sData;
+ ctrl->dir = dir;
+ ctrl->ctrl = (nControl->cmode == ftplib::pasv) ? nControl : NULL;
+ ctrl->idletime = nControl->idletime;
+ ctrl->cbarg = nControl->cbarg;
+ ctrl->xfered = 0;
+ ctrl->xfered1 = 0;
+ ctrl->cbbytes = nControl->cbbytes;
+ if (ctrl->idletime.tv_sec || ctrl->idletime.tv_usec) ctrl->idlecb = nControl->idlecb;
+ else ctrl->idlecb = NULL;
+ if (ctrl->cbbytes ) ctrl->xfercb = nControl->xfercb;
+ else ctrl->xfercb = NULL;
+ *nData = ctrl;
+
+ return 1;
+}
+
+/*
+ * FtpOpenPasv - Establishes a PASV connection for data transfer
+ *
+ * return 1 if successful, -1 otherwise
+ */
+int ftplib::FtpOpenPasv(netbuf *nControl, netbuf **nData, int mode, int dir, char *cmd)
+{
+ int sData;
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in in;
+ } sin;
+ struct linger lng = { 0, 0 };
+ unsigned int l;
+ int on=1;
+ netbuf *ctrl;
+ char *cp;
+ unsigned char v[6];
+ int ret;
+
+ if (nControl->dir != FTPLIB_CONTROL) return -1;
+ if ((dir != FTPLIB_READ) && (dir != FTPLIB_WRITE))
+ {
+ sprintf(nControl->response, "Invalid direction %d\n", dir);
+ return -1;
+ }
+ if ((mode != ftplib::ascii) && (mode != ftplib::image))
+ {
+ sprintf(nControl->response, "Invalid mode %c\n", mode);
+ return -1;
+ }
+ l = sizeof(sin);
+
+ memset(&sin, 0, l);
+ sin.in.sin_family = AF_INET;
+ if (!FtpSendCmd("PASV",'2',nControl)) return -1;
+ cp = strchr(nControl->response,'(');
+ if (cp == NULL) return -1;
+ cp++;
+ sscanf(cp,"%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",&v[2],&v[3],&v[4],&v[5],&v[0],&v[1]);
+ if (nControl->correctpasv) if (!CorrectPasvResponse(v)) return -1;
+ sin.sa.sa_data[2] = v[2];
+ sin.sa.sa_data[3] = v[3];
+ sin.sa.sa_data[4] = v[4];
+ sin.sa.sa_data[5] = v[5];
+ sin.sa.sa_data[0] = v[0];
+ sin.sa.sa_data[1] = v[1];
+
+ if (mp_netbuf->offset != 0)
+ {
+ char buf[256];
+ sprintf(buf,"REST %lld",mp_netbuf->offset);
+ if (!FtpSendCmd(buf,'3',nControl)) return 0;
+ }
+
+ sData = socket(PF_INET,SOCK_STREAM,IPPROTO_TCP);
+ if (sData == -1)
+ {
+ perror("socket");
+ return -1;
+ }
+ if (setsockopt(sData,SOL_SOCKET,SO_REUSEADDR, SETSOCKOPT_OPTVAL_TYPE &on,sizeof(on)) == -1)
+ {
+ perror("setsockopt");
+ close(sData);
+ return -1;
+ }
+ if (setsockopt(sData,SOL_SOCKET,SO_LINGER, SETSOCKOPT_OPTVAL_TYPE &lng,sizeof(lng)) == -1)
+ {
+ perror("setsockopt");
+ close(sData);
+ return -1;
+ }
+
+ if (nControl->dir != FTPLIB_CONTROL) return -1;
+ sprintf(cmd,"%s\r\n",cmd);
+ if (nControl->tlsctrl) ret = SSL_write(nControl->ssl,cmd,strlen(cmd));
+ else ret = write(nControl->handle,cmd,strlen(cmd));
+ if (ret <= 0)
+ {
+ perror("write");
+ return -1;
+ }
+
+ if (connect(sData, &sin.sa, sizeof(sin.sa)) == -1)
+ {
+ perror("connect");
+ close(sData);
+ return -1;
+ }
+ if (!readresp('1', nControl))
+ {
+ close(sData);
+ return -1;
+ }
+ ctrl = static_cast<netbuf*>(calloc(1,sizeof(netbuf)));
+ if (ctrl == NULL)
+ {
+ perror("calloc");
+ close(sData);
+ return -1;
+ }
+ if ((mode == 'A') && ((ctrl->buf = static_cast<char*>(malloc(FTPLIB_BUFSIZ))) == NULL))
+ {
+ perror("calloc");
+ close(sData);
+ free(ctrl);
+ return -1;
+ }
+ ctrl->handle = sData;
+ ctrl->dir = dir;
+ ctrl->ctrl = (nControl->cmode == ftplib::pasv) ? nControl : NULL;
+ ctrl->idletime = nControl->idletime;
+ ctrl->cbarg = nControl->cbarg;
+ ctrl->xfered = 0;
+ ctrl->xfered1 = 0;
+ ctrl->cbbytes = nControl->cbbytes;
+ if (ctrl->idletime.tv_sec || ctrl->idletime.tv_usec) ctrl->idlecb = nControl->idlecb;
+ else ctrl->idlecb = NULL;
+ if (ctrl->cbbytes ) ctrl->xfercb = nControl->xfercb;
+ else ctrl->xfercb = NULL;
+ *nData = ctrl;
+
+ return 1;
+}
+
+/*
+ * FtpClose - close a data connection
+ */
+int ftplib::FtpClose(netbuf *nData)
+{
+ netbuf *ctrl;
+
+ if (nData->dir == FTPLIB_WRITE)
+ {
+ if (nData->buf != NULL) writeline(NULL, 0, nData);
+ }
+ else if (nData->dir != FTPLIB_READ) return 0;
+ if (nData->buf) free(nData->buf);
+ shutdown(nData->handle,2);
+ close(nData->handle);
+
+ ctrl = nData->ctrl;
+ SSL_free(nData->ssl);
+ free(nData);
+ if (ctrl) return readresp('2', ctrl);
+ return 1;
+}
+
+/*
+ * FtpRead - read from a data connection
+ */
+int ftplib::FtpRead(void *buf, int max, netbuf *nData)
+{
+ int i;
+
+ if (nData->dir != FTPLIB_READ)
+ return 0;
+ if (nData->buf) i = readline(static_cast<char*>(buf), max, nData);
+ else
+ {
+ i = socket_wait(nData);
+ if (i != 1) return 0;
+ if (nData->tlsdata) i = SSL_read(nData->ssl, buf, max);
+ else i = read(nData->handle,buf,max);
+ }
+ if (i == -1) return 0;
+ nData->xfered += i;
+ if (nData->xfercb && nData->cbbytes)
+ {
+ nData->xfered1 += i;
+ if (nData->xfered1 > nData->cbbytes)
+ {
+ if (nData->xfercb(nData->xfered, nData->cbarg) == 0) return 0;
+ nData->xfered1 = 0;
+ }
+ }
+ return i;
+}
+
+/*
+ * FtpWrite - write to a data connection
+ */
+int ftplib::FtpWrite(void *buf, int len, netbuf *nData)
+{
+ int i;
+
+ if (nData->dir != FTPLIB_WRITE) return 0;
+ if (nData->buf) i = writeline(static_cast<char*>(buf), len, nData);
+ else
+ {
+ socket_wait(nData);
+ if (nData->tlsdata) i = SSL_write(nData->ssl, buf, len);
+ else i = write(nData->handle, buf, len);
+ }
+ if (i == -1) return 0;
+ nData->xfered += i;
+
+ if (nData->xfercb && nData->cbbytes)
+ {
+ nData->xfered1 += i;
+ if (nData->xfered1 > nData->cbbytes)
+ {
+ if (nData->xfercb(nData->xfered, nData->cbarg) == 0) return 0;
+ nData->xfered1 = 0;
+ }
+ }
+ return i;
+}
+
+/*
+ * FtpSite - send a SITE command
+ *
+ * return 1 if command successful, 0 otherwise
+ */
+int ftplib::Site(const char *cmd)
+{
+ char buf[256];
+
+ if ((strlen(cmd) + 7) > sizeof(buf)) return 0;
+ sprintf(buf,"SITE %s",cmd);
+ if (!FtpSendCmd(buf,'2',mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpRaw - send a raw string string
+ *
+ * return 1 if command successful, 0 otherwise
+ */
+
+int ftplib::Raw(const char *cmd)
+{
+ char buf[256];
+ strncpy(buf, cmd, 256);
+ if (!FtpSendCmd(buf,'2',mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpSysType - send a SYST command
+ *
+ * Fills in the user buffer with the remote system type. If more
+ * information from the response is required, the user can parse
+ * it out of the response buffer returned by FtpLastResponse().
+ *
+ * return 1 if command successful, 0 otherwise
+ */
+int ftplib::SysType(char *buf, int max)
+{
+ int l = max;
+ char *b = buf;
+ char *s;
+ if (!FtpSendCmd("SYST",'2',mp_netbuf)) return 0;
+ s = &mp_netbuf->response[4];
+ while ((--l) && (*s != ' ')) *b++ = *s++;
+ *b++ = '\0';
+ return 1;
+}
+
+/*
+ * FtpMkdir - create a directory at server
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Mkdir(const char *path)
+{
+ char buf[256];
+
+ if ((strlen(path) + 6) > sizeof(buf)) return 0;
+ sprintf(buf,"MKD %s",path);
+ if (!FtpSendCmd(buf,'2', mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpChdir - change path at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Chdir(const char *path)
+{
+ char buf[256];
+
+ if ((strlen(path) + 6) > sizeof(buf)) return 0;
+ sprintf(buf,"CWD %s",path);
+ if (!FtpSendCmd(buf,'2',mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpCDUp - move to parent directory at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Cdup()
+{
+ if (!FtpSendCmd("CDUP",'2',mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpRmdir - remove directory at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Rmdir(const char *path)
+{
+ char buf[256];
+
+ if ((strlen(path) + 6) > sizeof(buf)) return 0;
+ sprintf(buf,"RMD %s",path);
+ if (!FtpSendCmd(buf,'2',mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpPwd - get working directory at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Pwd(char *path, int max)
+{
+ int l = max;
+ char *b = path;
+ char *s;
+
+ if (!FtpSendCmd("PWD",'2',mp_netbuf)) return 0;
+ s = strchr(mp_netbuf->response, '"');
+ if (s == NULL) return 0;
+ s++;
+ while ((--l) && (*s) && (*s != '"')) *b++ = *s++;
+ *b++ = '\0';
+ return 1;
+}
+
+/*
+ * FtpXfer - issue a command and transfer data
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::FtpXfer(const char *localfile, const char *path, netbuf *nControl, int typ, int mode)
+{
+ int l,c;
+ char *dbuf;
+ FILE *local = NULL;
+ netbuf *nData;
+ int rv=1; // 3.1-1
+
+ if (localfile != NULL)
+ {
+ printf("localfile: -%s-", localfile);
+
+ //local = fopen(localfile, (typ == FTPLIB_FILE_WRITE) ? "r" : "w");
+ char ac[3] = " ";
+ if ((typ == FTPLIB_DIR) || (typ == FTPLIB_DIR_VERBOSE)) { ac[0] = 'w'; ac[1] = '\0'; }
+ if (typ == FTPLIB_FILE_READ) { ac[0] = 'w'; ac[1] = '\0'; }
+ if (typ == FTPLIB_FILE_WRITE_APPEND) { ac[0] = 'r'; ac[1] = '\0'; }
+ if (typ == FTPLIB_FILE_READ_APPEND) { ac[0] = 'a'; ac[1] = '\0'; }
+ if (typ == FTPLIB_FILE_WRITE) { ac[0] = 'r'; ac[1] = '\0'; }
+ if (mode == ftplib::image) ac[1] = 'b';
+
+ local = fopen64(localfile, ac);
+ if (typ == FTPLIB_FILE_WRITE_APPEND) fseeko64(local,mp_netbuf->offset,SEEK_SET);
+
+ if (local == NULL)
+ {
+ strncpy(nControl->response, strerror(errno), sizeof(nControl->response));
+ return 0;
+ }
+ }
+ if (local == NULL) local = ((typ == FTPLIB_FILE_WRITE)
+ || (typ == FTPLIB_FILE_WRITE_APPEND)) ? stdin : stdout;
+ if (!FtpAccess(path, typ, mode, nControl, &nData)) return 0;
+
+ dbuf = static_cast<char*>(malloc(FTPLIB_BUFSIZ));
+ if ((typ == FTPLIB_FILE_WRITE) || (typ == FTPLIB_FILE_WRITE_APPEND))
+ {
+ while ((l = fread(dbuf, 1, FTPLIB_BUFSIZ, local)) > 0)
+ {
+ if ((c = FtpWrite(dbuf, l, nData)) < l)
+ {
+ printf("short write: passed %d, wrote %d\n", l, c);
+ rv = 0;
+ break;
+ }
+ }
+ }
+ else
+ {
+ while ((l = FtpRead(dbuf, FTPLIB_BUFSIZ, nData)) > 0)
+ {
+ if (fwrite(dbuf, 1, l, local) <= 0)
+ {
+ perror("localfile write");
+ break;
+ }
+ }
+ }
+ free(dbuf);
+ fflush(local);
+ if (localfile != NULL)
+ fclose(local);
+ return FtpClose(nData);
+ return rv;
+}
+
+/*
+ * FtpNlst - issue an NLST command and write response to output
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Nlst(const char *outputfile, const char *path)
+{
+ mp_netbuf->offset = 0;
+ return FtpXfer(outputfile, path, mp_netbuf, FTPLIB_DIR, ftplib::ascii);
+}
+
+/*
+ * FtpDir - issue a LIST command and write response to output
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Dir(const char *outputfile, const char *path)
+{
+ mp_netbuf->offset = 0;
+ return FtpXfer(outputfile, path, mp_netbuf, FTPLIB_DIR_VERBOSE, ftplib::ascii);
+}
+
+/*
+ * FtpSize - determine the size of a remote file
+ *
+ * return 1 if successful, 0 otherwise
+ */
+//int ftplib::Size(const char *path, int *size, char mode)
+int ftplib::Size(const char *path, int *size, ftplib::ftp mode)
+{
+ char cmd[256];
+ int resp,sz,rv=1;
+
+ if ((strlen(path) + 7) > sizeof(cmd)) return 0;
+
+ sprintf(cmd, "TYPE %c", mode);
+ if (!FtpSendCmd(cmd, '2', mp_netbuf)) return 0;
+
+ sprintf(cmd,"SIZE %s",path);
+ if (!FtpSendCmd(cmd,'2',mp_netbuf)) rv = 0;
+ else
+ {
+ if (sscanf(mp_netbuf->response, "%d %d", &resp, &sz) == 2) *size = sz;
+ else rv = 0;
+ }
+ return rv;
+}
+
+/*
+ * FtpModDate - determine the modification date of a remote file
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::ModDate(const char *path, char *dt, int max)
+{
+ char buf[256];
+ int rv = 1;
+
+ if ((strlen(path) + 7) > sizeof(buf)) return 0;
+ sprintf(buf,"MDTM %s",path);
+ if (!FtpSendCmd(buf,'2',mp_netbuf)) rv = 0;
+ else strncpy(dt, &mp_netbuf->response[4], max);
+ return rv;
+}
+
+/*
+ * FtpGet - issue a GET command and write received data to output
+ *
+ * return 1 if successful, 0 otherwise
+ */
+
+int ftplib::Get(const char *outputfile, const char *path, ftplib::ftp mode, off64_t offset)
+{
+ mp_netbuf->offset = offset;
+ if (offset == 0) return FtpXfer(outputfile, path, mp_netbuf, FTPLIB_FILE_READ, mode);
+ else return FtpXfer(outputfile, path, mp_netbuf, FTPLIB_FILE_READ_APPEND, mode);
+}
+
+/*
+ * FtpPut - issue a PUT command and send data from input
+ *
+ * return 1 if successful, 0 otherwise
+ */
+
+int ftplib::Put(const char *inputfile, const char *path, ftplib::ftp mode, off64_t offset)
+{
+ mp_netbuf->offset = offset;
+ if (offset == 0) return FtpXfer(inputfile, path, mp_netbuf, FTPLIB_FILE_WRITE, mode);
+ else return FtpXfer(inputfile, path, mp_netbuf, FTPLIB_FILE_WRITE_APPEND, mode);
+}
+
+/*
+ * FtpRename - rename a file at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Rename(const char *src, const char *dst)
+{
+ char cmd[256];
+
+ if (((strlen(src) + 7) > sizeof(cmd)) || ((strlen(dst) + 7) > sizeof(cmd))) return 0;
+ sprintf(cmd,"RNFR %s",src);
+ if (!FtpSendCmd(cmd,'3',mp_netbuf)) return 0;
+ sprintf(cmd,"RNTO %s",dst);
+ if (!FtpSendCmd(cmd,'2',mp_netbuf)) return 0;
+
+ return 1;
+}
+
+/*
+ * FtpDelete - delete a file at remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Delete(const char *fnm)
+{
+ char cmd[256];
+
+ if ((strlen(fnm) + 7) > sizeof(cmd)) return 0;
+ sprintf(cmd,"DELE %s",fnm);
+ if (!FtpSendCmd(cmd,'2', mp_netbuf)) return 0;
+ return 1;
+}
+
+/*
+ * FtpQuit - disconnect from remote
+ *
+ * return 1 if successful, 0 otherwise
+ */
+int ftplib::Quit()
+{
+ if (mp_netbuf->dir != FTPLIB_CONTROL) return 0;
+ if (mp_netbuf->handle == 0)
+ {
+ strcpy(mp_netbuf->response, "error: no anwser from server\n");
+ return 0;
+ }
+ if (!FtpSendCmd("QUIT",'2',mp_netbuf))
+ {
+ close(mp_netbuf->handle);
+ return 0;
+ }
+ else
+ {
+ close(mp_netbuf->handle);
+ return 1;
+ }
+}
+
+int ftplib::Fxp(ftplib* src, ftplib* dst, const char *pathSrc, const char *pathDst, ftplib::ftp mode, ftplib::ftp method)
+{
+ char *cp;
+ unsigned char v[6];
+ char buf[256];
+ int retval = 0;
+
+ sprintf(buf, "TYPE %c", mode);
+ if (!dst->FtpSendCmd(buf,'2',dst->mp_netbuf)) return -1;
+ if (!src->FtpSendCmd(buf,'2',src->mp_netbuf)) return -1;
+
+ if (method == ftplib::defaultfxp)
+ {
+ // PASV dst
+
+ if (!dst->FtpSendCmd("PASV",'2',dst->mp_netbuf)) return -1;
+ cp = strchr(dst->mp_netbuf->response,'(');
+ if (cp == NULL) return -1;
+ cp++;
+ sscanf(cp,"%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",&v[2],&v[3],&v[4],&v[5],&v[0],&v[1]);
+ if (dst->mp_netbuf->correctpasv) if (!dst->CorrectPasvResponse(v)) return -1;
+
+ // PORT src
+
+ sprintf(buf, "PORT %d,%d,%d,%d,%d,%d", v[2],v[3],v[4],v[5],v[0],v[1]);
+ if (!src->FtpSendCmd(buf,'2',src->mp_netbuf)) return -1;
+
+ // RETR src
+
+ strcpy(buf,"RETR");
+ if (pathSrc != NULL)
+ {
+ int i = strlen(buf);
+ buf[i++] = ' ';
+ if ((strlen(pathSrc) + i) >= sizeof(buf)) return 0;
+ strcpy(&buf[i],pathSrc);
+ }
+ if (!src->FtpSendCmd(buf, '1', src->mp_netbuf)) return 0;
+
+ // STOR dst
+
+ strcpy(buf,"STOR");
+ if (pathDst != NULL)
+ {
+ int i = strlen(buf);
+ buf[i++] = ' ';
+ if ((strlen(pathDst) + i) >= sizeof(buf)) return 0;
+ strcpy(&buf[i],pathDst);
+ }
+ if (!dst->FtpSendCmd(buf, '1', dst->mp_netbuf))
+ {
+ /* this closes the data connection, to abort the RETR on
+ the source ftp. all hail pftp, it took me several
+ hours and i was absolutely clueless, playing around with
+ ABOR and whatever, when i desperately checked the pftp
+ source which gave me this final hint. thanks dude(s). */
+
+ dst->FtpSendCmd("PASV", '2', dst->mp_netbuf);
+ src->readresp('4', src->mp_netbuf);
+ return 0;
+ }
+
+ retval = (src->readresp('2', src->mp_netbuf)) & (dst->readresp('2', dst->mp_netbuf));
+
+ }
+ else
+ {
+ // PASV src
+
+ if (!src->FtpSendCmd("PASV",'2',src->mp_netbuf)) return -1;
+ cp = strchr(src->mp_netbuf->response,'(');
+ if (cp == NULL) return -1;
+ cp++;
+ sscanf(cp,"%hhu,%hhu,%hhu,%hhu,%hhu,%hhu",&v[2],&v[3],&v[4],&v[5],&v[0],&v[1]);
+ if (src->mp_netbuf->correctpasv) if (!src->CorrectPasvResponse(v)) return -1;
+
+ // PORT dst
+
+ sprintf(buf, "PORT %d,%d,%d,%d,%d,%d", v[2],v[3],v[4],v[5],v[0],v[1]);
+ if (!dst->FtpSendCmd(buf,'2',dst->mp_netbuf)) return -1;
+
+ // STOR dest
+
+ strcpy(buf,"STOR");
+ if (pathDst != NULL)
+ {
+ int i = strlen(buf);
+ buf[i++] = ' ';
+ if ((strlen(pathDst) + i) >= sizeof(buf)) return 0;
+ strcpy(&buf[i],pathDst);
+ }
+ if (!dst->FtpSendCmd(buf, '1', dst->mp_netbuf)) return 0;
+
+ // RETR src
+
+ strcpy(buf,"RETR");
+ if (pathSrc != NULL)
+ {
+ int i = strlen(buf);
+ buf[i++] = ' ';
+ if ((strlen(pathSrc) + i) >= sizeof(buf)) return 0;
+ strcpy(&buf[i],pathSrc);
+ }
+ if (!src->FtpSendCmd(buf, '1', src->mp_netbuf))
+ {
+ src->FtpSendCmd("PASV", '2', src->mp_netbuf);
+ dst->readresp('4', dst->mp_netbuf);
+ return 0;
+ }
+
+ // wait til its finished!
+
+ retval = (src->readresp('2', src->mp_netbuf)) & (dst->readresp('2', dst->mp_netbuf));
+
+ }
+
+ return retval;
+}
+int ftplib::SetDataEncryption(ftplib::ftp flag)
+{
+ if (!mp_netbuf->tlsctrl) return 0;
+ if (!FtpSendCmd("PBSZ 0",'2',mp_netbuf)) return 0;
+ switch(flag)
+ {
+ case 0:
+ mp_netbuf->tlsdata = 0;
+ if (!FtpSendCmd("PROT C",'2',mp_netbuf)) return 0;
+ break;
+ case 1:
+ mp_netbuf->tlsdata = 1;
+ if (!FtpSendCmd("PROT P",'2',mp_netbuf)) return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+int ftplib::NegotiateEncryption()
+{
+ int ret;
+
+ if (!FtpSendCmd("AUTH TLS",'2',mp_netbuf)) return 0;
+
+ mp_netbuf->sbio = BIO_new_socket(mp_netbuf->handle, BIO_NOCLOSE);
+ SSL_set_bio(mp_netbuf->ssl,mp_netbuf->sbio,mp_netbuf->sbio);
+
+ ret = SSL_connect(mp_netbuf->ssl);
+ if (ret == 1) mp_netbuf->tlsctrl = 1;
+
+ if (ret < 1) return 0;
+
+ return 1;
+}
+
+void ftplib::SetCallbackIdleFunction(FtpCallbackIdle pointer)
+{
+ mp_netbuf->idlecb = pointer;
+}
+
+void ftplib::SetCallbackXferFunction(FtpCallbackXfer pointer)
+{
+ mp_netbuf->xfercb = pointer;
+}
+
+void ftplib::SetCallbackLogFunction(FtpCallbackLog pointer)
+{
+ mp_netbuf->logcb = pointer;
+}
+
+void ftplib::SetCallbackArg(void *arg)
+{
+ mp_netbuf->cbarg = arg;
+}
+
+void ftplib::SetCallbackBytes(off64_t bytes)
+{
+ mp_netbuf->cbbytes = bytes;
+}
+
+void ftplib::SetCallbackIdletime(int time)
+{
+ mp_netbuf->idletime.tv_sec = time / 1000;
+ mp_netbuf->idletime.tv_usec = (time % 1000) * 1000;
+}
+
+void ftplib::SetConnmode(ftplib::ftp mode)
+{
+ if ((mode != ftplib::pasv) && (mode != ftplib::port)) mode = ftplib::defaultconnmode;
+ mp_netbuf->cmode = mode;
+}
+
+void ftplib::ClearNetbuf()
+{
+ mp_netbuf->dir = FTPLIB_CONTROL;
+ mp_netbuf->ctrl = NULL;
+ mp_netbuf->cmode = ftplib::defaultconnmode;
+ mp_netbuf->idlecb = NULL;
+ mp_netbuf->idletime.tv_sec = mp_netbuf->idletime.tv_usec = 0;
+ mp_netbuf->cbarg = NULL;
+ mp_netbuf->xfered = 0;
+ mp_netbuf->xfered1 = 0;
+ mp_netbuf->cbbytes = 0;
+ mp_netbuf->tlsctrl = 0;
+ mp_netbuf->tlsdata = 0;
+ mp_netbuf->offset = 0;
+ mp_netbuf->handle = 0;
+ mp_netbuf->logcb = NULL;
+ mp_netbuf->xfercb = NULL;
+ mp_netbuf->correctpasv = false;
+}
+
+int ftplib::CorrectPasvResponse(unsigned char *v)
+{
+ struct sockaddr ipholder;
+ unsigned int ipholder_size = sizeof(ipholder);
+
+ if (getpeername(mp_netbuf->handle, &ipholder, &ipholder_size) == -1)
+ {
+ perror("getpeername");
+ close(mp_netbuf->handle);
+ return 0;
+ }
+
+ for (int i = 2; i < 6; i++) v[i] = ipholder.sa_data[i];
+
+ return 1;
+}
diff --git a/src/ftplib.h b/src/ftplib.h
new file mode 100755
index 0000000..78a567f
--- /dev/null
+++ b/src/ftplib.h
@@ -0,0 +1,161 @@
+/***************************************************************************
+ ftplib.h - description
+ -------------------
+ begin : Son Jul 27 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+/* original unmodified copyright notes from Thomas Pfau */
+
+/***************************************************************************/
+/* */
+/* ftplib.c - callable ftp access routines */
+/* Copyright (C) 1996, 1997, 1998 Thomas Pfau, pfau@cnj.digex.net */
+/* 73 Catherine Street, South Bound Brook, NJ, 08880 */
+/* */
+/* This library is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Library General Public */
+/* License as published by the Free Software Foundation; either */
+/* version 2 of the License, or (at your option) any later version. */
+/* */
+/* This library is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* Library General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU Library General Public */
+/* License along with this progam; if not, write to the */
+/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
+/* Boston, MA 02111-1307, USA. */
+/* */
+/***************************************************************************/
+
+#ifndef FTPLIB_H
+#define FTPLIB_H
+
+/* FtpAccess() type codes */
+#define FTPLIB_DIR 1
+#define FTPLIB_DIR_VERBOSE 2
+#define FTPLIB_FILE_READ 3
+#define FTPLIB_FILE_WRITE 4
+#define FTPLIB_FILE_READ_APPEND 5
+#define FTPLIB_FILE_WRITE_APPEND 6
+#define FTPLIB_ASCII 'A'
+#define FTPLIB_IMAGE 'I'
+
+#include <sys/time.h>
+#include <openssl/ssl.h>
+
+using namespace std;
+
+/**
+ *@author mkulke
+ */
+
+typedef int (*FtpCallbackXfer)(off64_t xfered, void *arg);
+typedef int (*FtpCallbackIdle)(void *arg);
+typedef void (*FtpCallbackLog)(char *str, void* arg, bool out);
+
+struct netbuf {
+ char *cput,*cget;
+ int handle;
+ int cavail,cleft;
+ char *buf;
+ int dir;
+ netbuf *ctrl;
+ int cmode;
+ int tlsctrl;
+ int tlsdata;
+ struct timeval idletime;
+ FtpCallbackXfer xfercb;
+ FtpCallbackIdle idlecb;
+ FtpCallbackLog logcb;
+ void *cbarg;
+ off64_t xfered;
+ off64_t cbbytes;
+ off64_t xfered1;
+ char response[256];
+ SSL* ssl;
+ SSL_CTX* ctx;
+ BIO* sbio;
+ off64_t offset;
+ bool correctpasv;
+};
+
+class ftplib {
+public:
+ enum ftp
+ {
+ pasv = 1,
+ port = 2,
+ defaultconnmode = 1,
+ ascii = 'A',
+ image = 'I',
+ unencrypted = 0,
+ secure = 1,
+ defaultfxp = 0,
+ alternativefxp = 1
+ };
+ ftplib();
+ ~ftplib();
+ char* LastResponse();
+ int Connect(const char *host);
+ int Login(const char *user, const char *pass);
+ int Site(const char *cmd);
+ int Raw(const char *cmd);
+ int SysType(char *buf, int max);
+ int Mkdir(const char *path);
+ int Chdir(const char *path);
+ int Cdup();
+ int Rmdir(const char *path);
+ int Pwd(char *path, int max);
+ int Nlst(const char *outputfile, const char *path);
+ int Dir(const char *outputfile, const char *path);
+ int Size(const char *path, int *size, ftplib::ftp mode);
+ int ModDate(const char *path, char *dt, int max);
+ int Get(const char *outputfile, const char *path, ftplib::ftp mode, off64_t offset = 0);
+ int Put(const char *inputfile, const char *path, ftplib::ftp mode, off64_t offset= 0);
+ int Rename(const char *src, const char *dst);
+ int Delete(const char *fnm);
+ int SetDataEncryption(ftplib::ftp flag);
+ int NegotiateEncryption();
+ int Quit();
+ void SetCallbackIdleFunction(FtpCallbackIdle pointer);
+ void SetCallbackLogFunction(FtpCallbackLog pointer);
+ void SetCallbackXferFunction(FtpCallbackXfer pointer);
+ void SetCallbackArg(void *arg);
+ void SetCallbackBytes(off64_t bytes);
+ void SetCorrectPasv(bool b) { mp_netbuf->correctpasv = b; };
+ void SetCallbackIdletime(int time);
+ void SetConnmode(ftplib::ftp mode);
+ static int Fxp(ftplib* src, ftplib* dst, const char *pathSrc, const char *pathDst, ftplib::ftp mode, ftplib::ftp method);
+ netbuf* mp_netbuf;
+ int FtpRead(void *buf, int max, netbuf *nData);
+ int FtpWrite(void *buf, int len, netbuf *nData);
+ int FtpAccess(const char *path, int typ, int mode, netbuf *nControl, netbuf **nData);
+ int FtpClose(netbuf *nData);
+private:
+ int FtpXfer(const char *localfile, const char *path, netbuf *nControl, int typ, int mode);
+ int FtpOpenPasv(netbuf *nControl, netbuf **nData, int mode, int dir, char *cmd);
+ int FtpSendCmd(const char *cmd, char expresp, netbuf *nControl);
+ int FtpAcceptConnection(netbuf *nData, netbuf *nControl);
+ int FtpOpenPort(netbuf *nControl, netbuf **nData, int mode, int dir, char *cmd);
+ int socket_wait(netbuf *ctl);
+ int readline(char *buf,int max,netbuf *ctl);
+ int writeline(char *buf, int len, netbuf *nData);
+ int readresp(char c, netbuf *nControl);
+ void ClearNetbuf();
+ int CorrectPasvResponse(unsigned char *v);
+};
+
+#endif
diff --git a/src/ftpsession.cpp b/src/ftpsession.cpp
new file mode 100644
index 0000000..2287d7e
--- /dev/null
+++ b/src/ftpsession.cpp
@@ -0,0 +1,1189 @@
+//
+// C++ Implementation: ftpsession
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <sikor_sxe@radicalapproach.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kiconloader.h>
+#include <kinputdialog.h>
+#include <klineedit.h>
+
+#include <qtextedit.h>
+#include <qtoolbutton.h>
+#include <qpopupmenu.h>
+#include <qwidget.h>
+#include <qlistview.h>
+#include <qlabel.h>
+#include <qpixmap.h>
+#include <qheader.h>
+#include <qstringlist.h>
+#include <qevent.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qpushbutton.h>
+
+#include "fileexistsdialog.h"
+#include "customconnectdialog.h"
+#include "ftpthread.h"
+#include "eventhandler.h"
+#include "kbsiteinfo.h"
+#include "ftpsession.h"
+#include "kasablanca.h"
+#include "kbdir.h"
+#include "kbdirinfo.h"
+#include "kbfile.h"
+#include "kbfileinfo.h"
+#include "kbconfig.h"
+#include "ftplib.h"
+
+FtpSession::FtpSession(QObject *parent, const char *name)
+ : QObject(parent, name)
+{
+ installEventFilter(this);
+
+ mp_ftpthread = new FtpThread();
+ mp_eventhandler = new EventHandler(this, "event handler");
+ mp_siteinfo = new KbSiteInfo();
+
+ m_connected = false;
+ m_occupied = false;
+ m_encrypted = false;
+ m_startqueue = false;
+ m_sortascending = true;
+ mp_currenttransfer = NULL;
+ m_sortpref = 0;
+
+ m_colorsuccess = green;
+ m_colorfailure = red;
+ m_colorlocal = yellow;
+
+ mp_eventhandler->SetFtpThread(mp_ftpthread);
+ mp_ftpthread->SetEventReceiver(mp_eventhandler);
+
+ m_iconencrypted = KGlobal::iconLoader()->loadIconSet("encrypted",KIcon::Small).pixmap(QIconSet::Small,QIconSet::Normal);
+ m_iconunencrypted = KGlobal::iconLoader()->loadIconSet("encrypted",KIcon::Small).pixmap(QIconSet::Small,QIconSet::Disabled);
+
+ connect(mp_eventhandler, SIGNAL(ftp_log(QString, bool)), SLOT(SLOT_Log(QString, bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_connect(bool)), SLOT(SLOT_Connect(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_login(bool)), SLOT(SLOT_Login(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_xfered(off64_t, bool)), SLOT(SLOT_Xfered(off64_t, bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_quit(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_chdir(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_raw(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_get(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_put(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_fxp(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_rm(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_authtls(bool)), SLOT(SLOT_AuthTls(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_misc(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_mkdir(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_rename(bool)), SLOT(SLOT_Misc(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_pwd(bool, QString)), SLOT(SLOT_Pwd(bool, QString)));
+ connect(mp_eventhandler, SIGNAL(ftp_dir(bool, list<KbFileInfo*>, list<KbFileInfo*>)),
+ SLOT(SLOT_Dir(bool, list<KbFileInfo*>, list<KbFileInfo*>)));
+ connect(mp_eventhandler, SIGNAL(ftp_encryptdata(bool)), SLOT(SLOT_EncryptData(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_finished()), SLOT(SLOT_Finish()));
+ connect(mp_eventhandler, SIGNAL(ftp_connectionlost()), SLOT(SLOT_ConnectionLost()));
+ connect(mp_eventhandler, SIGNAL(ftp_transfer(bool)), SLOT(SLOT_Transfer(bool)));
+ connect(mp_eventhandler, SIGNAL(ftp_scandir(bool, KbDirInfo*)), SLOT(SLOT_Scandir(bool, KbDirInfo*)));
+}
+
+FtpSession::~FtpSession()
+{
+}
+
+void FtpSession::SetCmdLine(KLineEdit* cmdline)
+{
+ KCompletion *comp = cmdline->completionObject();
+ connect(cmdline, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));
+ cmdline->setCompletionMode(KGlobalSettings::CompletionAuto);
+ mp_cmdline = cmdline;
+}
+
+void FtpSession::SetCwdLine(KLineEdit* cwdline)
+{
+ KCompletion *comp = cwdline->completionObject();
+ connect(cwdline, SIGNAL(returnPressed(const QString&)), comp, SLOT(addItem(const QString&)));
+ cwdline->setCompletionMode(KGlobalSettings::CompletionAuto);
+ mp_cwdline = cwdline;
+}
+
+void FtpSession::SLOT_Log(QString log, bool out)
+{
+ if (out) m_loglist.push_back(make_pair(log, true));
+ else m_loglist.push_back(make_pair(log, false));
+}
+
+void FtpSession::SLOT_Xfered(off64_t xfered, bool encrypted)
+{
+ //if (encrypted) mp_encryptionicon->setPixmap(m_iconencrypted);
+ //else mp_encryptionicon->setPixmap(m_iconunencrypted);
+
+ if ((encrypted) && (!m_encrypted)) mp_encryptionicon->setPixmap(m_iconencrypted);
+ else if ((!encrypted) && (m_encrypted)) mp_encryptionicon->setPixmap(m_iconunencrypted);
+ m_encrypted = encrypted;
+
+ if (mp_currenttransfer) mp_currenttransfer->Xfered(xfered);
+}
+
+void FtpSession::SLOT_HeaderClicked(int section)
+{
+ m_sortascending = m_sortascending ^ true;
+ m_sortpref = section;
+ SortItems();
+}
+
+void FtpSession::SLOT_ActionMenu(int i)
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: triggered action while occupied");
+ return;
+ }
+ if (i == Kasablanca::Mkdir)
+ {
+ bool b;
+ QString name = KInputDialog::getText(i18n("Enter directory name"), i18n("Enter directory name:"), "", &b);
+ if (!b) return;
+ if (Connected())
+ {
+ Occupy();
+ mp_ftpthread->Mkdir(name);
+ RefreshBrowser();
+ mp_ftpthread->start();
+ }
+ else
+ {
+ m_localworkingdir.mkdir(name);
+ UpdateLocal();
+ }
+ }
+ else if (i == Kasablanca::Delete)
+ {
+ if (Connected())
+ {
+ Occupy();
+ QListViewItemIterator it(mp_browser);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ {
+ KbItem* item = static_cast<KbItem*>(it.current());
+ int warning = KMessageBox::warningContinueCancel(0, i18n("Delete this item?"), item->File());
+ if (warning == KMessageBox::Continue)
+ {
+ if (item->rtti() == KbItem::dir) mp_ftpthread->Rmdir(item->File());
+ else if (item->rtti() == KbItem::file) mp_ftpthread->Rm(item->File());
+ }
+ }
+ it++;
+ }
+ RefreshBrowser();
+ mp_ftpthread->start();
+ }
+ else
+ {
+ QListViewItemIterator it(mp_browser);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ {
+ KbItem* item = static_cast<KbItem*>(it.current());
+ int warning = KMessageBox::warningContinueCancel(0, i18n("Delete this item?"), item->File());
+ if (warning == KMessageBox::Continue)
+ {
+ if (KbConfig::deleteMovesIntoTrashIsEnabled())
+ {
+ system(QString("mv " + m_localworkingdir.absPath() + "/" + item->File() +
+ + " " + KGlobalSettings::trashPath()).latin1());
+ }
+ else
+ {
+ if (item->rtti() == KbItem::dir)
+ {
+ QString dir = "rm -rf " + m_localworkingdir.absFilePath(item->File());
+ system(dir.latin1());
+ }
+ //RmdirLocal(item->File());
+ else if (item->rtti() == KbItem::file) m_localworkingdir.remove(item->File());
+ }
+ }
+ }
+ it++;
+ }
+ UpdateLocal();
+ }
+ }
+ else if (i == Kasablanca::Rename)
+ {
+ if (Connected())
+ {
+ QListViewItemIterator it(mp_browser);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ {
+ bool b;
+ KbItem* item = static_cast<KbItem*>(it.current());
+ QString name = KInputDialog::getText(i18n("Enter new name"), i18n("Enter new name:"), item->File(), &b);
+ if (b)
+ {
+ Occupy();
+ mp_ftpthread->Rename(item->File(), name);
+ }
+ else return;
+ }
+ it++;
+ }
+ RefreshBrowser();
+ mp_ftpthread->start();
+ }
+ else
+ {
+ QListViewItemIterator it(mp_browser);
+ while (it.current())
+ {
+ if (it.current()->isSelected())
+ {
+ bool b;
+ KbItem* item = static_cast<KbItem*>(it.current());
+ QString name = KInputDialog::getText(i18n("Enter new name"), i18n("Enter new name:"), item->File(), &b);
+ if (b) m_localworkingdir.rename(item->text(0), name);
+ else return;
+ }
+ it++;
+ }
+ UpdateLocal();
+ }
+ }
+ else if (i == Kasablanca::Queue)
+ {
+ m_startqueue = false;
+ QueueItems();
+ }
+ else if (i == Kasablanca::Transfer)
+ {
+ m_startqueue = true;
+ QueueItems();
+ }
+ else if (i == Kasablanca::Bookmark)
+ {
+ KbSiteInfo newsite = *mp_siteinfo;
+ bool b;
+ QString name = KInputDialog::getText(i18n("Enter bookmark name"), i18n("Enter bookmark name:"), "", &b);
+ if (!b) return;
+ if (name == "") name = "New site";
+ newsite.SetName(name);
+ newsite.SetDefaultDirectory(m_remoteworkingdir);
+ static_cast<Kasablanca*>(parent())->m_bookmarks.push_back(newsite);
+ KbSiteInfo::WriteBookmarks(static_cast<Kasablanca*>(parent())->m_bookmarks);
+ static_cast<Kasablanca*>(parent())->InitBookmarks();
+ }
+}
+
+void FtpSession::SLOT_ConnectMenu(int i)
+{
+ if (i == 0)
+ {
+ CustomConnectDialog dlg;
+ mp_siteinfo->Clear();
+ dlg.mp_site = mp_siteinfo;
+ if (dlg.exec() == QDialog::Rejected) return;
+ else if (!mp_siteinfo->IsLegit())
+ {
+ KMessageBox::error(0,i18n("That site information is not legit."));
+ return;
+ }
+ }
+ else
+ {
+ list<KbSiteInfo>::iterator it = static_cast<Kasablanca*>(parent())->m_bookmarks.begin();
+ for (int x = 0; x < i - 1; x++) it++;
+ mp_siteinfo = &(*it);
+ qWarning("INFO: connecting to bookmark entry named: %s", mp_siteinfo->GetName().latin1());
+ }
+ Connect();
+ Occupy();
+ m_loglist.clear();
+ mp_ftpthread->Connect(mp_siteinfo->GetInfo());
+ if (mp_siteinfo->GetTls() > 0) mp_ftpthread->Authtls();
+ if (mp_siteinfo->GetPasv() > 0) mp_ftpthread->Pasv(true);
+ else mp_ftpthread->Pasv(false);
+ if (mp_siteinfo->GetCorrectPasv()) mp_ftpthread->Ftp()->SetCorrectPasv(true);
+ else mp_ftpthread->Ftp()->SetCorrectPasv(false);
+ mp_ftpthread->Login(mp_siteinfo->GetUser(), mp_siteinfo->GetPass());
+ if (QString(mp_siteinfo->GetDefaultDirectory()) != "") mp_ftpthread->Chdir(mp_siteinfo->GetDefaultDirectory());
+ RefreshBrowser();
+ mp_ftpthread->start();
+}
+
+void FtpSession::SLOT_Finish()
+{
+ while (!mp_ftpthread->wait(KB_THREAD_TIMEOUT)) qWarning("WARNING: thread timeout, should *not* happen.");
+
+ if (mp_currenttransfer) Transfer(mp_currenttransfer);
+ else Free();
+}
+
+void FtpSession::SLOT_ItemClicked(QListViewItem * item)
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: item clicked while occupied");
+ return;
+ }
+ if (item->rtti() == KbItem::file) return;
+ else if (Connected())
+ {
+ Occupy();
+ if (item->text(0) == "..") mp_ftpthread->Cdup();
+ else mp_ftpthread->Chdir(item->text(0));
+ mp_ftpthread->Pwd();
+ if (mp_siteinfo->GetTls() > 1) mp_ftpthread->EncryptData(true);
+ mp_ftpthread->Dir(false);
+ mp_ftpthread->start();
+ }
+ else UpdateLocal(item->text(0));
+}
+
+void FtpSession::SLOT_ItemRClicked(QListViewItem *, const QPoint & point, int)
+{
+ mp_rclickmenu->exec(point);
+}
+
+void FtpSession::SLOT_CmdLine()
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: entered command while occupied");
+ return;
+ }
+ else if (Connected())
+ {
+ Occupy();
+ mp_ftpthread->Raw(mp_cmdline->text());
+ mp_cmdline->setText("");
+ mp_ftpthread->start();
+ }
+ else
+ {
+ KProcess* p = new KProcess();
+ p->setWorkingDirectory(m_localworkingdir.absPath());
+ *p << QStringList::split(" ", mp_cmdline->text());
+ connect(p, SIGNAL(processExited(KProcess*)), SLOT(SLOT_LocalProcessExited(KProcess*)));
+ if (p->start() == TRUE) mp_cmdline->setText("");
+ }
+}
+
+void FtpSession::SLOT_ConnectButton()
+{
+ /* this button is also an abort button */
+
+ if (Occupied())
+ {
+ if (mp_currenttransfer)
+ {
+ int answer = KMessageBox::warningYesNo(0, i18n("Cancel transfer?"));
+ if (answer == KMessageBox::Yes)
+ {
+ FtpSession *srcsession = mp_currenttransfer->SrcSession();
+ FtpSession *dstsession = mp_currenttransfer->DstSession();
+
+ mp_currenttransfer->Finish();
+ delete mp_currenttransfer;
+ if (srcsession->Connected()) srcsession->Abort();
+ if (dstsession->Connected()) dstsession->Abort();
+ }
+ }
+ else if (Connected()) Abort();
+ }
+
+ /* when connected issue disconnect */
+
+ else if (Connected())
+ {
+ Disconnect();
+ Occupy();
+ mp_ftpthread->Quit();
+ mp_ftpthread->start();
+ }
+
+ /* when disconnected show connect menu */
+
+ else if (!Connected()) mp_bookmarksmenu->exec(mp_connectbutton->mapToGlobal(QPoint(0,0)));
+}
+
+void FtpSession::SetColors(QColor local, QColor success, QColor failure, QColor background)
+{
+ m_colorlocal = local;
+ m_colorsuccess = success;
+ m_colorfailure = failure;
+ mp_logwindow->setPaletteBackgroundColor(background);
+}
+
+void FtpSession::SetFont(QFont font)
+{
+ mp_logwindow->setFont(font);
+}
+
+void FtpSession::Abort()
+{
+ mp_logwindow->setColor(m_colorlocal);
+ mp_logwindow->append(i18n("Aborted ftp operation"));
+ mp_ftpthread->terminate();
+ mp_ftpthread->wait(KB_THREAD_TIMEOUT);
+ mp_ftpthread->ClearQueue();
+ Disconnect();
+ Free();
+}
+void FtpSession::SLOT_CwdLine()
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: entered cwd while occupied");
+ return;
+ }
+ if (Connected())
+ {
+ Occupy();
+ mp_ftpthread->Chdir(mp_cwdline->text());
+ mp_ftpthread->Pwd();
+ if (mp_siteinfo->GetTls() > 1) mp_ftpthread->EncryptData(true);
+ mp_ftpthread->Dir(false);
+ mp_ftpthread->start();
+ }
+ else UpdateLocal(mp_cwdline->text());
+}
+
+void FtpSession::SLOT_RefreshButton()
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: refresh button pressed while occupied");
+ return;
+ }
+ if (Connected())
+ {
+ Occupy();
+ RefreshBrowser();
+ mp_ftpthread->start();
+ }
+ else UpdateLocal();
+}
+
+void FtpSession::QueueItems()
+{
+ KbDirInfo *dir = new KbDirInfo(WorkingDir());
+
+ QListViewItemIterator iit(mp_browser->lastItem());//, QListViewItemIterator::Selected);
+ while (iit.current())
+ {
+ QListViewItem *item = iit.current();
+ if (item->isSelected())
+ {
+ if (item->rtti() == KbItem::dir) dir->AddDirectory( KbFileInfo(static_cast<KbFile*>(item), "/"));
+ else if (item->rtti() == KbItem::file) dir->AddFile(new KbFileInfo(static_cast<KbFile*>(item), "/"));
+ mp_browser->setSelected(item, false);
+ }
+ iit--;
+ }
+
+ if (Connected())
+ {
+ Occupy();
+ mp_ftpthread->Scandir(dir);
+ mp_ftpthread->start();
+ }
+ else
+ {
+ list<KbDirInfo*>::iterator end_dir = dir->Dirlist()->end();
+ for(list<KbDirInfo*>::iterator i = dir->Dirlist()->begin(); i != end_dir; i++)
+ {
+ ScandirLocal(*i, '/' + (*i)->fileName());
+ }
+ /* temporary hack, as there are only 2 ftpsessions available yet */
+
+ FtpSession* dst;
+ list<FtpSession*>::iterator end_session = mp_sessionlist->end();
+ for (list<FtpSession*>::iterator i = mp_sessionlist->begin(); i != end_session; i++) if (*i != this) dst = *i;
+
+ /* /temporary hack */
+
+ emit gui_queueitems(dir, this, dst, m_startqueue);
+ }
+}
+
+void FtpSession::SLOT_TransferButton()
+{
+ if (Occupied())
+ {
+ qWarning("ERROR: transfer button pressed while occupied");
+ return;
+ }
+ m_startqueue = true;
+ QueueItems();
+}
+
+void FtpSession::SLOT_Scandir(bool success, KbDirInfo* dir)
+{
+ if (success)
+ {
+ /* temporary hack, as there are only 2 ftpsessions available yet */
+
+ FtpSession* dst;
+ list<FtpSession*>::iterator end_dir = mp_sessionlist->end();
+ for (list<FtpSession*>::iterator i = mp_sessionlist->begin(); i != end_dir; i++) if (*i != this) dst = *i;
+
+ /* /temporary hack */
+
+ emit gui_queueitems(dir, this, dst, m_startqueue);
+ }
+ else qWarning("INFO: scandir error");
+}
+
+void FtpSession::SLOT_Connect(bool success)
+{
+ if (!success)
+ {
+ m_loglist.push_back(make_pair(i18n("connection failed"), false));
+ Disconnect();
+ }
+ PrintLog(success);
+}
+
+void FtpSession::SLOT_EncryptData(bool success)
+{
+ PrintLog(success);
+}
+
+void FtpSession::SLOT_AuthTls(bool success)
+{
+ if (!success)
+ {
+ Disconnect();
+ m_loglist.push_back(make_pair(i18n("server does not support encryption"), false));
+ }
+ PrintLog(success);
+}
+
+void FtpSession::SLOT_Misc(bool success)
+{
+ PrintLog(success);
+}
+
+void FtpSession::SLOT_Login(bool success)
+{
+ PrintLog(success);
+ if (!success) Disconnect();
+}
+
+void FtpSession::SLOT_ConnectionLost()
+{
+ PrintLog(false);
+ Disconnect();
+}
+
+void FtpSession::SLOT_Dir(bool success, list<KbFileInfo*> dirlist, list<KbFileInfo*> filelist)
+{
+ PrintLog(success);
+ if (success)
+ {
+ while (QListViewItem* tmpviewitem = mp_browser->firstChild()) delete tmpviewitem;
+ QListViewItem* dirup = new QListViewItem(mp_browser, "..");
+ dirup->setPixmap(0, KGlobal::iconLoader()->loadIcon("folder",KIcon::Small));
+ dirup->setSelectable(false);
+
+ list<KbFileInfo*>::iterator end_dir = dirlist.end();
+ for (list<KbFileInfo*>::iterator i = dirlist.begin(); i != end_dir; i++)
+ {
+ new KbDir(**i, mp_browser, mp_browser->lastItem());
+ //if (!KbConfig::dirCachingIsEnabled()) delete *i;
+ }
+ list<KbFileInfo*>::iterator end_file = filelist.end();
+ for (list<KbFileInfo*>::iterator i = filelist.begin(); i != end_file; i++)
+ {
+ new KbFile(**i, mp_browser, mp_browser->lastItem());
+ //if (!KbConfig::dirCachingIsEnabled()) delete *i;
+ }
+ SortItems();
+ if (KbConfig::hideHiddenFilesIsEnabled()) FilterHiddenFiles(true);
+ emit gui_update();
+ }
+}
+
+void FtpSession::SLOT_Pwd(bool success, QString pwd)
+{
+ PrintLog(success);
+ if (success)
+ {
+ m_remoteworkingdir = pwd;
+
+ /* strip trailing "/", thanks allanonl for pointing out */
+
+ if(pwd.endsWith("/") && pwd.length() > 1)
+ {
+ qWarning("INFO: stripping trailing /");
+ m_remoteworkingdir.truncate(pwd.length() - 1);
+ }
+ mp_cwdline->setText(pwd);
+ }
+}
+
+
+void FtpSession::SortItems()
+{
+ QListViewItem* x = mp_browser->firstChild();
+ mp_browser->takeItem(x);
+
+ mp_browser->setSorting(m_sortpref, m_sortascending);
+ mp_browser->sort();
+ mp_browser->setSorting(-1);
+
+ mp_browser->insertItem(x);
+}
+
+void FtpSession::PrintLog(bool)
+{
+ list<logentries>::iterator i;
+ for (i = m_loglist.begin(); i != m_loglist.end(); i++)
+ {
+ QString line = (*i).first;
+
+ if ((*i).second == true)
+ {
+ if ((line.startsWith("4")) || (line.startsWith("5"))) mp_logwindow->setColor(m_colorfailure);
+ else mp_logwindow->setColor(m_colorsuccess);
+ mp_logwindow->append((*i).first);
+ }
+ else
+ {
+ mp_logwindow->setColor(m_colorlocal);
+ if (line.startsWith("PASS")) mp_logwindow->append("PASS *");
+ else mp_logwindow->append(line);
+ }
+ }
+ m_loglist.clear();
+}
+
+void FtpSession::Connect()
+{
+ mp_rclickmenu->setItemEnabled(Kasablanca::Bookmark, true);
+ mp_bookmarksmenu->setEnabled(false);
+ mp_connectbutton->setIconSet(KGlobal::iconLoader()->loadIconSet("connect_established",KIcon::Toolbar));
+ mp_statusline->setText(i18n("Occupied"));
+ m_connected = true;
+ emit gui_clearqueue(this);
+}
+
+void FtpSession::Disconnect()
+{
+ UpdateLocal();
+ mp_rclickmenu->setItemEnabled(Kasablanca::Bookmark, false);
+ mp_bookmarksmenu->setEnabled(true);
+ mp_connectbutton->setIconSet(KGlobal::iconLoader()->loadIconSet("connect_no",KIcon::Toolbar));
+ mp_statusline->setText(i18n("Disconnected"));
+ m_connected = false;
+ emit gui_clearqueue(this);
+}
+
+void FtpSession::Occupy()
+{
+ qWarning("INFO: %s gui blocked", name());
+
+ mp_rclickmenu->setEnabled(false);
+ mp_browser->setEnabled(false);
+ mp_cmdline->setEnabled(false);
+ mp_cwdline->setEnabled(false);
+ mp_refreshbutton->setEnabled(false);
+ if (m_connected) mp_statusline->setText(mp_siteinfo->GetName() + i18n(" is occupied"));
+ else mp_statusline->setText("Local " + i18n(" is occupied"));
+ m_occupied = true;
+ emit gui_update();
+}
+
+void FtpSession::Free()
+{
+ qWarning("INFO: %s gui freed", name());
+
+ mp_rclickmenu->setEnabled(true);
+ mp_browser->setEnabled(true);
+ mp_cmdline->setEnabled(true);
+ mp_cwdline->setEnabled(true);
+ mp_refreshbutton->setEnabled(true);
+ if (m_connected) mp_statusline->setText(i18n("Connected to ") + mp_siteinfo->GetName());
+ else mp_statusline->setText(i18n("Disconnected"));
+ if ((mp_siteinfo->GetTls() > 0) && (m_connected)) mp_encryptionicon->setPixmap(m_iconencrypted);
+ else mp_encryptionicon->setPixmap(m_iconunencrypted);
+ m_occupied = false;
+ emit gui_update();
+}
+
+void FtpSession::RefreshBrowser()
+{
+ mp_ftpthread->Pwd();
+ if (mp_siteinfo->GetTls() > 1) mp_ftpthread->EncryptData(true, true);
+ mp_ftpthread->Dir(true);
+}
+
+void FtpSession::UpdateLocal(QString cwd)
+{
+ QFileInfoList filelist, dirlist;
+
+ if (cwd != "") if (!m_localworkingdir.cd(cwd)) return;
+ if (!m_localworkingdir.exists()) return;
+
+ mp_browser->sortColumn();
+ m_localworkingdir.setSorting(QDir::Name);
+
+ while (QListViewItem* tmpviewitem = mp_browser->firstChild()) delete tmpviewitem;
+
+ QListViewItem* dirup = new QListViewItem(mp_browser, "..");
+ dirup->setPixmap(0, KGlobal::iconLoader()->loadIcon("folder",KIcon::Small));
+ dirup->setSelectable(false);
+
+ m_localworkingdir.setFilter(QDir::Dirs | QDir::Hidden);
+ dirlist = *m_localworkingdir.entryInfoList();
+
+ QFileInfoListIterator dit(dirlist);
+ dit.atFirst();
+ while (dit.current())
+ {
+ new KbDir(KbFileInfo(*dit.current()), mp_browser, mp_browser->lastItem());
+ ++dit;
+ }
+
+ m_localworkingdir.setFilter(QDir::Files | QDir::Hidden);
+ filelist = *m_localworkingdir.entryInfoList();
+
+ QFileInfoListIterator fit(filelist);
+ fit.atFirst();
+ while (fit.current())
+ {
+ new KbFile(KbFileInfo(*fit.current()), mp_browser, mp_browser->lastItem());
+ ++fit;
+ }
+
+ mp_cwdline->setText(m_localworkingdir.absPath());
+
+ SortItems();
+ if (KbConfig::hideHiddenFilesIsEnabled()) FilterHiddenFiles(true);
+}
+
+/*bool FtpSession::RmdirLocal(QString dir)
+{
+ QStringList filelist, dirlist;
+ QString olddir;
+
+ olddir = m_localworkingdir.path();
+ if (!m_localworkingdir.cd(dir)) return false;
+
+ filelist = m_localworkingdir.entryList("*", QDir::Files | QDir::Hidden);
+ for (QStringList::Iterator it = filelist.begin(); it != filelist.end(); ++it)
+ {
+ if (!m_localworkingdir.remove(*it)) return false;
+ }
+
+ dirlist = m_localworkingdir.entryList("*", QDir::Dirs | QDir::Hidden);
+ for (QStringList::Iterator it = dirlist.begin(); it != dirlist.end(); ++it)
+ {
+ if ((*it != ".") && (*it != ".."))
+ {
+ if (!RmdirLocal(*it)) return false;
+ }
+ }
+
+ if (!m_localworkingdir.cd(olddir)) return false;
+ if (!m_localworkingdir.rmdir(dir)) return false;
+
+ return true;
+}*/
+
+bool FtpSession::ScandirLocal(KbDirInfo *dir, QString path)
+{
+ QFileInfoList filelist, dirlist;
+ QString olddir;
+
+ qWarning("dir: path: %s file: %s", dir->dirPath(true).latin1(), dir->fileName().latin1());
+
+ olddir = WorkingDir();
+ if (!m_localworkingdir.cd(dir->fileName())) return false;
+
+ m_localworkingdir.setFilter(QDir::Files | QDir::Hidden);
+ filelist = *m_localworkingdir.entryInfoList();
+
+ QFileInfoListIterator fit(filelist);
+ fit.atFirst();
+ while (fit.current())
+ {
+ KbFileInfo *kfi = new KbFileInfo(*fit.current());
+ kfi->SetDirPath(path);
+ dir->AddFile(kfi);
+ qWarning("file: path: %s file: %s", kfi->dirPath(true).latin1(), kfi->fileName().latin1());
+ ++fit;
+ }
+
+ m_localworkingdir.setFilter(QDir::Dirs | QDir::Hidden);
+ dirlist = *m_localworkingdir.entryInfoList();
+
+ list<KbFileInfo> kfilist;
+
+ QFileInfoListIterator dit(dirlist);
+ dit.atFirst();
+ while (dit.current())
+ {
+ QFileInfo qfi = *dit.current();
+ KbFileInfo kfi(qfi);
+ kfi.SetDirPath(path);
+ kfilist.push_back(kfi);
+ ++dit;
+ }
+
+ list<KbFileInfo>::iterator end_kfi = kfilist.end();
+
+ for(list<KbFileInfo>::iterator kfiit = kfilist.begin(); kfiit != end_kfi; kfiit++)
+ {
+ KbDirInfo* newdir = dir->AddDirectory(*kfiit);
+ if (newdir) if (!ScandirLocal(newdir, path + '/' + newdir->fileName())) return false;
+ }
+
+ if (!m_localworkingdir.cd(olddir)) return false;
+
+ return true;
+}
+
+QString FtpSession::WorkingDir()
+{
+ if (Connected()) return m_remoteworkingdir;
+ else return m_localworkingdir.absPath();
+}
+
+bool FtpSession::CheckLocalDirectory(QString path)
+{
+ if (Connected())
+ {
+ qWarning("ERROR: CheckLocalDirectory on connected session called");
+ return false;
+ }
+
+ if (path == m_localworkingdir.absPath()) return true;
+ else
+ {
+ bool result;
+ result = m_localworkingdir.cd(path);
+ if (result) UpdateLocal();
+ return result;
+ }
+}
+
+bool FtpSession::MakeLocalDirectory(QString path)
+{
+ if (Connected())
+ {
+ qWarning("ERROR: MakeLocalDirectory on connected session called");
+ return false;
+ }
+
+ bool result;
+ result = m_localworkingdir.mkdir(path);
+ if (result) UpdateLocal();
+ return result;
+}
+
+void FtpSession::MakeDirectory(QString dir)
+{
+ bool result = mp_ftpthread->Transfer_Mkdir(dir);
+ if (result) mp_ftpthread->start();
+ else qWarning("ERROR: thread error, thread was still busy.");
+}
+
+bool FtpSession::CopyLocalFile(KbTransferItem* item)
+{
+ QTextStream srcstream;
+ QTextStream dststream;
+ QFile srcfile(item->SrcFileInfo()->filePath());
+ QFile dstfile(item->DstFileInfo()->filePath());
+ if (!dstfile.open(IO_WriteOnly))
+ {
+ qWarning("ERROR: writing to local destination file not allowed");
+ return false;
+ }
+ dststream.setDevice(&dstfile);
+ if (!srcfile.open(IO_ReadOnly))
+ {
+ qWarning("ERROR: reading from local source file not allowed");
+ return false;
+ }
+ srcstream.setDevice(&srcfile);
+ dststream << srcstream.read();
+ srcfile.close();
+ dstfile.close();
+
+ return true;
+}
+
+void FtpSession::ChangeDirectory(QString path)
+{
+ bool result = mp_ftpthread->Transfer_Changedir(path, (mp_siteinfo->GetTls() > 1));
+ if (result) mp_ftpthread->start();
+ else qWarning("ERROR: thread error, thread was still busy.");
+}
+
+void FtpSession::SLOT_Transfer(bool success)
+{
+ if (success) mp_currenttransfer->IncrementStatus();
+ else mp_currenttransfer->Abort();
+}
+
+int FtpSession::CheckFile(KbTransferItem *item)
+{
+ item->DstFileInfo()->SetSize(0);
+ QListViewItemIterator it(mp_browser);
+
+ while (it.current())
+ {
+ if (it.current()->text(0) == item->DstFileInfo()->fileName())
+ {
+ FileExistsDialog dlg;
+ KbItem* kbi;
+ QString newname;
+ bool b;
+ int result;
+
+ kbi = static_cast<KbItem*>(it.current());
+ item->DstFileInfo()->SetSize(kbi->Size());
+ if (kbi->rtti() == KbItem::dir)
+ {
+ dlg.ResumeButton->setEnabled(false);
+ dlg.OverwriteButton->setEnabled(false);
+ }
+ else if (kbi->rtti() == KbItem::file)
+ {
+ if (item->DstFileInfo()->Size() >= item->SrcFileInfo()->Size()) dlg.ResumeButton->setEnabled(false);
+ }
+
+ if (m_onfileexistsdefault != off)
+ {
+ if (m_onfileexistsdefault == clear) item->DstFileInfo()->SetSize(0);
+ if ((m_onfileexistsdefault == resume) &&
+ (item->DstFileInfo()->Size() >= item->SrcFileInfo()->Size())
+ ) return skip;
+ return m_onfileexistsdefault;
+ }
+ else result = dlg.exec();
+
+ switch (result)
+ {
+ case FileExistsDialog::overwrite:
+ item->DstFileInfo()->SetSize(0);
+ return clear;
+ break;
+ case FileExistsDialog::resume:
+ return resume;
+ break;
+ case FileExistsDialog::rename:
+ newname = KInputDialog::getText(i18n("Enter New Name"), i18n("Enter New Name:"), kbi->File() + i18n("_alt"), &b);
+ if (!b) return skip;
+ else
+ {
+ item->DstFileInfo()->setFile(newname);
+ return CheckFile(item);
+ }
+ break;
+ case FileExistsDialog::skip:
+ return skip;
+ break;
+ }
+ }
+ it++;
+ }
+ return clear;
+}
+
+void FtpSession::Transfer(KbTransferItem *item)
+{
+ if (item->Status() == KbTransferItem::clear)
+ {
+ item->Info();
+ item->Init();
+ if (!item->SrcSession()->Connected())
+ {
+ if (item->SrcSession()->CheckLocalDirectory(item->SrcFileInfo()->dirPath(true)) == false)
+ {
+ emit gui_succeedtransfer(mp_currenttransfer);
+ return;
+ }
+ else item->IncrementStatus();
+ }
+ else item->SrcSession()->ChangeDirectory(item->SrcFileInfo()->dirPath(true));
+ }
+
+ if (item->Status() == KbTransferItem::src_ready)
+ {
+ if (!item->DstSession()->Connected())
+ {
+ if (item->DstSession()->CheckLocalDirectory(item->DstFileInfo()->dirPath(true)) == false)
+ {
+ emit gui_succeedtransfer(mp_currenttransfer);
+ return;
+ }
+ else item->IncrementStatus();
+ }
+ else item->DstSession()->ChangeDirectory(item->DstFileInfo()->dirPath(true));
+ }
+
+ if (item->Status() == KbTransferItem::dst_ready)
+ {
+ if (item->rtti() == KbTransferItem::dir)
+ {
+ if (item->DstSession()->Connected()) item->DstSession()->MakeDirectory(item->DstFileInfo()->fileName());
+ else
+ {
+ if (item->DstSession()->MakeLocalDirectory(item->DstFileInfo()->fileName()) == false)
+ {
+ emit gui_succeedtransfer(mp_currenttransfer);
+ return;
+ }
+ else item->IncrementStatus();
+ }
+ }
+ else if (item->rtti() == KbTransferItem::file)
+ {
+ filecheck result = static_cast<filecheck>(item->DstSession()->CheckFile(item));
+
+ startTimer(1024);
+ item->StartTimer();
+
+ if (result == skip)
+ {
+ qWarning("INFO: skipped transfer");
+ item->IncrementStatus();
+ }
+ else if (item->SrcSession()->Connected())
+ {
+ if (item->DstSession()->Connected())
+ {
+ item->SrcSession()->FxpFile(item, result);
+ }
+ else item->SrcSession()->GetFile(item, result);
+ }
+ else
+ {
+ if (item->DstSession()->Connected()) item->DstSession()->PutFile(item, result);
+ else
+ {
+ if (CopyLocalFile(item) == false)
+ {
+ emit gui_succeedtransfer(mp_currenttransfer);
+ return;
+ }
+ else item->IncrementStatus();
+ }
+ }
+ }
+ }
+
+ if (item->Status() == KbTransferItem::done)
+ {
+ killTimers();
+ emit gui_succeedtransfer(mp_currenttransfer);
+ }
+}
+
+void FtpSession::FxpFile(KbTransferItem *item, filecheck fc)
+{
+ bool result;
+ int srctls, dsttls, alternativefxp;
+ QString localfile, remotefile;
+ off64_t offset;
+
+ remotefile = item->SrcFileInfo()->fileName();
+ localfile = mp_currenttransfer->DstSession()->WorkingDir() + '/' + item->DstFileInfo()->fileName();
+ srctls = mp_siteinfo->GetTls();
+ dsttls = item->DstSession()->SiteInfo()->GetTls();
+ FtpThread* dstftp = item->DstSession()->Ftp();
+ offset = item->DstFileInfo()->Size();
+
+ alternativefxp = mp_siteinfo->GetAlternativeFxp() | mp_currenttransfer->DstSession()->mp_siteinfo->GetAlternativeFxp();
+
+ if (fc == resume) result = mp_ftpthread->Transfer_Fxp(remotefile, localfile, dstftp, srctls, dsttls, offset, alternativefxp);
+ else result = mp_ftpthread->Transfer_Fxp(remotefile, localfile, dstftp, srctls, dsttls, 0, alternativefxp);
+
+ if (result) mp_ftpthread->start();
+ else qWarning("ERROR: thread error, thread was still busy.");
+}
+
+void FtpSession::GetFile(KbTransferItem *item, filecheck fc)
+{
+ bool result;
+ int tls;
+ QString localfile, remotefile;
+
+ remotefile = item->SrcFileInfo()->fileName();
+ localfile = mp_currenttransfer->DstSession()->WorkingDir() + '/' + item->DstFileInfo()->fileName();
+ tls = mp_siteinfo->GetTls();
+
+ if (fc == resume) result = mp_ftpthread->Transfer_Get(remotefile, localfile, tls, item->DstFileInfo()->Size());
+ else result = mp_ftpthread->Transfer_Get(remotefile, localfile, tls);
+
+ if (result) mp_ftpthread->start();
+ else qWarning("ERROR: thread error, thread was still busy.");
+}
+
+void FtpSession::PutFile(KbTransferItem *item, filecheck fc)
+{
+ bool result;
+ int tls;
+ QString localfile, remotefile;
+
+ remotefile = item->SrcFileInfo()->fileName();
+ localfile = mp_currenttransfer->SrcSession()->WorkingDir() + '/' + item->DstFileInfo()->fileName();
+ tls = mp_siteinfo->GetTls();
+
+ if (fc == resume) result = mp_ftpthread->Transfer_Put(localfile, remotefile, tls, item->DstFileInfo()->Size());
+ else result = mp_ftpthread->Transfer_Put(localfile, remotefile, tls);
+
+ if (result) mp_ftpthread->start();
+ else qWarning("ERROR: thread error, thread was still busy.");
+}
+
+void FtpSession::timerEvent(QTimerEvent*)
+{
+ if (mp_currenttransfer) mp_currenttransfer->ShowProgress(static_cast<Kasablanca*>(parent())->statusTip());
+}
+
+void FtpSession::EnableCmdLine(bool b)
+{
+ if (b) mp_cmdline->show();
+ else mp_cmdline->hide();
+}
+
+void FtpSession::FilterHiddenFiles(bool b)
+{
+ QListViewItemIterator it(mp_browser);
+ while (it.current())
+ {
+ if ((it.current() != mp_browser->firstChild()) && (static_cast<KbItem*>(it.current())->File().startsWith(".")))
+ {
+ if (b) it.current()->setVisible(false);
+ else it.current()->setVisible(true);
+ }
+ ++it;
+ }
+}
+
+#include "ftpsession.moc"
diff --git a/src/ftpsession.h b/src/ftpsession.h
new file mode 100644
index 0000000..37abcd8
--- /dev/null
+++ b/src/ftpsession.h
@@ -0,0 +1,165 @@
+//
+// C++ Interface: ftpsession
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <sikor_sxe@radicalapproach.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef FTPSESSION_H
+#define FTPSESSION_H
+
+#include <kprocess.h>
+#include <qstring.h>
+#include <qdir.h>
+#include <qpixmap.h>
+#include <qobject.h>
+#include <qcolor.h>
+#include <list>
+
+#include "kbfileinfo.h"
+
+using namespace std;
+
+class FtpThread;
+class EventHandler;
+class QMutex;
+class QTextEdit;
+class QToolButton;
+class QListView;
+class KbSiteInfo;
+class QPopupMenu;
+class KLineEdit;
+class QLabel;
+class QPoint;
+class KbDirInfo;
+class QHeader;
+class KbTransferItem;
+
+typedef pair<QString, bool> logentries;
+
+/**
+@author Magnus Kulke
+*/
+class FtpSession : public QObject
+{
+Q_OBJECT
+public:
+ enum filecheck
+ {
+ off = 0,
+ skip,
+ clear,
+ resume
+ };
+public:
+ FtpSession(QObject *parent = 0, const char *name = 0);
+ ~FtpSession();
+ void SetLogWindow(QTextEdit* logwindow) { mp_logwindow = logwindow; };
+ void SetRefreshButton(QToolButton* refreshbutton) { mp_refreshbutton = refreshbutton; };
+ void SetConnectButton(QToolButton* connectbutton) { mp_connectbutton = connectbutton; };
+ void SetTransferButton(QToolButton* transferbutton) { mp_transferbutton = transferbutton; }
+ void SetBrowser(QListView* browser) { mp_browser = browser; };
+ void SetStatusLine(QLabel* statusline) { mp_statusline = statusline; };
+ void SetEncryptionIcon(QLabel* encryptionicon) { mp_encryptionicon = encryptionicon; };
+ void SetBookmarksMenu(QPopupMenu *bookmarksmenu) { mp_bookmarksmenu = bookmarksmenu; };
+ void SetRclickMenu(QPopupMenu *rclickmenu) { mp_rclickmenu = rclickmenu; };
+ void SetSessionList(list<FtpSession*> *sessionlist) { mp_sessionlist = sessionlist; };
+ void SetCurrentTransfer(KbTransferItem* currenttransfer) { mp_currenttransfer = currenttransfer; };
+ bool Connected() { return m_connected; };
+ void Disconnect();
+ void Connect();
+ bool Occupied() { return m_occupied; };
+ void Occupy();
+ void Free();
+ QString WorkingDir();
+ void Transfer(KbTransferItem *item);
+ int CheckFile(KbTransferItem *item);
+ void Abort();
+ FtpThread* Ftp() { return mp_ftpthread; };
+ KbSiteInfo* SiteInfo() { return mp_siteinfo; };
+ void SetColors(QColor local, QColor success, QColor failure, QColor background);
+ void SetFont(QFont font);
+ void SetOnFileExistsDefault(filecheck onfileexistsdefault) {m_onfileexistsdefault = onfileexistsdefault; };
+ void EnableCmdLine(bool b);
+ void FilterHiddenFiles(bool b);
+ void SetCmdLine(KLineEdit* cmdline);
+ void SetCwdLine(KLineEdit* cwdline);
+private:
+ FtpThread *mp_ftpthread;
+ EventHandler *mp_eventhandler;
+ KbSiteInfo *mp_siteinfo;
+ QTextEdit *mp_logwindow;
+ QToolButton *mp_connectbutton, *mp_refreshbutton, *mp_transferbutton;
+ KLineEdit *mp_cwdline, *mp_cmdline;
+ QPopupMenu* mp_bookmarksmenu, *mp_rclickmenu;
+ QListView *mp_browser;
+ QLabel *mp_statusline, *mp_encryptionicon;
+ QString m_remoteworkingdir;
+ QDir m_localworkingdir;
+ QColor m_colorsuccess, m_colorfailure, m_colorlocal;
+ QFont m_logwindowfont;
+ int m_sortpref;
+ bool m_connected, m_occupied, m_sortascending, m_startqueue;
+ list<logentries> m_loglist;
+ QPixmap m_iconencrypted, m_iconunencrypted;
+ QHeader *mp_header;
+ list<FtpSession*> *mp_sessionlist;
+ KbTransferItem *mp_currenttransfer;
+ filecheck m_onfileexistsdefault;
+ bool m_encrypted;
+
+public slots:
+ void SLOT_Log(QString log, bool out);
+ void SLOT_Xfered(off64_t xfered, bool encrypted);
+ void SLOT_ActionMenu(int i);
+ void SLOT_ConnectMenu(int i);
+ void SLOT_HeaderClicked(int section);
+ void SLOT_LocalProcessExited(KProcess* proc) { delete proc; };
+ void SLOT_ItemClicked(QListViewItem*);
+ void SLOT_ItemRClicked(QListViewItem * item, const QPoint & point, int col);
+ void SLOT_Connect(bool success);
+ void SLOT_Login(bool success);
+ void SLOT_Pwd(bool success, QString pwd);
+ void SLOT_Misc(bool success);
+ void SLOT_AuthTls(bool success);
+ void SLOT_EncryptData(bool success);
+ void SLOT_Dir(bool success, list<KbFileInfo*> dirlist, list<KbFileInfo*> filelist);
+ void SLOT_ConnectButton();
+ void SLOT_RefreshButton();
+ void SLOT_TransferButton();
+ void SLOT_CwdLine();
+ void SLOT_CmdLine();
+ void SLOT_Finish();
+ void SLOT_ConnectionLost();
+ void SLOT_Transfer(bool success);
+ void SLOT_Scandir(bool success, KbDirInfo* dir);
+
+private:
+ void PrintLog(bool success);
+ void QueueItems();
+ void RefreshBrowser();
+ void UpdateLocal(QString cwd = "");
+ //bool RmdirLocal(QString dir);
+ void GetFile(KbTransferItem *item, filecheck fc);
+ void PutFile(KbTransferItem *item, filecheck fc);
+ void FxpFile(KbTransferItem *item, filecheck fc);
+ void ChangeDirectory(QString path);
+ bool CheckLocalDirectory(QString path);
+ bool MakeLocalDirectory(QString path);
+ bool CopyLocalFile(KbTransferItem* item);
+ bool ScandirLocal(KbDirInfo *dir, QString path);
+ void SortItems();
+ void MakeDirectory(QString dir);
+ void timerEvent(QTimerEvent*);
+signals:
+ void gui_update();
+ void gui_queueitems(KbDirInfo* dir, FtpSession* src, FtpSession* dst, bool startqueue);
+ void gui_succeedtransfer(QListViewItem* item);
+ void gui_clearqueue(FtpSession* session);
+};
+
+#endif
diff --git a/src/ftpthread.cpp b/src/ftpthread.cpp
new file mode 100644
index 0000000..842fecc
--- /dev/null
+++ b/src/ftpthread.cpp
@@ -0,0 +1,1437 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <kstandarddirs.h>
+
+#include <qapplication.h>
+#include <qevent.h>
+#include <qdir.h>
+
+#include <iostream>
+#include <list>
+
+#include "kbconfig.h"
+#include "ftplib.h"
+#include "kbdirinfo.h"
+#include "eventhandler.h"
+#include "kbfileinfo.h"
+#include "ftpthread.h"
+
+using namespace std;
+
+/*
+class description:
+
+the class accepts ftp operations by public methods. when such a method is called,
+a certain type value is appended to a list. in the threads main loop (triggered when
+start() is called) the list is processed by calling the ftplibpp functions. depending
+on the result of an operation a certain event is posted to the eventreceiver. when
+there is a value to be returned, it's named out_.
+*/
+
+
+FtpThread::FtpThread() : QThread()
+{
+ mp_eventreceiver = NULL;
+ mp_ftp = new ftplib();
+
+ mp_ftp->SetCallbackArg(this);
+ mp_ftp->SetCallbackLogFunction(FtpThread::CallbackLog);
+ mp_ftp->SetCallbackBytes(1024);
+ mp_ftp->SetCallbackXferFunction(FtpThread::CallbackXfer);
+}
+
+FtpThread::~FtpThread()
+{
+ delete mp_ftp;
+}
+
+/* init the variables the ftp session needs */
+
+void FtpThread::InitInternals()
+{
+ m_stringlist.clear();
+ m_intlist.clear();
+ m_ulonglist.clear();
+ m_pwd = "";
+ m_dataencrypted = false;
+ m_cache_vector.clear();
+ m_cache_list.clear();
+}
+
+/* callback function for the transfer */
+
+int FtpThread::CallbackXfer(off64_t xfered, void *arg)
+{
+ FtpThread* ftp = static_cast<FtpThread*>(arg);
+
+ ftp->Event(EventHandler::xfered, new xferpair(xfered, ftp->m_dataencrypted));
+ return 1;
+}
+
+/* callback function for the logs */
+
+void FtpThread::CallbackLog(char *log, void *arg, bool out)
+{
+ /* the incoming log message isn't formatted at all. data
+ can be "end.\r\n230 ne" for example. the log gets chopped
+ into lines and for every line an events is posted. for
+ in-logs there's no need for this procedure, as the logs
+ always arrive in line-format. */
+
+ FtpThread* ftp = static_cast<FtpThread*>(arg);
+
+ if (out)
+ {
+ int pos;
+ QString buffer = ftp->m_linebuffer + log;
+ while ((pos = buffer.find('\n')) != -1)
+ {
+ ftp->Event(EventHandler::outlog, new QString(buffer.left(pos + 1)));
+ buffer.remove(0, pos + 1);
+ }
+ ftp->m_linebuffer = buffer;
+ }
+ else ftp->Event(EventHandler::inlog, new QString(log));
+}
+
+/* set the receiver for the events the thread posts when a certain ftp operation is done */
+
+void FtpThread::SetEventReceiver(QObject* eventreceiver)
+{
+ mp_eventreceiver = eventreceiver;
+}
+
+/* connect to host */
+
+bool FtpThread::Connect(QString host)
+{
+ InitInternals();
+
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(host);
+ m_tasklist.append(FtpThread::connect);
+ return true;
+ }
+}
+
+/* login with user and pass */
+
+bool FtpThread::Login(QString user, QString pass)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(user);
+ m_stringlist.append(pass);
+ m_tasklist.append(FtpThread::login);
+ return true;
+ }
+}
+
+/* quit the ftp session*/
+
+bool FtpThread::Quit()
+{
+ if (running()) return false;
+ else
+ {
+ m_tasklist.append(FtpThread::quit);
+ return true;
+ }
+}
+
+/* get file */
+
+bool FtpThread::Transfer_Get(QString src, QString dst, int tls, off64_t resume)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(src);
+ m_stringlist.append(dst);
+ m_intlist.append(tls);
+ m_ulonglist.append(resume);
+ m_tasklist.append(FtpThread::transfer_get);
+ return true;
+ }
+}
+
+/* fxp file */
+
+bool FtpThread::Transfer_Fxp(QString src, QString dst, FtpThread *dstftp, int srctls, int dsttls, off64_t resume, int alt)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(src);
+ m_stringlist.append(dst);
+ m_ftplist.append(dstftp);
+ m_intlist.append(srctls);
+ m_intlist.append(dsttls);
+ m_ulonglist.append(resume);
+ m_intlist.append(alt);
+ m_tasklist.append(FtpThread::transfer_fxp);
+ return true;
+ }
+}
+
+/* put file */
+
+bool FtpThread::Transfer_Put(QString src, QString dst, int tls, off64_t resume)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(src);
+ m_stringlist.append(dst);
+ m_intlist.append(tls);
+ m_ulonglist.append(resume);
+ m_tasklist.append(FtpThread::transfer_put);
+ return true;
+ }
+}
+
+/* transfer mkdir */
+
+bool FtpThread::Transfer_Mkdir(QString dir)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(dir);
+ m_tasklist.append(FtpThread::transfer_mkdir);
+ return true;
+ }
+}
+
+/* rename file */
+
+bool FtpThread::Rename(QString src, QString dst)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(src);
+ m_stringlist.append(dst);
+ m_tasklist.append(FtpThread::rename);
+ return true;
+ }
+}
+
+/* set wether the data channel is encrypted or not */
+
+bool FtpThread::Pasv(bool flag)
+{
+ if (running()) return false;
+ else
+ {
+ if (flag) mp_ftp->SetConnmode(ftplib::pasv);
+ else mp_ftp->SetConnmode(ftplib::port);
+ return true;
+ }
+}
+
+/* set wether the data channel is encrypted or not */
+
+bool FtpThread::EncryptData(bool flag, bool force)
+{
+ if (running()) return false;
+ else
+ {
+ m_intlist.append(flag);
+ m_intlist.append(force);
+ m_tasklist.append(FtpThread::dataencryption);
+ return true;
+ }
+}
+
+/* retrieve the current workind dir */
+
+bool FtpThread::Pwd()
+{
+ if (running()) return false;
+ else
+ {
+ m_tasklist.append(FtpThread::pwd);
+ return true;
+ }
+}
+
+/* change working dir to the given path */
+
+bool FtpThread::Chdir(QString path)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(path);
+ m_tasklist.append(FtpThread::chdir);
+ return true;
+ }
+}
+
+/* change working dir to the given path, used by transfers */
+
+bool FtpThread::Transfer_Changedir(QString dir, int tls)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(dir);
+ m_intlist.append(tls);
+ m_tasklist.append(FtpThread::transfer_changedir);
+ return true;
+ }
+}
+
+/* creates a directory */
+
+bool FtpThread::Mkdir(QString path)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(path);
+ m_tasklist.append(FtpThread::mkdir);
+ return true;
+ }
+}
+
+/* step above in the working dir */
+
+bool FtpThread::Cdup()
+{
+ if (running()) return false;
+ else
+ {
+ m_tasklist.append(FtpThread::cdup);
+ return true;
+ }
+}
+
+/* retrieve dir contents */
+
+bool FtpThread::Dir(bool force)
+{
+ if (running()) return false;
+ else
+ {
+ m_intlist.append(force);
+ m_tasklist.append(FtpThread::dir);
+ return true;
+ }
+}
+
+/* attempt negotiating an encrypted session */
+
+bool FtpThread::Authtls()
+{
+ if (running()) return false;
+ else
+ {
+ m_tasklist.append(FtpThread::authtls);
+ return true;
+ }
+}
+
+/* delete a file */
+
+bool FtpThread::Rm(QString name)
+{
+ wait(KB_THREAD_TIMEOUT);
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(name);
+ m_tasklist.append(FtpThread::rm);
+ return true;
+ }
+}
+
+/* delete a directory */
+
+bool FtpThread::Rmdir(QString name)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(name);
+ m_tasklist.append(FtpThread::rmdir);
+ return true;
+ }
+}
+
+/* issue raw command */
+
+bool FtpThread::Raw(QString cmd)
+{
+ if (running()) return false;
+ else
+ {
+ m_stringlist.append(cmd);
+ m_tasklist.append(FtpThread::raw);
+ return true;
+ }
+}
+
+/* scan the directory recursively */
+
+bool FtpThread::Scandir(KbDirInfo* dir)
+{
+ if (running()) return false;
+ else
+ {
+ mp_scandir = dir;
+ m_tasklist.append(FtpThread::scandir);
+ return true;
+ }
+}
+/* the thread methods */
+
+void FtpThread::Connect_thread()
+{
+ int result;
+ QString host = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Connect(host.latin1());
+
+ //unsigned long int xxx = mp_ftp->mp_netbuf->ipappr;
+ //qWarning("INFO %lu.%lu.%lu.%lu", xxx & 0xff, (xxx >> 8) & 0xff, (xxx >> 16) & 0xff, (xxx >> 24) & 0xff);
+ //qWarning("INFO: ip:%lu", mp_ftp->mp_netbuf->ipappr);
+
+ if (result) Event(EventHandler::connect_success);
+ else
+ {
+ ClearQueue();
+ Event(EventHandler::connect_failure);
+ }
+}
+
+void FtpThread::Authtls_thread()
+{
+ int result;
+
+ result = mp_ftp->NegotiateEncryption();
+
+ if (result) Event(EventHandler::authtls_success);
+ else
+ {
+ ClearQueue();
+ Event(EventHandler::authtls_failure);
+ }
+}
+
+void FtpThread::Login_thread()
+{
+ int result;
+ QString user = m_stringlist.front();
+ m_stringlist.pop_front();
+ QString pass = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Login(user.latin1(), pass.latin1());
+
+ if (result) Event(EventHandler::login_success);
+ else
+ {
+ ClearQueue();
+ Event(EventHandler::login_failure);
+ }
+}
+
+void FtpThread::Dataencryption_thread()
+{
+ int result, flag, force, cacheindex;
+
+ flag = m_intlist.front();
+ m_intlist.pop_front();
+ force = m_intlist.front();
+ m_intlist.pop_front();
+
+ cacheindex = -1;
+
+ if (KbConfig::dirCachingIsEnabled())
+ {
+ cacheindex = m_cache_list.findIndex(m_pwd);
+
+ if ((cacheindex != -1) && (!force))
+ {
+ Event(EventHandler::encryptdata_success);
+ return;
+ }
+ }
+
+ if (flag) result = mp_ftp->SetDataEncryption(ftplib::secure);
+ else result = mp_ftp->SetDataEncryption(ftplib::unencrypted);
+
+ if (result)
+ {
+ Event(EventHandler::encryptdata_success);
+ m_dataencrypted = flag;
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::encryptdata_failure);
+ }
+}
+
+void FtpThread::Transfer_Changedir_thread()
+{
+ int result;
+ char buffer[1024];
+ QString dirname;
+
+ dirname = locateLocal("appdata", QString::number(rand()) + ".dir");
+
+ QString path = m_stringlist.front();
+ m_stringlist.pop_front();
+ int tls = m_intlist.front();
+ m_intlist.pop_front();
+
+ if (path == m_pwd)
+ {
+ Event(EventHandler::transfer_success);
+ return;
+ }
+
+ result = mp_ftp->Chdir(path.latin1());
+ if (result) Event(EventHandler::chdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::chdir_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+
+ result = mp_ftp->Pwd(buffer, 1024);
+ if (result)
+ {
+ Event(EventHandler::pwd_success, new QString(buffer));
+ m_pwd = buffer;
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::pwd_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+
+ if (tls)
+ {
+ result = mp_ftp->SetDataEncryption(ftplib::secure);
+ if (result)
+ {
+ Event(EventHandler::encryptdata_success);
+ m_dataencrypted = true;
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::encryptdata_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+ }
+
+ result = mp_ftp->Dir(dirname.latin1(), "");
+ if (result)
+ {
+ m_dirlist.clear();
+ m_filelist.clear();
+ FormatFilelist(dirname.latin1(), m_pwd, &m_dirlist, &m_filelist);
+ m_dircontent.first = m_dirlist;
+ m_dircontent.second = m_filelist;
+ Event(EventHandler::dir_success, &m_dircontent);
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::dir_failure, &m_dircontent);
+ }
+
+ if (!result) Event(EventHandler::transfer_failure);
+ else Event(EventHandler::transfer_success);
+
+ QFile::remove(dirname);
+}
+
+void FtpThread::Transfer_Mkdir_thread()
+{
+ int result;
+ QString dir = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Mkdir(dir.latin1());
+ if (result) Event(EventHandler::mkdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::mkdir_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+
+ Event(EventHandler::transfer_success);
+}
+
+void FtpThread::Transfer_Get_thread()
+{
+ int result;
+
+ QString src = m_stringlist.front();
+ m_stringlist.pop_front();
+ QString dst = m_stringlist.front();
+ m_stringlist.pop_front();
+ int tls = m_intlist.front();
+ m_intlist.pop_front();
+ off64_t resume = m_ulonglist.front();
+ m_ulonglist.pop_front();
+
+ if (tls > 1)
+ {
+ if (tls == 2) result = mp_ftp->SetDataEncryption(ftplib::unencrypted);
+ else result = mp_ftp->SetDataEncryption(ftplib::secure);
+ if (result)
+ {
+ Event(EventHandler::encryptdata_success);
+ m_dataencrypted = (tls > 2);
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::encryptdata_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+ }
+
+ if (resume == 0) result = mp_ftp->Get(dst.latin1(), src.latin1(), ftplib::image);
+ else result = mp_ftp->Get(dst.latin1(), src.latin1(), ftplib::image, resume);
+
+ if (result) Event(EventHandler::get_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::get_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+
+ Event(EventHandler::transfer_success);
+}
+
+void FtpThread::Transfer_Put_thread()
+{
+ int result;
+
+ QString src = m_stringlist.front();
+ m_stringlist.pop_front();
+ QString dst = m_stringlist.front();
+ m_stringlist.pop_front();
+ int tls = m_intlist.front();
+ m_intlist.pop_front();
+ off64_t resume = m_ulonglist.front();
+ m_ulonglist.pop_front();
+
+ if (tls > 1)
+ {
+ if (tls == 2) result = mp_ftp->SetDataEncryption(ftplib::unencrypted);
+ else result = mp_ftp->SetDataEncryption(ftplib::secure);
+ if (result)
+ {
+ Event(EventHandler::encryptdata_success);
+ m_dataencrypted = (tls > 2);
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::encryptdata_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+ }
+
+ if (resume == 0) result = mp_ftp->Put(src.latin1(), dst.latin1(), ftplib::image);
+ else result = mp_ftp->Put(src.latin1(), dst.latin1(), ftplib::image, resume);
+
+ if (result) Event(EventHandler::put_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::put_failure);
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+
+ Event(EventHandler::transfer_success);
+}
+
+void FtpThread::Quit_thread()
+{
+ int result;
+
+ result = mp_ftp->Quit();
+
+ if (result) Event(EventHandler::quit_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::quit_failure);
+ }
+}
+
+void FtpThread::Transfer_Fxp_thread()
+{
+ int result = 0;
+ ftplib::ftp method;
+
+ QString src = m_stringlist.front();
+ m_stringlist.pop_front();
+ QString dst = m_stringlist.front();
+ m_stringlist.pop_front();
+ FtpThread* dstftp = m_ftplist.front();
+ m_ftplist.pop_front();
+ int srctls = m_intlist.front();
+ m_intlist.pop_front();
+ int dsttls = m_intlist.front();
+ m_intlist.pop_front();
+ off64_t resume = m_ulonglist.front();
+ m_ulonglist.pop_front();
+ int alt = m_intlist.front();
+ m_intlist.pop_front();
+
+ if (srctls > 1)
+ {
+ if (!FxpDisableTls())
+ {
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+ }
+
+ if (dsttls > 1)
+ {
+ if (!dstftp->FxpDisableTls())
+ {
+ Event(EventHandler::transfer_failure);
+ return;
+ }
+ }
+
+ if (alt) method = ftplib::alternativefxp;
+ else method = ftplib::defaultfxp;
+
+ qWarning("bla_thread: %d", alt);
+
+ if (resume) qWarning("WARNING: fxp resume isn't supported. overwriting file instead");
+ result == ftplib::Fxp(mp_ftp, dstftp->Ftp(), src, dst, ftplib::image, method);
+
+ FxpReportResult(result);
+ dstftp->FxpReportResult(result);
+
+ if (result) Event(EventHandler::transfer_success);
+ else Event(EventHandler::transfer_failure);
+}
+
+bool FtpThread::FxpDisableTls()
+{
+ bool result = mp_ftp->SetDataEncryption(ftplib::unencrypted);
+ if (result)
+ {
+ Event(EventHandler::encryptdata_success);
+ m_dataencrypted = false;
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::encryptdata_failure);
+ }
+
+ return result;
+}
+
+void FtpThread::FxpReportResult(bool result)
+{
+ if (result) Event(EventHandler::fxp_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::fxp_failure);
+ }
+}
+
+void FtpThread::Pwd_thread()
+{
+ char buffer[1024];
+ int result;
+
+ result = mp_ftp->Pwd(buffer, 1024);
+
+ if (result)
+ {
+ Event(EventHandler::pwd_success, new QString(buffer));
+ m_pwd = buffer;
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::pwd_failure);
+ }
+}
+
+void FtpThread::Chdir_thread()
+{
+ int result;
+
+ QString path = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Chdir(path.latin1());
+
+ if (result) Event(EventHandler::chdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::chdir_failure);
+ }
+}
+
+void FtpThread::Mkdir_thread()
+{
+ int result;
+
+ QString path = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Mkdir(path.latin1());
+
+ if (result) Event(EventHandler::mkdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::mkdir_failure);
+ }
+}
+
+void FtpThread::Cdup_thread()
+{
+ int result;
+
+ result = mp_ftp->Cdup();
+
+ if (result) Event(EventHandler::chdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::chdir_failure);
+ }
+}
+
+void FtpThread::Rm_thread()
+{
+ int result;
+
+ QString name = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Delete(name.latin1());
+
+ if (result) Event(EventHandler::rm_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::rm_failure);
+ }
+}
+
+void FtpThread::Rename_thread()
+{
+ int result;
+
+ QString src = m_stringlist.front();
+ m_stringlist.pop_front();
+ QString dst = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Rename(src.latin1(),dst.latin1());
+
+ if (result) Event(EventHandler::rename_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::rename_failure);
+ }
+}
+
+void FtpThread::Dir_thread()
+{
+ int result;
+ QString dirname;
+ int cacheindex = -1;
+
+ int force = m_intlist.front();
+ m_intlist.pop_front();
+
+ dirname = locateLocal("appdata", QString::number(rand()) + ".dir");
+
+ if (KbConfig::dirCachingIsEnabled())
+ {
+ cacheindex = m_cache_list.findIndex(m_pwd);
+
+ if ((cacheindex != -1) && (!force))
+ {
+ m_dircontent = m_cache_vector.at(cacheindex);
+ Event(EventHandler::dir_success, &m_dircontent);
+ return;
+ }
+ }
+
+ result = mp_ftp->Dir(dirname.latin1(), "");
+
+ if (result)
+ {
+ m_dirlist.clear();
+ m_filelist.clear();
+ FormatFilelist(dirname.latin1(), m_pwd, &m_dirlist, &m_filelist);
+ m_dircontent.first = m_dirlist;
+ m_dircontent.second = m_filelist;
+ m_cache_vector.push_back(m_dircontent);
+ m_cache_list.push_back(m_pwd);
+
+ if (KbConfig::dirCachingIsEnabled())
+ {
+ if (cacheindex == -1)
+ {
+ m_cache_vector.push_back(m_dircontent);
+ m_cache_list.push_back(m_pwd);
+ }
+ else m_cache_vector.at(cacheindex) = m_dircontent;
+ }
+ Event(EventHandler::dir_success, &m_dircontent);
+ }
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::dir_failure, &m_dircontent);
+ }
+
+ QFile::remove(dirname);
+}
+
+void FtpThread::Scandir_thread()
+{
+ bool result = true;
+
+ list<KbDirInfo*>::iterator end_dir = mp_scandir->Dirlist()->end();
+ for(list<KbDirInfo*>::iterator dirIterator = mp_scandir->Dirlist()->begin(); dirIterator != end_dir; dirIterator++)
+ {
+ result = Scandir_recurse(*dirIterator, (*dirIterator)->dirPath() + (*dirIterator)->fileName());
+ }
+
+ if (result) Event(EventHandler::scandir_success, mp_scandir);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::scandir_failure);
+ }
+}
+
+void FtpThread::Rmdir_thread()
+{
+ bool result;
+
+ QString name = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = Delete_recurse(name.latin1());
+
+ if (result) Event(EventHandler::rmdir_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::rmdir_failure);
+ }
+}
+
+void FtpThread::Raw_thread()
+{
+ bool result;
+
+ QString cmd = m_stringlist.front();
+ m_stringlist.pop_front();
+
+ result = mp_ftp->Raw(cmd.latin1());
+
+ if (result) Event(EventHandler::raw_success);
+ else
+ {
+ if (ConnectionLost()) Event(EventHandler::connectionlost);
+ else Event(EventHandler::raw_failure);
+ }
+}
+
+/* the thread's main loop */
+
+void FtpThread::run()
+{
+ while (!m_tasklist.empty())
+ {
+ task t = m_tasklist.front();
+ m_tasklist.pop_front();
+
+ switch (t)
+ {
+ case FtpThread::connect:
+ Connect_thread();
+ break;
+ case FtpThread::login:
+ Login_thread();
+ break;
+ case FtpThread::quit:
+ Quit_thread();
+ break;
+ case FtpThread::pwd:
+ Pwd_thread();
+ break;
+ case FtpThread::chdir:
+ Chdir_thread();
+ break;
+ case FtpThread::cdup:
+ Cdup_thread();
+ break;
+ case FtpThread::dir:
+ Dir_thread();
+ break;
+ case FtpThread::scandir:
+ Scandir_thread();
+ break;
+ case FtpThread::rm:
+ Rm_thread();
+ break;
+ case FtpThread::rmdir:
+ Rmdir_thread();
+ break;
+ case FtpThread::authtls:
+ Authtls_thread();
+ break;
+ case FtpThread::dataencryption:
+ Dataencryption_thread();
+ break;
+ case FtpThread::transfer_get:
+ Transfer_Get_thread();
+ break;
+ case transfer_put:
+ Transfer_Put_thread();
+ break;
+ case FtpThread::mkdir:
+ Mkdir_thread();
+ break;
+ case FtpThread::rename:
+ Rename_thread();
+ break;
+ case FtpThread::raw:
+ Raw_thread();
+ break;
+ case FtpThread::transfer_changedir:
+ Transfer_Changedir_thread();
+ break;
+ case FtpThread::transfer_mkdir:
+ Transfer_Mkdir_thread();
+ break;
+ case FtpThread::transfer_fxp:
+ Transfer_Fxp_thread();
+ default:
+ Event(EventHandler::error);
+ break;
+ }
+ }
+ Event(EventHandler::finished);
+}
+
+/* event is posted to the eventreceiver */
+
+void FtpThread::Event(EventHandler::EventType type, void *data)
+{
+ if (mp_eventreceiver == NULL) qWarning("WARNING: mp_eventreceiver is NULL");
+ else
+ {
+ QCustomEvent* e = new QCustomEvent(type);
+ if (data != NULL) e->setData(data);
+ qApp->postEvent(mp_eventreceiver, e);
+ }
+}
+
+/* parses the dir file */
+
+bool FtpThread::FormatFilelist(const char *filename, QString current, filist *dirtable, filist *filetable)
+{
+ int i, blocks, space, month_int = 1;
+ unsigned int loc, fileloc, datebegin, sizebegin = 0;
+ string buffer, filestring;
+
+ FILE* dirfile;
+
+ char file[1024];
+
+ char month[][5] = {
+ "... ", "Jan ", "Feb ", "Mar ", "Apr ", "May ", "Jun ", "Jul ", "Aug ",
+ "Sep ", "Oct ", "Nov ", "Dec "
+ };
+
+ dirfile = fopen(filename, "r");
+ if (dirfile == NULL)
+ {
+ qWarning("ERROR: failed open dirfile");
+ return false;
+ }
+
+ while (fgets(file, 1024, dirfile) != NULL)
+ {
+ *(strchr(file,'\n')) = '\0';
+ buffer = file;
+
+ for (i = 1; i < 13; i++)
+ {
+ loc = buffer.find(month[i], 0);
+ if (loc != string::npos)
+ {
+ month_int = i;
+ break;
+ }
+ }
+ if( loc == string::npos )
+ {
+ qWarning("INFO: no month entry found");
+ loc = buffer.length();
+ }
+
+ datebegin = loc;
+
+ space = 1;
+ blocks = 0;
+ fileloc = 0;
+ while (loc < buffer.length())
+ {
+ if (space)
+ {
+ // look for a space
+ if (buffer[loc] == ' ')
+ {
+ blocks++;
+ space = !space;
+ }
+ }
+ else
+ {
+ // look for a non-space
+ if (buffer[loc] != ' ')
+ {
+ if (blocks > 2)
+ {
+ fileloc = loc;
+ break;
+ }
+ space = !space;
+ }
+ }
+ loc += 1;
+ }
+ if (blocks != 3)
+ {
+ qWarning("INFO: ignoring invalid line in dirlist");
+ }
+ else
+ {
+ QString date(buffer.substr( datebegin, loc - datebegin - 1).c_str());
+
+ int day_int = date.section( ' ', 1, 1 ).toInt();
+ int year_int = date.section( ' ', -1, -1 ).toInt();
+ int hour_int = 0;
+ int minute_int = 0;
+
+ if (day_int == 0) day_int = date.section( ' ', 1, 2 ).toInt();
+
+ if (year_int == 0)
+ {
+ year_int = QDate::currentDate().year();
+ if (month_int > QDate::currentDate().month()) year_int--;
+ QTime mytime = QTime::fromString(date.section( ' ', -1, -1 ));
+ hour_int = mytime.hour();
+ minute_int = mytime.minute();
+ }
+
+ unsigned int date_int =
+ (minute_int) |
+ (hour_int << 6 ) |
+ (day_int << 11) |
+ (month_int << 16) |
+ (year_int << 20);
+
+ // 6 bits for minutes, 5 bits for hours, 5 bits for days, 4 bits for months, 11 bits for years -> 31 bits (should be sufficient)
+
+ space = 0;
+ blocks = 0;
+ loc = datebegin;
+ while (loc > 0)
+ {
+ if (space)
+ {
+ if (buffer[loc] == ' ')
+ {
+ blocks++;
+ space = !space;
+ }
+ }
+ else
+ {
+ if (buffer[loc] != ' ')
+ {
+ if (blocks > 1)
+ {
+ sizebegin = loc + 1;
+ break;
+ }
+ space = !space;
+ }
+ }
+ loc--;
+ }
+
+ off64_t size = atoll(buffer.substr( sizebegin, datebegin - sizebegin).c_str());
+
+ filestring.erase();
+ filestring.append(buffer, fileloc, buffer.length() - fileloc);
+ if ((filestring.compare(".") != 0) && (filestring.compare("..") != 0))
+ {
+ if ((*file == 'd') || (*file == 'D'))
+ {
+ KbFileInfo* di = new KbFileInfo(current, filestring.c_str(), size, date, date_int);
+ dirtable->push_back(di);
+ }
+ else if ((*file == 'l') || (*file == 'L'))
+ {
+ qWarning("INFO: links to files not supported yet");
+ }
+ else
+ {
+ KbFileInfo* fi = new KbFileInfo(current, filestring.c_str(), size, date, date_int);
+ filetable->push_back(fi);
+ }
+ }
+ }
+ }
+ fclose(dirfile);
+ return true;
+}
+
+/* recursive method to check content of a directory */
+
+bool FtpThread::Scandir_recurse(KbDirInfo *dir, QString path)
+{
+ char currentpath[1024];
+ int result;
+ filist dirlist;
+ filist filelist;
+ QString dirname;
+
+ result = mp_ftp->Pwd(currentpath, 1024);
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ result = mp_ftp->Chdir(dir->fileName().latin1());
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return true;
+ }
+ else Event(EventHandler::misc_success);
+
+ dirname = locateLocal("appdata", QString::number(rand()) + ".dir");
+
+ result = mp_ftp->Dir(dirname.latin1(), "");
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ if(!FormatFilelist(dirname.latin1(), path, &dirlist, &filelist)) return false;
+
+ QFile::remove(dirname);
+
+ filist::iterator end_file = filelist.end();
+ for(filist::iterator fiIterator = filelist.begin(); fiIterator != end_file; fiIterator++)
+ {
+ dir->AddFile(*fiIterator);
+ }
+
+ filist::iterator end_dir = dirlist.end();
+ for(filist::iterator fiIterator = dirlist.begin(); fiIterator != end_dir; fiIterator++)
+ {
+ KbDirInfo* newdir = dir->AddDirectory(**fiIterator);
+ if (!Scandir_recurse(newdir, path + '/' + newdir->fileName())) return false;
+ }
+
+ result = mp_ftp->Chdir(currentpath);
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ return true;
+}
+
+/* recursive method to delete directories */
+
+bool FtpThread::Delete_recurse(QString name)
+{
+ char currentdir[1024];
+ int result;
+ filist dirlist;
+ filist filelist;
+ QString dirname;
+
+ result = mp_ftp->Pwd(currentdir, 1024);
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ result = mp_ftp->Chdir(name.latin1());
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return true;
+ }
+ else Event(EventHandler::misc_success);
+
+ //dirname = QDir::homeDirPath() +
+ //"/.kasablanca/" +
+ //QString::number((int) time(NULL) & 0xffff) +
+ //".dir";
+ dirname = locateLocal("appdata", QString::number(rand()) + ".dir");
+
+ result = mp_ftp->Dir(dirname.latin1(), "");
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ if(!FormatFilelist(dirname.latin1(), "", &dirlist, &filelist)) return false;
+
+ QFile::remove(dirname);
+
+ filist::iterator end_file = filelist.end();
+ for(filist::iterator fiIterator = filelist.begin(); fiIterator != end_file; fiIterator++)
+ {
+ result = mp_ftp->Delete((*fiIterator)->fileName().latin1());
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+ }
+
+ filist::iterator end_dir = dirlist.end();
+ for(filist::iterator fiIterator = dirlist.begin(); fiIterator != end_dir; fiIterator++)
+ {
+ if (!Delete_recurse((*fiIterator)->fileName())) return false;
+ }
+
+ result = mp_ftp->Chdir(currentdir);
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ result = mp_ftp->Rmdir(name.latin1());
+
+ if (!result)
+ {
+ Event(EventHandler::misc_failure);
+ return false;
+ }
+ else Event(EventHandler::misc_success);
+
+ return true;
+}
+
+/* check if we lost the connection */
+
+bool FtpThread::ConnectionLost()
+{
+ QString response;
+
+ response = mp_ftp->LastResponse();
+
+ if (response.startsWith("421"))
+ {
+ ClearQueue();
+ return true;
+ }
+ else return false;
+}
+
+/* empty queue */
+
+void FtpThread::ClearQueue()
+{
+ m_tasklist.clear();
+ m_stringlist.clear();
+ m_intlist.clear();
+ m_ulonglist.clear();
+ m_ftplist.clear();
+ m_cache_vector.clear();
+ m_cache_list.clear();
+}
diff --git a/src/ftpthread.h b/src/ftpthread.h
new file mode 100644
index 0000000..4372e82
--- /dev/null
+++ b/src/ftpthread.h
@@ -0,0 +1,156 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef FTPTHREAD_H
+#define FTPTHREAD_H
+
+#define KB_THREAD_TIMEOUT 1000
+
+#include <list>
+#include <qthread.h>
+#include <qstringlist.h>
+#include <qvaluelist.h>
+#include <qvaluevector.h>
+#include "eventhandler.h"
+#include "kbfileinfo.h"
+
+using namespace std;
+
+class ftplib;
+class QObject;
+class KbDirInfo;
+
+typedef list<KbFileInfo*> filist;
+typedef pair<off64_t, bool> xferpair;
+typedef pair<filist, filist> dirpair;
+
+/**
+@author Magnus Kulke
+*/
+class FtpThread : public QThread
+{
+public:
+ FtpThread();
+ ~FtpThread();
+ static void CallbackLog(char *log, void *arg, bool out);
+ static int CallbackXfer(off64_t xfered, void *arg);
+ void SetEventReceiver(QObject* eventreceiver);
+ void ClearQueue();
+ bool Connect(QString host);
+ bool Login(QString user, QString pass);
+ bool Quit();
+ bool Pwd();
+ bool Chdir(QString path);
+ bool Cdup();
+ bool Dir(bool force = false);
+ bool Scandir(KbDirInfo* dir);
+ bool Rm(QString name);
+ bool Rmdir(QString name);
+ bool Authtls();
+ bool Pasv(bool flag);
+ bool EncryptData(bool flag, bool force = false);
+ bool Transfer_Fxp(QString src, QString dst, FtpThread* dstftp, int srctls, int dsttls, off64_t resume = 0, int alt = 0);
+ bool Mkdir(QString path);
+ bool Rename(QString src, QString dst);
+ bool Raw(QString cmd);
+ bool Transfer_Get(QString src, QString dst, int tls, off64_t resume = 0);
+ bool Transfer_Put(QString src, QString dst, int tls, off64_t resume = 0);
+ bool Transfer_Changedir(QString dir, int tls);
+ bool Transfer_Mkdir(QString dir);
+ void Event(EventHandler::EventType type, void *data = NULL);
+ ftplib* Ftp() { return mp_ftp; };
+ void FxpReportResult(bool result);
+ bool FxpDisableTls();
+private:
+ enum task
+ {
+ connect = 0,
+ negotiateencryption,
+ login,
+ quit,
+ pwd,
+ chdir,
+ cdup,
+ dir,
+ scandir,
+ rm,
+ rmdir,
+ authtls,
+ dataencryption,
+ mkdir,
+ rename,
+ raw,
+ transfer_changedir,
+ transfer_get,
+ transfer_mkdir,
+ transfer_put,
+ transfer_fxp
+ };
+ void run();
+ bool FormatFilelist(const char *filename,
+ QString current,
+ filist *filetable,
+ filist *dirtable
+ );
+ void InitInternals();
+ void Connect_thread();
+ void Login_thread();
+ void Pwd_thread();
+ void Quit_thread();
+ void Chdir_thread();
+ void Cdup_thread();
+ void Dir_thread();
+ void Scandir_thread();
+ void Delete_thread();
+ void Rm_thread();
+ void Rmdir_thread();
+ void Authtls_thread();
+ void Dataencryption_thread();
+ void Mkdir_thread();
+ void Rename_thread();
+ void Raw_thread();
+ void Transfer_Changedir_thread();
+ void Transfer_Get_thread();
+ void Transfer_Put_thread();
+ void Transfer_Fxp_thread();
+ void Transfer_Mkdir_thread();
+ bool Scandir_recurse(KbDirInfo *dir, QString path);
+ bool Delete_recurse(QString name);
+ bool ConnectionLost();
+private:
+ QMutex* mp_mutex;
+ QObject* mp_eventreceiver;
+ ftplib* mp_ftp;
+ QString m_pwd;
+ bool m_dataencrypted;
+ KbDirInfo* mp_scandir;
+ filist m_dirlist, m_filelist;
+ dirpair m_dircontent;
+ QValueList<task> m_tasklist;
+ QStringList m_stringlist;
+ QValueList<int> m_intlist;
+ QValueList<off64_t> m_ulonglist;
+ QValueList<FtpThread*> m_ftplist;
+ QValueVector<dirpair> m_cache_vector;
+ QStringList m_cache_list;
+public:
+ QString m_linebuffer;
+};
+
+#endif
diff --git a/src/hi128-app-kasablanca.png b/src/hi128-app-kasablanca.png
new file mode 100644
index 0000000..504c0ce
--- /dev/null
+++ b/src/hi128-app-kasablanca.png
Binary files differ
diff --git a/src/hi16-app-kasablanca.png b/src/hi16-app-kasablanca.png
new file mode 100644
index 0000000..5fbf279
--- /dev/null
+++ b/src/hi16-app-kasablanca.png
Binary files differ
diff --git a/src/hi22-app-kasablanca.png b/src/hi22-app-kasablanca.png
new file mode 100644
index 0000000..2934a1f
--- /dev/null
+++ b/src/hi22-app-kasablanca.png
Binary files differ
diff --git a/src/hi32-app-kasablanca.png b/src/hi32-app-kasablanca.png
new file mode 100644
index 0000000..740d0df
--- /dev/null
+++ b/src/hi32-app-kasablanca.png
Binary files differ
diff --git a/src/hi48-app-kasablanca.png b/src/hi48-app-kasablanca.png
new file mode 100644
index 0000000..ae7ad64
--- /dev/null
+++ b/src/hi48-app-kasablanca.png
Binary files differ
diff --git a/src/hi64-app-kasablanca.png b/src/hi64-app-kasablanca.png
new file mode 100644
index 0000000..a512d7e
--- /dev/null
+++ b/src/hi64-app-kasablanca.png
Binary files differ
diff --git a/src/importdialog.cpp b/src/importdialog.cpp
new file mode 100644
index 0000000..53d7f8f
--- /dev/null
+++ b/src/importdialog.cpp
@@ -0,0 +1,177 @@
+//
+// C++ Implementation: importdialog
+//
+// Description:
+//
+//
+// Author: Christoph Thielecke <u15119@hs-harz.de>, (C) 2004
+//
+// Contains pieces of code from kbear, Bjrn Sahlstrm <kbjorn@users.sourceforge.net>
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <qradiobutton.h>
+#include <qdir.h>
+#include <qfile.h>
+#include <qprogressdialog.h>
+
+#include <klocale.h>
+#include <kconfig.h>
+#include <kmessagebox.h>
+#include <kdebug.h>
+
+#include "kbsiteinfo.h"
+#include "importdialog.h"
+
+using namespace std;
+
+ImportDialog::ImportDialog(QWidget *parent, const char *name ) : KDialogBase(parent, name, true, i18n( "Import Bookmarks" ), KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true)
+{
+ mp_dialog = new KasablancaImportDialog(this);
+ setMainWidget(mp_dialog);
+}
+
+ImportDialog::~ImportDialog()
+{
+}
+
+
+void ImportDialog::slotOk()
+{
+ if (mp_dialog->GftpRadioButton->isChecked())
+ importGftpBookmarks ( QDir::homeDirPath() + "/.gftp/bookmarks" );
+ accept();
+}
+
+void ImportDialog::importGftpBookmarks( QString fileName ) {
+
+// kdDebug() << "import start" << endl;
+ if ( fileName.isEmpty() || fileName.isNull() ) {
+ KMessageBox::sorry( 0, i18n( "You have to select a file to import." ), i18n( "No file" ) );
+
+ // emit progress( 100 );
+ return ;
+ }
+
+ QFile f(fileName);
+ if ( !f.exists() ) {
+ KMessageBox::information( 0, i18n( "No gftp bookmarks to import found." ), i18n( "No file" ) );
+
+ // emit progress( 100 );
+ return ;
+ }
+
+
+ // First we fetch some global settings
+ KConfig tmpConfig( fileName, true, false, "HOME" );
+ QString email = tmpConfig.readEntry( "email", "anonymous@" );
+
+ KConfig config( fileName, true, false, "HOME" );
+ QStringList groupList = config.groupList();
+ float size = ( float ) groupList.count();
+ if ( size == 0 ) {
+
+ // m_hasError = true;
+ // emit progress( 100 );
+ return ;
+ }
+ int counter = 0;
+
+ m_lines = groupList.count();
+
+ QProgressDialog progress( 0, "progressdialog", true );
+ progress.setLabelText( i18n( "Importing bookmarks..." ) );
+ progress.setCancelButton( 0 );
+ progress.setTotalSteps( m_lines );
+
+
+ for ( QStringList::Iterator it = groupList.begin(); it != groupList.end(); ++it ) {
+ QString groupName = *it; // found groupname from gFTP, can have subgroups ( group1/group2/group3 )
+ QStringList groupNames = QStringList::split( "/", groupName ); //split group name into subgroups if any
+
+ config.setGroup( groupName );
+ QString tmp = config.readEntry( "hostname" ); // we ignore the site if it hasn't any host
+
+ // first check so the site has a host, if not ignore it
+ if ( ! tmp.isNull() ) { // had host
+
+ KbSiteInfo newsite;
+
+ // kdDebug() << "-- start -- " << endl;
+
+ // kdDebug() << "bookmark count (read): " << counter << endl;
+
+ tmp = groupName;
+ // kdDebug() << "label: " << tmp << endl;
+ newsite.SetName( tmp );
+
+ // set host
+ tmp = config.readEntry( "hostname" );
+ // kdDebug() << "hostname: " << tmp << endl;
+
+ // set port
+ int p = config.readNumEntry( "port", 21 );
+ // kdDebug() << "port: " << p << endl;
+
+
+ // QString HostPort = tmp; /* host:port */
+ // HostPort += ":";
+ // HostPort += QString().setNum( p );
+
+ newsite.SetInfo(tmp + ":" + QString::number(p));
+
+ //newsite.SetPort( p );
+ //newsite.SetHostname(tmp);
+
+ // set protocol
+ //tmp = config.readEntry( "protocol", "ftp" ).lower();
+ //kdDebug() << "protocol: " << tmp << endl;
+
+ // set remote directory
+ tmp = config.readEntry( "remote directory", "/" );
+ // kdDebug() << "remote directory: " << tmp << endl;
+ newsite.SetDefaultDirectory( tmp );
+
+ // set local directory
+ //tmp = config.readEntry( "local directory", QDir::homeDirPath() );
+ //kdDebug() << "local directory: " << tmp << endl;
+
+ // set username
+ tmp = config.readEntry( "username", "anonymous" );
+ newsite.SetUser( tmp );
+
+ // set password
+ tmp = config.readEntry( "password" );
+
+ if ( tmp == "@EMAIL@" || tmp.isNull() || tmp.isEmpty() )
+ tmp = email;
+
+// kdDebug() << "password: " << tmp << endl;
+ newsite.SetPass( tmp );
+
+// kdDebug() << "-- end -- " << endl;
+
+ newsite.SetPasv( 1 );
+ newsite.SetTls( 0 );
+ newsite.SetAlternativeFxp( 0 );
+ newsite.SetCorrectPasv( 0 );
+
+ m_bookmarks.push_back( newsite );
+ }
+ // emit progress( int( float( counter ) / size * 100 ) );
+ counter++;
+ progress.setProgress( counter );
+ } // for
+ KMessageBox::information( 0, i18n( "%1 bookmarks from gftp successful imported." ).arg(QString().setNum(counter-1)), i18n( "Successful import" ) );
+ /*
+ int cnt = 0;
+ list<KbSiteInfo>::iterator end_session = bookmarks.end();
+ for (list<KbSiteInfo>::iterator i = bookmarks.begin(); i != end_session; i++){
+
+ cnt++;
+ kdDebug() << "bookmark count(list): " << cnt << endl;
+ }*/
+}
+
diff --git a/src/importdialog.h b/src/importdialog.h
new file mode 100644
index 0000000..dfe2716
--- /dev/null
+++ b/src/importdialog.h
@@ -0,0 +1,40 @@
+//
+// C++ Interface: importdialog
+//
+// Description:
+//
+//
+// Author: Christoph Thielecke <u15119@hs-harz.de>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef IMPORTDIALOG_H
+#define IMPORTDIALOG_H
+
+#include <kdialogbase.h>
+
+#include <list>
+
+#include "kbsiteinfo.h"
+
+#include "Q_importdialog.h"
+
+/**
+@author Christoph Thielecke
+*/
+class ImportDialog : public KDialogBase
+{
+public:
+ ImportDialog(QWidget *parent=0, const char *name=0);
+ ~ImportDialog();
+ list<KbSiteInfo>* Bookmarks() { return &m_bookmarks; };
+private:
+ list<KbSiteInfo> m_bookmarks;
+ int m_lines;
+ KasablancaImportDialog *mp_dialog;
+ void slotOk();
+ void importGftpBookmarks(QString fileName);
+};
+
+#endif
diff --git a/src/kasablanca.cpp b/src/kasablanca.cpp
new file mode 100644
index 0000000..ecaf77c
--- /dev/null
+++ b/src/kasablanca.cpp
@@ -0,0 +1,632 @@
+/***************************************************************************
+ kasablanca.cpp - description
+ -------------------
+ begin : Die Aug 19 20:54:14 CEST 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#include <kaction.h>
+#include <kapp.h>
+#include <kapplication.h>
+#include <kdeversion.h>
+#include <kedittoolbar.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kicontheme.h>
+#include <kkeydialog.h>
+#include <klocale.h>
+#include <kmainwindow.h>
+#include <kmenubar.h>
+#include <kmessagebox.h>
+#include <kstandarddirs.h>
+#include <kstatusbar.h>
+#include <kstdaction.h>
+#include <ksystemtray.h>
+#include <kconfigdialog.h>
+#include <kpassivepopup.h>
+#include <klineedit.h>
+
+#include <qtextedit.h>
+#include <qcolor.h>
+#include <qlistview.h>
+#include <qpushbutton.h>
+#include <qheader.h>
+#include <qtoolbutton.h>
+#include <qaction.h>
+
+#include "Q_colorspreferencesdialog.h"
+#include "Q_generalpreferencesdialog.h"
+#include "Q_userinterfacepreferencesdialog.h"
+#include "importdialog.h"
+#include "customconnectdialog.h"
+#include "fileexistsdialog.h"
+#include "bookmarkdialog.h"
+#include "kbtransferdir.h"
+#include "kbtransferfile.h"
+#include "kbdirinfo.h"
+#include "ftpsession.h"
+#include "kbconfig.h"
+#include "kbtaskview.h"
+#include "kasablanca.h"
+#include "kbstatustip.h"
+
+using namespace std;
+
+Kasablanca::Kasablanca() : KMainWindow( 0, "Kasablanca" ), mp_view(new KasablancaMainWindow(this))
+{
+ //first, load the system tray icon
+ mp_systemtray = new KSystemTray(this);
+ mp_systemtray->setPixmap( KSystemTray::loadIcon( "kasablanca" ) );
+ if ( KbConfig::systrayIsEnabled() ) mp_systemtray->show();
+
+ mp_statustip = new KbStatusTip(mp_systemtray);
+
+ mp_session_a = new FtpSession(this, "session a");
+ mp_session_b = new FtpSession(this, "session b");
+ mp_sessionlist = new list<FtpSession*>;
+ mp_sessionlist->push_back(mp_session_a);
+ mp_sessionlist->push_back(mp_session_b);
+
+ setAcceptDrops(true);
+ setCentralWidget(mp_view);
+ setupGUI();
+ setupActions();
+ setupStatusBar();
+ setupMenu();
+ statusBar()->show();
+
+ setAutoSaveSettings();
+
+ /* when the qmainwindow is closed the object gets deleted,
+ so the destructers of kbprocesses are called. */
+
+ setWFlags(WDestructiveClose);
+
+ /* if initbookmarks returns false, an error box appears */
+
+ InitBookmarks();
+
+ //if (!InitBookmarks() != 1) KMessageBox::error(0, i18n("Could not open Kasablanca bookmark xml."));
+
+ connect(mp_view->BrowserB, SIGNAL(selectionChanged()), SLOT(SLOT_SelectionChanged()));
+ connect(mp_view->BrowserA, SIGNAL(selectionChanged()), SLOT(SLOT_SelectionChanged()));
+ connect(mp_view->TaskView, SIGNAL(selectionChanged()), SLOT(SLOT_SelectionChanged()));
+
+ mp_session_a->SetLogWindow(mp_view->LogWindowA);
+ mp_session_a->SetBrowser(mp_view->BrowserA);
+ mp_session_a->SetConnectButton(mp_view->ConnectButtonA);
+ mp_session_a->SetRefreshButton(mp_view->RefreshButtonA);
+ mp_session_a->SetTransferButton(mp_view->TransferButtonA);
+ mp_session_a->SetCmdLine(mp_view->CommandLineA);
+ mp_session_a->SetCwdLine(mp_view->CwdLineA);
+ mp_session_a->SetBookmarksMenu(&m_bookmarksmenu_a);
+ mp_session_a->SetStatusLine(mp_statusline_a);
+ mp_session_a->SetEncryptionIcon(mp_encryptionicon_a);
+ mp_session_a->SetRclickMenu(&m_rclickmenu_a);
+ mp_session_a->SetSessionList(mp_sessionlist);
+
+ connect(mp_view->RefreshButtonA, SIGNAL(clicked()), mp_session_a, SLOT(SLOT_RefreshButton()));
+ connect(mp_view->ConnectButtonA, SIGNAL(clicked()), mp_session_a, SLOT(SLOT_ConnectButton()));
+ connect(mp_view->TransferButtonA, SIGNAL(clicked()), mp_session_a, SLOT(SLOT_TransferButton()));
+ connect(mp_view->CwdLineA, SIGNAL(returnPressed()), mp_session_a, SLOT(SLOT_CwdLine()));
+ connect(mp_view->CommandLineA, SIGNAL(returnPressed()), mp_session_a, SLOT(SLOT_CmdLine()));
+
+ mp_session_b->SetLogWindow(mp_view->LogWindowB);
+ mp_session_b->SetBrowser(mp_view->BrowserB);
+ mp_session_b->SetConnectButton(mp_view->ConnectButtonB);
+ mp_session_b->SetRefreshButton(mp_view->RefreshButtonB);
+ mp_session_b->SetTransferButton(mp_view->TransferButtonB);
+ mp_session_b->SetCmdLine(mp_view->CommandLineB);
+ mp_session_b->SetCwdLine(mp_view->CwdLineB);
+ mp_session_b->SetBookmarksMenu(&m_bookmarksmenu_b);
+ mp_session_b->SetStatusLine(mp_statusline_b);
+ mp_session_b->SetEncryptionIcon(mp_encryptionicon_b);
+ mp_session_b->SetRclickMenu(&m_rclickmenu_b);
+ mp_session_b->SetSessionList(mp_sessionlist);
+
+ connect(mp_view->RefreshButtonB, SIGNAL(clicked()), mp_session_b, SLOT(SLOT_RefreshButton()));
+ connect(mp_view->ConnectButtonB, SIGNAL(clicked()), mp_session_b, SLOT(SLOT_ConnectButton()));
+ connect(mp_view->TransferButtonB, SIGNAL(clicked()), mp_session_b, SLOT(SLOT_TransferButton()));
+ connect(mp_view->CwdLineB, SIGNAL(returnPressed()), mp_session_b, SLOT(SLOT_CwdLine()));
+ connect(mp_view->CommandLineB, SIGNAL(returnPressed()), mp_session_b, SLOT(SLOT_CmdLine()));
+ connect(mp_session_a, SIGNAL(gui_update()), SLOT(SLOT_SelectionChanged()));
+ connect(mp_session_b, SIGNAL(gui_update()), SLOT(SLOT_SelectionChanged()));
+ connect(mp_session_a, SIGNAL(gui_queueitems(KbDirInfo*, FtpSession*, FtpSession*, bool)),
+ SLOT(SLOT_QueueItems(KbDirInfo*, FtpSession*, FtpSession*, bool)));
+ connect(mp_session_b, SIGNAL(gui_queueitems(KbDirInfo*, FtpSession*, FtpSession*, bool)),
+ SLOT(SLOT_QueueItems(KbDirInfo*, FtpSession*, FtpSession*, bool)));
+ connect(mp_session_a, SIGNAL(gui_succeedtransfer(QListViewItem*)), SLOT(SLOT_NextTransfer(QListViewItem*)));
+ connect(mp_session_b, SIGNAL(gui_succeedtransfer(QListViewItem*)), SLOT(SLOT_NextTransfer(QListViewItem*)));
+ connect(mp_session_a, SIGNAL(gui_clearqueue(FtpSession*)), SLOT(SLOT_ClearQueue(FtpSession*)));
+ connect(mp_session_b, SIGNAL(gui_clearqueue(FtpSession*)), SLOT(SLOT_ClearQueue(FtpSession*)));
+
+ QAction *deleteShortcut = new QAction( QPixmap(), "&Delete",
+ Key_Delete, this, "delete" );
+
+ connect(deleteShortcut, SIGNAL(activated()), this, SLOT(SLOT_SkipTasks()));
+
+ mp_session_a->Disconnect();
+ mp_session_b->Disconnect();
+
+ applyConfig();
+}
+
+void Kasablanca::setupGUI()
+{
+ mp_view->TaskView->setSorting(-1);
+ mp_view->BrowserA->setSorting(-1);
+ mp_view->BrowserB->setSorting(-1);
+
+ mp_view->TransferButtonA->setIconSet(KGlobal::iconLoader()->loadIconSet("forward",KIcon::Toolbar));
+ mp_view->TransferButtonB->setIconSet(KGlobal::iconLoader()->loadIconSet("back",KIcon::Toolbar));
+ mp_view->RefreshButtonA->setIconSet(KGlobal::iconLoader()->loadIconSet("reload",KIcon::Toolbar));
+ mp_view->RefreshButtonB->setIconSet(KGlobal::iconLoader()->loadIconSet("reload",KIcon::Toolbar));
+ mp_view->ConnectButtonA->setIconSet(KGlobal::iconLoader()->loadIconSet("connect_no",KIcon::Toolbar));
+ mp_view->ConnectButtonB->setIconSet(KGlobal::iconLoader()->loadIconSet("connect_no",KIcon::Toolbar));
+}
+
+void Kasablanca::applyConfig()
+{
+ FtpSession::filecheck def = FtpSession::off;
+ if (!KbConfig::onFileExistsIsEnabled()) def = FtpSession::off;
+ else if(KbConfig::onFileExistsOverwrite()) def = FtpSession::clear;
+ else if(KbConfig::onFileExistsResume()) def = FtpSession::resume;
+ else if(KbConfig::onFileExistsSkip()) def = FtpSession::skip;
+
+ m_skiplist.setPattern(KbConfig::skiplist());
+ m_skiplistenabled = KbConfig::skiplistIsEnabled();
+ m_onqueuefinishedenabled = KbConfig::onQueueFinishedIsEnabled();
+ m_onqueuefinished = KbConfig::onQueueFinished();
+
+ list<FtpSession*>::iterator end_session = mp_sessionlist->end();
+ for (list<FtpSession*>::iterator i = mp_sessionlist->begin(); i != end_session; i++)
+ {
+ (*i)->SetColors(KbConfig::localColor(), KbConfig::successColor(), KbConfig::failureColor(), KbConfig::backgroundColor());
+ (*i)->SetOnFileExistsDefault(def);
+ (*i)->EnableCmdLine(KbConfig::commandLineIsEnabled());
+ (*i)->SetFont(KbConfig::logwindowFont());
+ (*i)->FilterHiddenFiles(KbConfig::hideHiddenFilesIsEnabled());
+ }
+
+ // make the system tray switch on/off when settings are changed
+ if (KbConfig::systrayIsEnabled()) mp_systemtray->show();
+ else mp_systemtray->hide();
+}
+
+void Kasablanca::saveSettings()
+{
+ KbConfig::writeConfig();
+}
+
+void Kasablanca::setupActions()
+{
+ KStdAction::quit(kapp, SLOT(quit()), actionCollection());
+
+ //m_toolbarAction = KStdAction::showToolbar(this, SLOT(optionsShowToolbar()), actionCollection());
+ m_statusbarAction = KStdAction::showStatusbar(this, SLOT(optionsShowStatusbar()), actionCollection());
+
+ KStdAction::keyBindings(this, SLOT(optionsConfigureKeys()), actionCollection());
+ //KStdAction::configureToolbars(this, SLOT(optionsConfigureToolbars()), actionCollection());
+ KStdAction::preferences(this, SLOT(optionsPreferences()), actionCollection());
+
+ /*
+ // this doesn't do anything useful. it's just here to illustrate
+ // how to insert a custom menu and menu item
+ KAction *custom = new KAction(i18n("Cus&tom Menuitem"), 0,
+ this, SLOT(optionsPreferences()),
+ actionCollection(), "custom_action");
+ */
+
+ new KAction(i18n("Edit"), CTRL+Key_E, this, SLOT(SLOT_EditBookmarks()), actionCollection(), "edit bookmarks action");
+
+ new KAction(i18n("Import"), CTRL+Key_I, this, SLOT(SLOT_ImportBookmarks()), actionCollection(), "import bookmarks action");
+
+ createGUI();
+}
+
+void Kasablanca::optionsShowToolbar()
+{
+ if (m_toolbarAction->isChecked())
+ toolBar()->show();
+ else
+ toolBar()->hide();
+}
+
+void Kasablanca::optionsShowStatusbar()
+{
+ if (m_statusbarAction->isChecked())
+ statusBar()->show();
+ else
+ statusBar()->hide();
+}
+
+void Kasablanca::optionsConfigureKeys()
+{
+ KKeyDialog::configure(actionCollection(), mp_view);
+}
+
+void Kasablanca::optionsConfigureToolbars()
+{
+ // use the standard toolbar editor
+#if defined(KDE_MAKE_VERSION)
+# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0)
+ saveMainWindowSettings(KGlobal::config(), autoSaveGroup());
+# else
+ saveMainWindowSettings(KGlobal::config());
+# endif
+#else
+ saveMainWindowSettings(KGlobal::config());
+#endif
+}
+
+void Kasablanca::optionsPreferences()
+{
+ if (KConfigDialog::showDialog("settings")) return;
+
+ KConfigDialog* dialog = new KConfigDialog(0, "settings", KbConfig::self(), KDialogBase::IconList,
+ KDialogBase::Ok | KDialogBase::Apply | KDialogBase::Cancel | KDialogBase::Help);
+
+ dialog->setHelp("globalhelp");
+
+ KasablancaGeneralPreferencesDialog *general = new KasablancaGeneralPreferencesDialog(0, i18n("General"));
+ KasablancaColorsPreferencesDialog *colors = new KasablancaColorsPreferencesDialog(0, i18n("Colors"));
+ KasablancaUserInterfacePreferencesDialog *ui = new KasablancaUserInterfacePreferencesDialog(0, i18n("User Interface"));
+ dialog->addPage(general, i18n("General"), "kasablanca");
+ dialog->addPage(colors, i18n("Colors"), "colors");
+ dialog->addPage(ui, i18n("User Interface"), "winprops");
+ connect(dialog, SIGNAL(settingsChanged()), this, SLOT(applyConfig()));
+ dialog->show();
+}
+
+void Kasablanca::newToolbarConfig()
+{
+ // this slot is called when user clicks "Ok" or "Apply" in the toolbar editor.
+ // recreate our GUI, and re-apply the settings (e.g. "text under icons", etc.)
+ createGUI();
+
+#if defined(KDE_MAKE_VERSION)
+# if KDE_VERSION >= KDE_MAKE_VERSION(3,1,0)
+ applyMainWindowSettings(KGlobal::config(), autoSaveGroup());
+# else
+ applyMainWindowSettings(KGlobal::config());
+# endif
+#else
+ applyMainWindowSettings(KGlobal::config());
+#endif
+}
+
+void Kasablanca::setupMenu()
+{
+ QWidget *w;
+ w = factory()->container("connect menu", this);
+ if (w == NULL) qWarning("ERROR: 'connect menu' not found in .ui file");
+ else
+ {
+ QPopupMenu *menu = static_cast<QPopupMenu *>(w);
+ menu->insertItem(i18n("Session A"), &m_bookmarksmenu_a);
+ menu->insertItem(i18n("Session B"), &m_bookmarksmenu_b);
+ }
+ w = factory()->container("action menu", this);
+ if (w == NULL) qWarning("ERROR: 'action menu' not found in .ui file");
+ else
+ {
+ QPopupMenu *menu = static_cast<QPopupMenu *>(w);
+ menu->insertItem(i18n("Session A"), &m_rclickmenu_a);
+ menu->insertItem(i18n("Session B"), &m_rclickmenu_b);
+ menu->insertItem(i18n("Queue"), &m_rclickmenu_t);
+ }
+
+ m_rclickmenu_a.insertItem(i18n("Transfer"), Transfer);
+ m_rclickmenu_a.insertItem(i18n("Put in queue"), Queue);
+ m_rclickmenu_a.insertSeparator();
+ m_rclickmenu_a.insertItem(i18n("Delete"), Delete);
+ m_rclickmenu_a.insertItem(i18n("Rename"), Rename);
+ m_rclickmenu_a.insertItem(i18n("Mkdir"), Mkdir);
+ m_rclickmenu_a.insertSeparator();
+ m_rclickmenu_a.insertItem(i18n("Bookmark site"), Bookmark);
+
+ m_rclickmenu_b.insertItem(i18n("Transfer"), Transfer);
+ m_rclickmenu_b.insertItem(i18n("Put in queue"), Queue);
+ m_rclickmenu_b.insertSeparator();
+ m_rclickmenu_b.insertItem(i18n("Delete"), Delete);
+ m_rclickmenu_b.insertItem(i18n("Rename"), Rename);
+ m_rclickmenu_b.insertItem(i18n("Mkdir"), Mkdir);
+ m_rclickmenu_b.insertSeparator();
+ m_rclickmenu_b.insertItem(i18n("Bookmark site"), Bookmark);
+
+ m_rclickmenu_t.insertItem(i18n("Start Queue"), Start);
+ m_rclickmenu_t.insertSeparator();
+ m_rclickmenu_t.insertItem(i18n("Skip Item(s)"), Skip);
+
+ connect(&m_rclickmenu_a, SIGNAL(activated(int)), mp_session_a, SLOT(SLOT_ActionMenu(int)));
+ connect(&m_bookmarksmenu_a, SIGNAL(activated(int)), mp_session_a, SLOT(SLOT_ConnectMenu(int)));
+ connect(mp_view->BrowserA, SIGNAL(doubleClicked(QListViewItem*)), mp_session_a, SLOT(SLOT_ItemClicked(QListViewItem*)));
+ connect(mp_view->BrowserA, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)),
+ mp_session_a, SLOT(SLOT_ItemRClicked(QListViewItem *, const QPoint &, int)));
+ connect(mp_view->BrowserA->header(), SIGNAL (clicked(int)), mp_session_a, SLOT (SLOT_HeaderClicked(int)));
+
+ connect(&m_rclickmenu_b, SIGNAL(activated(int)), mp_session_b, SLOT(SLOT_ActionMenu(int)));
+ connect(&m_bookmarksmenu_b, SIGNAL(activated(int)), mp_session_b, SLOT(SLOT_ConnectMenu(int)));
+ connect(mp_view->BrowserB, SIGNAL(doubleClicked(QListViewItem*)), mp_session_b, SLOT(SLOT_ItemClicked(QListViewItem*)));
+ connect(mp_view->BrowserB, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)),
+ mp_session_b, SLOT(SLOT_ItemRClicked(QListViewItem *, const QPoint &, int)));
+ connect(mp_view->BrowserB->header(), SIGNAL(clicked(int)), mp_session_b, SLOT(SLOT_HeaderClicked(int)));
+
+ connect( mp_view->TaskView, SIGNAL (rightButtonPressed( QListViewItem *, const QPoint &, int )), this,
+ SLOT (SLOT_ItemRightClickedT(QListViewItem *, const QPoint &, int )));
+
+ m_rclickmenu_t.connectItem(Start, this, SLOT(SLOT_ProcessQueue()));
+ m_rclickmenu_t.connectItem(Skip, this, SLOT(SLOT_SkipTasks()));
+}
+
+void Kasablanca::setupStatusBar()
+{
+ m_iconencrypted = KGlobal::iconLoader()->loadIconSet("encrypted",KIcon::Small).pixmap(QIconSet::Small,QIconSet::Normal);
+ m_iconunencrypted = KGlobal::iconLoader()->loadIconSet("encrypted",KIcon::Small).pixmap(QIconSet::Small,QIconSet::Disabled);
+
+ mp_statusline_a = new QLabel("", statusBar());
+ mp_encryptionicon_a = new QLabel(statusBar());
+ mp_encryptionicon_a->setPixmap(m_iconunencrypted);
+
+ mp_statusline_b = new QLabel("", statusBar());
+ mp_encryptionicon_b = new QLabel(statusBar());
+ mp_encryptionicon_b->setPixmap(m_iconunencrypted);
+
+ statusBar()->addWidget(mp_statusline_a, 1);
+ statusBar()->addWidget(mp_encryptionicon_a, 0);
+ statusBar()->addWidget(mp_statusline_b, 1, true);
+ statusBar()->addWidget(mp_encryptionicon_b, 0, true);
+}
+
+Kasablanca::~Kasablanca()
+{
+}
+
+void Kasablanca::InitBookmarks()
+{
+ int count;
+ m_bookmarks.clear();
+ m_bookmarks = KbSiteInfo::ParseBookmarks();
+
+ m_bookmarksmenu_a.clear();
+ m_bookmarksmenu_b.clear();
+
+ m_bookmarksmenu_a.insertItem(i18n("Custom"),0);
+ m_bookmarksmenu_b.insertItem(i18n("Custom"),0);
+ count = 1;
+
+ m_bookmarksmenu_a.insertSeparator();
+ m_bookmarksmenu_b.insertSeparator();
+
+ list<KbSiteInfo>::iterator end_bookmarks = m_bookmarks.end();
+ for (list<KbSiteInfo>::iterator i = m_bookmarks.begin(); i != end_bookmarks; i++)
+ {
+ m_bookmarksmenu_a.insertItem((*i).GetName(),count);
+ m_bookmarksmenu_b.insertItem((*i).GetName(),count);
+ count++;
+ }
+}
+
+void Kasablanca::SLOT_QueueItems(KbDirInfo *dir, FtpSession* src, FtpSession* dst, bool startqueue)
+{
+ QueueItemsRecurse(dir, src, dst);
+ if ((mp_view->TaskView->firstChild()) && (startqueue))
+ {
+ if (!src->Connected()) ProcessQueue(static_cast<KbTransferItem*>(mp_view->TaskView->firstChild()));
+ else static_cast<KbTransferItem*>(mp_view->TaskView->firstChild())->Init();
+ }
+}
+
+void Kasablanca::QueueItemsRecurse(KbDirInfo *dir, FtpSession* src, FtpSession* dst, QListViewItem* parent)
+{
+ list<KbFileInfo*>* filelist;
+ list<KbDirInfo*>* dirlist;
+ QListViewItem *after, *lastchild;
+
+ filelist = dir->Filelist();
+ dirlist = dir->Dirlist();
+
+ if (KbConfig::prioritylistIsEnabled())
+ {
+ dirlist->sort(KbDirInfo::PrioritySort);
+ filelist->sort(KbFileInfo::PrioritySort);
+ }
+
+ lastchild = mp_view->TaskView->LastChild();
+
+ after = NULL;
+ list<KbFileInfo*>::iterator end_file = filelist->end();
+ for(list<KbFileInfo*>::iterator fileIterator = filelist->begin(); fileIterator != end_file; fileIterator++)
+ {
+ if ((m_skiplist.search((*fileIterator)->fileName()) < 0) || (!m_skiplistenabled))
+ {
+ KbFileInfo *srcfi = new KbFileInfo(**fileIterator);
+ KbFileInfo *dstfi = new KbFileInfo(**fileIterator);
+ srcfi->SetDirPath(src->WorkingDir() + srcfi->dirPath());
+ dstfi->SetDirPath(dst->WorkingDir() + dstfi->dirPath());
+ if (parent) after = new KbTransferFile(parent, after, src, dst, srcfi, dstfi);
+ else new KbTransferFile(mp_view->TaskView, lastchild /*mp_view->TaskView->lastItem()*/, src, dst, srcfi, dstfi);
+ }
+ else qWarning("INFO: entry ignored due to matched skiplist regexp");
+ }
+
+ after = NULL;
+ list<KbDirInfo*>::iterator end_dir = dirlist->end();
+ for(list<KbDirInfo*>::iterator dirIterator = dirlist->begin(); dirIterator != end_dir; dirIterator++)
+ {
+ if ((m_skiplist.search((*dirIterator)->fileName()) < 0) || (!m_skiplistenabled))
+ {
+ KbFileInfo *srcfi = new KbFileInfo(*(*dirIterator));
+ KbFileInfo *dstfi = new KbFileInfo(*(*dirIterator));
+ srcfi->SetDirPath(src->WorkingDir() + srcfi->dirPath());
+ dstfi->SetDirPath(dst->WorkingDir() + dstfi->dirPath());
+ if (parent) after = new KbTransferDir(parent, after, src, dst, srcfi, dstfi);
+ else after = new KbTransferDir(mp_view->TaskView, lastchild /*mp_view->TaskView->lastItem()*/, src, dst, srcfi, dstfi);
+ QueueItemsRecurse(*dirIterator, src, dst, after);
+ }
+ else qWarning("INFO: entry ignored due to matched skiplist regexp");
+ }
+ delete dir;
+}
+
+void Kasablanca::SLOT_EditBookmarks()
+{
+ BookmarkDialog dlg;
+
+ if (dlg.exec() == QDialog::Accepted)
+ {
+ InitBookmarks();
+ }
+}
+
+void Kasablanca::SLOT_ImportBookmarks()
+{
+ ImportDialog dlg;
+ dlg.exec();
+
+ int cnt=0;
+ list<KbSiteInfo> newbookmarklist;
+
+ list<KbSiteInfo>::iterator end_session = dlg.Bookmarks()->end();
+ for (list<KbSiteInfo>::iterator i = dlg.Bookmarks()->begin(); i != end_session; i++)
+ {
+ m_bookmarks.push_back( *i );
+ cnt++;
+ }
+ KbSiteInfo::WriteBookmarks(m_bookmarks);
+}
+
+void Kasablanca::SLOT_ClearQueue(FtpSession*)
+{
+ mp_view->TaskView->clear();
+}
+
+void Kasablanca::SLOT_ItemRightClickedT(QListViewItem *, const QPoint & point, int)
+{
+ m_rclickmenu_t.exec(point);
+}
+
+void Kasablanca::SLOT_SkipTasks()
+{
+ QListViewItemIterator it(mp_view->TaskView);
+ while ( it.current() )
+ {
+ if (it.current()->isSelected()) delete it.current();
+ else ++it;
+ }
+}
+
+void Kasablanca::SLOT_SelectionChanged()
+{
+ int counter_a = 0;
+ int counter_b = 0;
+ bool flag;
+
+ QListViewItemIterator ita(mp_view->BrowserA);
+ while ( ita.current() )
+ {
+ if (ita.current()->isSelected()) counter_a++;
+ ++ita;
+ }
+
+ flag = ((counter_a) && (!mp_session_a->Occupied()) && (!mp_session_b->Occupied()));
+
+ m_rclickmenu_a.setItemEnabled(Transfer, flag);
+ m_rclickmenu_a.setItemEnabled(Queue, flag);
+ mp_view->TransferButtonA->setEnabled(flag);
+
+ /* when at least one item is selected, Delete and Rename are
+ enabled. */
+
+ m_rclickmenu_a.setItemEnabled(Rename, (counter_a >= 1));
+ m_rclickmenu_a.setItemEnabled(Delete, (counter_a >= 1));
+
+ QListViewItemIterator itb(mp_view->BrowserB);
+ while ( itb.current() )
+ {
+ if (itb.current()->isSelected()) counter_b++;
+ ++itb;
+ }
+
+ flag = ((counter_b) && (!mp_session_a->Occupied()) && (!mp_session_b->Occupied()));
+
+ m_rclickmenu_b.setItemEnabled(Transfer, flag);
+ m_rclickmenu_b.setItemEnabled(Queue, flag);
+ mp_view->TransferButtonB->setEnabled(flag);
+
+ /* when at least one item is selected, Delete and Rename are
+ enabled. */
+
+ m_rclickmenu_b.setItemEnabled(Rename, (counter_b >= 1));
+ m_rclickmenu_b.setItemEnabled(Delete, (counter_b >= 1));
+}
+
+void Kasablanca::SLOT_NextTransfer(QListViewItem* item)
+{
+ QListViewItem *next;
+ next = NextTransfer(item);
+ if (next) ProcessQueue(static_cast<KbTransferItem*>(next));
+ else QueueFinished();
+}
+
+void Kasablanca::QueueFinished()
+{
+ if (m_onqueuefinishedenabled)
+ {
+ KProcess* p = new KProcess();
+ *p << QStringList::split(" ", m_onqueuefinished);
+ connect(p, SIGNAL(processExited(KProcess*)), SLOT(SLOT_LocalProcessExited(KProcess*)));
+ p->start();
+ }
+ if (KbConfig::systrayIsEnabled()) KPassivePopup::message("Transfer is finished.", mp_systemtray);
+ //QToolTip::remove(mp_systemtray);
+}
+
+QListViewItem* Kasablanca::NextTransfer(QListViewItem* item)
+{
+ FtpSession *src, *dst;
+ QListViewItem *parent, *next, *retval;
+ src = static_cast<KbTransferItem*>(item)->SrcSession();
+ dst = static_cast<KbTransferItem*>(item)->DstSession();
+ next = item->nextSibling();
+ parent = item->parent();
+ retval = NULL;
+ if (item->childCount() == 0) // if the item contains no subelements - delete it, if it doesn't - start with the next
+ {
+ static_cast<KbTransferItem*>(item)->Finish();
+ if (mp_view->TaskView->childCount() > 0) delete item;
+ if (next) retval = next;
+ else if (parent) retval = NextTransfer(parent);
+ else
+ {
+ src->SLOT_RefreshButton();
+ dst->SLOT_RefreshButton();
+ }
+ }
+ else retval = item->firstChild();
+
+ return retval;
+}
+
+void Kasablanca::SLOT_ProcessQueue()
+{
+ KbTransferItem *ti = static_cast<KbTransferItem*>(mp_view->TaskView->firstChild());
+ if (ti) ProcessQueue(ti);
+}
+
+void Kasablanca::ProcessQueue(KbTransferItem* item)
+{
+ FtpSession *srcsession = item->SrcSession();
+ srcsession->Transfer(item);
+}
+
diff --git a/src/kasablanca.desktop b/src/kasablanca.desktop
new file mode 100644
index 0000000..a61be14
--- /dev/null
+++ b/src/kasablanca.desktop
@@ -0,0 +1,26 @@
+[Desktop Entry]
+Encoding=UTF-8
+Name=kasablanca
+Name[xx]=xxkasablancaxx
+Exec=kasablanca
+Icon=kasablanca
+Type=Application
+Comment=A simple KDE Application
+Comment[ca]=Una simple aplicació KDE
+Comment[da]=Et simpelt KDE program
+Comment[de]=Eine einfache KDE-Anwendung
+Comment[el]=Μια απλή εφαρμογή του KDE
+Comment[es]=Una aplicación de KDE sencilla
+Comment[et]=Lihtne KDE rakendus
+Comment[fr]=Une application simple pour KDE.
+Comment[hu]=Egyszerű KDE-alkalmazás
+Comment[it]=Una semplice applicazione KDE
+Comment[nl]=Een eenvoudige KDE-toepassing
+Comment[pt]=Uma aplicação KDE simples
+Comment[pt_BR]=Um simples Aplicativo do KDE
+Comment[ru]=Простое приложение KDE
+Comment[sl]=Preprost program za KDE
+Comment[sr]=Једноставан KDE програм
+Comment[sv]=Ett enkelt KDE-program
+Comment[xx]=xxA simple KDE Applicationxx
+Comment[zh_CN]=一个简单的KDE应用程序
diff --git a/src/kasablanca.h b/src/kasablanca.h
new file mode 100644
index 0000000..3d297d3
--- /dev/null
+++ b/src/kasablanca.h
@@ -0,0 +1,130 @@
+/***************************************************************************
+ kasablanca.h - description
+ -------------------
+ begin : Die Aug 19 20:54:14 CEST 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef KASABLANCA_H
+#define KASABLANCA_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+class KbDir;
+class KbFile;
+class KToggleAction;
+class KSystemTray;
+class QWidget;
+class QCloseEvent;
+class QLabel;
+class QPixmap;
+class FtpSession;
+class KbStatusTip;
+
+#include <kapplication.h>
+#include <klistview.h>
+#include <kmainwindow.h>
+#include <kprocess.h>
+
+#include <qdir.h>
+#include <qlistview.h>
+#include <qmenubar.h>
+#include <qregexp.h>
+
+#include <list>
+
+#include "kbsiteinfo.h"
+#include "kbtransferitem.h"
+#include "Q_mainwindow.h"
+
+using namespace std;
+
+/** Kasablanca is the base class of the project */
+
+class Kasablanca : public KMainWindow
+{
+ Q_OBJECT
+public:
+ enum RightClickMenu
+ {
+ Transfer = 1001,
+ Queue,
+ Delete,
+ Rename,
+ Mkdir,
+ Start,
+ Skip,
+ Bookmark
+ };
+
+ Kasablanca();
+ ~Kasablanca();
+
+ QString m_tempdirname;
+ QString m_version;
+ list<KbSiteInfo> m_bookmarks;
+ KSystemTray* systemTray() const { return mp_systemtray; }
+ KbStatusTip* statusTip() const { return mp_statustip; }
+ void InitBookmarks();
+
+public slots:
+ void SLOT_EditBookmarks();
+ void SLOT_ImportBookmarks();
+ void SLOT_ItemRightClickedT(QListViewItem * item, const QPoint & point, int col );
+ void SLOT_SelectionChanged();
+ void SLOT_SkipTasks();
+ void SLOT_ProcessQueue();
+ void SLOT_QueueItems(KbDirInfo *dir, FtpSession* src, FtpSession* dst, bool startqueue);
+ void SLOT_NextTransfer(QListViewItem* item);
+ void SLOT_ClearQueue(FtpSession* session);
+ void SLOT_LocalProcessExited(KProcess* proc) { delete proc; };
+
+private slots:
+ void optionsShowToolbar();
+ void optionsShowStatusbar();
+ void optionsConfigureKeys();
+ void optionsConfigureToolbars();
+ void optionsPreferences();
+ void newToolbarConfig();
+ void applyConfig();
+
+private:
+ void QueueItemsRecurse(KbDirInfo *dir, FtpSession* src, FtpSession* dst, QListViewItem* parent = NULL);
+ void setupStatusBar();
+ void setupMenu();
+ void setupGUI();
+ void setupActions();
+ void saveSettings();
+ void ProcessQueue(KbTransferItem* item);
+ QListViewItem* NextTransfer(QListViewItem* item);
+ void QueueFinished();
+
+ KasablancaMainWindow *mp_view;
+ QPopupMenu m_bookmarksmenu_a, m_bookmarksmenu_b;
+ QRegExp m_skiplist;
+ QPopupMenu m_rclickmenu_a, m_rclickmenu_b, m_rclickmenu_t;
+ QLabel *mp_statusline_a, *mp_statusline_b, *mp_encryptionicon_a, *mp_encryptionicon_b;
+ QPixmap m_iconencrypted, m_iconunencrypted;
+ KToggleAction *m_toolbarAction;
+ KToggleAction *m_statusbarAction;
+ FtpSession *mp_session_a, *mp_session_b;
+ list<FtpSession*> *mp_sessionlist;
+ bool m_skiplistenabled, m_onqueuefinishedenabled;
+ QString m_onqueuefinished;
+ KSystemTray* mp_systemtray;
+ KbStatusTip *mp_statustip;
+};
+
+#endif
diff --git a/src/kasablanca.lsm b/src/kasablanca.lsm
new file mode 100644
index 0000000..1862322
--- /dev/null
+++ b/src/kasablanca.lsm
@@ -0,0 +1,16 @@
+Begin3
+Title: kasablanca -- Some description
+Version: 0.3
+Entered-date:
+Description:
+Keywords: KDE Qt
+Author: Magnus Kulke <mkulke@magnusmachine>
+Maintained-by: Magnus Kulke <mkulke@magnusmachine>
+Home-page:
+Alternate-site:
+Primary-site: ftp://ftp.kde.org/pub/kde/unstable/apps/utils
+ xxxxxx kasablanca-0.3.tar.gz
+ xxx kasablanca-0.3.lsm
+Platform: Linux. Needs KDE
+Copying-policy: GPL
+End
diff --git a/src/kasablancaui.rc b/src/kasablancaui.rc
new file mode 100644
index 0000000..bacd962
--- /dev/null
+++ b/src/kasablancaui.rc
@@ -0,0 +1,13 @@
+<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
+<kpartgui name="kasablanca" version="1">
+<MenuBar>
+<Menu name="bookmarks menu"><text>Bookmarks</text>
+ <Action name="edit bookmarks action" />
+ <Action name="import bookmarks action" />
+</Menu>
+<Menu name="connect menu"><text>Connect</text>
+</Menu>
+<Menu name="action menu"><text>Action</text>
+</Menu>
+</MenuBar>
+</kpartgui>
diff --git a/src/kbbookmarkitem.cpp b/src/kbbookmarkitem.cpp
new file mode 100644
index 0000000..4181b39
--- /dev/null
+++ b/src/kbbookmarkitem.cpp
@@ -0,0 +1,26 @@
+//
+// C++ Implementation: kbbookmarkitem
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#include "kbbookmarkitem.h"
+#include "kbsiteinfo.h"
+
+KbBookmarkItem::KbBookmarkItem(QListView *view, QListViewItem *after, KbSiteInfo *site) : QListViewItem(view, after)
+{
+ mp_siteinfo = site;
+ setText(0, mp_siteinfo->GetName());
+}
+
+
+KbBookmarkItem::~KbBookmarkItem()
+{
+}
+
+
diff --git a/src/kbbookmarkitem.h b/src/kbbookmarkitem.h
new file mode 100644
index 0000000..491c6d7
--- /dev/null
+++ b/src/kbbookmarkitem.h
@@ -0,0 +1,33 @@
+//
+// C++ Interface: kbbookmarkitem
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBBOOKMARKITEM_H
+#define KBBOOKMARKITEM_H
+
+#include <qlistview.h>
+
+class KbSiteInfo;
+
+/**
+@author Magnus Kulke
+*/
+class KbBookmarkItem : public QListViewItem
+{
+public:
+ KbBookmarkItem(QListView *view, QListViewItem *after, KbSiteInfo *site);
+ ~KbBookmarkItem();
+ KbSiteInfo* GetSiteInfo() { return mp_siteinfo; };
+private:
+ KbSiteInfo* mp_siteinfo;
+
+};
+
+#endif
diff --git a/src/kbconfig.cpp b/src/kbconfig.cpp
new file mode 100644
index 0000000..f945d40
--- /dev/null
+++ b/src/kbconfig.cpp
@@ -0,0 +1,100 @@
+// This file is generated by kconfig_compiler from kbconfig.kcfg.
+// All changes you do to this file will be lost.
+
+#include "kbconfig.h"
+
+#include <kstaticdeleter.h>
+
+KbConfig *KbConfig::mSelf = 0;
+static KStaticDeleter<KbConfig> staticKbConfigDeleter;
+
+KbConfig *KbConfig::self()
+{
+ if ( !mSelf ) {
+ staticKbConfigDeleter.setObject( mSelf, new KbConfig() );
+ mSelf->readConfig();
+ }
+
+ return mSelf;
+}
+
+KbConfig::KbConfig( )
+ : KConfigSkeleton( QString::fromLatin1( "kasablancarc" ) )
+{
+ mSelf = this;
+ setCurrentGroup( QString::fromLatin1( "general" ) );
+
+ KConfigSkeleton::ItemString *itemSkiplist;
+ itemSkiplist = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "Skiplist" ), mSkiplist );
+ addItem( itemSkiplist, QString::fromLatin1( "Skiplist" ) );
+ KConfigSkeleton::ItemString *itemPrioritylist;
+ itemPrioritylist = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "Prioritylist" ), mPrioritylist );
+ addItem( itemPrioritylist, QString::fromLatin1( "Prioritylist" ) );
+ KConfigSkeleton::ItemBool *itemDirCachingIsEnabled;
+ itemDirCachingIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "DirCachingIsEnabled" ), mDirCachingIsEnabled, false );
+ addItem( itemDirCachingIsEnabled, QString::fromLatin1( "DirCachingIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemDeleteMovesIntoTrashIsEnabled;
+ itemDeleteMovesIntoTrashIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "DeleteMovesIntoTrashIsEnabled" ), mDeleteMovesIntoTrashIsEnabled, false );
+ addItem( itemDeleteMovesIntoTrashIsEnabled, QString::fromLatin1( "DeleteMovesIntoTrashIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemSkiplistIsEnabled;
+ itemSkiplistIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "SkiplistIsEnabled" ), mSkiplistIsEnabled, false );
+ addItem( itemSkiplistIsEnabled, QString::fromLatin1( "SkiplistIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemPrioritylistIsEnabled;
+ itemPrioritylistIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "PrioritylistIsEnabled" ), mPrioritylistIsEnabled, false );
+ addItem( itemPrioritylistIsEnabled, QString::fromLatin1( "PrioritylistIsEnabled" ) );
+ KConfigSkeleton::ItemString *itemOnQueueFinished;
+ itemOnQueueFinished = new KConfigSkeleton::ItemString( currentGroup(), QString::fromLatin1( "OnQueueFinished" ), mOnQueueFinished );
+ addItem( itemOnQueueFinished, QString::fromLatin1( "OnQueueFinished" ) );
+ KConfigSkeleton::ItemBool *itemOnQueueFinishedIsEnabled;
+ itemOnQueueFinishedIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OnQueueFinishedIsEnabled" ), mOnQueueFinishedIsEnabled, false );
+ addItem( itemOnQueueFinishedIsEnabled, QString::fromLatin1( "OnQueueFinishedIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemOnFileExistsOverwrite;
+ itemOnFileExistsOverwrite = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OnFileExistsOverwrite" ), mOnFileExistsOverwrite, false );
+ addItem( itemOnFileExistsOverwrite, QString::fromLatin1( "OnFileExistsOverwrite" ) );
+ KConfigSkeleton::ItemBool *itemOnFileExistsResume;
+ itemOnFileExistsResume = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OnFileExistsResume" ), mOnFileExistsResume, true );
+ addItem( itemOnFileExistsResume, QString::fromLatin1( "OnFileExistsResume" ) );
+ KConfigSkeleton::ItemBool *itemOnFileExistsSkip;
+ itemOnFileExistsSkip = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OnFileExistsSkip" ), mOnFileExistsSkip, false );
+ addItem( itemOnFileExistsSkip, QString::fromLatin1( "OnFileExistsSkip" ) );
+ KConfigSkeleton::ItemBool *itemOnFileExistsIsEnabled;
+ itemOnFileExistsIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "OnFileExistsIsEnabled" ), mOnFileExistsIsEnabled, false );
+ addItem( itemOnFileExistsIsEnabled, QString::fromLatin1( "OnFileExistsIsEnabled" ) );
+
+ setCurrentGroup( QString::fromLatin1( "ui" ) );
+
+ KConfigSkeleton::ItemBool *itemSystrayIsEnabled;
+ itemSystrayIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "SystrayIsEnabled" ), mSystrayIsEnabled, false );
+ addItem( itemSystrayIsEnabled, QString::fromLatin1( "SystrayIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemCommandLineIsEnabled;
+ itemCommandLineIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "CommandLineIsEnabled" ), mCommandLineIsEnabled, true );
+ addItem( itemCommandLineIsEnabled, QString::fromLatin1( "CommandLineIsEnabled" ) );
+ KConfigSkeleton::ItemBool *itemHideHiddenFilesIsEnabled;
+ itemHideHiddenFilesIsEnabled = new KConfigSkeleton::ItemBool( currentGroup(), QString::fromLatin1( "HideHiddenFilesIsEnabled" ), mHideHiddenFilesIsEnabled, false );
+ addItem( itemHideHiddenFilesIsEnabled, QString::fromLatin1( "HideHiddenFilesIsEnabled" ) );
+ KConfigSkeleton::ItemFont *itemLogwindowFont;
+ itemLogwindowFont = new KConfigSkeleton::ItemFont( currentGroup(), QString::fromLatin1( "LogwindowFont" ), mLogwindowFont, QFont( "DEC Terminal" ) );
+ addItem( itemLogwindowFont, QString::fromLatin1( "LogwindowFont" ) );
+
+ setCurrentGroup( QString::fromLatin1( "colors" ) );
+
+ KConfigSkeleton::ItemColor *itemLocalColor;
+ itemLocalColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "LocalColor" ), mLocalColor, QColor( 244,247,66 ) );
+ addItem( itemLocalColor, QString::fromLatin1( "LocalColor" ) );
+ KConfigSkeleton::ItemColor *itemSuccessColor;
+ itemSuccessColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "SuccessColor" ), mSuccessColor, QColor( 0,188,53 ) );
+ addItem( itemSuccessColor, QString::fromLatin1( "SuccessColor" ) );
+ KConfigSkeleton::ItemColor *itemBackgroundColor;
+ itemBackgroundColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "BackgroundColor" ), mBackgroundColor, QColor( 0,90,128 ) );
+ addItem( itemBackgroundColor, QString::fromLatin1( "BackgroundColor" ) );
+ KConfigSkeleton::ItemColor *itemFailureColor;
+ itemFailureColor = new KConfigSkeleton::ItemColor( currentGroup(), QString::fromLatin1( "FailureColor" ), mFailureColor, QColor( 222,9,48 ) );
+ addItem( itemFailureColor, QString::fromLatin1( "FailureColor" ) );
+}
+
+KbConfig::~KbConfig()
+{
+ if ( mSelf == this )
+ staticKbConfigDeleter.setObject( mSelf, 0, false );
+}
+
diff --git a/src/kbconfig.kcfg b/src/kbconfig.kcfg
new file mode 100644
index 0000000..c74b3be
--- /dev/null
+++ b/src/kbconfig.kcfg
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
+<kcfg> <kcfgfile name="kasablancarc"/>
+ <group name="general">
+ <entry name="Skiplist" type="String">
+ <label>A RegExp which describes the items to skip at transfer.</label>
+ </entry>
+ <entry name="Prioritylist" type="String">
+ <label>A RegExp which describes the items to transfer first.</label>
+ </entry>
+ <entry name="DirCachingIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="DeleteMovesIntoTrashIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="SkiplistIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="PrioritylistIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="OnQueueFinished" type="String"/>
+ <entry name="OnQueueFinishedIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="OnFileExistsOverwrite" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="OnFileExistsResume" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="OnFileExistsSkip" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="OnFileExistsIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ </group>
+ <group name="ui">
+ <entry name="SystrayIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="CommandLineIsEnabled" type="Bool">
+ <default>true</default>
+ </entry>
+ <entry name="HideHiddenFilesIsEnabled" type="Bool">
+ <default>false</default>
+ </entry>
+ <entry name="LogwindowFont" type="Font">
+ <label>The font for the logwindow.</label>
+ <default>QFont( "DEC Terminal" )</default>
+ </entry>
+ </group>
+ <group name="colors">
+ <entry name="LocalColor" type="Color">
+ <label>The color value for local messages on the logging window.</label>
+ <default>244,247,66</default>
+ </entry>
+ <entry name="SuccessColor" type="Color">
+ <label>The color value for successful remote messages on the logging window.</label>
+ <default>0,188,53</default>
+ </entry>
+ <entry name="BackgroundColor" type="Color">
+ <label>The color value for the background on the logging window.</label>
+ <default>0,90,128</default>
+ </entry>
+ <entry name="FailureColor" type="Color">
+ <label>The color value for failed remote messages on the logging window.</label>
+ <default>222,9,48</default>
+ </entry>
+ </group>
+</kcfg> \ No newline at end of file
diff --git a/src/kbconfig.kcfgc b/src/kbconfig.kcfgc
new file mode 100644
index 0000000..e028322
--- /dev/null
+++ b/src/kbconfig.kcfgc
@@ -0,0 +1,4 @@
+File=kbconfig.kcfg
+ClassName=KbConfig
+Singleton=true
+Mutators=true
diff --git a/src/kbdir.cpp b/src/kbdir.cpp
new file mode 100755
index 0000000..bbb9716
--- /dev/null
+++ b/src/kbdir.cpp
@@ -0,0 +1,60 @@
+/***************************************************************************
+ kbdir.cpp - description
+ -------------------
+ begin : Sam Sep 20 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include "kbfileinfo.h"
+
+#include "kbdir.h"
+
+KbDir::KbDir(KbFileInfo kfi, QListView * parent, QListViewItem * after) : KbItem(kfi, parent, after)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("folder",KIcon::Small));
+
+ if ((kfi.fileName() == ".") || (kfi.fileName() == "..")) delete this;
+}
+
+KbDir::KbDir(QListView * parent, QListViewItem * after, QString file, QString path, QString date, off64_t size, unsigned int date_int) : KbItem(parent, after)
+{
+ setText(0,file);
+
+ QString s;
+ s.setNum(size);
+ setText(1, s);
+
+ setText(2, date);
+
+ m_path = path;
+ m_file = file;
+ m_date = date;
+ m_size = size;
+
+ m_date_int = date_int;
+}
+KbDir::~KbDir()
+{
+}
+
+int KbDir::rtti() const
+{
+ return KbItem::dir;
+}
diff --git a/src/kbdir.h b/src/kbdir.h
new file mode 100755
index 0000000..17fc3b1
--- /dev/null
+++ b/src/kbdir.h
@@ -0,0 +1,36 @@
+/***************************************************************************
+ kbdir.h - description
+ -------------------
+ begin : Sam Sep 20 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef DIRITEM_H
+#define DIRITEM_H
+
+#include "kbitem.h"
+#include <qlistview.h>
+
+/**
+ *@author mkulke
+ */
+
+class KbDir : public KbItem {
+public:
+ KbDir(KbFileInfo kfi, QListView * parent, QListViewItem * after);
+ KbDir(QListView * parent, QListViewItem * after, QString file, QString path, QString date, off64_t size, unsigned int date_int);
+ ~KbDir();
+ int rtti() const;
+};
+
+#endif
diff --git a/src/kbdirinfo.cpp b/src/kbdirinfo.cpp
new file mode 100644
index 0000000..8f913d2
--- /dev/null
+++ b/src/kbdirinfo.cpp
@@ -0,0 +1,53 @@
+//
+// C++ Implementation: kbdirinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <qregexp.h>
+
+#include <list>
+
+#include "kbconfig.h"
+#include "kbdirinfo.h"
+
+using namespace std;
+
+KbDirInfo::KbDirInfo(KbFileInfo info) : KbFileInfo(info)
+{
+}
+
+KbDirInfo::KbDirInfo(QString path) : KbFileInfo(path)
+{
+}
+
+KbDirInfo::~KbDirInfo()
+{
+}
+
+bool KbDirInfo::PrioritySort(const KbDirInfo *f1, const KbDirInfo *f2)
+{
+ QRegExp m_prioritylist(KbConfig::prioritylist());
+
+ if ((m_prioritylist.search(f1->fileName()) >= 0) > (m_prioritylist.search(f2->fileName()) >= 0)) return true;
+ else return false;
+}
+
+KbDirInfo* KbDirInfo::AddDirectory(KbFileInfo info)
+{
+ if ((info.fileName() == ".") || (info.fileName() == "..")) return NULL;
+ KbDirInfo* dir = new KbDirInfo(info);
+ m_dirlist.push_back(dir);
+ return dir;
+}
+
+void KbDirInfo::AddFile(KbFileInfo* file)
+{
+ m_filelist.push_back(file);
+}
diff --git a/src/kbdirinfo.h b/src/kbdirinfo.h
new file mode 100644
index 0000000..0c97e40
--- /dev/null
+++ b/src/kbdirinfo.h
@@ -0,0 +1,41 @@
+//
+// C++ Interface: kbdirinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBDIRINFO_H
+#define KBDIRINFO_H
+
+#include <list>
+
+#include "kbfileinfo.h"
+
+using namespace std;
+
+/**
+@author Magnus Kulke
+*/
+class KbDirInfo : public KbFileInfo
+{
+public:
+ KbDirInfo(QString path);
+ KbDirInfo(KbFileInfo info);
+ ~KbDirInfo();
+ KbDirInfo* AddDirectory(KbFileInfo info);
+ void AddFile(KbFileInfo* info);
+ static bool PrioritySort(const KbDirInfo *f1, const KbDirInfo *f2);
+private:
+ list<KbFileInfo*> m_filelist;
+ list<KbDirInfo*> m_dirlist;
+public:
+ list<KbDirInfo*>* Dirlist() { return &m_dirlist; }
+ list<KbFileInfo*>* Filelist() { return &m_filelist; }
+};
+
+#endif
diff --git a/src/kbfile.cpp b/src/kbfile.cpp
new file mode 100755
index 0000000..39d4095
--- /dev/null
+++ b/src/kbfile.cpp
@@ -0,0 +1,59 @@
+/***************************************************************************
+ kbfile.cpp - description
+ -------------------
+ begin : Die Sep 23 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include "kbfileinfo.h"
+
+#include "kbfile.h"
+
+KbFile::KbFile(KbFileInfo kfi, QListView * parent, QListViewItem * after) : KbItem(kfi, parent, after)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("files",KIcon::Small));
+}
+
+KbFile::KbFile(QListView * parent, QListViewItem * after, QString file, QString path, QString date, off64_t size, unsigned int date_int) : KbItem(parent, after)
+{
+ setText(0,file);
+
+ QString s;
+ s.setNum(size);
+ setText(1, s);
+
+ setText(2, date);
+
+ m_path = path;
+ m_file = file;
+ m_date = date;
+ m_size = size;
+
+ m_date_int = date_int;
+}
+
+KbFile::~KbFile()
+{
+}
+
+int KbFile::rtti() const
+{
+ return KbItem::file;
+}
diff --git a/src/kbfile.h b/src/kbfile.h
new file mode 100755
index 0000000..2c53ab3
--- /dev/null
+++ b/src/kbfile.h
@@ -0,0 +1,38 @@
+/***************************************************************************
+ kbfile.h - description
+ -------------------
+ begin : Die Sep 23 2003
+ copyright : (C) 2003 by mkulke
+ email : sikor_sxe@radicalapproach.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. *
+ * *
+ ***************************************************************************/
+
+#ifndef FILEITEM_H
+#define FILEITEM_H
+
+#include <qlistview.h>
+#include "kbitem.h"
+
+class KbFileInfo;
+
+/**
+ *@author mkulke
+ */
+
+class KbFile : public KbItem {
+public:
+ KbFile(KbFileInfo kfi, QListView * parent, QListViewItem * after);
+ KbFile(QListView * parent, QListViewItem * after, QString file, QString path, QString date, off64_t size, unsigned int date_int);
+ ~KbFile();
+ int rtti() const;
+};
+
+#endif
diff --git a/src/kbfileinfo.cpp b/src/kbfileinfo.cpp
new file mode 100644
index 0000000..46fe553
--- /dev/null
+++ b/src/kbfileinfo.cpp
@@ -0,0 +1,85 @@
+//
+// C++ Implementation: kbfileinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <qregexp.h>
+#include <qdir.h>
+
+#include "kbconfig.h"
+#include "kbitem.h"
+
+#include "kbfileinfo.h"
+
+/*KbFileInfo::KbFileInfo() : QFileInfo()
+{
+
+}*/
+
+KbFileInfo::KbFileInfo(QString workingdir) : QFileInfo(QDir(workingdir), ".")
+{
+
+}
+
+bool KbFileInfo::PrioritySort(KbFileInfo *f1, KbFileInfo *f2)
+//bool KbFileInfo::PrioritySort(const KbFileInfo &f1, const KbFileInfo &f2)
+{
+ QRegExp m_prioritylist(KbConfig::prioritylist());
+
+ if ((m_prioritylist.search(f1->fileName()) >= 0) > (m_prioritylist.search(f2->fileName()) >= 0)) return true;
+ else return false;
+};
+
+KbFileInfo::KbFileInfo(QFileInfo qfi) : QFileInfo(qfi)
+{
+ m_date_int =
+ qfi.lastModified().date().year() * 10000 +
+ qfi.lastModified().date().month() * 100 +
+ qfi.lastModified().date().day();
+ m_date = qfi.lastModified().toString("MMM dd yyyy");
+ m_size = qfi.size();
+}
+
+KbFileInfo::KbFileInfo(const KbFileInfo& kfi) : QFileInfo(kfi)
+{
+ m_date_int = kfi.m_date_int;
+ m_date = kfi.m_date;
+ m_size = kfi.m_size;
+}
+
+KbFileInfo::KbFileInfo(KbItem* item, QString workingdir) : QFileInfo(QDir(workingdir), item->File())
+{
+ m_date_int = item->DateInt();
+ m_date = item->Date();
+ m_size = item->Size();
+}
+
+KbFileInfo::KbFileInfo(const QString & d, const QString & fileName, off64_t size, QString date, unsigned int date_int)
+ : QFileInfo(QDir(d), fileName)
+{
+ m_date_int = date_int;
+ m_date = date;
+ m_size = size;
+}
+
+KbFileInfo::~KbFileInfo()
+{
+}
+
+void KbFileInfo::SetDirPath(QString path)
+{
+ setFile(QDir(path), fileName());
+}
+
diff --git a/src/kbfileinfo.h b/src/kbfileinfo.h
new file mode 100644
index 0000000..79b60c4
--- /dev/null
+++ b/src/kbfileinfo.h
@@ -0,0 +1,46 @@
+//
+// C++ Interface: kbfileinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBFILEINFO_H
+#define KBFILEINFO_H
+
+#include <qfileinfo.h>
+
+class KbItem;
+
+/**
+@author Magnus Kulke
+*/
+class KbFileInfo : public QFileInfo
+{
+public:
+
+ //KbFileInfo();
+ KbFileInfo(QFileInfo qfi);
+ KbFileInfo(const KbFileInfo& kfi);
+ KbFileInfo(QString workingdir);
+ KbFileInfo(KbItem* item, QString workingdir);
+ KbFileInfo(const QString & d, const QString & fileName, off64_t size, QString date, unsigned int date_int);
+ ~KbFileInfo();
+ off64_t Size() { return m_size; };
+ QString Date() { return m_date; };
+ unsigned int DateInt() { return m_date_int; };
+ void SetDirPath(QString path);
+ void SetSize(off64_t size) { m_size = size; };
+ static bool PrioritySort(KbFileInfo *f1, KbFileInfo *f2);
+ //static bool PrioritySort(const KbFileInfo &f1, const KbFileInfo &f2);
+private:
+ off64_t m_size;
+ unsigned int m_date_int;
+ QString m_date;
+};
+
+#endif
diff --git a/src/kbitem.cpp b/src/kbitem.cpp
new file mode 100644
index 0000000..5978496
--- /dev/null
+++ b/src/kbitem.cpp
@@ -0,0 +1,76 @@
+//
+// C++ Implementation: KbItem
+//
+// Description:
+//
+//
+// Author: mkulke <sikor_sxe@radicalapproach.de>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <qdatetime.h>
+#include "kbfileinfo.h"
+
+#include "kbitem.h"
+
+
+KbItem::KbItem(KbFileInfo kfi, QListView* parent, QListViewItem* after) : QListViewItem(parent, after)
+{
+ m_file = kfi.fileName();
+ m_path = kfi.dirPath(),
+ m_date = kfi.Date(),
+ m_size = kfi.Size(),
+ m_date_int = kfi.DateInt();
+
+ setText(0, m_file);
+ setText(1, QString::number(m_size));
+ setText(2, m_date);
+}
+
+KbItem::KbItem(QListView* parent, QListViewItem* after) : QListViewItem(parent, after)
+{
+}
+
+KbItem::~KbItem()
+{
+}
+
+int KbItem::compare(QListViewItem * i, int col, bool ascending) const
+{
+ if ((this->rtti() == 1001) && (i->rtti() == 1002))
+ {
+ if (ascending) return -1;
+ else return 1;
+ }
+ else if ((this->rtti() == 1002) && (i->rtti() == 1001))
+ {
+ if (ascending) return 1;
+ else return -1;
+ }
+
+ if (col == 1)
+ {
+ unsigned int x = this->text(1).toInt();
+ unsigned int y = i->text(1).toInt();
+ if (x == y) return 0;
+ if (x < y) return -1;
+ if (x > y) return 1;
+ }
+ if (col == 2)
+ {
+ unsigned int x = this->m_date_int;
+ unsigned int y = static_cast<KbItem*>(i)->m_date_int;
+ if (x == y) return 0;
+ if (x < y) return -1;
+ if (x > y) return 1;
+ }
+ return QListViewItem::compare(i, col, ascending);
+}
+
diff --git a/src/kbitem.h b/src/kbitem.h
new file mode 100644
index 0000000..ee390be
--- /dev/null
+++ b/src/kbitem.h
@@ -0,0 +1,50 @@
+//
+// C++ Interface: KbItem
+//
+// Description:
+//
+//
+// Author: mkulke <sikor_sxe@radicalapproach.de>, (C) 2003
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBITEM_H
+#define KBITEM_H
+
+#include <qlistview.h>
+
+class KbFileInfo;
+
+/**
+@author mkulke
+*/
+class KbItem : public QListViewItem
+{
+public:
+ enum entrytype
+ {
+ dir = 1001,
+ file
+ };
+ KbItem(KbFileInfo kfi, QListView* parent, QListViewItem* after);
+ KbItem(QListView* parent, QListViewItem* after);
+ int compare (QListViewItem * i, int col, bool ascending) const;
+ ~KbItem();
+
+ QString File() { return m_file; };
+ QString Path() { return m_path; };
+ QString Date() { return m_date; };
+ unsigned int DateInt() { return m_date_int; };
+ off64_t Size() { return m_size; };
+
+protected:
+ QString m_path;
+ QString m_date;
+ off64_t m_size;
+ unsigned int m_date_int;
+ QString m_file;
+
+};
+
+#endif
diff --git a/src/kbsiteinfo.cpp b/src/kbsiteinfo.cpp
new file mode 100644
index 0000000..63ba875
--- /dev/null
+++ b/src/kbsiteinfo.cpp
@@ -0,0 +1,194 @@
+//
+// C++ Implementation: kbsiteinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+
+#include <kstandarddirs.h>
+
+#include <qdom.h>
+#include <qfile.h>
+#include <qdir.h>
+#include <qtextstream.h>
+
+#include "kbsiteinfo.h"
+
+KbSiteInfo::KbSiteInfo()
+{
+ Clear();
+}
+
+
+KbSiteInfo::~KbSiteInfo()
+{
+}
+
+void KbSiteInfo::Clear()
+{
+ m_name = "";
+ m_info = "";
+ m_user = "";
+ m_pass = "";
+ m_defaultdir = "";
+ m_altfxp = 0;
+ m_correctpasv = 0;
+ m_pasv = 1;
+ m_tls = 0;
+}
+
+bool KbSiteInfo::IsLegit()
+{
+ if ((m_name != "") && (m_info != "") && (m_user != "")) return true;
+ else return false;
+}
+
+list<KbSiteInfo> KbSiteInfo::ParseBookmarks()
+{
+ list<KbSiteInfo> bookmarks;
+ bookmarks.clear();
+
+ QDomDocument doc( "KasablancaBookmarks" );
+
+ QFile filein(locateLocal("appdata", "bookmarks.xml"));
+
+ if( !filein.open( IO_ReadOnly ) ) return bookmarks;
+
+ if( !doc.setContent( &filein ) )
+ {
+ filein.close();
+ return bookmarks;
+ }
+
+ filein.close();
+
+ QDomElement root = doc.documentElement();
+
+ if( root.tagName() != "kasablanca" ) return bookmarks;
+
+ QDomNode curNode = root.firstChild();
+
+ while( !curNode.isNull() )
+ {
+ QDomElement siteElement = curNode.toElement();
+
+ if( !siteElement.isNull() )
+ {
+ if( siteElement.tagName() == "site" )
+ {
+ KbSiteInfo entry;
+ entry.SetPasv(1);
+ entry.SetTls(0);
+ entry.SetAlternativeFxp(0);
+ entry.SetCorrectPasv(0);
+ entry.SetDefaultDirectory("");
+ entry.SetName(siteElement.attribute( "name", "" ));
+
+ QDomNode siteNode = siteElement.firstChild();
+
+ while( !siteNode.isNull() )
+ {
+ QDomElement curElement = siteNode.toElement();
+
+ if( !curElement.isNull() )
+ {
+ if(curElement.tagName() == "user") entry.SetUser(curElement.text());
+ if(curElement.tagName() == "pass") entry.SetPass(curElement.text());
+ if(curElement.tagName() == "info") entry.SetInfo(curElement.text());
+ if(curElement.tagName() == "defaultdirectory") entry.SetDefaultDirectory(curElement.text());
+ if(curElement.tagName() == "pasv") entry.SetPasv(curElement.text().toInt());
+ if(curElement.tagName() == "tls") entry.SetTls(curElement.text().toInt());
+ if(curElement.tagName() == "alternativefxp") entry.SetAlternativeFxp(curElement.text().toInt());
+ if(curElement.tagName() == "correctpasv") entry.SetCorrectPasv(curElement.text().toInt());
+ }
+
+ siteNode = siteNode.nextSibling();
+ }
+
+ if (entry.IsLegit()) bookmarks.push_back(entry);
+ }
+ }
+
+ curNode = curNode.nextSibling();
+ }
+
+ return bookmarks;
+}
+
+bool KbSiteInfo::WriteBookmarks(list<KbSiteInfo> bookmarks)
+{
+ QDomDocument doc( "KasablancaBookmarks" );
+ QDomElement root = doc.createElement( "kasablanca" );
+ doc.appendChild( root );
+
+ list<KbSiteInfo>::iterator end_bookmarks = bookmarks.end();
+ for (list<KbSiteInfo>::iterator i = bookmarks.begin(); i != end_bookmarks; i++)
+ {
+ if ((*i).IsLegit())
+ {
+ QDomElement siteElement = doc.createElement("site");
+ siteElement.setAttribute("name", (*i).GetName());
+ root.appendChild( siteElement );
+
+ QDomText text;
+ QDomElement curElement;
+
+ curElement = doc.createElement( "user" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode((*i).GetUser());
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "pass" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode((*i).GetPass());
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "info" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode((*i).GetInfo());
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "pasv" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode(QString::number((*i).GetPasv()));
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "tls" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode(QString::number((*i).GetTls()));
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "alternativefxp" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode(QString::number((*i).GetAlternativeFxp()));
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "correctpasv" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode(QString::number((*i).GetCorrectPasv()));
+ curElement.appendChild(text);
+
+ curElement = doc.createElement( "defaultdirectory" );
+ siteElement.appendChild( curElement );
+ text = doc.createTextNode((*i).GetDefaultDirectory());
+ curElement.appendChild(text);
+ }
+ }
+
+ QFile fileout(locateLocal("appdata", "bookmarks.xml"));
+
+ if( !fileout.open( IO_WriteOnly ) ) return false;
+
+ QTextStream ts( &fileout );
+ ts << doc.toString();
+
+ fileout.close();
+
+ return true;
+}
diff --git a/src/kbsiteinfo.h b/src/kbsiteinfo.h
new file mode 100644
index 0000000..573ae89
--- /dev/null
+++ b/src/kbsiteinfo.h
@@ -0,0 +1,65 @@
+//
+// C++ Interface: kbsiteinfo
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBSITEINFO_H
+#define KBSITEINFO_H
+
+#include <qstring.h>
+
+#include <list>
+
+/**
+@author Magnus Kulke
+*/
+
+using namespace std;
+
+class KbSiteInfo
+{
+public:
+ KbSiteInfo();
+ ~KbSiteInfo();
+ QString GetInfo() { return m_info; };
+ QString GetUser() { return m_user; };
+ QString GetPass() { return m_pass; };
+ QString GetName() { return m_name; };
+ QString GetDefaultDirectory() { return m_defaultdir; };
+ int GetAlternativeFxp() { return m_altfxp; };
+ int GetCorrectPasv() { return m_correctpasv; };
+ int GetPasv() { return m_pasv; };
+ int GetTls() { return m_tls; };
+ void SetPasv(int pasv) { m_pasv = pasv; };
+ void SetTls(int tls) { m_tls = tls; };
+ void SetDefaultDirectory(QString path) { m_defaultdir = path; };
+ void SetAlternativeFxp(int i) { m_altfxp = i; };
+ void SetCorrectPasv(int i) { m_correctpasv = i; };
+ void SetUser(QString user) { m_user = user; };
+ void SetInfo(QString info) { m_info = info; };
+ void SetPass(QString pass) { m_pass = pass; };
+ void SetName(QString name) { m_name = name; };
+ bool IsLegit();
+ static list<KbSiteInfo> ParseBookmarks();
+ static bool WriteBookmarks(const list<KbSiteInfo> bookmarks);
+ void Clear();
+private:
+ list<KbSiteInfo> goo;
+ QString m_user;
+ QString m_info;
+ QString m_name;
+ QString m_pass;
+ QString m_defaultdir;
+ int m_altfxp;
+ int m_correctpasv;
+ int m_pasv;
+ int m_tls;
+};
+
+#endif
diff --git a/src/kbstatustip.cpp b/src/kbstatustip.cpp
new file mode 100644
index 0000000..cb50edf
--- /dev/null
+++ b/src/kbstatustip.cpp
@@ -0,0 +1,35 @@
+//
+// C++ Implementation: kbstatustip
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <qcursor.h>
+
+#include "kbstatustip.h"
+
+KbStatusTip::KbStatusTip(QWidget * widget) : QToolTip(widget)
+{
+}
+
+void KbStatusTip::maybeTip(const QPoint &)
+{
+ tip(parentWidget()->rect(), "kasablanca");
+}
+
+void KbStatusTip::ShowStatus(QString msg)
+{
+ if ((QCursor::pos().x() > parentWidget()->mapToGlobal(parentWidget()->pos()).x())
+ && (QCursor::pos().y() > parentWidget()->mapToGlobal(parentWidget()->pos()).y())
+ && (QCursor::pos().x() < (parentWidget()->mapToGlobal(parentWidget()->pos()).x() + parentWidget()->width()))
+ && (QCursor::pos().y() < (parentWidget()->mapToGlobal(parentWidget()->pos()).y() + parentWidget()->height())))
+ {
+ tip(parentWidget()->rect(), msg);
+ }
+}
diff --git a/src/kbstatustip.h b/src/kbstatustip.h
new file mode 100644
index 0000000..1fec765
--- /dev/null
+++ b/src/kbstatustip.h
@@ -0,0 +1,28 @@
+//
+// C++ Interface: kbstatustip
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBSTATUSTIP_H
+#define KBSTATUSTIP_H
+
+#include <qtooltip.h>
+
+/**
+@author Magnus Kulke
+*/
+class KbStatusTip : public QToolTip
+{
+public:
+ KbStatusTip(QWidget * widget);
+ void maybeTip(const QPoint &pos);
+ void ShowStatus(QString msg);
+};
+
+#endif
diff --git a/src/kbtaskview.cpp b/src/kbtaskview.cpp
new file mode 100644
index 0000000..d1f6cc1
--- /dev/null
+++ b/src/kbtaskview.cpp
@@ -0,0 +1,64 @@
+//
+// C++ Implementation: kbtaskview
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+
+#include <klocale.h>
+
+#include <qptrlist.h>
+#include <qevent.h>
+
+#include "kbtaskview.h"
+#include "kbfileinfo.h"
+#include "kbtransferitem.h"
+
+KbTaskView::KbTaskView(QWidget *parent, const char *name)
+ : KListView(parent, name)
+{
+ addColumn(i18n("Task"));
+ addColumn(i18n("Progress"));
+ addColumn(i18n("Speed"));
+ addColumn(i18n("Percentage"));
+ addColumn(i18n("Remaining"));
+
+ setRootIsDecorated(true);
+ setSelectionMode(QListView::Extended);
+ setDragEnabled(true);
+ setAcceptDrops(true);
+
+ //connect(this, SIGNAL(doubleClicked(QListViewItem*, const QPoint&, int)),
+ // this, SLOT(SLOT_DoubleClicked(QListViewItem*, const QPoint&, int)));
+}
+
+KbTaskView::~KbTaskView()
+{
+}
+
+QListViewItem* KbTaskView::LastChild()
+{
+ QListViewItem* last = NULL;
+ QListViewItem* it = lastItem();
+ while (it)
+ {
+ last = it;
+ it = it->parent();
+ }
+ return last;
+}
+
+void KbTaskView::SLOT_DoubleClicked(QListViewItem* item, const QPoint&, int)
+{
+ KbTransferItem *kti = static_cast<KbTransferItem*>(item);
+ qWarning("src: %s|%s", kti->SrcFileInfo()->filePath().latin1(), kti->SrcFileInfo()->fileName().latin1());
+ qWarning("dst: %s|%s", kti->DstFileInfo()->filePath().latin1(), kti->DstFileInfo()->fileName().latin1());
+}
+
+#include "kbtaskview.moc"
diff --git a/src/kbtaskview.h b/src/kbtaskview.h
new file mode 100644
index 0000000..79d1ec9
--- /dev/null
+++ b/src/kbtaskview.h
@@ -0,0 +1,33 @@
+//
+// C++ Interface: kbtaskview
+//
+// Description:
+//
+//
+// Author: Magnus Kulke <mkulke@magnusmachine>, (C) 2004
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef KBTASKVIEW_H
+#define KBTASKVIEW_H
+
+#include <klistview.h>
+
+/**
+@author Magnus Kulke
+*/
+class KbTaskView : public KListView
+{
+Q_OBJECT
+public:
+ KbTaskView(QWidget *parent = 0, const char *name = 0);
+ ~KbTaskView();
+ QListViewItem* LastChild();
+public slots:
+ void SLOT_DoubleClicked(QListViewItem* item, const QPoint& p, int c);
+ //virtual bool acceptDrag(QDropEvent* event) const;
+ //virtual QDragObject* dragObject();
+};
+
+#endif
diff --git a/src/kbtransferdir.cpp b/src/kbtransferdir.cpp
new file mode 100644
index 0000000..7104715
--- /dev/null
+++ b/src/kbtransferdir.cpp
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "kbtransferdir.h"
+
+KbTransferDir::KbTransferDir(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : KbTransferItem(taskview, after, srcsession, dstsession, src, dst)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("folder",KIcon::Small));
+}
+
+KbTransferDir::KbTransferDir(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : KbTransferItem(root, after, srcsession, dstsession, src, dst)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("folder",KIcon::Small));
+}
+
+KbTransferDir::~KbTransferDir()
+{
+}
+
+int KbTransferDir::rtti() const
+{
+ return KbTransferItem::dir;
+}
+
+void KbTransferDir::Info()
+{
+ qWarning("INFO: transfer dir from %s to %s", mp_srcsession->name(), mp_dstsession->name());
+ qWarning("INFO: mp_src->fileName() = %s", mp_src->fileName().latin1());
+ qWarning("INFO: mp_dst->fileName() = %s", mp_dst->fileName().latin1());
+ qWarning("INFO: mp_src->dirPath() = %s", mp_src->dirPath(true).latin1());
+ qWarning("INFO: mp_dst->dirPath() = %s", mp_dst->dirPath(true).latin1());
+}
+
+
diff --git a/src/kbtransferdir.h b/src/kbtransferdir.h
new file mode 100644
index 0000000..643cccd
--- /dev/null
+++ b/src/kbtransferdir.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef TRANSFERDIR_H
+#define TRANSFERDIR_H
+
+#include <kbtransferitem.h>
+
+/**
+@author Magnus Kulke
+*/
+class KbTransferDir : public KbTransferItem
+{
+public:
+ KbTransferDir(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst);
+ KbTransferDir(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst);
+ ~KbTransferDir();
+ int rtti() const;
+ void Info();
+
+};
+
+#endif
diff --git a/src/kbtransferfile.cpp b/src/kbtransferfile.cpp
new file mode 100644
index 0000000..d8e158e
--- /dev/null
+++ b/src/kbtransferfile.cpp
@@ -0,0 +1,120 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+// enable > 2gb support (LFS)
+
+#define _LARGEFILE_SOURCE
+#define _LARGEFILE64_SOURCE
+
+#include <qpainter.h>
+#include <qcolor.h>
+
+#include "kbstatustip.h"
+#include "kbsiteinfo.h"
+
+#include "kbtransferfile.h"
+
+KbTransferFile::KbTransferFile(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : KbTransferItem(taskview, after, srcsession, dstsession, src, dst)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("files",KIcon::Small));
+ m_time_old = -1;
+ m_xfered_old = 0;
+ m_percentage = 0;
+}
+
+KbTransferFile::KbTransferFile(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : KbTransferItem(root, after, srcsession, dstsession, src, dst)
+{
+ setPixmap(0, KGlobal::iconLoader()->loadIcon("files",KIcon::Small));
+ m_time_old = -1;
+ m_xfered_old = 0;
+}
+
+KbTransferFile::~KbTransferFile()
+{
+}
+
+int KbTransferFile::rtti() const
+{
+ return KbTransferItem::file;
+}
+
+void KbTransferFile::Info()
+{
+ qWarning("INFO: transfer file from %s to %s", mp_srcsession->name(), mp_dstsession->name());
+ qWarning("INFO: mp_src->fileName() = %s", mp_src->fileName().latin1());
+ qWarning("INFO: mp_dst->fileName() = %s", mp_dst->fileName().latin1());
+ qWarning("INFO: mp_src->dirPath() = %s", mp_src->dirPath(true).latin1());
+ qWarning("INFO: mp_dst->dirPath() = %s", mp_dst->dirPath(true).latin1());
+}
+
+void KbTransferFile::ShowProgress(KbStatusTip *statustip)
+{
+ int time = m_time.elapsed();
+ int time_dif = time - m_time_old;
+ if (time_dif == 0) time_dif = 1;
+ off64_t xfer_dif = m_xfered - m_xfered_old;
+
+ off64_t currentsize = (m_xfered + mp_dst->Size()) >> 10;
+ off64_t wholesize = mp_src->Size() >> 10;
+ off64_t rest = wholesize - currentsize;
+ m_percentage = ((currentsize * 100 ) / (wholesize + 1));
+ int speed = xfer_dif / time_dif;
+ off64_t remaining = rest / (speed + 1);
+
+ if ((mp_srcsession->Connected()) && (mp_dstsession->Connected()))
+ {
+ setText(1, "unknown kb of " + QString::number(wholesize) + "kb");
+ setText(2, "unknown kb/s");
+ setText(4, "unknown");
+ }
+ else
+ {
+ setText(1, QString::number(currentsize) + "kb of " + QString::number(wholesize) + "kb");
+ setText(2, QString::number(speed) + "kb/s");
+ setText(4, QString::number(remaining / 3600) + "h" + QString::number(remaining / 60) + "m" + QString::number(remaining % 60) + "s");
+ }
+
+ m_time_old = time;
+ m_xfered_old = m_xfered;
+
+ statustip->ShowStatus(mp_src->fileName()
+ + "," + QString::number(m_percentage) + "%," + QString::number(speed) + "kb/s");
+
+ //QToolTip::add(systemtray, mp_src->fileName()
+ //+ "," + QString::number(percentage) + "%," + QString::number(speed) + "kb/s");
+}
+
+void KbTransferFile::paintCell( QPainter *painter, const QColorGroup &colorGroup, int column,
+ int width, int alignment )
+{
+ if ((column == 3)
+ && (m_xfered_old != 0)
+ && ((!mp_srcsession->Connected()) || (!mp_dstsession->Connected())))
+ PaintPercentageBar (painter, width);
+ else QListViewItem::paintCell(painter, colorGroup, column, width, alignment);
+}
+
+void KbTransferFile::PaintPercentageBar(QPainter * painter, int width)
+{
+ int len = width * m_percentage / 100;
+ painter->fillRect(0, 0, width, height(), Qt::lightGray);
+ painter->fillRect(0, 0, len, height(), Qt::gray);
+ painter->drawText((width / 2) - 10, height() - 5, QString::number(m_percentage) + "%");
+}
diff --git a/src/kbtransferfile.h b/src/kbtransferfile.h
new file mode 100644
index 0000000..5b2030a
--- /dev/null
+++ b/src/kbtransferfile.h
@@ -0,0 +1,48 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef TRANSFERFILE_H
+#define TRANSFERFILE_H
+
+#include <kbtransferitem.h>
+
+class KbStatusTip;
+
+/**
+@author Magnus Kulke
+*/
+class KbTransferFile : public KbTransferItem
+{
+public:
+ KbTransferFile(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst);
+ KbTransferFile(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst);
+ ~KbTransferFile();
+ int rtti() const;
+ void Info();
+ void ShowProgress(KbStatusTip *statustip);
+private:
+ int m_time_old;
+ off64_t m_xfered_old;
+ int m_percentage;
+ virtual void paintCell( QPainter *painter, const QColorGroup &colorGroup, int column,
+ int width, int alignment );
+ void PaintPercentageBar(QPainter *painter, int width);
+};
+
+#endif
diff --git a/src/kbtransferitem.cpp b/src/kbtransferitem.cpp
new file mode 100644
index 0000000..cb4c254
--- /dev/null
+++ b/src/kbtransferitem.cpp
@@ -0,0 +1,83 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+
+#include "kbfileinfo.h"
+
+#include "kbtransferitem.h"
+
+KbTransferItem::KbTransferItem(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : QListViewItem(taskview, after)
+{
+ mp_srcsession = srcsession;
+ mp_dstsession = dstsession;
+ mp_src = src;
+ mp_dst = dst;
+ m_status = clear;
+ m_transfererror = false;
+ m_xfered = 0;
+
+ setText(0, src->fileName());
+}
+
+KbTransferItem::KbTransferItem(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo *src, KbFileInfo *dst) : QListViewItem(root, after)
+{
+ mp_srcsession = srcsession;
+ mp_dstsession = dstsession;
+ mp_src = src;
+ mp_dst = dst;
+ m_status = clear;
+ m_transfererror = false;
+ m_xfered = 0;
+
+ setText(0, src->fileName());
+}
+
+KbTransferItem::~KbTransferItem()
+{
+ delete mp_src;
+ delete mp_dst;
+}
+
+void KbTransferItem::Info()
+{
+}
+
+void KbTransferItem::ShowProgress(KbStatusTip *)
+{
+}
+
+void KbTransferItem::Init()
+{
+ setSelectable(false);
+ listView()->setOpen(this, true);
+ setSelected(false);
+ repaint();
+ mp_srcsession->Occupy();
+ mp_dstsession->Occupy();
+ mp_srcsession->SetCurrentTransfer(this);
+ mp_dstsession->SetCurrentTransfer(this);
+}
+
+void KbTransferItem::Finish()
+{
+ mp_srcsession->SetCurrentTransfer(NULL);
+ mp_dstsession->SetCurrentTransfer(NULL);
+ mp_srcsession->Free();
+ mp_dstsession->Free();
+}
diff --git a/src/kbtransferitem.h b/src/kbtransferitem.h
new file mode 100644
index 0000000..4744ff4
--- /dev/null
+++ b/src/kbtransferitem.h
@@ -0,0 +1,79 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Magnus Kulke *
+ * mkulke@magnusmachine *
+ * *
+ * 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., *
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
+ ***************************************************************************/
+#ifndef TRANSFERITEM_H
+#define TRANSFERITEM_H
+
+#include <kiconloader.h>
+#include <kglobal.h>
+#include <qlistview.h>
+#include <qfileinfo.h>
+
+#include "ftpsession.h"
+#include "kbfileinfo.h"
+
+class FtpSession;
+class KbStatusTip;
+
+/**
+@author Magnus Kulke
+*/
+class KbTransferItem : public QListViewItem
+{
+public:
+ enum type
+ {
+ file = 1001,
+ dir
+ };
+ KbTransferItem(QListViewItem *root, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo* src, KbFileInfo* dst);
+ KbTransferItem(QListView *taskview, QListViewItem *after, FtpSession *srcsession, FtpSession *dstsession, KbFileInfo* src, KbFileInfo* dst);
+ ~KbTransferItem();
+
+ virtual void Info();
+ virtual void ShowProgress(KbStatusTip *statustip);
+ void Finish();
+ void IncrementStatus() { m_status = m_status + 1; };
+ void Init();
+ void Xfered(off64_t xfered) { m_xfered = xfered; };
+ void StartTimer() { m_time.start(); };
+ FtpSession* SrcSession() { return mp_srcsession; };
+ KbFileInfo* SrcFileInfo() { return mp_src; };
+ FtpSession* DstSession() { return mp_dstsession; };
+ KbFileInfo* DstFileInfo() { return mp_dst; };
+ int Status() { return m_status; };
+ void Abort() { m_status = done; };
+ enum status
+ {
+ clear = 0,
+ src_ready,
+ dst_ready,
+ done
+ };
+
+protected:
+ FtpSession *mp_srcsession, *mp_dstsession;
+ KbFileInfo *mp_src, *mp_dst;
+ int m_status;
+ bool m_transfererror;
+ off64_t m_xfered;
+ QTime m_time;
+};
+
+#endif
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644
index 0000000..834d499
--- /dev/null
+++ b/src/main.cpp
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2004 Magnus Kulke <mkulke@magnusmachine>
+ */
+
+#include "kasablanca.h"
+#include <kapplication.h>
+#include <dcopclient.h>
+#include <kaboutdata.h>
+#include <kcmdlineargs.h>
+#include <klocale.h>
+
+static const char description[] =
+ I18N_NOOP("A KDE Ftp Client");
+
+static const char version[] = "0.4.0.2";
+
+static KCmdLineOptions options[] =
+{
+// { "+[URL]", I18N_NOOP( "Document to open." ), 0 },
+ KCmdLineLastOption
+};
+
+int main(int argc, char **argv)
+{
+ KLocale::setMainCatalogue("kasablanca");
+
+ KAboutData about("kasablanca", I18N_NOOP("kasablanca"), version, description,
+ KAboutData::License_GPL, "(C) 2004 Magnus Kulke", 0, 0,
+ "sikor_sxe@radicalapproach.de");
+ about.addAuthor( "Magnus Kulke", 0, "sikor_sxe@radicalapproach.de" );
+ about.addAuthor( "Big Biff", 0, "bigbiff@chunkyfilms.org" );
+ about.addCredit( "Stefan Bogner", 0, "bochi@online.ms" );
+ about.addCredit( "Christoph Thielecke", 0, "u15119@hs-harz.de" );
+ about.addCredit( "Richard Stellingwerf", 0, "justremenic@hotmail.com" );
+ KCmdLineArgs::init(argc, argv, &about);
+ KCmdLineArgs::addCmdLineOptions(options);
+ KApplication app;
+
+ // register ourselves as a dcop client
+ app.dcopClient()->registerAs(app.name(), false);
+
+ // see if we are starting with session management
+ if (app.isRestored())
+ {
+ RESTORE(Kasablanca);
+ }
+ else
+ {
+ // no session.. just start up normally
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+ if (args->count() == 0)
+ {
+ Kasablanca *widget = new Kasablanca;
+ widget->show();
+ }
+ else
+ {
+ int i = 0;
+ for (; i < args->count(); i++)
+ {
+ Kasablanca *widget = new Kasablanca;
+ widget->show();
+// TODO: Load the ftp url passed on the command line.
+// widget->load(args->url(i));
+ }
+ }
+ args->clear();
+ }
+
+ return app.exec();
+}
+