Changeset View
Changeset View
Standalone View
Standalone View
src/core/slavebase.cpp
Show All 15 Lines | |||||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU Library General Public License | 17 | * You should have received a copy of the GNU Library General Public License | ||
18 | * along with this library; see the file COPYING.LIB. If not, write to | 18 | * along with this library; see the file COPYING.LIB. If not, write to | ||
19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
20 | * Boston, MA 02110-1301, USA. | 20 | * Boston, MA 02110-1301, USA. | ||
21 | * | 21 | * | ||
22 | **/ | 22 | **/ | ||
23 | 23 | | |||
24 | // TODO: remove me | | |||
25 | #undef QT_NO_CAST_FROM_ASCII | | |||
26 | | ||||
27 | #include "slavebase.h" | 24 | #include "slavebase.h" | ||
28 | 25 | | |||
29 | #include <config-kiocore.h> | 26 | #include <config-kiocore.h> | ||
30 | 27 | | |||
31 | #include <stdlib.h> | 28 | #include <stdlib.h> | ||
32 | #include <qplatformdefs.h> | 29 | #include <qplatformdefs.h> | ||
33 | #include <signal.h> | 30 | #include <signal.h> | ||
34 | #ifdef Q_OS_WIN | 31 | #ifdef Q_OS_WIN | ||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Line(s) | 201 | { | |||
205 | return ((m_state == FinishedCalled) || (m_state == ErrorCalled)); | 202 | return ((m_state == FinishedCalled) || (m_state == ErrorCalled)); | ||
206 | } | 203 | } | ||
207 | 204 | | |||
208 | void verifyState(const char *cmdName) | 205 | void verifyState(const char *cmdName) | ||
209 | { | 206 | { | ||
210 | KIO_STATE_ASSERT(finalState(), | 207 | KIO_STATE_ASSERT(finalState(), | ||
211 | Q_FUNC_INFO, | 208 | Q_FUNC_INFO, | ||
212 | qUtf8Printable(QStringLiteral("%1 did not call finished() or error()! Please fix the %2 KIO slave") | 209 | qUtf8Printable(QStringLiteral("%1 did not call finished() or error()! Please fix the %2 KIO slave") | ||
213 | .arg(cmdName) | 210 | .arg(QLatin1String(cmdName)) | ||
214 | .arg(QCoreApplication::applicationName()))); | 211 | .arg(QCoreApplication::applicationName()))); | ||
215 | // Force the command into finished state. We'll not reach this for Debug builds | 212 | // Force the command into finished state. We'll not reach this for Debug builds | ||
216 | // that fail the assertion. For Release builds we'll have made sure that the | 213 | // that fail the assertion. For Release builds we'll have made sure that the | ||
217 | // command is actually finished after the verification regardless of what | 214 | // command is actually finished after the verification regardless of what | ||
218 | // the slave did. | 215 | // the slave did. | ||
219 | if (!finalState()) { | 216 | if (!finalState()) { | ||
220 | q->finished(); | 217 | q->finished(); | ||
221 | } | 218 | } | ||
222 | } | 219 | } | ||
223 | 220 | | |||
224 | void verifyErrorFinishedNotCalled(const char *cmdName) | 221 | void verifyErrorFinishedNotCalled(const char *cmdName) | ||
225 | { | 222 | { | ||
226 | KIO_STATE_ASSERT(!finalState(), | 223 | KIO_STATE_ASSERT(!finalState(), | ||
227 | Q_FUNC_INFO, | 224 | Q_FUNC_INFO, | ||
228 | qUtf8Printable(QStringLiteral("%1 called finished() or error(), but it's not supposed to! Please fix the %2 KIO slave") | 225 | qUtf8Printable(QStringLiteral("%1 called finished() or error(), but it's not supposed to! Please fix the %2 KIO slave") | ||
229 | .arg(cmdName) | 226 | .arg(QLatin1String(cmdName)) | ||
230 | .arg(QCoreApplication::applicationName()))); | 227 | .arg(QCoreApplication::applicationName()))); | ||
231 | } | 228 | } | ||
232 | 229 | | |||
233 | KPasswdServerClient *passwdServerClient() | 230 | KPasswdServerClient *passwdServerClient() | ||
234 | { | 231 | { | ||
235 | if (!m_passwdServerClient) { | 232 | if (!m_passwdServerClient) { | ||
236 | m_passwdServerClient = new KPasswdServerClient; | 233 | m_passwdServerClient = new KPasswdServerClient; | ||
237 | } | 234 | } | ||
▲ Show 20 Lines • Show All 660 Lines • ▼ Show 20 Line(s) | 894 | case CMD_OPEN: | |||
898 | return i18n("Opening files is not supported with protocol %1.", protocol); | 895 | return i18n("Opening files is not supported with protocol %1.", protocol); | ||
899 | default: | 896 | default: | ||
900 | return i18n("Protocol %1 does not support action %2.", protocol, cmd); | 897 | return i18n("Protocol %1 does not support action %2.", protocol, cmd); | ||
901 | }/*end switch*/ | 898 | }/*end switch*/ | ||
902 | } | 899 | } | ||
903 | 900 | | |||
904 | void SlaveBase::openConnection() | 901 | void SlaveBase::openConnection() | ||
905 | { | 902 | { | ||
906 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CONNECT)); | 903 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_CONNECT)); | ||
907 | } | 904 | } | ||
908 | void SlaveBase::closeConnection() | 905 | void SlaveBase::closeConnection() | ||
909 | { } // No response! | 906 | { } // No response! | ||
910 | void SlaveBase::stat(QUrl const &) | 907 | void SlaveBase::stat(QUrl const &) | ||
911 | { | 908 | { | ||
912 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_STAT)); | 909 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_STAT)); | ||
913 | } | 910 | } | ||
914 | void SlaveBase::put(QUrl const &, int, JobFlags) | 911 | void SlaveBase::put(QUrl const &, int, JobFlags) | ||
915 | { | 912 | { | ||
916 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_PUT)); | 913 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_PUT)); | ||
917 | } | 914 | } | ||
918 | void SlaveBase::special(const QByteArray &) | 915 | void SlaveBase::special(const QByteArray &) | ||
919 | { | 916 | { | ||
920 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SPECIAL)); | 917 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SPECIAL)); | ||
921 | } | 918 | } | ||
922 | void SlaveBase::listDir(QUrl const &) | 919 | void SlaveBase::listDir(QUrl const &) | ||
923 | { | 920 | { | ||
924 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_LISTDIR)); | 921 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_LISTDIR)); | ||
925 | } | 922 | } | ||
926 | void SlaveBase::get(QUrl const &) | 923 | void SlaveBase::get(QUrl const &) | ||
927 | { | 924 | { | ||
928 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_GET)); | 925 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_GET)); | ||
929 | } | 926 | } | ||
930 | void SlaveBase::open(QUrl const &, QIODevice::OpenMode) | 927 | void SlaveBase::open(QUrl const &, QIODevice::OpenMode) | ||
931 | { | 928 | { | ||
932 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_OPEN)); | 929 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_OPEN)); | ||
933 | } | 930 | } | ||
934 | void SlaveBase::read(KIO::filesize_t) | 931 | void SlaveBase::read(KIO::filesize_t) | ||
935 | { | 932 | { | ||
936 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_READ)); | 933 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_READ)); | ||
937 | } | 934 | } | ||
938 | void SlaveBase::write(const QByteArray &) | 935 | void SlaveBase::write(const QByteArray &) | ||
939 | { | 936 | { | ||
940 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_WRITE)); | 937 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_WRITE)); | ||
941 | } | 938 | } | ||
942 | void SlaveBase::seek(KIO::filesize_t) | 939 | void SlaveBase::seek(KIO::filesize_t) | ||
943 | { | 940 | { | ||
944 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SEEK)); | 941 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SEEK)); | ||
945 | } | 942 | } | ||
946 | void SlaveBase::close() | 943 | void SlaveBase::close() | ||
947 | { | 944 | { | ||
948 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CLOSE)); | 945 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_CLOSE)); | ||
949 | } | 946 | } | ||
950 | void SlaveBase::mimetype(QUrl const &url) | 947 | void SlaveBase::mimetype(QUrl const &url) | ||
951 | { | 948 | { | ||
952 | get(url); | 949 | get(url); | ||
953 | } | 950 | } | ||
954 | void SlaveBase::rename(QUrl const &, QUrl const &, JobFlags) | 951 | void SlaveBase::rename(QUrl const &, QUrl const &, JobFlags) | ||
955 | { | 952 | { | ||
956 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_RENAME)); | 953 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_RENAME)); | ||
957 | } | 954 | } | ||
958 | void SlaveBase::symlink(QString const &, QUrl const &, JobFlags) | 955 | void SlaveBase::symlink(QString const &, QUrl const &, JobFlags) | ||
959 | { | 956 | { | ||
960 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SYMLINK)); | 957 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SYMLINK)); | ||
961 | } | 958 | } | ||
962 | void SlaveBase::copy(QUrl const &, QUrl const &, int, JobFlags) | 959 | void SlaveBase::copy(QUrl const &, QUrl const &, int, JobFlags) | ||
963 | { | 960 | { | ||
964 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_COPY)); | 961 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_COPY)); | ||
965 | } | 962 | } | ||
966 | void SlaveBase::del(QUrl const &, bool) | 963 | void SlaveBase::del(QUrl const &, bool) | ||
967 | { | 964 | { | ||
968 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_DEL)); | 965 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_DEL)); | ||
969 | } | 966 | } | ||
970 | void SlaveBase::setLinkDest(const QUrl &, const QString &) | 967 | void SlaveBase::setLinkDest(const QUrl &, const QString &) | ||
971 | { | 968 | { | ||
972 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SETLINKDEST)); | 969 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SETLINKDEST)); | ||
973 | } | 970 | } | ||
974 | void SlaveBase::mkdir(QUrl const &, int) | 971 | void SlaveBase::mkdir(QUrl const &, int) | ||
975 | { | 972 | { | ||
976 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MKDIR)); | 973 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_MKDIR)); | ||
977 | } | 974 | } | ||
978 | void SlaveBase::chmod(QUrl const &, int) | 975 | void SlaveBase::chmod(QUrl const &, int) | ||
979 | { | 976 | { | ||
980 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHMOD)); | 977 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_CHMOD)); | ||
981 | } | 978 | } | ||
982 | void SlaveBase::setModificationTime(QUrl const &, const QDateTime &) | 979 | void SlaveBase::setModificationTime(QUrl const &, const QDateTime &) | ||
983 | { | 980 | { | ||
984 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SETMODIFICATIONTIME)); | 981 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SETMODIFICATIONTIME)); | ||
985 | } | 982 | } | ||
986 | void SlaveBase::chown(QUrl const &, const QString &, const QString &) | 983 | void SlaveBase::chown(QUrl const &, const QString &, const QString &) | ||
987 | { | 984 | { | ||
988 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_CHOWN)); | 985 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_CHOWN)); | ||
989 | } | 986 | } | ||
990 | void SlaveBase::setSubUrl(QUrl const &) | 987 | void SlaveBase::setSubUrl(QUrl const &) | ||
991 | { | 988 | { | ||
992 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_SUBURL)); | 989 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_SUBURL)); | ||
993 | } | 990 | } | ||
994 | void SlaveBase::multiGet(const QByteArray &) | 991 | void SlaveBase::multiGet(const QByteArray &) | ||
995 | { | 992 | { | ||
996 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_MULTI_GET)); | 993 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_MULTI_GET)); | ||
997 | } | 994 | } | ||
998 | 995 | | |||
999 | void SlaveBase::slave_status() | 996 | void SlaveBase::slave_status() | ||
1000 | { | 997 | { | ||
1001 | slaveStatus(QString(), false); | 998 | slaveStatus(QString(), false); | ||
1002 | } | 999 | } | ||
1003 | 1000 | | |||
1004 | void SlaveBase::reparseConfiguration() | 1001 | void SlaveBase::reparseConfiguration() | ||
▲ Show 20 Lines • Show All 490 Lines • ▼ Show 20 Line(s) | |||||
1495 | } | 1492 | } | ||
1496 | 1493 | | |||
1497 | void SlaveBase::virtual_hook(int id, void *data) | 1494 | void SlaveBase::virtual_hook(int id, void *data) | ||
1498 | { | 1495 | { | ||
1499 | Q_UNUSED(data); | 1496 | Q_UNUSED(data); | ||
1500 | 1497 | | |||
1501 | switch(id) { | 1498 | switch(id) { | ||
1502 | case GetFileSystemFreeSpace: { | 1499 | case GetFileSystemFreeSpace: { | ||
1503 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocol, CMD_FILESYSTEMFREESPACE)); | 1500 | error(ERR_UNSUPPORTED_ACTION, unsupportedActionErrorString(mProtocolToStr(), CMD_FILESYSTEMFREESPACE)); | ||
1504 | } break; | 1501 | } break; | ||
1505 | } | 1502 | } | ||
1506 | } | 1503 | } | ||
1507 | 1504 | | |||
1508 | void SlaveBase::lookupHost(const QString &host) | 1505 | void SlaveBase::lookupHost(const QString &host) | ||
1509 | { | 1506 | { | ||
1510 | KIO_DATA << host; | 1507 | KIO_DATA << host; | ||
1511 | send(MSG_HOST_INFO_REQ, data); | 1508 | send(MSG_HOST_INFO_REQ, data); | ||
▲ Show 20 Lines • Show All 53 Lines • Show Last 20 Lines |