File: gdrive.h

package info (click to toggle)
freefilesync 13.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,044 kB
  • sloc: cpp: 66,712; ansic: 447; makefile: 216
file content (44 lines) | stat: -rw-r--r-- 2,158 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under    *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0          *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************

#ifndef FS_GDRIVE_9238425018342701356
#define FS_GDRIVE_9238425018342701356

#include "abstract.h"

namespace fff
{
bool         acceptsItemPathPhraseGdrive(const Zstring& itemPathPhrase); //noexcept
AbstractPath createItemPathGdrive       (const Zstring& itemPathPhrase); //noexcept

void gdriveInit(const Zstring& configDirPath,   //directory to store Google-Drive-specific files
                const Zstring& caCertFilePath); //cacert.pem
void gdriveTeardown();

//-------------------------------------------------------

//caveat: gdriveAddUser() blocks indefinitely if user doesn't log in with Google! timeoutSec is only regarding HTTP requests
std::string /*account email*/ gdriveAddUser(const std::function<void()>& updateGui /*throw X*/, int timeoutSec); //throw FileError, X
void                          gdriveRemoveUser(const std::string& accountEmail, int timeoutSec);                 //throw FileError

std::vector<std::string /*account email*/> gdriveListAccounts(); //throw FileError
std::vector<Zstring /*locationName*/> gdriveListLocations(const std::string& accountEmail, int timeoutSec); //throw FileError

struct GdriveLogin
{
    std::string email;
    Zstring locationName; //empty for "My Drive"; can be a shared drive or starred folder name
    int timeoutSec = 10; //Gdrive can "hang" for 20 seconds when "scanning for viruses": https://freefilesync.org/forum/viewtopic.php?t=9116
};

AfsDevice condenseToGdriveDevice(const GdriveLogin& login); //noexcept; potentially messy user input
GdriveLogin extractGdriveLogin(const AfsDevice& afsDevice); //noexcept

//return empty, if not a Google Drive path
Zstring getGoogleDriveFolderUrl(const AbstractPath& folderPath); //throw FileError
}

#endif //FS_GDRIVE_9238425018342701356