File indexing completed on 2024-05-12 05:22:07

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Daniel Vrátil <dvratil@kde.org>
0003  *
0004  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005  */
0006 
0007 #include "about.h"
0008 #include "change.h"
0009 #include "drives.h"
0010 #include "file.h"
0011 #include "teamdrive.h"
0012 #include "testutils.h"
0013 
0014 #include <QFile>
0015 
0016 KGAPI2::Drive::AboutPtr aboutFromFile(const QString &path)
0017 {
0018     QFile f(path);
0019     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0020 
0021     auto about = KGAPI2::Drive::About::fromJSON(f.readAll());
0022     VERIFY_RET(about, {});
0023     return about;
0024 }
0025 
0026 KGAPI2::Drive::ChangePtr changeFromFile(const QString &path)
0027 {
0028     QFile f(path);
0029     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0030 
0031     auto change = KGAPI2::Drive::Change::fromJSON(f.readAll());
0032     VERIFY_RET(change, {});
0033     return change;
0034 }
0035 
0036 KGAPI2::Drive::FilePtr fileFromFile(const QString &path)
0037 {
0038     QFile f(path);
0039     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0040 
0041     auto file = KGAPI2::Drive::File::fromJSON(f.readAll());
0042     VERIFY_RET(file, {});
0043     return file;
0044 }
0045 
0046 KGAPI2::Drive::DrivesPtr drivesFromFile(const QString &path)
0047 {
0048     QFile f(path);
0049     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0050 
0051     auto drives = KGAPI2::Drive::Drives::fromJSON(f.readAll());
0052     VERIFY_RET(drives, {});
0053     return drives;
0054 }
0055 
0056 KGAPI2::Drive::TeamdrivePtr teamdriveFromFile(const QString &path)
0057 {
0058     QFile f(path);
0059     VERIFY_RET(f.open(QIODevice::ReadOnly), {});
0060 
0061     auto teamdrive = KGAPI2::Drive::Teamdrive::fromJSON(f.readAll());
0062     VERIFY_RET(teamdrive, {});
0063     return teamdrive;
0064 }