Changeset View
Changeset View
Standalone View
Standalone View
src/core/ksambashare.cpp
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 45 | static const char *const DefaultSambaConfigFilePathList[] = { | |||
---|---|---|---|---|---|
50 | "/usr/samba/lib/smb.conf", | 50 | "/usr/samba/lib/smb.conf", | ||
51 | "/usr/lib/smb.conf", | 51 | "/usr/lib/smb.conf", | ||
52 | "/usr/local/lib/smb.conf" | 52 | "/usr/local/lib/smb.conf" | ||
53 | }; | 53 | }; | ||
54 | 54 | | |||
55 | KSambaSharePrivate::KSambaSharePrivate(KSambaShare *parent) | 55 | KSambaSharePrivate::KSambaSharePrivate(KSambaShare *parent) | ||
56 | : q_ptr(parent) | 56 | : q_ptr(parent) | ||
57 | , data() | 57 | , data() | ||
58 | , smbConf() | | |||
59 | , userSharePath() | 58 | , userSharePath() | ||
60 | , skipUserShare(false) | 59 | , skipUserShare(false) | ||
61 | { | 60 | { | ||
62 | setUserSharePath(); | 61 | setUserSharePath(); | ||
62 | #if KIOCORE_BUILD_DEPRECATED_SINCE(4, 6) | ||||
63 | findSmbConf(); | 63 | findSmbConf(); | ||
64 | #endif | ||||
64 | data = parse(getNetUserShareInfo()); | 65 | data = parse(getNetUserShareInfo()); | ||
65 | } | 66 | } | ||
66 | 67 | | |||
67 | KSambaSharePrivate::~KSambaSharePrivate() | 68 | KSambaSharePrivate::~KSambaSharePrivate() | ||
68 | { | 69 | { | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | bool KSambaSharePrivate::isSambaInstalled() | 72 | bool KSambaSharePrivate::isSambaInstalled() | ||
72 | { | 73 | { | ||
73 | if (QFile::exists(QStringLiteral("/usr/sbin/smbd")) | 74 | if (QFile::exists(QStringLiteral("/usr/sbin/smbd")) | ||
74 | || QFile::exists(QStringLiteral("/usr/local/sbin/smbd"))) { | 75 | || QFile::exists(QStringLiteral("/usr/local/sbin/smbd"))) { | ||
75 | return true; | 76 | return true; | ||
76 | } | 77 | } | ||
77 | 78 | | |||
78 | //qDebug() << "Samba is not installed!"; | 79 | //qDebug() << "Samba is not installed!"; | ||
79 | 80 | | |||
80 | return false; | 81 | return false; | ||
81 | } | 82 | } | ||
82 | 83 | | |||
84 | #if KIOCORE_BUILD_DEPRECATED_SINCE(4, 6) | ||||
83 | // Try to find the samba config file path | 85 | // Try to find the samba config file path | ||
84 | // in several well-known paths | 86 | // in several well-known paths | ||
85 | bool KSambaSharePrivate::findSmbConf() | 87 | bool KSambaSharePrivate::findSmbConf() | ||
86 | { | 88 | { | ||
87 | for (const char *str : DefaultSambaConfigFilePathList) { | 89 | for (const char *str : DefaultSambaConfigFilePathList) { | ||
88 | const QString filePath = QString::fromLatin1(str); | 90 | const QString filePath = QString::fromLatin1(str); | ||
89 | if (QFile::exists(filePath)) { | 91 | if (QFile::exists(filePath)) { | ||
90 | smbConf = filePath; | 92 | smbConf = filePath; | ||
91 | return true; | 93 | return true; | ||
92 | } | 94 | } | ||
93 | } | 95 | } | ||
94 | 96 | | |||
95 | qCDebug(KIO_CORE_SAMBASHARE) << "KSambaShare: Could not find smb.conf!"; | 97 | qCDebug(KIO_CORE_SAMBASHARE) << "KSambaShare: Could not find smb.conf!"; | ||
96 | 98 | | |||
97 | return false; | 99 | return false; | ||
98 | } | 100 | } | ||
101 | #endif | ||||
99 | 102 | | |||
100 | void KSambaSharePrivate::setUserSharePath() | 103 | void KSambaSharePrivate::setUserSharePath() | ||
101 | { | 104 | { | ||
102 | const QString rawString = testparmParamValue(QStringLiteral("usershare path")); | 105 | const QString rawString = testparmParamValue(QStringLiteral("usershare path")); | ||
103 | const QFileInfo fileInfo(rawString); | 106 | const QFileInfo fileInfo(rawString); | ||
104 | if (fileInfo.isDir()) { | 107 | if (fileInfo.isDir()) { | ||
105 | userSharePath = rawString; | 108 | userSharePath = rawString; | ||
106 | } | 109 | } | ||
▲ Show 20 Lines • Show All 376 Lines • ▼ Show 20 Line(s) | |||||
483 | { | 486 | { | ||
484 | Q_D(const KSambaShare); | 487 | Q_D(const KSambaShare); | ||
485 | if (KDirWatch::exists() && KDirWatch::self()->contains(d->userSharePath)) { | 488 | if (KDirWatch::exists() && KDirWatch::self()->contains(d->userSharePath)) { | ||
486 | KDirWatch::self()->removeDir(d->userSharePath); | 489 | KDirWatch::self()->removeDir(d->userSharePath); | ||
487 | } | 490 | } | ||
488 | delete d_ptr; | 491 | delete d_ptr; | ||
489 | } | 492 | } | ||
490 | 493 | | |||
494 | #if KIOCORE_BUILD_DEPRECATED_SINCE(4, 6) | ||||
491 | QString KSambaShare::smbConfPath() const | 495 | QString KSambaShare::smbConfPath() const | ||
492 | { | 496 | { | ||
493 | Q_D(const KSambaShare); | 497 | Q_D(const KSambaShare); | ||
494 | return d->smbConf; | 498 | return d->smbConf; | ||
495 | } | 499 | } | ||
500 | #endif | ||||
496 | 501 | | |||
497 | bool KSambaShare::isDirectoryShared(const QString &path) const | 502 | bool KSambaShare::isDirectoryShared(const QString &path) const | ||
498 | { | 503 | { | ||
499 | Q_D(const KSambaShare); | 504 | Q_D(const KSambaShare); | ||
500 | return d->isDirectoryShared(path); | 505 | return d->isDirectoryShared(path); | ||
501 | } | 506 | } | ||
502 | 507 | | |||
503 | bool KSambaShare::isShareNameAvailable(const QString &name) const | 508 | bool KSambaShare::isShareNameAvailable(const QString &name) const | ||
▲ Show 20 Lines • Show All 43 Lines • Show Last 20 Lines |