summaryrefslogtreecommitdiffstats
path: root/src/modules/sharedfileswindow
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /src/modules/sharedfileswindow
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/modules/sharedfileswindow')
-rw-r--r--src/modules/sharedfileswindow/Makefile.am22
-rw-r--r--src/modules/sharedfileswindow/caps/Makefile.am9
-rw-r--r--src/modules/sharedfileswindow/caps/sharedfileswindow0
-rw-r--r--src/modules/sharedfileswindow/libkvisharedfileswindow.cpp158
-rw-r--r--src/modules/sharedfileswindow/sharedfileswindow.cpp742
-rw-r--r--src/modules/sharedfileswindow/sharedfileswindow.h114
6 files changed, 1045 insertions, 0 deletions
diff --git a/src/modules/sharedfileswindow/Makefile.am b/src/modules/sharedfileswindow/Makefile.am
new file mode 100644
index 00000000..f43e1e67
--- /dev/null
+++ b/src/modules/sharedfileswindow/Makefile.am
@@ -0,0 +1,22 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it>
+###############################################################################
+
+SUBDIRS = caps
+
+AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \
+$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\"
+
+pluglib_LTLIBRARIES = libkvisharedfileswindow.la
+
+libkvisharedfileswindow_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
+
+libkvisharedfileswindow_la_SOURCES = libkvisharedfileswindow.cpp sharedfileswindow.cpp
+libkvisharedfileswindow_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
+
+noinst_HEADERS= sharedfileswindow.h
+
+m_%.moc: %.h
+ $(SS_QT_MOC) $< -o $@
+
+sharedfileswindow.cpp: m_sharedfileswindow.moc
diff --git a/src/modules/sharedfileswindow/caps/Makefile.am b/src/modules/sharedfileswindow/caps/Makefile.am
new file mode 100644
index 00000000..bc03ac24
--- /dev/null
+++ b/src/modules/sharedfileswindow/caps/Makefile.am
@@ -0,0 +1,9 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <stefanek@tin.it>
+###############################################################################
+
+tmpdir = $(pluglibdir)/caps/tool/
+
+tmp_DATA= sharedfileswindow
+
+EXTRA_DIST = $(tmp_DATA)
diff --git a/src/modules/sharedfileswindow/caps/sharedfileswindow b/src/modules/sharedfileswindow/caps/sharedfileswindow
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/modules/sharedfileswindow/caps/sharedfileswindow
diff --git a/src/modules/sharedfileswindow/libkvisharedfileswindow.cpp b/src/modules/sharedfileswindow/libkvisharedfileswindow.cpp
new file mode 100644
index 00000000..a7cab111
--- /dev/null
+++ b/src/modules/sharedfileswindow/libkvisharedfileswindow.cpp
@@ -0,0 +1,158 @@
+//==================================================================================
+//
+// File : libkvisharedfileswindow.cpp
+// Creation date : Mon Apr 21 2003 23:14:12 CEST by Szymon Stefanek
+//
+// Copyright (C) 2003 Szymon Stefanek (pragma at kvirc dot net)
+//
+// 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 opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//==================================================================================
+
+#include "kvi_module.h"
+
+
+#include "sharedfileswindow.h"
+
+#include "kvi_app.h"
+#include "kvi_frame.h"
+#include "kvi_window.h"
+#include "kvi_locale.h"
+#include "kvi_iconmanager.h"
+
+#include <qsplitter.h>
+
+#define KVI_SHARED_FILES_WINDOW_EXTENSION_NAME "Shared files window extension"
+
+KviSharedFilesWindow * g_pSharedFilesWindow = 0;
+
+static KviModuleExtension * sharedfileswindow_extension_alloc(KviModuleExtensionAllocStruct * s)
+{
+ bool bCreateMinimized = false;
+ bool bNoRaise = false;
+
+ if(!g_pSharedFilesWindow)
+ {
+ if(s->pParams)
+ {
+ if(QVariant * v = s->pParams->find("bCreateMinimized"))
+ {
+ if(v->isValid())
+ {
+ if(v->type() == QVariant::Bool)
+ {
+ bCreateMinimized = v->toBool();
+ }
+ }
+ }
+ }
+
+ g_pSharedFilesWindow = new KviSharedFilesWindow(s->pDescriptor,g_pFrame);
+ g_pFrame->addWindow(g_pSharedFilesWindow,!bCreateMinimized);
+ if(bCreateMinimized)g_pSharedFilesWindow->minimize();
+ return g_pSharedFilesWindow;
+ }
+
+ if(s->pParams)
+ {
+ if(QVariant * v = s->pParams->find("bNoRaise"))
+ {
+ if(v)
+ {
+ if(v->isValid() && v->type() == QVariant::Bool)
+ bNoRaise = v->toBool();
+ }
+ }
+ }
+
+ if(!bNoRaise)g_pSharedFilesWindow->delayedAutoRaise();
+ return g_pSharedFilesWindow;
+}
+
+
+/*
+ @doc: sharedfileswindow.open
+ @type:
+ command
+ @title:
+ sharedfileswindow.open
+ @short:
+ Opens the shared files window
+ @syntax:
+ sharedfileswindow.open [-m] [-n]
+ @switches:
+ !sw: -m
+ Causes the window to be created as minimized
+ !sw: -n
+ Causes the window to be not raised if already open
+ @description:
+ Opens the shared files window
+*/
+
+static bool sharedfileswindow_kvs_cmd_open(KviKvsModuleCommandCall * c)
+{
+ KviModuleExtensionDescriptor * d = c->module()->findExtensionDescriptor("tool",KVI_SHARED_FILES_WINDOW_EXTENSION_NAME);
+ if(d)
+ {
+ KviPointerHashTable<QString,QVariant> dict(17,true);
+ dict.setAutoDelete(true);
+ dict.replace("bCreateMinimized",new QVariant(c->hasSwitch('m',"minimized")));
+ dict.replace("bNoRaise",new QVariant(c->hasSwitch('n',"noraise")));
+
+ d->allocate(c->window(),&dict,0);
+ } else {
+ c->warning("Ops.. internal error");
+ }
+ return true;
+}
+
+static bool sharedfileswindow_module_init(KviModule * m)
+{
+ KviModuleExtensionDescriptor * d = m->registerExtension("tool",
+ KVI_SHARED_FILES_WINDOW_EXTENSION_NAME,
+ __tr2qs_ctx("Manage S&hared Files","sharedfileswindow"),
+ sharedfileswindow_extension_alloc);
+
+ if(d)d->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_SHAREDFILES)));
+
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"open",sharedfileswindow_kvs_cmd_open);
+ return true;
+}
+
+static bool sharedfileswindow_module_cleanup(KviModule *m)
+{
+ if(g_pSharedFilesWindow)
+ {
+ delete g_pSharedFilesWindow;
+ g_pSharedFilesWindow = 0;
+ }
+ return true;
+}
+
+static bool sharedfileswindow_module_can_unload(KviModule *m)
+{
+ return (!g_pSharedFilesWindow);
+}
+
+KVIRC_MODULE(
+ "SharedFilesWindow",
+ "1.0.0",
+ "Copyright (C) 2003 Szymon Stefanek (pragma at kvirc dot net)",
+ "Shared files window extension",
+ sharedfileswindow_module_init,
+ sharedfileswindow_module_can_unload,
+ 0,
+ sharedfileswindow_module_cleanup
+)
diff --git a/src/modules/sharedfileswindow/sharedfileswindow.cpp b/src/modules/sharedfileswindow/sharedfileswindow.cpp
new file mode 100644
index 00000000..aa851684
--- /dev/null
+++ b/src/modules/sharedfileswindow/sharedfileswindow.cpp
@@ -0,0 +1,742 @@
+//==================================================================================
+//
+// File : sharedfileswindow.cpp
+// Creation date : Mon Apr 21 2003 23:14:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 1999-2001 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the linkss of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//==================================================================================
+
+#include "sharedfileswindow.h"
+
+#include "kvi_debug.h"
+#include "kvi_iconmanager.h"
+#include "kvi_ircview.h"
+#include "kvi_out.h"
+#include "kvi_options.h"
+#include "kvi_locale.h"
+#include "kvi_out.h"
+#include "kvi_mirccntrl.h"
+#include "kvi_themedlabel.h"
+#include "kvi_input.h"
+#include "kvi_filedialog.h"
+#include "kvi_styled_controls.h"
+
+#include <qdatetimeedit.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qsplitter.h>
+#include "kvi_tal_hbox.h"
+#include "kvi_tal_vbox.h"
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qmessagebox.h>
+#include <qfileinfo.h>
+
+extern KviSharedFilesWindow * g_pSharedFilesWindow;
+extern KVIRC_API KviSharedFilesManager * g_pSharedFilesManager;
+
+KviSharedFileEditDialog::KviSharedFileEditDialog(QWidget * par,KviSharedFile * f)
+: QDialog(par,"shared_file_editor",true)
+{
+ QGridLayout * g = new QGridLayout(this,1,1,11,6);
+
+ setCaption(__tr2qs_ctx("Edit Shared File - KVIrc","sharedfileswindow"));
+
+ QLabel * l = new QLabel(__tr2qs_ctx("Share name:","sharedfileswindow"),this);
+ g->addWidget(l, 0, 0 );
+
+ m_pShareNameEdit = new QLineEdit(this);
+ g->addMultiCellWidget( m_pShareNameEdit, 0, 0, 1, 3 );
+
+ l = new QLabel(__tr2qs_ctx("File path:","sharedfileswindow"),this);
+ g->addWidget(l, 1, 0 );
+
+ m_pFilePathEdit = new QLineEdit(this);
+ g->addMultiCellWidget( m_pFilePathEdit, 1, 1, 1, 2 );
+
+ m_pBrowseButton = new QPushButton(__tr2qs_ctx("&Browse...","sharedfileswindow"),this);
+ g->addWidget( m_pBrowseButton, 1, 3 );
+ connect(m_pBrowseButton,SIGNAL(clicked()),this,SLOT(browse()));
+
+ l = new QLabel(__tr2qs_ctx("User mask:","sharedfileswindow"),this);
+ g->addWidget(l, 2, 0 );
+
+ m_pUserMaskEdit = new QLineEdit(this);
+ g->addMultiCellWidget( m_pUserMaskEdit, 2, 2, 1, 3 );
+
+ m_pExpireCheckBox = new KviStyledCheckBox(__tr2qs_ctx("Expire at:","sharedfileswindow"),this);
+ g->addWidget(m_pExpireCheckBox,3,0);
+
+ m_pExpireDateTimeEdit = new QDateTimeEdit(this);
+ g->addMultiCellWidget(m_pExpireDateTimeEdit, 3, 3, 1, 3 );
+
+ connect(m_pExpireCheckBox,SIGNAL(toggled(bool)),m_pExpireDateTimeEdit,SLOT(setEnabled(bool)));
+
+ QPushButton * pb;
+
+ pb = new QPushButton(__tr2qs_ctx("&OK","sharedfileswindow"),this);
+ connect(pb,SIGNAL(clicked()),this,SLOT(okClicked()));
+ pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_ACCEPT)));
+ g->addWidget(pb,5,2);
+ pb = new QPushButton(__tr2qs_ctx("Cancel","sharedfileswindow"),this);
+ connect(pb,SIGNAL(clicked()),this,SLOT(reject()));
+ pb->setIconSet(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_DISCARD)));
+ g->addWidget(pb,5,3);
+
+ g->setRowStretch(4,1);
+ g->setColStretch(0,1);
+
+ if(f)
+ {
+ m_pShareNameEdit->setText(f->name());
+ m_pFilePathEdit->setText(f->absFilePath());
+ m_pUserMaskEdit->setText(f->userMask());
+ QDateTime dt;
+ dt.setTime_t(f->expireTime());
+ m_pExpireDateTimeEdit->setDateTime(dt);
+ m_pExpireCheckBox->setChecked(f->expires());
+ m_pExpireDateTimeEdit->setEnabled(f->expires());
+ } else {
+ m_pExpireCheckBox->setChecked(false);
+ m_pExpireDateTimeEdit->setDateTime(QDateTime::currentDateTime());
+ m_pExpireDateTimeEdit->setEnabled(false);
+ }
+
+}
+
+KviSharedFileEditDialog::~KviSharedFileEditDialog()
+{
+
+}
+
+void KviSharedFileEditDialog::browse()
+{
+ QString szBuf;
+ QString szTxt = m_pFilePathEdit->text();
+ if(!KviFileDialog::askForOpenFileName(szBuf,__tr2qs("Choose the file to share"),szTxt))return;
+ m_pFilePathEdit->setText(szBuf);
+}
+
+KviSharedFile * KviSharedFileEditDialog::getResult()
+{
+ QString szName = m_pShareNameEdit->text();
+ QString szPath = m_pFilePathEdit->text();
+ QString szMask = m_pUserMaskEdit->text();
+ QDateTime dt = m_pExpireDateTimeEdit->dateTime();
+ bool bExpires = m_pExpireCheckBox->isChecked();
+ QFileInfo f(szPath);
+ return new KviSharedFile(szName,szPath,szMask,bExpires ? dt.toTime_t() : (time_t)0,f.size());
+}
+
+void KviSharedFileEditDialog::okClicked()
+{
+ QString szName = m_pShareNameEdit->text();
+ QString szPath = m_pFilePathEdit->text();
+ QDateTime dt = m_pExpireDateTimeEdit->dateTime();
+ bool bExpires = m_pExpireCheckBox->isChecked();
+ if(bExpires && (dt <= QDateTime::currentDateTime()))
+ {
+ QMessageBox::warning(this,__tr2qs_ctx("Invalid expire time","sharedfileswindow"),
+ __tr2qs_ctx("The expire date/time is in the past: please either remove the \"expires\"" \
+ "check mark or specify a expire date/time in the future","sharedfileswindow"),
+ __tr2qs_ctx("OK","sharedfileswindow"));
+ return;
+ }
+
+ if(szName.isEmpty())
+ {
+ QMessageBox::warning(this,__tr2qs_ctx("Invalid share name","sharedfileswindow"),
+ __tr2qs_ctx("The share name can't be empty, please correct it","sharedfileswindow"),
+ __tr2qs_ctx("OK","sharedfileswindow"));
+ return;
+ }
+
+ QFileInfo f(szPath);
+ if(!(f.exists() && f.isFile() && f.isReadable()))
+ {
+ QMessageBox::warning(this,__tr2qs_ctx("Can't open the file","sharedfileswindow"),
+ __tr2qs_ctx("The file doesn't exist or it is not readable, please check the path","sharedfileswindow"),
+ __tr2qs_ctx("OK","sharedfileswindow"));
+ return;
+ }
+
+ accept();
+}
+
+
+KviSharedFilesListViewItem::KviSharedFilesListViewItem(KviTalListView * lv,KviSharedFile * f)
+: KviTalListViewItem(lv,f->name())
+{
+ setText(1,f->absFilePath());
+ setText(2,f->userMask());
+ if(f->expires())
+ {
+ QDateTime dt;
+ dt.setTime_t(f->expireTime());
+ setText(3,dt.toString());
+ } else {
+ setText(3,__tr2qs_ctx("Never","sharedfileswindow"));
+ }
+ m_pSharedFilePointer = f;
+}
+
+KviSharedFilesListViewItem::~KviSharedFilesListViewItem()
+{
+}
+
+
+KviSharedFilesWindow::KviSharedFilesWindow(KviModuleExtensionDescriptor * d,KviFrame * lpFrm)
+: KviWindow(KVI_WINDOW_TYPE_TOOL,lpFrm,"shared files window",0) , KviModuleExtension(d)
+{
+ g_pSharedFilesWindow = this;
+#ifdef COMPILE_USE_QT4
+ m_pSplitter = new QSplitter(Qt::Horizontal,this,"splitter");
+#else
+ m_pSplitter = new QSplitter(QSplitter::Horizontal,this,"splitter");
+#endif
+
+ KviTalVBox * vbox = new KviTalVBox(m_pSplitter);
+
+ m_pListView = new KviTalListView(vbox);
+ //m_pListView->header()->hide();
+ m_pListView->setAllColumnsShowFocus(true);
+ m_pListView->addColumn(__tr2qs_ctx("Name","sharedfileswindow"),200);
+ m_pListView->addColumn(__tr2qs_ctx("Filename","sharedfileswindow"),300);
+ m_pListView->addColumn(__tr2qs_ctx("Mask","sharedfileswindow"),200);
+ m_pListView->addColumn(__tr2qs_ctx("Expires","sharedfileswindow"),200);
+ m_pListView->setSelectionMode(KviTalListView::Single);
+ connect(m_pListView,SIGNAL(selectionChanged()),this,SLOT(enableButtons()));
+
+ connect(g_pSharedFilesManager,SIGNAL(sharedFilesChanged()),this,SLOT(fillFileView()));
+ connect(g_pSharedFilesManager,SIGNAL(sharedFileAdded(KviSharedFile *)),this,SLOT(sharedFileAdded(KviSharedFile *)));
+ connect(g_pSharedFilesManager,SIGNAL(sharedFileRemoved(KviSharedFile *)),this,SLOT(sharedFileRemoved(KviSharedFile *)));
+
+ KviTalHBox * b = new KviTalHBox(vbox);
+
+ m_pAddButton = new QPushButton(__tr2qs_ctx("&Add...","sharedfileswindow"),b);
+ connect(m_pAddButton,SIGNAL(clicked()),this,SLOT(addClicked()));
+ m_pRemoveButton = new QPushButton(__tr2qs_ctx("Re&move","sharedfileswindow"),b);
+ connect(m_pRemoveButton,SIGNAL(clicked()),this,SLOT(removeClicked()));
+ m_pEditButton = new QPushButton(__tr2qs_ctx("&Edit","sharedfileswindow"),b);
+ connect(m_pEditButton,SIGNAL(clicked()),this,SLOT(editClicked()));
+
+ fillFileView();
+}
+
+KviSharedFilesWindow::~KviSharedFilesWindow()
+{
+ g_pSharedFilesWindow = 0;
+}
+
+void KviSharedFilesWindow::enableButtons()
+{
+ KviTalListViewItem * it = m_pListView->currentItem();
+ m_pEditButton->setEnabled(it);
+ m_pRemoveButton->setEnabled(it);
+}
+
+void KviSharedFilesWindow::removeClicked()
+{
+ KviSharedFilesListViewItem * it = (KviSharedFilesListViewItem *)m_pListView->currentItem();
+ if(!it)return;
+
+ g_pSharedFilesManager->removeSharedFile(it->readOnlySharedFilePointer()->name(),it->readOnlySharedFilePointer());
+}
+
+void KviSharedFilesWindow::addClicked()
+{
+ KviSharedFileEditDialog dlg(0);
+ if(dlg.exec() != QDialog::Accepted)return;
+
+ KviSharedFile * f = dlg.getResult();
+ if(!f)return;
+ g_pSharedFilesManager->addSharedFile(f);
+}
+
+void KviSharedFilesWindow::editClicked()
+{
+ KviSharedFilesListViewItem * it = (KviSharedFilesListViewItem *)m_pListView->currentItem();
+ if(!it)return;
+
+ KviSharedFileEditDialog dlg(0,it->readOnlySharedFilePointer());
+ if(dlg.exec() != QDialog::Accepted)return;
+
+ KviSharedFilesListViewItem * it2 = (KviSharedFilesListViewItem *)m_pListView->currentItem();
+ if(it2 != it)return; // ooops ?
+ KviSharedFile * f = dlg.getResult();
+ if(!f)return; // ooops 2 ?
+
+ g_pSharedFilesManager->removeSharedFile(it->readOnlySharedFilePointer()->name(),it->readOnlySharedFilePointer());
+ g_pSharedFilesManager->addSharedFile(f);
+}
+
+void KviSharedFilesWindow::fillFileView()
+{
+ m_pListView->clear();
+ KviPointerHashTableIterator<QString,KviSharedFileList> it(*(g_pSharedFilesManager->sharedFileListDict()));
+
+ KviSharedFilesListViewItem * itm;
+
+ while(KviSharedFileList * l = it.current())
+ {
+ for(KviSharedFile * o = l->first();o;o = l->next())
+ {
+ itm = new KviSharedFilesListViewItem(m_pListView,o);
+ }
+ ++it;
+ }
+ enableButtons();
+}
+
+void KviSharedFilesWindow::sharedFileAdded(KviSharedFile * f)
+{
+ KviSharedFilesListViewItem * it;
+ it = new KviSharedFilesListViewItem(m_pListView,f);
+ enableButtons();
+}
+
+void KviSharedFilesWindow::sharedFileRemoved(KviSharedFile * f)
+{
+ KviTalListViewItem * it = m_pListView->firstChild();
+ while(it)
+ {
+ if(((KviSharedFilesListViewItem *)it)->readOnlySharedFilePointer() == f)
+ {
+ delete ((KviSharedFilesListViewItem *)it);
+ return;
+ }
+ it = it->nextSibling();
+ }
+ enableButtons();
+}
+
+
+
+/*
+void KviSharedFilesWindow::tipRequest(KviDynamicToolTip * tip,const QPoint &pnt)
+{
+
+ KviSharedFilesItem * it = (KviSharedFilesItem *)m_pListView->itemAt(pnt);
+ if(!it)return;
+ QString txt = it->transfer()->tipText();
+ tip->tip(m_pListView->itemRect(it),txt);
+
+}
+*/
+/*
+void KviSharedFilesWindow::fillTransferView()
+{
+ KviPointerList<KviSharedFiles> * l = KviSharedFilesManager::instance()->transferList();
+ if(!l)return;
+ KviSharedFilesItem * it;
+ for(KviSharedFiles * t = l->first();t;t = l->next())
+ {
+ it = new KviSharedFilesItem(m_pListView,t);
+ t->setDisplayItem(it);
+ }
+}
+
+KviSharedFilesItem * KviSharedFilesWindow::findItem(KviSharedFiles * t)
+{
+ KviSharedFilesItem * it = (KviSharedFilesItem *)m_pListView->firstChild();
+ while(it)
+ {
+ if(it->transfer() == t)return it;
+ it = (KviSharedFilesItem *)(it->nextSibling());
+ }
+ return 0;
+}
+
+void KviSharedFilesWindow::transferRegistered(KviSharedFiles * t)
+{
+ KviSharedFilesItem * it = new KviSharedFilesItem(m_pListView,t);
+ //t->setDisplayItem(it);
+}
+
+void KviSharedFilesWindow::transferUnregistering(KviSharedFiles * t)
+{
+ KviSharedFilesItem * it = findItem(t);
+ //t->setDisplayItem(0);
+ if(it)delete it;
+}
+
+void KviSharedFilesWindow::rightButtonPressed(KviTalListViewItem *it,const QPoint &pnt,int col)
+{
+ if(!m_pContextPopup)m_pContextPopup = new KviTalPopupMenu(this);
+ if(!m_pLocalFilePopup)m_pLocalFilePopup = new KviTalPopupMenu(this);
+ if(!m_pOpenFilePopup)
+ {
+ m_pOpenFilePopup= new KviTalPopupMenu(this);
+ connect(m_pOpenFilePopup,SIGNAL(activated(int)),this,SLOT(openFilePopupActivated(int)));
+ }
+
+ m_pContextPopup->clear();
+
+ int id;
+
+
+ if(it)
+ {
+ KviSharedFilesItem * i = (KviSharedFilesItem *)it;
+ if(i->transfer())
+ {
+
+ QString szFile = i->transfer()->localFileName();
+ if(!szFile.isEmpty())
+ {
+ m_pLocalFilePopup->clear();
+
+ QString tmp = "<b>file:/";
+ tmp += szFile;
+ tmp += "</b><br>";
+
+ QFileInfo fi(szFile);
+ if(fi.exists())
+ {
+ tmp += "<nobr>";
+ tmp += __tr2qs_ctx("Size: %1 bytes","filetransferwindow").arg(fi.size());
+ tmp += "</nobr><br>";
+ }
+
+#ifdef COMPILE_KDE_SUPPORT
+ tmp += "<nobr>Mime: ";
+ tmp += KMimeType::findByPath(szFile)->name();
+ tmp += "</nobr>";
+#endif //COMPILE_KDE_SUPPORT
+
+ QLabel * l = new QLabel(tmp,m_pLocalFilePopup);
+ l->setFrameStyle(QFrame::Raised | QFrame::Panel);
+ m_pLocalFilePopup->insertItem(l);
+
+#ifdef COMPILE_KDE_SUPPORT
+ QString mimetype = KMimeType::findByPath(szFile)->name();
+ KServiceTypeProfile::OfferList offers = KServiceTypeProfile::offers(mimetype,"Application");
+
+ m_pOpenFilePopup->clear();
+
+ int id;
+ int idx = 0;
+
+ for(KServiceTypeProfile::OfferList::Iterator itOffers = offers.begin();
+ itOffers != offers.end(); ++itOffers)
+ {
+ id = m_pOpenFilePopup->insertItem((*itOffers).service()->pixmap(KIcon::Small),(*itOffers).service()->name());
+ m_pOpenFilePopup->setItemParameter(id,idx);
+ idx++;
+ }
+
+ m_pOpenFilePopup->insertSeparator();
+
+ id = m_pOpenFilePopup->insertItem(__tr2qs_ctx("Default application","filetransferwindow"),this,SLOT(openLocalFile()));
+ m_pOpenFilePopup->setItemParameter(id,-1);
+ id = m_pOpenFilePopup->insertItem(__tr2qs_ctx("&Other...","filetransferwindow"),this,SLOT(openLocalFileWith()));
+ m_pOpenFilePopup->setItemParameter(id,-1);
+
+ m_pLocalFilePopup->insertItem(__tr2qs_ctx("Open with","filetransferwindow"),m_pOpenFilePopup);
+ m_pLocalFilePopup->insertSeparator();
+ m_pLocalFilePopup->insertItem(__tr2qs_ctx("Open folder","filetransferwindow"),this,SLOT(openLocalFileFolder()));
+ m_pLocalFilePopup->insertItem(__tr2qs_ctx("Reach in terminal","filetransferwindow"),this,SLOT(openLocalFileTerminal()));
+ m_pLocalFilePopup->insertSeparator();
+#endif //COMPILE_KDE_SUPPORT
+ m_pLocalFilePopup->insertItem(__tr2qs_ctx("Copy path to clipboard","filetransferwindow"),this,SLOT(copyLocalFileToClipboard()));
+
+ m_pContextPopup->insertItem(__tr2qs_ctx("Local file","filetransferwindow"),m_pLocalFilePopup);
+ }
+
+ i->transfer()->fillContextPopup(m_pContextPopup,col);
+ m_pContextPopup->insertSeparator();
+ }
+ }
+
+
+ bool bHaveTerminated = false;
+ KviSharedFilesItem * item = (KviSharedFilesItem *)m_pListView->firstChild();
+ while(item)
+ {
+ if(item->transfer()->terminated())
+ {
+ bHaveTerminated = true;
+ break;
+ }
+ item = (KviSharedFilesItem *)item->nextSibling();
+ }
+
+ id = m_pContextPopup->insertItem(__tr2qs_ctx("Clear terminated","filetransferwindow"),this,SLOT(clearTerminated()));
+ m_pContextPopup->setItemEnabled(id,bHaveTerminated);
+
+ id = m_pContextPopup->insertItem(__tr2qs_ctx("Clear all","filetransferwindow"),this,SLOT(clearAll()));
+ m_pContextPopup->setItemEnabled(id,it);
+
+ m_pContextPopup->popup(pnt);
+}
+
+
+KviSharedFiles * KviSharedFilesWindow::selectedTransfer()
+{
+ KviTalListViewItem * it = m_pListView->selectedItem();
+ if(!it)return 0;
+ KviSharedFilesItem * i = (KviSharedFilesItem *)it;
+ return i->transfer();
+}
+
+void KviSharedFilesWindow::openFilePopupActivated(int id)
+{
+#ifdef COMPILE_KDE_SUPPORT
+ int ip = m_pOpenFilePopup->itemParameter(id);
+ if(ip < 0)return;
+ QString txt = m_pOpenFilePopup->text(id);
+
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+
+ QString mimetype = KMimeType::findByPath(tmp)->name();
+ KServiceTypeProfile::OfferList offers = KServiceTypeProfile::offers(mimetype,"Application");
+
+ for(KServiceTypeProfile::OfferList::Iterator itOffers = offers.begin();
+ itOffers != offers.end(); ++itOffers)
+ {
+ if(txt == (*itOffers).service()->name())
+ {
+ KURL::List lst;
+ KURL url;
+ url.setPath(tmp);
+ lst.append(url);
+ KRun::run(*((*itOffers).service()), lst);
+ break;
+ }
+ }
+#endif //COMPILE_KDE_SUPPORT
+}
+
+void KviSharedFilesWindow::openLocalFileTerminal()
+{
+#ifdef COMPILE_KDE_SUPPORT
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+
+ int idx = tmp.findRev("/");
+ if(idx == -1)return;
+ tmp = tmp.left(idx);
+
+ tmp.prepend("konsole --workdir=\"");
+ tmp.append("\"");
+
+ KRun::runCommand(tmp);
+#endif //COMPILE_KDE_SUPPORT
+}
+
+void KviSharedFilesWindow::openLocalFile()
+{
+#ifdef COMPILE_KDE_SUPPORT
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+
+ QString mimetype = KMimeType::findByPath(tmp)->name();
+ KService::Ptr offer = KServiceTypeProfile::preferredService(mimetype,"Application");
+ if(!offer)
+ {
+ openLocalFileWith();
+ return;
+ }
+
+ KURL::List lst;
+ KURL url;
+ url.setPath(tmp);
+ lst.append(url);
+ KRun::run(*offer, lst);
+#endif //COMPILE_KDE_SUPPORT
+}
+
+void KviSharedFilesWindow::openLocalFileWith()
+{
+#ifdef COMPILE_KDE_SUPPORT
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+
+ KURL::List lst;
+ KURL url;
+ url.setPath(tmp);
+ lst.append(url);
+ KRun::displayOpenWithDialog(lst);
+#endif //COMPILE_KDE_SUPPORT
+}
+
+void KviSharedFilesWindow::copyLocalFileToClipboard()
+{
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+ QApplication::clipboard()->setSelectionMode(false);
+ QApplication::clipboard()->setText(tmp);
+ QApplication::clipboard()->setSelectionMode(true);
+ QApplication::clipboard()->setText(tmp);
+}
+
+void KviSharedFilesWindow::openLocalFileFolder()
+{
+#ifdef COMPILE_KDE_SUPPORT
+ KviSharedFiles * t = selectedTransfer();
+ if(!t)return;
+ QString tmp = t->localFileName();
+ if(tmp.isEmpty())return;
+
+ int idx = tmp.findRev("/");
+ if(idx == -1)return;
+ tmp = tmp.left(idx);
+
+ QString mimetype = KMimeType::findByPath(tmp)->name(); // inode/directory
+ KService::Ptr offer = KServiceTypeProfile::preferredService(mimetype,"Application");
+ if(!offer)return;
+
+ KURL::List lst;
+ KURL url;
+ url.setPath(tmp);
+ lst.append(url);
+ KRun::run(*offer, lst);
+#endif //COMPILE_KDE_SUPPORT
+}
+
+void KviSharedFilesWindow::heartbeat()
+{
+ if(m_pListView->childCount() < 1)return;
+
+ KviTalListViewItem * i1;
+ KviTalListViewItem * i2;
+
+ i1 = m_pListView->itemAt(QPoint(1,1));
+ if(!i1)
+ {
+ m_pListView->viewport()->update();
+ return;
+ }
+ i2 = m_pListView->itemAt(QPoint(1,m_pListView->viewport()->height() - 2));
+ if(i2)i2 = i2->nextSibling();
+
+ while(i1 && (i1 != i2))
+ {
+ if(((KviSharedFilesItem *)i1)->transfer()->active())
+ {
+ m_pListView->repaintItem(i1);
+ }
+ i1 = i1->nextSibling();
+ }
+}
+
+void KviSharedFilesWindow::clearAll()
+{
+ if(QMessageBox::information(this,__tr2qs_ctx("Clear all transfers","filetransferwindow"),
+ __tr2qs_ctx("Remove all the transfers including the running ones ?","filetransferwindow"),
+ __tr2qs_ctx("Yes","filetransferwindow"),__tr2qs_ctx("No","filetransferwindow")) != 0)return;
+
+ KviSharedFilesManager::instance()->killAllTransfers();
+}
+
+void KviSharedFilesWindow::clearTerminated()
+{
+ KviSharedFilesManager::instance()->killTerminatedTransfers();
+}
+*/
+void KviSharedFilesWindow::getBaseLogFileName(KviStr &buffer)
+{
+ buffer.sprintf("SHAREDFILES");
+}
+
+QPixmap * KviSharedFilesWindow::myIconPtr()
+{
+ return g_pIconManager->getSmallIcon(KVI_SMALLICON_SHAREDFILES);
+}
+
+void KviSharedFilesWindow::resizeEvent(QResizeEvent *e)
+{
+ //int h = m_pInput->heightHint();
+ m_pSplitter->setGeometry(0,0,width(),height());
+ //m_pInput->setGeometry(0,height() - h,width(),h);
+}
+
+QSize KviSharedFilesWindow::sizeHint() const
+{
+ return m_pSplitter->sizeHint();
+}
+
+void KviSharedFilesWindow::fillCaptionBuffers()
+{
+ m_szPlainTextCaption = __tr2qs_ctx("Shared Files","sharedfileswindow");
+
+ m_szHtmlActiveCaption = "<nobr><font color=\"";
+ m_szHtmlActiveCaption += KVI_OPTION_COLOR(KviOption_colorCaptionTextActive).name();
+ m_szHtmlActiveCaption += "\"><b>";
+ m_szHtmlActiveCaption += m_szPlainTextCaption;
+ m_szHtmlActiveCaption += "</b></font></nobr>";
+
+ m_szHtmlInactiveCaption = "<nobr><font color=\"";
+ m_szHtmlInactiveCaption += KVI_OPTION_COLOR(KviOption_colorCaptionTextInactive).name();
+ m_szHtmlInactiveCaption += "\"><b>";
+ m_szHtmlInactiveCaption += m_szPlainTextCaption;
+ m_szHtmlInactiveCaption += "</b></font></nobr>";
+
+}
+
+void KviSharedFilesWindow::die()
+{
+ close();
+}
+
+
+
+//#warning "Load & save properties of this kind of window"
+
+//void KviSharedFilesWindow::saveProperties()
+//{
+// KviWindowProperty p;
+// p.rect = externalGeometry();
+// p.isDocked = isAttacched();
+// QValueList<int> l(m_pSplitter->sizes());
+// if(l.count() >= 1)p.splitWidth1 = *(l.at(0));
+// if(l.count() >= 2)p.splitWidth2 = *(l.at(1));
+// p.timestamp = m_pView->timestamp();
+// p.imagesVisible = m_pView->imagesVisible();
+// p.isMaximized = isAttacched() && isMaximized();
+// p.topSplitWidth1 = 0;
+// p.topSplitWidth2 = 0;
+// p.topSplitWidth3 = 0;
+// g_pOptions->m_pWinPropertiesList->setProperty(caption(),&p);
+//}
+//
+//void KviSharedFilesWindow::setProperties(KviWindowProperty *p)
+//{
+// QValueList<int> l;
+// l.append(p->splitWidth1);
+// l.append(p->splitWidth2);
+// m_pVertSplitter->setSizes(l);
+// m_pIrcView->setTimestamp(p->timestamp);
+// m_pIrcView->setShowImages(p->imagesVisible);
+//}
+
+
+#include "m_sharedfileswindow.moc"
diff --git a/src/modules/sharedfileswindow/sharedfileswindow.h b/src/modules/sharedfileswindow/sharedfileswindow.h
new file mode 100644
index 00000000..f46bd6df
--- /dev/null
+++ b/src/modules/sharedfileswindow/sharedfileswindow.h
@@ -0,0 +1,114 @@
+#ifndef _SHAREDFILESWINDOW_H_
+#define _SHAREDFILESWINDOW_H_
+//==================================================================================
+//
+// File : sharedfileswindow.h
+// Creation date : Mon Apr 21 2003 23:14:12 CEST by Szymon Stefanek
+//
+// This file is part of the KVirc irc client distribution
+// Copyright (C) 2003 Szymon Stefanek (pragma at kvirc dot net)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the linkss of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc. ,51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//==================================================================================
+
+#include "kvi_window.h"
+#include "kvi_string.h"
+#include "kvi_sparser.h"
+#include "kvi_console.h"
+#include "kvi_moduleextension.h"
+#include "kvi_sharedfiles.h"
+#include "kvi_styled_controls.h"
+
+#include "kvi_tal_listview.h"
+#include <qdialog.h>
+
+class QGridLayout;
+class QDateTimeEdit;
+class QLabel;
+class QLineEdit;
+class QPushButton;
+
+class KviSharedFilesListViewItem : public KviTalListViewItem
+{
+public:
+ KviSharedFilesListViewItem(KviTalListView * lv,KviSharedFile * f);
+ ~KviSharedFilesListViewItem();
+protected:
+ KviSharedFile * m_pSharedFilePointer; // THIS IS READ ONLY!
+public:
+ KviSharedFile * readOnlySharedFilePointer(){ return m_pSharedFilePointer; };
+};
+
+
+
+class KviSharedFileEditDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ KviSharedFileEditDialog(QWidget* par,KviSharedFile * f = 0);
+ ~KviSharedFileEditDialog();
+
+ QDateTimeEdit * m_pExpireDateTimeEdit;
+ QLineEdit * m_pFilePathEdit;
+ QLineEdit * m_pUserMaskEdit;
+ QPushButton * m_pBrowseButton;
+ QLineEdit * m_pShareNameEdit;
+ KviStyledCheckBox * m_pExpireCheckBox;
+public:
+ KviSharedFile * getResult();
+protected slots:
+ void okClicked();
+ void browse();
+};
+
+
+
+
+class KviSharedFilesWindow : public KviWindow , public KviModuleExtension
+{
+ friend class KviSharedFilesItem;
+ Q_OBJECT
+public:
+ KviSharedFilesWindow(KviModuleExtensionDescriptor * d,KviFrame * lpFrm);
+ ~KviSharedFilesWindow();
+protected:
+ QSplitter * m_pVertSplitter;
+
+ KviTalListView * m_pListView;
+
+ QPushButton * m_pRemoveButton;
+ QPushButton * m_pEditButton;
+ QPushButton * m_pAddButton;
+public: // Methods
+ virtual void die();
+protected:
+ virtual QPixmap * myIconPtr();
+ virtual void fillCaptionBuffers();
+ virtual void resizeEvent(QResizeEvent *e);
+ virtual void getBaseLogFileName(KviStr &buffer);
+public:
+ virtual QSize sizeHint() const;
+protected slots:
+ void fillFileView();
+ void sharedFileAdded(KviSharedFile * f);
+ void sharedFileRemoved(KviSharedFile * f);
+ void enableButtons();
+ void removeClicked();
+ void addClicked();
+ void editClicked();
+};
+
+#endif //_SHAREDFILESWINDOW_H_