summaryrefslogtreecommitdiffstats
path: root/kcontrol/samba
diff options
context:
space:
mode:
Diffstat (limited to 'kcontrol/samba')
-rw-r--r--kcontrol/samba/AUTHORS32
-rw-r--r--kcontrol/samba/CMakeLists.txt36
-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.h87
-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.cpp141
-rw-r--r--kcontrol/samba/smbstatus.desktop242
13 files changed, 1633 insertions, 0 deletions
diff --git a/kcontrol/samba/AUTHORS b/kcontrol/samba/AUTHORS
new file mode 100644
index 000000000..08f2ff61b
--- /dev/null
+++ b/kcontrol/samba/AUTHORS
@@ -0,0 +1,32 @@
+Samba Status Module:
+
+ Michael Glauche <[email protected]>
+
+Conversion to kcontrol applet:
+
+ Matthias Hoelzer <[email protected]>
+
+Use of TDEProcess instead of popen, and more error checking
+
+ David Faure <[email protected]>
+
+Added Window and Column resizing:
+
+ Harald Koschinski <[email protected]>
+
+KTabListBox to QListView conversion and use of QLayout:
+
+ Wilco Greven <[email protected]>
+
+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 <[email protected]>
+
diff --git a/kcontrol/samba/CMakeLists.txt b/kcontrol/samba/CMakeLists.txt
new file mode 100644
index 000000000..20a39f232
--- /dev/null
+++ b/kcontrol/samba/CMakeLists.txt
@@ -0,0 +1,36 @@
+#################################################
+#
+# (C) 2010-2011 Serghei Amelian
+# serghei (DOT) amelian (AT) gmail.com
+#
+# Improvements and feedback are welcome
+#
+# This file is released under GPL >= 2
+#
+#################################################
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${TDE_INCLUDE_DIR}
+ ${TQT_INCLUDE_DIRS}
+)
+
+link_directories(
+ ${TQT_LIBRARY_DIRS}
+)
+
+
+##### other data ################################
+
+install( FILES smbstatus.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
+
+
+##### kcm_samba (module) ########################
+
+tde_add_kpart( kcm_samba AUTOMOC
+ SOURCES
+ main.cpp ksmbstatus.cpp kcmsambaimports.cpp kcmsambalog.cpp
+ kcmsambastatistics.cpp
+ LINK tdeio-shared
+ DESTINATION ${PLUGIN_INSTALL_DIR}
+)
diff --git a/kcontrol/samba/Makefile.am b/kcontrol/samba/Makefile.am
new file mode 100644
index 000000000..4eabf0d8d
--- /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_TDEIO)
+
+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..c25867fa5
--- /dev/null
+++ b/kcontrol/samba/kcmsambaimports.cpp
@@ -0,0 +1,95 @@
+/*
+ * kcmsambaimports.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+ *
+ * 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 <tqlayout.h>
+#include <tqwhatsthis.h>
+
+#include <tdelocale.h>
+#include <kdialog.h>
+
+#include <stdio.h>
+
+ImportsView::ImportsView(TQWidget * parent, TDEConfig *config, const char * name )
+ : TQWidget (parent, name)
+ ,configFile(config)
+ ,list(this)
+{
+ TQBoxLayout *topLayout = new TQVBoxLayout(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);
+
+ TQWhatsThis::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);
+ TQObject::connect(&timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateList()));
+ updateList();
+}
+
+void ImportsView::updateList()
+{
+ list.clear();
+ char *e;
+ char buf[250];
+ TQCString 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 TQListViewItem(&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..0897af021
--- /dev/null
+++ b/kcontrol/samba/kcmsambaimports.h
@@ -0,0 +1,47 @@
+/*
+ * kcmsambaimports.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+ *
+ * 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 <tqtimer.h>
+#include <tqlistview.h>
+#include <tdeconfig.h>
+
+class ImportsView: public TQWidget
+{
+ Q_OBJECT
+ public:
+ ImportsView(TQWidget *parent, TDEConfig *config=0, const char * name=0);
+ virtual ~ImportsView() {};
+ void saveSettings() {};
+ void loadSettings() {};
+private:
+ TDEConfig *configFile;
+ TQListView list;
+ TQTimer 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..c25a01113
--- /dev/null
+++ b/kcontrol/samba/kcmsambalog.cpp
@@ -0,0 +1,253 @@
+/*
+ * kcmsambalog.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+ *
+ * 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 <tqfile.h>
+#include <tqlayout.h>
+#include <tqwhatsthis.h>
+
+#include <tdemessagebox.h>
+#include <kdialog.h>
+#include <tdelocale.h>
+
+#include "kcmsambalog.h"
+#include "kcmsambalog.moc"
+
+#define LOG_SCREEN_XY_OFFSET 10
+
+LogView::LogView(TQWidget *parent,TDEConfig *config, const char *name)
+: TQWidget (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)
+{
+ TQVBoxLayout *mainLayout=new TQVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ TQHBoxLayout *leLayout=new TQHBoxLayout(mainLayout);
+ leLayout->addWidget(&label);
+ leLayout->addWidget(&logFileName,1);
+ mainLayout->addWidget(&viewHistory,1);
+ TQGridLayout *subLayout=new TQGridLayout(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);
+
+ TQWhatsThis::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.") );
+
+ TQWhatsThis::add( &showConnOpen, i18n("Check this option if you want to"
+ " view the details for connections opened to your computer.") );
+
+ TQWhatsThis::add( &showConnClose, i18n("Check this option if you want to"
+ " view the events when connections to your computer were closed.") );
+
+ TQWhatsThis::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).") );
+
+ TQWhatsThis::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).") );
+
+ TQWhatsThis::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(TQ_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);
+
+ TQWhatsThis::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 TDE, 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,TQT_SIGNAL(clicked()),this,TQT_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()
+{
+ TQFile logFile(logFileName.url());
+ if (logFile.open(IO_ReadOnly))
+ {
+ TQApplication::setOverrideCursor(tqwaitCursor);
+ 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);
+ TQApplication::restoreOverrideCursor();
+ }
+ else
+ {
+ TQString 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..c3c8c07ea
--- /dev/null
+++ b/kcontrol/samba/kcmsambalog.h
@@ -0,0 +1,87 @@
+/*
+ * kcmsambalog.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+*
+ * 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 <tqlabel.h>
+#include <tqcstring.h>
+#include <tqcheckbox.h>
+#include <tqpushbutton.h>
+#include <tqlistview.h>
+#include <tqevent.h>
+#include <tqapplication.h>
+#include <tdeconfig.h>
+
+#include <kurlrequester.h>
+
+#define LOGGROUPNAME "SambaLogFileSettings"
+
+class LogView: public TQWidget
+{
+ Q_OBJECT
+ public:
+ LogView(TQWidget *parent=0, TDEConfig *config=0, const char *name=0);
+ virtual ~LogView() {};
+ void saveSettings();
+ void loadSettings();
+ private:
+ TDEConfig *configFile;
+ int filesCount, connectionsCount;
+ KURLRequester logFileName;
+ TQLabel label;
+ TQListView viewHistory;
+ TQCheckBox showConnOpen, showConnClose, showFileOpen, showFileClose;
+ TQPushButton updateButton;
+ private slots:
+ void updateList();
+ signals:
+ void contentsChanged(TQListView* list, int nrOfFiles, int nrOfConnections);
+};
+
+class QListViewItemX:public TQListViewItem
+{
+ public:
+ //a faster constructor saves a lot time
+ QListViewItemX( TQListView * 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 )
+ :TQListViewItem(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..3b77dbc9f
--- /dev/null
+++ b/kcontrol/samba/kcmsambastatistics.cpp
@@ -0,0 +1,289 @@
+/*
+ * kcmsambastatistics.cpp
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+ *
+ * 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 <tqlayout.h>
+#include <tqlistview.h>
+#include <tqlabel.h>
+#include <tqlineedit.h>
+#include <tqcheckbox.h>
+#include <tqcombobox.h>
+#include <tqpushbutton.h>
+#include <tqregexp.h>
+
+#include <tdeglobal.h>
+#include <tdelocale.h>
+#include <kdebug.h>
+#include <kdialog.h>
+
+StatisticsView::StatisticsView(TQWidget *parent,TDEConfig *config, const char *name)
+ :TQWidget (parent, name)
+ ,configFile(config)
+ ,dataList(0)
+ ,connectionsCount(0)
+ ,filesCount(0)
+ ,calcCount(0)
+{
+ viewStatistics = new TQListView( this );
+ connectionsL = new TQLabel( i18n( "Connections: 0" ), this );
+ filesL = new TQLabel( i18n( "File accesses: 0" ), this );
+ eventCb = new TQComboBox( false, this );
+ eventL = new TQLabel( eventCb, i18n( "Event: " ), this );
+ serviceLe = new TQLineEdit( this );
+ serviceL = new TQLabel( serviceLe, i18n( "Service/File:" ), this );
+ hostLe = new TQLineEdit( this );
+ hostL = new TQLabel( hostLe, i18n( "Host/User:" ), this );
+ calcButton = new TQPushButton( i18n( "&Search" ), this );
+ clearButton = new TQPushButton( i18n( "Clear Results" ), this );
+ expandedInfoCb = new TQCheckBox( i18n( "Show expanded service info" ), this );
+ expandedUserCb = new TQCheckBox( i18n( "Show expanded host info" ), this );
+
+ viewStatistics->setAllColumnsShowFocus(TRUE);
+ viewStatistics->setFocusPolicy(TQ_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());
+
+ TQVBoxLayout *topLayout=new TQVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ topLayout->addWidget(viewStatistics,1);
+ TQGridLayout *subLayout=new TQGridLayout(topLayout,4,3);
+ subLayout->setColStretch(1,1);
+ subLayout->setColStretch(2,1);
+
+ TQHBoxLayout *twoButtonsLayout=new TQHBoxLayout;
+ 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,TQT_SIGNAL(clicked()),this,TQT_SLOT(clearStatistics()));
+ connect(calcButton,TQT_SIGNAL(clicked()),this,TQT_SLOT(calculate()));
+ setListInfo(0,0,0);
+}
+
+void StatisticsView::setListInfo(TQListView *list, int nrOfFiles, int nrOfConnections)
+{
+ dataList=list;
+ filesCount=nrOfFiles;
+ connectionsCount=nrOfConnections;
+ connectionsL->setText(i18n("Connections: %1").arg(TDEGlobal::locale()->formatNumber(connectionsCount, 0)));
+ filesL->setText(i18n("File accesses: %1").arg(TDEGlobal::locale()->formatNumber(filesCount, 0)));
+ clearStatistics();
+}
+
+void StatisticsView::calculate()
+{
+ if (dataList==0) return;
+ TQApplication::setOverrideCursor(tqwaitCursor);
+ int connCount(0);
+ if (eventCb->currentText()==i18n("Connection"))
+ connCount=1;
+ //something has to be counted exactly
+ if ((expandedInfoCb->isChecked()) || (expandedUserCb->isChecked()))
+ {
+ SambaLog sLog;
+ TQRegExp rService(serviceLe->text(),FALSE,TRUE);
+ TQRegExp rHost(hostLe->text(),FALSE,TRUE);
+ TQString item2, item3;
+ TQListViewItem* item=dataList->firstChild();
+ while (item!=0)
+ {
+ if (connCount)
+ {
+ if ((TQString(item->text(1)).contains(i18n("CONNECTION OPENED")))
+ && (TQString(item->text(2)).contains(rService)) && (TQString(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 ((TQString(item->text(1)).contains(i18n("FILE OPENED")))
+ && (TQString(item->text(2)).contains(rService)) && (TQString(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++;
+ TQString number("");
+ number.sprintf("%6d",calcCount);
+ TQString hits("");
+ hits.sprintf("%7d",tmpStr->count);
+ new TQListViewItem(viewStatistics,number,eventCb->currentText(),tmpItem->name,tmpStr->name,hits);
+ };
+ };
+ }
+ //no expanded info needed
+ else
+ {
+ calcCount++;
+ int count(0);
+ TQRegExp rService(serviceLe->text(),FALSE,TRUE);
+ TQRegExp rHost(hostLe->text(),FALSE,TRUE);
+ TQListViewItem* item=dataList->firstChild();
+ while (item!=0)
+ {
+ if (connCount)
+ {
+ if ((TQString(item->text(1)).contains(i18n("CONNECTION OPENED")))
+ && (TQString(item->text(2)).contains(rService)) && (TQString(item->text(3)).contains(rHost)))
+ count++;
+ }
+ else
+ {
+ if ((TQString(item->text(1)).contains(i18n("FILE OPENED")))
+ && (TQString(item->text(2)).contains(rService)) && (TQString(item->text(3)).contains(rHost)))
+ count++;
+ };
+ item=item->nextSibling();
+ };
+ TQString number("");
+ number.sprintf("%6d",calcCount);
+ TQString hits("");
+ hits.sprintf("%7d",count);
+ new TQListViewItem(viewStatistics,number,eventCb->currentText(),serviceLe->text(),hostLe->text(),hits);
+ };
+ TQApplication::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(TQString 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(TQString share, TQString 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(TQString 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 (TQString 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..4b6ad6211
--- /dev/null
+++ b/kcontrol/samba/kcmsambastatistics.h
@@ -0,0 +1,106 @@
+/*
+ * kcmsambastatistics.h
+ *
+ * Copyright (c) 2000 Alexander Neundorf <[email protected]>
+ *
+ * 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 <tqwidget.h>
+#include <tqptrlist.h>
+
+class TQListView;
+class TQLabel;
+class TQComboBox;
+class TQCheckBox;
+class TQLineEdit;
+class TQPushButton;
+
+class TDEConfig;
+
+class SmallLogItem
+{
+ public:
+ SmallLogItem():name(""),count(0){};
+ SmallLogItem(TQString n):name(n),count(1){};
+ TQString name;
+ int count;
+};
+
+class LogItem
+{
+ public:
+ LogItem():name(""), accessed(),count(0) {};
+ LogItem(TQString n, TQString a):name(n), accessed(), count(1)
+ {
+ accessed.setAutoDelete(TRUE);
+ accessed.append(new SmallLogItem(a));
+ };
+ TQString name;
+ //TQStrList accessedBy;
+ TQPtrList<SmallLogItem> accessed;
+ int count;
+ SmallLogItem* itemInList(TQString name);
+ void addItem (TQString host);
+};
+
+class SambaLog
+{
+ public:
+ SambaLog()
+ {
+ items.setAutoDelete(TRUE);
+ };
+ TQPtrList<LogItem> items;
+ void addItem (TQString share, TQString host);
+ void printItems();
+ private:
+ LogItem* itemInList(TQString name);
+};
+
+class StatisticsView: public TQWidget
+{
+ Q_OBJECT
+public:
+ StatisticsView(TQWidget *parent=0, TDEConfig *config=0, const char *name=0);
+ virtual ~StatisticsView() {};
+ void saveSettings() {};
+ void loadSettings() {};
+ public slots:
+ void setListInfo(TQListView *list, int nrOfFiles, int nrOfConnections);
+private:
+ TDEConfig *configFile;
+ TQListView *dataList;
+ TQListView* viewStatistics;
+ TQLabel* connectionsL, *filesL;
+ TQComboBox* eventCb;
+ TQLabel* eventL;
+ TQLineEdit* serviceLe;
+ TQLabel* serviceL;
+ TQLineEdit* hostLe;
+ TQLabel* hostL;
+ TQPushButton* calcButton, *clearButton;
+ TQCheckBox* 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..abd423d13
--- /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 <tqlayout.h>
+
+#include <tdelocale.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)?TQString(in.mid(in.find(ttf)+TQString(ttf).length())):TQString(""))
+
+NetMon::NetMon( TQWidget * parent, TDEConfig *config, const char * name )
+ : TQWidget(parent, name)
+ ,configFile(config)
+ ,showmountProc(0)
+ ,strShare("")
+ ,strUser("")
+ ,strGroup("")
+ ,strMachine("")
+ ,strSince("")
+ ,strPid("")
+ ,iUser(0)
+ ,iGroup(0)
+ ,iMachine(0)
+ ,iPid(0)
+{
+ TQBoxLayout *topLayout = new TQVBoxLayout(this, KDialog::marginHint(),
+ KDialog::spacingHint());
+ topLayout->setAutoAdd(true);
+
+ list=new TQListView(this,"Hello");
+ version=new TQLabel(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 TQTimer(this);
+ timer->start(15000);
+ TQObject::connect(timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(update()));
+ update();
+}
+
+void NetMon::processNFSLine(char *bufline, int)
+{
+ TQCString line(bufline);
+ if (line.contains(":/"))
+ new TQListViewItem(list,"NFS",After(":",line),Before(":/",line));
+}
+
+void NetMon::processSambaLine(char *bufline, int)
+{
+ TQCString 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 TQListViewItem(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(TDEProcess *, 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()
+{
+ TDEProcess * process = new TDEProcess();
+
+ memset(&lo, 0, sizeof(lo));
+ list->clear();
+ /* Re-read the Contents ... */
+
+ TQString path(::getenv("PATH"));
+ path += "/bin:/sbin:/usr/bin:/usr/sbin";
+
+ rownumber=0;
+ readingpart=header;
+ nrpid=0;
+ process->setEnvironment("PATH", path);
+ connect(process,
+ TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int)),
+ TQT_SLOT(slotReceivedData(TDEProcess *, char *, int)));
+ *process << "smbstatus";
+ if (!process->start(TDEProcess::Block,TDEProcess::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 (TQListViewItem *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,TQString("%1").arg((lo)[pid]));
+ }
+ }
+ delete process;
+ process=0;
+
+ readingpart=nfs;
+ delete showmountProc;
+ showmountProc=new TDEProcess();
+ showmountProc->setEnvironment("PATH", path);
+ *showmountProc<<"showmount"<<"-a"<<"localhost";
+ connect(showmountProc,TQT_SIGNAL(receivedStdout(TDEProcess *, char *, int)),TQT_SLOT(slotReceivedData(TDEProcess *, char *, int)));
+ //without this timer showmount hangs up to 5 minutes
+ //if the portmapper daemon isn't running
+ TQTimer::singleShot(5000,this,TQT_SLOT(killShowmount()));
+ //kdDebug()<<"starting kill timer with 5 seconds"<<endl;
+ connect(showmountProc,TQT_SIGNAL(processExited(TDEProcess*)),this,TQT_SLOT(killShowmount()));
+ if (!showmountProc->start(TDEProcess::NotifyOnExit,TDEProcess::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..f787293ae
--- /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 <tqtimer.h>
+#include <tqlabel.h>
+#include <kprocess.h>
+#include <tqcstring.h>
+#include <tqlistview.h>
+#include <tdeconfig.h>
+
+#define SCREEN_XY_OFFSET 20
+
+class TQListView;
+class TQListViewItem;
+class TDEProcess;
+
+class NetMon : public TQWidget
+{
+Q_OBJECT
+public:
+ NetMon(TQWidget *parent, TDEConfig * config=0, const char * name=0);
+ void saveSettings() {};
+ void loadSettings() {};
+private:
+ TDEConfig *configFile;
+ TDEProcess *showmountProc;
+ TQListView *list;
+ TQLabel *version;
+ TQTimer *timer;
+ TQListViewItem *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);
+
+ TQCString strShare, strUser, strGroup, strMachine, strSince, strPid;
+ int iUser, iGroup, iMachine, iPid;
+
+private slots:
+ void killShowmount();
+ void update();
+ void slotReceivedData(TDEProcess *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..d5af28c1a
--- /dev/null
+++ b/kcontrol/samba/main.cpp
@@ -0,0 +1,141 @@
+/*
+ * 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 <tqlayout.h>
+#include <tqtabwidget.h>
+
+#include <tdeaboutdata.h>
+#include <tdecmodule.h>
+#include <kdialog.h>
+#include <kgenericfactory.h>
+
+#include "kcmsambaimports.h"
+#include "kcmsambalog.h"
+#include "kcmsambastatistics.h"
+#include "ksmbstatus.h"
+
+class SambaContainer:public TDECModule
+{
+ public:
+ SambaContainer(TQWidget *parent=0, const char * name=0, const TQStringList &list = TQStringList() );
+ virtual ~SambaContainer();
+ virtual void load();
+ virtual void save();
+
+ virtual TQString handbookSection() const;
+
+ private:
+ TDEConfig config;
+ TQTabWidget tabs;
+ NetMon status;
+ ImportsView imports;
+ LogView logView;
+ StatisticsView statisticsView;
+};
+
+typedef KGenericFactory<SambaContainer, TQWidget > SambaFactory;
+K_EXPORT_COMPONENT_FACTORY (kcm_samba, SambaFactory("kcmsamba") )
+
+SambaContainer::SambaContainer(TQWidget *parent, const char* name, const TQStringList&)
+:TDECModule(SambaFactory::instance(), parent,name)
+,config("kcmsambarc",false,true)
+,tabs(this)
+,status(&tabs,&config)
+,imports(&tabs,&config)
+,logView(&tabs,&config)
+,statisticsView(&tabs,&config)
+{
+ TQVBoxLayout *layout = new TQVBoxLayout( 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,TQT_SIGNAL(contentsChanged(TQListView* , int, int)),&statisticsView,TQT_SLOT(setListInfo(TQListView *, 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 (Server 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."));
+
+ TDEAboutData *about =
+ new TDEAboutData(I18N_NOOP("kcmsamba"),
+ I18N_NOOP("TDE Panel System Information Control Module"),
+ 0, 0, TDEAboutData::License_GPL,
+ I18N_NOOP("(c) 2002 KDE Information Control Module Samba Team"));
+ about->addAuthor("Michael Glauche", 0, "[email protected]");
+ about->addAuthor("Matthias Hoelzer", 0, "[email protected]");
+ about->addAuthor("David Faure", 0, "[email protected]");
+ about->addAuthor("Harald Koschinski", 0, "[email protected]");
+ about->addAuthor("Wilco Greven", 0, "[email protected]");
+ about->addAuthor("Alexander Neundorf", 0, "[email protected]");
+ 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();
+}
+
+TQString SambaContainer::handbookSection() const
+{
+ int index = tabs.currentPageIndex();
+ if (index == 0) {
+ //return "smb-exports";
+ return TQString::null;
+ }
+ else if (index == 1) {
+ return "smb-imports";
+ }
+ else if (index == 2) {
+ return "smb-log";
+ }
+ else if (index == 3) {
+ return "smb-statistics";
+ }
+ else {
+ return TQString::null;
+ }
+}
diff --git a/kcontrol/samba/smbstatus.desktop b/kcontrol/samba/smbstatus.desktop
new file mode 100644
index 000000000..c455c811d
--- /dev/null
+++ b/kcontrol/samba/smbstatus.desktop
@@ -0,0 +1,242 @@
+[Desktop Entry]
+Exec=tdecmshell smbstatus
+Icon=samba
+Type=Application
+X-DocPath=kcontrol/samba/index.html
+
+
+X-TDE-Library=samba
+X-TDE-FactoryName=samba
+X-TDE-ParentApp=kcontrol
+
+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;TDE;X-TDE-settings-network;
+