From 472156a41b1348c714986c772759ad950fffbe75 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 27 Jan 2013 15:11:21 -0600 Subject: Rename kioslaves --- tdeioslave/smb/tdeio_smb_mount.cpp | 211 +++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 tdeioslave/smb/tdeio_smb_mount.cpp (limited to 'tdeioslave/smb/tdeio_smb_mount.cpp') diff --git a/tdeioslave/smb/tdeio_smb_mount.cpp b/tdeioslave/smb/tdeio_smb_mount.cpp new file mode 100644 index 000000000..1cda7f5f4 --- /dev/null +++ b/tdeioslave/smb/tdeio_smb_mount.cpp @@ -0,0 +1,211 @@ +/* This file is part of the KDE project + + Copyright (C) 2000 Alexander Neundorf + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "tdeio_smb.h" +#include +#include +#include +#include +#include + +void SMBSlave::readOutput(TDEProcess *, char *buffer, int buflen) +{ + mybuf += TQString::fromLocal8Bit(buffer, buflen); +} + +void SMBSlave::readStdErr(TDEProcess *, char *buffer, int buflen) +{ + mystderr += TQString::fromLocal8Bit(buffer, buflen); +} + +void SMBSlave::special( const TQByteArray & data) +{ + kdDebug(KIO_SMB)<<"Smb::special()"<> tmp; + //mounting and umounting are both blocking, "guarded" by a SIGALARM in the future + switch (tmp) + { + case 1: + case 3: + { + TQString remotePath, mountPoint, user; + stream >> remotePath >> mountPoint; + + TQStringList sl=TQStringList::split("/",remotePath); + TQString share,host; + if (sl.count()>=2) + { + host=(*sl.at(0)).mid(2); + share=(*sl.at(1)); + kdDebug(KIO_SMB)<<"special() host -"<< host <<"- share -" << share <<"-"<> mountPoint; + + TDEProcess proc; + proc.setUseShell(true); + proc << "smbumount"; + proc << TDEProcess::quote(mountPoint); + + mybuf.truncate(0); + mystderr.truncate(0); + + connect(&proc, TQT_SIGNAL( receivedStdout(TDEProcess *, char *, int )), + TQT_SLOT(readOutput(TDEProcess *, char *, int))); + + connect(&proc, TQT_SIGNAL( receivedStderr(TDEProcess *, char *, int )), + TQT_SLOT(readStdErr(TDEProcess *, char *, int))); + + if ( !proc.start( TDEProcess::Block, TDEProcess::AllOutput ) ) + { + error(TDEIO::ERR_CANNOT_LAUNCH_PROCESS, + "smbumount"+i18n("\nMake sure that the samba package is installed properly on your system.")); + return; + } + + kdDebug(KIO_SMB) << "smbumount exit " << proc.exitStatus() << endl + << "stdout:" << mybuf << endl << "stderr:" << mystderr << endl; + + if (proc.exitStatus() != 0) + { + error(TDEIO::ERR_COULD_NOT_UNMOUNT, + i18n("Unmounting of mountpoint \"%1\" failed.\n%2") + .arg(mountPoint).arg(mybuf + "\n" + mystderr)); + return; + } + + if ( tmp == 4 ) + { + bool ok; + + TQDir dir(mountPoint); + dir.cdUp(); + ok = dir.rmdir(mountPoint); + if ( ok ) + { + TQString p=dir.path(); + dir.cdUp(); + ok = dir.rmdir(p); + } + + if ( !ok ) + { + error(TDEIO::ERR_COULD_NOT_RMDIR, mountPoint); + return; + } + } + + finished(); + } + break; + default: + break; + } + finished(); +} + +#include "tdeio_smb.moc" -- cgit v1.2.1