Commit 3d68b22f authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Port deprecated method

parent f3e66c24
......@@ -191,7 +191,7 @@ void ArchiveProtocolBase::createUDSEntry( const KArchiveEntry * archiveEntry, UD
entry.fastInsert( KIO::UDSEntry::UDS_NAME, archiveEntry->name() );
entry.fastInsert( KIO::UDSEntry::UDS_FILE_TYPE, archiveEntry->permissions() & S_IFMT ); // keep file type only
entry.fastInsert( KIO::UDSEntry::UDS_SIZE, archiveEntry->isFile() ? ((KArchiveFile *)archiveEntry)->size() : 0L );
entry.fastInsert( KIO::UDSEntry::UDS_MODIFICATION_TIME, archiveEntry->date().toTime_t());
entry.fastInsert( KIO::UDSEntry::UDS_MODIFICATION_TIME, archiveEntry->date().toSecsSinceEpoch());
entry.fastInsert( KIO::UDSEntry::UDS_ACCESS, archiveEntry->permissions() & 07777 ); // keep permissions only
entry.fastInsert( KIO::UDSEntry::UDS_USER, archiveEntry->user());
entry.fastInsert( KIO::UDSEntry::UDS_GROUP, archiveEntry->group());
......
......@@ -204,9 +204,7 @@ QString BookmarksProtocol::htmlColor(const QColor &col)
{
int r, g, b;
col.getRgb(&r, &g, &b);
QString num;
num.sprintf("#%02X%02X%02X", r, g, b);
const QString num = QString::asprintf("#%02X%02X%02X", r, g, b);
return num;
}
......
......@@ -856,7 +856,7 @@ int fishProtocol::makeTimeFromLs(const QString &monthStr, const QString &dayStr,
}
dt.date().setDate(year,month,day);
return dt.toTime_t();
return dt.toSecsSinceEpoch();
}
/**
......@@ -980,7 +980,7 @@ void fishProtocol::manageConnection(const QString &l) {
if (pos < 0 || pos2 < 0 || pos3 < 0) break;
dt.setTime(QTime(line.mid(pos+1,pos2-pos-1).toInt(),line.mid(pos2+1,pos3-pos2-1).toInt(),line.mid(pos3+1).toInt()));
errorCount--;
udsEntry.replace(KIO::UDSEntry::UDS_MODIFICATION_TIME, dt.toTime_t());
udsEntry.replace(KIO::UDSEntry::UDS_MODIFICATION_TIME, dt.toSecsSinceEpoch());
break;
case 'S':
......
......@@ -663,7 +663,7 @@ void MTPSlave::copy(const QUrl &src, const QUrl &dest, int, JobFlags flags)
// set correct modification time
struct ::utimbuf times;
times.actime = QDateTime::currentDateTime().toTime_t();
times.actime = QDateTime::currentDateTime().toSecsSinceEpoch();
times.modtime = source.modificationdate();
::utime(dest.path().toUtf8().data(), &times);
......
......@@ -552,7 +552,7 @@ int MTPStorage::sendFileFromFileDescriptor(const QDBusUnixFileDescriptor &descri
file->filename = qstrdup(filename.toUtf8().data());
file->filetype = getFiletype(filename);
file->filesize = quint64(srcBuf.st_size);
file->modificationdate = lastModified.toTime_t(); // no matter what to set here, current time is taken
file->modificationdate = lastModified.toSecsSinceEpoch(); // no matter what to set here, current time is taken
file->storage_id = m_id;
result = LIBMTP_Send_File_From_File_Descriptor(getDevice(), descriptor.fileDescriptor(), file, onDataProgress, this);
......
......@@ -51,13 +51,13 @@ class NetworkDBusInterface: public QDBusAbstractInterface
inline QDBusReply<Mollet::NetDevice> NetworkDBusInterface::deviceData( const QString& hostAddress )
{
QList<QVariant> argumentList;
argumentList << qVariantFromValue(hostAddress);
argumentList << QVariant::fromValue(hostAddress);
return callWithArgumentList( QDBus::Block, QString::fromLatin1("deviceData"), argumentList );
}
inline QDBusReply<Mollet::NetService> NetworkDBusInterface::serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType )
{
QList<QVariant> argumentList;
argumentList << qVariantFromValue(hostAddress) << qVariantFromValue(serviceName) << qVariantFromValue(serviceType);
argumentList << QVariant::fromValue(hostAddress) << QVariant::fromValue(serviceName) << QVariant::fromValue(serviceType);
return callWithArgumentList( QDBus::Block, QString::fromLatin1("serviceData"), argumentList );
}
inline QDBusReply<Mollet::NetDeviceList> NetworkDBusInterface::deviceDataList()
......@@ -67,7 +67,7 @@ inline QDBusReply<Mollet::NetDeviceList> NetworkDBusInterface::deviceDataList()
inline QDBusReply<Mollet::NetServiceList> NetworkDBusInterface::serviceDataList( const QString& hostAddress )
{
QList<QVariant> argumentList;
argumentList << qVariantFromValue(hostAddress);
argumentList << QVariant::fromValue(hostAddress);
return callWithArgumentList( QDBus::Block, QString::fromLatin1("serviceDataList"), argumentList );
}
......
......@@ -389,7 +389,7 @@ void NFSProtocolV2::listDir(const QUrl& url)
int rpcStatus;
readlinkres readLinkRes;
char nameBuf[NFS_MAXPATHLEN];
if (readLink(filePath, rpcStatus, readLinkRes, nameBuf)) {
if (symLinkTarget(filePath, rpcStatus, readLinkRes, nameBuf)) {
const QString linkDest = QString::fromLocal8Bit(readLinkRes.readlinkres_u.data);
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, linkDest);
......@@ -486,7 +486,7 @@ void NFSProtocolV2::stat(const QUrl& url)
int rpcStatus;
readlinkres readLinkRes;
char nameBuf[NFS_MAXPATHLEN];
if (readLink(path, rpcStatus, readLinkRes, nameBuf)) {
if (symLinkTarget(path, rpcStatus, readLinkRes, nameBuf)) {
linkDest = QString::fromLocal8Bit(readLinkRes.readlinkres_u.data);
} else {
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, i18n("Unknown target"));
......@@ -840,7 +840,7 @@ void NFSProtocolV2::copySame(const QUrl& src, const QUrl& dest, int _mode, KIO::
int rpcStatus;
readlinkres readLinkRes;
char nameBuf[NFS_MAXPATHLEN];
if (!readLink(srcPath, rpcStatus, readLinkRes, nameBuf)) {
if (!symLinkTarget(srcPath, rpcStatus, readLinkRes, nameBuf)) {
m_slave->error(KIO::ERR_DOES_NOT_EXIST, srcPath);
return;
}
......@@ -1063,7 +1063,7 @@ void NFSProtocolV2::copyFrom(const QUrl& src, const QUrl& dest, int _mode, KIO::
int rpcStatus;
readlinkres readLinkRes;
char nameBuf[NFS_MAXPATHLEN];
if (!readLink(srcPath, rpcStatus, readLinkRes, nameBuf)) {
if (!symLinkTarget(srcPath, rpcStatus, readLinkRes, nameBuf)) {
m_slave->error(KIO::ERR_DOES_NOT_EXIST, srcPath);
return;
}
......@@ -1219,11 +1219,11 @@ void NFSProtocolV2::copyFrom(const QUrl& src, const QUrl& dest, int _mode, KIO::
if (!mtimeStr.isEmpty()) {
QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate);
if (dt.isValid()) {
qCDebug(LOG_KIO_NFS) << "Setting modification time to" << dt.toTime_t();
qCDebug(LOG_KIO_NFS) << "Setting modification time to" << dt.toSecsSinceEpoch();
struct utimbuf utbuf;
utbuf.actime = QFileInfo(destPath).lastRead().toTime_t(); // access time, unchanged
utbuf.modtime = dt.toTime_t(); // modification time
utbuf.actime = QFileInfo(destPath).lastRead().toSecsSinceEpoch(); // access time, unchanged
utbuf.modtime = dt.toSecsSinceEpoch(); // modification time
utime(QFile::encodeName(destPath).constData(), &utbuf);
}
}
......@@ -1421,7 +1421,7 @@ void NFSProtocolV2::copyTo(const QUrl& src, const QUrl& dest, int _mode, KIO::Jo
if (dt.isValid()) {
sattr attributes;
memset(&attributes, 0xFF, sizeof(attributes));
attributes.mtime.seconds = dt.toTime_t();
attributes.mtime.seconds = dt.toSecsSinceEpoch();
attributes.mtime.useconds = attributes.mtime.seconds * 1000000ULL;
int rpcStatus;
......@@ -1572,7 +1572,7 @@ bool NFSProtocolV2::lookupHandle(const QString& path, int& rpcStatus, diropres&
return (rpcStatus == RPC_SUCCESS && result.status == NFS_OK);
}
bool NFSProtocolV2::readLink(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer)
bool NFSProtocolV2::symLinkTarget(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer)
{
const NFSFileHandle fh = getFileHandle(path);
......
......@@ -67,7 +67,7 @@ private:
bool lookupHandle(const QString& path, int& rpcStatus, diropres& result);
bool readLink(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer);
bool symLinkTarget(const QString& path, int& rpcStatus, readlinkres& result, char* dataBuffer);
// Calls @remove, but with dummy rpcStatus and result arguments
bool remove(const QString& path);
......
......@@ -406,7 +406,7 @@ void NFSProtocolV3::listDir(const QUrl& url)
int rpcStatus;
READLINK3res readLinkRes;
char nameBuf[NFS3_MAXPATHLEN];
if (readLink(filePath, rpcStatus, readLinkRes, nameBuf)) {
if (symLinkTarget(filePath, rpcStatus, readLinkRes, nameBuf)) {
QString linkDest = QString::fromLocal8Bit(readLinkRes.READLINK3res_u.resok.data);
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, linkDest);
......@@ -571,7 +571,7 @@ void NFSProtocolV3::listDirCompat(const QUrl& url)
int rpcStatus;
READLINK3res readLinkRes;
char nameBuf[NFS3_MAXPATHLEN];
if (readLink(filePath, rpcStatus, readLinkRes, nameBuf)) {
if (symLinkTarget(filePath, rpcStatus, readLinkRes, nameBuf)) {
const QString linkDest = QString::fromLocal8Bit(readLinkRes.READLINK3res_u.resok.data);
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, linkDest);
......@@ -671,7 +671,7 @@ void NFSProtocolV3::stat(const QUrl& url)
int rpcStatus;
READLINK3res readLinkRes;
char nameBuf[NFS3_MAXPATHLEN];
if (readLink(path, rpcStatus, readLinkRes, nameBuf)) {
if (symLinkTarget(path, rpcStatus, readLinkRes, nameBuf)) {
linkDest = QString::fromLocal8Bit(readLinkRes.READLINK3res_u.resok.data);
} else {
entry.insert(KIO::UDSEntry::UDS_LINK_DEST, linkDest);
......@@ -1085,7 +1085,7 @@ void NFSProtocolV3::copySame(const QUrl& src, const QUrl& dest, int _mode, KIO::
int rpcStatus;
READLINK3res readLinkRes;
char nameBuf[NFS3_MAXPATHLEN];
if (!readLink(srcPath, rpcStatus, readLinkRes, nameBuf)) {
if (!symLinkTarget(srcPath, rpcStatus, readLinkRes, nameBuf)) {
m_slave->error(KIO::ERR_DOES_NOT_EXIST, srcPath);
return;
}
......@@ -1314,7 +1314,7 @@ void NFSProtocolV3::copyFrom(const QUrl& src, const QUrl& dest, int _mode, KIO::
int rpcStatus;
READLINK3res readLinkRes;
char nameBuf[NFS3_MAXPATHLEN];
if (!readLink(srcPath, rpcStatus, readLinkRes, nameBuf)) {
if (!symLinkTarget(srcPath, rpcStatus, readLinkRes, nameBuf)) {
m_slave->error(KIO::ERR_DOES_NOT_EXIST, srcPath);
return;
}
......@@ -1476,8 +1476,8 @@ void NFSProtocolV3::copyFrom(const QUrl& src, const QUrl& dest, int _mode, KIO::
QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate);
if (dt.isValid()) {
struct utimbuf utbuf;
utbuf.actime = QFileInfo(destPath).lastRead().toTime_t(); // access time, unchanged
utbuf.modtime = dt.toTime_t(); // modification time
utbuf.actime = QFileInfo(destPath).lastRead().toSecsSinceEpoch(); // access time, unchanged
utbuf.modtime = dt.toSecsSinceEpoch(); // modification time
utime(QFile::encodeName(destPath).constData(), &utbuf);
}
}
......@@ -1683,7 +1683,7 @@ void NFSProtocolV3::copyTo(const QUrl& src, const QUrl& dest, int _mode, KIO::Jo
sattr3 attributes;
memset(&attributes, 0, sizeof(attributes));
attributes.mtime.set_it = SET_TO_CLIENT_TIME;
attributes.mtime.set_mtime_u.mtime.seconds = dt.toTime_t();
attributes.mtime.set_mtime_u.mtime.seconds = dt.toSecsSinceEpoch();
attributes.mtime.set_mtime_u.mtime.nseconds = attributes.mtime.set_mtime_u.mtime.seconds * 1000000000ULL;
int rpcStatus;
......@@ -1868,7 +1868,7 @@ bool NFSProtocolV3::lookupHandle(const QString& path, int& rpcStatus, LOOKUP3res
return (rpcStatus == RPC_SUCCESS && result.status == NFS3_OK);
}
bool NFSProtocolV3::readLink(const QString& path, int& rpcStatus, READLINK3res& result, char* dataBuffer)
bool NFSProtocolV3::symLinkTarget(const QString& path, int& rpcStatus, READLINK3res& result, char* dataBuffer)
{
qCDebug(LOG_KIO_NFS) << path;
......
......@@ -71,7 +71,7 @@ private:
bool lookupHandle(const QString& path, int& rpcStatus, LOOKUP3res& result);
bool readLink(const QString& path, int& rpcStatus, READLINK3res& result, char* dataBuffer);
bool symLinkTarget(const QString& path, int& rpcStatus, READLINK3res& result, char* dataBuffer);
// Calls @remove, but with dummy rpcStatus and result arguments
bool remove(const QString& path);
......
......@@ -1874,7 +1874,7 @@ sftpProtocol::StatusCode sftpProtocol::sftpPut(const QUrl& url, int permissions,
sftp_attributes attr = sftp_lstat(mSftp, dest_orig_c.constData());
if (attr != nullptr) {
times[0].tv_sec = attr->atime; //// access time, unchanged
times[1].tv_sec = dt.toTime_t(); // modification time
times[1].tv_sec = dt.toSecsSinceEpoch(); // modification time
times[0].tv_usec = times[1].tv_usec = 0;
qCDebug(KIO_SFTP_LOG) << "Trying to restore mtime for " << dest_orig << " to: " << mtimeStr;
......
......@@ -418,8 +418,8 @@ void SMBSlave::smbCopyGet(const QUrl& ksrc, const QUrl& kdst, int permissions, K
QDateTime dt = QDateTime::fromString(mtimeStr, Qt::ISODate);
if (dt.isValid()) {
struct utimbuf utbuf;
utbuf.actime = QFileInfo(file).lastRead().toTime_t(); // access time, unchanged
utbuf.modtime = dt.toTime_t(); // modification time
utbuf.actime = QFileInfo(file).lastRead().toSecsSinceEpoch(); // access time, unchanged
utbuf.modtime = dt.toSecsSinceEpoch(); // modification time
utime(QFile::encodeName(dstFile).constData(), &utbuf);
}
}
......@@ -603,7 +603,7 @@ void SMBSlave::smbCopyPut(const QUrl& ksrc, const QUrl& kdst, int permissions, K
if ( dt.isValid() ) {
struct utimbuf utbuf;
utbuf.actime = st.st_atime; // access time, unchanged
utbuf.modtime = dt.toTime_t(); // modification time
utbuf.modtime = dt.toSecsSinceEpoch(); // modification time
smbc_utime( dstUrl.toSmbcUrl(), &utbuf );
}
}
......
......@@ -454,7 +454,7 @@ void SMBSlave::put( const QUrl& kurl,
if (cache_stat( m_current_url, &st ) == 0) {
struct utimbuf utbuf;
utbuf.actime = st.st_atime; // access time, unchanged
utbuf.modtime = dt.toTime_t(); // modification time
utbuf.modtime = dt.toSecsSinceEpoch(); // modification time
smbc_utime( m_current_url.toSmbcUrl(), &utbuf );
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment