summaryrefslogtreecommitdiffstats
path: root/plugin
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:55:11 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-03-01 18:55:11 +0000
commit854bf52eebd2da47ff45f6ae85f4cb89bae89876 (patch)
tree24fa0a7eabb9c300a1655d665f72327fe5ab3464 /plugin
downloadsmb4k-854bf52eebd2da47ff45f6ae85f4cb89bae89876.tar.gz
smb4k-854bf52eebd2da47ff45f6ae85f4cb89bae89876.zip
Added old KDE3 version of SMB4K
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/smb4k@1097609 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'plugin')
-rw-r--r--plugin/Makefile.am13
-rw-r--r--plugin/smb4k_add.desktop74
-rw-r--r--plugin/smb4k_konqplugin.cpp236
-rw-r--r--plugin/smb4k_konqplugin.h136
4 files changed, 459 insertions, 0 deletions
diff --git a/plugin/Makefile.am b/plugin/Makefile.am
new file mode 100644
index 0000000..db77a81
--- /dev/null
+++ b/plugin/Makefile.am
@@ -0,0 +1,13 @@
+INCLUDES = $(all_includes)
+METASOURCES = AUTO
+kde_module_LTLIBRARIES = konqsidebar_smb4k.la
+konqsidebar_smb4k_la_SOURCES = smb4k_konqplugin.cpp
+konqsidebar_smb4k_la_LDFLAGS = -module $(all_libraries) \
+ -L$(top_builddir)/smb4k/core -L$(topbuild_dir)/smb4k/widgets -lkonqsidebarplugin
+konqsidebar_smb4k_la_LIBADD = $(top_builddir)/smb4k/core/libsmb4kcore.la \
+ $(KDE_PLUGIN) $(LIB_KFILE) $(LIB_KPARTS) $(LIB_QT) $(LIB_KDECORE) \
+ $(LIB_KDEUI)
+
+globaladddir = $(kde_datadir)/konqsidebartng/add
+globaladd_DATA = smb4k_add.desktop
+noinst_HEADERS = smb4k_konqplugin.h
diff --git a/plugin/smb4k_add.desktop b/plugin/smb4k_add.desktop
new file mode 100644
index 0000000..b6af026
--- /dev/null
+++ b/plugin/smb4k_add.desktop
@@ -0,0 +1,74 @@
+# KDE Config File
+[Desktop Entry]
+Name=Samba Browser
+Icon=smb4k
+Type=Application
+GenericName=The SMB/CIFS Share Browser
+GenericName[bg]=Самба ресурсен четец
+GenericName[ca]=El navegador de compartits SMB/CIFS
+GenericName[cs]=Prohližeč SMB/CIFS sdílení
+GenericName[de]=Der Browser für SMB/CIFS-Freigaben
+GenericName[es]=El explorador de recursos compartidos SMB/CIFS
+GenericName[fr]=L'explorateur de partages SMB / CIFS
+GenericName[hu]=Az SMB/CIFS böngésző
+GenericName[it]=Browser di condivisioni SMB/CIFS
+GenericName[ja]=SMB/CIFS 共有(シェア)・ブラウザー
+GenericName[nl]=De SMB/CIFS Share Browser
+GenericName[no]=SMB/CIFS ressurs utforsker
+GenericName[no_NY]=SMB/CIFS ressurs surfar
+GenericName[pl]=Przeglądarka Zasobów SMB/CIFS
+GenericName[pt_BR]=O navegador de compartilhamentos SMB/CIFS
+GenericName[ru]=The SMB/CIFS Share Browser
+GenericName[sk]=Prehliadač SMB/CIFS zdieľaní
+GenericName[sv]=SMB Katalog programmed
+GenericName[tr]=SMB/CIFS Paylaşım Tarayıcısı
+GenericName[uk]=Навігатор спільних ресурсів SMB/CIFS
+GenericName[zh_CN]=SMB 共享浏览器"
+#
+# The following lines seem to be necessary for SuSE.
+#
+Name[bg]=Samba Browser
+Name[ca]=Samba Browser
+Name[cs]=Samba Browser
+Name[de]=Samba Browser
+Name[es]=Samba Browser
+Name[fr]=Samba Browser
+Name[hu]=Samba Browser
+Name[it]=Samba Browser
+Name[ja]=Samba Browser
+Name[nl]=Samba Browser
+Name[no]=Samba Browser
+Name[no_NY]=Samba Browser
+Name[pl]=Samba Browser
+Name[pt_BR]=Samba Browser
+Name[ru]=Samba Browser
+Name[sk]=Samba Browser
+Name[sv]=Samba Browser
+Name[tr]=Samba Tarayıcısı
+Name[uk]=Samba Browser
+Name[zh_CN]=Samba Browser
+Comment=The SMB/CIFS Share Browser
+Comment[bg]=Самба ресурсен четец
+Comment[ca]=El navegador de compartits SMB/CIFS
+Comment[cs]=Prohližeč SMB/CIFS sdílení
+Comment[de]=Der Browser für SMB/CIFS-Freigaben
+Comment[es]=El explorador de recursos compartidos SMB/CIFS
+Comment[fr]=L'explorateur de partages SMB / CIFS
+Comment[hu]=Az SMB/CIFS böngésző
+Comment[it]=Browser di condivisioni SMB/CIFS
+Comment[ja]=SMB/CIFS 共有(シェア)・ブラウザー
+Comment[nl]=De SMB/CIFS Share Browser
+Comment[no]=SMB/CIFS ressurs utforsker
+Comment[no_NY]=SMB/CIFS ressurs surfar
+Comment[pl]=Przeglądarka Zasobów SMB/CIFS
+Comment[pt_BR]=O navegador de compartilhamentos SMB/CIFS
+Comment[ru]=The SMB/CIFS Share Browser
+Comment[sk]=Prehliadač SMB/CIFS zdieľaní
+Comment[sv]=SMB Katalog programmed
+Comment[tr]=SMB/CIFS Paylaşım Tarayıcısı
+Comment[uk]=Навігатор спільних ресурсів SMB/CIFS
+Comment[zh_CN]=SMB 共享浏览器"
+
+X-Open=false
+X-KDE-KonqSidebarAddModule=konqsidebar_smb4k
+X-KDE-KonqSidebarUniversal=true
diff --git a/plugin/smb4k_konqplugin.cpp b/plugin/smb4k_konqplugin.cpp
new file mode 100644
index 0000000..3cab7fa
--- /dev/null
+++ b/plugin/smb4k_konqplugin.cpp
@@ -0,0 +1,236 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Massimo Callegari *
+ * massimocallegari@yahoo.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+// Qt includes
+#include <qapplication.h>
+#include <qlabel.h>
+#include <qtooltip.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qlayout.h>
+#include <qpainter.h>
+#include <qheader.h>
+#include <qvaluelist.h>
+#include <qpixmap.h>
+#include <qtoolbutton.h>
+#include <qtoolbar.h>
+#include <qdir.h>
+#include <qpushbutton.h>
+
+// KDE includes
+#include <klibloader.h>
+#include <kinstance.h>
+#include <klocale.h>
+#include <kiconloader.h>
+#include <kmessagebox.h>
+#include <kdialogbase.h>
+#include <kcombobox.h>
+#include <ktoolbarbutton.h>
+#include <kaction.h>
+#include <kactionclasses.h>
+#include <kconfigdialog.h>
+
+// plugin specific includes
+// #include "smb4k_konqplugin.moc"
+#include "smb4k_konqplugin.h"
+#include "../smb4k/core/smb4kcore.h"
+#include "../smb4k/core/smb4kdefs.h"
+
+smb4kWidget::smb4kWidget( QWidget * parent, const char * name, WFlags f )
+ : QVBox(parent, name, f)
+{
+ // Nothing exciting to do !
+}
+
+KonqSidebar_Smb4K::KonqSidebar_Smb4K(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name):
+ KonqSidebarPlugin(inst,parent,widgetParent,desktopName,name)
+{
+
+ widget = new smb4kWidget( widgetParent );
+
+ KToolBar *topBar = new KToolBar( widget, "Topbar" );
+ topBar->setIconSize(16);
+ topBar->insertButton( "reload", 0, SIGNAL( clicked() ), this, SLOT( slotRescan() ) , TRUE, i18n( "Scan Network" ) );
+ topBar->insertButton( "find", 1, SIGNAL( clicked() ), this, SLOT( slotSearch() ) , TRUE, i18n( "Search" ) );
+ topBar->insertButton( "configure", 2, SIGNAL( clicked() ), this, SLOT( slotSmb4KOptionsDlg() ) , TRUE, i18n( "Configure" ) );
+
+ //
+ // Browser widget:
+ //
+ KLibFactory *browser_factory = KLibLoader::self()->factory( "libsmb4knetworkbrowser" );
+
+ if ( browser_factory )
+ {
+ m_browser_part = static_cast<KParts::Part *>( browser_factory->create( widget, "BrowserPart", "KParts::Part", QStringList( "konqplugin=\"true\"" ) ) );
+
+ // Do nothing here. The network scan (and the mounting of recently used
+ // shares) will be done by Smb4KCore::init() below.
+ }
+ else
+ {
+ KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
+
+ return;
+ }
+
+ connect( Smb4KCore::mounter(), SIGNAL( mountedShare( const QString &) ), this, SLOT( slotMountedShare( const QString & ) ) );
+ connect( Smb4KCore::mounter(), SIGNAL( aboutToUnmount( const QString& ) ), this, SLOT( slotPrepareUnmount( const QString& ) ) );
+
+ // Scan the network and remount recently used shares:
+ Smb4KCore::self()->init();
+
+}
+
+
+KonqSidebar_Smb4K::~KonqSidebar_Smb4K()
+{
+
+}
+
+extern "C"
+{
+ void* create_konqsidebar_smb4k(KInstance *instance,QObject *par,QWidget *widp,QString &desktopname,const char *name)
+ {
+ KGlobal::locale()->insertCatalogue("smb4k");
+ return new KonqSidebar_Smb4K(instance,par,widp,desktopname,name);
+ }
+};
+
+extern "C"
+{
+ bool add_konqsidebar_smb4k(QString* fn, QString* /*param*/, QMap<QString,QString> *map)
+ {
+ map->insert("Type","Link");
+ map->insert("Icon","smb4k");
+ map->insert("Name",i18n("Samba Browser"));
+ map->insert("Open","false");
+ map->insert("X-KDE-KonqSidebarModule","konqsidebar_smb4k");
+ fn->setLatin1("smb4k%1.desktop");
+ return true;
+ }
+}
+
+void KonqSidebar_Smb4K::handleURL(const KURL &url)
+{
+ currentKonquerorURL = url.path();
+ //kdDebug() << "KonqSidebar_Smb4K::handleURL - "<< currentKonquerorURL << endl;
+}
+
+void KonqSidebar_Smb4K::slotRescan()
+{
+ // Send a custom rescan event to the browser part.
+ QApplication::postEvent( m_browser_part, new QCustomEvent( EVENT_SCAN_NETWORK ) );
+}
+
+void KonqSidebar_Smb4K::slotSearch()
+{
+ // Load the factory of the config dialog:
+ KLibFactory *search_factory = KLibLoader::self()->factory( "libsmb4ksearchdialog" );
+
+ if ( search_factory )
+ {
+ KDialogBase *searchDialog = new KDialogBase( KDialogBase::Plain, i18n( "Search Dialog" ), KDialogBase::Close,
+ KDialogBase::NoDefault, widget, "sd", true, true );
+
+ QFrame *frame = searchDialog->plainPage();
+
+ m_search_part = static_cast<KParts::Part *>( search_factory->create( frame, "SearchDialogPart", "KParts::Part" ) );
+
+ if ( m_search_part )
+ {
+ QGridLayout *layout = new QGridLayout( frame );
+ layout->setSpacing( 10 );
+ layout->setMargin( 0 );
+ layout->addWidget ( m_search_part->widget(), 0, 0, 0 );
+ searchDialog->resize(400,300);
+ // We do not want the dialog to be closed if the user presses return.
+ // Instead we want that a search is started:
+ searchDialog->actionButton( KDialogBase::Close )->setAutoDefault( false );
+
+ //connect( m_search_dialog, SIGNAL( searchResult( Smb4KHostItem * ) ), this, SLOT( slotInsertItem( Smb4KHostItem * ) ) );
+
+ searchDialog->show();
+ }
+ else
+ {
+ delete searchDialog;
+ }
+ }
+ else
+ {
+ KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
+
+ return;
+ }
+}
+
+void KonqSidebar_Smb4K::slotSmb4KOptionsDlg()
+{
+ // Load the factory of the config dialog:
+ KLibFactory *config_factory = KLibLoader::self()->factory( "libsmb4kconfigdialog" );
+
+ if ( config_factory )
+ {
+ KConfigDialog *dlg = static_cast<KConfigDialog *>( config_factory->create( widget, "ConfigDialog", "KConfigDialog" ) );
+
+ if ( dlg )
+ {
+ connect( dlg, SIGNAL( settingsChanged() ), this, SLOT( slotSettingsChanged() ) );
+
+ dlg->show();
+ }
+ }
+ else
+ {
+ KMessageBox::error( 0, "<qt>"+KLibLoader::self()->lastErrorMessage()+"</qt>" );
+
+ return;
+ }
+
+}
+
+void KonqSidebar_Smb4K::slotSettingsChanged()
+{
+ QApplication::postEvent( m_browser_part, new QCustomEvent( EVENT_LOAD_SETTINGS ) );
+}
+
+void KonqSidebar_Smb4K::slotMountedShare( const QString &mountedShare )
+{
+ emit openURLRequest( KURL(mountedShare) );
+}
+
+void KonqSidebar_Smb4K::slotPrepareUnmount( const QString &mountpoint )
+{
+ if ( QString::compare( currentKonquerorURL, mountpoint ) == 0 )
+ {
+ emit openURLRequest( KURL( QDir::home().canonicalPath() ) );
+ }
+ else
+ {
+ // Nothing to do
+ }
+}
+
+#include "smb4k_konqplugin.moc"
+
+
+
+
+
diff --git a/plugin/smb4k_konqplugin.h b/plugin/smb4k_konqplugin.h
new file mode 100644
index 0000000..7f57324
--- /dev/null
+++ b/plugin/smb4k_konqplugin.h
@@ -0,0 +1,136 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Massimo Callegari *
+ * massimo.callegari@telsey.it *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef SAMBROWSER_H
+#define SAMBROWSER_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <konqsidebarplugin.h>
+#include <qstring.h>
+#include <qwidget.h>
+#include <qvbox.h>
+#include <qwidgetstack.h>
+#include <kpopupmenu.h>
+#include <ktoolbar.h>
+#include <khtml_part.h>
+// KDE includes
+#include <kaction.h>
+#include <kparts/dockmainwindow.h>
+#include <kparts/part.h>
+#include <kparts/factory.h>
+
+
+class smb4kWidget : public QVBox
+{
+Q_OBJECT
+public:
+ smb4kWidget( QWidget * parent = 0, const char * name = 0, WFlags f = 0 );
+
+private:
+
+};
+
+class KonqSidebar_Smb4K : public KonqSidebarPlugin
+{
+ Q_OBJECT
+public:
+ /**
+ * Construct a @ref KonqSidebarPlugin.
+ *
+ * @param inst The sidebar's kinstance class.
+ * @param parent The sidebar internal button info class responsible for this plugin.
+ * @param widgetParent The container which will contain the plugins widget.
+ * @param desktopName The filename of the configuration file.
+ * @param name A Qt object name for your plugin.
+ **/
+ KonqSidebar_Smb4K(KInstance *inst,QObject *parent,QWidget *widgetParent, QString &desktopName, const char* name=0);
+
+ /** destructor */
+ ~KonqSidebar_Smb4K();
+
+ KHTMLPart* m_part;
+ virtual QWidget *getWidget(){ return (QWidget*)widget;}
+ virtual void *provides(const QString &) {return 0;}
+ void emitStatusBarText (const QString &) {;}
+
+private:
+ /**
+ * The browser part
+ */
+ KParts::Part *m_browser_part;
+
+ /**
+ * The search dialog part
+ */
+ KParts::Part *m_search_part;
+
+protected:
+ /**
+ * The main plugin widget. Contains a klistview and a ktoolbox objects
+ */
+ smb4kWidget *widget;
+
+ QString currentKonquerorURL;
+
+
+ virtual void handleURL(const KURL &url);
+protected slots:
+ /**
+ * This slot initializes a rescan of the network neighborhood.
+ */
+ void slotRescan();
+ /**
+ * This slot is connected to the clicked() signal of the topBar search button
+ * It brings up the "Search" dialog.
+ */
+ void slotSearch();
+ /**
+ * Opens the configuration dialog.
+ */
+ void slotSmb4KOptionsDlg();
+ /**
+ * This slot is invoked when the config dialog is closed and the settings have
+ * been changed. Emits the reloadSettings() signal and adjusts the system tray
+ * widget to the new settings afterwards.
+ */
+ void slotSettingsChanged();
+ /**
+ * Called from mounter when a share is mounted
+ */
+ void slotMountedShare( const QString & );
+ /**
+ * Called from the mounter just before a share is unmounted. This slot
+ * changes the URL to the user's home so that we can unmount the share
+ * without problems.
+ *
+ * @param mountpoint The mount point of the share that's going to
+ * be unmounted.
+ */
+ void slotPrepareUnmount( const QString &mounpoint );
+ signals:
+ // see <konqsidebarplugin.h>
+ void openURLRequest(const KURL &url,
+ const KParts::URLArgs &args = KParts::URLArgs());
+};
+
+#endif