summaryrefslogtreecommitdiffstats
path: root/kcontrol/samba
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit4aed2c8219774f5d797760606b8489a92ddc5163 (patch)
tree3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/samba
downloadtdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz
tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kcontrol/samba')
-rw-r--r--kcontrol/samba/AUTHORS32
-rw-r--r--kcontrol/samba/Makefile.am15
-rw-r--r--kcontrol/samba/kcmsambaimports.cpp95
-rw-r--r--kcontrol/samba/kcmsambaimports.h47
-rw-r--r--kcontrol/samba/kcmsambalog.cpp253
-rw-r--r--kcontrol/samba/kcmsambalog.h86
-rw-r--r--kcontrol/samba/kcmsambastatistics.cpp289
-rw-r--r--kcontrol/samba/kcmsambastatistics.h106
-rw-r--r--kcontrol/samba/ksmbstatus.cpp225
-rw-r--r--kcontrol/samba/ksmbstatus.h65
-rw-r--r--kcontrol/samba/main.cpp119
-rw-r--r--kcontrol/samba/smbstatus.desktop241
12 files changed, 1573 insertions, 0 deletions
diff --git a/kcontrol/samba/AUTHORS b/kcontrol/samba/AUTHORS
new file mode 100644
index 000000000..0bebeaa06
--- /dev/null
+++ b/kcontrol/samba/AUTHORS
@@ -0,0 +1,32 @@
+Samba Status Module:
+
+ Michael Glauche <glauche@isa.rwth-aachen.de>
+
+Conversion to kcontrol applet:
+
+ Matthias Hoelzer <hoelzer@physik.uni-wuerzburg.de>
+
+Use of KProcess instead of popen, and more error checking
+
+ David Faure <David.Faure@insa-lyon.fr>
+
+Added Window and Column resizing:
+
+ Harald Koschinski <Harald.Koschinski@arcormail.de>
+
+KTabListBox to QListView conversion and use of QLayout:
+
+ Wilco Greven <j.w.greven@student.utwente.nl>
+
+Conversion to KDE2 kcontrol module
+Corrected parsing of the smbstatus output
+ (now works also with shares containing spaces "a share name")
+Added three tab pages
+-one for viewing mounted network resources (Samba and NFS, works on Linux, maybe Solaris)
+-one for viewing samba logfile
+-one for some filtering of samba logfile
+Added support for viewing NFS-exports mounted by remote hosts on the first
+tab
+
+ Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
+
diff --git a/kcontrol/samba/Makefile.am b/kcontrol/samba/Makefile.am
new file mode 100644
index 000000000..42c3f6618
--- /dev/null
+++ b/kcontrol/samba/Makefile.am
@@ -0,0 +1,15 @@
+kde_module_LTLIBRARIES = kcm_samba.la
+
+kcm_samba_la_SOURCES = main.cpp ksmbstatus.cpp kcmsambaimports.cpp kcmsambalog.cpp kcmsambastatistics.cpp
+
+kcm_samba_la_LDFLAGS = $(all_libraries) -module -avoid-version -no-undefined
+kcm_samba_la_LIBADD = $(LIB_KIO)
+
+AM_CPPFLAGS = $(all_includes)
+
+METASOURCES = AUTO
+
+messages:
+ $(XGETTEXT) $(kcm_samba_la_SOURCES) -o $(podir)/kcmsamba.pot
+
+xdg_apps_DATA = smbstatus.desktop
diff --git a/kcontrol/samba/kcmsambaimports.cpp b/kcontrol/samba/kcmsambaimports.cpp
new file mode 100644
index 000000000..a88e2448f
--- /dev/null
+++ b/kcontrol/samba/kcmsambaimports.cpp
@@ -0,0 +1,95 @@
+/*
+ * kcmsambaimports.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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.
+ */
+#include "kcmsambaimports.h"
+#include "kcmsambaimports.moc"
+
+#include <qlayout.h>
+#include <qwhatsthis.h>
+
+#include <klocale.h>
+#include <kdialog.h>
+
+#include <stdio.h>
+
+ImportsView::ImportsView(QWidget * parent, KConfig *config, const char * name )
+ : QWidget (parent, name)
+ ,configFile(config)
+ ,list(this)
+{
+ QBoxLayout *topLayout = new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ topLayout->setAutoAdd(true);
+
+ list.setAllColumnsShowFocus(true);
+ list.setShowSortIndicator(true);
+ list.setMinimumSize(425,200);
+ list.addColumn(i18n("Type"), 50);
+ list.addColumn(i18n("Resource"), 200);
+ list.addColumn(i18n("Mounted Under"), 190);
+
+ QWhatsThis::add( this, i18n("This list shows the Samba and NFS shared"
+ " resources mounted on your system from other hosts. The \"Type\""
+ " column tells you whether the mounted resource is a Samba or an NFS"
+ " type of resource. The \"Resource\" column shows the descriptive name"
+ " of the shared resource. Finally, the third column, which is labeled"
+ " \"Mounted under\" shows the location on your system where the shared"
+ " resource is mounted.") );
+
+ timer.start(10000);
+ QObject::connect(&timer, SIGNAL(timeout()), this, SLOT(updateList()));
+ updateList();
+}
+
+void ImportsView::updateList()
+{
+ list.clear();
+ char *e;
+ char buf[250];
+ QCString s(""),strSource, strMount, strType;
+ FILE *f=popen("mount","r");
+ if (f==0) return;
+ do
+ {
+ e=fgets(buf,250,f);
+ if (e!=0)
+ {
+ s=buf;
+ if ((s.contains(" nfs ")) || (s.contains(" smbfs ")))
+ {
+ strSource=s.left(s.find(" on /"));
+ strMount=s.mid(s.find(" on /")+4,s.length());
+ if ((s.contains(" nfs ")) || (s.contains("/remote on ")))
+ strType="NFS";
+ else if (s.contains(" smbfs "))
+ strType="SMB";
+ int pos(strMount.find(" type "));
+ if (pos==-1) pos=strMount.find(" read/");
+ strMount=strMount.left(pos);
+ new QListViewItem(&list,strType,strSource,strMount);
+ };
+ };
+ }
+ while (!feof(f));
+ pclose(f);
+}
+
diff --git a/kcontrol/samba/kcmsambaimports.h b/kcontrol/samba/kcmsambaimports.h
new file mode 100644
index 000000000..5cd1c5e92
--- /dev/null
+++ b/kcontrol/samba/kcmsambaimports.h
@@ -0,0 +1,47 @@
+/*
+ * kcmsambaimports.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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 kcmsambaimports_h_included
+#define kcmsambaimports_h_included
+
+#include <qtimer.h>
+#include <qlistview.h>
+#include <kconfig.h>
+
+class ImportsView: public QWidget
+{
+ Q_OBJECT
+ public:
+ ImportsView(QWidget *parent, KConfig *config=0, const char * name=0);
+ virtual ~ImportsView() {};
+ void saveSettings() {};
+ void loadSettings() {};
+private:
+ KConfig *configFile;
+ QListView list;
+ QTimer timer;
+private slots:
+ void updateList();
+};
+
+#endif // main_included
diff --git a/kcontrol/samba/kcmsambalog.cpp b/kcontrol/samba/kcmsambalog.cpp
new file mode 100644
index 000000000..c4f01b464
--- /dev/null
+++ b/kcontrol/samba/kcmsambalog.cpp
@@ -0,0 +1,253 @@
+/*
+ * kcmsambalog.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <neundorf@kde.org>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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.
+ */
+
+#include <qfile.h>
+#include <qlayout.h>
+#include <qwhatsthis.h>
+
+#include <kmessagebox.h>
+#include <kdialog.h>
+#include <klocale.h>
+
+#include "kcmsambalog.h"
+#include "kcmsambalog.moc"
+
+#define LOG_SCREEN_XY_OFFSET 10
+
+LogView::LogView(QWidget *parent,KConfig *config, const char *name)
+: QWidget (parent, name)
+,configFile(config)
+,filesCount(0)
+,connectionsCount(0)
+,logFileName("/var/log/samba.log",this)
+,label(&logFileName,i18n("Samba log file: "),this)
+,viewHistory(this)
+,showConnOpen(i18n("Show opened connections"),this)
+,showConnClose(i18n("Show closed connections"),this)
+,showFileOpen(i18n("Show opened files"),this)
+,showFileClose(i18n("Show closed files"),this)
+,updateButton(i18n("&Update"),this)
+{
+ QVBoxLayout *mainLayout=new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ QHBoxLayout *leLayout=new QHBoxLayout(mainLayout);
+ leLayout->addWidget(&label);
+ leLayout->addWidget(&logFileName,1);
+ mainLayout->addWidget(&viewHistory,1);
+ QGridLayout *subLayout=new QGridLayout(mainLayout,2,2);
+ subLayout->addWidget(&showConnOpen,0,0);
+ subLayout->addWidget(&showConnClose,1,0);
+ subLayout->addWidget(&showFileOpen,0,1);
+ subLayout->addWidget(&showFileClose,1,1);
+ mainLayout->addWidget(&updateButton,0,Qt::AlignLeft);
+
+ QWhatsThis::add( &logFileName, i18n("This page presents the contents of"
+ " your samba log file in a friendly layout. Check that the correct log"
+ " file for your computer is listed here. If you need to, correct the name"
+ " or location of the log file, and then click the \"Update\" button.") );
+
+ QWhatsThis::add( &showConnOpen, i18n("Check this option if you want to"
+ " view the details for connections opened to your computer.") );
+
+ QWhatsThis::add( &showConnClose, i18n("Check this option if you want to"
+ " view the events when connections to your computer were closed.") );
+
+ QWhatsThis::add( &showFileOpen, i18n("Check this option if you want to"
+ " see the files which were opened on your computer by remote users."
+ " Note that file open/close events are not logged unless the samba"
+ " log level is set to at least 2 (you cannot set the log level"
+ " using this module).") );
+
+ QWhatsThis::add( &showFileClose, i18n("Check this option if you want to"
+ " see the events when files opened by remote users were closed."
+ " Note that file open/close events are not logged unless the samba"
+ " log level is set to at least 2 (you cannot set the log level"
+ " using this module).") );
+
+ QWhatsThis::add( &updateButton, i18n("Click here to refresh the information"
+ " on this page. The log file (shown above) will be read to obtain the"
+ " events logged by samba.") );
+
+ logFileName.setURL("/var/log/samba.log");
+
+ viewHistory.setAllColumnsShowFocus(TRUE);
+ viewHistory.setFocusPolicy(QWidget::ClickFocus);
+ viewHistory.setShowSortIndicator(true);
+
+ viewHistory.addColumn(i18n("Date & Time"),130);
+ viewHistory.addColumn(i18n("Event"),150);
+ viewHistory.addColumn(i18n("Service/File"),210);
+ viewHistory.addColumn(i18n("Host/User"),150);
+
+ QWhatsThis::add( &viewHistory, i18n("This list shows details of the events"
+ " logged by samba. Note that events at the file level are not logged"
+ " unless you have configured the log level for samba to 2 or greater.<p>"
+ " As with many other lists in KDE, you can click on a column heading"
+ " to sort on that column. Click again to change the sorting direction"
+ " from ascending to descending or vice versa.<p>"
+ " If the list is empty, try clicking the \"Update\" button. The samba"
+ " log file will be read and the list refreshed.") );
+
+ showConnOpen.setChecked(TRUE);
+ showConnClose.setChecked(TRUE);
+ showFileOpen.setChecked(FALSE);
+ showFileClose.setChecked(FALSE);
+
+ connect(&updateButton,SIGNAL(clicked()),this,SLOT(updateList()));
+ emit contentsChanged(&viewHistory,0,0);
+
+ label.setMinimumSize(label.sizeHint());
+ logFileName.setMinimumSize(250,logFileName.sizeHint().height());
+ viewHistory.setMinimumSize(425,200);
+ showConnOpen.setMinimumSize(showConnOpen.sizeHint());
+ showConnClose.setMinimumSize(showConnClose.sizeHint());
+ showFileOpen.setMinimumSize(showFileOpen.sizeHint());
+ showFileClose.setMinimumSize(showFileClose.sizeHint());
+ updateButton.setFixedSize(updateButton.sizeHint());
+}
+
+void LogView::loadSettings()
+{
+ if (configFile==0) return;
+ configFile->setGroup(LOGGROUPNAME);
+ logFileName.setURL(configFile->readPathEntry( "SambaLogFile", "/var/log/samba.log"));
+
+ showConnOpen.setChecked(configFile->readBoolEntry( "ShowConnectionOpen", TRUE));
+ showConnClose.setChecked(configFile->readBoolEntry( "ShowConnectionClose", FALSE));
+ showFileOpen.setChecked(configFile->readBoolEntry( "ShowFileOpen", TRUE));
+ showFileClose.setChecked(configFile->readBoolEntry( "ShowFileClose", FALSE));
+}
+
+void LogView::saveSettings()
+{
+ if (configFile==0) return;
+ configFile->setGroup(LOGGROUPNAME);
+ configFile->writePathEntry( "SambaLogFile", logFileName.url());
+
+ configFile->writeEntry( "ShowConnectionOpen", showConnOpen.isChecked());
+ configFile->writeEntry( "ShowConnectionClose", showConnClose.isChecked());
+ configFile->writeEntry( "ShowFileOpen", showFileOpen.isChecked());
+ configFile->writeEntry( "ShowFileClose", showFileClose.isChecked());
+}
+
+#define CONN_OPEN " connect to service "
+#define CONN_CLOSE " closed connection to service "
+#define FILE_OPEN " opened file "
+#define FILE_CLOSE " closed file "
+
+//caution ! high optimized code :-)
+void LogView::updateList()
+{
+ QFile logFile(logFileName.url());
+ if (logFile.open(IO_ReadOnly))
+ {
+ QApplication::setOverrideCursor(waitCursor);
+ viewHistory.clear();
+ filesCount=0;
+ connectionsCount=0;
+
+ int connOpenLen(strlen(CONN_OPEN));
+ int connCloseLen(strlen(CONN_CLOSE));
+ int fileOpenLen(strlen(FILE_OPEN));
+ int fileCloseLen(strlen(FILE_CLOSE));
+
+ char buf[400];
+ char *c1, *c2, *c3, *c4, *c, time[25];
+ int timeRead(0);
+
+ while (!logFile.atEnd())
+ {
+ logFile.readLine(buf,sizeof(buf));
+ timeRead=0;
+ if (buf[0]=='[')
+ {
+ if (strlen(buf)>11)
+ if (buf[5]=='/')
+ {
+ buf[20]='\0';
+ strncpy(time,buf+1, sizeof(time));
+ time[sizeof(time)-1] = '\0';
+ timeRead=1;
+ };
+ };
+ if (timeRead==0)
+ {
+ c1=0;
+ c2=0;
+ c3=0;
+ c4=0;
+ if (showConnOpen.isChecked()) c1=strstr(buf,CONN_OPEN);
+ if (c1==0)
+ {
+ if (showConnClose.isChecked()) c2=strstr(buf,CONN_CLOSE);
+ if (c2==0)
+ {
+ if (showFileOpen.isChecked()) c3=strstr(buf,FILE_OPEN);
+ if (c3==0)
+ {
+ if (showFileClose.isChecked()) c4=strstr(buf,FILE_CLOSE);
+ if (c4==0) continue;
+ };
+ };
+ };
+ if (c1!=0)
+ {
+ c=strstr(buf," as user");
+ *c='\0';
+ *c1='\0';
+ new QListViewItemX(&viewHistory,time,I18N_NOOP("CONNECTION OPENED"),c1+connOpenLen,buf+2);
+ connectionsCount++;
+ }
+ else if (c2!=0)
+ {
+ *c2='\0';
+ new QListViewItemX(&viewHistory,time,I18N_NOOP("CONNECTION CLOSED"),c2+connCloseLen,buf+2);
+ }
+ else if (c3!=0)
+ {
+ c=strstr(buf," read=");
+ *c='\0';
+ *c3='\0';
+ new QListViewItemX(&viewHistory,time,I18N_NOOP(" FILE OPENED"),c3+fileOpenLen,buf+2);
+ filesCount++;
+ }
+ else if (c4!=0)
+ {
+ c=strstr(buf," (numopen=");
+ *c='\0';
+ *c4='\0';
+ new QListViewItemX(&viewHistory,time,I18N_NOOP(" FILE CLOSED"),c4+fileCloseLen,buf+2);
+ };
+ };
+ };
+ logFile.close();
+ emit contentsChanged(&viewHistory, filesCount, connectionsCount);
+ QApplication::restoreOverrideCursor();
+ }
+ else
+ {
+ QString tmp = i18n("Could not open file %1").arg(logFileName.url());
+ KMessageBox::error(this,tmp);
+ };
+}
+
diff --git a/kcontrol/samba/kcmsambalog.h b/kcontrol/samba/kcmsambalog.h
new file mode 100644
index 000000000..03e22f872
--- /dev/null
+++ b/kcontrol/samba/kcmsambalog.h
@@ -0,0 +1,86 @@
+/*
+ * kcmsambalog.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <neundorf@kde.org>
+*
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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 kcmsambalog_h_included
+#define kcmsambalog_h_included
+
+#include <qlabel.h>
+#include <qcstring.h>
+#include <qcheckbox.h>
+#include <qpushbutton.h>
+#include <qlistview.h>
+#include <qevent.h>
+#include <kconfig.h>
+
+#include <kurlrequester.h>
+
+#define LOGGROUPNAME "SambaLogFileSettings"
+
+class LogView: public QWidget
+{
+ Q_OBJECT
+ public:
+ LogView(QWidget *parent=0, KConfig *config=0, const char *name=0);
+ virtual ~LogView() {};
+ void saveSettings();
+ void loadSettings();
+ private:
+ KConfig *configFile;
+ int filesCount, connectionsCount;
+ KURLRequester logFileName;
+ QLabel label;
+ QListView viewHistory;
+ QCheckBox showConnOpen, showConnClose, showFileOpen, showFileClose;
+ QPushButton updateButton;
+ private slots:
+ void updateList();
+ signals:
+ void contentsChanged(QListView* list, int nrOfFiles, int nrOfConnections);
+};
+
+class QListViewItemX:public QListViewItem
+{
+ public:
+ //a faster constructor saves a lot time
+ QListViewItemX( QListView * parent,
+ const char *c0, const char *c1 = 0,
+ const char *c2 = 0, const char *c3 = 0,
+ const char *c4 = 0, const char *c5 = 0,
+ const char *c6 = 0, const char *c7 = 0 )
+ :QListViewItem(parent)
+ {
+ setText( 0, c0 );
+ setText( 1, c1 );
+ setText( 2, c2 );
+ setText( 3, c3 );
+ if (c4==0) return;
+ setText( 4, c4 );
+ if (c5==0) return;
+ setText( 5, c5 );
+ if (c6==0) return;
+ setText( 6, c6 );
+ if (c7==0) return;
+ setText( 7, c7 );
+ };
+};
+
+#endif // main_included
diff --git a/kcontrol/samba/kcmsambastatistics.cpp b/kcontrol/samba/kcmsambastatistics.cpp
new file mode 100644
index 000000000..ebdd1c092
--- /dev/null
+++ b/kcontrol/samba/kcmsambastatistics.cpp
@@ -0,0 +1,289 @@
+/*
+ * kcmsambastatistics.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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.
+ */
+#include "kcmsambastatistics.h"
+#include "kcmsambastatistics.moc"
+
+#include <qlayout.h>
+#include <qlistview.h>
+#include <qlabel.h>
+#include <qlineedit.h>
+#include <qcheckbox.h>
+#include <qcombobox.h>
+#include <qpushbutton.h>
+#include <qregexp.h>
+
+#include <kglobal.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kdialog.h>
+
+StatisticsView::StatisticsView(QWidget *parent,KConfig *config, const char *name)
+ :QWidget (parent, name)
+ ,configFile(config)
+ ,dataList(0)
+ ,connectionsCount(0)
+ ,filesCount(0)
+ ,calcCount(0)
+{
+ viewStatistics = new QListView( this );
+ connectionsL = new QLabel( i18n( "Connections: 0" ), this );
+ filesL = new QLabel( i18n( "File accesses: 0" ), this );
+ eventCb = new QComboBox( false, this );
+ eventL = new QLabel( eventCb, i18n( "Event: " ), this );
+ serviceLe = new QLineEdit( this );
+ serviceL = new QLabel( serviceLe, i18n( "Service/File:" ), this );
+ hostLe = new QLineEdit( this );
+ hostL = new QLabel( hostLe, i18n( "Host/User:" ), this );
+ calcButton = new QPushButton( i18n( "&Search" ), this );
+ clearButton = new QPushButton( i18n( "Clear Results" ), this );
+ expandedInfoCb = new QCheckBox( i18n( "Show expanded service info" ), this );
+ expandedUserCb = new QCheckBox( i18n( "Show expanded host info" ), this );
+
+ viewStatistics->setAllColumnsShowFocus(TRUE);
+ viewStatistics->setFocusPolicy(QWidget::ClickFocus);
+ viewStatistics->setShowSortIndicator(true);
+
+ viewStatistics->addColumn(i18n("Nr"),30);
+ viewStatistics->addColumn(i18n("Event"),130);
+ viewStatistics->addColumn(i18n("Service/File"),200);
+ viewStatistics->addColumn(i18n("Host/User"),90);
+ viewStatistics->addColumn(i18n("Hits"),50);
+ //viewStatistics->addColumn(i18n("Percentage"),100);
+
+ eventCb->insertItem(i18n("Connection"));
+ eventCb->insertItem(i18n("File Access"));
+
+ expandedInfoCb->setChecked(FALSE);
+ expandedUserCb->setChecked(FALSE);
+ clearStatistics();
+ serviceLe->setText("*");
+ hostLe->setText("*");
+
+ viewStatistics->setMinimumSize(375,200);
+ connectionsL->setMinimumSize(connectionsL->sizeHint());
+ filesL->setMinimumSize(filesL->sizeHint());
+ eventL->setMinimumSize(eventL->sizeHint());
+ eventCb->setMinimumSize(eventCb->sizeHint());
+ hostL->setMinimumSize(hostL->sizeHint());
+ hostLe->setMinimumSize(120,hostLe->sizeHint().height());
+ serviceL->setMinimumSize(serviceL->sizeHint());
+ serviceLe->setMinimumSize(120,serviceLe->sizeHint().height());
+ calcButton->setMinimumSize(calcButton->sizeHint());
+ clearButton->setMinimumSize(clearButton->sizeHint());
+ expandedInfoCb->setMinimumSize(expandedInfoCb->sizeHint());
+ expandedUserCb->setMinimumSize(expandedUserCb->sizeHint());
+
+ QVBoxLayout *topLayout=new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ topLayout->addWidget(viewStatistics,1);
+ QGridLayout *subLayout=new QGridLayout(topLayout,4,3);
+ subLayout->setColStretch(1,1);
+ subLayout->setColStretch(2,1);
+
+ QHBoxLayout *twoButtonsLayout=new QHBoxLayout;
+ twoButtonsLayout->addWidget(calcButton,1);
+ twoButtonsLayout->addWidget(clearButton,1);
+
+ subLayout->addWidget(connectionsL,0,0);
+ subLayout->addWidget(filesL,0,1);
+ subLayout->addWidget(eventL,1,0);
+ subLayout->addWidget(serviceL,1,1);
+ subLayout->addWidget(hostL,1,2);
+ subLayout->addWidget(eventCb,2,0);
+ subLayout->addWidget(serviceLe,2,1);
+ subLayout->addWidget(hostLe,2,2);
+ subLayout->addLayout(twoButtonsLayout,3,0);
+ subLayout->addWidget(expandedInfoCb,3,1);
+ subLayout->addWidget(expandedUserCb,3,2);
+
+ connect(clearButton,SIGNAL(clicked()),this,SLOT(clearStatistics()));
+ connect(calcButton,SIGNAL(clicked()),this,SLOT(calculate()));
+ setListInfo(0,0,0);
+}
+
+void StatisticsView::setListInfo(QListView *list, int nrOfFiles, int nrOfConnections)
+{
+ dataList=list;
+ filesCount=nrOfFiles;
+ connectionsCount=nrOfConnections;
+ connectionsL->setText(i18n("Connections: %1").arg(KGlobal::locale()->formatNumber(connectionsCount, 0)));
+ filesL->setText(i18n("File accesses: %1").arg(KGlobal::locale()->formatNumber(filesCount, 0)));
+ clearStatistics();
+}
+
+void StatisticsView::calculate()
+{
+ if (dataList==0) return;
+ QApplication::setOverrideCursor(waitCursor);
+ int connCount(0);
+ if (eventCb->currentText()==i18n("Connection"))
+ connCount=1;
+ //something has to be counted exactly
+ if ((expandedInfoCb->isChecked()) || (expandedUserCb->isChecked()))
+ {
+ SambaLog sLog;
+ QRegExp rService(serviceLe->text(),FALSE,TRUE);
+ QRegExp rHost(hostLe->text(),FALSE,TRUE);
+ QString item2, item3;
+ QListViewItem* item=dataList->firstChild();
+ while (item!=0)
+ {
+ if (connCount)
+ {
+ if ((QString(item->text(1)).contains(i18n("CONNECTION OPENED")))
+ && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
+ {
+ if (expandedInfoCb->isChecked()) item2=item->text(2);
+ else item2=serviceLe->text();
+ if (expandedUserCb->isChecked()) item3=item->text(3);
+ else item3=hostLe->text();
+ sLog.addItem(item2,item3);
+ //count++;
+ };
+ }
+ else
+ {
+ if ((QString(item->text(1)).contains(i18n("FILE OPENED")))
+ && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
+ {
+ if (expandedInfoCb->isChecked()) item2=item->text(2);
+ else item2=serviceLe->text();
+ if (expandedUserCb->isChecked()) item3=item->text(3);
+ else item3=hostLe->text();
+ sLog.addItem(item2,item3);
+
+ };
+ };
+ item=item->nextSibling();
+ };
+ for (LogItem* tmpItem=sLog.items.first();tmpItem!=0;tmpItem=sLog.items.next())
+ {
+ for (SmallLogItem *tmpStr=tmpItem->accessed.first();tmpStr!=0;tmpStr=tmpItem->accessed.next())
+ {
+ calcCount++;
+ QString number("");
+ number.sprintf("%6d",calcCount);
+ QString hits("");
+ hits.sprintf("%7d",tmpStr->count);
+ new QListViewItem(viewStatistics,number,eventCb->currentText(),tmpItem->name,tmpStr->name,hits);
+ };
+ };
+ }
+ //no expanded info needed
+ else
+ {
+ calcCount++;
+ int count(0);
+ QRegExp rService(serviceLe->text(),FALSE,TRUE);
+ QRegExp rHost(hostLe->text(),FALSE,TRUE);
+ QListViewItem* item=dataList->firstChild();
+ while (item!=0)
+ {
+ if (connCount)
+ {
+ if ((QString(item->text(1)).contains(i18n("CONNECTION OPENED")))
+ && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
+ count++;
+ }
+ else
+ {
+ if ((QString(item->text(1)).contains(i18n("FILE OPENED")))
+ && (QString(item->text(2)).contains(rService)) && (QString(item->text(3)).contains(rHost)))
+ count++;
+ };
+ item=item->nextSibling();
+ };
+ QString number("");
+ number.sprintf("%6d",calcCount);
+ QString hits("");
+ hits.sprintf("%7d",count);
+ new QListViewItem(viewStatistics,number,eventCb->currentText(),serviceLe->text(),hostLe->text(),hits);
+ };
+ QApplication::restoreOverrideCursor();
+}
+
+void StatisticsView::clearStatistics()
+{
+ viewStatistics->clear();
+ calcCount=0;
+}
+
+void SambaLog::printItems()
+{
+ kdDebug() << "****** printing items: ******" << endl;
+ for (LogItem* tmpItem=items.first();tmpItem!=0;tmpItem=items.next())
+ {
+ kdDebug() << "SERVICE: " << tmpItem->name << endl;
+ for (SmallLogItem* tmpLog=tmpItem->accessed.first();tmpLog!=0;tmpLog=tmpItem->accessed.next())
+ kdDebug() << " accessed by: " << tmpLog->name << " " << tmpLog->count << endl;
+ };
+ kdDebug() << "------ end of printing ------" << endl << endl;
+}
+
+LogItem* SambaLog::itemInList(QString name)
+{
+ LogItem* tmpItem(items.first());
+ LogItem* foundItem(0);
+ while ((tmpItem!=0) && (foundItem==0))
+ {
+ if (tmpItem->name==name) foundItem=tmpItem;
+ tmpItem=items.next();
+ };
+ return foundItem;
+}
+
+void SambaLog::addItem(QString share, QString user)
+{
+ //cout<<" adding connection: -"<<share<<"- -"<<user<<"-"<<endl;
+ LogItem* tmp(itemInList(share));
+ if (tmp!=0)
+ {
+ tmp->count++;
+ tmp->addItem(user);
+ }
+ else
+ {
+ items.append(new LogItem(share,user));
+ };
+}
+
+SmallLogItem* LogItem::itemInList(QString name)
+{
+ SmallLogItem* tmpItem(accessed.first());
+ SmallLogItem* foundItem(0);
+ while ((tmpItem!=0) && (foundItem==0))
+ {
+ if (tmpItem->name==name) foundItem=tmpItem;
+ tmpItem=accessed.next();
+ };
+ return foundItem;
+}
+
+void LogItem::addItem (QString host)
+{
+ SmallLogItem* tmp(itemInList(host));
+ if (tmp!=0)
+ tmp->count++;
+ else
+ accessed.append(new SmallLogItem(host));
+}
diff --git a/kcontrol/samba/kcmsambastatistics.h b/kcontrol/samba/kcmsambastatistics.h
new file mode 100644
index 000000000..66a9474ab
--- /dev/null
+++ b/kcontrol/samba/kcmsambastatistics.h
@@ -0,0 +1,106 @@
+/*
+ * kcmsambastatistics.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <alexander.neundorf@rz.tu-ilmenau.de>
+ *
+ * Requires the Qt widget libraries, available at no cost at
+ * http://www.troll.no/
+ *
+ * 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 kcmsambastatistics_h_included
+#define kcmsambastatistics_h_included
+
+#include <qwidget.h>
+#include <qptrlist.h>
+
+class QListView;
+class QLabel;
+class QComboBox;
+class QCheckBox;
+class QLineEdit;
+class QPushButton;
+
+class KConfig;
+
+class SmallLogItem
+{
+ public:
+ SmallLogItem():name(""),count(0){};
+ SmallLogItem(QString n):name(n),count(1){};
+ QString name;
+ int count;
+};
+
+class LogItem
+{
+ public:
+ LogItem():name(""), accessed(),count(0) {};
+ LogItem(QString n, QString a):name(n), accessed(), count(1)
+ {
+ accessed.setAutoDelete(TRUE);
+ accessed.append(new SmallLogItem(a));
+ };
+ QString name;
+ //QStrList accessedBy;
+ QPtrList<SmallLogItem> accessed;
+ int count;
+ SmallLogItem* itemInList(QString name);
+ void addItem (QString host);
+};
+
+class SambaLog
+{
+ public:
+ SambaLog()
+ {
+ items.setAutoDelete(TRUE);
+ };
+ QPtrList<LogItem> items;
+ void addItem (QString share, QString host);
+ void printItems();
+ private:
+ LogItem* itemInList(QString name);
+};
+
+class StatisticsView: public QWidget
+{
+ Q_OBJECT
+public:
+ StatisticsView(QWidget *parent=0, KConfig *config=0, const char *name=0);
+ virtual ~StatisticsView() {};
+ void saveSettings() {};
+ void loadSettings() {};
+ public slots:
+ void setListInfo(QListView *list, int nrOfFiles, int nrOfConnections);
+private:
+ KConfig *configFile;
+ QListView *dataList;
+ QListView* viewStatistics;
+ QLabel* connectionsL, *filesL;
+ QComboBox* eventCb;
+ QLabel* eventL;
+ QLineEdit* serviceLe;
+ QLabel* serviceL;
+ QLineEdit* hostLe;
+ QLabel* hostL;
+ QPushButton* calcButton, *clearButton;
+ QCheckBox* expandedInfoCb, *expandedUserCb;
+ int connectionsCount, filesCount, calcCount;
+private slots:
+ void clearStatistics();
+ void calculate();
+};
+#endif // main_included
diff --git a/kcontrol/samba/ksmbstatus.cpp b/kcontrol/samba/ksmbstatus.cpp
new file mode 100644
index 000000000..4866a3a1e
--- /dev/null
+++ b/kcontrol/samba/ksmbstatus.cpp
@@ -0,0 +1,225 @@
+/*
+ * ksmbstatus.cpp
+ *
+ * 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.
+ */
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include <qlayout.h>
+
+#include <klocale.h>
+#include <kdialog.h>
+
+#include "ksmbstatus.h"
+#include "ksmbstatus.moc"
+
+
+#define Before(ttf,in) in.left(in.find(ttf))
+#define After(ttf,in) (in.contains(ttf)?QString(in.mid(in.find(ttf)+QString(ttf).length())):QString(""))
+
+NetMon::NetMon( QWidget * parent, KConfig *config, const char * name )
+ : QWidget(parent, name)
+ ,configFile(config)
+ ,showmountProc(0)
+ ,strShare("")
+ ,strUser("")
+ ,strGroup("")
+ ,strMachine("")
+ ,strSince("")
+ ,strPid("")
+ ,iUser(0)
+ ,iGroup(0)
+ ,iMachine(0)
+ ,iPid(0)
+{
+ QBoxLayout *topLayout = new QVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ topLayout->setAutoAdd(true);
+
+ list=new QListView(this,"Hello");
+ version=new QLabel(this);
+
+ list->setAllColumnsShowFocus(true);
+ list->setMinimumSize(425,200);
+ list->setShowSortIndicator(true);
+
+ list->addColumn(i18n("Type"));
+ list->addColumn(i18n("Service"));
+ list->addColumn(i18n("Accessed From"));
+ list->addColumn(i18n("UID"));
+ list->addColumn(i18n("GID"));
+ list->addColumn(i18n("PID"));
+ list->addColumn(i18n("Open Files"));
+
+ timer = new QTimer(this);
+ timer->start(15000);
+ QObject::connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+ update();
+}
+
+void NetMon::processNFSLine(char *bufline, int)
+{
+ QCString line(bufline);
+ if (line.contains(":/"))
+ new QListViewItem(list,"NFS",After(":",line),Before(":/",line));
+}
+
+void NetMon::processSambaLine(char *bufline, int)
+{
+ QCString line(bufline);
+ rownumber++;
+ if (rownumber == 2)
+ version->setText(bufline); // second line = samba version
+ if ((readingpart==header) && line.contains("Service"))
+ {
+ iUser=line.find("uid");
+ iGroup=line.find("gid");
+ iPid=line.find("pid");
+ iMachine=line.find("machine");
+ }
+ else if ((readingpart==header) && (line.contains("---")))
+ {
+ readingpart=connexions;
+ }
+ else if ((readingpart==connexions) && (int(line.length())>=iMachine))
+ {
+ strShare=line.mid(0,iUser);
+ strUser=line.mid(iUser,iGroup-iUser);
+ strGroup=line.mid(iGroup,iPid-iGroup);
+ strPid=line.mid(iPid,iMachine-iPid);
+
+ line=line.mid(iMachine,line.length());
+ strMachine=line;
+ new QListViewItem(list,"SMB",strShare,strMachine, strUser,strGroup,strPid/*,strSince*/);
+ }
+ else if (readingpart==connexions)
+ readingpart=locked_files;
+ else if ((readingpart==locked_files) && (line.find("No ")==0))
+ readingpart=finished;
+ else if (readingpart==locked_files)
+ {
+ if ((strncmp(bufline,"Pi", 2) !=0) // "Pid DenyMode ..."
+ && (strncmp(bufline,"--", 2) !=0)) // "------------"
+ {
+ char *tok=strtok(bufline," ");
+ if (tok) {
+ int pid=atoi(tok);
+ (lo)[pid]++;
+ }
+ }
+ }
+}
+
+// called when we get some data from smbstatus
+// can be called for any size of buffer (one line, several lines,
+// half of one ...)
+void NetMon::slotReceivedData(KProcess *, char *buffer, int )
+{
+ //kdDebug()<<"received stuff"<<endl;
+ char s[250],*start,*end;
+ size_t len;
+ start = buffer;
+ while ((end = strchr(start,'\n'))) // look for '\n'
+ {
+ len = end-start;
+ if (len>=sizeof(s))
+ len=sizeof(s)-1;
+ strncpy(s,start,len);
+ s[len] = '\0';
+ //kdDebug() << "recived: "<<s << endl;
+ if (readingpart==nfs)
+ processNFSLine(s,len);
+ else
+ processSambaLine(s,len); // process each line
+ start=end+1;
+ }
+ if (readingpart==nfs)
+ {
+ list->viewport()->update();
+ list->update();
+ }
+ // here we could save the remaining part of line, if ever buffer
+ // doesn't end with a '\n' ... but will this happen ?
+}
+
+void NetMon::update()
+{
+ KProcess * process = new KProcess();
+
+ memset(&lo, 0, sizeof(lo));
+ list->clear();
+ /* Re-read the Contents ... */
+
+ QString path(::getenv("PATH"));
+ path += "/bin:/sbin:/usr/bin:/usr/sbin";
+
+ rownumber=0;
+ readingpart=header;
+ nrpid=0;
+ process->setEnvironment("PATH", path);
+ connect(process,
+ SIGNAL(receivedStdout(KProcess *, char *, int)),
+ SLOT(slotReceivedData(KProcess *, char *, int)));
+ *process << "smbstatus";
+ if (!process->start(KProcess::Block,KProcess::Stdout))
+ version->setText(i18n("Error: Unable to run smbstatus"));
+ else if (rownumber==0) // empty result
+ version->setText(i18n("Error: Unable to open configuration file \"smb.conf\""));
+ else
+ {
+ // ok -> count the number of locked files for each pid
+ for (QListViewItem *row=list->firstChild();row!=0;row=row->itemBelow())
+ {
+// cerr<<"NetMon::update: this should be the pid: "<<row->text(5)<<endl;
+ int pid=row->text(5).toInt();
+ row->setText(6,QString("%1").arg((lo)[pid]));
+ }
+ }
+ delete process;
+ process=0;
+
+ readingpart=nfs;
+ delete showmountProc;
+ showmountProc=new KProcess();
+ showmountProc->setEnvironment("PATH", path);
+ *showmountProc<<"showmount"<<"-a"<<"localhost";
+ connect(showmountProc,SIGNAL(receivedStdout(KProcess *, char *, int)),SLOT(slotReceivedData(KProcess *, char *, int)));
+ //without this timer showmount hangs up to 5 minutes
+ //if the portmapper daemon isn't running
+ QTimer::singleShot(5000,this,SLOT(killShowmount()));
+ //kdDebug()<<"starting kill timer with 5 seconds"<<endl;
+ connect(showmountProc,SIGNAL(processExited(KProcess*)),this,SLOT(killShowmount()));
+ if (!showmountProc->start(KProcess::NotifyOnExit,KProcess::Stdout)) // run showmount
+ {
+ delete showmountProc;
+ showmountProc=0;
+ }
+
+ version->adjustSize();
+ list->show();
+}
+
+void NetMon::killShowmount()
+{
+ //kdDebug()<<"killShowmount()"<<endl;
+ delete showmountProc;
+ showmountProc=0;
+}
+
diff --git a/kcontrol/samba/ksmbstatus.h b/kcontrol/samba/ksmbstatus.h
new file mode 100644
index 000000000..9d60e30c2
--- /dev/null
+++ b/kcontrol/samba/ksmbstatus.h
@@ -0,0 +1,65 @@
+/*
+ * ksmbstatus.h
+ *
+ *
+ * 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 ksmbstatus_h_included
+#define ksmbstatus_h_included
+
+#include <qtimer.h>
+#include <qlabel.h>
+#include <kprocess.h>
+#include <qcstring.h>
+#include <qlistview.h>
+#include <kconfig.h>
+
+#define SCREEN_XY_OFFSET 20
+
+class QListView;
+class QListViewItem;
+class KProcess;
+
+class NetMon : public QWidget
+{
+Q_OBJECT
+public:
+ NetMon(QWidget *parent, KConfig * config=0, const char * name=0);
+ void saveSettings() {};
+ void loadSettings() {};
+private:
+ KConfig *configFile;
+ KProcess *showmountProc;
+ QListView *list;
+ QLabel *version;
+ QTimer *timer;
+ QListViewItem *killrow;
+ int rownumber;
+ enum {header, connexions, locked_files, finished, nfs} readingpart;
+ int lo[65536];
+ int nrpid;
+ void processNFSLine(char *bufline, int linelen);
+ void processSambaLine(char *bufline, int linelen);
+
+ QCString strShare, strUser, strGroup, strMachine, strSince, strPid;
+ int iUser, iGroup, iMachine, iPid;
+
+private slots:
+ void killShowmount();
+ void update();
+ void slotReceivedData(KProcess *proc, char *buffer, int buflen);
+};
+
+#endif // main_included
diff --git a/kcontrol/samba/main.cpp b/kcontrol/samba/main.cpp
new file mode 100644
index 000000000..f6df8f91b
--- /dev/null
+++ b/kcontrol/samba/main.cpp
@@ -0,0 +1,119 @@
+/*
+ * main.cpp for the samba kcontrol module
+ *
+ * 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.
+ */
+
+#include <qlayout.h>
+#include <qtabwidget.h>
+
+#include <kaboutdata.h>
+#include <kcmodule.h>
+#include <kdialog.h>
+#include <kgenericfactory.h>
+
+#include "kcmsambaimports.h"
+#include "kcmsambalog.h"
+#include "kcmsambastatistics.h"
+#include "ksmbstatus.h"
+
+class SambaContainer:public KCModule
+{
+ public:
+ SambaContainer(QWidget *parent=0, const char * name=0, const QStringList &list = QStringList() );
+ virtual ~SambaContainer();
+ virtual void load();
+ virtual void save();
+
+ private:
+ KConfig config;
+ QTabWidget tabs;
+ NetMon status;
+ ImportsView imports;
+ LogView logView;
+ StatisticsView statisticsView;
+};
+
+typedef KGenericFactory<SambaContainer, QWidget > SambaFactory;
+K_EXPORT_COMPONENT_FACTORY (kcm_samba, SambaFactory("kcmsamba") )
+
+SambaContainer::SambaContainer(QWidget *parent, const char* name, const QStringList&)
+:KCModule(SambaFactory::instance(), parent,name)
+,config("kcmsambarc",false,true)
+,tabs(this)
+,status(&tabs,&config)
+,imports(&tabs,&config)
+,logView(&tabs,&config)
+,statisticsView(&tabs,&config)
+{
+ QVBoxLayout *layout = new QVBoxLayout( this, 0, KDialog::spacingHint() );
+ layout->addWidget(&tabs);
+ tabs.addTab(&status,i18n("&Exports"));
+ tabs.addTab(&imports,i18n("&Imports"));
+ tabs.addTab(&logView,i18n("&Log"));
+ tabs.addTab(&statisticsView,i18n("&Statistics"));
+ connect(&logView,SIGNAL(contentsChanged(QListView* , int, int)),&statisticsView,SLOT(setListInfo(QListView *, int, int)));
+ setButtons(Help);
+ load();
+
+ setQuickHelp( i18n("The Samba and NFS Status Monitor is a front end to the programs"
+ " <em>smbstatus</em> and <em>showmount</em>. Smbstatus reports on current"
+ " Samba connections, and is part of the suite of Samba tools, which"
+ " implements the SMB (Session Message Block) protocol, also called the"
+ " NetBIOS or LanManager protocol. This protocol can be used to provide"
+ " printer sharing or drive sharing services on a network including"
+ " machines running the various flavors of Microsoft Windows.<p>"
+ " Showmount is part of the NFS software package. NFS stands for Network"
+ " File System and is the traditional UNIX way to share directories over"
+ " the network. In this case the output of <em>showmount -a localhost</em>"
+ " is parsed. On some systems showmount is in /usr/sbin, check if you have"
+ " showmount in your PATH."));
+
+ KAboutData *about =
+ new KAboutData(I18N_NOOP("kcmsamba"),
+ I18N_NOOP("KDE Panel System Information Control Module"),
+ 0, 0, KAboutData::License_GPL,
+ I18N_NOOP("(c) 2002 KDE Information Control Module Samba Team"));
+ about->addAuthor("Michael Glauche", 0, "glauche@isa.rwth-aachen.de");
+ about->addAuthor("Matthias Hoelzer", 0, "hoelzer@kde.org");
+ about->addAuthor("David Faure", 0, "faure@kde.org");
+ about->addAuthor("Harald Koschinski", 0, "Harald.Koschinski@arcormail.de");
+ about->addAuthor("Wilco Greven", 0, "greven@kde.org");
+ about->addAuthor("Alexander Neundorf", 0, "neundorf@kde.org");
+ setAboutData( about );
+}
+
+SambaContainer::~SambaContainer()
+{
+ save();
+}
+
+void SambaContainer::load()
+{
+ status.loadSettings();
+ imports.loadSettings();
+ logView.loadSettings();
+ statisticsView.loadSettings();
+}
+
+void SambaContainer::save()
+{
+ status.saveSettings();
+ imports.saveSettings();
+ logView.saveSettings();
+ statisticsView.saveSettings();
+ config.sync();
+}
+
diff --git a/kcontrol/samba/smbstatus.desktop b/kcontrol/samba/smbstatus.desktop
new file mode 100644
index 000000000..c0b6db58a
--- /dev/null
+++ b/kcontrol/samba/smbstatus.desktop
@@ -0,0 +1,241 @@
+[Desktop Entry]
+Exec=kcmshell smbstatus
+Icon=samba
+Type=Application
+DocPath=kinfocenter/samba/index.html
+
+
+X-KDE-Library=samba
+X-KDE-FactoryName=samba
+X-KDE-ParentApp=kinfocenter
+
+Name=Samba Status
+Name[ar]=حالة Samba
+Name[az]=Samba'nın Vəziyyəti
+Name[be]=Стан Samba
+Name[bg]=Сървър Samba
+Name[bn]=সাম্বা স্ট্যাটাস
+Name[br]=Saviad Samba
+Name[bs]=Status Sambe
+Name[ca]=Estat de Samba
+Name[cs]=Stav Samby
+Name[csb]=Sztaus Samba
+Name[cy]=Cyflwr Samba
+Name[da]=Samba-status
+Name[de]=Samba-Status
+Name[el]=Κατάσταση samba
+Name[eo]=Sambo-stato
+Name[es]=Estado de Samba
+Name[et]=Samba olek
+Name[eu]=Sambaren egoera
+Name[fa]=وضعیت Samba
+Name[fi]=Samban tila
+Name[fr]=État de Samba
+Name[fy]=Samba-tastân
+Name[ga]=Stádas Samba
+Name[gl]=Estado de Samba
+Name[he]=מצב Samba
+Name[hi]=साम्बा स्थिति
+Name[hr]=Stanje Sambe
+Name[hu]=Samba
+Name[id]=Status Samba
+Name[is]=Staða Samba
+Name[it]=Stato di Samba
+Name[ja]=Samba の状態
+Name[ka]=Samba-ს სტატუსი
+Name[kk]=Samba сервері
+Name[km]=ស្ថានភាព Samba
+Name[ko]=삼바 상태
+Name[lo]=ສະຖານະຂອງ Samba
+Name[lt]=Samba būsena
+Name[lv]=Samba Statuss
+Name[mk]=Статус на Samba
+Name[mn]=Samba-Төлөв
+Name[ms]=Status Samba
+Name[mt]=Stat tas-Samba
+Name[nb]=Samba-status
+Name[nds]=Samba-Status
+Name[ne]=साम्बा वस्तुस्थिति
+Name[nl]=Samba-status
+Name[nn]=Samba-status
+Name[nso]=Boemo bja Samba
+Name[oc]=Estat de Samba
+Name[pa]=ਸਾਂਬਾ ਸਥਿਤੀ
+Name[pt]=Samba
+Name[pt_BR]=Estado do Samba
+Name[ro]=Stare Samba
+Name[ru]=Сервер Samba
+Name[rw]=Imimerere Samba
+Name[se]=Samba stáhtus
+Name[sk]=Stav systému Samba
+Name[sl]=Status Sambe
+Name[sr]=Статус Самбе
+Name[sr@Latn]=Status Sambe
+Name[ss]=Simo se Samba
+Name[sv]=Samba-status
+Name[ta]=சம்பா நிலை
+Name[tg]=Шароити Samba
+Name[th]=สถานะของ Samba
+Name[tr]=Samba Servisi
+Name[tt]=Samba Xäläte
+Name[uk]=Стан Samba
+Name[uz]=Samba'ning holati
+Name[uz@cyrillic]=Samba'нинг ҳолати
+Name[ven]=Maimo a samba
+Name[vi]=Trạng thái của Samba
+Name[wa]=Estat di Samba
+Name[xh]=Isimo se Samba
+Name[zh_CN]=Samba 状态
+Name[zh_TW]=Samba 狀態
+Name[zu]=Isimo se-Samba
+
+Comment=Samba status monitor
+Comment[ar]=مراقب حالة Samba
+Comment[az]=Samba üçün vəziyyət izləyici
+Comment[be]=Назіральнік стану Samba
+Comment[bg]=Информация за състоянието на сървъра Samba
+Comment[bn]=সাম্বা স্ট্যাটাস নির্দেশক
+Comment[br]=Diskwel saviad Samba
+Comment[bs]=Nadzor statusa samba-e
+Comment[ca]=Monitor de l'estat de Samba
+Comment[cs]=Monitor stavu Samby
+Comment[csb]=Mònitor stónu Sambë
+Comment[cy]=Monitr cyflwr samba
+Comment[da]=Overvågning af samba-status
+Comment[de]=Samba-Statusmonitor
+Comment[el]=Εποπτεία της Samba
+Comment[eo]=Rigardilo por la stato de Sambo
+Comment[es]=Monitor de estado de Samba
+Comment[et]=Samba oleku monitooring
+Comment[eu]=Sambaren egoeraren monitorea
+Comment[fa]=نمایشگر وضعیت Samba
+Comment[fi]=Samban tilan näyttö
+Comment[fr]=Indicateur d'état de Samba
+Comment[fy]=Sambatastânmonitor
+Comment[gl]=Monitor do estado de Samba
+Comment[he]=מידע על המצב של Samba
+Comment[hi]=साम्बा स्थिति मॉनीटर
+Comment[hr]=Nadzor stanje Sambe
+Comment[hu]=Samba állapotmonitor
+Comment[id]=Monitor status Samba
+Comment[is]=Eftirlit með stöðu Samba
+Comment[it]=Controllo dello stato di Samba
+Comment[ja]=Samba の状態を監視します
+Comment[ka]=Samba-ს სტატუსის მონიტორი
+Comment[kk]=Samba күйін бақылау
+Comment[km]=កម្មវិធី​ត្រួត​ពិនិត្យ​ស្ថានភាព Samba
+Comment[ko]=삼바 상태 모니터
+Comment[lo]=ເຄື່ອງມືສອດສ່ອງສະຖານະຂອງເນັດ
+Comment[lt]=Samba būsenos monitorius
+Comment[lv]=Sambas statusa monitors
+Comment[mk]=Монитор на статусот на Samba
+Comment[mn]=Samba-Төлөв харуулагч
+Comment[ms]=Monitor status Samba
+Comment[mt]=Monitur tal-istat tas-Samba
+Comment[nb]=Overvåking av Samba-status
+Comment[nds]=Statuskieker för Samba
+Comment[ne]=साम्बा वस्तुस्थिति मोनिटर
+Comment[nl]=Sambastatusmonitor
+Comment[nn]=Overvaking av Samba-status
+Comment[nso]=Mohlokomedi wa boemo bja Samba
+Comment[oc]=Monitor de l'estat de Samba
+Comment[pa]=ਸਾਂਬਾ ਸਥਿਤੀ ਨਿਗਰਾਨ
+Comment[pl]=Monitor stanu Samby
+Comment[pt]=Monitor do estado do Samba
+Comment[pt_BR]=Monitor de estado do Samba
+Comment[ro]=Monitorizează starea serverului Samba
+Comment[ru]=Состояние сервера Samba
+Comment[rw]=Mugaragaza y'Imimerere Samba
+Comment[se]=Gozit Samba stáhtusa
+Comment[sk]=Monitor stavu Samby
+Comment[sl]=Nadzornik stanja Sambe
+Comment[sr]=Преглед статуса Самбе
+Comment[sr@Latn]=Pregled statusa Sambe
+Comment[sv]=Övervakar Samba-status
+Comment[ta]=சம்பா திரை நிலை
+Comment[tg]=Назорати вазъияти Samba
+Comment[th]=เฝ้าดูสถานะ Samba
+Comment[tr]=Samba için durum izleyici
+Comment[tt]=Samba xäläten küzätüçe
+Comment[uk]=Монітор стану Samba
+Comment[uz]=Samba'ning holatini nazorat qiluvchi vosita
+Comment[uz@cyrillic]=Samba'нинг ҳолатини назорат қилувчи восита
+Comment[ven]=Mutoli wa maimo a Samba
+Comment[vi]=Theo dõi trạng thái samba
+Comment[wa]=Corwaitoe di l' estat di Samba
+Comment[xh]=Umphathi wemeko we Samba
+Comment[zh_CN]=Samba 状态监视器
+Comment[zh_TW]=Samba 狀態監視器
+Comment[zu]=Umphathi wesimo se-samba
+
+Keywords=SMB,SAMBA,Windows network,LAN,System Information
+Keywords[af]=SMB,SAMBA,Windows network,LAN,System Informasie
+Keywords[ar]=SMB,SAMBA,شبكة Windows,شبكة محلية,معلومات النظام
+Keywords[az]=SMB,SAMBA,Pəncərə şəbəkəsi,LAN,Sistem Haqqında Mə'lumat
+Keywords[be]=Сетка Windows,Сетка,Сістэмная інфармацыя,SMB,SAMBA,Windows network,LAN,System Information
+Keywords[bg]=информация, система, системна, самба, сървър, статус, състояние, мрежа, SMB, SAMBA, Windows network, LAN, System Information
+Keywords[br]=SMB,SAMBA,rouedad Windows,LAN,titouroù reizhiad
+Keywords[bs]=SMB,SAMBA,Windows network,LAN,System Information,Windows mreža,mreža,informacije o sustavu
+Keywords[ca]=SMB,SAMBA,Xarxa Windows,LAN,Informació del sistema
+Keywords[cs]=SMB,Samba,Síť Microsoft Windows,LAN,Informace o systému
+Keywords[csb]=SMB,SAMBA,séc Windows,môlowô séc,LAN,wëdowiédzô ò systemie
+Keywords[cy]=SMB,SAMBA,Rhwydwaith Windows,LAN,Gwybodaeth Cysawd
+Keywords[da]=SMB,Samba,Windows-netværk,LAN,Systeminformation
+Keywords[de]=SMB,Samba,Windows-Netzwerk,LAN,Systeminformation
+Keywords[el]=SMB,SAMBA,Δίκτυο Windows,LAN,Πληροφορίες συστήματος
+Keywords[eo]=SMB,Sambo,Vindozo,reto,LAN,sistemo,operaciumo,informo
+Keywords[es]=SMB,SAMBA,Red Windows,LAN,Información del sistema
+Keywords[et]=SMB,SAMBA,Windowsi võrk,LAN,Süsteemi info
+Keywords[eu]=SMB,SAMBA,Windows sarea,LAN,Sistemaren informazioa
+Keywords[fa]=SMB، SAMBA، ویندوز، شبکه، شبکۀ داخلی، اطلاعات سیستم
+Keywords[fi]=SMB,SAMBA,Windows verkko,LAN,Järjestelmätiedot
+Keywords[fr]=réseau Windows,réseau local,informations système,smb,samba,lan,windows
+Keywords[fy]=SMB,SAMBA,Windows network,LAN,systeemynformaasje,Windows-netwurk
+Keywords[ga]=SMB,SAMBA,Líonra Windows,LAN,líonra logánta,Eolas faoin Chóras
+Keywords[gl]=SMB,SAMBA,Rede Windows,LAN,Información do Sistema
+Keywords[he]=רשת מקומית,מידע מערכת,רשת Windows,SAMBA,SMB, SMB,SAMBA,Windows network,LAN,System Information
+Keywords[hi]=एसएमबी,साम्बा,विंडोज़ नेटवर्क,लैन,तंत्र जानकारी
+Keywords[hr]=SMB,SAMBA,Windows network,LAN,System Information,Windows mreža,mreža,podaci o sustavu
+Keywords[hu]=SMB,Samba,Windows-hálózat,LAN,rendszerinformáció
+Keywords[id]=SMB,SAMBA,Windows network,LAN,Informasi Sistem
+Keywords[is]=Netdrif,windows net,kerfi,upplýsingar
+Keywords[it]=SMB,SAMBA,Rete Windows,LAN,Rete locale,Informazioni sul sistema
+Keywords[ja]=SMB,SAMBA,Windowsネットワーク,LAN,システムの情報
+Keywords[km]=SMB,SAMBA,បណ្ដាញ Windows,បណ្ដាញ​មូលដ្ឋាន,ព័ត៌មាន​បណ្ដាញ
+Keywords[lt]=SMB,SAMBA,Windows tinklas,LAN,Sistemos Informacija
+Keywords[lv]=SMB,SAMBA,Windows tīkls,LAN,Sistēmas Informācija
+Keywords[mk]=SMB,SAMBA,Windows network,LAN,System Information, Windows мрежа,Информации за системот,Виндоус мрежа
+Keywords[mn]=SMB,Samba,Виндовс-Сүлжээ,LAN,Системийн мэдээлэл
+Keywords[nb]=SMB,SAMBA,Windows-nettverk,LAN,Systeminformasjon
+Keywords[nds]=SMB,SAMBA,Windowsnettwark,LAN,Systeeminformatschoon
+Keywords[ne]=SMB,SAMBA, सञ्झ्याल सञ्जाल,LAN, प्रणाली सूचना
+Keywords[nl]=SMB,SAMBA,Windows network,LAN,systeeminformatie,Windows-netwerk
+Keywords[nn]=SMB,SAMBA,Windows-nettverk,LAN,systeminformasjon
+Keywords[nso]=SMB,SAMBA,kgokagano ya Windows,LAN,Tshedimoso ya System
+Keywords[oc]=SMB,SAMBA,xarxa Windows,LAN,Informacion dèu sistemo
+Keywords[pa]=SMB,SAMBA,Windows network,LAN,ਸਿਸਟਮ ਜਾਣਕਾਰੀ
+Keywords[pl]=SMB,SAMBA,sieć Windows,sieć lokalna,LAN,informacja o systemie
+Keywords[pt]=SMB,SAMBA,rede Windows,LAN,informações de sistema
+Keywords[pt_BR]=SMB,Samba,Rede Windows,LAN,Informações de sistema
+Keywords[ro]=SMB,SAMBA,rețea Windows,LAN,informații despre sistem
+Keywords[rw]=SMB,SAMBA,Urusobemiyoboro Windows,LAN,Amakuru ya Sisitemu
+Keywords[se]=SMB,SAMBA,Windows-fierbmi,LAN,vuogádatdiehtu
+Keywords[sk]=SMB,SAMBA,sieť Windows,LAN,Systémové Informácie
+Keywords[sl]=SMB,SAMBA,omrežje Windows,LAN,informacije o sistemu
+Keywords[sr]=SMB,SAMBA,Windows network,LAN,System Information,мрежа,системске информације
+Keywords[sr@Latn]=SMB,SAMBA,Windows network,LAN,System Information,mreža,sistemske informacije
+Keywords[sv]=SMB,Samba,Windows nätverk,LAN,Systeminformation
+Keywords[ta]=SMB,சாம்பா,சாளரங்களின் வலை,LAN,அமைப்பு தகவல்
+Keywords[th]=SMB,SAMBA,เครือข่ายวินโดว์ส,เครือข่ายท้องถิ่น,ข้อมูลระบบ
+Keywords[tr]=SMB,SAMBA,Pencere ağı,LAN,Sistem Hakkında Bilgi
+Keywords[uk]=SMB,SAMBA,мережа Windows,lan,ЛОМ,системна інформація
+Keywords[uz]=SMB,SAMBA,Windows tarmogʻi,Tizim haqida maʼlumot,LAN
+Keywords[uz@cyrillic]=SMB,SAMBA,Windows тармоғи,Тизим ҳақида маълумот,LAN
+Keywords[ven]=SMB,SAMBA,Mawindo a vhukwamani,LAN,Mafhungo a sisitemu
+Keywords[vi]=SMB,SAMBA,Mạng Windows,LAN,Thông tin hệ thống
+Keywords[wa]=SMB,SAMBA,rantoele Windows,LAN,rantoele locåle,informåcion do sistinme
+Keywords[xh]=SMB,SAMBA,umsebenzi womnatha wee window,LAN,Ulwazi lwendlela yokusebenza
+Keywords[zh_CN]=SMB,SAMBA,Windows network,LAN,System Information,局域网,系统信息
+Keywords[zh_TW]=SMB,SAMBA,Windows network,LAN,System Information,Windows 網路,區域網路,系統資訊
+Keywords[zu]=SMB,SAMBA,Uxhumano olusakazekile lwama-windows,LAN,Ulwazi lwesistimu
+Categories=Qt;KDE;X-KDE-information;