Changeset View
Changeset View
Standalone View
Standalone View
smb/kio_smb_mount.cpp
Show All 24 Lines | |||||
25 | #include <QDir> | 25 | #include <QDir> | ||
26 | #include <QDataStream> | 26 | #include <QDataStream> | ||
27 | #include <KLocalizedString> | 27 | #include <KLocalizedString> | ||
28 | #include <KProcess> | 28 | #include <KProcess> | ||
29 | #include <kshell.h> | 29 | #include <kshell.h> | ||
30 | 30 | | |||
31 | void SMBSlave::special( const QByteArray & data) | 31 | void SMBSlave::special( const QByteArray & data) | ||
32 | { | 32 | { | ||
33 | qCDebug(KIO_SMB)<<"Smb::special()"; | 33 | qCDebug(KIO_SMB_LOG)<<"Smb::special()"; | ||
34 | int tmp; | 34 | int tmp; | ||
35 | QDataStream stream(data); | 35 | QDataStream stream(data); | ||
36 | stream >> tmp; | 36 | stream >> tmp; | ||
37 | //mounting and umounting are both blocking, "guarded" by a SIGALARM in the future | 37 | //mounting and umounting are both blocking, "guarded" by a SIGALARM in the future | ||
38 | switch (tmp) | 38 | switch (tmp) | ||
39 | { | 39 | { | ||
40 | case 1: | 40 | case 1: | ||
41 | case 3: | 41 | case 3: | ||
42 | { | 42 | { | ||
43 | QString remotePath, mountPoint, user; | 43 | QString remotePath, mountPoint, user; | ||
44 | stream >> remotePath >> mountPoint; | 44 | stream >> remotePath >> mountPoint; | ||
45 | 45 | | |||
46 | QStringList sl=remotePath.split('/'); | 46 | QStringList sl=remotePath.split('/'); | ||
47 | QString share,host; | 47 | QString share,host; | ||
48 | if (sl.count()>=2) | 48 | if (sl.count()>=2) | ||
49 | { | 49 | { | ||
50 | host=sl.at(0).mid(2); | 50 | host=sl.at(0).mid(2); | ||
51 | share=sl.at(1); | 51 | share=sl.at(1); | ||
52 | qCDebug(KIO_SMB)<<"special() host -"<< host <<"- share -" << share <<"-"; | 52 | qCDebug(KIO_SMB_LOG)<<"special() host -"<< host <<"- share -" << share <<"-"; | ||
53 | } | 53 | } | ||
54 | 54 | | |||
55 | remotePath.replace('\\', '/'); // smbmounterplugin sends \\host/share | 55 | remotePath.replace('\\', '/'); // smbmounterplugin sends \\host/share | ||
56 | 56 | | |||
57 | qCDebug(KIO_SMB) << "mounting: " << remotePath.toLocal8Bit() << " to " << mountPoint.toLocal8Bit(); | 57 | qCDebug(KIO_SMB_LOG) << "mounting: " << remotePath.toLocal8Bit() << " to " << mountPoint.toLocal8Bit(); | ||
58 | 58 | | |||
59 | if (tmp==3) { | 59 | if (tmp==3) { | ||
60 | if (!QDir().mkpath(mountPoint)) { | 60 | if (!QDir().mkpath(mountPoint)) { | ||
61 | error(KIO::ERR_CANNOT_MKDIR, mountPoint); | 61 | error(KIO::ERR_CANNOT_MKDIR, mountPoint); | ||
62 | return; | 62 | return; | ||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | 65 | | |||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 109 | { | |||
110 | error(KIO::ERR_CANNOT_LAUNCH_PROCESS, | 110 | error(KIO::ERR_CANNOT_LAUNCH_PROCESS, | ||
111 | "smbmount"+i18n("\nMake sure that the samba package is installed properly on your system.")); | 111 | "smbmount"+i18n("\nMake sure that the samba package is installed properly on your system.")); | ||
112 | return; | 112 | return; | ||
113 | } | 113 | } | ||
114 | 114 | | |||
115 | QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput()); | 115 | QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput()); | ||
116 | QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError()); | 116 | QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError()); | ||
117 | 117 | | |||
118 | qCDebug(KIO_SMB) << "mount exit " << proc.exitCode() | 118 | qCDebug(KIO_SMB_LOG) << "mount exit " << proc.exitCode() | ||
119 | << "stdout:" << mybuf << "\nstderr:" << mystderr; | 119 | << "stdout:" << mybuf << "\nstderr:" << mystderr; | ||
120 | 120 | | |||
121 | if (proc.exitCode() != 0) | 121 | if (proc.exitCode() != 0) | ||
122 | { | 122 | { | ||
123 | error( KIO::ERR_CANNOT_MOUNT, | 123 | error( KIO::ERR_CANNOT_MOUNT, | ||
124 | i18n("Mounting of share \"%1\" from host \"%2\" by user \"%3\" failed.\n%4", | 124 | i18n("Mounting of share \"%1\" from host \"%2\" by user \"%3\" failed.\n%4", | ||
125 | share, host, user, mybuf + '\n' + mystderr)); | 125 | share, host, user, mybuf + '\n' + mystderr)); | ||
126 | return; | 126 | return; | ||
Show All 19 Lines | 145 | { | |||
146 | error(KIO::ERR_CANNOT_LAUNCH_PROCESS, | 146 | error(KIO::ERR_CANNOT_LAUNCH_PROCESS, | ||
147 | "smbumount"+i18n("\nMake sure that the samba package is installed properly on your system.")); | 147 | "smbumount"+i18n("\nMake sure that the samba package is installed properly on your system.")); | ||
148 | return; | 148 | return; | ||
149 | } | 149 | } | ||
150 | 150 | | |||
151 | QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput()); | 151 | QString mybuf = QString::fromLocal8Bit(proc.readAllStandardOutput()); | ||
152 | QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError()); | 152 | QString mystderr = QString::fromLocal8Bit(proc.readAllStandardError()); | ||
153 | 153 | | |||
154 | qCDebug(KIO_SMB) << "smbumount exit " << proc.exitCode() | 154 | qCDebug(KIO_SMB_LOG) << "smbumount exit " << proc.exitCode() | ||
155 | << "stdout:" << mybuf << "\nstderr:" << mystderr; | 155 | << "stdout:" << mybuf << "\nstderr:" << mystderr; | ||
156 | 156 | | |||
157 | if (proc.exitCode() != 0) | 157 | if (proc.exitCode() != 0) | ||
158 | { | 158 | { | ||
159 | error(KIO::ERR_CANNOT_UNMOUNT, | 159 | error(KIO::ERR_CANNOT_UNMOUNT, | ||
160 | i18n("Unmounting of mountpoint \"%1\" failed.\n%2", | 160 | i18n("Unmounting of mountpoint \"%1\" failed.\n%2", | ||
161 | mountPoint, mybuf + '\n' + mystderr)); | 161 | mountPoint, mybuf + '\n' + mystderr)); | ||
162 | return; | 162 | return; | ||
Show All 31 Lines |