Hello community, here is the log from the commit of package kio-gdrive for openSUSE:Factory checked in at 2017-02-16 17:06:25 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kio-gdrive (Old) and /work/SRC/openSUSE:Factory/.kio-gdrive.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "kio-gdrive" Changes: -------- --- /work/SRC/openSUSE:Factory/kio-gdrive/kio-gdrive.changes 2017-01-12 15:57:37.700304399 +0100 +++ /work/SRC/openSUSE:Factory/.kio-gdrive.new/kio-gdrive.changes 2017-02-16 17:06:26.300069051 +0100 @@ -1,0 +2,13 @@ +Tue Feb 14 20:52:33 UTC 2017 - [email protected] + +- Update to 1.1.1 + * Fixed wrong write permissions in the top-level accounts folder. + +------------------------------------------------------------------- +Thu Jan 26 11:36:51 UTC 2017 - [email protected] + +- Update to 1.1.0 + * Feature release + * No changelog, see https://eang.it/kio-gdrive-1-1-released/ + +------------------------------------------------------------------- Old: ---- kio-gdrive-1.0.5.tar.xz New: ---- kio-gdrive-1.1.1.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kio-gdrive.spec ++++++ --- /var/tmp/diff_new_pack.a7I3Ur/_old 2017-02-16 17:06:26.620023779 +0100 +++ /var/tmp/diff_new_pack.a7I3Ur/_new 2017-02-16 17:06:26.624023213 +0100 @@ -1,7 +1,7 @@ # # spec file for package kio-gdrive # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %bcond_without lang Name: kio-gdrive -Version: 1.0.5 +Version: 1.1.1 Release: 0 Summary: Google Drive KIO-slave for KDE applications License: GPL-2.0+ @@ -56,7 +56,6 @@ %install %kf5_makeinstall -C build - %suse_update_desktop_file org.kde.kio-gdrive Network FileTransfer KDE %if %{with lang} %find_lang kio5_gdrive %{name}.lang %endif @@ -64,8 +63,10 @@ %files %defattr(-,root,root) %doc COPYING README.md README.packagers +%doc %lang(en) %{_kf5_htmldir}/en/kioslave5/gdrive/ %{_kf5_plugindir}/kf5/ -%{_kf5_applicationsdir}/org.kde.kio-gdrive.desktop +%dir %{_datadir}/remoteview +%{_datadir}/remoteview/gdrive-network.desktop %if %{with lang} %files lang -f %{name}.lang ++++++ kio-gdrive-1.0.5.tar.xz -> kio-gdrive-1.1.1.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/CMakeLists.txt new/kio-gdrive-1.1.1/CMakeLists.txt --- old/kio-gdrive-1.0.5/CMakeLists.txt 2017-01-10 22:30:16.000000000 +0100 +++ new/kio-gdrive-1.1.1/CMakeLists.txt 2017-02-13 11:03:31.000000000 +0100 @@ -4,7 +4,7 @@ include(FeatureSummary) -set(PROJECT_VERSION 1.0.5) +set(PROJECT_VERSION 1.1.1) set(QT_MIN_VERSION 5.2.0) set(KF5_MIN_VERSION 5.14.0) @@ -37,30 +37,26 @@ URL "https://github.com/frankosterfeld/qtkeychain" PURPOSE "Required for secure storage of accounts secrets.") -#find_package(Qt5Test QUIET) -#set_package_properties(Qt5Test PROPERTIES -# TYPE OPTIONAL -# PURPOSE "Required for building tests.") - -#if(NOT Qt5Test_FOUND) -# set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") -#endif() +find_package(Qt5Test QUIET) +set_package_properties(Qt5Test PROPERTIES + TYPE OPTIONAL + PURPOSE "Required for building tests.") + +if(NOT Qt5Test_FOUND) + set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") +endif() ecm_setup_version(${PROJECT_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\") -# FIXME: tests are currently broken. -#add_subdirectory(autotests) - -option(DOLPHIN_INTEGRATION "Whether to install the .desktop file for Dolphin integration." ON) -if(DOLPHIN_INTEGRATION) - add_subdirectory(desktop) -endif() - +add_subdirectory(autotests) +add_subdirectory(desktop) +add_subdirectory(doc) add_subdirectory(src) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/README.md new/kio-gdrive-1.1.1/README.md --- old/kio-gdrive-1.0.5/README.md 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/README.md 2017-02-13 10:55:12.000000000 +0100 @@ -1,3 +1,4 @@ +https://community.kde.org/KIO_GDrive Hello there, lonely wanderer and welcome to the magical land of Google Drive! @@ -12,8 +13,7 @@ $ sudo make install $ kdeinit5 # or just re-login -Now you are ready to use the slave. Either click on "Google Drive File Manager" -in the application launcher (which will open Dolphin with the `gdrive:/` URL) or run: +Now you are ready to use the slave. Either click the "Network" button in Dolphin or run: $ kioclient5 exec gdrive:/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/README.packagers new/kio-gdrive-1.1.1/README.packagers --- old/kio-gdrive-1.0.5/README.packagers 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/README.packagers 2017-02-13 10:55:12.000000000 +0100 @@ -3,8 +3,7 @@ KIO GDrive requires a KIO-enabled file manager at runtime, otherwise there is no way to setup a Google Drive account. -This can be Dolphin or Gwenview or (the unreleased) Konqueror. +This can be Dolphin or Gwenview or Konqueror. -The slave installs a .desktop file that enables Dolphin integration -in the applications launcher (if Dolphin is installed). -This can be prevented by passing `-DDOLPHIN_INTEGRATION=OFF` to cmake. +The slave installs a .desktop file that enables integration with +the Dolphin's Places panel and the Plasma's Folder View widget. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/autotests/CMakeLists.txt new/kio-gdrive-1.1.1/autotests/CMakeLists.txt --- old/kio-gdrive-1.0.5/autotests/CMakeLists.txt 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/autotests/CMakeLists.txt 2017-02-13 10:55:12.000000000 +0100 @@ -1,7 +1,14 @@ include(ECMAddTests) ecm_add_test( - listtest.cpp - LINK_LIBRARIES Qt5::Test KF5::KIOCore - TEST_NAME listtest + urltest.cpp ../src/gdriveurl.cpp + LINK_LIBRARIES Qt5::Test + TEST_NAME urltest NAME_PREFIX kio_gdrive-) + +# FIXME: this test is currently broken for Jenkins +#ecm_add_test( +# listtest.cpp +# LINK_LIBRARIES Qt5::Test KF5::KIOCore +# TEST_NAME listtest +# NAME_PREFIX kio_gdrive-) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/autotests/listtest.cpp new/kio-gdrive-1.1.1/autotests/listtest.cpp --- old/kio-gdrive-1.0.5/autotests/listtest.cpp 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/autotests/listtest.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Elvis Angelaccio <[email protected]> + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> * * 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/autotests/urltest.cpp new/kio-gdrive-1.1.1/autotests/urltest.cpp --- old/kio-gdrive-1.0.5/autotests/urltest.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/autotests/urltest.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> + * + * 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) any later version. + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "../src/gdriveurl.h" + +#include <QTest> + +class UrlTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void testGDriveUrl_data(); + void testGDriveUrl(); +}; + +QTEST_GUILESS_MAIN(UrlTest) + +void UrlTest::testGDriveUrl_data() +{ + QTest::addColumn<QUrl>("url"); + QTest::addColumn<QString>("expectedAccount"); + QTest::addColumn<QString>("expectedParentPath"); + QTest::addColumn<QStringList>("expectedPathComponents"); + + QTest::newRow("root url") + << QUrl(QStringLiteral("gdrive://")) + << QString() + << QString() + << QStringList(); + + QTest::newRow("account root url") + << QUrl(QStringLiteral("gdrive:///[email protected]")) + << QStringLiteral("[email protected]") + << QStringLiteral("/") + << QStringList {QStringLiteral("[email protected]")}; + + QTest::newRow("file in account root") + << QUrl(QStringLiteral("gdrive:///[email protected]/bar.txt")) + << QStringLiteral("[email protected]") + << QStringLiteral("/[email protected]") + << QStringList {QStringLiteral("[email protected]"), QStringLiteral("bar.txt")}; + + QTest::newRow("folder in account root - no trailing slash") + << QUrl(QStringLiteral("gdrive:///[email protected]/bar")) + << QStringLiteral("[email protected]") + << QStringLiteral("/[email protected]") + << QStringList {QStringLiteral("[email protected]"), QStringLiteral("bar")}; + QTest::newRow("folder in account root - trailing slash") + << QUrl(QStringLiteral("gdrive:///[email protected]/bar/")) + << QStringLiteral("[email protected]") + << QStringLiteral("/[email protected]") + << QStringList {QStringLiteral("[email protected]"), QStringLiteral("bar")}; + + QTest::newRow("file in subfolder") + << QUrl(QStringLiteral("gdrive:///[email protected]/bar/baz.txt")) + << QStringLiteral("[email protected]") + << QStringLiteral("/[email protected]/bar") + << QStringList {QStringLiteral("[email protected]"), QStringLiteral("bar"), QStringLiteral("baz.txt")}; +} + +void UrlTest::testGDriveUrl() +{ + QFETCH(QUrl, url); + QFETCH(QString, expectedAccount); + QFETCH(QString, expectedParentPath); + QFETCH(QStringList, expectedPathComponents); + + const auto gdriveUrl = GDriveUrl(url); + + QCOMPARE(gdriveUrl.account(), expectedAccount); + QCOMPARE(gdriveUrl.parentPath(), expectedParentPath); + QCOMPARE(gdriveUrl.pathComponents(), expectedPathComponents); + + if (expectedPathComponents.isEmpty()) { + QVERIFY(gdriveUrl.isRoot()); + } else if (expectedPathComponents.count() == 1) { + QVERIFY(gdriveUrl.isAccountRoot()); + } +} + +#include "urltest.moc" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/desktop/CMakeLists.txt new/kio-gdrive-1.1.1/desktop/CMakeLists.txt --- old/kio-gdrive-1.0.5/desktop/CMakeLists.txt 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/desktop/CMakeLists.txt 2017-02-13 10:55:12.000000000 +0100 @@ -1,2 +1,2 @@ -install(PROGRAMS org.kde.kio-gdrive.desktop - DESTINATION ${KDE_INSTALL_APPDIR}) +install(FILES gdrive-network.desktop + DESTINATION ${KDE_INSTALL_DATADIR}/remoteview) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/desktop/gdrive-network.desktop new/kio-gdrive-1.1.1/desktop/gdrive-network.desktop --- old/kio-gdrive-1.0.5/desktop/gdrive-network.desktop 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/desktop/gdrive-network.desktop 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,19 @@ +[Desktop Entry] +Icon=folder-gdrive +Name=Google Drive +Name[ca]=Google Drive +Name[ca@valencia]=Google Drive +Name[en_GB]=Google Drive +Name[es]=Google Drive +Name[it]=Google Drive +Name[ko]=Google 드라이브 +Name[nl]=Google Drive +Name[pl]=Dysk Google +Name[pt]=Google Drive +Name[pt_BR]=Google Drive +Name[sk]=Google Drive +Name[sv]=Google Drive +Name[uk]=Google Диск +Name[x-test]=xxGoogle Drivexx +Type=Link +URL=gdrive:/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/desktop/org.kde.kio-gdrive.desktop new/kio-gdrive-1.1.1/desktop/org.kde.kio-gdrive.desktop --- old/kio-gdrive-1.0.5/desktop/org.kde.kio-gdrive.desktop 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/desktop/org.kde.kio-gdrive.desktop 1970-01-01 01:00:00.000000000 +0100 @@ -1,49 +0,0 @@ -[Desktop Entry] -Name=Dolphin (Google Drive) -Name[ca]=Dolphin (Google Drive) -Name[ca@valencia]=Dolphin (Google Drive) -Name[cs]=Dolphin (Google Drive) -Name[de]=Dolphin (Google Drive) -Name[en_GB]=Dolphin (Google Drive) -Name[es]=Dolphin (Google Drive) -Name[et]=Dolphin (Google Drive) -Name[fr]=Dolphin (Google Drive) -Name[it]=Dolphin (Google Drive) -Name[nl]=Dolphin (Google Drive) -Name[pl]=Dolphin (Dysk Google) -Name[pt]=Dolphin (Google Drive) -Name[pt_BR]=Dolphin (Google Drive) -Name[sk]=Dolphin (Google Drive) -Name[sv]=Dolphin (Google Drive) -Name[uk]=Dolphin (Google Диск) -Name[x-test]=xxDolphin (Google Drive)xx -Name[zh_CN]=Dolphin (Google Drive) -Name[zh_TW]=Dolphin(Google 雲端硬碟) -GenericName=Google Drive File Manager -GenericName[ca]=Gestor de fitxers amb el Google Drive -GenericName[ca@valencia]=Gestor de fitxers amb el Google Drive -GenericName[cs]=Správce souborů Google Drive -GenericName[de]=„Google Drive“-Dateiverwaltung -GenericName[en_GB]=Google Drive File Manager -GenericName[es]=Gestor de archivos para Google Drive -GenericName[et]=Google Drive'i failihaldur -GenericName[fr]=Gestionnaire de fichiers Google Drive -GenericName[it]=Gestione file di Google Drive -GenericName[nl]=Bestandsbeheerder voor Google Drive -GenericName[pl]=Zarządzanie plikami Dysku Google -GenericName[pt]=Gestor de Ficheiros do Google Drive -GenericName[pt_BR]=Gerenciador de arquivos do Google Drive -GenericName[sk]=Správca súborov Google Drive -GenericName[sv]=Google Drive-filhanterare -GenericName[uk]=Засіб керування файлами Google Диск -GenericName[x-test]=xxGoogle Drive File Managerxx -GenericName[zh_CN]=Google Drive 文件管理器 -GenericName[zh_TW]=Google 雲端硬碟檔案管理員 -Categories=Qt;KDE;Network; -TryExec=dolphin -Exec=dolphin gdrive:// -Icon=system-file-manager -NoDisplay=false -StartupNotify=true -Terminal=false -Type=Application diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/doc/CMakeLists.txt new/kio-gdrive-1.1.1/doc/CMakeLists.txt --- old/kio-gdrive-1.0.5/doc/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/doc/CMakeLists.txt 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,3 @@ +kdoctools_create_handbook(index.docbook + INSTALL_DESTINATION ${KDE_INSTALL_DOCBUNDLEDIR}/en + SUBDIR kioslave5/gdrive) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/doc/index.docbook new/kio-gdrive-1.1.1/doc/index.docbook --- old/kio-gdrive-1.0.5/doc/index.docbook 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/doc/index.docbook 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,41 @@ +<?xml version="1.0" ?> +<!DOCTYPE article PUBLIC "-//KDE//DTD DocBook XML V4.5-Based Variant V1.1//EN" "dtd/kdedbx45.dtd" [ +<!ENTITY % addindex "IGNORE"> +<!ENTITY % English "INCLUDE" > +]> + +<article lang="&language;" id="gdrive"> +<title>gdrive</title> + +<articleinfo> + +<authorgroup> + <author><firstname>Elvis</firstname><surname>Angelaccio</surname> + <affiliation> + <address> + <email>[email protected]</email> + </address> + </affiliation> + </author> +<!-- TRANS:ROLES_OF_TRANSLATORS --> +</authorgroup> + +<date>2016-10-03</date> +<releaseinfo>kio-gdrive 1.0.1</releaseinfo> + +</articleinfo> + +<para>KIO GDrive allows you to access and edit your Google Drive files using KDE applications that support KIO.</para> + +<para>You can use the gdrive kioslave like this:</para> +<para><userinput>gdrive://</userinput> or <userinput>gdrive://<replaceable>[email protected]</replaceable></userinput>.</para> + +<para>The first URL shows an OAuth login dialog from Google, if no Drive account has been authenticated yet, +or the list of your authenticated accounts instead.</para> + +<para>The <userinput>gdrive://</userinput> URL can also be used at any time to add an additional account.</para> + +<para>The URL <userinput>gdrive://<replaceable>[email protected]</replaceable></userinput> lists all the files and folders +from the top level of the <userinput>[email protected]</userinput> Drive account.</para> + +</article> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/gdrive.json new/kio-gdrive-1.1.1/gdrive.json --- old/kio-gdrive-1.0.5/gdrive.json 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/gdrive.json 2017-02-13 10:55:12.000000000 +0100 @@ -4,7 +4,8 @@ "Class": ":internet", "ExtraNames": [ ], - "Icon": "im-google", + "Icon": "folder-gdrive", + "X-DocPath": "kioslave5/gdrive/index.html", "deleteRecursive": true, "deleting": true, "exec": "kf5/kio/gdrive", diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/po/ar/kio5_gdrive.po new/kio-gdrive-1.1.1/po/ar/kio5_gdrive.po --- old/kio-gdrive-1.0.5/po/ar/kio5_gdrive.po 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/po/ar/kio5_gdrive.po 2017-02-13 11:00:10.000000000 +0100 @@ -0,0 +1,25 @@ +# Copyright (C) YEAR This_file_is_part_of_KDE +# This file is distributed under the same license as the PACKAGE package. +# +# Safa Alfulaij <[email protected]>, 2017. +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2016-11-19 20:16+0100\n" +"PO-Revision-Date: 2017-01-23 10:59+0300\n" +"Last-Translator: Safa Alfulaij <[email protected]>\n" +"Language-Team: Arabic <[email protected]>\n" +"Language: ar\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=6; plural=n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 " +"&& n%100<=10 ? 3 : n%100>=11 && n%100<=99 ? 4 : 5;\n" +"X-Generator: Lokalize 2.0\n" + +#: kio_gdrive.cpp:212 +#, kde-format +msgctxt "login in a new google account" +msgid "New account" +msgstr "حساب جديد" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/po/ko/kio5_gdrive.po new/kio-gdrive-1.1.1/po/ko/kio5_gdrive.po --- old/kio-gdrive-1.0.5/po/ko/kio5_gdrive.po 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/po/ko/kio5_gdrive.po 2017-02-13 11:01:46.000000000 +0100 @@ -0,0 +1,24 @@ +# Copyright (C) YEAR This_file_is_part_of_KDE +# This file is distributed under the same license as the PACKAGE package. +# Shinjo Park <[email protected]>, 2017. +# +msgid "" +msgstr "" +"Project-Id-Version: \n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2016-11-19 20:16+0100\n" +"PO-Revision-Date: 2017-01-22 21:17+0100\n" +"Last-Translator: Shinjo Park <[email protected]>\n" +"Language-Team: Korean <[email protected]>\n" +"Language: ko\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Lokalize 2.0\n" + +#: kio_gdrive.cpp:212 +#, kde-format +msgctxt "login in a new google account" +msgid "New account" +msgstr "새 계정" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/CMakeLists.txt new/kio-gdrive-1.1.1/src/CMakeLists.txt --- old/kio-gdrive-1.0.5/src/CMakeLists.txt 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/CMakeLists.txt 2017-02-13 10:55:12.000000000 +0100 @@ -5,7 +5,8 @@ kio_gdrive.cpp pathcache.cpp accountmanager.cpp - gdrivehelper.cpp) + gdrivehelper.cpp + gdriveurl.cpp) ecm_qt_declare_logging_category(kio_gdrive_SRCS HEADER gdrivedebug.h diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/accountmanager.cpp new/kio-gdrive-1.1.1/src/accountmanager.cpp --- old/kio-gdrive-1.0.5/src/accountmanager.cpp 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/accountmanager.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Daniel Vrátil <[email protected]> + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> * * 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 @@ -54,10 +55,10 @@ if (accountName.isEmpty() || !accounts().contains(accountName)) { account = KGAPI2::AccountPtr(new KGAPI2::Account(accountName)); - account->addScope(QUrl("https://www.googleapis.com/auth/drive")); - account->addScope(QUrl("https://www.googleapis.com/auth/drive.file")); - account->addScope(QUrl("https://www.googleapis.com/auth/drive.metadata.readonly")); - account->addScope(QUrl("https://www.googleapis.com/auth/drive.readonly")); + account->addScope(QUrl(QStringLiteral("https://www.googleapis.com/auth/drive"))); + account->addScope(QUrl(QStringLiteral("https://www.googleapis.com/auth/drive.file"))); + account->addScope(QUrl(QStringLiteral("https://www.googleapis.com/auth/drive.metadata.readonly"))); + account->addScope(QUrl(QStringLiteral("https://www.googleapis.com/auth/drive.readonly"))); KGAPI2::AuthJob *authJob = new KGAPI2::AuthJob(account, s_apiKey, s_apiSecret); @@ -129,8 +130,8 @@ entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, accountNAme); entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); entry.insert(KIO::UDSEntry::UDS_SIZE, 0); - entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); - entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("im-google")); + entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); + entry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("folder-gdrive")); return entry; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/accountmanager.h new/kio-gdrive-1.1.1/src/accountmanager.h --- old/kio-gdrive-1.0.5/src/accountmanager.h 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/accountmanager.h 2017-02-13 10:55:12.000000000 +0100 @@ -1,5 +1,6 @@ /* * Copyright (C) 2014 Daniel Vrátil <[email protected]> + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> * * 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 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/gdrivehelper.cpp new/kio-gdrive-1.1.1/src/gdrivehelper.cpp --- old/kio-gdrive-1.0.5/src/gdrivehelper.cpp 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/gdrivehelper.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -50,49 +50,40 @@ namespace GDriveHelper { -static const QMap<QString /* mimetype */, QString /* .ext */> ExtensionsMap = []() { - QMap<QString, QString> ext; - ext[VND_OASIS_OPENDOCUMENT_TEXT] = QStringLiteral(".odt"); - ext[VND_OASIS_OPENDOCUMENT_SPREADSHEED] = QStringLiteral(".ods"); - ext[VND_OASIS_OPENDOCUMENT_PRESENTATION] = QStringLiteral(".odp"); - ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT] = QStringLiteral(".docx"); - ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET] = QStringLiteral(".xlsx"); - ext[VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION] = QStringLiteral(".pptx"); - ext[IMAGE_PNG] = QStringLiteral(".png"); - ext[IMAGE_JPEG] = QStringLiteral(".jpg"); - ext[APPLICATION_PDF] = QStringLiteral(".pdf"); - return ext; -}(); +static const QMap<QString /* mimetype */, QString /* .ext */> ExtensionsMap{ + { VND_OASIS_OPENDOCUMENT_TEXT, QStringLiteral(".odt") }, + { VND_OASIS_OPENDOCUMENT_SPREADSHEED, QStringLiteral(".ods") }, + { VND_OASIS_OPENDOCUMENT_PRESENTATION, QStringLiteral(".odp") }, + { VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT, QStringLiteral(".docx") }, + { VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET, QStringLiteral(".xlsx") }, + { VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION, QStringLiteral(".pptx") }, + { IMAGE_PNG, QStringLiteral(".png") }, + { IMAGE_JPEG, QStringLiteral(".jpg") }, + { APPLICATION_PDF, QStringLiteral(".pdf") } +}; -static const QMap<QString /* mimetype */, QStringList /* target mimetypes */ > ConversionMap = []() { - QMap<QString, QStringList> map; - - map[VND_GOOGLE_APPS_DOCUMENT] = QStringList { +static const QMap<QString /* mimetype */, QStringList /* target mimetypes */ > ConversionMap{ + { VND_GOOGLE_APPS_DOCUMENT, { VND_OASIS_OPENDOCUMENT_TEXT, VND_OPENXMLFORMATS_OFFICEDOCUMENT_WORDPROCESSINGML_DOCUMENT, - APPLICATION_PDF - }; - - map[VND_GOOGLE_APPS_DRAWING] = QStringList { + APPLICATION_PDF } + }, + { VND_GOOGLE_APPS_DRAWING, { IMAGE_PNG, IMAGE_JPEG, - APPLICATION_PDF - }; - - map[VND_GOOGLE_APPS_PRESENTATION] = QStringList { + APPLICATION_PDF } + }, + { VND_GOOGLE_APPS_PRESENTATION, { VND_OASIS_OPENDOCUMENT_PRESENTATION, VND_OPENXMLFORMATS_OFFICEDOCUMENT_PRESENTATIONML_PRESENTATION, - APPLICATION_PDF - }; - - map[VND_GOOGLE_APPS_SPREADSHEET] = QStringList { + APPLICATION_PDF } + }, + { VND_GOOGLE_APPS_SPREADSHEET, { VND_OASIS_OPENDOCUMENT_SPREADSHEED, VND_OPENXMLFORMATS_OFFICEDOCUMENT_SPREADSHEETML_SHEET, - APPLICATION_PDF - }; - - return map; -}(); + APPLICATION_PDF } + } +}; } @@ -109,16 +100,18 @@ QUrl GDriveHelper::convertFromGDocs(KGAPI2::Drive::FilePtr &file) { const QString originalMimeType = file->mimeType(); - if (!GDriveHelper::ConversionMap.contains(originalMimeType)) { + auto convIt = GDriveHelper::ConversionMap.constFind(originalMimeType); + if (convIt == GDriveHelper::ConversionMap.cend()) { return file->downloadUrl(); } const auto exportLinks = file->exportLinks(); - Q_FOREACH (const QString &targetMimeType, GDriveHelper::ConversionMap[originalMimeType]) { - if (exportLinks.contains(targetMimeType)) { + Q_FOREACH (const QString &targetMimeType, convIt.value()) { + const auto linkIt = exportLinks.constFind(targetMimeType); + if (linkIt != exportLinks.cend()) { file->setMimeType(targetMimeType); file->setTitle(file->title() + GDriveHelper::ExtensionsMap[targetMimeType]); - return exportLinks[targetMimeType]; + return *linkIt; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/gdriveurl.cpp new/kio-gdrive-1.1.1/src/gdriveurl.cpp --- old/kio-gdrive-1.0.5/src/gdriveurl.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/gdriveurl.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2014 Daniel Vrátil <[email protected]> + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> + * + * 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) any later version. + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "gdriveurl.h" + +GDriveUrl::GDriveUrl(const QUrl &url) + : m_url(url) +{ + const auto path = url.adjusted(QUrl::StripTrailingSlash).path(); + m_components = path.split(QLatin1Char('/'), QString::SkipEmptyParts); +} + +QString GDriveUrl::account() const +{ + if (isRoot()) { + return QString(); + } + + return m_components.at(0); +} + +bool GDriveUrl::isRoot() const +{ + return m_components.isEmpty(); +} + +bool GDriveUrl::isAccountRoot() const +{ + return m_components.length() == 1; +} + +QString GDriveUrl::parentPath() const +{ + if (isRoot()) { + return QString(); + } + + auto path = m_components; + path.removeLast(); + + return QLatin1Char('/') + path.join(QLatin1Char('/')); +} + +QStringList GDriveUrl::pathComponents() const +{ + return m_components; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/gdriveurl.h new/kio-gdrive-1.1.1/src/gdriveurl.h --- old/kio-gdrive-1.0.5/src/gdriveurl.h 1970-01-01 01:00:00.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/gdriveurl.h 2017-02-13 10:55:12.000000000 +0100 @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2014 Daniel Vrátil <[email protected]> + * Copyright (c) 2016 Elvis Angelaccio <[email protected]> + * + * 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) any later version. + * + * 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, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef GDRIVEURL_U +#define GDRIVEURL_U + +#include <QUrl> + +class GDriveUrl +{ +public: + explicit GDriveUrl(const QUrl &url); + + QString account() const; + bool isRoot() const; + bool isAccountRoot() const; + QString parentPath() const; + QStringList pathComponents() const; + +private: + QUrl m_url; + QStringList m_components; +}; + +#endif // GDRIVEURL_U diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/kio_gdrive.cpp new/kio-gdrive-1.1.1/src/kio_gdrive.cpp --- old/kio-gdrive-1.0.5/src/kio_gdrive.cpp 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/kio_gdrive.cpp 2017-02-13 10:55:12.000000000 +0100 @@ -20,6 +20,7 @@ #include "kio_gdrive.h" #include "gdrivedebug.h" #include "gdrivehelper.h" +#include "gdriveurl.h" #include "gdriveversion.h" #include <QApplication> @@ -58,18 +59,6 @@ Q_PLUGIN_METADATA(IID "org.kde.kio.slave.gdrive" FILE "gdrive.json") }; -static QString joinSublist(const QStringList &strv, int start, int end, const QChar &joinChar) -{ - QString res = joinChar; - for (int i = start; i <= end; ++i) { - res += strv[i]; - if (i < end) { - res += joinChar; - } - } - return res; -} - extern "C" { int Q_DECL_EXPORT kdemain(int argc, char **argv) @@ -112,13 +101,13 @@ return Success; case KGAPI2::AuthCancelled: case KGAPI2::AuthError: - error(KIO::ERR_COULD_NOT_LOGIN, url.toDisplayString()); + error(KIO::ERR_CANNOT_LOGIN, url.toDisplayString()); return Fail; case KGAPI2::Unauthorized: { const AccountPtr oldAccount = job.account(); const AccountPtr account = m_accountManager.refreshAccount(oldAccount); if (!account) { - error(KIO::ERR_COULD_NOT_LOGIN, url.toDisplayString()); + error(KIO::ERR_CANNOT_LOGIN, url.toDisplayString()); return Fail; } return Restart; @@ -165,7 +154,7 @@ entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG); entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, file->mimeType()); entry.insert(KIO::UDSEntry::UDS_SIZE, file->fileSize()); - entry.insert(KIO::UDSEntry::UDS_URL, QString::fromLatin1("gdrive://%1/%2?id=%3").arg(path, origFile->title(), origFile->id())); + entry.insert(KIO::UDSEntry::UDS_URL, QStringLiteral("gdrive://%1/%2?id=%3").arg(path, origFile->title(), origFile->id())); } entry.insert(KIO::UDSEntry::UDS_CREATION_TIME, file->createdDate().toTime_t()); @@ -196,36 +185,13 @@ -QStringList KIOGDrive::pathComponents(const QString &path) const -{ - return path.split(QLatin1Char('/'), QString::SkipEmptyParts); -} - -QString KIOGDrive::accountFromPath(const QUrl &url) const -{ - const QStringList components = pathComponents(url); - if (components.isEmpty()) { - return QString(); - } - return components[0]; -} - -bool KIOGDrive::isRoot(const QUrl &url) const -{ - return pathComponents(url).length() == 0; -} - -bool KIOGDrive::isAccountRoot(const QUrl &url) const -{ - return pathComponents(url).length() == 1; -} void KIOGDrive::createAccount() { const KGAPI2::AccountPtr account = m_accountManager.account(QString()); - redirection(QUrl(QString::fromLatin1("gdrive:/%1").arg(account->accountName()))); + redirection(QUrl(QStringLiteral("gdrive:/%1").arg(account->accountName()))); finished(); } @@ -247,6 +213,15 @@ newAccountEntry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); newAccountEntry.insert(KIO::UDSEntry::UDS_ICON_NAME, QStringLiteral("list-add-user")); listEntry(newAccountEntry); + + // Create also non-writable UDSentry for "." + KIO::UDSEntry entry; + entry.insert(KIO::UDSEntry::UDS_NAME, QStringLiteral(".")); + entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR); + entry.insert(KIO::UDSEntry::UDS_SIZE, 0); + entry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + listEntry(entry); + finished(); return; } @@ -263,6 +238,9 @@ --sDepth; } + RecursionDepthCounter(const RecursionDepthCounter &) = delete; + RecursionDepthCounter& operator=(const RecursionDepthCounter &) = delete; + int depth() const { return sDepth; @@ -278,10 +256,6 @@ QString KIOGDrive::resolveFileIdFromPath(const QString &path, PathFlags flags) { qCDebug(GDRIVE) << Q_FUNC_INFO << path; - RecursionDepthCounter recursion; - if (recursion.depth() == 1) { - m_cache.dump(); - } if (path.isEmpty()) { return QString(); @@ -293,19 +267,21 @@ return fileId; } - const QStringList components = pathComponents(path); - Q_ASSERT(!components.isEmpty()); - if (components.size() == 1 || (components.size() == 2 && components[1] == QLatin1String("trash"))) { + QUrl url; + url.setScheme(QStringLiteral("gdrive")); + url.setPath(path); + const auto gdriveUrl = GDriveUrl(url); + Q_ASSERT(!gdriveUrl.isRoot()); + + const QStringList components = gdriveUrl.pathComponents(); + if (gdriveUrl.isAccountRoot() || (components.size() == 2 && components[1] == QLatin1String("trash"))) { qCDebug(GDRIVE) << "Resolved" << path << "to \"root\""; return rootFolderId(components[0]); } - QString parentName; - Q_ASSERT(components.size() >= 2); - const QString parentPath = joinSublist(components, 0, components.size() - 2, QLatin1Char('/')); // Try to recursively resolve ID of parent path - either from cache, or by // querying Google - const QString parentId = resolveFileIdFromPath(parentPath, KIOGDrive::PathIsFolder); + const QString parentId = resolveFileIdFromPath(gdriveUrl.parentPath(), KIOGDrive::PathIsFolder); if (parentId.isEmpty()) { // We failed to resolve parent -> error return QString(); @@ -321,10 +297,7 @@ query.addQuery(FileSearchQuery::Parents, FileSearchQuery::In, parentId); query.addQuery(FileSearchQuery::Trashed, FileSearchQuery::Equals, components[1] == QLatin1String("trash")); - QUrl url; - url.setScheme(QStringLiteral("gdrive")); - url.setPath(path); - const QString accountId = accountFromPath(url); + const QString accountId = gdriveUrl.account(); FileFetchJob fetchJob(query, getAccount(accountId)); fetchJob.setFields(FileFetchJob::Id | FileFetchJob::Title | FileFetchJob::Labels); if (!runJob(fetchJob, url, accountId)) { @@ -348,7 +321,8 @@ QString KIOGDrive::rootFolderId(const QString &accountId) { - if (!m_rootIds.contains(accountId)) { + auto it = m_rootIds.constFind(accountId); + if (it == m_rootIds.cend()) { AboutFetchJob aboutFetch(getAccount(accountId)); QUrl url; if (!runJob(aboutFetch, url, accountId)) { @@ -361,29 +335,29 @@ return QString(); } - m_rootIds.insert(accountId, about->rootFolderId()); - return about->rootFolderId(); + auto v = m_rootIds.insert(accountId, about->rootFolderId()); + return *v; } - return m_rootIds[accountId]; + return *it; } void KIOGDrive::listDir(const QUrl &url) { qCDebug(GDRIVE) << "Going to list" << url; - const QString accountId = accountFromPath(url); + const auto gdriveUrl = GDriveUrl(url); + const QString accountId = gdriveUrl.account(); if (accountId == QLatin1String("new-account")) { createAccount(); return; } QString folderId; - const QStringList components = pathComponents(url); - if (components.isEmpty()) { + if (gdriveUrl.isRoot()) { listAccounts(); return; - } else if (components.size() == 1) { + } else if (gdriveUrl.isAccountRoot()) { folderId = rootFolderId(accountId); } else { folderId = m_cache.idForPath(url.path()); @@ -439,18 +413,19 @@ qCDebug(GDRIVE) << "Creating directory" << url; - const QString accountId = accountFromPath(url); - const QStringList components = pathComponents(url); - QString parentId; + const auto gdriveUrl = GDriveUrl(url); + const QString accountId = gdriveUrl.account(); // At least account and new folder name - if (components.size() < 2) { + if (gdriveUrl.isRoot() || gdriveUrl.isAccountRoot()) { error(KIO::ERR_DOES_NOT_EXIST, url.path()); return; - } else if (components.size() == 2) { + } + QString parentId; + const auto components = gdriveUrl.pathComponents(); + if (components.size() == 2) { parentId = rootFolderId(accountId); } else { - const QString subpath = joinSublist(components, 0, components.size() - 2, QLatin1Char('/')); - parentId = resolveFileIdFromPath(subpath, KIOGDrive::PathIsFolder); + parentId = resolveFileIdFromPath(gdriveUrl.parentPath(), KIOGDrive::PathIsFolder); } if (parentId.isEmpty()) { @@ -477,13 +452,14 @@ { qCDebug(GDRIVE) << "Going to stat()" << url; - const QString accountId = accountFromPath(url); - const QStringList components = pathComponents(url); - if (components.isEmpty()) { + const auto gdriveUrl = GDriveUrl(url); + const QString accountId = gdriveUrl.account(); + if (gdriveUrl.isRoot()) { // TODO Can we stat() root? finished(); return; - } else if (components.size() == 1) { + } + if (gdriveUrl.isAccountRoot()) { const KIO::UDSEntry entry = AccountManager::accountToUDSEntry(accountId); statEntry(entry); finished(); @@ -491,8 +467,8 @@ } const QString fileId - = url.hasQueryItem(QLatin1String("id")) - ? QUrlQuery(url).queryItemValue(QLatin1String("id")) + = url.hasQueryItem(QStringLiteral("id")) + ? QUrlQuery(url).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), KIOGDrive::None); if (fileId.isEmpty()) { @@ -515,7 +491,7 @@ return; } - const KIO::UDSEntry entry = fileToUDSEntry(file, joinSublist(components, 0, components.size() - 2, QLatin1Char('/'))); + const KIO::UDSEntry entry = fileToUDSEntry(file, gdriveUrl.parentPath()); statEntry(entry); finished(); @@ -525,21 +501,22 @@ { qCDebug(GDRIVE) << "Fetching content of" << url; - const QString accountId = accountFromPath(url); - const QStringList components = pathComponents(url); + const auto gdriveUrl = GDriveUrl(url); + const QString accountId = gdriveUrl.account(); - if (components.isEmpty()) { + if (gdriveUrl.isRoot()) { error(KIO::ERR_DOES_NOT_EXIST, url.path()); return; - } else if (components.size() == 1) { + } + if (gdriveUrl.isAccountRoot()) { // You cannot GET an account folder! error(KIO::ERR_ACCESS_DENIED, url.path()); return; } const QString fileId = - url.hasQueryItem(QLatin1String("id")) - ? QUrlQuery(url).queryItemValue(QLatin1String("id")) + url.hasQueryItem(QStringLiteral("id")) + ? QUrlQuery(url).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), KIOGDrive::PathIsFile); if (fileId.isEmpty()) { @@ -588,7 +565,7 @@ // TODO: Support resumable upload (requires support in LibKGAPI) if (!tempFile.open()) { - error(KIO::ERR_COULD_NOT_WRITE, tempFile.fileName()); + error(KIO::ERR_CANNOT_WRITE, tempFile.fileName()); return false; } @@ -600,7 +577,7 @@ if (!buffer.isEmpty()) { qint64 size = tempFile.write(buffer); if (size != buffer.size()) { - error(KIO::ERR_COULD_NOT_WRITE, tempFile.fileName()); + error(KIO::ERR_CANNOT_WRITE, tempFile.fileName()); return false; } } @@ -609,7 +586,7 @@ if (result == -1) { qCWarning(GDRIVE) << "Could not read source file" << tempFile.fileName(); - error(KIO::ERR_COULD_NOT_READ, QString()); + error(KIO::ERR_CANNOT_READ, QString()); return false; } @@ -638,11 +615,14 @@ return true; } -bool KIOGDrive::putUpdate(const QUrl &url, const QString &accountId, const QStringList &pathComponents) +bool KIOGDrive::putUpdate(const QUrl &url) { const QString fileId = QUrlQuery(url).queryItemValue(QStringLiteral("id")); qCDebug(GDRIVE) << Q_FUNC_INFO << url << fileId; + const auto gdriveUrl = GDriveUrl(url); + const auto accountId = gdriveUrl.account(); + FileFetchJob fetchJob(fileId, getAccount(accountId)); if (!runJob(fetchJob, url, accountId)) { return false; @@ -650,14 +630,14 @@ const ObjectsList objects = fetchJob.items(); if (objects.size() != 1) { - putCreate(url, accountId, pathComponents); + putCreate(url); return false; } const FilePtr file = objects[0].dynamicCast<File>(); QTemporaryFile tmpFile; if (!readPutData(tmpFile)) { - error(KIO::ERR_COULD_NOT_READ, url.path()); + error(KIO::ERR_CANNOT_READ, url.path()); return false; } @@ -670,17 +650,21 @@ return true; } -bool KIOGDrive::putCreate(const QUrl &url, const QString &accountId, const QStringList &components) +bool KIOGDrive::putCreate(const QUrl &url) { qCDebug(GDRIVE) << Q_FUNC_INFO << url; ParentReferencesList parentReferences; - if (components.size() < 2) { + + const auto gdriveUrl = GDriveUrl(url); + if (gdriveUrl.isRoot() || gdriveUrl.isAccountRoot()) { error(KIO::ERR_ACCESS_DENIED, url.path()); return false; - } else if (components.length() == 2) { + } + const auto components = gdriveUrl.pathComponents(); + if (components.length() == 2) { // Creating in root directory } else { - const QString parentId = resolveFileIdFromPath(joinSublist(components, 0, components.size() - 2, QLatin1Char('/'))); + const QString parentId = resolveFileIdFromPath(gdriveUrl.parentPath()); if (parentId.isEmpty()) { error(KIO::ERR_DOES_NOT_EXIST, url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()); return false; @@ -701,10 +685,11 @@ QTemporaryFile tmpFile; if (!readPutData(tmpFile)) { - error(KIO::ERR_COULD_NOT_READ, url.path()); + error(KIO::ERR_CANNOT_READ, url.path()); return false; } + const auto accountId = gdriveUrl.account(); FileCreateJob createJob(tmpFile.fileName(), file, getAccount(accountId)); if (!runJob(createJob, url, accountId)) { return false; @@ -724,15 +709,12 @@ qCDebug(GDRIVE) << Q_FUNC_INFO << url; - const QString accountId = accountFromPath(url); - const QStringList components = pathComponents(url); - if (url.hasQueryItem(QStringLiteral("id"))) { - if (!putUpdate(url, accountId, components)) { + if (!putUpdate(url)) { return; } } else { - if (!putCreate(url, accountId, components)) { + if (!putCreate(url)) { return; } } @@ -745,6 +727,8 @@ void KIOGDrive::copy(const QUrl &src, const QUrl &dest, int permissions, KIO::JobFlags flags) { + qCDebug(GDRIVE) << "Going to copy" << src << "to" << dest; + // NOTE: We deliberately ignore the permissions field here, because GDrive // does not recognize any privileges that could be mapped to standard UNIX // file permissions. @@ -757,8 +741,10 @@ // name will be created. Q_UNUSED(flags); - const QString sourceAccountId = accountFromPath(src); - const QString destAccountId = accountFromPath(dest); + const auto srcGDriveUrl = GDriveUrl(src); + const auto destGDriveUrl = GDriveUrl(dest); + const QString sourceAccountId = srcGDriveUrl.account(); + const QString destAccountId = destGDriveUrl.account(); // TODO: Does this actually happen, or does KIO treat our account name as host? if (sourceAccountId != destAccountId) { @@ -767,17 +753,17 @@ return; } - const QStringList srcPathComps = pathComponents(src); - if (srcPathComps.isEmpty()) { + if (srcGDriveUrl.isRoot()) { error(KIO::ERR_DOES_NOT_EXIST, src.path()); return; - } else if (srcPathComps.size() == 1) { + } + if (srcGDriveUrl.isAccountRoot()) { error(KIO::ERR_ACCESS_DENIED, src.path()); return; } const QString sourceFileId - = src.hasQueryItem(QLatin1String("id")) + = src.hasQueryItem(QStringLiteral("id")) ? QUrlQuery(src).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path()); if (sourceFileId.isEmpty()) { @@ -797,12 +783,13 @@ const FilePtr sourceFile = objects[0].dynamicCast<File>(); - const QStringList destPathComps = pathComponents(dest); ParentReferencesList destParentReferences; - if (destPathComps.isEmpty()) { + if (destGDriveUrl.isRoot()) { error(KIO::ERR_ACCESS_DENIED, dest.path()); return; - } else if (destPathComps.size() == 1) { + } + const auto destPathComps = destGDriveUrl.pathComponents(); + if (destGDriveUrl.isAccountRoot()) { // copy to root } else { const QString destDirId = destPathComps[destPathComps.count() - 2]; @@ -840,19 +827,19 @@ qCDebug(GDRIVE) << "Deleting URL" << url << "- is it a file?" << isfile; const QString fileId - = isfile && url.hasQueryItem(QLatin1String("id")) - ? QUrlQuery(url).queryItemValue(QLatin1String("id")) + = isfile && url.hasQueryItem(QStringLiteral("id")) + ? QUrlQuery(url).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path(), isfile ? KIOGDrive::PathIsFile : KIOGDrive::PathIsFolder); if (fileId.isEmpty()) { error(KIO::ERR_DOES_NOT_EXIST, url.path()); return; } - const QString accountId = accountFromPath(url); - const QStringList components = pathComponents(url); + const auto gdriveUrl = GDriveUrl(url); + const QString accountId = gdriveUrl.account(); // If user tries to delete the account folder, remove the account from the keychain - if (components.count() == 1) { + if (gdriveUrl.isAccountRoot()) { const KGAPI2::AccountPtr account = m_accountManager.account(accountId); if (!account) { error(KIO::ERR_DOES_NOT_EXIST, accountId); @@ -871,8 +858,8 @@ runJob(referencesFetch, url, accountId); const bool isEmpty = !referencesFetch.items().count(); - if (!isEmpty && metaData("recurse") != QLatin1String("true")) { - error(KIO::ERR_COULD_NOT_RMDIR, url.path()); + if (!isEmpty && metaData(QStringLiteral("recurse")) != QLatin1String("true")) { + error(KIO::ERR_CANNOT_RMDIR, url.path()); return; } } @@ -891,8 +878,10 @@ Q_UNUSED(flags) qCDebug(GDRIVE) << "Renaming" << src << "to" << dest; - const QString sourceAccountId = accountFromPath(src); - const QString destAccountId = accountFromPath(dest); + const auto srcGDriveUrl = GDriveUrl(src); + const auto destGDriveUrl = GDriveUrl(dest); + const QString sourceAccountId = srcGDriveUrl.account(); + const QString destAccountId = destGDriveUrl.account(); // TODO: Does this actually happen, or does KIO treat our account name as host? if (sourceAccountId != destAccountId) { @@ -900,17 +889,17 @@ return; } - const QStringList srcPathComps = pathComponents(src); - if (srcPathComps.isEmpty()) { + if (srcGDriveUrl.isRoot()) { error(KIO::ERR_DOES_NOT_EXIST, dest.path()); return; - } else if (srcPathComps.size() == 1) { + } + if (srcGDriveUrl.isAccountRoot()) { error(KIO::ERR_ACCESS_DENIED, dest.path()); return; } const QString sourceFileId - = src.hasQueryItem(QLatin1String("id")) - ? QUrlQuery(src).queryItemValue(QLatin1String("id")) + = src.hasQueryItem(QStringLiteral("id")) + ? QUrlQuery(src).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(src.adjusted(QUrl::StripTrailingSlash).path(), KIOGDrive::PathIsFile); if (sourceFileId.isEmpty()) { @@ -932,19 +921,19 @@ const FilePtr sourceFile = objects[0].dynamicCast<File>(); ParentReferencesList parentReferences = sourceFile->parents(); - const QStringList destPathComps = pathComponents(dest); - if (destPathComps.isEmpty()) { - // paths.size == 0 -> error, user is trying to move to top-level gdrive:/// + if (destGDriveUrl.isRoot()) { + // user is trying to move to top-level gdrive:/// error(KIO::ERR_ACCESS_DENIED, dest.fileName()); return; - } else if (destPathComps.size() == 1) { + } + const auto srcPathComps = srcGDriveUrl.pathComponents(); + const auto destPathComps = destGDriveUrl.pathComponents(); + if (destGDriveUrl.isAccountRoot()) { // user is trying to move to root -> we are only renaming } else { // skip filename and extract the second-to-last component - const QString destDirId = resolveFileIdFromPath(joinSublist(destPathComps, 0, destPathComps.count() - 2, QLatin1Char('/')), - KIOGDrive::PathIsFolder); - const QString srcDirId = resolveFileIdFromPath(joinSublist(srcPathComps, 0, srcPathComps.count() - 2, QLatin1Char('/')), - KIOGDrive::PathIsFolder); + const QString destDirId = resolveFileIdFromPath(destGDriveUrl.parentPath(), KIOGDrive::PathIsFolder); + const QString srcDirId = resolveFileIdFromPath(srcGDriveUrl.parentPath(), KIOGDrive::PathIsFolder); // Remove source from parent references auto iter = parentReferences.begin(); @@ -986,14 +975,14 @@ qCDebug(GDRIVE) << Q_FUNC_INFO << url; const QString fileId - = url.hasQueryItem(QLatin1String("id")) - ? QUrlQuery(url).queryItemValue(QLatin1String("id")) + = url.hasQueryItem(QStringLiteral("id")) + ? QUrlQuery(url).queryItemValue(QStringLiteral("id")) : resolveFileIdFromPath(url.adjusted(QUrl::StripTrailingSlash).path()); if (fileId.isEmpty()) { error(KIO::ERR_DOES_NOT_EXIST, url.path()); return; } - const QString accountId = accountFromPath(url); + const QString accountId = GDriveUrl(url).account(); FileFetchJob fileFetchJob(fileId, getAccount(accountId)); fileFetchJob.setFields(FileFetchJob::Id | FileFetchJob::MimeType); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/kio-gdrive-1.0.5/src/kio_gdrive.h new/kio-gdrive-1.1.1/src/kio_gdrive.h --- old/kio-gdrive-1.0.5/src/kio_gdrive.h 2017-01-10 21:53:51.000000000 +0100 +++ new/kio-gdrive-1.1.1/src/kio_gdrive.h 2017-02-13 10:55:12.000000000 +0100 @@ -62,6 +62,8 @@ virtual void mimetype(const QUrl &url) Q_DECL_OVERRIDE; private: + Q_DISABLE_COPY(KIOGDrive) + enum PathFlags { None = 0, PathIsFolder = 1, @@ -76,14 +78,7 @@ Action handleError(const KGAPI2::Job &job, const QUrl &url); KIO::UDSEntry fileToUDSEntry(const KGAPI2::Drive::FilePtr &file, const QString &path) const; - QStringList pathComponents(const QString &path) const; - QStringList pathComponents(const QUrl &url) const { - return pathComponents(url.adjusted(QUrl::StripTrailingSlash).path()); - } - bool isRoot(const QUrl &url) const; - bool isAccountRoot(const QUrl &url) const; - QString accountFromPath(const QUrl &url) const; KGAPI2::AccountPtr getAccount(const QString &accountName) { return m_accountManager.account(accountName); @@ -91,8 +86,8 @@ QString rootFolderId(const QString &accountId); - bool putUpdate(const QUrl &url, const QString &accountId, const QStringList &pathComponents); - bool putCreate(const QUrl &url, const QString &accountId, const QStringList &pathComponents); + bool putUpdate(const QUrl &url); + bool putCreate(const QUrl &url); bool readPutData(QTemporaryFile &tmpFile); /**
