...
 
Commits (9)
cmake_minimum_required(VERSION 3.0)
set(GDRIVE_VERSION 1.3.70)
project(kio-gdrive VERSION ${GDRIVE_VERSION})
# KDE Application Version, managed by release script
set (RELEASE_SERVICE_VERSION_MAJOR "20")
set (RELEASE_SERVICE_VERSION_MINOR "11")
set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(kio-gdrive VERSION ${RELEASE_SERVICE_VERSION})
set(QT_MIN_VERSION 5.2.0)
set(KF5_MIN_VERSION 5.71.0)
......@@ -54,16 +58,13 @@ if(NOT Qt5Test_FOUND)
set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.")
endif()
ecm_setup_version(PROJECT
ecm_setup_version(${RELEASE_SERVICE_VERSION}
VARIABLE_PREFIX GDRIVE
VERSION_HEADER gdriveversion.h)
add_definitions(-DQT_NO_URL_CAST_FROM_STRING)
add_definitions(-DQT_STRICT_ITERATORS)
add_definitions(-DTRANSLATION_DOMAIN=\"kio5_gdrive\")
if (EXISTS "${CMAKE_SOURCE_DIR}/.git")
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x060000)
endif()
if(BUILD_TESTING)
add_subdirectory(autotests)
......
......@@ -139,6 +139,9 @@
<image type="source" width="1664" height="936">https://cdn.kde.org/screenshots/kio-gdrive/kio-gdrive.png</image>
</screenshot>
</screenshots>
<releases>
<release date="2020-04-12" version="1.3.0"/>
</releases>
<project_group>KDE</project_group>
<categories>
<category>Network</category>
......
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_BINARY_DIR})
add_subdirectory(integration)
set(kio_gdrive_SRCS
kio_gdrive.cpp
pathcache.cpp
......@@ -43,12 +45,3 @@ target_link_libraries(kio_gdrive
${BACKEND_LIBS})
set_target_properties(kio_gdrive PROPERTIES OUTPUT_NAME "gdrive")
kcoreaddons_add_plugin(copyurlitemaction
SOURCES copyurlitemaction.cpp
JSON copyurlitemaction.json
INSTALL_NAMESPACE "kf5/kfileitemaction")
target_link_libraries(copyurlitemaction
KF5::I18n
KF5::KIOWidgets)
/*
* Copyright 2020 David Barchiesi <david@barchie.si>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GDRIVEUDSENTRY_H
#define GDRIVEUDSENTRY_H
#include <KIO/UDSEntry>
enum GDriveUDSEntryExtras {
Url = KIO::UDSEntry::UDS_EXTRA,
Id,
Md5,
Owners,
Version,
LastModifyingUser,
Description
};
#endif // GDRIVEUDSENTRY_H
......@@ -30,7 +30,7 @@ GDriveUrl::GDriveUrl(const QUrl &url)
: m_url(url)
{
const auto path = url.adjusted(QUrl::StripTrailingSlash).path();
m_components = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
m_components = path.split(QLatin1Char('/'), Qt::SkipEmptyParts);
}
QString GDriveUrl::account() const
......
add_subdirectory(copyurlitemaction)
add_subdirectory(propertiesplugin)
kcoreaddons_add_plugin(gdrivecopyurlitemaction
SOURCES copyurlitemaction.cpp
JSON copyurlitemaction.json
INSTALL_NAMESPACE "kf5/kfileitemaction")
target_link_libraries(gdrivecopyurlitemaction
KF5::I18n
KF5::KIOWidgets)
......@@ -18,6 +18,7 @@
*/
#include "copyurlitemaction.h"
#include "../../gdrive_udsentry.h"
#include <QGuiApplication>
#include <QClipboard>
......@@ -50,7 +51,7 @@ QList<QAction*> CopyUrlItemAction::actions(const KFileItemListProperties& fileIt
}
const KIO::UDSEntry entry = item.entry();
const QString gdriveLink = entry.stringValue(KIO::UDSEntry::UDS_EXTRA);
const QString gdriveLink = entry.stringValue(GDriveUDSEntryExtras::Url);
// Ignore if missing a shareable link
if (gdriveLink.isEmpty()) {
return {};
......
set(gdrivepropertiesplugin_SRCS
gdrivepropertiesplugin.cpp
../../gdrivedebug.cpp
)
ki18n_wrap_ui(gdrivepropertiesplugin_UI_SRCS gdrivepropertiesplugin.ui)
add_library(gdrivepropertiesplugin MODULE ${gdrivepropertiesplugin_UI_SRCS} ${gdrivepropertiesplugin_SRCS})
target_link_libraries(gdrivepropertiesplugin
KF5::I18n
KF5::KIOWidgets
)
install(TARGETS gdrivepropertiesplugin DESTINATION ${PLUGIN_INSTALL_DIR})
install(FILES gdrivepropertiesplugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
/*
* Copyright 2020 David Barchiesi <d.barchiesi@reply.it>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "gdrivepropertiesplugin.h"
#include "../../gdrivedebug.h"
#include "../../gdrive_udsentry.h"
#include <KPluginFactory>
#include <KPluginLoader>
#include <QClipboard>
#include <QDesktopServices>
K_PLUGIN_FACTORY(GDrivePropertiesPluginFactory, registerPlugin<GDrivePropertiesPlugin>();)
GDrivePropertiesPlugin::GDrivePropertiesPlugin(QObject *parent, const QList<QVariant> &args)
: KPropertiesDialogPlugin(qobject_cast<KPropertiesDialog *>(parent))
{
Q_UNUSED(args);
// Ignore if more than one file is selected
if (properties->items().size() != 1) {
qCDebug(GDRIVE) << "Can't show Google Drive properties tab for more than one item";
return;
}
const KFileItem item = properties->items().at(0);
// Ignore if not a Google Drive url
if (item.url().scheme() != QLatin1String("gdrive")) {
qCDebug(GDRIVE) << "Can't show Google Drive properties for non Google Drive entries";
return;
}
const KIO::UDSEntry entry = item.entry();
ui.setupUi(&widget);
const QString id = entry.stringValue(GDriveUDSEntryExtras::Id);
ui.idValue->setText(id);
const QString created = item.timeString(KFileItem::CreationTime);
ui.createdValue->setText(created);
const QString modified = item.timeString(KFileItem::ModificationTime);
ui.modifiedValue->setText(modified);
const QString lastViewedByMe = item.timeString(KFileItem::AccessTime);
ui.lastViewedByMeValue->setText(lastViewedByMe);
const QString version = entry.stringValue(GDriveUDSEntryExtras::Version);
ui.versionValue->setText(version);
const QString md5 = entry.stringValue(GDriveUDSEntryExtras::Md5);
ui.md5Value->setText(md5);
const QString lastModifyingUserName = entry.stringValue(GDriveUDSEntryExtras::LastModifyingUser);
ui.lastModifiedByValue->setText(lastModifyingUserName);
const QString owners = entry.stringValue(GDriveUDSEntryExtras::Owners);
ui.ownersValue->setText(owners);
const QString description = entry.stringValue(KIO::UDSEntry::UDS_COMMENT);
ui.descriptionValue->setText(description);
const QString gdriveLink = entry.stringValue(GDriveUDSEntryExtras::Url);
connect(ui.urlOpenButton, &QPushButton::clicked, this, [gdriveLink]() {
QDesktopServices::openUrl(QUrl(gdriveLink));
});
connect(ui.urlCopyButton, &QPushButton::clicked, this, [gdriveLink]() {
QGuiApplication::clipboard()->setText(gdriveLink);
});
properties->addPage(&widget, "G&oogle Drive");
}
GDrivePropertiesPlugin::~GDrivePropertiesPlugin() = default;
#include "gdrivepropertiesplugin.moc"
[Desktop Entry]
Type=Service
Icon=folder-gdrive
Name=Google Drive Properties Page
Comment=Properties page showing additional information regarding a Google Drive item
X-KDE-Library=gdrivepropertiesplugin
X-KDE-ServiceTypes=KPropertiesDialog/Plugin
MimeType=inode/directory;application/octet-stream
/*
* Copyright 2020 David Barchiesi <david@barchie.si>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License or (at your option) version 3 or any later version
* accepted by the membership of KDE e.V. (or its successor approved
* by the membership of KDE e.V.), which shall act as a proxy
* defined in Section 14 of version 3 of the license.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GDRIVEPROPERTIESPLUGIN_H
#define GDRIVEPROPERTIESPLUGIN_H
#include <KPropertiesDialog>
#include "ui_gdrivepropertiesplugin.h"
class GDrivePropertiesPlugin : public KPropertiesDialogPlugin
{
Q_OBJECT
public:
explicit GDrivePropertiesPlugin(QObject *parent, const QList<QVariant> &args);
~GDrivePropertiesPlugin() override;
private:
QWidget widget;
Ui::GDrivePropertiesWidget ui;
};
#endif // GDRIVEPROPERTIESPLUGIN_H
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>GDrivePropertiesWidget</class>
<widget class="QWidget" name="GDrivePropertiesWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>783</width>
<height>612</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QFormLayout" name="formLayout">
<property name="formAlignment">
<set>Qt::AlignHCenter|Qt::AlignTop</set>
</property>
<item row="0" column="0">
<widget class="QLabel" name="idLabel">
<property name="text">
<string>Id:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="idValue">
<property name="text">
<string notr="true">idValue</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Description:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLabel" name="descriptionValue">
<property name="text">
<string notr="true">descriptionValue</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="ownersLabel">
<property name="text">
<string>Owners:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLabel" name="ownersValue">
<property name="text">
<string notr="true">ownersValue</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="createdLabel">
<property name="text">
<string>Created:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="createdValue">
<property name="text">
<string notr="true">createdValue</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="modifiedLabel">
<property name="text">
<string>Modified:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QLabel" name="modifiedValue">
<property name="text">
<string notr="true">modifiedValue</string>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lastModifiedByLabel">
<property name="text">
<string>Last modified by:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QLabel" name="lastModifiedByValue">
<property name="text">
<string notr="true">lastModifiedByValue</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lastViewedByMeLabel">
<property name="text">
<string>Last viewed by me:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QLabel" name="lastViewedByMeValue">
<property name="text">
<string notr="true">lastViewedByMeValue</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="versionLabel">
<property name="text">
<string>Version:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="versionValue">
<property name="text">
<string notr="true">versionValue</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="md5Label">
<property name="text">
<string>MD5 checksum:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="md5Value">
<property name="text">
<string notr="true">md5Value</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="betweenFormAndButtonsSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>16</height>
</size>
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="urlOpenButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Open in browser</string>
</property>
<property name="icon">
<iconset theme="internet-services">
<normaloff>.</normaloff>.</iconset>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="urlCopyButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Click to copy the checksum to the clipboard.</string>
</property>
<property name="text">
<string>Copy URL to Clipboard</string>
</property>
<property name="icon">
<iconset theme="edit-copy">
<normaloff>../../../kio/src/widgets</normaloff>../../../kio/src/widgets</iconset>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -23,6 +23,7 @@
#include "gdrivehelper.h"
#include "gdriveurl.h"
#include "gdriveversion.h"
#include "gdrive_udsentry.h"
#include <QApplication>
#include <QMimeDatabase>
......@@ -236,7 +237,12 @@ KIO::UDSEntry KIOGDrive::fileToUDSEntry(const FilePtr &origFile, const QString &
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IXGRP | S_IROTH | S_IXOTH);
}
entry.fastInsert(KIO::UDSEntry::UDS_EXTRA, file->alternateLink().toString());
entry.fastInsert(GDriveUDSEntryExtras::Id, file->id());
entry.fastInsert(GDriveUDSEntryExtras::Url, file->alternateLink().toString());
entry.fastInsert(GDriveUDSEntryExtras::Version, QString::number(file->version()));
entry.fastInsert(GDriveUDSEntryExtras::Md5, file->md5Checksum());
entry.fastInsert(GDriveUDSEntryExtras::LastModifyingUser, file->lastModifyingUserName());
entry.fastInsert(GDriveUDSEntryExtras::Owners, file->ownerNames().join(QStringLiteral(", ")));
return entry;
}
......@@ -508,7 +514,7 @@ QString KIOGDrive::resolveFileIdFromPath(const QString &path, PathFlags flags)
return QString();
}
QString fileId = m_cache.idForPath(path);
const QString fileId = m_cache.idForPath(path);
if (!fileId.isEmpty()) {
qCDebug(GDRIVE) << "Resolved" << path << "to" << fileId << "(from cache)";
return fileId;
......@@ -736,7 +742,11 @@ void KIOGDrive::mkdir(const QUrl &url, int permissions)
void KIOGDrive::stat(const QUrl &url)
{
qCDebug(GDRIVE) << "Going to stat()" << url;
// TODO We should be using StatDetails to limit how we respond to a stat request
const QString statDetails = metaData(QStringLiteral("statDetails"));
KIO::StatDetails details = statDetails.isEmpty() ? KIO::StatDefaultDetails : static_cast<KIO::StatDetails>(statDetails.toInt());
qCDebug(GDRIVE) << "Going to stat()" << url << "for details" << details;
const auto gdriveUrl = GDriveUrl(url);
if (gdriveUrl.isRoot()) {
......