diff options
Diffstat (limited to 'kget')
135 files changed, 11924 insertions, 0 deletions
diff --git a/kget/AUTHORS b/kget/AUTHORS new file mode 100644 index 00000000..c12f6a54 --- /dev/null +++ b/kget/AUTHORS @@ -0,0 +1,4 @@ +Patrick Charbonnier <[email protected]> +Carsten Pfeiffer <[email protected]> +Matej Koss + diff --git a/kget/Makefile.am b/kget/Makefile.am new file mode 100644 index 00000000..433ee66d --- /dev/null +++ b/kget/Makefile.am @@ -0,0 +1,50 @@ +SUBDIRS = . pics icons sounds kget_plug_in +INCLUDES = $(all_includes) + + +bin_PROGRAMS = kget + +kget_LDFLAGS = $(all_libraries) $(KDE_RPATH) +kget_LDADD = $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIBSOCKET) +kget_SOURCES = getfilejob.cpp slaveevent.cpp slave.cpp transferlist.cpp \ + transfer.cpp settings.cpp logwindow.cpp \ + kmainwidget.cpp kfileio.cpp droptarget.cpp docking.cpp \ + dlgconnectionbase.ui dlgautomationbase.ui dlglimitsbase.ui \ + dlgadvancedbase.ui dlgdirectoriesbase.ui dlgsystembase.ui \ + dlgSystem.cpp dlgPreferences.cpp dlgLimits.cpp \ + dlgIndividual.cpp dlgDirectories.cpp dlgConnection.cpp \ + dlgAutomation.cpp dlgAdvanced.cpp \ + main.cpp dockindividual.cpp kget_iface.skel safedelete.cpp + +noinst_HEADERS = common.h \ + dlgAdvanced.h dlgAutomation.h dlgConnection.h \ + dlgDirectories.h dlgIndividual.h dlgLimits.h \ + dlgPreferences.h dlgSystem.h docking.h droptarget.h \ + kfileio.h kmainwidget.h logwindow.h settings.h \ + transfer.h transferlist.h version.h slave.h \ + slaveevent.h http_defaults.h getfilejob.h dockindividual.h + +kget_METASOURCES = AUTO + +xdg_apps_DATA = kget.desktop + +mimedir = $(kde_mimedir)/application +mime_DATA =x-kgetlist.desktop + +servicemenudir = $(kde_datadir)/konqueror/servicemenus +servicemenu_DATA = kget_download.desktop + +EXTRA_DIST = kget.desktop $(mime_DATA) + +rcdir = $(kde_datadir)/kget +rc_DATA = kgetui.rc + +events_DATA = eventsrc +eventsdir = $(kde_datadir)/kget + +KDE_ICON = AUTO + +messages: rc.cpp + $(EXTRACTRC) *.ui > rc.cpp + $(EXTRACTRC) *.rc */*.rc >> rc.cpp + $(XGETTEXT) *.cpp */*.cpp *.h -o $(podir)/kget.pot diff --git a/kget/README b/kget/README new file mode 100644 index 00000000..f121641b --- /dev/null +++ b/kget/README @@ -0,0 +1,30 @@ + KGet 0.8.0-RC-1 + ========== + +New working release of kget for kde3. + +INSTALLATION +============= +checkout the admin directory from kde-common then: +cd kget +ln -s kde-common/admin . +make -f Makefile.cvs +./configure --disable-debug --enable-mt +make +make install + +BUGS +===== + Please report all bugs to [email protected] + +TODO +===== + o Download segments + + +Happy downloading + +____________ +Patrick Charbonnier +E-mail: [email protected] + diff --git a/kget/TODO b/kget/TODO new file mode 100644 index 00000000..2fe91449 --- /dev/null +++ b/kget/TODO @@ -0,0 +1,10 @@ +Add a plug-in for konqueror +Add support for mirrors +Add bandwidth limiting +Splits download in 2 segments +Better icons +Add Help & Guide + + + + diff --git a/kget/common.h b/kget/common.h new file mode 100644 index 00000000..b436902a --- /dev/null +++ b/kget/common.h @@ -0,0 +1,41 @@ +/*************************************************************************** +* common.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * * + * 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 _COMMON_H +#define _COMMON_H + + +#include <kdebug.h> + +#define mDebugIn mDebug << ">>>>Entering " +#define mDebugOut mDebug << ">>>>Leaving " + +#define sDebugIn sDebug << ">>>>Entering " +#define sDebugOut sDebug << ">>>>Leaving " + + +#define mDebug kdDebug(DKGET)<<k_funcinfo << THREAD_ID +#define sDebug kdDebug(DKGET)<<k_funcinfo << "|--( GUI )--| " +#define DKGET 0 +#define THREAD_ID "|--TH_ID ( "<< currentThread()<<" )--| " + + +#define TIME_OUT 35 +#endif // common diff --git a/kget/cr16-app-kget.png b/kget/cr16-app-kget.png Binary files differnew file mode 100644 index 00000000..2503410c --- /dev/null +++ b/kget/cr16-app-kget.png diff --git a/kget/cr16-mime-kget_list.png b/kget/cr16-mime-kget_list.png Binary files differnew file mode 100644 index 00000000..626cddef --- /dev/null +++ b/kget/cr16-mime-kget_list.png diff --git a/kget/cr22-app-kget.png b/kget/cr22-app-kget.png Binary files differnew file mode 100644 index 00000000..0e9c982f --- /dev/null +++ b/kget/cr22-app-kget.png diff --git a/kget/cr22-mime-kget_list.png b/kget/cr22-mime-kget_list.png Binary files differnew file mode 100644 index 00000000..cada0ffe --- /dev/null +++ b/kget/cr22-mime-kget_list.png diff --git a/kget/cr32-app-kget.png b/kget/cr32-app-kget.png Binary files differnew file mode 100644 index 00000000..96ef6794 --- /dev/null +++ b/kget/cr32-app-kget.png diff --git a/kget/cr32-mime-kget_list.png b/kget/cr32-mime-kget_list.png Binary files differnew file mode 100644 index 00000000..6ead9cfe --- /dev/null +++ b/kget/cr32-mime-kget_list.png diff --git a/kget/cr48-app-kget.png b/kget/cr48-app-kget.png Binary files differnew file mode 100644 index 00000000..ef0d08a5 --- /dev/null +++ b/kget/cr48-app-kget.png diff --git a/kget/cr48-mime-kget_list.png b/kget/cr48-mime-kget_list.png Binary files differnew file mode 100644 index 00000000..5cbf505d --- /dev/null +++ b/kget/cr48-mime-kget_list.png diff --git a/kget/dlgAdvanced.cpp b/kget/dlgAdvanced.cpp new file mode 100644 index 00000000..43b0265c --- /dev/null +++ b/kget/dlgAdvanced.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** +* dlgAdvanced.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <qcheckbox.h> +#include <qradiobutton.h> + +#include <kprotocolmanager.h> + +#include <klocale.h> +#include <kconfig.h> + +#include "settings.h" +#include "kmainwidget.h" +#include "dlgAdvanced.h" + + + +DlgAdvanced::DlgAdvanced(QWidget * parent) + : DlgAdvancedBase(parent) +{ + cb_partial->hide(); +} + + +void +DlgAdvanced::setData() +{ + rb_queued->setChecked(ksettings.b_addQueued); + rb_delayed->setChecked(!ksettings.b_addQueued); + cb_iconify->setEnabled(ksettings.b_showIndividual); + cb_individual->setChecked(ksettings.b_showIndividual); + cb_iconify->setChecked(ksettings.b_iconifyIndividual); + cb_advanced->setChecked(ksettings.b_advancedIndividual); + cb_remove->setChecked(ksettings.b_removeOnSuccess); + cb_getsizes->setChecked(ksettings.b_getSizes); + cb_expertmode->setChecked(ksettings.b_expertMode); + cb_partial->setChecked(KProtocolManager::markPartial()); + cb_konqiIntegration->setChecked(ksettings.b_KonquerorIntegration); + cb_ShowMain->setChecked(ksettings.b_showMain); +} + + +void DlgAdvanced::applyData() +{ + ksettings.b_addQueued = rb_queued->isChecked(); + ksettings.b_showIndividual = cb_individual->isChecked(); + ksettings.b_iconifyIndividual = cb_iconify->isChecked(); + ksettings.b_advancedIndividual = cb_advanced->isChecked(); + ksettings.b_removeOnSuccess = cb_remove->isChecked(); + ksettings.b_getSizes = cb_getsizes->isChecked(); + ksettings.b_showMain=cb_ShowMain->isChecked(); + + if (ksettings.b_expertMode != cb_expertmode->isChecked()) { + kmain->slotToggleExpertMode(); + } + + bool bIsKonquiEnable=cb_konqiIntegration->isChecked(); + + if (ksettings.b_KonquerorIntegration!=bIsKonquiEnable) + { + ksettings.b_KonquerorIntegration=!ksettings.b_KonquerorIntegration; + KConfig cfg("konquerorrc", false, false); + cfg.setGroup("HTML Settings"); + cfg.writePathEntry("DownloadManager",QString((bIsKonquiEnable)?"kget":"")); + cfg.sync(); + } +} + +void DlgAdvanced::slotChanged() +{ + emit configChanged(); +} + +#include "dlgAdvanced.moc" diff --git a/kget/dlgAdvanced.h b/kget/dlgAdvanced.h new file mode 100644 index 00000000..5af58c2a --- /dev/null +++ b/kget/dlgAdvanced.h @@ -0,0 +1,51 @@ +/*************************************************************************** +* dlgAdvanced.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ +#ifndef _DLGADVANCED_H +#define _DLGADVANCED_H + +#include "dlgadvancedbase.h" + +class DlgAdvanced : public DlgAdvancedBase +{ + +Q_OBJECT + +public: + + DlgAdvanced(QWidget * parent); + ~DlgAdvanced() {} + + void applyData(); + void setData(); + +protected slots: + void slotChanged(); + +signals: + void configChanged(); +}; + +#endif // _DLGADVANCED_H diff --git a/kget/dlgAutomation.cpp b/kget/dlgAutomation.cpp new file mode 100644 index 00000000..98ed4f3e --- /dev/null +++ b/kget/dlgAutomation.cpp @@ -0,0 +1,135 @@ +/*************************************************************************** +* dlgAutomation.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <qgroupbox.h> +#include <qcheckbox.h> +#include <qlabel.h> +#include <qlayout.h> + +#include <klocale.h> +#include <kdatetimewidget.h> +#include <knuminput.h> +#include "common.h" + +#include <kdialog.h> +#include <klineedit.h> + +#include "settings.h" +#include "kmainwidget.h" +#include "dlgAutomation.h" + + +DlgAutomation::DlgAutomation(QWidget * parent) + : DlgAutomationBase(parent) +{ +} + + +void DlgAutomation::disconnectToggled(bool flag) +{ + le_autoDisconnect->setEnabled(flag); + cb_timedDisconnect->setEnabled(flag); + if (cb_timedDisconnect->isChecked()) { + spins->setEnabled(flag); + } +} + + +void DlgAutomation::slotTypeChanged(int type) +{ + if (type == PERMANENT) { + disconnectToggled(false); + cb_autoDisconnect->setEnabled(false); + cb_autoDisconnect->setChecked(false); + cb_timedDisconnect->setChecked(false); + } else { + cb_autoDisconnect->setEnabled(true); + } +} + + +void DlgAutomation::setData() +{ + // auto save + le_autoSave->setEnabled(ksettings.b_autoSave); + cb_autoSave->setChecked(ksettings.b_autoSave); + + le_autoSave->setValue(ksettings.autoSaveInterval); + + // auto disconnect + le_autoDisconnect->setEnabled(ksettings.b_autoDisconnect); + cb_timedDisconnect->setEnabled(ksettings.b_autoDisconnect); + spins->setEnabled(ksettings.b_autoDisconnect); + cb_autoDisconnect->setChecked(ksettings.b_autoDisconnect); + le_autoDisconnect->setText(ksettings.disconnectCommand); + + cb_timedDisconnect->setChecked(ksettings.b_timedDisconnect); + spins->setEnabled(ksettings.b_timedDisconnect); + + disconnectDateTime.setDate(ksettings.disconnectDate); + disconnectDateTime.setTime(ksettings.disconnectTime); + spins->setDateTime(disconnectDateTime); + + // auto shutdown + cb_autoShutdown->setChecked(ksettings.b_autoShutdown); + + // auto paste + cb_autoPaste->setChecked(ksettings.b_autoPaste); +} + + +void DlgAutomation::applyData() +{ + if (cb_autoSave->isChecked() != ksettings.b_autoSave || (uint) le_autoSave->value() != ksettings.autoSaveInterval) { + ksettings.b_autoSave = cb_autoSave->isChecked(); + ksettings.autoSaveInterval = le_autoSave->value(); + kmain->setAutoSave(); + } + + if (cb_autoDisconnect->isChecked() != ksettings.b_autoDisconnect) { + kmain->slotToggleAutoDisconnect(); + kmain->setAutoDisconnect(); + } + + ksettings.disconnectCommand = le_autoDisconnect->text(); + ksettings.b_timedDisconnect = cb_timedDisconnect->isChecked(); + ksettings.disconnectDate = spins->dateTime().date(); + ksettings.disconnectTime = spins->dateTime().time(); + + if (cb_autoShutdown->isChecked() != ksettings.b_autoShutdown) { + kmain->slotToggleAutoShutdown(); + } + + if (cb_autoPaste->isChecked() != ksettings.b_autoPaste) { + kmain->slotToggleAutoPaste(); + } +} + +void DlgAutomation::slotChanged() +{ + emit configChanged(); +} +#include "dlgAutomation.moc" diff --git a/kget/dlgAutomation.h b/kget/dlgAutomation.h new file mode 100644 index 00000000..e9f629bc --- /dev/null +++ b/kget/dlgAutomation.h @@ -0,0 +1,61 @@ +/*************************************************************************** +* dlgAutomation.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _DLGAUTOMATION_H +#define _DLGAUTOMATION_H + +#include <qstringlist.h> +#include <qdatetime.h> + +#include "dlgautomationbase.h" + +class DlgAutomation:public DlgAutomationBase +{ + +Q_OBJECT public: + + DlgAutomation(QWidget * parent); + ~DlgAutomation() {} + void applyData(); + void setData(); + +private: + + QDateTime disconnectDateTime; + +signals: + void configChanged(); + +public slots: + void slotTypeChanged(int); + +protected slots: + void disconnectToggled(bool); + void slotChanged(); +}; + +#endif // _DLGAUTOMATION_H diff --git a/kget/dlgConnection.cpp b/kget/dlgConnection.cpp new file mode 100644 index 00000000..c5ffae56 --- /dev/null +++ b/kget/dlgConnection.cpp @@ -0,0 +1,137 @@ +/*************************************************************************** +* dlgConnection.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qgroupbox.h> +#include <qlabel.h> +#include <qcheckbox.h> +#include <qlayout.h> + +#include <klocale.h> +#include <kprotocolmanager.h> +#include <kdialog.h> +#include <knuminput.h> +#include <kcombobox.h> + + +#include "kmainwidget.h" +#include "settings.h" +#include "dlgConnection.h" + + +DlgConnection::DlgConnection(QWidget * parent) + :DlgConnectionBase(parent, "", 0) +{ + // TODO: these are not supported yet, so hide them + gb_timeout->hide(); + le_nodata->hide(); + le_noresume->hide(); +} + + +void DlgConnection::comboActivated(int Index) +{ + if (Index == 0) { + lb_linknum->setEnabled(false); + le_linknum->setEnabled(false); + cb_offlinemode->setEnabled(true); + } else { + lb_linknum->setEnabled(true); + le_linknum->setEnabled(true); + cb_offlinemode->setEnabled(false); + cb_offlinemode->setChecked(false); + } + + emit typeChanged(Index); +} + + +void DlgConnection::setData() +{ + lb_after->setEnabled(ksettings.b_reconnectOnError); + le_after->setEnabled(ksettings.b_reconnectOnError); +// lb_retries->setEnabled(ksettings.b_reconnectOnError); +// le_retries->setEnabled(ksettings.b_reconnectOnError); + cb_onerror->setChecked(ksettings.b_reconnectOnError); + + le_after->setValue(ksettings.reconnectTime); + le_retries->setValue(ksettings.reconnectRetries); + + cb_onbroken->setChecked(ksettings.b_reconnectOnBroken); + +// cb_autoresume->setChecked(KProtocolManager::autoResume()); + + le_nodata->setValue(ksettings.timeoutData); + le_noresume->setValue(ksettings.timeoutDataNoResume); + + cmb_type->setCurrentItem(ksettings.connectionType); + + if (cmb_type->currentItem() == 0) { + le_linknum->setValue(0); + lb_linknum->setEnabled(false); + le_linknum->setEnabled(false); + } else { + le_linknum->setValue(ksettings.linkNumber); + lb_linknum->setEnabled(true); + le_linknum->setEnabled(true); + } + + cb_offlinemode->setChecked(ksettings.b_offlineMode); + if (ksettings.connectionType == 0) + cb_offlinemode->setChecked(ksettings.b_offlineMode); + else { + cb_offlinemode->setEnabled(false); + cb_offlinemode->setChecked(false); + } +} + + +void DlgConnection::applyData() +{ + ksettings.b_reconnectOnError = cb_onerror->isChecked(); + ksettings.reconnectTime = le_after->value(); + ksettings.reconnectRetries = le_retries->value(); + ksettings.b_reconnectOnBroken = cb_onbroken->isChecked(); + + // KProtocolManager::setAutoResume(cb_autoresume->isChecked()); + + ksettings.timeoutData = le_nodata->value(); + ksettings.timeoutDataNoResume = le_noresume->value(); + + ksettings.connectionType = cmb_type->currentItem(); + ksettings.linkNumber = le_linknum->value(); + + if (cb_offlinemode->isChecked() != ksettings.b_offlineMode) { + kmain->slotToggleOfflineMode(); + } +} + +void DlgConnection::slotChanged() +{ + emit configChanged(); +} + +#include "dlgConnection.moc" diff --git a/kget/dlgConnection.h b/kget/dlgConnection.h new file mode 100644 index 00000000..0420b4f0 --- /dev/null +++ b/kget/dlgConnection.h @@ -0,0 +1,59 @@ +/*************************************************************************** +* dlgConnection.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _DLGCONNECTION_H +#define _DLGCONNECTION_H + +#include <qstringlist.h> + +#include "dlgconnectionbase.h" + +class DlgConnection : public DlgConnectionBase +{ + +Q_OBJECT public: + + DlgConnection(QWidget * parent); + ~DlgConnection() {} + void applyData(); + void setData(); + + int type() const + { + return cmb_type->currentItem(); + } + +signals: + void typeChanged(int type); + void configChanged(); + +protected slots: + void comboActivated(int Index); + void slotChanged(); +}; + +#endif // _DLGCONNECTION_H diff --git a/kget/dlgDirectories.cpp b/kget/dlgDirectories.cpp new file mode 100644 index 00000000..6c4c42e3 --- /dev/null +++ b/kget/dlgDirectories.cpp @@ -0,0 +1,203 @@ +/*************************************************************************** +* dlgDirectories.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qpushbutton.h> +#include <qtoolbutton.h> +#include <qlistview.h> + +#include <qdir.h> + +#include <kfiledialog.h> +#include <klineedit.h> +#include <kglobal.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kurlrequester.h> + +#include "settings.h" +#include "dlgDirectories.h" +#include <kapplication.h> + +DlgDirectories::DlgDirectories(QWidget * parent) + : DlgDirectoriesBase(parent) +{ + connect( le_ext, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotDirectoryChanged( ) ) ); + connect( le_dir, SIGNAL( textChanged ( const QString & ) ), this, SLOT( slotDirectoryChanged( ) ) ); + + le_dir->setMode( KFile::Directory ); + lv_entries->setSortColumn( -1 ); + + slotDirectoryChanged(); +} + +void DlgDirectories::slotDirectoryChanged( ) +{ + pb_add->setEnabled(!le_ext->text().isEmpty() &&!le_dir->url().isEmpty() ); +} + +void DlgDirectories::selectEntry(QListViewItem * item) +{ + if (item) { + le_ext->setText(item->text(0)); + le_dir->setURL(item->text(1)); + + } else { + le_ext->clear(); + le_dir->clear(); + } + updateUpDown(); +} + + +void DlgDirectories::updateUpDown() +{ + QListViewItem *item = lv_entries->selectedItem(); + + pb_up->setEnabled( item && item->itemAbove() ); + pb_down->setEnabled( item && item->itemBelow() ); +} + +void DlgDirectories::addEntry() +{ + QString ext = le_ext->text(); + QString dir = le_dir->url(); + + if (ext.contains(",") || dir.contains(",") || ext.isEmpty() || dir.isEmpty()) { + KMessageBox::error(this, i18n("Each row consists of exactly one\nextension type and one folder."), i18n("Error")); + return; + } + + QDir f(dir); + + if (!f.exists()) { + KMessageBox::error(this, i18n("Folder does not exist:\n%1").arg(dir), i18n("Error")); + return; + } + + new QListViewItem(lv_entries, ext, dir); + updateUpDown(); + + emit configChanged(); +} + + +void DlgDirectories::deleteEntry() +{ + QListViewItem *item = lv_entries->selectedItem(); + delete item; + updateUpDown(); + emit configChanged(); +} + + +void DlgDirectories::changeEntry() +{ + QListViewItem *old_item = lv_entries->selectedItem(); + + if (old_item) { + QString ext = le_ext->text(); + QString dir = le_dir->url(); + + if (ext.contains(",") || dir.contains(",") || ext.isEmpty() || dir.isEmpty()) { + KMessageBox::error(this, i18n("Each row consists of exactly one\nextension type and one folder."), i18n("Error")); + return; + } + + QDir f(dir); + + if (!f.exists()) { + KMessageBox::error(this, i18n("Folder does not exist:\n%1").arg(dir), i18n("Error")); + return; + } + + new QListViewItem(lv_entries, old_item, ext, dir); + delete old_item; + emit configChanged(); + } +} + + +void DlgDirectories::downEntry() +{ + QListViewItem *item = lv_entries->selectedItem(); + + if ( !item ) + return; + + item->moveItem( item->itemBelow() ); + + updateUpDown(); + emit configChanged(); +} + + +void DlgDirectories::upEntry() +{ + QListViewItem *item = lv_entries->selectedItem(); + + if ( !item || !item->itemAbove() ) + return; + + item->moveItem( item->itemAbove()->itemAbove() ); + + updateUpDown(); + emit configChanged(); +} + + +void DlgDirectories::setData() +{ + DirList::Iterator it; + + if (ksettings.defaultDirList.count() > 0) { + // we need to insert items in the reverse order + // because "new QListViewItem" puts itself at the beginning + for (it = ksettings.defaultDirList.fromLast(); it != ksettings.defaultDirList.begin(); it--) { + new QListViewItem(lv_entries, (*it).extRegexp, (*it).defaultDir); + } + new QListViewItem(lv_entries, (*it).extRegexp, (*it).defaultDir); + } +} + + +void DlgDirectories::applyData() +{ + ksettings.defaultDirList.clear(); + QListViewItemIterator it(lv_entries); + + for (; it.current(); ++it) { + QListViewItem *item = it.current(); + + DirItem ditem; + + ditem.extRegexp = item->text(0); + ditem.defaultDir = item->text(1); + ksettings.defaultDirList.append(ditem); + } +} + +#include "dlgDirectories.moc" diff --git a/kget/dlgDirectories.h b/kget/dlgDirectories.h new file mode 100644 index 00000000..deb403e3 --- /dev/null +++ b/kget/dlgDirectories.h @@ -0,0 +1,62 @@ +/*************************************************************************** +* dlgDirectories.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _DLGDIRECTORIES_H +#define _DLGDIRECTORIES_H + +#include "dlgdirectoriesbase.h" + +class DlgDirectories : public DlgDirectoriesBase +{ + +Q_OBJECT + +public: + + DlgDirectories(QWidget * parent); + ~DlgDirectories() {} + void applyData(); + void setData(); + +signals: + void configChanged(); + +protected slots: + void selectEntry(QListViewItem * item); + void addEntry(); + void deleteEntry(); + void changeEntry(); + + void upEntry(); + void downEntry(); + void slotDirectoryChanged( ); +protected: + void updateUpDown(); + +}; + +#endif // _DLGDIRECTORIES_H diff --git a/kget/dlgIndividual.cpp b/kget/dlgIndividual.cpp new file mode 100644 index 00000000..72fc6c7d --- /dev/null +++ b/kget/dlgIndividual.cpp @@ -0,0 +1,379 @@ +/*************************************************************************** +* dlgIndividual.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qlayout.h> + +#include "dockindividual.h" + +#include <qlabel.h> +#include <qtabwidget.h> +#include <kprogress.h> +#include <qtextedit.h> +#include <qcheckbox.h> +#include <kpushbutton.h> +#include <ksqueezedtextlabel.h> +#include <kdatetimewidget.h> + +#include <kapplication.h> +#include <kaction.h> +#include <klocale.h> +#include <ktoolbar.h> +#include <krun.h> +#include <kio/global.h> +#include "common.h" + +#include "transfer.h" + +#include "settings.h" +#include "dlgIndividual.h" + + +DlgIndividual::DlgIndividual(Transfer * _item) + : QWidget(0, "dialog", WDestructiveClose) +{ + item = _item; + + //create dock + m_pDockIndividual =new DockIndividual(this); + + + // Actions + + m_paDock = new KToggleAction(i18n("&Dock"),"tool_dock.png", 0, this, SLOT(slotToggleDock()), this, "dockIndividual"); + + + QVBoxLayout *topLayout = new QVBoxLayout( this, KDialog::marginHint(),KDialog::spacingHint() ); + topLayout->addStrut( 360 ); // makes dlg at least that wide + + QGridLayout *grid = new QGridLayout( 2, 3 ); + topLayout->addLayout(grid); + grid->addColSpacing(1, KDialog::spacingHint()); + + grid->addWidget(new QLabel(i18n("Source:"), this), 0, 0); + + sourceLabel = new KSqueezedTextLabel(this); + grid->addWidget(sourceLabel, 0, 2); + sourceLabel->setText(i18n("Source Label")); + grid->addWidget(new QLabel(i18n("Destination:"), this), 1, 0); + + destLabel = new KSqueezedTextLabel(this); + grid->addWidget(destLabel, 1, 2); + destLabel->setText(i18n("Source Label")); + + m_pProgressBar = new KProgress(this); + topLayout->addWidget( m_pProgressBar ); + + // processed info + QHBoxLayout *hBox = new QHBoxLayout(); + topLayout->addLayout(hBox); + + sizeLabel = new QLabel(this); + hBox->addWidget(sizeLabel); + resumeLabel = new QLabel(this); + hBox->addWidget(resumeLabel); + + speedLabel = new QLabel(this); + speedLabel->setText(i18n("0 B/s")); + topLayout->addWidget(speedLabel); + + // setup toolbar + KToolBar *toolBar = new KToolBar(this); + toolBar->setIconText(KToolBar::IconOnly); + toolBar->setBarPos(KToolBar::Bottom); + toolBar->setMovingEnabled(false); + toolBar->setFlat(true); + + topLayout->addWidget( toolBar ); + + // insert toolbar actions + item->m_paResume->plug(toolBar); + item->m_paPause->plug(toolBar); + item->m_paDelete->plug(toolBar); + + toolBar->insertLineSeparator(); + + item->m_paQueue->plug(toolBar); + item->m_paTimer->plug(toolBar); + item->m_paDelay->plug(toolBar); + + toolBar->insertLineSeparator(); + m_paDock->plug(toolBar); + + + + QCheckBox * keepOpen = new QCheckBox( i18n("&Keep this window open after the operation is complete."), this); + connect( keepOpen, SIGNAL( toggled(bool) ), SLOT( slotKeepOpenToggled(bool) ) ); + topLayout->addWidget(keepOpen); + + QFrame *line3 = new QFrame( this ); + line3->setFrameShape( QFrame::HLine ); + line3->setFrameShadow( QFrame::Sunken ); + topLayout->addWidget( line3 ); + + hBox = new QHBoxLayout(); + topLayout->addLayout(hBox); + + openFile = new KPushButton( i18n("Open &File"), this ); + connect( openFile, SIGNAL( clicked() ), SLOT( slotOpenFile() ) ); + hBox->addWidget( openFile ); + openFile->setEnabled(false); + + openLocation = new KPushButton( i18n("Open &Destination"), this ); + connect( openLocation, SIGNAL( clicked() ), SLOT( slotOpenLocation() ) ); + hBox->addWidget( openLocation ); + + hBox->addStretch(1); + + pbAdvanced = new KPushButton( i18n("Advanced"), this ); + + connect(pbAdvanced, SIGNAL(clicked()), SLOT(slotToggleAdvanced())); + + hBox->addWidget( pbAdvanced ); + + + // setup tab dialog + panelAdvanced = new QTabWidget(this); + + // if the time was already set somewhere in the future, keep it + // otherwise set it to the current time + QDateTime dt; + + if (item->getStartTime() < QDateTime::currentDateTime() && item->getMode() != Transfer::MD_SCHEDULED) + { + dt = QDateTime::currentDateTime(); + } + else + { + dt = item->getStartTime(); + } + + spins = new KDateTimeWidget(dt, this, "spins"); + + panelAdvanced->addTab(spins, i18n("Timer")); + panelAdvanced->hide(); + + connect(spins, SIGNAL(valueChanged(const QDateTime &)), item, SLOT(slotStartTime(const QDateTime &))); + + // adding item log + ml_log = new QTextEdit(panelAdvanced); + ml_log->setTextFormat(LogText); + ml_log->setReadOnly(true); + // ml_log->setFixedSize(sizeHint()); + ml_log->setVScrollBarMode(QScrollView::Auto); + ml_log->setWordWrap(QTextEdit::NoWrap); + + // ml_log->setSizePolicy(policy); + + panelAdvanced->addTab(ml_log, i18n("Log")); + // panelAdvanced->setFixedSize(sizeHint()); + + + + topLayout->addWidget(panelAdvanced); + advanced = ksettings.b_advancedIndividual; + slotToggleAdvanced(); + + resize( minimumSizeHint() ); + setMaximumHeight( height() ); + + //bool keepOpenChecked = false; + //bool noCaptionYet = true; + setCaption(i18n("Progress Dialog")); + + bKeepDlgOpen=false; +} + + +void DlgIndividual::setTotalSize(KIO::filesize_t bytes) +{ + m_iTotalSize = bytes; +} + + +void DlgIndividual::setPercent(unsigned long percent) +{ + m_pProgressBar->setValue(percent); + m_pDockIndividual->setValue(percent); + setCaption(i18n("%1% of %2 - %3").arg(percent).arg(KIO::convertSize(m_iTotalSize)).arg(m_location.fileName())); +} + + +void DlgIndividual::setProcessedSize(KIO::filesize_t bytes) +{ + sizeLabel->setText(i18n("%1 of %2").arg(KIO::convertSize(bytes)).arg(KIO::convertSize(m_iTotalSize))); +} + + +void DlgIndividual::setSpeed(QString speed) +{ + speedLabel->setText(speed); + m_pDockIndividual->setTip(speed); +} + + +void DlgIndividual::setCopying(const KURL & from, const KURL & to) +{ + m_location=to; + setCaption(m_location.fileName()); + + sourceLabel->setText(from.prettyURL()); + destLabel->setText(to.prettyURL()); +} + + +void DlgIndividual::setCanResume(bool resume) +{ + if (resume) + resumeLabel->setText(i18n("Resumed")); + else + resumeLabel->setText(i18n("Not resumed")); +} + +//void DlgIndividual::slotToggleAdvanced(bool advanced) +void DlgIndividual::slotToggleAdvanced() +{ +#ifdef _DEBUG + sDebugIn<<endl; +#endif + + if (advanced) + panelAdvanced->show(); + else + { + panelAdvanced->hide(); + adjustSize(); + } + advanced = !advanced; + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + +void DlgIndividual::slotToggleDock() +{ +#ifdef _DEBUG + sDebugIn<<endl; +#endif + + if (m_paDock->isChecked()) + { + m_pDockIndividual->show(); + hide(); + } + else + m_pDockIndividual->hide(); + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + + +/** Sets the whole log */ +void DlgIndividual::setLog(const QString & _msg) +{ + ml_log->setText(_msg); +} + +void DlgIndividual::appendLog(const QString & _msg) +{ + ml_log->append(_msg); +} + + +void DlgIndividual::slotKeepOpenToggled(bool bToggled) +{ +#ifdef _DEBUG + sDebugIn <<"bToggled= "<<bToggled<<endl; +#endif + + + bKeepDlgOpen=bToggled; + + if (!bKeepDlgOpen && item->getStatus()==Transfer::ST_FINISHED) + { + hide(); + m_pDockIndividual->hide(); + } + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + + +void DlgIndividual::slotOpenLocation() +{ +#ifdef _DEBUG + sDebugIn<<endl; +#endif + + KURL location=m_location; + location.setFileName(""); + kapp->invokeBrowser( location.url() ); + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + +void DlgIndividual::slotOpenFile() +{ +#ifdef _DEBUG + sDebugIn "Starting kfmclient with url "<<m_location.prettyURL()<<endl; +#endif + + (void) new KRun( m_location ); + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + + +void DlgIndividual::enableOpenFile() +{ +#ifdef _DEBUG + sDebugIn<<endl; +#endif + + + openFile->setEnabled(true); + + if (!bKeepDlgOpen) + { + hide(); + m_pDockIndividual->hide(); + } + +#ifdef _DEBUG + sDebugOut<<endl; +#endif +} + +#include "dlgIndividual.moc" diff --git a/kget/dlgIndividual.h b/kget/dlgIndividual.h new file mode 100644 index 00000000..73a233aa --- /dev/null +++ b/kget/dlgIndividual.h @@ -0,0 +1,115 @@ +/*************************************************************************** +* dlgIndividual.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#ifndef __dlgprogress_h__ +#define __dlgprogress_h__ + +#include <qdatetime.h> + +#include <qwidget.h> + +#include <kio/global.h> + +class Transfer; + +class QLabel; +class QRadioButton; +class QTabWidget; +class QTextEdit; +class QCheckBox; +class KPushButton; +class KProgress; +class KToggleAction; +class KDateTimeWidget; + +class DockIndividual; + +class DlgIndividual:public QWidget +{ +Q_OBJECT +public: + DlgIndividual(Transfer * _item); + ~DlgIndividual() + {} + void setLog(const QString & _msg); + void appendLog(const QString & _msg); + void enableOpenFile(); + +public slots: + void setTotalSize(KIO::filesize_t bytes); + + void setProcessedSize(KIO::filesize_t bytes); + + void setSpeed(QString speed); + void setPercent(unsigned long percent); + + void setCopying(const KURL & src, const KURL & dest); + void setCanResume(bool); + void slotKeepOpenToggled(bool); + void slotOpenLocation(); + void slotOpenFile(); + + bool keepDialogOpen() const { return bKeepDlgOpen; } + +protected slots: + void slotToggleAdvanced(); + void slotToggleDock(); + +protected: + QLabel *sourceLabel; + QLabel *destLabel; + QLabel *speedLabel; + QLabel *sizeLabel; + QLabel *resumeLabel; + QTextEdit *ml_log; + + KProgress *m_pProgressBar; + DockIndividual * m_pDockIndividual; + + KPushButton * openFile; + KPushButton * openLocation; + KPushButton * pbAdvanced ; + + QTabWidget * panelAdvanced; + KToggleAction * m_paDock; + + QDateTime qdt; + KDateTimeWidget *spins; + + Transfer *item; + + KURL m_location; + + bool bKeepDlgOpen; + + KIO::filesize_t m_iTotalSize; + + bool advanced; +} + +; + +#endif // __dlgprogress_h__ diff --git a/kget/dlgLimits.cpp b/kget/dlgLimits.cpp new file mode 100644 index 00000000..e31326c7 --- /dev/null +++ b/kget/dlgLimits.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +* dlgLimits.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qlabel.h> +#include <qlayout.h> + +#include <knuminput.h> +#include <klocale.h> +#include <kdialog.h> + +#include "settings.h" +#include "kmainwidget.h" +#include "dlgLimits.h" + + +DlgLimits::DlgLimits(QWidget * parent) + : DlgLimitsBase(parent) +{ + // TODO: these are not supported yet, so hide them + lb_maxband->hide(); + le_maxband->hide(); + lb_minband->hide(); + le_minband->hide(); +} + + +void DlgLimits::setData() +{ + le_maxnum->setValue(ksettings.maxSimultaneousConnections); + le_minband->setValue(ksettings.minimumBandwidth); + le_maxband->setValue(ksettings.maximumBandwidth); +} + + +void DlgLimits::applyData() +{ + ksettings.maxSimultaneousConnections = le_maxnum->value(); + ksettings.minimumBandwidth = le_minband->value(); + ksettings.maximumBandwidth = le_maxband->value(); + kmain->checkQueue(); +} + +void DlgLimits::slotChanged() +{ + emit configChanged(); +} + +#include "dlgLimits.moc" diff --git a/kget/dlgLimits.h b/kget/dlgLimits.h new file mode 100644 index 00000000..a020f221 --- /dev/null +++ b/kget/dlgLimits.h @@ -0,0 +1,51 @@ +/*************************************************************************** +* dlgLimits.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _DLGLIMITS_H +#define _DLGLIMITS_H + +#include "dlglimitsbase.h" + +class DlgLimits : public DlgLimitsBase +{ + +Q_OBJECT public: + + DlgLimits(QWidget * parent); + ~DlgLimits() {} + void applyData(); + void setData(); + +signals: + void configChanged(); + +protected slots: + void slotChanged(); + +}; + +#endif // _DLGLIMITS_H diff --git a/kget/dlgPreferences.cpp b/kget/dlgPreferences.cpp new file mode 100644 index 00000000..f35b8add --- /dev/null +++ b/kget/dlgPreferences.cpp @@ -0,0 +1,164 @@ +/*************************************************************************** +* dlgPreferences.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qlayout.h> + +#include <kapplication.h> +#include <klocale.h> +#include <kaction.h> +#include <kcombobox.h> + +#include "dlgConnection.h" +#include "dlgAutomation.h" +#include "dlgLimits.h" +#include "dlgAdvanced.h" +#include "dlgDirectories.h" +#include "dlgSystem.h" + +#include "settings.h" + +#ifdef index +#undef index +#endif + +#include "kmainwidget.h" +#include "dlgPreferences.h" + + +DlgPreferences::DlgPreferences(QWidget * parent): + KDialogBase(Tabbed, i18n("Configure"), Ok|Apply|Help|Cancel, Ok, parent, "DlgPreferences", true) +{ + // add pages + QFrame *page = addPage(i18n("Connection")); + QVBoxLayout *topLayout = new QVBoxLayout(page, 0, spacingHint()); + + conDlg = new DlgConnection(page); + topLayout->addWidget(conDlg); + + page = addPage(i18n("Automation")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + autDlg = new DlgAutomation(page); + topLayout->addWidget(autDlg); + topLayout->addStretch(); + + page = addPage(i18n("Limits")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + limDlg = new DlgLimits(page); + topLayout->addWidget(limDlg); + topLayout->addStretch(); + + page = addPage(i18n("Advanced")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + advDlg = new DlgAdvanced(page); + topLayout->addWidget(advDlg); + topLayout->addStretch(); + + // page = addPage(i18n("Search")); + // topLayout = new QVBoxLayout(page, 0, spacingHint()); + // seaDlg = new DlgSearch(page); + // topLayout->addWidget(seaDlg); + + page = addPage(i18n("Folders")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + dirDlg = new DlgDirectories(page); + topLayout->addWidget(dirDlg); + topLayout->addStretch(); + + page = addPage(i18n("System")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + sysDlg = new DlgSystem(page); + topLayout->addWidget(sysDlg); + topLayout->addStretch(); + + // type of connection influences autoDisconnect & timedDisconnect features + connect(conDlg, SIGNAL(typeChanged(int)), autDlg, SLOT(slotTypeChanged(int))); + + loadAllData(); + + connect( conDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); + connect( autDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); + connect( limDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); + connect( advDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); + connect( dirDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); + connect( sysDlg, SIGNAL( configChanged() ), this, SLOT( slotChanged() ) ); +} + + +void DlgPreferences::slotChanged() +{ + changed = true; + enableButton( Apply, true ); +} + +void DlgPreferences::applySettings() +{ + conDlg->applyData(); + autDlg->applyData(); + limDlg->applyData(); + advDlg->applyData(); + // seaDlg->applyData(); + dirDlg->applyData(); + sysDlg->applyData(); + + ksettings.save(); + changed = false; + enableButton( Apply, false ); +} + +void DlgPreferences::slotOk() +{ + if ( changed ) + applySettings(); + accept(); +} + +void DlgPreferences::slotCancel() +{ + if ( changed ) + loadAllData(); + reject(); +} + +void DlgPreferences::slotApply() +{ + applySettings(); +} + +void DlgPreferences::loadAllData() +{ + conDlg->setData(); + autDlg->setData(); + limDlg->setData(); + advDlg->setData(); + // seaDlg->setData(); + dirDlg->setData(); + sysDlg->setData(); + changed = false; + enableButton( Apply, false ); +} + +#include "dlgPreferences.moc" diff --git a/kget/dlgPreferences.h b/kget/dlgPreferences.h new file mode 100644 index 00000000..8e2e1307 --- /dev/null +++ b/kget/dlgPreferences.h @@ -0,0 +1,77 @@ +/*************************************************************************** +* dlgPreferences.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#ifndef _DLGPREFERENCES_H +#define _DLGPREFERENCES_H + +#include <qdialog.h> +#include <qstringlist.h> + +#include <kdialogbase.h> + +class DlgConnection; +class DlgAutomation; +class DlgLimits; +class DlgAdvanced; +class DlgSearch; +class DlgDirectories; +class DlgSystem; + + +class DlgPreferences:public KDialogBase +{ + +Q_OBJECT public: + + DlgPreferences(QWidget * parent); + ~DlgPreferences() + {} + +private: + + DlgConnection * conDlg; + DlgAutomation *autDlg; + DlgLimits *limDlg; + DlgAdvanced *advDlg; + + // DlgSearch *seaDlg; + DlgDirectories *dirDlg; + DlgSystem *sysDlg; + + bool changed; + + void loadAllData(); + +protected slots: + void applySettings(); + void slotChanged(); + virtual void slotOk(); + virtual void slotCancel(); + virtual void slotApply(); + +}; + +#endif // _DLGPREFERENCES_H diff --git a/kget/dlgSystem.cpp b/kget/dlgSystem.cpp new file mode 100644 index 00000000..d908724a --- /dev/null +++ b/kget/dlgSystem.cpp @@ -0,0 +1,77 @@ +/*************************************************************************** +* dlgSystem.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qcheckbox.h> +#include <qradiobutton.h> + +#ifdef index +#undef index +#endif + +#include <kfontrequester.h> + +#include "settings.h" +#include "kmainwidget.h" +#include "dlgSystem.h" + +#include <qbuttongroup.h> +#include <qlabel.h> + + +DlgSystem::DlgSystem(QWidget * parent) + : DlgSystemBase(parent) +{ + bg_window->hide(); + textLabel4->hide(); +} + + +void DlgSystem::setData() +{ + cb_useAnimation->setChecked(ksettings.b_useAnimation); + + le_font->setFont(ksettings.listViewFont); +} + + +void DlgSystem::applyData() +{ + if (cb_useAnimation->isChecked() != ksettings.b_useAnimation) + { + kmain->slotToggleAnimation(); + } + + ksettings.listViewFont = le_font->font(); + kmain->setListFont(); +} + +void DlgSystem::slotChanged() +{ + emit configChanged(); +} + +#include "dlgSystem.moc" diff --git a/kget/dlgSystem.h b/kget/dlgSystem.h new file mode 100644 index 00000000..677481b3 --- /dev/null +++ b/kget/dlgSystem.h @@ -0,0 +1,51 @@ +/*************************************************************************** +* dlgSystem.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + + + +#ifndef _DLGSYSTEM_H +#define _DLGSYSTEM_H + +#include "dlgsystembase.h" + +class DlgSystem : public DlgSystemBase +{ +Q_OBJECT public: + DlgSystem(QWidget * parent); + ~DlgSystem() {} + + void applyData(); + void setData(); + +signals: + void configChanged(); + +protected slots: + void slotChanged(); +}; + +#endif // _DLGSYSTEM_H diff --git a/kget/dlgadvancedbase.ui b/kget/dlgadvancedbase.ui new file mode 100644 index 00000000..dd9b5c59 --- /dev/null +++ b/kget/dlgadvancedbase.ui @@ -0,0 +1,274 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgAdvancedBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgAdvancedBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>368</width> + <height>285</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_advanced</cstring> + </property> + <property name="title"> + <string>Advanced Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lb_adding</cstring> + </property> + <property name="text"> + <string>Add new transfers as:</string> + </property> + </widget> + <spacer row="2" column="0"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QCheckBox" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_iconify</cstring> + </property> + <property name="text"> + <string>Iconified</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_advanced</cstring> + </property> + <property name="text"> + <string>Advanced individual windows</string> + </property> + </widget> + <widget class="QCheckBox" row="4" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_partial</cstring> + </property> + <property name="text"> + <string>Mark partial downloads</string> + </property> + </widget> + <widget class="QCheckBox" row="5" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_remove</cstring> + </property> + <property name="text"> + <string>Remove files from a list after success</string> + </property> + </widget> + <widget class="QCheckBox" row="6" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_getsizes</cstring> + </property> + <property name="text"> + <string>Get file sizes</string> + </property> + </widget> + <widget class="QCheckBox" row="7" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>cb_expertmode</cstring> + </property> + <property name="text"> + <string>Expert mode (do not prompt for Cancel or Delete)</string> + </property> + </widget> + <widget class="QCheckBox" row="8" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_konqiIntegration</cstring> + </property> + <property name="text"> + <string>Use KGet as Download Manager for Konqueror</string> + </property> + </widget> + <widget class="QCheckBox" row="9" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_ShowMain</cstring> + </property> + <property name="text"> + <string>Show main window at startup</string> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_individual</cstring> + </property> + <property name="text"> + <string>Show individual windows</string> + </property> + </widget> + <widget class="QButtonGroup" row="0" column="2"> + <property name="name"> + <cstring>bg_adding</cstring> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="frameShadow"> + <enum>Sunken</enum> + </property> + <property name="title"> + <string></string> + </property> + <property name="exclusive"> + <bool>false</bool> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>rb_queued</cstring> + </property> + <property name="text"> + <string>Queued</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>rb_delayed</cstring> + </property> + <property name="text"> + <string>Delayed</string> + </property> + </widget> + </hbox> + </widget> + <spacer row="0" column="3"> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>35</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>cb_ShowMain</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_advanced</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_expertmode</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_getsizes</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_iconify</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_individual</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_konqiIntegration</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_partial</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_remove</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>rb_delayed</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>rb_queued</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAdvancedBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_individual</sender> + <signal>toggled(bool)</signal> + <receiver>cb_iconify</receiver> + <slot>setEnabled(bool)</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">slotChanged()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/kget/dlgautomationbase.ui b/kget/dlgautomationbase.ui new file mode 100644 index 00000000..071a089b --- /dev/null +++ b/kget/dlgautomationbase.ui @@ -0,0 +1,256 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgAutomationBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgAutomationBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>401</width> + <height>217</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_automation</cstring> + </property> + <property name="title"> + <string>Automation Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KIntSpinBox" row="0" column="3"> + <property name="name"> + <cstring>le_autoSave</cstring> + </property> + <property name="suffix"> + <string> min</string> + </property> + <property name="maxValue"> + <number>3600</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>cb_autoDisconnect</cstring> + </property> + <property name="text"> + <string>Auto disconnect after completing downloads</string> + </property> + </widget> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_autoSave</cstring> + </property> + <property name="text"> + <string>Autosave file list every:</string> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_timedDisconnect</cstring> + </property> + <property name="text"> + <string>Timed disconnect</string> + </property> + </widget> + <widget class="QLabel" row="2" column="1" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lb_autoDisconnect</cstring> + </property> + <property name="text"> + <string>Disconnect command:</string> + </property> + </widget> + <widget class="KLineEdit" row="2" column="3"> + <property name="name"> + <cstring>le_autoDisconnect</cstring> + </property> + </widget> + <widget class="KDateTimeWidget" row="4" column="1" rowspan="1" colspan="3"> + <property name="name"> + <cstring>spins</cstring> + </property> + </widget> + <widget class="QCheckBox" row="6" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>cb_autoPaste</cstring> + </property> + <property name="text"> + <string>Auto paste from clipboard</string> + </property> + </widget> + <widget class="QCheckBox" row="5" column="0" rowspan="1" colspan="4"> + <property name="name"> + <cstring>cb_autoShutdown</cstring> + </property> + <property name="text"> + <string>Auto shutdown after completing downloads</string> + </property> + </widget> + <spacer row="0" column="2"> + <property name="name"> + <cstring>spacer18</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="0"> + <property name="name"> + <cstring>spacer16</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>50</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="4" column="0"> + <property name="name"> + <cstring>spacer17</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Preferred</enum> + </property> + <property name="sizeHint"> + <size> + <width>50</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>cb_autoDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>lb_autoDisconnect</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_autoDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>le_autoDisconnect</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_timedDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>spins</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_autoSave</sender> + <signal>toggled(bool)</signal> + <receiver>le_autoSave</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_autoSave</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_autoSave</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_autoDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_autoDisconnect</sender> + <signal>textChanged(const QString&)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_timedDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>spins</sender> + <signal>valueChanged(const QDateTime&)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_autoShutdown</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_autoPaste</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_autoDisconnect</sender> + <signal>toggled(bool)</signal> + <receiver>DlgAutomationBase</receiver> + <slot>disconnectToggled(bool)</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">slotChanged()</slot> + <slot access="protected" specifier="pure virtual">disconnectToggled(bool b)</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>kdatetimewidget.h</includehint> + <includehint>kdatewidget.h</includehint> + <includehint>ktimewidget.h</includehint> +</includehints> +</UI> diff --git a/kget/dlgconnectionbase.ui b/kget/dlgconnectionbase.ui new file mode 100644 index 00000000..fa9bc377 --- /dev/null +++ b/kget/dlgconnectionbase.ui @@ -0,0 +1,401 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgConnectionBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgConnectionBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>319</width> + <height>355</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_reconnect</cstring> + </property> + <property name="title"> + <string>Reconnect Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QCheckBox" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_onerror</cstring> + </property> + <property name="text"> + <string>On login or timeout error</string> + </property> + </widget> + <widget class="QLabel" row="2" column="1"> + <property name="name"> + <cstring>lb_after</cstring> + </property> + <property name="text"> + <string>Reconnect after:</string> + </property> + </widget> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lb_retries</cstring> + </property> + <property name="text"> + <string>Number of retries:</string> + </property> + </widget> + <widget class="KIntSpinBox" row="2" column="2"> + <property name="name"> + <cstring>le_after</cstring> + </property> + <property name="suffix"> + <string> min</string> + </property> + <property name="maxValue"> + <number>3600</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="KIntSpinBox" row="0" column="2"> + <property name="name"> + <cstring>le_retries</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QCheckBox" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>cb_onbroken</cstring> + </property> + <property name="text"> + <string>On broken connection</string> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="0"> + <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>40</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_timeout</cstring> + </property> + <property name="title"> + <string>Timeout Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer row="0" column="1" rowspan="1" colspan="2"> + <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>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="QLabel" row="0" column="0"> + <property name="name"> + <cstring>lb_nodata</cstring> + </property> + <property name="text"> + <string>If no data arrives in:</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>lb_cannot</cstring> + </property> + <property name="text"> + <string>If server cannot resume:</string> + </property> + </widget> + <spacer row="2" column="2"> + <property name="name"> + <cstring>spacer4</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="KIntSpinBox" row="2" column="3"> + <property name="name"> + <cstring>le_noresume</cstring> + </property> + <property name="suffix"> + <string> min</string> + </property> + <property name="maxValue"> + <number>3600</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>lb_or</cstring> + </property> + <property name="text"> + <string>or</string> + </property> + </widget> + <widget class="KIntSpinBox" row="0" column="3"> + <property name="name"> + <cstring>le_nodata</cstring> + </property> + <property name="suffix"> + <string> min</string> + </property> + <property name="maxValue"> + <number>3600</number> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + </grid> + </widget> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_type</cstring> + </property> + <property name="title"> + <string>Connection Type</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="KComboBox" row="0" column="0"> + <item> + <property name="text"> + <string>Permanent</string> + </property> + </item> + <item> + <property name="text"> + <string>Ethernet</string> + </property> + </item> + <item> + <property name="text"> + <string>PLIP</string> + </property> + </item> + <item> + <property name="text"> + <string>SLIP</string> + </property> + </item> + <item> + <property name="text"> + <string>PPP</string> + </property> + </item> + <item> + <property name="text"> + <string>ISDN</string> + </property> + </item> + <property name="name"> + <cstring>cmb_type</cstring> + </property> + </widget> + <widget class="QCheckBox" row="1" column="0"> + <property name="name"> + <cstring>cb_offlinemode</cstring> + </property> + <property name="text"> + <string>Offline mode</string> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer5</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> + <widget class="QLabel" row="0" column="2"> + <property name="name"> + <cstring>lb_linknum</cstring> + </property> + <property name="text"> + <string>Link number:</string> + </property> + </widget> + <widget class="KIntSpinBox" row="0" column="3"> + <property name="name"> + <cstring>le_linknum</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </grid> + </widget> + </vbox> +</widget> +<connections> + <connection> + <sender>cb_onerror</sender> + <signal>toggled(bool)</signal> + <receiver>lb_after</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_onerror</sender> + <signal>toggled(bool)</signal> + <receiver>le_after</receiver> + <slot>setEnabled(bool)</slot> + </connection> + <connection> + <sender>cb_onerror</sender> + <signal>toggled(bool)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_after</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_retries</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_onbroken</sender> + <signal>toggled(bool)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_nodata</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_noresume</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cmb_type</sender> + <signal>activated(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_linknum</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cb_offlinemode</sender> + <signal>toggled(bool)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>cmb_type</sender> + <signal>activated(int)</signal> + <receiver>DlgConnectionBase</receiver> + <slot>comboActivated(int)</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">slotChanged()</slot> + <slot access="protected" specifier="pure virtual">comboActivated(int)</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +</UI> diff --git a/kget/dlgdirectoriesbase.ui b/kget/dlgdirectoriesbase.ui new file mode 100644 index 00000000..ccad9d15 --- /dev/null +++ b/kget/dlgdirectoriesbase.ui @@ -0,0 +1,263 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgDirectoriesBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgDirectoriesBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>437</width> + <height>275</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QLayoutWidget" row="0" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout1</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QToolButton" row="2" column="1"> + <property name="name"> + <cstring>pb_down</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"down"</iconset> + </property> + </widget> + <spacer row="1" 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>20</width> + <height>40</height> + </size> + </property> + </spacer> + <widget class="QToolButton" row="0" column="1"> + <property name="name"> + <cstring>pb_up</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string></string> + </property> + <property name="iconSet"> + <iconset>"up"</iconset> + </property> + </widget> + <widget class="QListView" row="0" column="0" rowspan="3" colspan="1"> + <column> + <property name="text"> + <string>Extension</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Default Folder</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>lv_entries</cstring> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> + <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>layout12</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QPushButton"> + <property name="name"> + <cstring>pb_add</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>5</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Add</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>pb_delete</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>5</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Remove</string> + </property> + </widget> + <widget class="QPushButton"> + <property name="name"> + <cstring>pb_change</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>5</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Change</string> + </property> + </widget> + </hbox> + </widget> + <widget class="KLineEdit" row="2" column="0"> + <property name="name"> + <cstring>le_ext</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + <widget class="QLabel" row="1" column="0"> + <property name="name"> + <cstring>lb_ext</cstring> + </property> + <property name="text"> + <string>Extension (* for all files):</string> + </property> + </widget> + <widget class="KURLRequester" row="2" column="1"> + <property name="name"> + <cstring>le_dir</cstring> + </property> + </widget> + <widget class="QLabel" row="1" column="1"> + <property name="name"> + <cstring>lb_dir</cstring> + </property> + <property name="text"> + <string>Default folder:</string> + </property> + </widget> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>pb_down</sender> + <signal>clicked()</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>downEntry()</slot> + </connection> + <connection> + <sender>pb_up</sender> + <signal>clicked()</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>upEntry()</slot> + </connection> + <connection> + <sender>lv_entries</sender> + <signal>selectionChanged(QListViewItem*)</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>selectEntry(QListViewItem*)</slot> + </connection> + <connection> + <sender>pb_add</sender> + <signal>clicked()</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>addEntry()</slot> + </connection> + <connection> + <sender>pb_delete</sender> + <signal>clicked()</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>deleteEntry()</slot> + </connection> + <connection> + <sender>pb_change</sender> + <signal>clicked()</signal> + <receiver>DlgDirectoriesBase</receiver> + <slot>changeEntry()</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> + <include location="global" impldecl="in implementation">kiconloader.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">selectEntry(QListViewItem *)</slot> + <slot specifier="pure virtual">upEntry()</slot> + <slot>downEntry()</slot> + <slot>addEntry()</slot> + <slot>deleteEntry()</slot> + <slot>changeEntry()</slot> +</slots> +<pixmapfunction>BarIconSet</pixmapfunction> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>klineedit.h</includehint> + <includehint>kurlrequester.h</includehint> +</includehints> +</UI> diff --git a/kget/dlglimitsbase.ui b/kget/dlglimitsbase.ui new file mode 100644 index 00000000..faf2309f --- /dev/null +++ b/kget/dlglimitsbase.ui @@ -0,0 +1,189 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgLimitsBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgLimitsBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>568</width> + <height>141</height> + </rect> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QGroupBox"> + <property name="name"> + <cstring>gb_limits</cstring> + </property> + <property name="title"> + <string>Limits Options</string> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="QLabel" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>lbl_maxnum</cstring> + </property> + <property name="text"> + <string>Maximum open connections:</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0"> + <property name="name"> + <cstring>lb_minband</cstring> + </property> + <property name="text"> + <string>Minimum network bandwidth:</string> + </property> + </widget> + <widget class="QLabel" row="3" column="0"> + <property name="name"> + <cstring>lb_maxband</cstring> + </property> + <property name="text"> + <string>Maximum network bandwidth:</string> + </property> + </widget> + <widget class="KIntSpinBox" row="0" column="2"> + <property name="name"> + <cstring>le_maxnum</cstring> + </property> + <property name="minValue"> + <number>1</number> + </property> + </widget> + <widget class="KIntSpinBox" row="1" column="2" rowspan="2" colspan="1"> + <property name="name"> + <cstring>le_minband</cstring> + </property> + <property name="suffix"> + <string> bytes/sec</string> + </property> + <property name="maxValue"> + <number>100000</number> + </property> + <property name="minValue"> + <number>100</number> + </property> + <property name="lineStep"> + <number>100</number> + </property> + </widget> + <widget class="KIntSpinBox" row="3" column="2"> + <property name="name"> + <cstring>le_maxband</cstring> + </property> + <property name="suffix"> + <string> bytes/sec</string> + </property> + <property name="maxValue"> + <number>100000</number> + </property> + <property name="minValue"> + <number>100</number> + </property> + <property name="lineStep"> + <number>100</number> + </property> + </widget> + <spacer row="0" column="1"> + <property name="name"> + <cstring>spacer19</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="2" column="1"> + <property name="name"> + <cstring>spacer20</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="3" column="1"> + <property name="name"> + <cstring>spacer21</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </grid> + </widget> + </vbox> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>le_maxband</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgLimitsBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_maxnum</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgLimitsBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_minband</sender> + <signal>valueChanged(int)</signal> + <receiver>DlgLimitsBase</receiver> + <slot>slotChanged()</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">slotChanged()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> + <includehint>knuminput.h</includehint> +</includehints> +</UI> diff --git a/kget/dlgsystembase.ui b/kget/dlgsystembase.ui new file mode 100644 index 00000000..beee27eb --- /dev/null +++ b/kget/dlgsystembase.ui @@ -0,0 +1,169 @@ +<!DOCTYPE UI><UI version="3.2" stdsetdef="1"> +<class>DlgSystemBase</class> +<widget class="QWidget"> + <property name="name"> + <cstring>DlgSystemBase</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>389</width> + <height>137</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QCheckBox" row="0" column="0" rowspan="1" colspan="3"> + <property name="name"> + <cstring>cb_useAnimation</cstring> + </property> + <property name="text"> + <string>Use animation</string> + </property> + </widget> + <widget class="QLabel" row="1" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel4</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Window style:</string> + </property> + </widget> + <widget class="QLabel" row="2" column="0" rowspan="1" colspan="2"> + <property name="name"> + <cstring>textLabel5</cstring> + </property> + <property name="text"> + <string>Font:</string> + </property> + </widget> + <widget class="KFontRequester" row="2" column="2" rowspan="1" colspan="5"> + <property name="name"> + <cstring>le_font</cstring> + </property> + </widget> + <widget class="QButtonGroup" row="1" column="2" rowspan="1" colspan="4"> + <property name="name"> + <cstring>bg_window</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="frameShape"> + <enum>NoFrame</enum> + </property> + <property name="title"> + <string></string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <property name="margin"> + <number>0</number> + </property> + <widget class="QRadioButton"> + <property name="name"> + <cstring>rb_normal</cstring> + </property> + <property name="text"> + <string>Normal</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>rb_docked</cstring> + </property> + <property name="text"> + <string>Docked</string> + </property> + </widget> + <widget class="QRadioButton"> + <property name="name"> + <cstring>rb_droptarget</cstring> + </property> + <property name="text"> + <string>Drop target</string> + </property> + </widget> + </hbox> + </widget> + <spacer row="1" column="6"> + <property name="name"> + <cstring>spacer8</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <spacer row="3" column="0"> + <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>40</width> + <height>10</height> + </size> + </property> + </spacer> + </grid> +</widget> +<customwidgets> +</customwidgets> +<connections> + <connection> + <sender>cb_useAnimation</sender> + <signal>toggled(bool)</signal> + <receiver>DlgSystemBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>bg_window</sender> + <signal>toggled(bool)</signal> + <receiver>DlgSystemBase</receiver> + <slot>slotChanged()</slot> + </connection> + <connection> + <sender>le_font</sender> + <signal>fontSelected(const QFont&)</signal> + <receiver>DlgSystemBase</receiver> + <slot>slotChanged()</slot> + </connection> +</connections> +<includes> + <include location="global" impldecl="in implementation">kdialog.h</include> +</includes> +<slots> + <slot access="protected" specifier="pure virtual">slotChanged()</slot> +</slots> +<layoutdefaults spacing="6" margin="11"/> +<layoutfunctions spacing="KDialog::spacingHint" margin="KDialog::marginHint"/> +<includehints> + <includehint>kfontrequester.h</includehint> +</includehints> +</UI> diff --git a/kget/dockindividual.cpp b/kget/dockindividual.cpp new file mode 100644 index 00000000..1ecf61fa --- /dev/null +++ b/kget/dockindividual.cpp @@ -0,0 +1,99 @@ +/*************************************************************************** +* dockindividual.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <qtooltip.h> + +#include <kpopupmenu.h> + +#include "dockindividual.h" +DockIndividual::DockIndividual(QWidget *parent, const char *name ) : KSystemTray(parent,name) +{ + nPic=0; + setPixmap( loadIcon("bar0") ); +} + +DockIndividual::~DockIndividual() +{ + QToolTip::remove(this); +} + + +void DockIndividual::setValue(int value){ +#ifdef _DEBUG + //sDebugIn<<" value ="<<value<<endl; +#endif + int tmpPic=0; + if (value<20) + tmpPic=1; + else if(value<40) + tmpPic=2; + + else if(value<60) + tmpPic=3; + + else if(value<80) + tmpPic=4; + + else if(value<=95) + tmpPic=5; + + else if(value>=96) + tmpPic=6; + + if (tmpPic!=nPic) + { + nPic=tmpPic; + QString str = "bar" + QString::number( nPic ); + setPixmap( loadIcon( str ) ); + } + +#ifdef _DEBUG + //sDebugOut<<endl; +#endif +} + + + +void DockIndividual::setTip(const QString & _tip) +{ +#ifdef _DEBUG + //sDebugIn<<"_tip="<<_tip<<endl; +#endif + + + QToolTip::add( this, _tip ); + +#ifdef _DEBUG + //sDebugOut<<endl; +#endif +} + +#include "dockindividual.moc" +/** No descriptions */ +void DockIndividual::contextMenuAboutToShow ( KPopupMenu* menu ) +{ + menu->removeItemAt (3); +} diff --git a/kget/dockindividual.h b/kget/dockindividual.h new file mode 100644 index 00000000..39203272 --- /dev/null +++ b/kget/dockindividual.h @@ -0,0 +1,48 @@ +/*************************************************************************** +* dockindividual.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef DOCKINDIVIDUAL_H +#define DOCKINDIVIDUAL_H + +#include <ksystemtray.h> +#include "common.h" + +class KPopupMenu; + +class DockIndividual : public KSystemTray { + Q_OBJECT +public: + DockIndividual(QWidget *parent=0, const char *name=0); + ~DockIndividual(); + int nPic; + void setTip(const QString &); + void setValue(int value); + /** No descriptions */ + virtual void contextMenuAboutToShow ( KPopupMenu* menu ); +}; + +#endif diff --git a/kget/docking.cpp b/kget/docking.cpp new file mode 100644 index 00000000..cd3309c3 --- /dev/null +++ b/kget/docking.cpp @@ -0,0 +1,131 @@ +/*************************************************************************** +* docking.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <qtooltip.h> + +#include <kaboutdata.h> +#include <kapplication.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kpopupmenu.h> +#include <kurldrag.h> + +#include "kmainwidget.h" +#include "settings.h" +#include "docking.h" + + +DockWidget::DockWidget(KMainWidget * _parent):KSystemTray(_parent) +{ + parent = _parent; + + setPixmap( loadIcon( "kget_dock" )); + + // popup menu for right mouse button + KPopupMenu *popupMenu = contextMenu(); + parent->action("paste_transfer")->plug(popupMenu); + parent->action("drop_target")->plug(popupMenu); + parent->action("konqueror_integration")->plug(popupMenu); + popupMenu->insertSeparator(); + parent->m_paPreferences->plug(popupMenu); + + // Enable dropping + setAcceptDrops(true); + + dtip = new DynamicTip( this ); + dtip->setStatus( kapp->aboutData()->shortDescription() ); + +} + + +DockWidget::~DockWidget() +{ + delete dtip; + dtip = 0; +} + + +void DockWidget::dragEnterEvent(QDragEnterEvent * event) +{ + event->accept(KURLDrag::canDecode(event) + || QTextDrag::canDecode(event)); +} + + +void DockWidget::dropEvent(QDropEvent * event) +{ + KURL::List list; + QString str; + + if (KURLDrag::decode(event, list)) { + parent->addTransfers(list); + } else if (QTextDrag::decode(event, str)) { + parent->addTransfer(str); + } +} + + +void DockWidget::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == MidButton) { + parent->slotPasteTransfer(); + } else { + KSystemTray::mousePressEvent(e); + } +} + + +void DockWidget::updateToolTip( const QString& _status ) +{ + dtip->setStatus( _status ); +} + + +void DockWidget::changeIcon( const QString& icon ) +{ + setPixmap( loadIcon( icon )); +} + + +DynamicTip::DynamicTip( QWidget * parent ) + : QToolTip( parent ) +{ + // no explicit initialization needed +} + + +void DynamicTip::setStatus( const QString & _status ) +{ + status = _status; +} + +void DynamicTip::maybeTip( const QPoint & _pos ) +{ + QRect r( parentWidget()->rect() ); + tip( r, status ); +} + +#include "docking.moc" diff --git a/kget/docking.h b/kget/docking.h new file mode 100644 index 00000000..df4c75ec --- /dev/null +++ b/kget/docking.h @@ -0,0 +1,81 @@ +/*************************************************************************** +* docking.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + + +#ifndef _DOCKING_H_ +#define _DOCKING_H_ + +#include <stdio.h> + +#include <qdragobject.h> + +#include <ksystemtray.h> + +class KPopupMenu; +class KMainWidget; + +class DynamicTip : public QToolTip +{ + public: + DynamicTip( QWidget * parent ); + virtual ~DynamicTip() {}//TODO workaround for qt-bug, can be removed after 4.0 + void setStatus( const QString & _status ); + + protected: + void maybeTip( const QPoint & ); + + private: + QString status; +}; + +class DockWidget:public KSystemTray +{ + +Q_OBJECT public: + DockWidget(KMainWidget * parent); + ~DockWidget(); + /** No descriptions */ + void updateToolTip( const QString& ); + void changeIcon( const QString& ); + + + +private slots: + void mousePressEvent(QMouseEvent * e); + +protected: + // drag and drop + void dragEnterEvent(QDragEnterEvent *); + void dropEvent(QDropEvent *); + +private: + KMainWidget *parent; + DynamicTip * dtip; + +}; + +#endif diff --git a/kget/droptarget.cpp b/kget/droptarget.cpp new file mode 100644 index 00000000..97bb01e2 --- /dev/null +++ b/kget/droptarget.cpp @@ -0,0 +1,231 @@ +/*************************************************************************** +* droptarget.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <qpainter.h> + +#include <kaction.h> +#include <kapplication.h> +#include <kconfig.h> +#include <kiconloader.h> +#include <kglobalsettings.h> +#include <kmainwindow.h> +#include <kwin.h> +#include <klocale.h> +#include <kpopupmenu.h> +#include <kurldrag.h> + +#include "kmainwidget.h" +#include <qcursor.h> +#ifdef Q_WS_X11 +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <X11/Xos.h> +#include <X11/extensions/shape.h> +#undef Bool +#undef Status +#endif +#include "settings.h" +#include "droptarget.h" + +DropTarget::DropTarget(KMainWindow * mainWin):QWidget() +{ + int x = ksettings.dropPosition.x(); + int y = ksettings.dropPosition.y(); + + QRect desk = KGlobalSettings::desktopGeometry(this); + QPixmap bgnd = UserIcon( "target" ); + + if (x != -1 && + x >= desk.left() && y >= desk.top() && + (x + bgnd.width()) <= desk.right() && + (y + bgnd.height()) <= desk.bottom() ) + { + move(ksettings.dropPosition); + resize(bgnd.width(), bgnd.height()); + KWin::setState(winId(), ksettings.dropState); + } + else + { + setGeometry(desk.x()+200, desk.y()+200, bgnd.width(), bgnd.height()); + KWin::setState(winId(), NET::SkipTaskbar | NET::StaysOnTop); + } + + b_sticky = ksettings.dropState & NET::Sticky; + + // setup pixmaps + + if (!bgnd.mask()) + kdError(5001) << "Drop target pixmap has no mask!\n"; + else + mask = *bgnd.mask(); + + setBackgroundPixmap( bgnd ); + + // popup menu for right mouse button + popupMenu = new KPopupMenu(); + popupMenu->insertTitle(kapp->caption()); + popupMenu->setCheckable(true); + + pop_Max = popupMenu->insertItem(i18n("Maximize"), this, SLOT(toggleMinimizeRestore())); + pop_Min = popupMenu->insertItem(i18n("Minimize"), this, SLOT(toggleMinimizeRestore())); + + pop_sticky = popupMenu->insertItem(i18n("Sticky"), this, SLOT(toggleSticky())); + popupMenu->insertSeparator(); + mainWin->action("drop_target")->plug(popupMenu); + popupMenu->insertSeparator(); + + popupMenu->setItemChecked(pop_sticky, b_sticky); + kmain->m_paPreferences->plug(popupMenu); + popupMenu->insertSeparator(); + kmain->m_paQuit->plug(popupMenu); + + isdragging = false; + + // Enable dropping + setAcceptDrops(true); +} + + +DropTarget::~DropTarget() +{ + delete popupMenu; +} + + +void +DropTarget::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == LeftButton) + { + // toggleMinimizeRestore (); +// oldX = 0; +// oldY = 0; + isdragging = true; + dx = QCursor::pos().x() - pos().x(); + dy = QCursor::pos().y() - pos().y(); + } + else if (e->button() == RightButton) + { + popupMenu->setItemEnabled(pop_Min, kmain->isVisible()); + popupMenu->setItemEnabled(pop_Max, kmain->isHidden()); + + popupMenu->popup(QCursor::pos()); + } + else if (e->button() == MidButton) + { + kmain->slotPasteTransfer(); + } +} + + +void DropTarget::resizeEvent(QResizeEvent *) +{ +#ifdef Q_WS_X11 + XShapeCombineMask(x11Display(), winId(), ShapeBounding, 0, 0, mask.handle(), ShapeSet); +#endif +} + + +void DropTarget::dragEnterEvent(QDragEnterEvent * event) +{ + event->accept(KURLDrag::canDecode(event) + || QTextDrag::canDecode(event)); +} + + +void DropTarget::dropEvent(QDropEvent * event) +{ + KURL::List list; + QString str; + + if (KURLDrag::decode(event, list)) + { + kmain->addTransfers(list); + } + else if (QTextDrag::decode(event, str)) + { + kmain->addTransfer(str); + } +} + + +void DropTarget::toggleSticky() +{ + b_sticky = !b_sticky; + popupMenu->setItemChecked(pop_sticky, b_sticky); + updateStickyState(); +} + +void DropTarget::updateStickyState() +{ + if (b_sticky) + { + KWin::setState(winId(), NET::SkipTaskbar | NET::StaysOnTop | NET::Sticky); + } + else + { + KWin::clearState(winId(), NET::Sticky); + } +} + +void DropTarget::toggleMinimizeRestore() +{ + if (kmain->isVisible()) + kmain->hide(); + else + kmain->show(); +} + +/** No descriptions */ +void DropTarget::mouseMoveEvent(QMouseEvent * e) +{ +/* + if (oldX == 0) + { + oldX = e->x(); + oldY = e->y(); + return; + } ++*/ + if (isdragging) + move( QCursor::pos().x() - dx, QCursor::pos().y() - dy ); + +// move(x() + (e->x() - oldX), y() + (e->y() - oldY)); // <<-- +} + +void DropTarget::mouseReleaseEvent(QMouseEvent *) +{ + isdragging = false; +} + +/** No descriptions */ +void DropTarget::mouseDoubleClickEvent(QMouseEvent * e) +{ + if (e->button() == LeftButton) + toggleMinimizeRestore(); +} + +#include "droptarget.moc" diff --git a/kget/droptarget.h b/kget/droptarget.h new file mode 100644 index 00000000..debce208 --- /dev/null +++ b/kget/droptarget.h @@ -0,0 +1,87 @@ +/*************************************************************************** +* droptarget.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#ifndef _DROPTARGET_H +#define _DROPTARGET_H + +#include <qwidget.h> +#include <qbitmap.h> +#include <qdragobject.h> + +class KPopupMenu; +class KMainWidget; +class KMainWindow; + +class DropTarget:public QWidget +{ +Q_OBJECT + +public: + DropTarget(KMainWindow *); + ~DropTarget(); + + void updateStickyState(); + +protected: + virtual void resizeEvent(QResizeEvent *); + + // drag and drop + virtual void dragEnterEvent(QDragEnterEvent *); + /** No descriptions */ + virtual void mouseDoubleClickEvent(QMouseEvent * e); + virtual void dropEvent(QDropEvent *); + /** No descriptions */ + virtual void mouseMoveEvent(QMouseEvent *); + virtual void mousePressEvent(QMouseEvent * e); + virtual void mouseReleaseEvent(QMouseEvent *); + +private slots: + void toggleSticky(); + void toggleMinimizeRestore(); + +private: + KPopupMenu * popupMenu; + KMainWidget *parent; + + bool b_sticky; + + int pop_sticky; + int pop_Max; + int pop_Min; + + int size[4]; + + QBitmap mask; +public: // Public attributes + /** */ +// int oldX; +// int oldY; + int dx; + int dy; + bool isdragging; +}; + +#endif // _DROPTARGET_H diff --git a/kget/eventsrc b/kget/eventsrc new file mode 100644 index 00000000..98c9ab38 --- /dev/null +++ b/kget/eventsrc @@ -0,0 +1,360 @@ +[!Global!] +IconName=kget +Comment=KGet +Comment[bn]=কে-গেট +Comment[ne]=केडीई गेट +Comment[pa]=ਕੇ-ਗੈੱਟ +Comment[sv]=Kget + +[added] +Name=TransferAdded +Name[bg]=Нов файл за изтегляне +Name[ca]=Transferència afegida +Name[cs]=Přidán přenos +Name[el]=Προστέθηκε μεταφορά +Name[es]=TransferenciaAñadida +Name[et]=Ülekanne lisatud +Name[eu]=DeskargaGehituta +Name[fa]=انتقال افزوده +Name[fi]=SiirtoLisätty +Name[fr]=Transfert ajouté +Name[gl]=TransferenciaEngadida +Name[he]=העברה הוספה +Name[hu]=ÁtvittHozzáadva +Name[is]=Færslu bætt við +Name[it]=Aggiunto trasferimento +Name[ka]=ჩამოქაჩვა დაემატა +Name[kk]=Берілім қосылды +Name[km]=បានបន្ថែមការផ្ទេរ +Name[nds]=ÖverdregenToföögt +Name[ne]=स्थानान्तरण थपिएको +Name[nl]=OverdrachtToegevoegd +Name[pl]=Dodany transfer +Name[pt_BR]=TransferênciaAdicionada +Name[ru]=НовоеЗадание +Name[sk]=Pridaný transfer +Name[sl]=PrenosDodan +Name[sr]=Пренос додат +Name[sr@Latn]=Prenos dodat +Name[sv]=Överföring tillagd +Name[tr]=İndirme Eklendi +Name[uk]=Додано перенесення +Name[zh_CN]=添加了任务 +Name[zh_HK]=傳輸已新增 +Name[zh_TW]=新增傳輸 +Comment=A new download has been added +Comment[be]=Новы файл для сцягвання даданы ў чаргу +Comment[bg]=Добавен е нов файл за изтегляне +Comment[bn]=একটি নতুন ডাউনলোড যোগ করা হয়েছে +Comment[bs]=Dodan je novi download +Comment[ca]=S'ha afegit una descàrrega nova +Comment[cs]=Byl přidán nový přenos +Comment[da]=En ny download er blevet tilføjet +Comment[de]=Ein neuer Transfer wurde hinzugefügt +Comment[el]=Προστέθηκε μια νέα λήψη αρχείου +Comment[es]=Se ha añadido una nueva descarga +Comment[et]=Lisati uus allalaadimine +Comment[eu]=Deskarga berri bat gehitu da +Comment[fa]=بارگیری جدیدی اضافه شده است +Comment[fi]=Uusi tiedoston haku lisätty +Comment[fr]=Un nouveau téléchargement a été ajouté +Comment[gl]=Engadiuse unha nova descarga +Comment[he]=הורדה חדשה הוספה +Comment[hu]=Új letöltés lett megadva +Comment[is]=Nýju niðurhali hefur verið bætt við +Comment[it]=È stato aggiunto un nuovo scaricamento +Comment[ja]=新しいダウンロードが追加されました +Comment[ka]=ახალი ჩამოქაჩვა დაემატა +Comment[kk]=Жаңа жүктеп алу тапсырмасы қосылды +Comment[km]=បានបន្ថែមការទាញយកថ្មីមួយ +Comment[lt]=Pridėtas naujas atsisiuntimo įrašas +Comment[nb]=En ny nedlasting er lagt til +Comment[nds]=En niege Överdregen wöör toföögt +Comment[ne]=एउटा नयाँ डाउलोड थपिएको छ +Comment[nl]=Er is een nieuwe download toegevoegd +Comment[nn]=Ei ny nedlasting er lagd til +Comment[pl]=Nowe zlecenie pobrania pliku zostało dodane +Comment[pt]=Foi adicionada uma nova transferência +Comment[pt_BR]=Um novo download foi adicionado +Comment[ru]=Добавлено новое задание загрузки +Comment[sk]=Pridané nové sťahovanie +Comment[sl]=Dodan je bil nov prenos +Comment[sr]=Ново преузимање је додато +Comment[sr@Latn]=Novo preuzimanje je dodato +Comment[sv]=En ny nerladdning har lagts till +Comment[tr]=Yeni dosya eklendi +Comment[uk]=Додано нове звантаження +Comment[uz]=Yangi yozib olish qoʻshildi +Comment[uz@cyrillic]=Янги ёзиб олиш қўшилди +Comment[zh_CN]=添加了新下载 +Comment[zh_HK]=已新增新的下載 +Comment[zh_TW]=已增加新的下載 +default_sound=KGet_Added.ogg +default_presentation=17 + +[started] +Name=DownloadStarted +Name[bg]=Начало на изтегляне +Name[bn]=ডাউনলোড আরম্ভ +Name[br]=Kroget eo an enkargañ +Name[ca]=S'ha iniciat la descàrrega +Name[cs]=Stahování zahájeno +Name[el]=Εκκίνηση λήψης αρχείου +Name[es]=DescargaComenzada +Name[et]=Allalaadimine alustatud +Name[eu]=DeskargaHasita +Name[fa]=آغاز بارگیری +Name[fi]=HakuAlkoi +Name[fr]=Téléchargement démarré +Name[gl]=DescargaComezada +Name[he]=הורדההתחילה +Name[hu]=LetöltésKezdődött +Name[is]=Niðurhal sett í gang +Name[it]=Scaricamento avviato +Name[kk]=Жүктеп алу басталды +Name[km]=បានចាប់ផ្ដើមការទាញយក +Name[nb]=NedlastingStartet +Name[nds]=DaalladenHettStart +Name[ne]=डाउनलोड सुरु गरियो +Name[nl]=DownloadGestart +Name[nn]=NedlastingStarta +Name[pa]=ਡਾਊਨਲੋਡ ਸ਼ੁਰੂ +Name[pl]=Pobieranie rozpoczęte +Name[pt_BR]=DownloadIniciado +Name[ru]=ЗапускЗагрузки +Name[sk]=Spustené sťahovanie +Name[sl]=PrenosPričetek +Name[sr]=Преузимање покренуто +Name[sr@Latn]=Preuzimanje pokrenuto +Name[sv]=Nerladdning startad +Name[tr]=İndirme Başladı +Name[uk]=Почато звантаження +Name[zh_CN]=开始下载 +Name[zh_HK]=下載已開始 +Name[zh_TW]=開始下載 +Comment=Downloading started +Comment[be]=Сцягванне пачалося +Comment[bg]=Изтеглянето започна +Comment[bn]=ডাউনলোড আরম্ভ করল +Comment[br]=Kroget eo an enkargañ +Comment[bs]=Pokrenut download +Comment[ca]=S'ha iniciat la descàrrega +Comment[cs]=Bylo zahájeno stahování +Comment[da]=Download startet +Comment[de]=Herunterladen gestartet +Comment[el]=Η λήψη των αρχείων ξεκίνησε +Comment[es]=Una descarga comenzó +Comment[et]=Allalaadimine alustatud +Comment[eu]=Deskarga hasi da +Comment[fa]=بارگیری آغاز شد +Comment[fi]=Tiedoston hakeminen alkoi +Comment[fr]=Téléchargement démarré +Comment[gl]=Comezou a descarga +Comment[he]=ההורדה התחילה +Comment[hu]=Letöltés kezdődött +Comment[is]=Byrjað á niðurhali +Comment[it]=Scaricamento avviato +Comment[ja]=ダウンロード開始 +Comment[ka]=ჩამოქაჩვა დაიწყო +Comment[kk]=Жүктеп алу тапсырмасы басталды +Comment[km]=បានចាប់ផ្ដើមការទាញយក +Comment[lt]=Atsisiuntimas pradėtas +Comment[nb]=Nedlasting startet +Comment[nds]=Daalladen hett start +Comment[ne]=डाउनलोडिङ सुरु भयो +Comment[nl]=Downloaden is gestart +Comment[nn]=Nedlasting starta +Comment[pl]=Pobieranie pliku zostało rozpoczęte +Comment[pt]=Transferência iniciada +Comment[pt_BR]=Download iniciado +Comment[ru]=Загрузка выполняется +Comment[sk]=Spustené sťahovanie +Comment[sl]=Prenašanje se je pričelo +Comment[sr]=Покренуто је преузимање +Comment[sr@Latn]=Pokrenuto je preuzimanje +Comment[sv]=Nerladdning startad +Comment[tr]=Dosya indirme başladı +Comment[uk]=Звантаження почато +Comment[uz]=Yozib olish boshlandi +Comment[uz@cyrillic]=Ёзиб олиш бошланди +Comment[zh_CN]=下载已开始 +Comment[zh_HK]=下載已開始 +Comment[zh_TW]=開始下載 +default_sound=KGet_Started.ogg +default_presentation=16 + +[finished] +Name=DownloadFinished +Name[bg]=Край на изтегляне +Name[bn]=ডাউনলোড শেষ +Name[br]=Echu eo an enkargañ +Name[ca]=Ha acabat la descàrrega +Name[cs]=Stahování ukončeno +Name[el]=Η λήψη ολοκληρώθηκε +Name[es]=DescargaAcabada +Name[et]=Allalaadimine lõpetatud +Name[eu]=DeskargaAmaituta +Name[fa]=پایان بارگیری +Name[fi]=HakuValmistui +Name[fr]=Téléchargement terminé +Name[gl]=DescargaRematada +Name[he]=הורדההסתיימה +Name[hu]=LetöltésBefejezve +Name[is]=Niðurhali lokið +Name[it]=Scaricamento completato +Name[ka]=ჩამოქაჩვა დასრულდა +Name[kk]=Жүктеп алу аяқталды +Name[km]=បានបញ្ចប់ការទាញយក +Name[nb]=NedlastingFerdig +Name[nds]=DaaladenBeendt +Name[ne]=डाउनलोड समाप्त भयो +Name[nl]=DownloadVoltooid +Name[nn]=Nedlasting ferdig +Name[pa]=ਡਾਊਨਲੋਡ ਮੁਕੰਮਲ ਹੋਇਆ +Name[pl]=Pobieranie zakończone +Name[pt_BR]=DownloadConcluído +Name[ru]=ЗагрузкаЗавершена +Name[sk]=Sťahovanie ukončené +Name[sl]=PrenosKonec +Name[sr]=Преузимање завршено +Name[sr@Latn]=Preuzimanje završeno +Name[sv]=Nerladdning klar +Name[tr]=İndirme Bitti +Name[uk]=Звантаження завершено +Name[zh_CN]=下载完成 +Name[zh_HK]=下載已完成 +Name[zh_TW]=下載完成 +Comment=Downloading finished +Comment[be]=Сцягванне скончылася +Comment[bg]=Изтеглянето завърши +Comment[bn]=ডাউনলোড শেষ করল +Comment[br]=Echu eo an enkargañ +Comment[bs]=Završen download +Comment[ca]=Ha acabat la descàrrega +Comment[cs]=Stahování bylo dokončeno +Comment[da]=Download afsluttet +Comment[de]=Herunterladen abgeschlossen +Comment[el]=Η λήψη των αρχείων ολοκληρώθηκε +Comment[es]=Una descarga acabó +Comment[et]=Allalaadimine lõpetatud +Comment[eu]=Deskarga amaitu da +Comment[fa]=بارگیری پایان یافت +Comment[fi]=Tiedoston haku valmistui +Comment[fr]=Téléchargement terminé +Comment[gl]=Rematou a descarga +Comment[he]=ההורדה הסתיימה +Comment[hu]=Egy letöltés befejeződött +Comment[is]=Niðurhali lokið +Comment[it]=Scaricamento completato +Comment[ja]=ダウンロード完了 +Comment[ka]=ჩამოქაჩვა დასრულდა +Comment[kk]=Жүктеп алу тапсырмасы аяқталды +Comment[km]=បានបញ្ចប់ការទាញយក +Comment[lt]=Atsisiuntimas baigtas +Comment[nb]=Nedlasting ferdig +Comment[nds]=Daalladen beendt +Comment[ne]=डाउनलोडिङ समाप्त भयो +Comment[nl]=Downloaden is voltooid +Comment[nn]=Nedlasting ferdig +Comment[pl]=Pobieranie pliku zostało zakończone +Comment[pt]=Terminou uma transferência +Comment[pt_BR]=Download concluído +Comment[ru]=Загрузка завершена +Comment[sk]=Sťahovanie ukončené +Comment[sl]=Prenašanje se je zaključilo +Comment[sr]=Завршено је преузимање +Comment[sr@Latn]=Završeno je preuzimanje +Comment[sv]=Nerladdning klar +Comment[tr]=Dosya indirme tamamlandı +Comment[uk]=Звантаження завершено +Comment[uz]=Yozib olish tugadi +Comment[uz@cyrillic]=Ёзиб олиш тугади +Comment[zh_CN]=下载已完成 +Comment[zh_HK]=下載已完成 +Comment[zh_TW]=下載已完成 +default_sound=KGet_Finished.ogg +default_presentation=16 + +[finishedall] +Name=AddDownloadsFinished +Name[bg]=Всички файлове са изтеглени +Name[ca]=Han acabat totes les descàrregues +Name[cs]=Všechna stahování dokončena +Name[el]=Ολοκληρώθηκε η προσθήκη λήψεων +Name[es]=AñadirDescargasAcabadas +Name[et]=Kõik allalaadimised lõpetatud +Name[eu]=GehituDeskargakAmaituta +Name[fa]=پایان بارگیریهای افزوده +Name[fi]=LisääHautValmistui +Name[fr]=Téléchargements ajoutés terminés +Name[hu]=FelvettLetöltésBefejeződött +Name[is]=Lokið að bæta við niðurhölum +Name[it]=Aggiunti scaricamenti completati +Name[ja]=ダウンロード追加完了 +Name[kk]=Барлық жүктеу аяқталды +Name[km]=បានបញ្ចប់ការបន្ថែមការទាញយក +Name[nds]=AllDaalladenBeendt +Name[ne]=डाउनलोड थप्ने समाप्त भयो +Name[nl]=DownloadsToevoegenVoltooid +Name[pl]=Wszystkie transfery zakończone +Name[pt_BR]=AdicionaraosDonwloadsConcluídos +Name[ru]=ВсеЗагружено +Name[sk]=Pridanie sťahovania ukončené +Name[sl]=VsiPrenosiKonec +Name[sr]=Додавање преузимања завршено +Name[sr@Latn]=Dodavanje preuzimanja završeno +Name[sv]=Tillagda nerladdningar klara +Name[tr]=Biten İndirmelere Ekle +Name[uk]=Всі звантаження завершені +Name[zh_CN]=添加下载完成 +Name[zh_HK]=新增的下載已完成 +Name[zh_TW]=新增下載完成 +Comment=All downloads finished +Comment[be]=Усе файлы сцягнутыя +Comment[bg]=Изтеглянето на всичките файлове завърши +Comment[bn]=সব ডাউনলোড শেষ করল +Comment[bs]=Završeni svi downloadi +Comment[ca]=Han acabat totes les descàrregues +Comment[cs]=Všechna stahování byla dokončena +Comment[da]=Alle download afsluttet +Comment[de]=Alle Datentransfers sind abgeschlossen +Comment[el]=Ολοκληρώθηκαν όλες οι λήψεις +Comment[es]=Todas las descargas acabaron +Comment[et]=Kõik allalaadimised lõpetatud +Comment[eu]=Deskarga guztiak amaituta +Comment[fa]=همۀ بارگیریها پایان یافت +Comment[fi]=Kaikki tiedostojen haut ovat valmistuneet +Comment[fr]=Tous les téléchargements sont terminés +Comment[gl]=Tódalas descargar están rematadas +Comment[he]=כל ההורדות הסתיימו +Comment[hu]=Minden letöltés befejeződött +Comment[is]=Öllum niðurhölum lokið +Comment[it]=Tutti gli scaricamenti completati +Comment[ja]=すべてのダウンロードが完了 +Comment[ka]=ყველა ჩამოქაჩვა დასრულდა +Comment[kk]=Барлық жүктеу тапсырмалары аяқталды +Comment[km]=បានបញ្ចប់ការទាញយកទាំងអស់ +Comment[lt]=Visi atsisiuntimai baigti +Comment[nb]=Alle nedlastinger ferdig +Comment[nds]=All Daalladen beendt +Comment[ne]=सबै डाउनलोड समाप्त भयो +Comment[nl]=Alle downloads zijn voltooid +Comment[nn]=Alle nedlastingane er ferdige +Comment[pl]=Pobieranie wszystkich plików zostało zakończone +Comment[pt]=Todas as transferências terminaram +Comment[pt_BR]=Todos os downloads foram concluídos +Comment[ru]=Все загрузки выполнены. +Comment[sk]=Všetky sťahovania ukončené +Comment[sl]=Vsi prenosi so se zaključili +Comment[sr]=Сва преузимања су завршена +Comment[sr@Latn]=Sva preuzimanja su završena +Comment[sv]=Alla nerladdningar klara +Comment[tr]=Tüm dosyaların indirilmesi tamamlandı +Comment[uk]=Всі звантаження завершені +Comment[uz]=Hamma yozib olishlar tugadi +Comment[uz@cyrillic]=Ҳамма ёзиб олишлар тугади +Comment[zh_CN]=所有下载都已完成 +Comment[zh_HK]=所有下載已完成 +Comment[zh_TW]=所有下載皆已完成 +default_sound=KGet_Finished_All.ogg +default_presentation=16 diff --git a/kget/getfilejob.cpp b/kget/getfilejob.cpp new file mode 100644 index 00000000..3710dda1 --- /dev/null +++ b/kget/getfilejob.cpp @@ -0,0 +1,37 @@ +/*************************************************************************** + getfilejob.cpp - description + ------------------- + begin : Wed May 8 2002 + copyright : (C) 2002 by Patrick Charbonnier + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "getfilejob.h" + +namespace KIO +{ + + +GetFileJob::GetFileJob(const KURL & m_src, const KURL & m_dest):FileCopyJob(m_src, m_dest,-1, false, false, false, false) +{} + +GetFileJob::~GetFileJob() +{} + +/** Return true if the file has been resumed */ +bool GetFileJob::getCanResume()const +{ + return m_canResume; +} + + +} diff --git a/kget/getfilejob.h b/kget/getfilejob.h new file mode 100644 index 00000000..04c44258 --- /dev/null +++ b/kget/getfilejob.h @@ -0,0 +1,36 @@ +/*************************************************************************** + getfilejob.h - description + ------------------- + begin : Wed May 8 2002 + copyright : (C) 2002 by Patrick Charbonnier + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 GETFILEJOB_H +#define GETFILEJOB_H + +#include <kio/jobclasses.h> + + +namespace KIO +{ + +class GetFileJob:public FileCopyJob +{ +public: + GetFileJob(const KURL & m_src, const KURL & m_dest); + ~GetFileJob(); + bool getCanResume() const; +}; +} + +#endif diff --git a/kget/http_defaults.h b/kget/http_defaults.h new file mode 100644 index 00000000..2937dc5b --- /dev/null +++ b/kget/http_defaults.h @@ -0,0 +1,59 @@ +/*************************************************************************** +* http_defaults.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* +* email : [email protected] +* +***************************************************************************/ + +/* This file is part of the KDE libraries + Copyright (C) 2001 Waldo Bastian <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef _KIO_HTTP_SLAVE_DEFAULTS_H +#define _KIO_HTTP_SLAVE_DEFAULTS_H + +// CACHE SETTINGS +#define DEFAULT_MAX_CACHE_SIZE 5120 // 5 MB +#define DEFAULT_MAX_CACHE_AGE 60*60*24*14 // 14 DAYS +#define DEFAULT_CACHE_EXPIRE 10 // 10 SECS +#define DEFAULT_CLEAN_CACHE_INTERVAL 30*60 // 30 MINS +#define DEFAULT_CACHE_CONTROL KIO::CC_Verify // Verify with remote +#define CACHE_REVISION "7\n" // Cache version + +// DEFAULT USER AGENT KEY - ENABLES OS NAME +#define DEFAULT_USER_AGENT_KEYS "o" // Show OS + +// MAXIMUM AMOUNT OF DATA THAT CAN BE SAFELY SENT OVER IPC +#define MAX_IPC_SIZE 1024*8 + +// AMOUNT OF DATA TO OBTAIN FROM THE SERVER BY DEFAULT +#define DEFAULT_BUF_SIZE 1024*4 + +// SOME DEFAULT HEADER VALUES +#define DEFAULT_LANGUAGE_HEADER "en" +#define DEFAULT_MIME_TYPE "text/html" +#define DEFAULT_FULL_CHARSET_HEADER "iso-8859-1, utf-8, *" +#define DEFAULT_PARIAL_CHARSET_HEADER ", utf-8, *" + +#define DEFAULT_ACCEPT_HEADER "text/*, image/jpeg, image/png, image/*, */*" + +#endif diff --git a/kget/icons/Makefile.am b/kget/icons/Makefile.am new file mode 100644 index 00000000..9b3651ce --- /dev/null +++ b/kget/icons/Makefile.am @@ -0,0 +1,2 @@ +kgeticon_ICON = AUTO +kgeticondir = $(kde_datadir)/kget/icons diff --git a/kget/icons/cr22-action-bar0.png b/kget/icons/cr22-action-bar0.png Binary files differnew file mode 100644 index 00000000..234e8527 --- /dev/null +++ b/kget/icons/cr22-action-bar0.png diff --git a/kget/icons/cr22-action-bar1.png b/kget/icons/cr22-action-bar1.png Binary files differnew file mode 100644 index 00000000..ac7bd14c --- /dev/null +++ b/kget/icons/cr22-action-bar1.png diff --git a/kget/icons/cr22-action-bar2.png b/kget/icons/cr22-action-bar2.png Binary files differnew file mode 100644 index 00000000..ff6c7237 --- /dev/null +++ b/kget/icons/cr22-action-bar2.png diff --git a/kget/icons/cr22-action-bar3.png b/kget/icons/cr22-action-bar3.png Binary files differnew file mode 100644 index 00000000..c741bd4c --- /dev/null +++ b/kget/icons/cr22-action-bar3.png diff --git a/kget/icons/cr22-action-bar4.png b/kget/icons/cr22-action-bar4.png Binary files differnew file mode 100644 index 00000000..7390352c --- /dev/null +++ b/kget/icons/cr22-action-bar4.png diff --git a/kget/icons/cr22-action-bar5.png b/kget/icons/cr22-action-bar5.png Binary files differnew file mode 100644 index 00000000..418c1149 --- /dev/null +++ b/kget/icons/cr22-action-bar5.png diff --git a/kget/icons/cr22-action-bar6.png b/kget/icons/cr22-action-bar6.png Binary files differnew file mode 100644 index 00000000..930bd77a --- /dev/null +++ b/kget/icons/cr22-action-bar6.png diff --git a/kget/icons/cr22-action-kget_dock.png b/kget/icons/cr22-action-kget_dock.png Binary files differnew file mode 100644 index 00000000..6b0f14f3 --- /dev/null +++ b/kget/icons/cr22-action-kget_dock.png diff --git a/kget/icons/cr22-action-kget_dock_download.png b/kget/icons/cr22-action-kget_dock_download.png Binary files differnew file mode 100644 index 00000000..7242c864 --- /dev/null +++ b/kget/icons/cr22-action-kget_dock_download.png diff --git a/kget/icons/cr22-action-tool_clipboard.png b/kget/icons/cr22-action-tool_clipboard.png Binary files differnew file mode 100644 index 00000000..3695bdf0 --- /dev/null +++ b/kget/icons/cr22-action-tool_clipboard.png diff --git a/kget/icons/cr22-action-tool_delay.png b/kget/icons/cr22-action-tool_delay.png Binary files differnew file mode 100644 index 00000000..96919575 --- /dev/null +++ b/kget/icons/cr22-action-tool_delay.png diff --git a/kget/icons/cr22-action-tool_disconnect.png b/kget/icons/cr22-action-tool_disconnect.png Binary files differnew file mode 100644 index 00000000..437b9b6d --- /dev/null +++ b/kget/icons/cr22-action-tool_disconnect.png diff --git a/kget/icons/cr22-action-tool_dock.png b/kget/icons/cr22-action-tool_dock.png Binary files differnew file mode 100644 index 00000000..6dce81ca --- /dev/null +++ b/kget/icons/cr22-action-tool_dock.png diff --git a/kget/icons/cr22-action-tool_drop_target.png b/kget/icons/cr22-action-tool_drop_target.png Binary files differnew file mode 100644 index 00000000..6b0f14f3 --- /dev/null +++ b/kget/icons/cr22-action-tool_drop_target.png diff --git a/kget/icons/cr22-action-tool_expert.png b/kget/icons/cr22-action-tool_expert.png Binary files differnew file mode 100644 index 00000000..8e5a3472 --- /dev/null +++ b/kget/icons/cr22-action-tool_expert.png diff --git a/kget/icons/cr22-action-tool_logwindow.png b/kget/icons/cr22-action-tool_logwindow.png Binary files differnew file mode 100644 index 00000000..7596e67a --- /dev/null +++ b/kget/icons/cr22-action-tool_logwindow.png diff --git a/kget/icons/cr22-action-tool_normal.png b/kget/icons/cr22-action-tool_normal.png Binary files differnew file mode 100644 index 00000000..02511b78 --- /dev/null +++ b/kget/icons/cr22-action-tool_normal.png diff --git a/kget/icons/cr22-action-tool_offline_mode_off.png b/kget/icons/cr22-action-tool_offline_mode_off.png Binary files differnew file mode 100644 index 00000000..66c4e7f5 --- /dev/null +++ b/kget/icons/cr22-action-tool_offline_mode_off.png diff --git a/kget/icons/cr22-action-tool_offline_mode_on.png b/kget/icons/cr22-action-tool_offline_mode_on.png Binary files differnew file mode 100644 index 00000000..b98d1945 --- /dev/null +++ b/kget/icons/cr22-action-tool_offline_mode_on.png diff --git a/kget/icons/cr22-action-tool_pause.png b/kget/icons/cr22-action-tool_pause.png Binary files differnew file mode 100644 index 00000000..d529cee7 --- /dev/null +++ b/kget/icons/cr22-action-tool_pause.png diff --git a/kget/icons/cr22-action-tool_queue.png b/kget/icons/cr22-action-tool_queue.png Binary files differnew file mode 100644 index 00000000..43e2110e --- /dev/null +++ b/kget/icons/cr22-action-tool_queue.png diff --git a/kget/icons/cr22-action-tool_restart.png b/kget/icons/cr22-action-tool_restart.png Binary files differnew file mode 100644 index 00000000..3fa8db76 --- /dev/null +++ b/kget/icons/cr22-action-tool_restart.png diff --git a/kget/icons/cr22-action-tool_resume.png b/kget/icons/cr22-action-tool_resume.png Binary files differnew file mode 100644 index 00000000..1c71524e --- /dev/null +++ b/kget/icons/cr22-action-tool_resume.png diff --git a/kget/icons/cr22-action-tool_shutdown.png b/kget/icons/cr22-action-tool_shutdown.png Binary files differnew file mode 100644 index 00000000..119e5ef7 --- /dev/null +++ b/kget/icons/cr22-action-tool_shutdown.png diff --git a/kget/icons/cr22-action-tool_timer.png b/kget/icons/cr22-action-tool_timer.png Binary files differnew file mode 100644 index 00000000..e325e6ef --- /dev/null +++ b/kget/icons/cr22-action-tool_timer.png diff --git a/kget/icons/cr22-action-tool_uselastdir.png b/kget/icons/cr22-action-tool_uselastdir.png Binary files differnew file mode 100644 index 00000000..12f0413d --- /dev/null +++ b/kget/icons/cr22-action-tool_uselastdir.png diff --git a/kget/kfileio.cpp b/kget/kfileio.cpp new file mode 100644 index 00000000..bfd03864 --- /dev/null +++ b/kget/kfileio.cpp @@ -0,0 +1,174 @@ +/*************************************************************************** +* kfileio.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* +* email : [email protected] +* +***************************************************************************/ + +// Author: Stefan Taferner <[email protected]> + +#include <qapplication.h> +#include <qstring.h> +#include <unistd.h> +#include <string.h> +#include <assert.h> +#include <qfile.h> +#include <qfileinfo.h> + +#include <kdebug.h> +#include <klocale.h> +#include <kmessagebox.h> + +#include "kfileio.h" + +//----------------------------------------------------------------------------- +QString kFileToString(const QString & aFileName, bool aEnsureNL, bool aVerbose) +{ + QCString result; + + QFileInfo info(aFileName); + unsigned int readLen; + unsigned int len = info.size(); + QFile file(aFileName); + + // assert(aFileName!=NULL); + if (aFileName == NULL) + return ""; + + if (!info.exists()) { + if (aVerbose) + KMessageBox::error(qApp->mainWidget(), i18n("The specified file does not exist:\n%1").arg(aFileName)); + return QString::null; + } + if (info.isDir()) { + if (aVerbose) + KMessageBox::error(qApp->mainWidget(), i18n("This is a folder and not a file:\n%1").arg(aFileName)); + return QString::null; + } + if (!info.isReadable()) { + if (aVerbose) + KMessageBox::error(qApp->mainWidget(), i18n("You do not have read permission for the file:\n%1").arg(aFileName)); + return QString::null; + } + if (len <= 0) + return QString::null; + + if (!file.open(IO_Raw | IO_ReadOnly)) { + if (aVerbose) + switch (file.status()) { + case IO_ReadError: + KMessageBox::error(qApp->mainWidget(), i18n("Could not read file:\n%1").arg(aFileName)); + break; + case IO_OpenError: + KMessageBox::error(qApp->mainWidget(), i18n("Could not open file:\n%1").arg(aFileName)); + break; + default: + KMessageBox::error(qApp->mainWidget(), i18n("Error while reading file:\n%1").arg(aFileName)); + } + return QString::null; + } + + result.resize(len + (int) aEnsureNL + 1); + readLen = file.readBlock(result.data(), len); + if (aEnsureNL && result[len - 1] != '\n') { + result[len++] = '\n'; + readLen++; + } + result[len] = '\0'; + + if (readLen < len) { + QString msg = i18n("Could only read %1 bytes of %2.").arg(KGlobal::locale()->formatNumber(readLen, + 0)).arg(KGlobal::locale()->formatNumber(len, 0)); + + KMessageBox::error(qApp->mainWidget(), msg); + return QString::null; + } + + kdDebug() << "kFileToString: " << readLen << " bytes read" << endl; + return result; +} + + +//----------------------------------------------------------------------------- +static bool kBytesToFile(const char *aBuffer, int len, const QString & aFileName, bool aAskIfExists, bool aBackup, bool aVerbose) +{ + QFile file(aFileName); + QFileInfo info(aFileName); + int writeLen, rc; + + // assert(aFileName!=NULL); + if (aFileName.isNull()) + return false; + + if (info.exists()) { + if (aAskIfExists) { + QString str = i18n("File %1 exists.\nDo you want to replace it?").arg(aFileName); + + rc = KMessageBox::questionYesNo(qApp->mainWidget(), str, QString::null, i18n("Replace"),KStdGuiItem::cancel()); + if (rc != KMessageBox::Yes) + return FALSE; + } + if (aBackup) { + // make a backup copy + QString bakName = aFileName; + + bakName += '~'; + QFile::remove(bakName); + rc = rename(QFile::encodeName(aFileName), QFile::encodeName(bakName)); + if (rc) { + // failed to rename file + if (!aVerbose) + return FALSE; + rc = KMessageBox::warningContinueCancel(qApp->mainWidget(), i18n("Failed to make a backup copy of %1.\nContinue anyway?").arg(aFileName)); + if (rc != KMessageBox::Continue) + return FALSE; + } + } + } + + if (!file.open(IO_Raw | IO_WriteOnly)) { + if (aVerbose) + switch (file.status()) { + case IO_WriteError: + KMessageBox::error(qApp->mainWidget(), i18n("Could not write to file:\n%1").arg(aFileName)); + break; + case IO_OpenError: + KMessageBox::error(qApp->mainWidget(), i18n("Could not open file for writing:\n%1").arg(aFileName)); + break; + default: + KMessageBox::error(qApp->mainWidget(), i18n("Error while writing file:\n%1").arg(aFileName)); + } + return FALSE; + } + + writeLen = file.writeBlock(aBuffer, len); + + if (writeLen < 0) { + KMessageBox::error(qApp->mainWidget(), i18n("Could not write to file:\n%1").arg(aFileName)); + return FALSE; + } else if (writeLen < len) { + QString msg = i18n("Could only write %1 bytes of %2.").arg(KGlobal::locale()->formatNumber(writeLen, + 0)).arg(KGlobal::locale()->formatNumber(len, + 0)); + + KMessageBox::error(qApp->mainWidget(), msg); + return FALSE; + } + + return TRUE; +} + +bool kCStringToFile(const QCString & aBuffer, const QString & aFileName, bool aAskIfExists, bool aBackup, bool aVerbose) +{ + return kBytesToFile(aBuffer, aBuffer.length(), aFileName, aAskIfExists, aBackup, aVerbose); +} + +bool kByteArrayToFile(const QByteArray & aBuffer, const QString & aFileName, bool aAskIfExists, bool aBackup, bool aVerbose) +{ + return kBytesToFile(aBuffer, aBuffer.size(), aFileName, aAskIfExists, aBackup, aVerbose); +} diff --git a/kget/kfileio.h b/kget/kfileio.h new file mode 100644 index 00000000..9b2780ad --- /dev/null +++ b/kget/kfileio.h @@ -0,0 +1,44 @@ +/*************************************************************************** +* kfileio.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* +* email : [email protected] +* +***************************************************************************/ + +/* Load / save entire (local) files with nice diagnostics dialog messages. + * These functions load/save the whole buffer in one i/o call, so they + * should be pretty efficient. + * + * Author: Stefan Taferner <[email protected]> + * This code is under GPL. + */ +#ifndef kfileio_h +#define kfileio_h + +/** Load a file. Returns a pointer to the memory-block that contains + * the loaded file. Returns a NULL string if the file could not be loaded. + * If withDialogs is FALSE no warning dialogs are opened if there are + * problems. + * The string returned is always zero-terminated and therefore one + * byte longer than the file itself. + * If ensureNewline is TRUE the string will always have a trailing newline. + */ +QString kFileToString(const QString & fileName, bool ensureNewline = TRUE, bool withDialogs = TRUE); + +/** Save a file. If withDialogs is FALSE no warning dialogs are opened if + * there are problems. Returns TRUE on success and FALSE on failure. + * Replaces existing files without warning if askIfExists==FALSE. + * Makes a copy if the file exists to filename~ if createBackup==TRUE. + */ +bool kCStringToFile(const QCString & buffer, const QString & fileName, bool askIfExists = FALSE, bool createBackup = TRUE, bool withDialogs = TRUE); + +// Does not stop at NUL +bool kByteArrayToFile(const QByteArray & buffer, const QString & fileName, bool askIfExists = FALSE, bool createBackup = TRUE, bool withDialogs = TRUE); + + +#endif /* kfileio_h */ diff --git a/kget/kget.desktop b/kget/kget.desktop new file mode 100644 index 00000000..7230b416 --- /dev/null +++ b/kget/kget.desktop @@ -0,0 +1,77 @@ +# KDE Config File +[Desktop Entry] +Type=Application +Exec=kget -caption "%c" %i %m +Icon=kget +Terminal=false +Name=KGet +Name[ar]=ك.جيت +Name[bn]=কে-গেট +Name[cy]=KNôl +Name[eo]=Prenilo +Name[hi]=के-गेट +Name[ne]=केडीई गेट +Name[sv]=Kget +Name[ta]=கேகெட் +Name[th]=ดาวน์โหลด K +Name[ven]=Wana ha K +GenericName=Download Manager +GenericName[ar]=إدارة التحميل +GenericName[be]=Праграма сцягвання файлаў +GenericName[bg]=Изтегляне на файлове +GenericName[bn]=ডাউনলোড ম্যানেজার +GenericName[br]=Merour enkargañ +GenericName[bs]=Upravitelj downloadom +GenericName[ca]=Gestor de descàrregues +GenericName[cs]=Správce stahování +GenericName[cy]=Rheolydd Lawrlwytho +GenericName[da]=Håndtering af download +GenericName[de]=Datentransfer-Verwaltung +GenericName[el]=Διαχειριστής λήψεων αρχείων +GenericName[eo]=Elŝut-administrilo +GenericName[es]=Gestor de descargas +GenericName[et]=Allalaadimiste haldur +GenericName[eu]=Deskarga kudeatzailea +GenericName[fa]=مدیر بارگیری +GenericName[fi]=Tiedostonlataaja +GenericName[fr]=Gestionnaire de téléchargements +GenericName[ga]=Bainisteoir Thíosluchtaithe +GenericName[gl]=Xestor de Descargas +GenericName[he]=מנהל הורדות +GenericName[hi]=डाउनलोड प्रबंधक +GenericName[hr]=Upravitelj preuzimanja +GenericName[hu]=Letöltéskezelő +GenericName[is]=Niðurhalsstjóri +GenericName[it]=Gestore degli scaricamenti +GenericName[ja]=ダウンロードマネージャ +GenericName[ka]=ჩამოქაჩვათა მმართველი +GenericName[kk]=Жүкеп алу менеджері +GenericName[km]=កម្មវិធីគ្រប់គ្រងការទាញយក +GenericName[lt]=Siuntimų valdymas +GenericName[mk]=Менаџер за симнувања +GenericName[nb]=Nedlastingsbehandler +GenericName[nds]=Daallaadpleger +GenericName[ne]=डाउनलोड प्रबन्धक +GenericName[nl]=Downloadmanager +GenericName[nn]=Nedlastingshandsamar +GenericName[pa]=ਡਾਊਨਲੋਡ ਮੈਨੇਜਰ +GenericName[pl]=Menedżer pobierania +GenericName[pt]=Gestor de Transferências +GenericName[pt_BR]=Gerenciador de Download +GenericName[ru]=Диспетчер загрузок +GenericName[sk]=Správca sťahovania +GenericName[sl]=Upravitelj prenosov +GenericName[sr]=Менаџер преузимања +GenericName[sr@Latn]=Menadžer preuzimanja +GenericName[sv]=Nerladdningshanterare +GenericName[ta]=பதிவிறக்க மேலாளர் +GenericName[tg]=Мудири Боркунӣ +GenericName[tr]=İndirme Yöneticisi +GenericName[uk]=Менеджер звантажень +GenericName[uz]=Yozib olish boshqaruvchisi +GenericName[uz@cyrillic]=Ёзиб олиш бошқарувчиси +GenericName[zh_CN]=下载管理器 +GenericName[zh_HK]=下載管理員 +GenericName[zh_TW]=下載管理員 +Categories=Qt;KDE;Network;FileTransfer; +X-DCOP-ServiceType=Unique diff --git a/kget/kget_download.desktop b/kget/kget_download.desktop new file mode 100644 index 00000000..89654b8e --- /dev/null +++ b/kget/kget_download.desktop @@ -0,0 +1,57 @@ +[Desktop Entry] +Actions=KGetDownload; +Icon= +ServiceTypes=all/allfiles +ExcludeServiceTypes=kdedevice/* + +[Desktop Action KGetDownload] +Exec=kget %U +Icon=kget +Name=Download with KGet +Name[be]=Сцягнуць праз KGet +Name[bg]=Изтегляне с KGet +Name[bn]=কে-গেট দিয়ে ডাউনলোড +Name[br]=Enkargañ gant KGet +Name[bs]=Download sa KGet-om +Name[ca]=Descarrega amb el KGet +Name[cs]=Stáhnout pomocí KGet +Name[da]=Download med KGet +Name[de]=Mit KGet herunterladen +Name[el]=Λήψη αρχείου με το KGet +Name[es]=Descarga con KGet +Name[et]=Laadi alla KGeti abil +Name[eu]=Deskargatu KGet-ekin +Name[fa]=بارگیری با KGet +Name[fi]=Hae KGet ohjelmalla +Name[fr]=Télécharger avec KGet +Name[ga]=Íosluchtaigh le KGet +Name[gl]=Descargar con KGet +Name[he]=הורד בעזרת KGet +Name[hu]=Letöltés a KGettel +Name[is]=Sækja með KGet +Name[it]=Scarica con KGet +Name[ja]=KGet でダウンロード +Name[ka]=KGet-ით ჩამოქაჩვა +Name[kk]=KGet көмегімен жүктеп алу +Name[km]=ទាញយកដោយប្រើ KGet +Name[lt]=Atsisiųsti su KGet +Name[nb]=Nedlasting med KGet +Name[nds]=Dalladen mit KGet +Name[ne]=केडीई गेटसँग डाउनलोड गर्नुहोस् +Name[nl]=Met KGet downloaden +Name[nn]=Last ned med KGet +Name[pa]=KGet ਨਾਲ ਡਾਊਨਲੋਡ +Name[pl]=Pobierz za pomocą KGet +Name[pt]=Obter com o KGet +Name[pt_BR]=Baixar com o KGet +Name[ru]=Загрузить с помощью KGet +Name[sk]=Stiahnuť pomocou KGet +Name[sl]=Prenos s KGet +Name[sr]=Преузми са KGet-ом +Name[sr@Latn]=Preuzmi sa KGet-om +Name[sv]=Ladda ner med Kget +Name[tr]=KGet ile İndir +Name[uk]=Звантажити з KGet +Name[zh_CN]=用 KGet 下载 +Name[zh_HK]=以 KGet 下載 +Name[zh_TW]=用 KGet 下載 diff --git a/kget/kget_iface.h b/kget/kget_iface.h new file mode 100644 index 00000000..015bef2f --- /dev/null +++ b/kget/kget_iface.h @@ -0,0 +1,37 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer <[email protected]> +** +****************************************************************************/ + +#ifndef KGET_IFACE_H +#define KGET_IFACE_H + +#include <dcopobject.h> +#include <kurl.h> + +class KGetIface : public DCOPObject +{ + K_DCOP + +protected: + KGetIface( QCString objId ) : DCOPObject( objId ) {} + +k_dcop: + /** + * @param src The urls to download + * @param destDir The destination direction or QString::null if unspecified + */ + virtual ASYNC addTransfers( const KURL::List& src, const QString& destDir = QString::null ) = 0; + + virtual bool isDropTargetVisible() const = 0; + + virtual void setDropTargetVisible( bool setVisible ) = 0; + + virtual void setOfflineMode( bool offline ) = 0; + + virtual bool isOfflineMode() const = 0; +}; + +#endif // KGET_IFACE_H diff --git a/kget/kget_plug_in/Makefile.am b/kget/kget_plug_in/Makefile.am new file mode 100644 index 00000000..4e2afd67 --- /dev/null +++ b/kget/kget_plug_in/Makefile.am @@ -0,0 +1,13 @@ +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = khtml_kget.la + +khtml_kget_la_METASOURCES = AUTO +khtml_kget_la_SOURCES = kget_plug_in.cpp kget_linkview.cpp links.cpp +khtml_kget_la_LIBADD = $(LIB_KHTML) +khtml_kget_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module + +KDE_ICON = AUTO + +part_DATA = kget_plug_in.rc kget_plug_in.desktop +partdir = $(kde_datadir)/khtml/kpartplugins diff --git a/kget/kget_plug_in/cr22-action-khtml_kget.png b/kget/kget_plug_in/cr22-action-khtml_kget.png Binary files differnew file mode 100644 index 00000000..6b0f14f3 --- /dev/null +++ b/kget/kget_plug_in/cr22-action-khtml_kget.png diff --git a/kget/kget_plug_in/kget_linkview.cpp b/kget/kget_plug_in/kget_linkview.cpp new file mode 100644 index 00000000..179cc81b --- /dev/null +++ b/kget/kget_plug_in/kget_linkview.cpp @@ -0,0 +1,150 @@ +#include "kget_linkview.h" + +#include <qlayout.h> + +#include <dcopclient.h> +#include <kaction.h> +#include <kapplication.h> +#include <kiconloader.h> +#include <klistviewsearchline.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kprocess.h> +#include <kstdaction.h> +#include <ktoolbar.h> + +#define COL_NAME 0 +#define COL_DESC 1 +#define COL_MIME 2 +#define COL_URL 3 + +LinkViewItem::LinkViewItem( QListView *parent, const LinkItem *lnk ) + : QListViewItem( parent ), + link( lnk ) +{ + QString file = link->url.fileName(); + if ( file.isEmpty() ) + file = link->url.host(); + + setPixmap( COL_NAME, SmallIcon( link->icon ) ); + setText( COL_NAME, file ); + + setText( COL_DESC, link->text ); + setText( COL_MIME, link->mimeType ); + setText( COL_URL, link->url.prettyURL() ); +} + +/////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////// + +KGetLinkView::KGetLinkView( QWidget *parent, const char *name ) + : KMainWindow( parent, name ) +{ + setPlainCaption( i18n( "KGet" ) ); + + KAction* actionDownload = new KAction( i18n("Download Selected Files"), + "kget", CTRL+Key_D, + this, SLOT( slotStartLeech() ), + actionCollection(), "startDownload" ); + + KAction* actionSelectAll = KStdAction::selectAll( this, SLOT( slotSelectAll() ), + actionCollection() ); + + m_links.setAutoDelete( true ); + actionDownload->plug( toolBar() ); + toolBar()->insertLineSeparator(); + actionSelectAll->plug( toolBar() ); + + QWidget *mainWidget = new QWidget( this ); + QVBoxLayout *layout = new QVBoxLayout( mainWidget ); + setCentralWidget( mainWidget ); + + m_view = new KListView( mainWidget, "listview" ); + m_view->setSelectionMode( QListView::Extended ); + m_view->addColumn( i18n("File Name") ); + m_view->addColumn( i18n("Description") ); + m_view->addColumn( i18n("File Type") ); + m_view->addColumn( i18n("Location (URL)") ); + m_view->setShowSortIndicator( true ); + + KListViewSearchLineWidget *line = new KListViewSearchLineWidget( m_view, mainWidget, "search line" ); + layout->addWidget( line ); + layout->addWidget( m_view ); + + // setting a fixed (not floating) toolbar + toolBar()->setMovingEnabled( false ); + // setting Text next to Icons + toolBar()->setIconText( KToolBar::IconTextRight ); +} + +KGetLinkView::~KGetLinkView() +{ +} + +void KGetLinkView::setLinks( QPtrList<LinkItem>& links ) +{ + m_links = links; // now we 0wn them + showLinks( m_links ); +} + +void KGetLinkView::showLinks( const QPtrList<LinkItem>& links ) +{ + m_view->clear(); + + QPtrListIterator<LinkItem> it( links ); + for ( ; it.current(); ++it ) + (void) new LinkViewItem( m_view, *it ); + + m_view->sort(); +} + +void KGetLinkView::slotStartLeech() +{ + KURL::List urls; + QListViewItemIterator it( m_view->firstChild() ); + for ( ; it.current(); ++it ) + { + if ( it.current()->isSelected() ) + urls.append( static_cast<LinkViewItem*>( it.current() )->link->url ); + } + + if ( urls.isEmpty() ) + KMessageBox::sorry( this, + i18n("You did not select any files to download."), + i18n("No Files Selected") ); + else + { + DCOPClient* p_dcopServer = new DCOPClient(); + p_dcopServer->attach(); + + if ( !p_dcopServer->isApplicationRegistered( "kget" ) ) + { + KApplication::startServiceByDesktopName( "kget" ); + } + kapp->updateRemoteUserTimestamp( "kget" ); + + QByteArray data; + QDataStream stream( data, IO_WriteOnly ); + stream << urls << QString::null; + bool ok = DCOPClient::mainClient()->send( "kget", "KGet-Interface", + "addTransfers(KURL::List, QString)", + data ); + + kdDebug() << "*** startDownload: " << ok << endl; + + p_dcopServer->detach(); + delete p_dcopServer; + } +} + +void KGetLinkView::setPageURL( const QString& url ) +{ + setPlainCaption( i18n( "Links in: %1 - KGet" ).arg( url ) ); +} + +void KGetLinkView::slotSelectAll() +{ + m_view->selectAll( true ); +} + +#include "kget_linkview.moc" diff --git a/kget/kget_plug_in/kget_linkview.h b/kget/kget_plug_in/kget_linkview.h new file mode 100644 index 00000000..a6d7961c --- /dev/null +++ b/kget/kget_plug_in/kget_linkview.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer <[email protected]> +** +****************************************************************************/ + +#ifndef KGET_LINKVIEW_H +#define KGET_LINKVIEW_H + +#include <qptrlist.h> + +#include <klistview.h> +#include <kmainwindow.h> +#include <kurl.h> + +#include "links.h" + +class LinkViewItem : public QListViewItem +{ +public: + LinkViewItem( QListView *parent, const LinkItem * lnk ); + const LinkItem *link; +}; + + +class KGetLinkView : public KMainWindow +{ + Q_OBJECT + +public: + KGetLinkView( QWidget *parent = 0L, const char *name = 0L ); + ~KGetLinkView(); + + void setLinks( QPtrList<LinkItem>& links ); + void setPageURL( const QString& url ); + +signals: + void leechURLs( const KURL::List& urls ); + +private slots: + void slotStartLeech(); + void slotSelectAll(); + +private: + void showLinks( const QPtrList<LinkItem>& links ); + + QPtrList<LinkItem> m_links; + + KListView *m_view; + +}; + +#endif // KGET_LINKVIEW_H diff --git a/kget/kget_plug_in/kget_plug_in.cpp b/kget/kget_plug_in/kget_plug_in.cpp new file mode 100644 index 00000000..dc5f5b9f --- /dev/null +++ b/kget/kget_plug_in/kget_plug_in.cpp @@ -0,0 +1,189 @@ +/*************************************************************************** + kget_plug_in.cpp - description + ------------------- + begin : Wed Jul 3 22:09:28 CEST 2002 + copyright : (C) 2002 by Patrick + email : [email protected] + + Copyright (C) 2002 Carsten Pfeiffer <[email protected]> + + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 "kget_plug_in.h" + +#include <dcopref.h> +#include <kdatastream.h> +#include <kdebug.h> +#include <khtml_part.h> +#include <kiconloader.h> +#include <kglobal.h> +#include <kaction.h> +#include <kinstance.h> +#include <klocale.h> +#include <kmessagebox.h> +#include <kpopupmenu.h> +#include <krun.h> + +#include <dom/html_document.h> +#include <dom/html_misc.h> +#include <dom/dom_element.h> + +#include <kparts/partmanager.h> + +#include <set> + +#include "links.h" +#include "kget_linkview.h" + +KGet_plug_in::KGet_plug_in( QObject* parent, const char* name ) + : Plugin( parent, name ) +{ + QPixmap pix = KGlobal::iconLoader()->loadIcon("kget", + KIcon::MainToolbar); + KActionMenu *menu = new KActionMenu( i18n("Download Manager"), pix, + actionCollection(), "kget_menu" ); + menu->setDelayed( false ); + connect( menu->popupMenu(), SIGNAL( aboutToShow() ), SLOT( showPopup() )); + + m_paToggleDropTarget=new KToggleAction(i18n("Show Drop Target"), + KShortcut(), + this, SLOT(slotShowDrop()), + actionCollection(), "show_drop" ); + + menu->insert( m_paToggleDropTarget ); + + KAction *action = new KAction(i18n("List All Links"), KShortcut(), + this, SLOT( slotShowLinks() ), + actionCollection(), "show_links"); + menu->insert( action ); + + p_dcopServer= new DCOPClient(); + p_dcopServer->attach (); +} + + +KGet_plug_in::~KGet_plug_in() +{ + p_dcopServer->detach(); + delete p_dcopServer; +} + + +void KGet_plug_in::showPopup() +{ + bool hasDropTarget = false; + + if (p_dcopServer->isApplicationRegistered ("kget")) + { + DCOPRef kget( "kget", "KGet-Interface" ); + hasDropTarget = kget.call( "isDropTargetVisible" ); + } + + m_paToggleDropTarget->setChecked( hasDropTarget ); +} + +void KGet_plug_in::slotShowDrop() +{ + if (!p_dcopServer->isApplicationRegistered ("kget")) + KRun::runCommand("kget --showDropTarget"); + else + { + DCOPRef kget( "kget", "KGet-Interface" ); + kget.send( "setDropTargetVisible", m_paToggleDropTarget->isChecked()); + } +} + +void KGet_plug_in::slotShowLinks() +{ + if ( !parent() || !parent()->inherits( "KHTMLPart" ) ) + return; + + KHTMLPart *htmlPart = static_cast<KHTMLPart*>( parent() ); + KParts::Part *activePart = 0L; + if ( htmlPart->partManager() ) + { + activePart = htmlPart->partManager()->activePart(); + if ( activePart && activePart->inherits( "KHTMLPart" ) ) + htmlPart = static_cast<KHTMLPart*>( activePart ); + } + + DOM::HTMLDocument doc = htmlPart->htmlDocument(); + if ( doc.isNull() ) + return; + + DOM::HTMLCollection links = doc.links(); + + QPtrList<LinkItem> linkList; + std::set<QString> dupeCheck; + for ( uint i = 0; i < links.length(); i++ ) + { + DOM::Node link = links.item( i ); + if ( link.isNull() || link.nodeType() != DOM::Node::ELEMENT_NODE ) + continue; + + LinkItem *item = new LinkItem( (DOM::Element) link ); + if ( item->isValid() && + dupeCheck.find( item->url.url() ) == dupeCheck.end() ) + { + linkList.append( item ); + dupeCheck.insert( item->url.url() ); + } + else + delete item; + } + + if ( linkList.isEmpty() ) + { + KMessageBox::sorry( htmlPart->widget(), + i18n("There are no links in the active frame of the current HTML page."), + i18n("No Links") ); + return; + } + + KGetLinkView *view = new KGetLinkView(); + QString url = doc.URL().string(); + view->setPageURL( url ); + + view->setLinks( linkList ); + view->show(); +} + +KPluginFactory::KPluginFactory( QObject* parent, const char* name ) + : KLibFactory( parent, name ) +{ + s_instance = new KInstance("KPluginFactory"); +} + +QObject* KPluginFactory::createObject( QObject* parent, const char* name, const char*, const QStringList & ) +{ + QObject *obj = new KGet_plug_in( parent, name ); + return obj; +} + +KPluginFactory::~KPluginFactory() +{ + delete s_instance; +} + +extern "C" +{ + KDE_EXPORT void* init_khtml_kget() + { + KGlobal::locale()->insertCatalogue("kget"); + return new KPluginFactory; + } + +} + +KInstance* KPluginFactory::s_instance = 0L; + +#include "kget_plug_in.moc" diff --git a/kget/kget_plug_in/kget_plug_in.desktop b/kget/kget_plug_in/kget_plug_in.desktop new file mode 100644 index 00000000..8976c2f4 --- /dev/null +++ b/kget/kget_plug_in/kget_plug_in.desktop @@ -0,0 +1,77 @@ +[Desktop Entry] +X-KDE-Library=khtml_kget +X-KDE-PluginInfo-Author=Patrick Charbonnier, Carsten Pfeiffer +X-KDE-PluginInfo-Name=kget +X-KDE-PluginInfo-Version=3.4 +X-KDE-PluginInfo-Website=http://kget.sourceforge.net +X-KDE-PluginInfo-Category=Tools +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=true +Name=KGet +Name[ar]=ك.جيت +Name[bn]=কে-গেট +Name[cy]=KNôl +Name[eo]=Prenilo +Name[hi]=के-गेट +Name[ne]=केडीई गेट +Name[sv]=Kget +Name[ta]=கேகெட் +Name[th]=ดาวน์โหลด K +Name[ven]=Wana ha K +Comment=Download Manager +Comment[be]=Праграма сцягвання файлаў +Comment[bg]=Изтегляне на файлове +Comment[bn]=ডাউনলোড ম্যানেজার +Comment[br]=Merour enkargañ +Comment[bs]=Upravitelj downloadom +Comment[ca]=Gestor de descàrregues +Comment[cs]=Správce stahování +Comment[cy]=Trefnydd Lawrlwytho +Comment[da]=Håndtering af download +Comment[de]=Herunterladen von Dateien +Comment[el]=Διαχειριστής λήψεων αρχείων +Comment[eo]=Elŝut-administrilo +Comment[es]=Gestor de descargas +Comment[et]=Allalaadimiste haldur +Comment[eu]=Deskarga kudeatzailea +Comment[fa]=مدیر بارگیری +Comment[fi]=Tiedostonlataaja +Comment[fr]=Gestionnaire de téléchargements +Comment[ga]=Bainisteoir Íosluchtaithe +Comment[gl]=Xestor de Descargas +Comment[he]=מנהל הורדות +Comment[hu]=Letöltéskezelő +Comment[is]=Niðurhalsstjóri +Comment[it]=Gestore degli scaricamenti +Comment[ja]=ダウンロードマネージャ +Comment[ka]=ჩამოქაჩვათა მმართველი +Comment[kk]=Жүктеп алу менеджері +Comment[km]=កម្មវិធីគ្រប់គ្រងការទាញយក +Comment[lt]=Siuntimų valdymas +Comment[nb]=Nedlastingsbehandler +Comment[nds]=Daallaadpleger +Comment[ne]=डाउनलोड प्रबन्धक +Comment[nl]=Downloadmanager +Comment[nn]=Nedlastingshandsamar +Comment[pa]=ਡਾਊਨਲੋਡ ਮੈਨੇਜਰ +Comment[pl]=Menedżer pobierania +Comment[pt]=Gestor de Transferências +Comment[pt_BR]=Gerenciador de Download +Comment[ro]=Manager de transferuri FTP +Comment[ru]=Диспетчер загрузок +Comment[sk]=Správca sťahovania +Comment[sl]=Upravitelj prenosov +Comment[sr]=Менаџер преузимања +Comment[sr@Latn]=Menadžer preuzimanja +Comment[sv]=Nerladdningshanterare +Comment[tr]=İndirme Yöneticisi +Comment[uk]=Менеджер звантажень +Comment[uz]=Yozib olish boshqaruvchisi +Comment[uz@cyrillic]=Ёзиб олиш бошқарувчиси +Comment[zh_CN]=下载管理器 +Comment[zh_HK]=下載管理員 +Comment[zh_TW]=下載管理員 +Icon=khtml_kget + diff --git a/kget/kget_plug_in/kget_plug_in.h b/kget/kget_plug_in/kget_plug_in.h new file mode 100644 index 00000000..75888b10 --- /dev/null +++ b/kget/kget_plug_in/kget_plug_in.h @@ -0,0 +1,58 @@ +/*************************************************************************** + kget_plug_in.h - description + ------------------- + begin : Wed Jul 3 22:09:28 CEST 2002 + copyright : (C) 2002 by Patrick + email : [email protected] + ***************************************************************************/ + +/*************************************************************************** + * * + * 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 __plugin_kget_plug_in_h +#define __plugin_kget_plug_in_h + +#include <kparts/plugin.h> +#include <klibloader.h> +#include <dcopclient.h> +#include <kurl.h> + +class KInstance; + +class KGet_plug_in : public KParts::Plugin +{ + Q_OBJECT +public: + KGet_plug_in( QObject* parent = 0, const char* name = 0 ); + KToggleAction *m_paToggleDropTarget ; + DCOPClient* p_dcopServer; + virtual ~KGet_plug_in(); + +private slots: + void slotShowDrop(); + void slotShowLinks(); + void showPopup(); +}; + + +class KPluginFactory : public KLibFactory +{ + Q_OBJECT +public: + KPluginFactory( QObject *parent = 0, const char *name = 0 ); + ~KPluginFactory() ; + + virtual QObject* createObject( QObject* parent = 0, const char* pname = 0, + const char* name = "QObject", + const QStringList &args = QStringList() ); + +private: + static KInstance* s_instance; +}; + +#endif diff --git a/kget/kget_plug_in/kget_plug_in.rc b/kget/kget_plug_in/kget_plug_in.rc new file mode 100644 index 00000000..f40ee8b7 --- /dev/null +++ b/kget/kget_plug_in/kget_plug_in.rc @@ -0,0 +1,11 @@ +<!DOCTYPE kpartgui> +<kpartgui library="khtml_kget" name="khtml_kget" version="3" > +<MenuBar> + <Menu name="tools"><Text>&Tools</Text> + <Action name="kget_menu"/> + </Menu> +</MenuBar> +<ToolBar name="mainToolBar"> + <Action name="kget_menu"/> +</ToolBar> +</kpartgui> diff --git a/kget/kget_plug_in/links.cpp b/kget/kget_plug_in/links.cpp new file mode 100644 index 00000000..a597257d --- /dev/null +++ b/kget/kget_plug_in/links.cpp @@ -0,0 +1,41 @@ +#include "links.h" + +#include <kmimetype.h> +#include <kprotocolinfo.h> + +#include <dom/html_misc.h> +#include <dom/html_document.h> + +LinkItem::LinkItem( DOM::Element link ) + : m_valid( false ) +{ + DOM::NamedNodeMap attrs = link.attributes(); + DOM::Node href = attrs.getNamedItem( "href" ); + + // qDebug("*** href: %s", href.nodeValue().string().latin1() ); + + QString urlString = link.ownerDocument().completeURL( href.nodeValue() ).string(); + if ( urlString.isEmpty() ) + return; + + url = KURL::fromPathOrURL( urlString ); + if ( !KProtocolInfo::supportsReading( url ) ) + return; + + + // somehow getElementsByTagName("#text") doesn't work :( + DOM::NodeList children = link.childNodes(); + for ( uint i = 0; i < children.length(); i++ ) + { + DOM::Node node = children.item( i ); + if ( node.nodeType() == DOM::Node::TEXT_NODE ) + text.append( node.nodeValue().string() ); + } + + // force "local file" mimetype determination + KMimeType::Ptr mt = KMimeType::findByURL( url, 0, true, true); + icon = mt->icon( QString::null, false ); // dummy parameters + mimeType = mt->comment(); + + m_valid = true; +} diff --git a/kget/kget_plug_in/links.h b/kget/kget_plug_in/links.h new file mode 100644 index 00000000..89ba9ab5 --- /dev/null +++ b/kget/kget_plug_in/links.h @@ -0,0 +1,32 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer <[email protected]> +** +****************************************************************************/ + +#ifndef LINKS_H +#define LINKS_H + +#include <dom/dom_element.h> + +#include <kurl.h> + +class LinkItem +{ +public: + LinkItem( DOM::Element link ); + + KURL url; + QString icon; + QString text; + QString mimeType; + + bool isValid() const { return m_valid; } + +private: + bool m_valid : 1; +}; + + +#endif // LINKS_H diff --git a/kget/kgetui.rc b/kget/kgetui.rc new file mode 100644 index 00000000..6f746e79 --- /dev/null +++ b/kget/kgetui.rc @@ -0,0 +1,71 @@ +<!DOCTYPE kpartgui> +<kpartgui name="kget" version="4"> +<MenuBar> + <Menu noMerge="1" name="file"><text>&File</text> + <Action name="open_transfer"/> + <Action name="paste_transfer"/> + <Separator/> + <Action name="export_transfers"/> + <Action name="import_transfers"/> + <Action name="import_text"/> + <Separator/> + <Action name="quit"/> + </Menu> + <Menu name="transfer"><text>&Transfer</text> + <Action name="copy_url"/> + <Action name="open_individual"/> + <Separator/> + <Action name="move_begin"/> + <Action name="move_end"/> + <Separator/> + <Action name="resume"/> + <Action name="pause"/> + <Action name="delete"/> + <Action name="restart"/> + <Separator/> + <Action name="queue"/> + <Action name="timer"/> + <Action name="delay"/> + </Menu> + <Menu noMerge="1" name="view"><text>&View</text> + <Action name="toggle_log"/> + </Menu> + <Menu name="options"><text>&Options</text> + <Action name="toggle_animation"/> + <Action name="toggle_sound"/> + <Separator/> + <Action name="expert_mode"/> + <Action name="use_last_dir"/> + <Action name="offline_mode"/> + <Separator/> + <Action name="auto_disconnect"/> + <Action name="auto_shutdown"/> + <Action name="auto_paste"/> + </Menu> + <Menu name="settings"><text>&Settings</text> + <Action name="drop_target"/> + <Action name="show_statusbar"/> + <Action name="settings_showmenubar" append="show_merge"/> + </Menu> + <Menu name="help"><text>&Help</text> + </Menu> +</MenuBar> +<ToolBar fullWidth="true" name="mainToolBar"><text>Main Toolbar</text> + <Action name="open_transfer" /> + <Action name="paste_transfer"/> + <Separator/> + <Action name="resume"/> + <Action name="pause"/> + <Action name="delete"/> + <Action name="restart"/> + <Separator/> + <Action name="queue"/> + <Action name="delay"/> + <Separator/> + <Action name="auto_disconnect"/> + <Action name="auto_shutdown"/> + <Action name="offline_mode"/> + <Separator/> + <Action name="drop_target"/> +</ToolBar> +</kpartgui> diff --git a/kget/kmainwidget.cpp b/kget/kmainwidget.cpp new file mode 100644 index 00000000..420d44a1 --- /dev/null +++ b/kget/kmainwidget.cpp @@ -0,0 +1,2548 @@ +/*************************************************************************** +* kmainwidget.cpp +* ------------------- +* +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* Copyright (C) 2002 Carsten Pfeiffer <[email protected]> +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ +#include <sys/types.h> +#include <sys/ioctl.h> +#include <sys/socket.h> +#include <stdlib.h> +#include <unistd.h> + +#ifdef __svr4__ +#define map BULLSHIT // on Solaris it conflicts with STL ? +#include <net/if.h> +#undef map +#include <sys/sockio.h> // needed for SIOCGIFFLAGS +#else +#include <net/if.h> +#endif + +#include <qclipboard.h> +#include <qregexp.h> +#include <qdragobject.h> +#include <qwhatsthis.h> +#include <qtooltip.h> +#include <qtimer.h> +#include <qdropsite.h> +#include <qpopupmenu.h> +#include <qfileinfo.h> +#include <kinputdialog.h> + +#include <kprotocolinfo.h> +#include <kfiledialog.h> +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kiconloader.h> +#include <kurl.h> +#include <kurldrag.h> +#include <klocale.h> +#include <kglobal.h> +#include <kwin.h> +#include <kmessagebox.h> +#include <kstdaction.h> +#include <khelpmenu.h> +#include <kedittoolbar.h> +#include <kstatusbar.h> +#include <kconfig.h> +#include <kio/netaccess.h> +#include <knotifyclient.h> +#include <knotifydialog.h> +#include <kmenubar.h> +#include <kio/renamedlg.h> + +#include "safedelete.h" +#include "settings.h" +#include "transfer.h" +#include "transferlist.h" +#include "kmainwidget.h" +#include "kfileio.h" +#include "dlgPreferences.h" +#include "logwindow.h" +#include "docking.h" +#include "droptarget.h" +#include <assert.h> + + + +#include <kio/authinfo.h> +#include <kio/global.h> +#include <qiconset.h> + +#include "version.h" +#include "slave.h" +#include "slaveevent.h" + +struct KURLPair +{ + KURL dest; + KURL src; +}; + +KMainWidget *kmain = 0L; + +#define LOAD_ICON(X) KGlobal::iconLoader()->loadIcon(X, KIcon::MainToolbar) + +DropTarget *kdrop = 0L; + +Settings ksettings; // this object contains all settings + +static int sockets_open(); + + +// socket constants +int ipx_sock = -1; /* IPX socket */ +int ax25_sock = -1; /* AX.25 socket */ +int inet_sock = -1; /* INET socket */ +int ddp_sock = -1; /* Appletalk DDP socket */ + + + +KMainWidget::KMainWidget(bool bStartDocked) + : KGetIface( "KGet-Interface" ), + KMainWindow(0, "kget mainwindow",0), + prefDlg( 0 ), kdock( 0 ) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + { + KConfig cfg( "kioslaverc", false, false); + cfg.setGroup(QString::null); + cfg.writeEntry("AutoResume", true); + cfg.sync(); + } + + b_connected = TRUE; + b_viewLogWindow = FALSE; + b_viewPreferences = FALSE; + + myTransferList = 0L; + kmain = this; + + // Set log time, needed for the name of log file + QDate date = QDateTime::currentDateTime().date(); + QTime time = QDateTime::currentDateTime().time(); + QString tmp; + + tmp.sprintf("log%d:%d:%d-%d:%d:%d", date.day(), date.month(), date.year(), time.hour(), time.minute(), time.second()); + + logFileName = locateLocal("appdata", "logs/"); + logFileName += tmp; + + lastClipboard = QApplication::clipboard()->text( QClipboard::Clipboard ).stripWhiteSpace(); + // Load all settings from KConfig + ksettings.load(); + + // Setup log window + logWindow = new LogWindow(); + + m_showDropTarget = false; + + setCaption(KGETVERSION); + + setupGUI(); + setupWhatsThis(); + + log(i18n("Welcome to KGet")); + + setCentralWidget(myTransferList); + + connect(kapp, SIGNAL(saveYourself()), SLOT(slotSaveYourself())); + + // Enable dropping + setAcceptDrops(true); + + // Setup connection timer + connectionTimer = new QTimer(this); + connect(connectionTimer, SIGNAL(timeout()), SLOT(slotCheckConnection())); + + // setup socket for checking connection + if ((_sock = sockets_open()) < 0) { + log(i18n("Could not create valid socket"), false); + } else { + connectionTimer->start(5000); // 5 second interval for checking connection + } + + checkOnline(); + ksettings.b_offline=( !b_connected || ksettings.b_offlineMode ); + + // Setup animation timer + animTimer = new QTimer(this); + animCounter = 0; + connect(animTimer, SIGNAL(timeout()), SLOT(slotAnimTimeout())); + + if (ksettings.b_useAnimation) { + animTimer->start(400); + } else { + animTimer->start(1000); + } + + // Setup transfer timer for scheduled downloads and checkQueue() + transferTimer = new QTimer(this); + connect(transferTimer, SIGNAL(timeout()), SLOT(slotTransferTimeout())); + transferTimer->start(10000); // 10 secs time interval + + // Setup autosave timer + autosaveTimer = new QTimer(this); + connect(autosaveTimer, SIGNAL(timeout()), SLOT(slotAutosaveTimeout())); + setAutoSave(); + + // Setup clipboard timer + clipboardTimer = new QTimer(this); + connect(clipboardTimer, SIGNAL(timeout()), SLOT(slotCheckClipboard())); + if (ksettings.b_autoPaste) { + clipboardTimer->start(1000); + } + + readTransfers(); + + // Setup special windows + kdrop = new DropTarget(this); + kdock = new DockWidget(this); + connect(kdock, SIGNAL(quitSelected()), SLOT(slotQuit())); + + // Set geometry + if (ksettings.mainPosition.x() != -1) { + resize(ksettings.mainSize); + move(ksettings.mainPosition); + KWin::setState(winId(), ksettings.mainState); + } else { + resize(650, 180); + } + + // update actions + m_paUseAnimation->setChecked(ksettings.b_useAnimation); + m_paExpertMode->setChecked(ksettings.b_expertMode); + m_paUseLastDir->setChecked(ksettings.b_useLastDir); + + if (ksettings.connectionType != PERMANENT) { + m_paAutoDisconnect->setChecked(ksettings.b_autoDisconnect); + } + setAutoDisconnect(); + + m_paAutoShutdown->setChecked(ksettings.b_autoShutdown); + + + m_paOfflineMode->setChecked(ksettings.b_offline); + if (!ksettings.b_offlineMode) + m_paOfflineMode->setIconSet(LOAD_ICON("tool_offline_mode_on")); + + if (ksettings.b_offline) { + setCaption(i18n("Offline"), false); + log(i18n("Starting offline")); + } else + setCaption(QString::null, false); + + m_paAutoPaste->setChecked(ksettings.b_autoPaste); + m_paShowLog->setChecked(b_viewLogWindow); + + if (!bStartDocked && ksettings.b_showMain) + show(); + + kdock->show(); + + KNotifyClient::startDaemon(); + + setStandardToolBarMenuEnabled(true); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +KMainWidget::~KMainWidget() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + delete prefDlg; + delete kdrop; + writeTransfers(); + writeLog(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif + delete logWindow; +} + + +void KMainWidget::log(const QString & message, bool statusbar) +{ +#ifdef _DEBUG + sDebugIn <<" message= "<< message << endl; +#endif + + logWindow->logGeneral(message); + + if (statusbar) { + statusBar()->message(message, 1000); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotSaveYourself() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + writeTransfers(); + ksettings.save(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::setupGUI() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + // setup transfer list + myTransferList = new TransferList(this, "transferList"); + myTransferList->setSorting(-1); + setListFont(); + + KActionCollection *coll = actionCollection(); + + connect(myTransferList, SIGNAL(selectionChanged()), this, SLOT(slotUpdateActions())); + connect(myTransferList, SIGNAL(transferSelected(Transfer *)), this, SLOT(slotOpenIndividual())); + connect(myTransferList, SIGNAL(popupMenu(Transfer *)), this, SLOT(slotPopupMenu(Transfer *))); + + // file actions + m_paOpenTransfer = KStdAction::open(this, SLOT(slotOpenTransfer()), coll, "open_transfer"); + m_paPasteTransfer = KStdAction::paste(this, SLOT(slotPasteTransfer()), coll, "paste_transfer"); + + m_paExportTransfers = new KAction(i18n("&Export Transfer List..."), 0, this, SLOT(slotExportTransfers()), coll, "export_transfers"); + m_paImportTransfers = new KAction(i18n("&Import Transfer List..."), 0, this, SLOT(slotImportTransfers()), coll, "import_transfers"); + + m_paImportText = new KAction(i18n("Import Text &File..."), 0, this, SLOT(slotImportTextFile()), coll, "import_text"); + + m_paQuit = KStdAction::quit(this, SLOT(slotQuit()), coll, "quit"); + + + // transfer actions + m_paCopy = new KAction(i18n("&Copy URL to Clipboard"), 0, this, SLOT(slotCopyToClipboard()), coll, "copy_url"); + m_paIndividual = new KAction(i18n("&Open Individual Window"), 0, this, SLOT(slotOpenIndividual()), coll, "open_individual"); + + m_paMoveToBegin = new KAction(i18n("Move to &Beginning"), 0, this, SLOT(slotMoveToBegin()), coll, "move_begin"); + + m_paMoveToEnd = new KAction(i18n("Move to &End"), 0, this, SLOT(slotMoveToEnd()), coll, "move_end"); +#ifdef _DEBUG + sDebug << "Loading pics" << endl; +#endif + m_paResume = new KAction(i18n("&Resume"),"tool_resume", 0, this, SLOT(slotResumeCurrent()), coll, "resume"); + m_paPause = new KAction(i18n("&Pause"),"tool_pause", 0, this, SLOT(slotPauseCurrent()), coll, "pause"); + m_paDelete = new KAction(i18n("&Delete"),"editdelete", Qt::Key_Delete, this, SLOT(slotDeleteCurrent()), coll, "delete"); + m_paRestart = new KAction(i18n("Re&start"),"tool_restart", 0, this, SLOT(slotRestartCurrent()), coll, "restart"); + + m_paQueue = new KRadioAction(i18n("&Queue"),"tool_queue", 0, this, SLOT(slotQueueCurrent()), coll, "queue"); + m_paTimer = new KRadioAction(i18n("&Timer"),"tool_timer", 0, this, SLOT(slotTimerCurrent()), coll, "timer"); + m_paDelay = new KRadioAction(i18n("De&lay"),"tool_delay", 0, this, SLOT(slotDelayCurrent()), coll, "delay"); + + m_paQueue->setExclusiveGroup("TransferMode"); + m_paTimer->setExclusiveGroup("TransferMode"); + m_paDelay->setExclusiveGroup("TransferMode"); + + // options actions + m_paUseAnimation = new KToggleAction(i18n("Use &Animation"), 0, this, SLOT(slotToggleAnimation()), coll, "toggle_animation"); + m_paExpertMode = new KToggleAction(i18n("&Expert Mode"),"tool_expert", 0, this, SLOT(slotToggleExpertMode()), coll, "expert_mode"); + m_paUseLastDir = new KToggleAction(i18n("&Use-Last-Folder Mode"),"tool_uselastdir", 0, this, SLOT(slotToggleUseLastDir()), coll, "use_last_dir"); + m_paAutoDisconnect = new KToggleAction(i18n("Auto-&Disconnect Mode"),"tool_disconnect", 0, this, SLOT(slotToggleAutoDisconnect()), coll, "auto_disconnect"); + m_paAutoShutdown = new KToggleAction(i18n("Auto-S&hutdown Mode"), "tool_shutdown", 0, this, SLOT(slotToggleAutoShutdown()), coll, "auto_shutdown"); + m_paOfflineMode = new KToggleAction(i18n("&Offline Mode"),"tool_offline_mode_off", 0, this, SLOT(slotToggleOfflineMode()), coll, "offline_mode"); + m_paAutoPaste = new KToggleAction(i18n("Auto-Pas&te Mode"),"tool_clipboard", 0, this, SLOT(slotToggleAutoPaste()), coll, "auto_paste"); + + m_paPreferences = KStdAction::preferences(this, SLOT(slotPreferences()), coll); + + KStdAction::keyBindings(guiFactory(), SLOT(configureShortcuts()), coll); + KStdAction::configureToolbars(this, SLOT(slotConfigureToolbars()), coll); + KStdAction::configureNotifications(this, SLOT(slotConfigureNotifications()), coll); + + m_menubarAction = KStdAction::showMenubar(this, SLOT(slotShowMenubar()), coll, "settings_showmenubar" ); + m_menubarAction->setChecked( !menuBar()->isHidden() ); + + // view actions + createStandardStatusBarAction(); + + m_paShowLog = new KToggleAction(i18n("Show &Log Window"),"tool_logwindow", 0, this, SLOT(slotToggleLogWindow()), coll, "toggle_log"); + m_paShowLog->setCheckedState(i18n("Hide &Log Window")); + m_paDropTarget = new KAction(i18n("Show Drop &Target"),"tool_drop_target", 0, this, SLOT(slotToggleDropTarget()), coll, "drop_target"); + m_paKonquerorIntegration = new KAction(i18n("Enable &KGet as Konqueror Download Manager"), "konqueror", 0, this, SLOT(slotKonquerorIntegration()), coll, "konqueror_integration"); + if (ksettings.b_KonquerorIntegration) { + m_paKonquerorIntegration->setText(i18n("Disable &KGet as Konqueror Download Manager")); + } + + menuHelp = new KHelpMenu(this, KGlobal::instance()->aboutData()); + KStdAction::whatsThis(menuHelp, SLOT(contextHelpActivated()), coll, "whats_this"); + + createGUI("kgetui.rc"); + + // setup statusbar + statusBar()->insertFixedItem(i18n(" Transfers: %1 ").arg(99), ID_TOTAL_TRANSFERS); + statusBar()->insertFixedItem(i18n(" Files: %1 ").arg(555), ID_TOTAL_FILES); + statusBar()->insertFixedItem(i18n(" Size: %1 KB ").arg("134.56"), ID_TOTAL_SIZE); + statusBar()->insertFixedItem(i18n(" Time: %1 ").arg(KIO::convertSeconds(0)), ID_TOTAL_TIME); + statusBar()->insertFixedItem(i18n(" %1 KB/s ").arg("123.34"), ID_TOTAL_SPEED); + + setAutoSaveSettings( "MainWindow", false /*Settings takes care of size & pos & state */ ); + + slotUpdateActions(); + + updateStatusBar(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::setupWhatsThis() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + QString tmp; + + tmp = i18n("<b>Resume</b> button starts selected transfers\n" "and sets their mode to <i>queued</i>."); + m_paResume->setWhatsThis(tmp); + + tmp = i18n("<b>Pause</b> button stops selected transfers\n" "and sets their mode to <i>delayed</i>."); + m_paPause->setWhatsThis(tmp); + + tmp = i18n("<b>Delete</b> button removes selected transfers\n" "from the list."); + m_paDelete->setWhatsThis(tmp); + + tmp = i18n("<b>Restart</b> button is a convenience button\n" "that simply does Pause and Resume."); + m_paRestart->setWhatsThis(tmp); + + tmp = i18n("<b>Queued</b> button sets the mode of selected\n" "transfers to <i>queued</i>.\n" "\n" "It is a radio button -- you can choose between\n" "three modes."); + m_paQueue->setWhatsThis(tmp); + + tmp = i18n("<b>Scheduled</b> button sets the mode of selected\n" "transfers to <i>scheduled</i>.\n" "\n" "It is a radio button -- you can choose between\n" "three modes."); + m_paTimer->setWhatsThis(tmp); + + tmp = i18n("<b>Delayed</b> button sets the mode of selected\n" "transfers to <i>delayed</i>." "This also causes the selected transfers to stop.\n" "\n" "It is a radio button -- you can choose between\n" "three modes."); + m_paDelay->setWhatsThis(tmp); + + tmp = i18n("<b>Preferences</b> button opens a preferences dialog\n" "where you can set various options.\n" "\n" "Some of these options can be more easily set using the toolbar."); + m_paPreferences->setWhatsThis(tmp); + + tmp = i18n("<b>Log window</b> button opens a log window.\n" "The log window records all program events that occur\n" "while KGet is running."); + m_paShowLog->setWhatsThis(tmp); + + tmp = i18n("<b>Paste transfer</b> button adds a URL from\n" "the clipboard as a new transfer.\n" "\n" "This way you can easily copy&paste URLs between\n" "applications."); + m_paPasteTransfer->setWhatsThis(tmp); + + tmp = i18n("<b>Expert mode</b> button toggles the expert mode\n" "on and off.\n" "\n" "Expert mode is recommended for experienced users.\n" "When set, you will not be \"bothered\" by confirmation\n" "messages.\n" "<b>Important!</b>\n" "Turn it on if you are using auto-disconnect or\n" "auto-shutdown features and you want KGet to disconnect \n" "or shut down without asking."); + m_paExpertMode->setWhatsThis(tmp); + + tmp = i18n("<b>Use last folder</b> button toggles the\n" "use-last-folder feature on and off.\n" "\n" "When set, KGet will ignore the folder settings\n" "and put all new added transfers into the folder\n" "where the last transfer was put."); + m_paUseLastDir->setWhatsThis(tmp); + + tmp = i18n("<b>Auto disconnect</b> button toggles the auto-disconnect\n" "mode on and off.\n" "\n" "When set, KGet will disconnect automatically\n" "after all queued transfers are finished.\n" "\n" "<b>Important!</b>\n" "Also turn on the expert mode when you want KGet\n" "to disconnect without asking."); + m_paAutoDisconnect->setWhatsThis(tmp); + + tmp = i18n("<b>Auto shutdown</b> button toggles the auto-shutdown\n" "mode on and off.\n" "\n" "When set, KGet will quit automatically\n" "after all queued transfers are finished.\n" "<b>Important!</b>\n" "Also turn on the expert mode when you want KGet\n" "to quit without asking."); + m_paAutoShutdown->setWhatsThis(tmp); + + tmp = i18n("<b>Offline mode</b> button toggles the offline mode\n" "on and off.\n" "\n" "When set, KGet will act as if it was not connected\n" "to the Internet.\n" "\n" "You can browse offline, while still being able to add\n" "new transfers as queued."); + m_paOfflineMode->setWhatsThis(tmp); + + tmp = i18n("<b>Auto paste</b> button toggles the auto-paste mode\n" "on and off.\n" "\n" "When set, KGet will periodically scan the clipboard\n" "for URLs and paste them automatically."); + m_paAutoPaste->setWhatsThis(tmp); + + tmp = i18n("<b>Drop target</b> button toggles the window style\n" "between a normal window and a drop target.\n" "\n" "When set, the main window will be hidden and\n" "instead a small shaped window will appear.\n" "\n" "You can show/hide a normal window with a simple click\n" "on a shaped window."); + m_paDropTarget->setWhatsThis(tmp); + /* + tmp = i18n("<b>Dock widget</b> button toggles the window style\n" "between a normal window and a docked widget.\n" "\n" "When set, the main window will be hidden and\n" "instead a docked widget will appear on the panel.\n" "\n" "You can show/hide a normal window by simply clicking\n" "on a docked widget."); + m_paDockWindow->setWhatsThis(tmp); + + tmp = i18n("<b>Normal window</b> button sets\n" "\n" "the window style to normal window"); + m_paNormal->setWhatsThis(tmp); + */ + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotConfigureToolbars() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + saveMainWindowSettings( KGlobal::config(), "MainWindow" ); + KEditToolbar edit(factory()); + connect(&edit, SIGNAL( newToolbarConfig() ), this, SLOT( slotNewToolbarConfig() )); + edit.exec(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotNewToolbarConfig() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + createGUI("kgetui.rc"); + applyMainWindowSettings( KGlobal::config(), "MainWindow" ); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotImportTextFile() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + QString tmpFile; + QString list; + int i, j; + + KURL filename = KFileDialog::getOpenURL(ksettings.lastDirectory); + if (!filename.isValid()) + return; + + if (KIO::NetAccess::download(filename, tmpFile, this)) { + list = kFileToString(tmpFile); + KIO::NetAccess::removeTempFile(tmpFile); + } else + list = kFileToString(filename.path()); // file not accessible -> give error message + + i = 0; + while ((j = list.find('\n', i)) != -1) { + QString newtransfer = list.mid(i, j - i); + addTransfer(newtransfer); + i = j + 1; + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotImportTransfers() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + readTransfers(true); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::readTransfers(bool ask_for_name) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + KURL url; + + if (ask_for_name) + url = KFileDialog::getOpenURL(ksettings.lastDirectory, i18n("*.kgt|*.kgt\n*|All Files")); + else + url.setPath( locateLocal("appdata", "transfers.kgt") ); + + readTransfersEx(url); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::readTransfersEx(const KURL & file) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + if (!file.isValid()) { + +#ifdef _DEBUG + sDebugOut<< " string empty" << endl; +#endif + return; + } +#ifdef _DEBUG + sDebug << "Read from file: " << file << endl; +#endif + myTransferList->readTransfers(file); + checkQueue(); + slotTransferTimeout(); + myTransferList->clearSelection(); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotExportTransfers() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + writeTransfers(true); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::writeTransfers(bool ask_for_name) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + QString str; + QString txt; + + if (ask_for_name) + txt = KFileDialog::getSaveFileName(ksettings.lastDirectory, i18n("*.kgt|*.kgt\n*|All Files")); + else + txt = locateLocal("appdata", "transfers.kgt"); + + + + if (txt.isEmpty()) + { +#ifdef _DEBUG + sDebugOut<< " because Destination File name isEmpty"<< endl; +#endif + return; + } + if (!txt.endsWith(".kgt")) + txt += ".kgt"; + +#ifdef _DEBUG + sDebug << "Writing transfers " << txt << endl; +#endif + + myTransferList->writeTransfers(txt); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::writeLog() +{ +#ifdef _DEBUG + sDebugIn << "Writing log to file : " << logFileName.ascii() << endl; +#endif + + + kCStringToFile(logWindow->getText().local8Bit(), logFileName, false, false); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotQuit() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + Transfer *item; + TransferIterator it(myTransferList); + + log(i18n("Quitting...")); + + for (; it.current(); ++it) { + item = it.current(); + if (item->getStatus() == Transfer::ST_RUNNING && !ksettings.b_expertMode) { + if (KMessageBox::warningContinueCancel(this, i18n("Some transfers are still running.\nAre you sure you want to quit KGet?"), i18n("Warning"), KStdGuiItem::quit()) != KMessageBox::Continue) { +#ifdef _DEBUG + sDebugOut << endl; +#endif + + return; + } + break; + } + } + + ksettings.save(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif + + kapp->quit(); +} + + +void KMainWidget::slotResumeCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) + if (it.current()->isSelected()) + it.current()->slotResume(); + slotUpdateActions(); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotPauseCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + TransferIterator it(myTransferList); + + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + update(); + + for (; it.current(); ++it) + if (it.current()->isSelected()) + it.current()->slotRequestPause(); + slotUpdateActions(); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + + +void KMainWidget::slotRestartCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) + if (it.current()->isSelected()) + it.current()->slotRequestRestart(); + slotUpdateActions(); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotDeleteCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + m_paDelete->setEnabled(false); + m_paPause->setEnabled(false); + update(); + TransferIterator it(myTransferList); + QValueList<QGuardedPtr<Transfer> > selectedItems; + QStringList itemNames; + + while (it.current()) { + if (it.current()->isSelected()) { + selectedItems.append( QGuardedPtr<Transfer>( it.current() )); + itemNames.append( it.current()->getSrc().prettyURL() ); + } + ++it; + } + + if (!ksettings.b_expertMode) + { + if ( selectedItems.count() > 1 ) + { + if (KMessageBox::warningContinueCancelList(this, i18n("Are you sure you want to delete these transfers?"), + itemNames, i18n("Question"), + KStdGuiItem::del(), + QString("multiple_delete_transfer")) + != KMessageBox::Continue) + return; // keep 'em + } + else + { + if (KMessageBox::warningContinueCancel(this, i18n("Are you sure you want to delete this transfer?"), + i18n("Question"), KStdGuiItem::del(), + QString("delete_transfer")) + != KMessageBox::Continue) + return; + } + } + + // If we reach this, we want to delete all selected transfers + // Some of them might have finished in the meantime tho. Good that + // we used a QGuardedPtr :) + + int transferFinishedMeanwhile = 0; + QValueListConstIterator<QGuardedPtr<Transfer> > lit = selectedItems.begin();; + while ( lit != selectedItems.end() ) + { + if ( *lit ) + (*lit)->slotRequestRemove(); + else + ++transferFinishedMeanwhile; + + ++lit; + } + + checkQueue(); // needed ! + + if ( !ksettings.b_expertMode && transferFinishedMeanwhile > 0 ) + KMessageBox::information(this, i18n("The transfer you wanted to delete completed before it could be deleted.", + "%n transfers you wanted to delete completed before they could be deleted.", + transferFinishedMeanwhile ), + QString::null, "completedBeforeDeletion" ); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::stopAll() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + log(i18n("Stopping all jobs"), false); + + TransferIterator it(myTransferList); + Transfer::TransferStatus Status; + for (; it.current(); ++it) { + Status = it.current()->getStatus(); + if (Status == Transfer::ST_TRYING || Status == Transfer::ST_RUNNING) + it.current()->slotStop(); + } + slotUpdateActions(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotQueueCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) { + if (it.current()->isSelected()) { + it.current()->slotQueue(); + } + } + + // myTransferList->clearSelection(); + slotUpdateActions(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotTimerCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) + if (it.current()->isSelected()) + it.current()->slotRequestSchedule(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif + +} + + +void KMainWidget::slotDelayCurrent() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) + if (it.current()->isSelected()) + it.current()->slotRequestDelay(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotOpenTransfer() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + QString newtransfer; + bool ok = false; + +#ifdef _DEBUG + // newtransfer = "ftp://localhost/home/pch/test.gz"; + // newtransfer = "http://www.kernel.org/pub/linux/kernel/v2.4/linux-2.4.18.tar.gz"; + newtransfer = "ftp://darkmoon/pub/test.gz"; +#endif + + while (!ok) { + newtransfer = KInputDialog::getText(i18n("Open Transfer"), i18n("Open transfer:"), newtransfer, &ok, this); + + // user presses cancel + if (!ok) { + return; + } + + KURL url = KURL::fromPathOrURL(newtransfer); + + if (!url.isValid()) { + KMessageBox::error(this, i18n("Malformed URL:\n%1").arg(newtransfer), i18n("Error")); + ok = false; + } + } + + addTransfer(newtransfer); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + + +void KMainWidget::slotCheckClipboard() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + QString clipData = QApplication::clipboard()->text( QClipboard::Clipboard ).stripWhiteSpace(); + + if (clipData != lastClipboard) { + sDebug << "New clipboard event" << endl; + + lastClipboard = clipData; + if ( lastClipboard.isEmpty() ) + return; + + KURL url = KURL::fromPathOrURL( lastClipboard ); + + if (url.isValid() && !url.isLocalFile()) + slotPasteTransfer(); + } + +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +void KMainWidget::slotPasteTransfer() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + QString newtransfer; + + newtransfer = QApplication::clipboard()->text(); + newtransfer = newtransfer.stripWhiteSpace(); + + if (!ksettings.b_expertMode) { + bool ok = false; + newtransfer = KInputDialog::getText(i18n("Open Transfer"), i18n("Open transfer:"), newtransfer, &ok, this); + + if (!ok) { + // cancelled +#ifdef _DEBUG + sDebugOut << endl; +#endif + return; + } + + } + + if (!newtransfer.isEmpty()) + addTransfer(newtransfer); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +// destFile must be a filename, not a directory! And it will be deleted, if +// it exists already, without further notice. +void KMainWidget::addTransferEx(const KURL& url, const KURL& destFile) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + if ( !sanityChecksSuccessful( url ) ) + return; + + KURL destURL = destFile; + + // Malformed destination url means one of two things. + // 1) The URL is empty. + // 2) The URL is only a filename, like a default (suggested) filename. + if ( !destURL.isValid() ) + { + // Setup destination + QString destDir = getSaveDirectoryFor( url.fileName() ); + bool b_expertMode = ksettings.b_expertMode; + bool bDestisMalformed = true; + + while (bDestisMalformed) + { + if (!b_expertMode) { + // open the filedialog for confirmation + KFileDialog dlg( destDir, QString::null, + 0L, "save_as", true); + dlg.setCaption(i18n("Save As")); + dlg.setOperationMode(KFileDialog::Saving); + + // Use the destination name if not empty... + if (destURL.isEmpty()) + dlg.setSelection(url.fileName()); + else + dlg.setSelection(destURL.url()); + + if ( dlg.exec() == QDialog::Rejected ) + { +#ifdef _DEBUG + sDebugOut << endl; +#endif + return; + } + else + { + destURL = dlg.selectedURL(); + ksettings.lastDirectory = destURL.directory(); + } + } + else { + // in expert mode don't open the filedialog + // if destURL is not empty, it's the suggested filename + destURL = KURL::fromPathOrURL( destDir + "/" + + ( destURL.isEmpty() ? + url.fileName() : destURL.url() )); + } + + //check if destination already exists + if(KIO::NetAccess::exists(destURL, false, this)) + { + if (KMessageBox::warningYesNo(this,i18n("Destination file \n%1\nalready exists.\nDo you want to overwrite it?").arg( destURL.prettyURL()), QString::null, i18n("Overwrite"), i18n("Do Not Overwrite") ) + == KMessageBox::Yes) + { + bDestisMalformed=false; + SafeDelete::deleteFile( destURL ); + } + else + { + b_expertMode=false; + ksettings.lastDirectory = destURL.directory(); + } + } + else + bDestisMalformed=false; + } + } + + else // destURL was given, check whether the file exists already + { + // simply delete it, the calling process should have asked if you + // really want to delete (at least khtml does) + if(KIO::NetAccess::exists(destURL, false, this)) + SafeDelete::deleteFile( destURL ); + } + + // create a new transfer item + Transfer *item = myTransferList->addTransfer(url, destURL); + KNotifyClient::event(kdock->winId(), "added", i18n("<i>%1</i> has been added.").arg(url.prettyURL())); + item->updateAll(); // update the remaining fields + + if (ksettings.b_showIndividual) + item->showIndividual(); + + myTransferList->clearSelection(); + + checkQueue(); +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::addTransfers( const KURL::List& src, const QString& destDir ) +{ + QValueList<KURLPair> urls_orig; + + for ( KURL::List::ConstIterator it = src.begin(); it != src.end(); ++it ) + { + KURLPair url; + url.src = *it; + if ( url.src.fileName().endsWith( ".kgt" ) ) + readTransfersEx(url.src); + else + urls_orig.append( url ); + } + + if ( urls_orig.isEmpty() ) + return; + + if ( urls_orig.count() == 1 ) // just one file -> ask for filename + { + KURL destFile; + + if ( !destDir.isEmpty() ) + { + // create a proper destination file from destDir + KURL destURL = KURL::fromPathOrURL( destDir ); + QString fileName = urls_orig.first().src.fileName(); + + // in case the fileName is empty, we simply ask for a filename in + // addTransferEx. Do NOT attempt to use an empty filename, that + // would be a directory (and we don't want to overwrite that!) + if ( !fileName.isEmpty() ) + { + destURL.adjustPath( +1 ); + destURL.setFileName( fileName ); + if(KIO::NetAccess::exists(destURL, false, this)) + { + if (KMessageBox::warningYesNo(this,i18n("Destination file \n%1\nalready exists.\nDo you want to overwrite it?").arg( destURL.prettyURL()), QString::null, i18n("Overwrite"), i18n("Do Not Overwrite") ) + == KMessageBox::Yes) + { + SafeDelete::deleteFile( destURL ); + destFile = destURL; + } + } + else + { + destFile = destURL; + } + } + } + + addTransferEx( urls_orig.first().src, destFile ); + return; + } + + // multiple files -> ask for directory, not for every single filename + + bool dir_accepted = false; + QValueList<KURLPair>::Iterator it; + QValueList<KURLPair> urls; + KURL::List urlsToDelete; + while ( !dir_accepted ) + { + urlsToDelete.clear(); + urls = urls_orig; // copy the list here, urls might be changed, yet when we return here (Cancel), + // we want to start again with the original list + dir_accepted = true; //Set to false later when Cancel is pressed + KURL dest; + if ( destDir.isEmpty() || !QFileInfo( destDir ).isDir() ) + { + if ( !destDir.isEmpty() ) + dest.setPath( destDir ); + else + dest.setPath( getSaveDirectoryFor( src.first().fileName() ) ); + + // ask in any case, when destDir is empty + if ( destDir.isEmpty() || !QFileInfo( dest.path() ).isDir() ) + { + QString dir = KFileDialog::getExistingDirectory( dest.path() ); + if ( dir.isEmpty() ) // aborted + return; + + dest.setPath( dir ); + ksettings.lastDirectory = dir; + } + } + + // dest is now finally the real destination directory for all the files + dest.adjustPath(+1); + + // create new transfer items + bool skip_all = false; + bool overwrite_all = false; + it = urls.begin(); + KIO::RenameDlg_Result result; + while ( it != urls.end() ) + { + + if ( !sanityChecksSuccessful( (*it).src ) ) + { + it = urls.erase( it ); + continue; // shouldn't we notify the user?? + } + + (*it).dest = dest; + QString fileName = (*it).src.fileName(); + if ( fileName.isEmpty() ) // simply use the full url as filename + fileName = KURL::encode_string_no_slash( (*it).src.prettyURL() ); + + (*it).dest.setFileName( fileName ); + + if( KIO::NetAccess::exists((*it).dest, false, this)) + { + QString newdest; + if (skip_all) + result = KIO::R_SKIP; + else if( overwrite_all ) + result = KIO::R_OVERWRITE; + else + { + QFileInfo finfo( (*it).dest.path() ); + QString caption = i18n( "File Already exists" ) + " - KGet"; + result = KIO::open_RenameDlg( caption, (*it).src.url(), (*it).dest.url(), KIO::RenameDlg_Mode(KIO::M_OVERWRITE|KIO::M_SKIP|KIO::M_MULTI), newdest, (KIO::filesize_t) -1, (KIO::filesize_t)finfo.size(), (time_t) -1, (time_t) -1, (time_t) -1, finfo.lastModified().toTime_t()); + } + switch (result) + { + case KIO::R_RENAME: + (*it).dest = KURL::fromPathOrURL( newdest ); + break; + case KIO::R_OVERWRITE_ALL: + overwrite_all = true; //fall through + case KIO::R_OVERWRITE: + urlsToDelete.append( (*it).dest ); + break; + case KIO::R_AUTO_SKIP: + skip_all = true; + case KIO::R_SKIP: //fall through + it = urls.erase( it ); + continue; + break; + default: // Cancel, ask again for directory + dir_accepted = false; + } + if ( !dir_accepted ) + break; + } // if(KIO::NetAccess::exists + ++it; + } // while ( it != urls.end() ) + } // while ( !dir_accepted ) + + KURL::List::Iterator it_1 = urlsToDelete.begin(); + for ( ; it_1 != urlsToDelete.end(); ++it_1 ) + { + SafeDelete::deleteFile( *it_1 ); + } + + int numdl = 0; + it = urls.begin(); + for ( ; it != urls.end(); ++it ) + { + Transfer *item = myTransferList->addTransfer((*it).src, (*it).dest); + item->updateAll(); // update the remaining fields + numdl++; + } + + KNotifyClient::event(kdock->winId(), "added", i18n("1 download has been added.", "%n downloads have been added.", numdl)); + + myTransferList->clearSelection(); + + checkQueue(); +} + +void KMainWidget::addTransfer(const QString& src) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + if ( src.isEmpty() ) + return; + + addTransferEx( KURL::fromPathOrURL( src ) ); + +#ifdef _DEBUG + sDebugOut << endl; +#endif + +} + + +void KMainWidget::checkQueue() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + uint numRun = 0; + int status; + Transfer *item; + TransferIterator it(myTransferList); + + if (!ksettings.b_offline) { + + // count running transfers + for (; it.current(); ++it) { + status = it.current()->getStatus(); + if (status == Transfer::ST_RUNNING || status == Transfer::ST_TRYING) + numRun++; + } + sDebug << "Found " << numRun << " Running Jobs" << endl; + it.reset(); + bool isRunning; + bool isQuequed; + for (; it.current() && numRun < ksettings.maxSimultaneousConnections; ++it) { + item = it.current(); + isRunning = (item->getStatus() == Transfer::ST_RUNNING) || ((item->getStatus() == Transfer::ST_TRYING)); + + isQuequed = (item->getMode() == Transfer::MD_QUEUED || item->getMode() == Transfer::MD_NEW); + + if (!isRunning && isQuequed && !ksettings.b_offline) + { + log(i18n("Starting another queued job.")); + item->slotResume(); + numRun++; + } + } + + slotUpdateActions(); + + updateStatusBar(); + +// } else {//TODO this has to be solved different +// log(i18n("Cannot continue offline status")); + } + + it.reset(); + for (; it.current(); ++it) + { + item = it.current(); + if (item->getMode() == Transfer::MD_NEW && item->getStatus() == Transfer::ST_STOPPED) + { + item->checkCache(); + } + } +#ifdef _DEBUG + sDebugOut << endl; +#endif + +} + + +void KMainWidget::slotAnimTimeout() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + bool isTransfer; + + animCounter++; + if (animCounter == myTransferList->getPhasesNum()) { + //updateStatusBar(); + animCounter = 0; + } + // update status of all items of transferList + isTransfer = myTransferList->updateStatus(animCounter); + + //if (this->isVisible()) { + updateStatusBar(); + //} +#ifdef _DEBUG + //sDebugOut << endl; +#endif + +} + + +void KMainWidget::slotTransferTimeout() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + Transfer *item; + TransferIterator it(myTransferList); + + bool flag = false; + + for (; it.current(); ++it) { + item = it.current(); + if (item->getMode() == Transfer::MD_SCHEDULED && item->getStartTime() <= QDateTime::currentDateTime()) { + item->setMode(Transfer::MD_QUEUED); + flag = true; + } + } + + if (flag) { + checkQueue(); + } + + if (ksettings.b_autoDisconnect && ksettings.b_timedDisconnect && ksettings.disconnectTime <= QTime::currentTime() && ksettings.disconnectDate == QDate::currentDate()) { + onlineDisconnect(); + } + +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +void KMainWidget::slotAutosaveTimeout() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + writeTransfers(); + +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +void KMainWidget::slotStatusChanged(Transfer * item, int _operation) +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + switch (_operation) { + + case Transfer::OP_FINISHED: + { + QString srcurl = item->getSrc().prettyURL(); + if (ksettings.b_removeOnSuccess && !item->keepDialogOpen() ) + { + delete item; + item = 0L; + } + else + item->setMode(Transfer::MD_NONE); + + if (!myTransferList->areTransfersQueuedOrScheduled()) { + // no items or only delayed and finished items in the TransferList + if (ksettings.b_autoDisconnect) + onlineDisconnect(); + + if (ksettings.b_autoShutdown) { + slotQuit(); + return; + } + KNotifyClient::event(kdock->winId(), "finishedall", i18n("All the downloads are finished.")); + } + else + { + KNotifyClient::event(kdock->winId(), "finished", i18n("<i>%1</i> successfully downloaded.").arg(srcurl)); + } + + if ( item ) + item->slotUpdateActions(); + + break; + } + case Transfer::OP_RESUMED: + slotUpdateActions(); + item->slotUpdateActions(); + // play(ksettings.audioStarted); + break; + case Transfer::OP_PAUSED: + break; + case Transfer::OP_REMOVED: + delete item; + return; // checkQueue() will be called only once after all deletions + + case Transfer::OP_ABORTED: + break; + case Transfer::OP_DELAYED: + case Transfer::OP_QUEUED: + slotUpdateActions(); + item->slotUpdateActions(); + break; + case Transfer::OP_SCHEDULED: + slotUpdateActions(); + item->slotUpdateActions(); + slotTransferTimeout(); // this will check schedule times + return; // checkQueue() is called from slotTransferTimeout() + } + checkQueue(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::dragEnterEvent(QDragEnterEvent * event) +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + event->accept(KURLDrag::canDecode(event) || QTextDrag::canDecode(event)); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::dropEvent(QDropEvent * event) +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + KURL::List list; + QString str; + + if (KURLDrag::decode(event, list)) { + addTransfers(list); + } else if (QTextDrag::decode(event, str)) { + addTransfer(str); + } + sDebugOut << endl; +} + + +void KMainWidget::slotCopyToClipboard() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + Transfer *item = (Transfer *) myTransferList->currentItem(); + + if (item) { + QString url = item->getSrc().url(); + QClipboard *cb = QApplication::clipboard(); + cb->setText( url, QClipboard::Selection ); + cb->setText( url, QClipboard::Clipboard); + myTransferList->clearSelection(); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotMoveToBegin() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + myTransferList->moveToBegin((Transfer *) myTransferList->currentItem()); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotMoveToEnd() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + myTransferList->moveToEnd((Transfer *) myTransferList->currentItem()); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotOpenIndividual() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + Transfer *item = (Transfer *) myTransferList->currentItem(); + if (item) + item->showIndividual(); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +bool KMainWidget::queryClose() +{ + if( kapp->sessionSaving()) + return true; + hide(); + return false; +} + +void KMainWidget::setAutoSave() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + autosaveTimer->stop(); + if (ksettings.b_autoSave) { + autosaveTimer->start(ksettings.autoSaveInterval * 60000); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + + +void KMainWidget::setAutoDisconnect() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + // disable action when we are connected permanently + m_paAutoDisconnect->setEnabled(ksettings.connectionType != PERMANENT); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::slotPreferences() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + if ( !prefDlg ) + prefDlg = new DlgPreferences(this); + + prefDlg->show(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::slotConfigureNotifications() +{ + KNotifyDialog::configure(this); +} + +void KMainWidget::slotToggleLogWindow() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + b_viewLogWindow = !b_viewLogWindow; + if (b_viewLogWindow) + logWindow->show(); + else + logWindow->hide(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleAnimation() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_useAnimation = !ksettings.b_useAnimation; + + if (!ksettings.b_useAnimation && animTimer->isActive()) { + animTimer->stop(); + animTimer->start(1000); + animCounter = 0; + } else { + animTimer->stop(); + animTimer->start(400); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::slotToggleOfflineMode() +{ +#ifdef _DEBUG + sDebugIn "ksettings.b_offlineMode = " << ksettings.b_offlineMode << endl; +#endif + + ksettings.b_offlineMode = !ksettings.b_offlineMode; + ksettings.b_offline=(ksettings.b_offlineMode || !b_connected); + if (ksettings.b_offline) { + log(i18n("Offline mode on.")); + stopAll(); + setCaption(i18n("Offline"), false); + m_paOfflineMode->setIconSet(LOAD_ICON("tool_offline_mode_off")); + } else { + log(i18n("Offline mode off.")); + setCaption(QString::null, false); + m_paOfflineMode->setIconSet(LOAD_ICON("tool_offline_mode_on")); + } + + m_paOfflineMode->setChecked(ksettings.b_offline); + + + slotUpdateActions(); + checkQueue(); +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleExpertMode() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_expertMode = !ksettings.b_expertMode; + + if (ksettings.b_expertMode) { + log(i18n("Expert mode on.")); + } else { + log(i18n("Expert mode off.")); + } + m_paExpertMode->setChecked(ksettings.b_expertMode); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleUseLastDir() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_useLastDir = !ksettings.b_useLastDir; + + if (ksettings.b_useLastDir) { + log(i18n("Use last folder on.")); + } else { + log(i18n("Use last folder off.")); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleAutoDisconnect() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_autoDisconnect = !ksettings.b_autoDisconnect; + + if (ksettings.b_autoDisconnect) { + log(i18n("Auto disconnect on.")); + } else { + log(i18n("Auto disconnect off.")); + } + m_paAutoDisconnect->setChecked(ksettings.b_autoDisconnect); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleAutoShutdown() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_autoShutdown = !ksettings.b_autoShutdown; + + if (ksettings.b_autoShutdown) { + log(i18n("Auto shutdown on.")); + } else { + log(i18n("Auto shutdown off.")); + } + + m_paAutoShutdown->setChecked(ksettings.b_autoShutdown); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleAutoPaste() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + ksettings.b_autoPaste = !ksettings.b_autoPaste; + + if (ksettings.b_autoPaste) { + log(i18n("Auto paste on.")); + clipboardTimer->start(1000); + } else { + log(i18n("Auto paste off.")); + clipboardTimer->stop(); + } + m_paAutoPaste->setChecked(ksettings.b_autoPaste); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotToggleDropTarget() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + m_showDropTarget = !m_showDropTarget; + + if (m_showDropTarget) { + kdrop->show(); + kdrop->updateStickyState(); + m_paDropTarget->setText(i18n("Hide Drop &Target")); + } + else { + kdrop->hide(); + m_paDropTarget->setText(i18n("Show Drop &Target")); + } + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotKonquerorIntegration() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + bool bIsKonquiEnable=!ksettings.b_KonquerorIntegration; + ksettings.b_KonquerorIntegration=!ksettings.b_KonquerorIntegration; + KConfig cfg("konquerorrc", false, false); + cfg.setGroup("HTML Settings"); + cfg.writePathEntry("DownloadManager",QString((bIsKonquiEnable)?"kget":"")); + cfg.sync(); + if (bIsKonquiEnable) + { + m_paKonquerorIntegration->setText(i18n("Disable &KGet as Konqueror Download Manager")); + } + else + { + m_paKonquerorIntegration->setText(i18n("Enable &KGet as Konqueror Download Manager")); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotPopupMenu(Transfer * item) +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + // select current item + myTransferList->setCurrentItem(item); + + // set action properties + slotUpdateActions(); + + // popup transfer menu at the position + QWidget *menu = guiFactory()->container("transfer",this); + ((QPopupMenu *) menu)->popup(QCursor::pos()); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::setListFont() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + myTransferList->setFont(ksettings.listViewFont); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + +void KMainWidget::slotUpdateActions() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + + // disable all signals + m_paQueue->blockSignals(true); + m_paTimer->blockSignals(true); + m_paDelay->blockSignals(true); + + // at first turn off all buttons like when nothing is selected + m_paQueue->setChecked(false); + m_paTimer->setChecked(false); + m_paDelay->setChecked(false); + + m_paQueue->setEnabled(false); + m_paTimer->setEnabled(false); + m_paDelay->setEnabled(false); + + m_paDelete->setEnabled(false); + m_paResume->setEnabled(false); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + + m_paCopy->setEnabled(false); + m_paIndividual->setEnabled(false); + m_paMoveToBegin->setEnabled(false); + m_paMoveToEnd->setEnabled(false); + + Transfer *item; + Transfer *first_item = 0L; + TransferIterator it(myTransferList); + int index = 0; + int totals_items = 0; + int sel_items = 0; + + for (; it.current(); ++it, ++totals_items) { + + // update action on visibles windows + if (it.current()->isVisible()) + it.current()->slotUpdateActions(); + + if (it.current()->isSelected()) { + item = it.current(); + sel_items = totals_items; + index++; // counting number of selected items + if (index == 1) { + first_item = item; // store first selected item + if (totals_items > 0) + m_paMoveToBegin->setEnabled(true); + + m_paMoveToEnd->setEnabled(true); + } else { + + m_paMoveToBegin->setEnabled(false); + m_paMoveToEnd->setEnabled(false); + } + // enable PAUSE, RESUME and RESTART only when we are online and not in offline mode +#ifdef _DEBUG + sDebug << "-->ONLINE= " << ksettings.b_offline << endl; +#endif + if (item == first_item && !ksettings.b_offline) { + switch (item->getStatus()) { + case Transfer::ST_TRYING: + case Transfer::ST_RUNNING: + m_paResume->setEnabled(false); + m_paPause->setEnabled(true); + m_paRestart->setEnabled(true); + break; + case Transfer::ST_STOPPED: + m_paResume->setEnabled(true); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); +#ifdef _DEBUG + sDebug << "STATUS IS stopped" << item->getStatus() << endl; +#endif + break; + case Transfer::ST_FINISHED: + m_paResume->setEnabled(false); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + break; + + + } //end switch + + } else if (item->getStatus() != first_item->getStatus()) { + // disable all when all selected items don't have the same status + m_paResume->setEnabled(false); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + } + + + if (item == first_item) { + m_paDelete->setEnabled(true); + m_paCopy->setEnabled(true); + m_paIndividual->setEnabled(true); + if (item->getStatus() != Transfer::ST_FINISHED) { + m_paQueue->setEnabled(true); + m_paTimer->setEnabled(true); + m_paDelay->setEnabled(true); + + switch (item->getMode()) { + case Transfer::MD_QUEUED: +#ifdef _DEBUG + sDebug << "....................THE MODE IS MD_QUEUED " << item->getMode() << endl; +#endif + m_paQueue->setChecked(true); + break; + case Transfer::MD_SCHEDULED: +#ifdef _DEBUG + sDebug << "....................THE MODE IS MD_SCHEDULED " << item->getMode() << endl; +#endif + m_paTimer->setChecked(true); + break; + case Transfer::MD_DELAYED: +#ifdef _DEBUG + sDebug << "....................THE MODE IS MD_DELAYED " << item->getMode() << endl; +#endif + m_paDelay->setChecked(true); + break; + } + } + } else if (item->getMode() != first_item->getMode()) { + // unset all when all selected items don't have the same mode + m_paQueue->setChecked(false); + m_paTimer->setChecked(false); + m_paDelay->setChecked(false); + m_paMoveToBegin->setEnabled(false); + m_paMoveToEnd->setEnabled(false); + m_paQueue->setEnabled(false); + m_paTimer->setEnabled(false); + m_paDelay->setEnabled(false); + } + + } // when item is selected + } // loop + + + + if (sel_items == totals_items - 1) + m_paMoveToEnd->setEnabled(false); + + // enable all signals + + + + m_paQueue->blockSignals(false); + m_paTimer->blockSignals(false); + m_paDelay->blockSignals(false); + + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::updateStatusBar() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + Transfer *item; + QString tmpstr; + + int totalFiles = 0; + KIO::filesize_t totalSize = 0; + int totalSpeed = 0; + unsigned int remTime = 0; + + TransferIterator it(myTransferList); + + for (; it.current(); ++it) { + item = it.current(); + if (item->getTotalSize() != 0) { + totalSize += (item->getTotalSize() - item->getProcessedSize()); + } + totalFiles++; + totalSpeed += item->getSpeed(); + + if (item->getRemainingTime() > remTime) { + remTime = item->getRemainingTime(); + } + } + + statusBar()->changeItem(i18n(" Transfers: %1 ").arg(myTransferList->childCount()), ID_TOTAL_TRANSFERS); + statusBar()->changeItem(i18n(" Files: %1 ").arg(totalFiles), ID_TOTAL_FILES); + statusBar()->changeItem(i18n(" Size: %1 ").arg(KIO::convertSize(totalSize)), ID_TOTAL_SIZE); + statusBar()->changeItem(i18n(" Time: %1 ").arg(KIO::convertSeconds(remTime)), ID_TOTAL_TIME); + statusBar()->changeItem(i18n(" %1/s ").arg(KIO::convertSize(totalSpeed)), ID_TOTAL_SPEED); + //update size for each statusbar field + statusBar()->setItemFixed(ID_TOTAL_TRANSFERS, -1); + statusBar()->setItemFixed(ID_TOTAL_FILES, -1); + statusBar()->setItemFixed(ID_TOTAL_SIZE, -1); + statusBar()->setItemFixed(ID_TOTAL_TIME, -1); + statusBar()->setItemFixed(ID_TOTAL_SPEED, -1); + + if (kdock) { + tmpstr = i18n("<b>Transfers:</b> %1 ").arg(myTransferList->childCount()) + + i18n("<br /><b>Files:</b> %1 ").arg(totalFiles) + + i18n("<br /><b>Size:</b> %1 ").arg(KIO::convertSize(totalSize)) + + i18n("<br /><b>Time:</b> %1 ").arg(KIO::convertSeconds(remTime)) + + i18n("<br /><b>Speed:</b> %1/s").arg(KIO::convertSize(totalSpeed)); + kdock->updateToolTip( tmpstr ); + //trayicon changes if download is in progress + if (totalSpeed == 0) + { + kdock->changeIcon( "kget_dock" ); + } + else + { + kdock->changeIcon( "kget_dock_download" ); + } + } +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +void KMainWidget::onlineDisconnect() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + if (!b_connected) { + return; + } + + if (!ksettings.b_expertMode) { + if (KMessageBox::questionYesNo(this, i18n("Do you really want to disconnect?"), + i18n("Question"), + i18n("Disconnect"), i18n("Stay Connected"), + "kget_AutoOnlineDisconnect") + != KMessageBox::Yes) { + return; + } + } + log(i18n("Disconnecting...")); + system(QFile::encodeName(ksettings.disconnectCommand)); + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + +void KMainWidget::slotCheckConnection() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + bool old = b_connected; + checkOnline(); + if (b_connected != old) { + if (b_connected) { + log(i18n("We are online.")); + setCaption(QString::null, false); + ksettings.b_offline=ksettings.b_offlineMode; + checkQueue(); + } else { + log(i18n("We are offline.")); + setCaption(i18n("Offline"), false); + ksettings.b_offline=true; + stopAll(); + } + } +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +void KMainWidget::checkOnline() +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + struct ifreq ifr; + + memset(&ifr, 0, sizeof(ifreq)); + + // setup the device name according to the type of connection and link number + snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s%d", ConnectionDevices[ksettings.connectionType].ascii(), ksettings.linkNumber); + + bool flag = false; + + if (ksettings.connectionType != PERMANENT) { + // get the flags for particular device + if (ioctl(_sock, SIOCGIFFLAGS, &ifr) < 0) { + flag = true; + b_connected = false; + } else if (ifr.ifr_flags == 0) { +#ifdef _DEBUG + sDebug << "Can't get flags from interface " << ifr.ifr_name << endl; +#endif + b_connected = false; + } else if (ifr.ifr_flags & IFF_UP) { // if (ifr.ifr_flags & IFF_RUNNING) + b_connected = true; + } else { + b_connected = false; + } + } else { + b_connected = true; // PERMANENT connection + } + + m_paOfflineMode->setEnabled(b_connected); + + if (flag) { +#ifdef _DEBUG + sDebug << "Unknown interface " << ifr.ifr_name << endl; +#endif + } +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + + +// Helper method for opening device socket + + + + +static int sockets_open() +{ +#ifdef _DEBUG + sDebugIn << endl; +#endif + + inet_sock = socket(AF_INET, SOCK_DGRAM, 0); +#ifdef AF_IPX + ipx_sock = socket(AF_IPX, SOCK_DGRAM, 0); +#else + ipx_sock = -1; +#endif + +#ifdef AF_AX25 + ax25_sock = socket(AF_AX25, SOCK_DGRAM, 0); +#else + ax25_sock = -1; +#endif + + ddp_sock = socket(AF_APPLETALK, SOCK_DGRAM, 0); + /* + * Now pick any (exisiting) useful socket family for generic queries + */ + + sDebug << "<<<<Leaving -> sockets_open () " << endl; + if (inet_sock != -1) + return inet_sock; + if (ipx_sock != -1) + return ipx_sock; + if (ax25_sock != -1) + return ax25_sock; + /* + * If this is -1 we have no known network layers and its time to jump. + */ + +#ifdef _DEBUG + sDebugOut << endl; +#endif + + return ddp_sock; +} + + +/** No descriptions */ +void KMainWidget::customEvent(QCustomEvent * _e) +{ +#ifdef _DEBUG + //sDebugIn << endl; +#endif + + + SlaveEvent *e = (SlaveEvent *) _e; + unsigned int result = e->getEvent(); + + switch (result) { + + // running cases.. + case Slave::SLV_PROGRESS_SIZE: + e->getItem()->slotProcessedSize(e->getData()); + break; + case Slave::SLV_PROGRESS_SPEED: + e->getItem()->slotSpeed(e->getData()); + break; + + case Slave::SLV_RESUMED: + e->getItem()->slotExecResume(); + break; + + // stopping cases + case Slave::SLV_FINISHED: + e->getItem()->slotFinished(); + break; + case Slave::SLV_PAUSED: + e->getItem()->slotExecPause(); + break; + case Slave::SLV_SCHEDULED: + e->getItem()->slotExecSchedule(); + break; + + case Slave::SLV_DELAYED: + e->getItem()->slotExecDelay(); + break; + case Slave::SLV_CONNECTED: + e->getItem()->slotExecConnected(); + break; + + case Slave::SLV_CAN_RESUME: + e->getItem()->slotCanResume((bool) e->getData()); + break; + + case Slave::SLV_TOTAL_SIZE: + e->getItem()->slotTotalSize(e->getData()); + break; + + case Slave::SLV_ERROR: + e->getItem()->slotExecError(); + break; + + case Slave::SLV_BROKEN: + e->getItem()->slotExecBroken(); + break; + + case Slave::SLV_REMOVED: + e->getItem()->slotExecRemove(); + break; + + case Slave::SLV_INFO: + e->getItem()->logMessage(e->getMsg()); + break; + + case Slave::SLV_NOTINCACHE: + e->getItem()->NotInCache(); + break; + default: +#ifdef _DEBUG + sDebug << "Unknown Result..die" << result << endl; +#endif + assert(0); + } + + +#ifdef _DEBUG + //sDebugOut << endl; +#endif +} + +QString KMainWidget::getSaveDirectoryFor( const QString& filename ) const +{ + // first set destination directory to current directory ( which is also last used ) + QString destDir = ksettings.lastDirectory; + + if (!ksettings.b_useLastDir) { + // check wildcards for default directory + DirList::Iterator it; + for (it = ksettings.defaultDirList.begin(); it != ksettings.defaultDirList.end(); ++it) { + QRegExp rexp((*it).extRegexp); + + rexp.setWildcard(true); + + if ((rexp.search( filename )) != -1) { + destDir = (*it).defaultDir; + break; + } + } + } + + return destDir; +} + +bool KMainWidget::sanityChecksSuccessful( const KURL& url ) +{ + if (!url.isValid() || !KProtocolInfo::supportsReading( url ) ) + { + if (!ksettings.b_expertMode) + KMessageBox::error(this, i18n("Malformed URL:\n%1").arg(url.prettyURL()), i18n("Error")); + + return false; + } + // if we find this URL in the list + Transfer *transfer = myTransferList->find( url ); + if ( transfer ) + { + if ( transfer->getStatus() != Transfer::ST_FINISHED ) + { + if ( !ksettings.b_expertMode ) + { + KMessageBox::error(this, i18n("Already saving URL\n%1").arg(url.prettyURL()), i18n("Error")); + } + + transfer->showIndividual(); + return false; + } + + else // transfer is finished, ask if we want to download again + { + if ( ksettings.b_expertMode || + (KMessageBox::questionYesNo(this, i18n("Already saved URL\n%1\nDownload again?").arg(url.prettyURL()),i18n("Question"),i18n("Download Again"),KStdGuiItem::cancel() ) + == KMessageBox::Yes) ) + { + transfer->slotRequestRemove(); + checkQueue(); + return true; + } + } + + return false; + } + + // why restrict this to ftp and http? (pfeiffer) +// // don't download file URL's TODO : uncomment? +// if (url.protocol() == "http" && url.protocol() != "ftp") { +// KMessageBox::error(this, i18n("File protocol not accepted!\n%1").arg(url.prettyURL()), i18n("Error")); +// #ifdef _DEBUG +// sDebugOut << endl; +// #endif +// return false; +// } + + return true; +} + +bool KMainWidget::isDropTargetVisible() const +{ + return m_showDropTarget; +} + +void KMainWidget::setDropTargetVisible( bool setVisible ) +{ + if ( setVisible != isDropTargetVisible() ) + { + m_paDropTarget->activate(); + } +} + +void KMainWidget::setOfflineMode( bool offline ) +{ + if ( ksettings.b_offlineMode != offline ) + slotToggleOfflineMode(); +} + +bool KMainWidget::isOfflineMode() const +{ + return ksettings.b_offlineMode; +} + +void KMainWidget::activateDropTarget() +{ + setDropTargetVisible( true ); +} + +void KMainWidget::slotShowMenubar() +{ + if(m_menubarAction->isChecked()) + menuBar()->show(); + else + menuBar()->hide(); +} + +#include "kmainwidget.moc" diff --git a/kget/kmainwidget.h b/kget/kmainwidget.h new file mode 100644 index 00000000..ce7c9ea8 --- /dev/null +++ b/kget/kmainwidget.h @@ -0,0 +1,232 @@ +/*************************************************************************** +* kmainwidget.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _KMAINWIDGET_H_ +#define _KMAINWIDGET_H_ + +#include <kmainwindow.h> +#include <kaction.h> +#include <kurl.h> +#include "common.h" + +#include "kget_iface.h" + +class KAction; +//class KToggleAction; +class KRadioAction; + +class DockWidget; +class DropTarget; +class LogWindow; +class DlgPreferences; + +class Transfer; +class TransferList; +class Settings; + + +class KMainWidget:public KMainWindow, virtual public KGetIface +{ + +Q_OBJECT + +public: + enum StatusbarFields { ID_TOTAL_TRANSFERS = 1, ID_TOTAL_FILES, ID_TOTAL_SIZE, + ID_TOTAL_TIME , ID_TOTAL_SPEED }; + + KMainWidget(bool bShowMain = false); + ~KMainWidget(); + + void addTransfer( const QString& src ); + void addTransferEx( const KURL& url, + const KURL& destFile = KURL()); + + // dcop interface + virtual void addTransfers( const KURL::List& src, const QString& destDir = QString::null ); + virtual bool isDropTargetVisible() const; + virtual void setDropTargetVisible( bool setVisible ); + + + void checkQueue(); + + void setListFont(); + void setAutoSave(); + void setAutoDisconnect(); + + LogWindow *logwin()const { return logWindow;} + friend class Settings; + + // Actions + KToggleAction *m_paShowLog; + KToggleAction *m_menubarAction; + KAction *m_paPreferences; + KAction *m_paQuit; + bool b_viewLogWindow; + + void readTransfersEx(const KURL & url); + + void activateDropTarget(); + +public slots: + void slotPasteTransfer(); + void slotToggleLogWindow(); + void slotPreferences(); + void slotConfigureNotifications(); + void slotToggleExpertMode(); + void slotToggleOfflineMode(); + void slotToggleUseLastDir(); + void slotToggleAutoDisconnect(); + void slotToggleAutoShutdown(); + void slotToggleAutoPaste(); + void slotToggleDropTarget(); + void slotToggleAnimation(); + void slotUpdateActions(); + void slotKonquerorIntegration(); + +protected slots: + void slotQuit(); + + void slotOpenTransfer(); + void slotExportTransfers(); + void slotImportTransfers(); + void slotImportTextFile(); + + void slotSaveYourself(); + void slotCheckConnection(); + + + void slotStatusChanged(Transfer * item, int _operation); + + void slotResumeCurrent(); + void slotPauseCurrent(); + void slotDeleteCurrent(); + void slotRestartCurrent(); + + void slotQueueCurrent(); + void slotTimerCurrent(); + void slotDelayCurrent(); + + void slotOpenIndividual(); + + void slotAnimTimeout(); + void slotTransferTimeout(); + void slotAutosaveTimeout(); + + void slotMoveToBegin(); + void slotMoveToEnd(); + + void slotCopyToClipboard(); + void slotCheckClipboard(); + + void slotConfigureToolbars(); + void slotNewToolbarConfig(); + void slotShowMenubar(); + + void slotPopupMenu(Transfer * item); + +protected: + virtual void setOfflineMode( bool online ); + virtual bool isOfflineMode() const; + virtual bool queryClose(); + void writeLog(); + + // drag and drop + virtual void dragEnterEvent(QDragEnterEvent *); + virtual void dropEvent(QDropEvent *); + + void readTransfers(bool ask_for_name = false); + void writeTransfers(bool ask_for_name = false); + + + void setupGUI(); + void setupWhatsThis(); + + void updateStatusBar(); + + // some flags + bool b_connected; + bool b_viewPreferences; + + // utility functions + void onlineDisconnect(); + void checkOnline(); + void stopAll(); + void log(const QString & message, bool statusbar = true); + + /** No descriptions */ + virtual void customEvent(QCustomEvent * e); + + // various timers + QTimer *animTimer; // animation timer + QTimer *connectionTimer; // timer that checks whether we are online + QTimer *transferTimer; // timer for scheduled transfers + QTimer *autosaveTimer; // timer for autosaving transfer list + QTimer *clipboardTimer; // timer for checking clipboard - autopaste function + + QString logFileName; + + + +private: + QString getSaveDirectoryFor( const QString& filename ) const; + bool sanityChecksSuccessful( const KURL& url ); + + TransferList * myTransferList; + KHelpMenu *menuHelp; + + LogWindow *logWindow; + DlgPreferences *prefDlg; + DockWidget *kdock; + + QString lastClipboard; + + uint animCounter; + + int _sock; + + // Actions + KAction *m_paOpenTransfer, *m_paPasteTransfer, *m_paExportTransfers, *m_paImportTransfers; + KAction *m_paImportText; + + KAction *m_paMoveToBegin, *m_paMoveToEnd, *m_paCopy, *m_paIndividual; + KAction *m_paResume, *m_paPause, *m_paDelete, *m_paRestart; + KRadioAction *m_paQueue, *m_paTimer, *m_paDelay; + + KToggleAction *m_paUseAnimation; + KToggleAction *m_paExpertMode, *m_paUseLastDir, *m_paOfflineMode; + KToggleAction *m_paAutoDisconnect, *m_paAutoShutdown, *m_paAutoPaste; + + KAction *m_paDropTarget; + KAction *m_paKonquerorIntegration; + bool m_showDropTarget; + +}; + +extern KMainWidget *kmain; +extern DropTarget *kdrop; + +#endif // _KMAINWIDGET_H_ diff --git a/kget/logwindow.cpp b/kget/logwindow.cpp new file mode 100644 index 00000000..5d6f77ad --- /dev/null +++ b/kget/logwindow.cpp @@ -0,0 +1,218 @@ +/*************************************************************************** +* logwindow.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <qlayout.h> +#include <qlistview.h> + +#include <klocale.h> +#include <kdialog.h> +#include <kaction.h> + +#include "transfer.h" +#include "kmainwidget.h" +#include "logwindow.h" + +#include <kapplication.h> +#include <qtextedit.h> + +// // Replace regular space with nbsp +// QString replaceSpaces(const QString &str) { +// QString res = str; +// res.simplifyWhiteSpace(); + +// int pos; +// while ( (pos = res.find(' ')) != -1) { +// res.replace(pos, 1, new QChar( 0x00a0 ), 1); +// } + +// return res; +// } + + +static QString removeHTML(const QString & str) +{ + QString res = str; + int pos; + + // replace <br/> with a newline + while ((pos = res.find("<br/>")) != -1) { + res.replace(pos, 4, "\n"); + } + + // remove all tags + while ((pos = res.find('<')) != -1) { + int pos2 = res.find('>', pos); + + if (pos2 == -1) { + pos2 = res.length() + 1; + } + res.remove(pos, pos2 - pos + 1); + } + + return res; +} + + +SeparatedLog::SeparatedLog(QWidget * parent):QWidget(parent) +{ + idSelected = 0; + + QGridLayout *topGridLayout = new QGridLayout(this, 1, 2, 0, KDialog::spacingHint()); + + topGridLayout->setRowStretch(0, 5); + + topGridLayout->setColStretch(0, 3); + topGridLayout->setColStretch(1, 10); + + lv_log = new QListView(this); + lv_log->setMultiSelection(false); + lv_log->setAllColumnsShowFocus(true); + lv_log->setSorting(-1); + + lv_log->addColumn(i18n("Id"), 40); + lv_log->addColumn(i18n("Name"), 100); + + topGridLayout->addWidget(lv_log, 0, 0); + + connect(lv_log, SIGNAL(selectionChanged(QListViewItem *)), SLOT(transferSelected(QListViewItem *))); + + ml_log = new QTextEdit(this); + ml_log->setTextFormat(LogText); + ml_log->setMinimumSize(300, 200); + ml_log->setVScrollBarMode(QScrollView::Auto); + ml_log->setWordWrap(QTextEdit::NoWrap); + + topGridLayout->addWidget(ml_log, 0, 1); +} + + +void SeparatedLog::addLog(uint id, const QString & filename, const QString & message) +{ + if (!trMap.contains(id)) { + trMap.insert(id, message); + QListViewItem *last=lv_log->lastItem(); + new QListViewItem(lv_log, last); + last=lv_log->lastItem(); + last->setText(0, QString::number(id)); + last->setText(1, filename); + // if I don't do this, ID#10 gets sorted between ID#1 and ID#2, ugly. + } else { + trMap[id] += ("\n"+message); + } + + if (idSelected == id) { + refresh(); + } +} + + +void SeparatedLog::transferSelected(QListViewItem * item) +{ + if (item) { + idSelected = item->text(0).toUInt(); + // kapp->lock(); + ml_log->setText(trMap[idSelected]); + // kapp->unlock(); + } +} + + +void SeparatedLog::refresh() +{ + if (idSelected > 0) { + // kapp->lock(); + ml_log->setText(trMap[idSelected]); + // kapp->unlock(); + } +} + + +//////////////////////// + + + + +LogWindow::LogWindow():KDialogBase(Tabbed, i18n("Log Window"), Close, Close, 0, "", false) +{ + + // add pages + QFrame *page = addPage(i18n("Mixed")); + QVBoxLayout *topLayout = new QVBoxLayout(page, 0, spacingHint()); + + mixed_log = new QTextEdit(page); + mixed_log->setTextFormat(LogText); + mixed_log->setVScrollBarMode(QScrollView::Auto); + mixed_log->setWordWrap(QTextEdit::NoWrap); + topLayout->addWidget(mixed_log); + + page = addPage(i18n("Separated")); + topLayout = new QVBoxLayout(page, 0, spacingHint()); + sep_log = new SeparatedLog(page); + topLayout->addWidget(sep_log); + + connect(this, SIGNAL(closeClicked()), this, SLOT(close())); + + // resize( 500, 300 ); +} + + +void LogWindow::closeEvent(QCloseEvent *e) +{ + kmain->m_paShowLog->setChecked(false); + kmain->b_viewLogWindow = false; + KDialogBase::closeEvent( e ); +} + + +void LogWindow::logGeneral(const QString & message) +{ + QString tmps = "<font color=\"blue\">" + QTime::currentTime().toString() + "</font> : <b>" + message + "</b>"; + + mixed_log->append(tmps); +} + + +void LogWindow::logTransfer(uint id, const QString & filename, const QString & message) +{ + QString mixed_msg, single_msg, job_id; + + job_id = QString("Job[<font color=\"red\">%1</font>] : ").arg(id); + mixed_msg = "<font color=\"blue\">" + QTime::currentTime().toString() + "</font> : " + job_id + message; + + single_msg = "<font color=\"blue\">" + QTime::currentTime().toString() + "</font> : " + message; + + mixed_log->append(mixed_msg); + sep_log->addLog(id, filename, single_msg); +} + + +QString LogWindow::getText() const +{ + return removeHTML(mixed_log->text()); +} + +#include "logwindow.moc" diff --git a/kget/logwindow.h b/kget/logwindow.h new file mode 100644 index 00000000..a2aa13d5 --- /dev/null +++ b/kget/logwindow.h @@ -0,0 +1,85 @@ +/*************************************************************************** +* logwindow.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _LOGWINDOW_H +#define _LOGWINDOW_H + +#include <qmap.h> + +#include <kdialogbase.h> + +class QListView; +class QTextEdit; + + +class SeparatedLog:public QWidget +{ + +Q_OBJECT public: + SeparatedLog(QWidget * parent); + ~SeparatedLog() + {} + void addLog(uint id, const QString & filename, const QString & message); + void refresh(); + +protected slots: + void transferSelected(QListViewItem * item); + +private: + QListView * lv_log; + QTextEdit *ml_log; + + typedef QMap < uint, QString > TransferMap; + TransferMap trMap; + + uint idSelected; +}; + + +class LogWindow:public KDialogBase +{ + +Q_OBJECT public: + LogWindow(); + ~LogWindow() + {} + void logGeneral(const QString & message); + QString getText() const; + +public slots: + void logTransfer(uint id, const QString & filename, const QString & message); + +protected: + void closeEvent(QCloseEvent *); + +private: + QTextEdit * mixed_log; + SeparatedLog *sep_log; +}; + + +#endif // _LOGWINDOW_H diff --git a/kget/main.cpp b/kget/main.cpp new file mode 100644 index 00000000..cd3341b5 --- /dev/null +++ b/kget/main.cpp @@ -0,0 +1,225 @@ +/*************************************************************************** +* main.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <kwin.h> +#include <klocale.h> +#include <kaboutdata.h> +#include <kcmdlineargs.h> +#include <kurl.h> +#include <kuniqueapplication.h> +#include <kstartupinfo.h> + +#include <signal.h> +#include <unistd.h> +#include <stdio.h> +#include <stdlib.h> +#include "kmainwidget.h" +#include "version.h" + + + +static const char description[] = I18N_NOOP("An advanced download manager for KDE"); + +static const char version[] = KGETVERSION; + + +static KCmdLineOptions option[] = { + { "showDropTarget", I18N_NOOP("Start KGet with drop target"), 0 }, + {"+[URL(s)]", I18N_NOOP("URL(s) to download"), 0}, + KCmdLineLastOption + }; + +static void cleanup(void); +static void setSignalHandler(void (*handler) (int)); + +//static msg_handler oldMsgHandler = 0L; + +//----------------------------------------------------------------------------- +// Crash recovery signal handler +static void signalHandler(int sigId) +{ + fprintf(stderr, "*** KGet got signal %d\n", sigId); + + if (sigId != SIGSEGV && kmain) { + fprintf(stderr, "*** KGet saving data\n"); + delete kmain; + } + // If Kget crashes again below this line we consider the data lost :-| + // Otherwise Kget will end in an infinite loop. + setSignalHandler(SIG_DFL); + cleanup(); + exit(1); +} + + +//----------------------------------------------------------------------------- +static void setSignalHandler(void (*handler) (int)) +{ + signal(SIGSEGV, handler); + signal(SIGKILL, handler); + signal(SIGTERM, handler); + signal(SIGHUP, handler); + signal(SIGFPE, handler); + signal(SIGABRT, handler); + + // catch also the keyboard interrupt + signal(SIGINT, handler); +} + + +static void cleanup(void) +{ + qInstallMsgHandler(0L /*oldMsgHandler*/); +// QString cmd; +} + + +class KGetApp : public KUniqueApplication +{ +private: + KMainWidget *kmainwidget; + +public: + KGetApp() : KUniqueApplication() + { +#ifdef _DEBUG + sDebugIn << endl; +#endif + + kmainwidget=0; + +#ifdef _DEBUG + sDebugOut << endl; +#endif + } + + ~KGetApp() + { +#ifdef _DEBUG + sDebugIn << endl; +#endif + delete kmainwidget; +#ifdef _DEBUG + sDebugOut << endl; +#endif + } + + + int newInstance() + { +#ifdef _DEBUG + sDebugIn <<"kmainwidget="<<kmainwidget << endl; +#endif + + KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); + + + if (kmainwidget==0) + { + if(args->count()>0) + kmainwidget=new KMainWidget(true); + else + kmainwidget=new KMainWidget(); + setMainWidget(kmain); + } + + else + KStartupInfo::setNewStartupId( mainWidget(), kapp->startupId()); + + if (args->isSet("showDropTarget")) + kmain->activateDropTarget(); + + if (args->count()==1) + { +#ifdef _DEBUG + sDebug <<"args(0)= "<<args->arg(0) << endl; +#endif + QString txt(args->arg(0)); + if ( txt.endsWith( ".kgt" ) ) + kmain->readTransfersEx(KURL::fromPathOrURL( txt )); + else + kmain->addTransferEx( KURL::fromPathOrURL( txt ), + KURL()); + } + else if(args->count()>=2) + { + KURL::List urls; + for( int i=0; i < args->count(); ++i){ + urls.append(KURL::fromPathOrURL( args->arg(i))); + } + + // Sometimes valid filenames are not recognised by KURL::isLocalFile(), they are marked as invalid then + if ( args->count()==2 && ( urls.last().isLocalFile() || !urls.last().isValid())) + { + kmain->addTransferEx( urls.first(), urls.last() ); + } + else + { + kmain->addTransfers( urls, QString() ); + } + } + args->clear(); + +#ifdef _DEBUG + sDebugOut << endl; +#endif + + return 0; + } +}; + + +///////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + KAboutData aboutData("kget", I18N_NOOP("KGet"), version, description, KAboutData::License_GPL, "(C) 2001 - 2002, Patrick Charbonnier \n(C) 2002, Carsten Pfeiffer\n(C) 1998 - 2000, Matej Koss", "[email protected]", 0); + + aboutData.addAuthor("Patrick Charbonnier", 0, "[email protected]"); + aboutData.addAuthor("Carsten Pfeiffer", 0, "[email protected]"); + aboutData.addAuthor("Matej Koss", 0); + + + KCmdLineArgs::init(argc, argv, &aboutData); + KCmdLineArgs::addCmdLineOptions(option); + + KGetApp::addCmdLineOptions(); + + if (!KGetApp::start()) { + fprintf(stderr, "kget is already running!\n"); + return 0; + } + + KGetApp kApp; + +// disabling he custom signal handler, so at least we have the backtraces for +// crashes... +// setSignalHandler(signalHandler); + kApp.exec(); + + cleanup(); +} diff --git a/kget/pics/Makefile.am b/kget/pics/Makefile.am new file mode 100644 index 00000000..6ca36d36 --- /dev/null +++ b/kget/pics/Makefile.am @@ -0,0 +1,11 @@ +pics_DATA = connect0.png connect1.png connect2.png connect3.png \ + connect4.png connect5.png connect6.png connect7.png \ + try0.png try1.png try2.png try3.png \ + try4.png try5.png try6.png try7.png \ + md_delayed.png md_finished.png md_queued.png md_scheduled.png \ + retrying.png target.png + +picsdir = $(kde_datadir)/kget/pics + +EXTRA_DIST = $(pics_DATA) + diff --git a/kget/pics/connect0.png b/kget/pics/connect0.png Binary files differnew file mode 100644 index 00000000..658ce773 --- /dev/null +++ b/kget/pics/connect0.png diff --git a/kget/pics/connect1.png b/kget/pics/connect1.png Binary files differnew file mode 100644 index 00000000..9d2e472a --- /dev/null +++ b/kget/pics/connect1.png diff --git a/kget/pics/connect2.png b/kget/pics/connect2.png Binary files differnew file mode 100644 index 00000000..3e948c8d --- /dev/null +++ b/kget/pics/connect2.png diff --git a/kget/pics/connect3.png b/kget/pics/connect3.png Binary files differnew file mode 100644 index 00000000..1e700ddf --- /dev/null +++ b/kget/pics/connect3.png diff --git a/kget/pics/connect4.png b/kget/pics/connect4.png Binary files differnew file mode 100644 index 00000000..5f651e5f --- /dev/null +++ b/kget/pics/connect4.png diff --git a/kget/pics/connect5.png b/kget/pics/connect5.png Binary files differnew file mode 100644 index 00000000..eb951247 --- /dev/null +++ b/kget/pics/connect5.png diff --git a/kget/pics/connect6.png b/kget/pics/connect6.png Binary files differnew file mode 100644 index 00000000..23b7ef14 --- /dev/null +++ b/kget/pics/connect6.png diff --git a/kget/pics/connect7.png b/kget/pics/connect7.png Binary files differnew file mode 100644 index 00000000..02ddd04f --- /dev/null +++ b/kget/pics/connect7.png diff --git a/kget/pics/md_delayed.png b/kget/pics/md_delayed.png Binary files differnew file mode 100644 index 00000000..17d135a9 --- /dev/null +++ b/kget/pics/md_delayed.png diff --git a/kget/pics/md_finished.png b/kget/pics/md_finished.png Binary files differnew file mode 100644 index 00000000..5b1dac57 --- /dev/null +++ b/kget/pics/md_finished.png diff --git a/kget/pics/md_queued.png b/kget/pics/md_queued.png Binary files differnew file mode 100644 index 00000000..93e004b7 --- /dev/null +++ b/kget/pics/md_queued.png diff --git a/kget/pics/md_scheduled.png b/kget/pics/md_scheduled.png Binary files differnew file mode 100644 index 00000000..79f751df --- /dev/null +++ b/kget/pics/md_scheduled.png diff --git a/kget/pics/retrying.png b/kget/pics/retrying.png Binary files differnew file mode 100644 index 00000000..7c107550 --- /dev/null +++ b/kget/pics/retrying.png diff --git a/kget/pics/target.png b/kget/pics/target.png Binary files differnew file mode 100644 index 00000000..e71e668e --- /dev/null +++ b/kget/pics/target.png diff --git a/kget/pics/try0.png b/kget/pics/try0.png Binary files differnew file mode 100644 index 00000000..6d0cf4d1 --- /dev/null +++ b/kget/pics/try0.png diff --git a/kget/pics/try1.png b/kget/pics/try1.png Binary files differnew file mode 100644 index 00000000..5041101c --- /dev/null +++ b/kget/pics/try1.png diff --git a/kget/pics/try2.png b/kget/pics/try2.png Binary files differnew file mode 100644 index 00000000..f6f67818 --- /dev/null +++ b/kget/pics/try2.png diff --git a/kget/pics/try3.png b/kget/pics/try3.png Binary files differnew file mode 100644 index 00000000..b9af2b38 --- /dev/null +++ b/kget/pics/try3.png diff --git a/kget/pics/try4.png b/kget/pics/try4.png Binary files differnew file mode 100644 index 00000000..0948b759 --- /dev/null +++ b/kget/pics/try4.png diff --git a/kget/pics/try5.png b/kget/pics/try5.png Binary files differnew file mode 100644 index 00000000..f6f67818 --- /dev/null +++ b/kget/pics/try5.png diff --git a/kget/pics/try6.png b/kget/pics/try6.png Binary files differnew file mode 100644 index 00000000..5041101c --- /dev/null +++ b/kget/pics/try6.png diff --git a/kget/pics/try7.png b/kget/pics/try7.png Binary files differnew file mode 100644 index 00000000..9acacca1 --- /dev/null +++ b/kget/pics/try7.png diff --git a/kget/safedelete.cpp b/kget/safedelete.cpp new file mode 100644 index 00000000..c4cb6915 --- /dev/null +++ b/kget/safedelete.cpp @@ -0,0 +1,35 @@ +#include <klocale.h> +#include <kmessagebox.h> +#include <kurl.h> +#include <kio/netaccess.h> + +#include <qfileinfo.h> + +#include "safedelete.h" + +bool SafeDelete::deleteFile( const KURL& url ) +{ + if ( url.isLocalFile() ) + { + QFileInfo info( url.path() ); + if ( info.isDir() ) + { + KMessageBox::information(0L, + i18n("Not deleting\n%1\nas it is a " + "directory.").arg( url.prettyURL() ), + i18n("Not Deleted")); + return false; + } + + KIO::NetAccess::del( url, 0L ); + return true; + } + + else + KMessageBox::information( 0L, + i18n("Not deleting\n%1\nas it is not a local" + " file.").arg( url.prettyURL() ), + i18n("Not Deleted") ); + + return false; +} diff --git a/kget/safedelete.h b/kget/safedelete.h new file mode 100644 index 00000000..c93ebb67 --- /dev/null +++ b/kget/safedelete.h @@ -0,0 +1,19 @@ +/**************************************************************************** +** $Id$ +** +** Copyright (C) 2002 Carsten Pfeiffer <[email protected]> +** +****************************************************************************/ + +#ifndef SAFEDELETE_H +#define SAFEDELETE_H + +class KURL; + +class SafeDelete +{ +public: + static bool deleteFile( const KURL& url ); +}; + +#endif // SAFEDELETE_H diff --git a/kget/settings.cpp b/kget/settings.cpp new file mode 100644 index 00000000..da066a6a --- /dev/null +++ b/kget/settings.cpp @@ -0,0 +1,287 @@ +/*************************************************************************** +* settings.cpp +* ------------------- +* +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kglobal.h> +#include <kconfig.h> +#include <klocale.h> +#include <kwin.h> +#include <kmessagebox.h> +#include <kglobalsettings.h> +#include <netwm_def.h> + +#include <qdir.h> + +#include "kmainwidget.h" +#include "transferlist.h" +#include "droptarget.h" +#include "settings.h" +#include "common.h" +#include "version.h" + +static const unsigned long DEFAULT_DOCK_STATE = (NET::SkipTaskbar | NET::StaysOnTop); + +QString ConnectionDevices[6] = { + "", + "eth", + "plip", + "slip", + "ppp", + "isdn" + }; + + +void +Settings::load() +{ + sDebug << "Loading settings" << endl; + + KConfig *config = kapp->config(); + + // read system options + config->setGroup("System"); + + // read connection options + config->setGroup("Connection"); + + b_reconnectOnError = config->readBoolEntry("ReconnectOnError", DEF_ReconnectOnError); + reconnectTime = config->readNumEntry("ReconnectTime", DEF_ReconnectTime); + reconnectRetries = config->readNumEntry("ReconnectRetries", DEF_ReconnectRetries); + b_reconnectOnBroken = config->readBoolEntry("ReconnectOnBroken", DEF_ReconnectOnBroken); + + timeoutData = config->readNumEntry("TimeoutData", DEF_TimeoutData); + timeoutDataNoResume = config->readNumEntry("TimeoutDataNoResume", DEF_TimeoutDataNoResume); + + connectionType = config->readNumEntry("ConnectionType", DEF_ConnectionType); + linkNumber = config->readNumEntry("LinkNumber", DEF_LinkNumber); + b_offlineMode = config->readBoolEntry("OfflineMode", DEF_OfflineMode); + + // read automation options + config->setGroup("Automation"); + + b_autoSave = config->readBoolEntry("AutoSave", DEF_AutoSave); + autoSaveInterval = config->readNumEntry("AutoSaveInterval", DEF_AutoSaveInterval); + + b_autoDisconnect = config->readBoolEntry("AutoDisconnect", DEF_AutoDisconnect); + disconnectCommand = config->readPathEntry("DisconnectCommand", DEF_DisconnectCommand); + + b_timedDisconnect = config->readBoolEntry("TimedDisconnect", DEF_TimedDisconnect); + disconnectTime.setHMS(config->readNumEntry("DisconnectTimeHour"), config->readNumEntry("DisconnectTimeMinute"), 0); + + disconnectDate = QDate::currentDate(); // doesn't make sense to save it + + b_autoShutdown = config->readBoolEntry("AutoShutdown", DEF_AutoShutdown); + b_autoPaste = config->readBoolEntry("AutoPaste", DEF_AutoPaste); + + // read limits options + config->setGroup("Limits"); + + maxSimultaneousConnections = config->readNumEntry("MaxSimConnections", DEF_MaxSimConnections); + minimumBandwidth = config->readNumEntry("MinimumBandwidth", DEF_MinimumBandwidth); + maximumBandwidth = config->readNumEntry("MaximumBandwidth", DEF_MaximumBandwidth); + + // read advanced options + config->setGroup("Advanced"); + + b_addQueued = config->readBoolEntry("AddQueued", DEF_AddQueued); + b_showMain = config->readBoolEntry("ShowMain", DEF_ShowMain); + b_showIndividual = config->readBoolEntry("ShowIndividual", DEF_ShowIndividual); + b_iconifyIndividual = config->readBoolEntry("IconifyIndividual", DEF_IconifyIndividual); + b_advancedIndividual = config->readBoolEntry("AdvancedIndividual", DEF_AdvancedIndividual); + + b_removeOnSuccess = config->readBoolEntry("RemoveOnSuccess", DEF_RemoveOnSuccess); + b_getSizes = config->readBoolEntry("GetSizes", DEF_GetSizes); + b_expertMode = config->readBoolEntry("ExpertMode", DEF_ExpertMode); + + // read if the integration whith konqueror is enabled + + KConfig *cfg = new KConfig("konquerorrc", false, false); + cfg->setGroup("HTML Settings"); + QString downloadManager=cfg->readPathEntry("DownloadManager"); + + b_KonquerorIntegration=(downloadManager==KGET_APP_NAME)?true:false; + + // check if we already asked about konqueror integration + if(config->readBoolEntry("FirstRun",true)) + { + config->writeEntry("FirstRun",false); + bool bAnswerYes = KMessageBox::questionYesNo(0L,i18n("This is the first time that you have run KGet.\nDo you want to use KGet as Download Manager for Konqueror?"), i18n("Konqueror Integration"), i18n("Enable"), i18n("Do Not Enable")) == KMessageBox::Yes; + if (bAnswerYes) + { + cfg->writePathEntry("DownloadManager", QString(KGET_APP_NAME)); + cfg->sync(); + b_KonquerorIntegration=true; + } + } + delete cfg; + + + // read search options + config->setGroup("Search"); + b_searchFastest = config->readBoolEntry("SearchFastest", DEF_SearchFastest); + searchItems = config->readNumEntry("SearchItems", DEF_SearchItems); + timeoutSearch = config->readNumEntry("TimeoutSearch", DEF_TimeoutSearch); + b_switchHosts = config->readBoolEntry("SwitchHosts", DEF_SwitchHosts); + + // read directory options + config->setGroup("Directories"); + + b_useLastDir = config->readBoolEntry("UseLastDirectory", DEF_UseLastDir); + lastDirectory = config->readPathEntry("LastDirectory", + QString("file:") + QDir::currentDirPath() ); + + QStringList strList; + + strList = config->readPathListEntry("Items"); + + defaultDirList.clear(); + QStringList::Iterator it = strList.begin(); + for (; it != strList.end(); ++it) { + DirItem item; + + item.extRegexp = *it; + ++it; + item.defaultDir = *it; + defaultDirList.append(item); + } + + // read misc settings + config->setGroup("Misc"); + + QFont font = KGlobalSettings::generalFont(); + + listViewFont = config->readFontEntry("Font", &font); + + // read main window geometry settings + config->setGroup("MainGeometry"); + const QPoint point(-1,-1); + mainPosition = config->readPointEntry("Position", &point); + mainSize = config->readSizeEntry("Size"); + mainState = config->readUnsignedLongNumEntry("State", 0); + + // read drop target geometry settings + config->setGroup("DropGeometry"); + dropPosition = config->readPointEntry("Position", &point); + dropState = config->readUnsignedLongNumEntry("State", DEFAULT_DOCK_STATE ); + + // flushing pending changes + config->sync(); +} + + +void Settings::save() +{ + sDebug << "Saving settings" << endl; + + KConfig *config = kapp->config(); + + // write connection options + config->setGroup("Connection"); + config->writeEntry("ReconnectOnError", b_reconnectOnError); + config->writeEntry("ReconnectTime", reconnectTime); + config->writeEntry("ReconnectRetries", reconnectRetries); + config->writeEntry("ReconnectOnBroken", b_reconnectOnBroken); + config->writeEntry("TimeoutData", timeoutData); + config->writeEntry("TimeoutDataNoResume", timeoutDataNoResume); + config->writeEntry("ConnectionType", connectionType); + config->writeEntry("LinkNumber", linkNumber); + config->writeEntry("OfflineMode", b_offlineMode); + + // write automation options + config->setGroup("Automation"); + config->writeEntry("AutoSave", b_autoSave); + config->writeEntry("AutoSaveInterval", autoSaveInterval); + config->writeEntry("AutoDisconnect", b_autoDisconnect); + config->writePathEntry("DisconnectCommand", disconnectCommand); + config->writeEntry("TimedDisconnect", b_timedDisconnect); + config->writeEntry("DisconnectTimeHour", disconnectTime.hour()); + config->writeEntry("DisconnectTimeMinute", disconnectTime.minute()); + config->writeEntry("AutoShutdown", b_autoShutdown); + config->writeEntry("AutoPaste", b_autoPaste); + + // write limits options + config->setGroup("Limits"); + config->writeEntry("MaxSimConnections", maxSimultaneousConnections); + config->writeEntry("MinimumBandwidth", minimumBandwidth); + config->writeEntry("MaximumBandwidth", maximumBandwidth); + + // write advanced options + config->setGroup("Advanced"); + config->writeEntry("ShowMain", b_showMain); + config->writeEntry("AddQueued", b_addQueued); + config->writeEntry("ShowIndividual", b_showIndividual); + config->writeEntry("IconifyIndividual", b_iconifyIndividual); + config->writeEntry("AdvancedIndividual", b_advancedIndividual); + config->writeEntry("RemoveOnSuccess", b_removeOnSuccess); + config->writeEntry("GetSizes", b_getSizes); + config->writeEntry("ExpertMode", b_expertMode); + config->writeEntry("KonquerorIntegration",b_KonquerorIntegration); + + + // write search options + config->setGroup("Search"); + config->writeEntry("SearchFastest", b_searchFastest); + config->writeEntry("SearchItems", searchItems); + config->writeEntry("TimeoutSearch", timeoutSearch); + config->writeEntry("SwitchHosts", b_switchHosts); + + // write directory options + config->setGroup("Directories"); + config->writeEntry("UseLastDirectory", b_useLastDir); + config->writePathEntry("LastDirectory", lastDirectory ); + DirList::Iterator it; + QStringList lst; + + for (it = defaultDirList.begin(); it != defaultDirList.end(); ++it) { + lst.append((*it).extRegexp); + lst.append((*it).defaultDir); + } + config->writePathEntry("Items", lst); + + // write system options + config->setGroup("System"); + config->writeEntry("UseAnimation", b_useAnimation); + + // write misc options + config->setGroup("Misc"); + config->writeEntry("Font", listViewFont); + + // write main window geometry properties + config->setGroup("MainGeometry"); + config->writeEntry("Position", kmain->pos()); + config->writeEntry("Size", kmain->size()); + config->writeEntry("State", KWin::windowInfo(kmain->winId()).state()); + + // write drop target geometry properties + config->setGroup("DropGeometry"); + config->writeEntry("Position", kdrop->pos()); + unsigned long state = KWin::windowInfo(kdrop->winId()).state(); + // state will be 0L if droptarget is hidden. Sigh. + config->writeEntry("State", state ? state : DEFAULT_DOCK_STATE ); + + + config->sync(); +} diff --git a/kget/settings.h b/kget/settings.h new file mode 100644 index 00000000..c66b00e6 --- /dev/null +++ b/kget/settings.h @@ -0,0 +1,186 @@ +/*************************************************************************** +* settings.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _SETTINGS_H +#define _SETTINGS_H + +// common connection types +enum ConnectionType { PERMANENT = 0, ETHERNET, PLIP, SLIP, PPP, ISDN }; + +extern QString ConnectionDevices[]; + + +// Connection settings +#define DEF_ReconnectOnError true +#define DEF_ReconnectTime 1 +#define DEF_ReconnectRetries 10 +#define DEF_ReconnectOnBroken true + +#define DEF_TimeoutData 5 +#define DEF_TimeoutDataNoResume 15 + +#define DEF_ConnectionType PERMANENT +#define DEF_LinkNumber 0 +#define DEF_OfflineMode false + +// Automation settings +#define DEF_AutoSave true +#define DEF_AutoSaveInterval 10 +#define DEF_AutoDisconnect false +#define DEF_DisconnectCommand "kppp -k" +#define DEF_TimedDisconnect false +#define DEF_AutoShutdown false +#define DEF_AutoPaste false + +// Limits settings +#define DEF_MaxSimConnections 2 +#define DEF_MinimumBandwidth 1000 +#define DEF_MaximumBandwidth 10000 + +// Advanced settings +#define DEF_AddQueued true +#define DEF_ShowMain false +#define DEF_ShowIndividual false +#define DEF_IconifyIndividual false +#define DEF_AdvancedIndividual false +#define DEF_RemoveOnSuccess true +#define DEF_GetSizes true +#define DEF_ExpertMode false + +// Search settings +#define DEF_SearchFastest false +#define DEF_SearchItems 20 +#define DEF_TimeoutSearch 30 +#define DEF_SwitchHosts false + +// Directories settings +#define DEF_UseLastDir false + +// System settings +#define DEF_UseAnimation true + +#define DEF_WindowStyle NORMAL + + +#include <qdatetime.h> + +#include <kwin.h> +#include <qvaluelist.h> +struct DirItem +{ + QString extRegexp; + QString defaultDir; +}; + +typedef QValueList < DirItem > DirList; + +class Settings +{ + +public: + + Settings() + { + } + ~Settings() + { + } + + void load(); + void save(); + + // connection options + bool b_reconnectOnBroken; + bool b_reconnectOnError; + + uint reconnectTime; + uint reconnectRetries; + + uint timeoutData; + uint timeoutDataNoResume; + + uint connectionType; + uint linkNumber; + bool b_offlineMode;// If we want to be offline + bool b_offline; // If we really are offline + + + // automation options + bool b_autoSave; + uint autoSaveInterval; + bool b_autoDisconnect; + QString disconnectCommand; + bool b_timedDisconnect; + QDate disconnectDate; + QTime disconnectTime; + bool b_autoShutdown; + bool b_autoPaste; + + // limits options + uint maxSimultaneousConnections; + uint minimumBandwidth; + uint maximumBandwidth; + + // advanced options + bool b_addQueued; + bool b_showIndividual; + bool b_iconifyIndividual; + bool b_advancedIndividual; + bool b_removeOnSuccess; + bool b_getSizes; + bool b_expertMode; + bool b_KonquerorIntegration; + bool b_showMain; + // search options + bool b_searchFastest; + uint searchItems; + uint timeoutSearch; + bool b_switchHosts; + + // directories options + bool b_useLastDir; + QString lastDirectory; + + DirList defaultDirList; + + // system options + bool b_useAnimation; + QFont listViewFont; + + + // geometry settings + QPoint mainPosition; + QSize mainSize; + unsigned long int mainState; + + QPoint dropPosition; + unsigned long int dropState; +}; + +extern Settings ksettings; + +#endif // _SETTINGS_H diff --git a/kget/slave.cpp b/kget/slave.cpp new file mode 100644 index 00000000..944a7f37 --- /dev/null +++ b/kget/slave.cpp @@ -0,0 +1,331 @@ +/*************************************************************************** +* slave.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include <kapplication.h> +#include <kio/scheduler.h> + +#include "getfilejob.h" +#include "slave.h" +#include "slaveevent.h" +#include "transfer.h" + +#include <assert.h> + +Slave::Slave(Transfer * _parent, const KURL & _src, const KURL & _dest) + : QObject(), + QThread() +{ + mDebug << ">>>>Entering" << endl; + copyjob = NULL; + m_src = _src; + m_dest = _dest; + m_parent = _parent; + + nPendingCommand = 0; + + mDebug << ">>>>Leaving" << endl; +} + +Slave::~Slave() +{} + +void Slave::Op(SlaveCommand _cmd) +{ + mDebugIn << " _cmd = " << _cmd << endl; + + if ( !running() ) // start on demand + start(); + + mutex.lock(); + stack.push(_cmd); + nPendingCommand++; + worker.wakeOne(); + mutex.unlock(); + + mDebugOut << endl; +} + +/** No descriptions */ +void Slave::PostMessage(SlaveResult _event, Q_ULLONG _data) +{ + SlaveEvent *e1 = new SlaveEvent(m_parent, _event, _data); + + QApplication::postEvent(kapp->mainWidget(), (QEvent *) e1); +} + +void Slave::PostMessage(SlaveResult _event, const QString & _msg) +{ + SlaveEvent *e1 = new SlaveEvent(m_parent, _event, _msg); + + QApplication::postEvent(kapp->mainWidget(), (QEvent *) e1); + mDebug << "Msg:" << "_msg = " << _msg << endl; +} + +void Slave::InfoMessage(const QString & _msg) +{ + SlaveEvent *e1 = new SlaveEvent(m_parent, SLV_INFO, _msg); + + QApplication::postEvent(kapp->mainWidget(), (QEvent *) e1); + mDebug << "Infor Msg:" << "_msg = " << _msg << endl; +} + + + +void Slave::run() +{ + mDebugIn << endl; + + SlaveCommand cmd; + bool running = true; + + while (running) + { + if (!nPendingCommand) + worker.wait(); + switch (cmd = fetch_cmd()) + { + case RESTART: + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + // fall through + case RETR: + mDebug << " FETCHED COMMAND RETR" << endl; + assert(!copyjob); + KIO::Scheduler::checkSlaveOnHold( true ); + copyjob = new KIO::GetFileJob(m_src, m_dest); + Connect(); + PostMessage(SLV_RESUMED); + break; + + case RETR_CACHE: + mDebug << " FETCHED COMMAND RETR_CACHE" << endl; + assert(!copyjob); + KIO::Scheduler::checkSlaveOnHold( true ); + copyjob = new KIO::GetFileJob(m_src, m_dest); + copyjob->addMetaData("cache", "cacheonly"); + Connect(); + break; + + case PAUSE: + mDebug << " FETCHED COMMAND PAUSE" << endl; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + PostMessage(SLV_PAUSED); + break; + + case KILL: + mDebug << " FETCHED COMMAND KILL" << endl; + running = false; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + // no message posted + break; + + case REMOVE: + mDebug << " FETCHED COMMAND REMOVE" << endl; + running = false; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + PostMessage(SLV_REMOVED); + break; + + case SCHEDULE: + mDebug << " FETCHED COMMAND SCHEDULE" << endl; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + PostMessage(SLV_SCHEDULED); + break; + + case DELAY: + mDebug << " FETCHED COMMAND DELAY" << endl; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + PostMessage(SLV_DELAYED); + break; + + case NOOP: + mDebug << "FETCHED COMMAND NOOP, i.e. empty stack" << endl; + if (copyjob) { + copyjob->kill(true); + copyjob = 0L; + } + running = false; + break; + + default: + mDebug << " UNKNOWN COMMAND DIE...." << endl; + assert(0); + } + } + + assert(!copyjob); + mDebugOut << endl; +} + + +Slave::SlaveCommand Slave::fetch_cmd() +{ + mutex.lock(); + SlaveCommand cmd = NOOP; + if ( !stack.isEmpty() ) + { + nPendingCommand--; + cmd = stack.pop(); + } + mutex.unlock(); + return cmd; +} + + +void Slave::Connect() +{ + mDebugIn << endl; + + + connect(copyjob, SIGNAL(canceled(KIO::Job *)), SLOT(slotCanceled(KIO::Job *))); + connect(copyjob, SIGNAL(connected(KIO::Job *)), SLOT(slotConnected(KIO::Job *))); + connect(copyjob, SIGNAL(result(KIO::Job *)), SLOT(slotResult(KIO::Job *))); + + connect(copyjob, SIGNAL(totalSize(KIO::Job *, KIO::filesize_t)), SLOT(slotTotalSize(KIO::Job *, KIO::filesize_t))); + + connect(copyjob, SIGNAL(processedSize(KIO::Job *, KIO::filesize_t)), SLOT(slotProcessedSize(KIO::Job *, KIO::filesize_t))); + + connect(copyjob, SIGNAL(speed(KIO::Job *, unsigned long)), SLOT(slotSpeed(KIO::Job *, unsigned long))); + + connect(copyjob, SIGNAL(infoMessage(KIO::Job *, const QString &)), SLOT(slotInfoMessage(KIO::Job *, const QString &))); + + mDebugOut << endl; +} + + +void Slave::slotCanceled(KIO::Job *) +{ + mDebugIn << endl; + + + mDebugOut << endl; +} + +void Slave::slotConnected(KIO::Job *) +{ + mDebugIn << endl; + + + mDebugOut << endl; +} + +void Slave::slotResult(KIO::Job * job) +{ + mDebugIn << endl; + + assert(copyjob == job); + copyjob=0L; + KIO::Error error=KIO::Error(job->error()); + if (!error) { + PostMessage(SLV_FINISHED); + } + else { + if (m_parent->getMode() == Transfer::MD_NEW) + { + PostMessage(SLV_NOTINCACHE); + return; + } + QString tmsg="<font color=\"red\"> <b>" + job->errorString() + \ + "</b></font>"; + InfoMessage(tmsg); + if (m_parent->retryOnError() && \ + ((error==KIO::ERR_COULD_NOT_LOGIN) || (error==KIO::ERR_SERVER_TIMEOUT))) { + //Timeout or login error + PostMessage(SLV_ERROR); + } + else if (m_parent->retryOnBroken() && (error==KIO::ERR_CONNECTION_BROKEN)) { + // Connection Broken + PostMessage(SLV_BROKEN); + } + else { + job->showErrorDialog(); + PostMessage(SLV_DELAYED); + } + } + mDebugOut << endl; +} + + +void Slave::slotSpeed(KIO::Job *, unsigned long lSpeed) +{ + // mDebugIn<<endl; + PostMessage(SLV_PROGRESS_SPEED, lSpeed); + // mDebugOut<<endl; + +} + +void Slave::slotTotalSize(KIO::Job *, KIO::filesize_t _total_size) +{ + mDebugIn << "= " << _total_size << endl; + + if ((int)_total_size == 0)//shouldn't happen, but does + return; + + if (m_parent->getMode() != Transfer::MD_NEW) + { + PostMessage(SLV_CAN_RESUME, copyjob->getCanResume()); + PostMessage(SLV_CONNECTED); + } + else + InfoMessage("checking if file is in cache...yes"); + PostMessage(SLV_TOTAL_SIZE, _total_size); + mDebugOut << endl; +} + +void Slave::slotProcessedSize(KIO::Job *, KIO::filesize_t _processed_size) +{ + // mDebugIn<<endl; + PostMessage(SLV_PROGRESS_SIZE, _processed_size); + + // mDebugOut<<endl; +} + +void Slave::slotInfoMessage(KIO::Job *, const QString & _msg) +{ + mDebugIn << "MSG=" << _msg << endl; + InfoMessage(_msg); + mDebugOut << endl; +} + +#include "slave.moc" diff --git a/kget/slave.h b/kget/slave.h new file mode 100644 index 00000000..670b418b --- /dev/null +++ b/kget/slave.h @@ -0,0 +1,104 @@ +/*************************************************************************** +* slave.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef SLAVE_H +#define SLAVE_H + +#include <qthread.h> +#include <kurl.h> +#include <qvaluestack.h> +#include <qwaitcondition.h> +#include <qmutex.h> +#include <qobject.h> + +#include "common.h" + +namespace KIO +{ + class GetFileJob; +} + +class Transfer; + +class Slave:public QObject, public QThread +{ + Q_OBJECT + +public: + enum SlaveCommand { + RETR, RETR_CACHE, PAUSE, RESTART, ABORT, DELAY, + SCHEDULE, REMOVE, KILL, NOOP + }; + + enum SlaveResult { + + SLV_TOTAL_SIZE, SLV_PROGRESS_SIZE, SLV_PROGRESS_SPEED, + SLV_CAN_RESUME, SLV_CONNECTED, + + SLV_RESUMED, SLV_PAUSED, SLV_ERROR, SLV_BROKEN, SLV_SCHEDULED, SLV_DELAYED, + SLV_FINISHED, SLV_INFO, SLV_REMOVED, SLV_KILLED, SLV_NOTINCACHE + }; + +public: + Slave(Transfer * _parent, const KURL & _src, const KURL & _dest); + ~Slave(); + void Op(SlaveCommand _cmd); + +protected: + virtual void run(); + +private slots: + void slotCanceled(KIO::Job *); + void slotConnected(KIO::Job *); + void slotResult(KIO::Job *); + void slotTotalSize(KIO::Job *, KIO::filesize_t); + void slotProcessedSize(KIO::Job *, KIO::filesize_t); + void slotSpeed(KIO::Job *, unsigned long); + void slotInfoMessage(KIO::Job *, const QString &); + +private: + void Connect(); + + void PostMessage(SlaveResult _event, Q_ULLONG _data = 0L); + void PostMessage(SlaveResult _event, const QString & _msg); + void InfoMessage(const QString & _msg); + + Transfer * m_parent; + + KURL m_src; + KURL m_dest; + + Slave::SlaveCommand fetch_cmd(); + int nPendingCommand; + + QValueStack < SlaveCommand > stack; + QWaitCondition worker; + QMutex mutex; + KIO::GetFileJob * copyjob; + +}; + +#endif diff --git a/kget/slaveevent.cpp b/kget/slaveevent.cpp new file mode 100644 index 00000000..e0d41661 --- /dev/null +++ b/kget/slaveevent.cpp @@ -0,0 +1,72 @@ +/*************************************************************************** +* slaveevent.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* emai : [email protected] +* +***************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#include "slaveevent.h" + +#define EVENT_TYPE (QEvent::User + 252) + +SlaveEvent::SlaveEvent(Transfer * _item, unsigned int _event, Q_ULLONG _ldata):QCustomEvent(EVENT_TYPE) +{ + m_event = _event; + m_item = _item; + m_ldata = _ldata; + m_msg = QString(""); +} + + +SlaveEvent::SlaveEvent(Transfer * _item, unsigned int _event, const QString & _msg):QCustomEvent(EVENT_TYPE) +{ + m_event = _event; + m_item = _item; + m_ldata = 0L; + m_msg = _msg; +} + + +SlaveEvent::~SlaveEvent() +{ +} + +unsigned int +SlaveEvent::getEvent() const +{ + return m_event; +} + +Transfer *SlaveEvent::getItem() const +{ + return m_item; +} + +Q_ULLONG SlaveEvent::getData() const +{ + return m_ldata; +} + +const QString & SlaveEvent::getMsg() const +{ + return m_msg; +} diff --git a/kget/slaveevent.h b/kget/slaveevent.h new file mode 100644 index 00000000..6fb5f96b --- /dev/null +++ b/kget/slaveevent.h @@ -0,0 +1,59 @@ +/*************************************************************************** +* slaveevent.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* email :[email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef SLAVEEVENT_H +#define SLAVEEVENT_H + +#include <qevent.h> + +class Transfer; + +/** + *@author Patrick Charbonnier + */ + +class SlaveEvent:public QCustomEvent +{ +public: + SlaveEvent(Transfer * _item, unsigned int _event, Q_ULLONG _ldata = 0L); + SlaveEvent(Transfer * _item, unsigned int _event, const QString & _msg); + ~SlaveEvent(); + + unsigned int getEvent() const; + Transfer *getItem() const; + Q_ULLONG getData() const; + const QString & getMsg() const; + + +private: + unsigned int m_event; + Transfer *m_item; + Q_ULLONG m_ldata; + QString m_msg; + +}; + +#endif diff --git a/kget/sounds/KGet_Added.ogg b/kget/sounds/KGet_Added.ogg Binary files differnew file mode 100644 index 00000000..8647db9c --- /dev/null +++ b/kget/sounds/KGet_Added.ogg diff --git a/kget/sounds/KGet_Finished.ogg b/kget/sounds/KGet_Finished.ogg Binary files differnew file mode 100644 index 00000000..fd06b360 --- /dev/null +++ b/kget/sounds/KGet_Finished.ogg diff --git a/kget/sounds/KGet_Finished_All.ogg b/kget/sounds/KGet_Finished_All.ogg Binary files differnew file mode 100644 index 00000000..45fbfacd --- /dev/null +++ b/kget/sounds/KGet_Finished_All.ogg diff --git a/kget/sounds/KGet_Started.ogg b/kget/sounds/KGet_Started.ogg Binary files differnew file mode 100644 index 00000000..8b139ad8 --- /dev/null +++ b/kget/sounds/KGet_Started.ogg diff --git a/kget/sounds/Makefile.am b/kget/sounds/Makefile.am new file mode 100644 index 00000000..745b5a70 --- /dev/null +++ b/kget/sounds/Makefile.am @@ -0,0 +1,4 @@ +kde_sound_DATA = KGet_Added.ogg KGet_Finished.ogg KGet_Finished_All.ogg \ + KGet_Started.ogg + +EXTRA_DIST = $(kde_sound_DATA) diff --git a/kget/transfer.cpp b/kget/transfer.cpp new file mode 100644 index 00000000..44e76fae --- /dev/null +++ b/kget/transfer.cpp @@ -0,0 +1,1025 @@ +/*************************************************************************** +* transfer.cpp +* ------------------- +* +* begin : Tue Jan 29 2002 +* copyright : (C) 2002, 2003, 2004, 2005 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public Lkio/global.h:icense 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. + * + ***************************************************************************/ + +#include <qheader.h> + +#include <kurl.h> +#include <kmessagebox.h> +#include <klocale.h> +#include <ksimpleconfig.h> +#include <kaction.h> +#include <kiconloader.h> +#include <kstandarddirs.h> +#include <kwin.h> +#include <kmessagebox.h> + +#include <assert.h> +#include "safedelete.h" +#include "settings.h" +#include "logwindow.h" +#include "kmainwidget.h" +#include "dlgIndividual.h" +#include "transferlist.h" +#include "transfer.h" + +#include <kapplication.h> +#include <kio/passdlg.h> +#include <kio/global.h> +#include <kio/netaccess.h> + + +extern Settings ksettings; + + +Transfer::Transfer(TransferList * _view, const KURL & _src, const KURL & _dest, const uint _id) + : QObject( _view ), + KListViewItem(_view), + dlgIndividual( 0 ) +{ + sDebugIn << endl; + + src = _src; + dest = _dest; + + view = _view; + init(_id); + + sDebugOut << endl; +} + + +Transfer::Transfer(TransferList * _view, Transfer * after, const KURL & _src, const KURL & _dest, const uint _id) + : QObject( _view ), + KListViewItem(_view, (QListViewItem *) after), + src(_src), dest(_dest), view(_view), + dlgIndividual( 0 ) +{ + sDebugIn << endl; + + view = _view; + src = _src; + dest = _dest; + init(_id); + + sDebugOut << endl; +} + + +Transfer::~Transfer() +{ + sDebugIn << endl; + + synchronousAbort(); + delete dlgIndividual; + + sDebugOut << endl; +} + + +void +Transfer::init(const uint _id) +{ + sDebugIn << endl; + remainingTimeSec = 0; + totalSize = 0; + processedSize = 0; + percent = 0; + id = _id; + m_pSlave = new Slave(this, src, dest); + canResume = false; + startTime = QDateTime::currentDateTime(); + speed = 0; + // retryCount = ksettings.reconnectRetries-1; + retryCount = 0; + //first off all we need to know if resume is supported... + + status = ST_STOPPED; + + + connect(this, SIGNAL(statusChanged(Transfer *, int)), kmain, SLOT(slotStatusChanged(Transfer *, int))); + connect(this, SIGNAL(statusChanged(Transfer *, int)), this, SLOT(slotUpdateActions())); + + connect(this, SIGNAL(log(uint, const QString &, const QString &)), kmain->logwin(), SLOT(logTransfer(uint, const QString &, const QString &))); + + // setup actions + m_paResume = new KAction(i18n("&Resume"), "tool_resume", 0, this, SLOT(slotResume()), this, "resume"); + + m_paPause = new KAction(i18n("&Pause"), "tool_pause", 0, this, SLOT(slotRequestPause()), this, "pause"); + + m_paDelete = new KAction(i18n("&Delete"), "editdelete", 0, this, SLOT(slotRequestRemove()), this, "delete"); + + m_paRestart = new KAction(i18n("Re&start"), "tool_restart", 0, this, SLOT(slotRequestRestart()), this, "restart"); + + m_paQueue = new KRadioAction(i18n("&Queue"), "tool_queue", 0, this, SLOT(slotQueue()), this, "queue"); + + m_paTimer = new KRadioAction(i18n("&Timer"), "tool_timer", 0, this, SLOT(slotRequestSchedule()), this, "timer"); + + m_paDelay = new KRadioAction(i18n("De&lay"), "tool_delay", 0, this, SLOT(slotRequestDelay()), this, "delay"); + + m_paQueue->setExclusiveGroup("TransferMode"); + m_paTimer->setExclusiveGroup("TransferMode"); + m_paDelay->setExclusiveGroup("TransferMode"); + + // Actions + + // m_paDock = new KAction(i18n("&Dock"),"tool_dock", 0, this,SLOT(slotRequestDelay()), this, "dockIndividual"); + + // setup individual transfer dialog + + mode = MD_NEW; + + sDebugOut << endl; +} + + +void Transfer::synchronousAbort() +{ + if ( m_pSlave ) + { + if ( m_pSlave->running() ) + { + m_pSlave->Op(Slave::KILL); + m_pSlave->wait(); + } + + if ( m_pSlave->running() ) + m_pSlave->terminate(); + + delete m_pSlave; + m_pSlave = 0L; + + status = ST_STOPPED; + slotUpdateActions(); + } + +} + +void Transfer::slotUpdateActions() +{ + sDebugIn << "the item Status is =" << status << "offline=" << ksettings.b_offline << endl; + //if we are offline just disable Resume and Pause and return + if (ksettings.b_offline) { + m_paResume->setEnabled(false); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + if(dlgIndividual) + dlgIndividual->update(); + return; + } + + UpdateRetry(); + + switch (status) { + + case ST_TRYING://fall-through + case ST_RUNNING: + m_paResume->setEnabled(false); + m_paPause->setEnabled(true); + m_paRestart->setEnabled(true); + break; + + case ST_STOPPED: + m_paResume->setEnabled(true); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + break; + case ST_FINISHED: + m_paResume->setEnabled(false); + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + break; + } + + // disable all signals + m_paQueue->blockSignals(true); + m_paTimer->blockSignals(true); + m_paDelay->blockSignals(true); + + switch (mode) { + case MD_QUEUED: + m_paQueue->setChecked(true); + break; + case MD_SCHEDULED: + m_paTimer->setChecked(true); + break; + case MD_DELAYED: + m_paDelay->setChecked(true); + break; + case MD_NEW: //fall through + case MD_NONE: + m_paQueue->setChecked(false); + m_paTimer->setChecked(false); + m_paDelay->setChecked(false); + + m_paQueue->setEnabled(false); + m_paTimer->setEnabled(false); + m_paDelay->setEnabled(false); + break; + + } + + + // enable all signals + m_paQueue->blockSignals(false); + m_paTimer->blockSignals(false); + m_paDelay->blockSignals(false); + + if (dlgIndividual) + dlgIndividual->update(); + + sDebugOut << endl; +} + + + +void Transfer::setSpeed(unsigned long _speed) +{ + // sDebugIn <<endl; + speed = _speed; + + remainingTimeSec = KIO::calculateRemainingSeconds(totalSize, processedSize, speed); + remainingTime = KIO::convertSeconds(remainingTimeSec); + //sDebugOut <<endl; +} + + + +void Transfer::updateAll() +{ + sDebugIn << endl; + + updateStatus(status); // first phase of animation + + logMessage(i18n("Copy file from: %1").arg(src.prettyURL())); + logMessage(i18n("To: %1").arg(dest.prettyURL())); + + // source + setText(view->lv_url, src.prettyURL()); + + // destination + setText(view->lv_filename, dest.fileName()); + + if(dlgIndividual) + { + dlgIndividual->setCopying(src, dest); + dlgIndividual->setCanResume(canResume); + dlgIndividual->setTotalSize(totalSize); + dlgIndividual->setPercent(0); + dlgIndividual->setProcessedSize(0); + } + + if (totalSize != 0) { + //logMessage(i18n("Total size is %1 bytes").arg((double)totalSize)); + setText(view->lv_total, KIO::convertSize(totalSize)); + } else { + //logMessage(i18n("Total size is unknown")); + setText(view->lv_total, i18n("unknown")); + } + + + sDebugOut << endl; +} + + +bool Transfer::updateStatus(int counter) +{ + //sDebug<< ">>>>Entering"<<endl; + + QPixmap *pix = 0L; + bool isTransfer = false; + + view->setUpdatesEnabled(false); + + switch(status) + { + case ST_RUNNING: + pix = view->animConn.at(counter); + isTransfer = true; + break; + case ST_TRYING: + pix = view->animTry.at(counter); + isTransfer = true; + break; + case ST_STOPPED: + if(mode == MD_QUEUED) + pix = &view->pixQueued; + else if(mode == MD_SCHEDULED) + pix = &view->pixScheduled; + else + pix = &view->pixDelayed; + break; + case ST_FINISHED: + pix = &view->pixFinished; + } + + setPixmap(view->lv_pixmap, *pix); + view->setUpdatesEnabled(true); + + if(prevStatus!=status || prevMode != mode || status==ST_RUNNING || status==ST_TRYING) + { + QRect rect = view->header()->sectionRect(view->lv_pixmap); + + int x = rect.x(); + int y = view->itemRect(this).y(); + int w = rect.width(); + int h = rect.height(); + + view->QScrollView::updateContents(x,y,w,h); + + prevStatus = status; + prevMode = mode; + } + + return isTransfer; +} + + +void Transfer::UpdateRetry() +{ + QString retry; + QString MaxRetry; + + retry.setNum(retryCount); + MaxRetry.setNum(ksettings.reconnectRetries); + retry += " / " + MaxRetry; + + setText(view->lv_count, retry); +} + + +void Transfer::slotResume() +{ + sDebugIn << " state =" << status << endl; + + retryCount++; + if (retryCount > ksettings.reconnectRetries) + retryCount = 1; + UpdateRetry(); + assert(status == ST_STOPPED); + + sDebug << "src: " << src.prettyURL() << endl; + sDebug << "dest " << dest.prettyURL() << endl; + + m_paResume->setEnabled(false); + + status = ST_TRYING; + mode = MD_QUEUED; + logMessage(i18n("Attempt number %1").arg(retryCount)); + + sDebug << "sending Resume to slave " << endl; + m_pSlave->Op(Slave::RETR); + + sDebugOut << endl; +} + + + void Transfer::slotStop() +{ + sDebugIn << endl; + + logMessage(i18n("Stopping")); + + assert(status <= ST_RUNNING && ksettings.b_offline); + + m_pSlave->Op(Slave::KILL); // KILL doesn't post a Message + sDebug << "Killing Slave" << endl; + + slotSpeed(0); + mode = MD_QUEUED; + status=ST_STOPPED; + m_paQueue->setChecked(true); + + slotUpdateActions(); + + sDebugOut << endl; +} + + +void Transfer::slotRequestPause() +{ + sDebugIn << endl; + + logMessage(i18n("Pausing")); + + assert(status <= ST_RUNNING); + + //stopping the thead + + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + + + m_pSlave->Op(Slave::PAUSE); + sDebug << "Requesting Pause.." << endl; + + sDebugOut << endl; +} + + + + +void Transfer::slotRequestRestart() +{ + sDebugIn << endl; + m_pSlave->Op(Slave::RESTART); + slotSpeed(0); + sDebugOut << endl; +} + + +void Transfer::slotRequestRemove() +{ + sDebugIn << endl; + if (dlgIndividual && !ksettings.b_expertMode) + { + if (KMessageBox::warningContinueCancel(0, i18n("Are you sure you want to delete this transfer?"), + QString::null, KStdGuiItem::del(), + QString("delete_transfer")) + != KMessageBox::Continue) + return; + } + m_paDelete->setEnabled(false); + m_paPause->setEnabled(false); + if (dlgIndividual) + dlgIndividual->close(); + + + if ( status != ST_FINISHED ) + { + KURL file = dest; + // delete the partly downloaded file, if any + file.setFileName( dest.fileName() + ".part" ); // ### get it from the job? + + if ( KIO::NetAccess::exists( file, false, view ) ) // don't pollute user with warnings + { + SafeDelete::deleteFile( file ); // ### messagebox on failure? + } + } + if (status == ST_RUNNING) + m_pSlave->Op(Slave::REMOVE); + else + emit statusChanged(this, OP_REMOVED); + + sDebugOut << endl; +} + + +void Transfer::slotQueue() +{ + sDebug << ">>>>Entering with mode = " << mode << endl; + + logMessage(i18n("Queueing")); + + assert(!(mode == MD_QUEUED)); + + mode = MD_QUEUED; + m_paQueue->setChecked(true); + emit statusChanged(this, OP_QUEUED); + sDebugOut << endl; +} + + +void Transfer::slotRequestSchedule() +{ + sDebugIn << endl; + + logMessage(i18n("Scheduling")); + assert(!(mode == MD_SCHEDULED)); + + // if the time was already set somewhere in the future, keep it + // otherwise set it to the current time + 60 seconds + if (startTime < QDateTime::currentDateTime()) { + QDateTime dt = QDateTime::currentDateTime(); + startTime = dt.addSecs(60); + } + if (status == ST_RUNNING) { + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + m_pSlave->Op(Slave::SCHEDULE); + + } else + slotExecSchedule(); + sDebugOut << endl; +} + + +void Transfer::slotRequestDelay() +{ + sDebugIn << endl; + + logMessage(i18n("Delaying")); + + assert(!(mode == MD_DELAYED)); + if (status == ST_RUNNING) { + m_paPause->setEnabled(false); + m_paRestart->setEnabled(false); + m_pSlave->Op(Slave::DELAY); + } else + slotExecDelay(); + sDebugOut << endl; +} + + + +/* +void Transfer::slotCanceled(KIO::Job *) +{ + sDebugIn << endl; + + logMessage(i18n("Canceled by user")); + emit statusChanged(this, OP_CANCELED); + sDebugOut << endl; +} + +*/ + +void Transfer::slotFinished() +{ + sDebugIn << endl; + + logMessage(i18n("Download finished")); + mode = MD_NONE; + status = ST_FINISHED; + slotProcessedSize(totalSize); + + slotSpeed(0); + if(dlgIndividual) + dlgIndividual->enableOpenFile(); + emit statusChanged(this, OP_FINISHED); + sDebugOut << endl; +} + + + + +/* +void Transfer::slotRenaming(KIO::Job *, const KURL &, const KURL & to) +{ + sDebugIn << endl; + + dest = to; + + logMessage(i18n("Renaming to %1").arg(dest.prettyURL().ascii())); + + // destination + setText (view->lv_filename, dest.fileName ()); + + dlgIndividual->setCopying (src, dest); + + sDebugOut << endl; +} + */ + + + + +void Transfer::slotSpeed(unsigned long bytes_per_second) +{ + //sDebugIn <<endl; + + setSpeed(bytes_per_second); + + if (speed == 0 && status == ST_RUNNING) { + setText(view->lv_speed, i18n("Stalled")); + setText(view->lv_remaining, i18n("Stalled")); + if(dlgIndividual) + dlgIndividual->setSpeed(i18n("Stalled")); + } else if (speed == 0 && status == ST_FINISHED) { + + setText(view->lv_progress, i18n("OK as in 'finished'","OK")); + setText(view->lv_speed, i18n("Finished")); + setText(view->lv_remaining, i18n("Finished")); + if(dlgIndividual) + dlgIndividual->setSpeed(i18n("Finished")); + + } else if (speed == 0 && status == ST_STOPPED) { + + + setText(view->lv_speed, i18n("Stopped")); + setText(view->lv_remaining, i18n("Stopped")); + if(dlgIndividual) + dlgIndividual->setSpeed(i18n("Stopped")); + + } else { + QString tmps = i18n("%1/s").arg(KIO::convertSize(speed)); + setText(view->lv_speed, tmps); + setText(view->lv_remaining, remainingTime); + if(dlgIndividual) + dlgIndividual->setSpeed(tmps + " ( " + remainingTime + " ) "); + } + + //sDebugOut<<endl; +} + + + +void Transfer::slotTotalSize(KIO::filesize_t bytes) +{ +#ifdef _DEBUG + sDebugIn<<" totalSize is = "<<totalSize << endl; +#endif + + if (totalSize == 0) { + totalSize = bytes; + if (totalSize != 0) { + logMessage(i18n("Total size is %1 bytes").arg((double)totalSize,0,'f',0)); + setText(view->lv_total, KIO::convertSize(totalSize)); + if(dlgIndividual) + { + dlgIndividual->setTotalSize(totalSize); + dlgIndividual->setPercent(0); + dlgIndividual->setProcessedSize(0); + } + } + } else { + +#ifdef _DEBUG + sDebug<<"totalSize="<<totalSize<<" bytes="<<bytes<<endl; + assert(totalSize == bytes); +#endif + if (totalSize != bytes) + logMessage(i18n("The file size does not match.")); + else + logMessage(i18n("File Size checked")); + } + +#ifdef _DEBUG + sDebugOut << endl; +#endif +} + + + +void Transfer::slotProcessedSize(KIO::filesize_t bytes) +{ + //sDebug<< ">>>>Entering"<<endl; + + int old = percent; + processedSize = bytes; + + if (totalSize == 0) + { + percent = 0; + } + else if ( totalSize < processedSize ) // bogus totalSize value + { + percent = 99; // what can we say? + totalSize = processedSize; + + setText(view->lv_total, KIO::convertSize(totalSize)); + if(dlgIndividual) + dlgIndividual->setTotalSize(totalSize); + } + else { + percent = (int) (((float) processedSize / (float) totalSize) * 100.0); + } + if(dlgIndividual) + dlgIndividual->setProcessedSize(processedSize); + + if (percent != old) { + QString tmps; + if (percent == 100) { + tmps = i18n("OK as in 'finished'","OK"); + } else { + tmps.setNum(percent); + } + + setText(view->lv_progress, tmps); + + if(dlgIndividual) + dlgIndividual->setPercent(percent); + } + //sDebug<< "<<<<Leaving"<<endl; +} + + + + +void Transfer::showIndividual() +{ + sDebugIn << endl; + + // create a DlgIndividual only if it hasn't been created yet + if(!dlgIndividual) + { + dlgIndividual = new DlgIndividual(this); + dlgIndividual->setLog(transferLog); + dlgIndividual->setCopying(src, dest); + dlgIndividual->setCanResume(canResume); + dlgIndividual->setTotalSize(totalSize); + dlgIndividual->setPercent(percent); + dlgIndividual->setProcessedSize(processedSize); + } + + dlgIndividual->raise(); + + + if (ksettings.b_iconifyIndividual) { + KWin::iconifyWindow( dlgIndividual->winId() ); + } + + // update the actions + slotUpdateActions(); + // then show the single dialog + KWin::deIconifyWindow( dlgIndividual->winId() ); + dlgIndividual->show(); + + sDebugOut << endl; +} + + +void Transfer::logMessage(const QString & message) +{ + sDebugIn << message << endl; + + emit log(id, src.fileName(), message); + + QString tmps = "<font color=\"blue\">" + QTime::currentTime().toString() + "</font> : " + message; + + transferLog.append(tmps + '\n'); + + if(dlgIndividual) + dlgIndividual->appendLog(tmps); + + sDebugOut << endl; +} + + + +bool Transfer::read(KSimpleConfig * config, int id) +{ + sDebugIn << endl; + + + QString str; + str.sprintf("Item%d", id); + config->setGroup(str); + + if (src.isEmpty() || dest.isEmpty()) { + return false; + } + + if (!src.isValid() && !ksettings.b_expertMode) { + KMessageBox::error(kmain, i18n("Malformed URL:\n") + src.prettyURL(), i18n("Error")); + return false; + } + + mode = (TransferMode) config->readNumEntry("Mode", MD_QUEUED); + status = (TransferStatus) config->readNumEntry("Status", ST_RUNNING); + startTime = config->readDateTimeEntry("ScheduledTime"); + canResume = config->readBoolEntry("CanResume", true); + totalSize = config->readUnsignedNum64Entry("TotalSize", 0); + processedSize = config->readUnsignedNum64Entry("ProcessedSize", 0); + + if (status != ST_FINISHED && totalSize != 0) { + //TODO insert additional check + status = ST_STOPPED; + } + + updateAll(); + sDebugOut << endl; + return true; +} + + +void Transfer::write(KSimpleConfig * config, int id) +{ + sDebugIn << endl; + + QString str; + str.sprintf("Item%d", id); + + config->setGroup(str); + config->writePathEntry("Source", src.url()); + config->writePathEntry("Dest", dest.url()); + config->writeEntry("Mode", mode); + config->writeEntry("Status", status); + config->writeEntry("CanResume", canResume); + config->writeEntry("TotalSize", totalSize ); + config->writeEntry("ProcessedSize", processedSize ); + config->writeEntry("ScheduledTime", startTime); + sDebugOut << endl; +} + + + +/** No descriptions */ +void Transfer::slotExecPause() +{ + sDebugIn << endl; + slotSpeed(0); + + mode = MD_DELAYED; + m_paDelay->setChecked(true); + status = ST_STOPPED; + + m_paPause->setEnabled(false); + m_paRestart->setEnabled(true); + m_paResume->setEnabled(true); + slotUpdateActions(); + //TODO WE NEED TO UPDATE ACTIONS.. + kmain->slotUpdateActions(); + emit statusChanged(this, OP_PAUSED); + sDebugOut << endl; +} + +void Transfer::slotExecError() +{ + sDebugIn << endl; + + status = ST_STOPPED; + mode = MD_SCHEDULED; + startTime=QDateTime::currentDateTime().addSecs(ksettings.reconnectTime * 60); + emit statusChanged(this, OP_SCHEDULED); + + sDebugOut << endl; +} + +void Transfer::slotExecBroken() +{ + sDebugIn << endl; + + status = ST_STOPPED; + mode = MD_QUEUED; + emit statusChanged(this, OP_QUEUED); + + sDebugOut << endl; +} + + +void Transfer::slotExecRemove() +{ + sDebugIn << endl; + + m_pSlave->wait(); + emit statusChanged(this, OP_REMOVED); + sDebugOut << endl; +} + + +void Transfer::slotExecResume() +{ + sDebugIn << endl; + emit statusChanged(this, OP_RESUMED); + sDebugOut << endl; +} + +void Transfer::slotExecConnected() +{ + sDebugIn << endl; + if (mode == MD_NEW) + { + if (ksettings.b_offline)// when we're offline and arrive here, then the file is in cache + return; // Slave::slotResult will be called immediately, so we do nothing here + status = ST_STOPPED; + m_pSlave->Op(Slave::KILL); + if (ksettings.b_addQueued) + { + mode = MD_QUEUED; + emit statusChanged(this, OP_QUEUED); + } + else + { + mode = MD_DELAYED; + emit statusChanged(this, OP_DELAYED); + } + return; + } + + status = ST_RUNNING; + emit statusChanged(this, OP_CONNECTED); + sDebugOut << endl; +} + + +void Transfer::slotCanResume(bool _bCanResume) +{ + sDebugIn << endl; + + canResume = _bCanResume; + + if (canResume) { + logMessage(i18n("Download resumed")); + setText(view->lv_resume, i18n("Yes")); + } else { + setText(view->lv_resume, i18n("No")); + } + + //dlgIndividual->setCanResume(canResume); + + sDebugOut << endl; +} + + +/** No descriptions */ +void Transfer::slotExecDelay() +{ + sDebugIn << endl; + + mode = MD_DELAYED; + status = ST_STOPPED; + slotSpeed(0); //need??????? + m_paDelay->setChecked(true); + emit statusChanged(this, OP_DELAYED); + + sDebugOut << endl; +} + +/** No descriptions */ +void Transfer::slotExecSchedule() +{ + sDebugIn << endl; + + mode = MD_SCHEDULED; + status = ST_STOPPED; + m_paTimer->setChecked(true); + emit statusChanged(this, OP_SCHEDULED); + + sDebugOut << endl; +} + +/** No descriptions */ +void Transfer::slotStartTime(const QDateTime & _startTime) +{ + sDebugIn << endl; + + setStartTime(_startTime); + sDebugOut << endl; +} + +/** return true if the dlgIndividual is Visible */ +bool Transfer::isVisible() const +{ + return dlgIndividual ? dlgIndividual->isVisible() : false; +} + +bool Transfer::keepDialogOpen() const +{ + return dlgIndividual ? dlgIndividual->keepDialogOpen() : false; +} + +void Transfer::maybeShow() +{ + if ( ksettings.b_showIndividual && getStatus() != Transfer::ST_FINISHED ) + { + if(dlgIndividual) + dlgIndividual->show(); + } +} + +bool Transfer::retryOnError() +{ + return (ksettings.b_reconnectOnError && (retryCount < ksettings.reconnectRetries)); +} + +bool Transfer::retryOnBroken() +{ + return (ksettings.b_reconnectOnBroken && (retryCount < ksettings.reconnectRetries)); +} + +void Transfer::checkCache() +{ + assert (mode == MD_NEW); + + if (src.protocol()=="http") + { + status = ST_TRYING; + m_pSlave->Op(Slave::RETR_CACHE); + } + else + NotInCache(); +} + +void Transfer::NotInCache() +{ + logMessage(i18n("checking if file is in cache...no")); + if (ksettings.b_addQueued) + mode = MD_QUEUED; + else + mode = MD_DELAYED; + status = ST_STOPPED; +} +#include "transfer.moc" + diff --git a/kget/transfer.h b/kget/transfer.h new file mode 100644 index 00000000..845995d8 --- /dev/null +++ b/kget/transfer.h @@ -0,0 +1,241 @@ +/*************************************************************************** +* transfer.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + + +#ifndef _Transfer_h +#define _Transfer_h + +#include <klistview.h> +#include <qdatetime.h> +#include <qguardedptr.h> +#include <qmap.h> + +#include <kurl.h> +#include <kio/jobclasses.h> + +#include "slave.h" + +class QTimer; + +class KSimpleConfig; +class KAction; +class KRadioAction; + + + +class DlgIndividual; +class TransferList; + + +class Transfer:public QObject, public KListViewItem +{ + Q_OBJECT +public: + enum TransferMode { MD_QUEUED, MD_DELAYED, MD_SCHEDULED, MD_NONE, MD_NEW }; + + enum TransferStatus { ST_TRYING, ST_RUNNING, ST_STOPPED, ST_FINISHED }; + + enum TransferOperation { + OP_FINISHED, OP_RESUMED, OP_PAUSED, OP_REMOVED, OP_ABORTED, + OP_QUEUED, OP_SCHEDULED, OP_DELAYED, OP_CONNECTED + }; + + + + Transfer(TransferList * view, const KURL & _src, const KURL & _dest, const uint _id=0); + Transfer(TransferList * view, Transfer * after, const KURL & _src, const KURL & _dest, const uint _id=0); + ~Transfer(); + + void synchronousAbort(); + + bool read(KSimpleConfig * config, int id); + void write(KSimpleConfig * config, int id); + void logMessage(const QString & message); + + bool keepDialogOpen() const; + + + QDateTime getStartTime()const + { + return startTime; + } + unsigned int getRemainingTime()const + { + return remainingTimeSec; + } + + KIO::filesize_t getTotalSize()const + { + return totalSize; + } + KIO::filesize_t getProcessedSize()const + { + return processedSize; + } + + KURL getSrc()const + { + return src; + } + KURL getDest()const + { + return dest; + } + int getPercent()const + { + return percent; + } + + int getSpeed()const + { + return speed; + } + TransferStatus getStatus()const + { + return status; + } + int getMode()const + { + return mode; + } + + void setMode(TransferMode _mode) + { + mode = _mode; + } + void setStatus(TransferStatus _status) + { + status = _status; + }; + void setStartTime(QDateTime _startTime) + { + startTime = _startTime; + }; + void setSpeed(unsigned long _speed); + + // update methods + void updateAll(); + bool updateStatus(int counter); + + void showIndividual(); + void UpdateRetry(); + + + // actions + KAction *m_paResume, *m_paPause, *m_paDelete, *m_paRestart; + //KAction *m_paDock; + KRadioAction *m_paQueue, *m_paTimer, *m_paDelay; + +public: + void slotExecPause(); + void slotExecResume(); + void slotExecRemove(); + void slotExecDelay(); + void slotExecSchedule(); + void slotExecConnected(); + void slotExecError(); + void slotExecBroken(); + void slotCanResume(bool _bCanResume); + void slotSpeed(unsigned long); + void checkCache(); + + bool isVisible() const; + void maybeShow(); + + bool retryOnError(); + bool retryOnBroken(); + +public slots: + // operation methods + void slotResume(); + void slotRequestPause(); + void slotRequestRemove(); + void slotRequestSchedule(); + void slotRequestDelay(); + void NotInCache(); + void slotRequestRestart(); + void slotUpdateActions(); + + void slotQueue(); + void slotFinished(); + + void slotTotalSize(KIO::filesize_t bytes); + void slotProcessedSize(KIO::filesize_t); + + void slotStartTime(const QDateTime &); + void slotStop(); // stop all transfers when going offline + +signals: + void statusChanged(Transfer *, int _operation); + void log(uint, const QString &, const QString &); + +private: + void init(const uint _id); + + Slave *m_pSlave; + + KURL src; + KURL dest; + + /* the tranfer id number */ + uint id; + + static uint idcount; + + // log + QString transferLog; + + // schedule time + QDateTime startTime; + + KIO::filesize_t totalSize; + KIO::filesize_t processedSize; + int percent; + + int speed; + unsigned int remainingTimeSec; + QString remainingTime; + + TransferStatus status; + TransferMode mode; + + TransferStatus prevStatus; + TransferMode prevMode; + + // how many times have we retried already + unsigned int retryCount; + + bool canResume; + + TransferList *view; + + // individual download window + QGuardedPtr<DlgIndividual> dlgIndividual; + +}; + + +#endif // _Transfer_h diff --git a/kget/transferlist.cpp b/kget/transferlist.cpp new file mode 100644 index 00000000..1d9ed902 --- /dev/null +++ b/kget/transferlist.cpp @@ -0,0 +1,283 @@ +/*************************************************************************** +* transferlist.cpp +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#include <kapplication.h> +#include <kstandarddirs.h> +#include <kglobal.h> +#include <kiconloader.h> +#include <klocale.h> +#include <kconfig.h> +#include <kmessagebox.h> +#include <ksimpleconfig.h> +#include <kio/netaccess.h> + +#include "transfer.h" +#include "transferlist.h" + +#define NUM_COLS 9 + +static int defaultColumnWidth[] = { + 26, // PIXMAP + 160, // LOCAL FILENAME + 40, // RESUME + 60, // COUNT + 30, // PROGRESS + 65, // TOTAL + 70, // SPEED + 70, // REMAINING TIME + 450 // URL + }; + + +TransferList::TransferList(QWidget * parent, const char *name) + : KListView(parent, name) +{ + // enable selection of more than one item + setSelectionMode( QListView::Extended ); + + // // disable sorting and clicking on headers + // setSorting( -1 ); + + setAllColumnsShowFocus(true); + + lv_pixmap = addColumn(i18n("S")); + lv_filename = addColumn(i18n("Local File Name")); + lv_resume = addColumn(i18n("Resumed")); + lv_count = addColumn(i18n("Count")); + lv_progress = addColumn(i18n("%")); + lv_total = addColumn(i18n("Total")); + lv_speed = addColumn(i18n("Speed")); + lv_remaining = addColumn(i18n("Rem. Time")); + lv_url = addColumn(i18n("Address (URL)")); + + jobid=1; + + // initial layout + KConfig *config = KGlobal::config(); + config->setGroup("ListView"); + if ( config->readListEntry("ColumnWidths").isEmpty() ) + { + for (int i = 0; i < NUM_COLS; i++) + setColumnWidth(i, defaultColumnWidth[i]); + } + else + restoreLayout( KGlobal::config(), "ListView" ); + + QString connectPath = "pics/connect%2.png"; + QString tryPath = "pics/try%2.png"; + + // Load animations + QPixmap* curPix; + if (animConn.count() == 0) { + animConn.setAutoDelete(true); + animTry.setAutoDelete(true); + for (int i = 0; i < 8; i++) { + curPix = new QPixmap(); + curPix->load(locate("appdata", connectPath.arg(i))); + animConn.append(curPix); + + curPix = new QPixmap(); + curPix->load(locate("appdata", tryPath.arg(i))); + animTry.append(curPix); + } + } + + pixQueued = UserIcon("md_queued"); + pixScheduled = UserIcon("md_scheduled"); + pixDelayed = UserIcon("md_delayed.png"); + pixFinished = UserIcon("md_finished"); + pixRetrying = UserIcon("retrying"); + + phasesNum = animConn.count(); + + connect(this, SIGNAL(doubleClicked(QListViewItem *)), SLOT(slotTransferSelected(QListViewItem *))); + connect(this, SIGNAL(rightButtonPressed(QListViewItem *, const QPoint &, int)), SLOT(slotPopupMenu(QListViewItem *))); +} + + +TransferList::~TransferList() +{ + saveLayout( KGlobal::config(), "ListView" ); +} + + +Transfer *TransferList::addTransfer(const KURL & _source, const KURL & _dest, + bool canShow) +{ + Transfer *last = static_cast<Transfer*>( lastItem() ); + Transfer *new_item = new Transfer(this, last, _source, _dest, jobid); + jobid++; + if ( canShow ) + new_item->maybeShow(); + + return new_item; +} + + +void TransferList::slotTransferSelected(QListViewItem * item) +{ + emit transferSelected((Transfer *) item); +} + + +void TransferList::slotPopupMenu(QListViewItem * item) +{ + if (!item) + return; + emit popupMenu((Transfer *) item); +} + + +void TransferList::setSelected(QListViewItem * item, bool selected) +{ + bool tmpb = selected; + + if (tmpb && item->isSelected()) { + tmpb = false; + } + + QListView::setSelected(item, tmpb); +} + + +void TransferList::moveToBegin(Transfer * item) +{ + // ASSERT(item); + + Transfer *oldfirst=static_cast<Transfer*>(firstChild()); + item->moveItem(oldfirst); //move item after oldfirst + oldfirst->moveItem(item); //move oldfirst after item +} + + +void TransferList::moveToEnd(Transfer * item) +{ + // ASSERT(item); + + Transfer *oldlast=static_cast<Transfer*>(lastItem()); + item->moveItem(oldlast); +} + + +bool TransferList::updateStatus(int counter) +{ + bool isTransfer = false; + + TransferIterator it(this); + + for (; it.current(); ++it) { + isTransfer |= it.current()->updateStatus(counter); + } + + return isTransfer; +} + + +bool TransferList::areTransfersQueuedOrScheduled() +{ + TransferIterator it(this); + + if (childCount() > 0) { + for (; it.current(); ++it) { + if ((it.current()->getMode() == Transfer::MD_QUEUED)|| \ + (it.current()->getMode() == Transfer::MD_SCHEDULED)) + return true; + } + } + return false; +} + + +Transfer * TransferList::find(const KURL& _src) +{ + TransferIterator it(this); + + for (; it.current(); ++it) { + if (it.current()->getSrc() == _src) { + return it.current(); + } + } + + return 0L; +} + + +void TransferList::readTransfers(const KURL& file) +{ + QString tmpFile; + + if (KIO::NetAccess::download(file, tmpFile, (QWidget*)parent())) { + KSimpleConfig config(tmpFile); + + config.setGroup("Common"); + int num = config.readNumEntry("Count", 0); + + Transfer *item; + KURL src, dest; + + for ( int i = 0; i < num; i++ ) + { + QString str; + + str.sprintf("Item%d", i); + config.setGroup(str); + + src = KURL::fromPathOrURL( config.readPathEntry("Source") ); + dest = KURL::fromPathOrURL( config.readPathEntry("Dest") ); + item = addTransfer( src, dest, false ); // don't show! + + if (!item->read(&config, i)) + delete item; + else + { + // configuration read, now we know the status to determine + // whether to show or not + item->maybeShow(); + } + } + } +} + +void TransferList::writeTransfers(const QString& file) +{ + sDebug << ">>>>Entering with file =" << file << endl; + + KSimpleConfig config(file); + int num = childCount(); + + config.setGroup("Common"); + config.writeEntry("Count", num); + + TransferIterator it(this); + + for (int id = 0; it.current(); ++it, ++id) + it.current()->write(&config, id); + config.sync(); + + sDebug << "<<<<Leaving" << endl; +} + +#include "transferlist.moc" diff --git a/kget/transferlist.h b/kget/transferlist.h new file mode 100644 index 00000000..0d5929d0 --- /dev/null +++ b/kget/transferlist.h @@ -0,0 +1,116 @@ +/*************************************************************************** +* transferlist.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#ifndef _TransferList_h +#define _TransferList_h + +#include <klistview.h> +#include <qptrlist.h> + +#include <kurl.h> + +class Transfer; + +class TransferIterator:public QListViewItemIterator +{ + +public: + + TransferIterator(QListView * view):QListViewItemIterator(view) + { + } + Transfer *current() const + { + return (Transfer *) QListViewItemIterator::current(); + } + void reset() + { + curr = listView->firstChild(); + } + +}; + + +class TransferList:public KListView +{ +Q_OBJECT public: + + + TransferList(QWidget * parent = 0, const char *name = 0); + virtual ~ TransferList(); + + Transfer *addTransfer(const KURL & _source, const KURL & _dest, + bool canShow = true ); + + virtual void setSelected(QListViewItem * item, bool selected); + + void moveToBegin(Transfer * item); + void moveToEnd(Transfer * item); + + uint getPhasesNum()const + { + return phasesNum; + } + bool updateStatus(int counter); + Transfer * find(const KURL& _src); + bool areTransfersQueuedOrScheduled(); + + void readTransfers(const KURL& file); + void writeTransfers(const QString& file); + + friend class Transfer; + +signals: + void transferSelected(Transfer * item); + void popupMenu(Transfer * item); + +protected slots: + void slotTransferSelected(QListViewItem * item); + void slotPopupMenu(QListViewItem * item); + +protected: + + void readConfig(); + void writeConfig(); + + // ListView IDs + int lv_pixmap, lv_filename, lv_resume, lv_count, lv_progress; + int lv_total, lv_speed, lv_remaining, lv_url; + + QPtrList < QPixmap > animConn; + QPtrList < QPixmap > animTry; + QPixmap pixQueued; + QPixmap pixScheduled; + QPixmap pixDelayed; + QPixmap pixFinished; + QPixmap pixRetrying; + + uint phasesNum; + uint jobid; +}; + + +#endif // _TransferList_h diff --git a/kget/version.h b/kget/version.h new file mode 100644 index 00000000..1374e278 --- /dev/null +++ b/kget/version.h @@ -0,0 +1,35 @@ +/*************************************************************************** +* version.h +* ------------------- +* +* Revision : $Id$ +* begin : Tue Jan 29 2002 +* copyright : (C) 2002 by Patrick Charbonnier +* : Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss +* email : [email protected] +* +****************************************************************************/ + +/*************************************************************************** + * + * 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. + * + ***************************************************************************/ + +#ifndef _VERSION_H_ +#define _VERSION_H_ + + +#define KGETVERSION "v0.8.5" +#define KGET_APP_NAME "kget" + + +#endif diff --git a/kget/x-kgetlist.desktop b/kget/x-kgetlist.desktop new file mode 100644 index 00000000..e6a79308 --- /dev/null +++ b/kget/x-kgetlist.desktop @@ -0,0 +1,74 @@ +[Desktop Entry] +X-KDE-AutoEmbed=false +Comment=Kget Download List +Comment[ar]=قائمة تنزيل ك.جيت +Comment[be]=Спіс сцягвання Kget +Comment[bg]=Списък за изтегляне на Kget +Comment[bn]=কে-গেট ডাউনলোড তালিকা +Comment[br]=Roll enkargañ Kget +Comment[bs]=KGet download lista +Comment[ca]=Llista de descàrrega del Kget +Comment[cs]=Seznam stahování KGet +Comment[cy]=Rhestr Lawrlwytho KNôl +Comment[da]=KGet-download-liste +Comment[de]=Kget Dateiliste zum Herunterladen +Comment[el]=Λίστα λήψεων αρχείων του Kget +Comment[eo]=Kget Deŝutolisto +Comment[es]=Lista de descarga de KGet +Comment[et]=KGeti allalaadimise nimekiri +Comment[eu]=Kget deskargatzeko zerrenda +Comment[fa]=فهرست بارگیری Kget +Comment[fi]=Kget-hakulista +Comment[fr]=Liste de téléchargement de KGet +Comment[ga]=Liosta Thíosluchtaithe Kget +Comment[gl]=Lista de Descargas de KGet +Comment[he]=רשימת הורדה של Kget +Comment[hi]=के-गेट डाउनलोड सूची +Comment[hr]=Kget lista za preuzimanje +Comment[hu]=KGet letöltési lista +Comment[is]=Kget niðurhalslisti +Comment[it]=Lista scaricamenti di KGet +Comment[ja]=Kget ダウンロードリスト +Comment[ka]=Kget ჩამოქაჩვათა სია +Comment[kk]=Kget жүктеу тізімі +Comment[km]=បញ្ជីការទាញយករបស់ Kget +Comment[lt]=Kget atsisiuntimų sąrašas +Comment[mk]=Листа на симнувања во Kget +Comment[mn]=KGet жагсаалтыг Татаж авах +Comment[ms]=Senarai Muat turun Kget +Comment[mt]=Lista ta' downloads KGet +Comment[nb]=Kget nedlastingsliste +Comment[nds]=KGet-Daalladenlist +Comment[ne]=केडीई गेट डाउनलोड सूची +Comment[nl]=Kget-downloadlijst +Comment[nn]=Nedlastingsliste for Kget +Comment[nso]=Palo ya Ngwalollo ya Kget +Comment[pa]=Kget ਡਾਊਨਲੋਡ ਸੂਚੀ +Comment[pl]=Lista plików do pobrania przez KGet +Comment[pt]=Lista de Transferências do KGet +Comment[pt_BR]=Lista de Download do Kget +Comment[ro]=Listă de transfer KGet +Comment[ru]=Список заданий KGet +Comment[se]=Kget:a viežžanlisttu +Comment[sk]=Kget zoznam sťahovania +Comment[sl]=Seznam datotek za prenos s KGet +Comment[sr]=Kget-ова листа преузимања +Comment[sr@Latn]=Kget-ova lista preuzimanja +Comment[sv]=Nerladdningslista för Kget +Comment[ta]=கேகெட் பதிவிறக்க பட்டியல் +Comment[tg]=Рӯйхати Боркунии Kget +Comment[th]=รายการดาวน์โหลด K +Comment[tr]=KGet İndirme Listesi +Comment[uk]=Список звантаження kget +Comment[ven]=Mutevhe wau hwesulula wa Kget +Comment[wa]=Djivêye des aberwetaedjes di Kget +Comment[xh]=Uluhlu lwe Kget loku Layishela ezantsi +Comment[zh_CN]=Kget 下载清单 +Comment[zh_HK]=Kget 下載清單 +Comment[zh_TW]=Kget 下載清單 +Comment[zu]=I-Kget ye-listi Yokugcwalisela phansi +Icon=kget_list +Type=MimeType +MimeType=application/x-kgetlist +Patterns=*.kgt; +DefaultApp=KGet |