disable clang formatting for now
This commit is contained in:
parent
8baa05fef0
commit
6a5c1960bf
|
|
@ -0,0 +1 @@
|
|||
DisableFormat: true
|
||||
|
|
@ -3,72 +3,17 @@
|
|||
"arguments": [
|
||||
"/usr/bin/c++",
|
||||
"-Dpcloudcc_lib_EXPORTS",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/sqlite",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/pclsync",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/poverlay_linux",
|
||||
"-g",
|
||||
"-fPIC",
|
||||
"-c",
|
||||
"-o",
|
||||
"CMakeFiles/pcloudcc_lib.dir/pclsync_lib_c.cpp.o",
|
||||
"/home/lkn/src/pcloud/console-client/pCloudCC/pclsync_lib_c.cpp"
|
||||
],
|
||||
"directory": "/home/lkn/src/pcloud/console-client/pCloudCC",
|
||||
"file": "/home/lkn/src/pcloud/console-client/pCloudCC/pclsync_lib_c.cpp",
|
||||
"output": "/home/lkn/src/pcloud/console-client/pCloudCC/CMakeFiles/pcloudcc_lib.dir/pclsync_lib_c.cpp.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
"/usr/bin/c++",
|
||||
"-Dpcloudcc_lib_EXPORTS",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/sqlite",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/pclsync",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/poverlay_linux",
|
||||
"-g",
|
||||
"-I/home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/sqlite",
|
||||
"-I/home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/pclsync",
|
||||
"-I/home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/poverlay_linux",
|
||||
"-fPIC",
|
||||
"-c",
|
||||
"-o",
|
||||
"CMakeFiles/pcloudcc_lib.dir/pclsync_lib.cpp.o",
|
||||
"/home/lkn/src/pcloud/console-client/pCloudCC/pclsync_lib.cpp"
|
||||
"/home/lkn/src/my/pcloudcc-lneely/pCloudCC/pclsync_lib.cpp"
|
||||
],
|
||||
"directory": "/home/lkn/src/pcloud/console-client/pCloudCC",
|
||||
"file": "/home/lkn/src/pcloud/console-client/pCloudCC/pclsync_lib.cpp",
|
||||
"output": "/home/lkn/src/pcloud/console-client/pCloudCC/CMakeFiles/pcloudcc_lib.dir/pclsync_lib.cpp.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
"/usr/bin/c++",
|
||||
"-Dpcloudcc_lib_EXPORTS",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/sqlite",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/pclsync",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/poverlay_linux",
|
||||
"-g",
|
||||
"-fPIC",
|
||||
"-c",
|
||||
"-o",
|
||||
"CMakeFiles/pcloudcc_lib.dir/control_tools.cpp.o",
|
||||
"/home/lkn/src/pcloud/console-client/pCloudCC/control_tools.cpp"
|
||||
],
|
||||
"directory": "/home/lkn/src/pcloud/console-client/pCloudCC",
|
||||
"file": "/home/lkn/src/pcloud/console-client/pCloudCC/control_tools.cpp",
|
||||
"output": "/home/lkn/src/pcloud/console-client/pCloudCC/CMakeFiles/pcloudcc_lib.dir/control_tools.cpp.o"
|
||||
},
|
||||
{
|
||||
"arguments": [
|
||||
"/usr/bin/c++",
|
||||
"-DBOOST_PROGRAM_OPTIONS_NO_LIB",
|
||||
"-DBOOST_SYSTEM_NO_LIB",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/sqlite",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/pclsync",
|
||||
"-I/home/lkn/src/pcloud/console-client/pCloudCC/lib/poverlay_linux",
|
||||
"-g",
|
||||
"-c",
|
||||
"-o",
|
||||
"CMakeFiles/pcloudcc.dir/main.cpp.o",
|
||||
"/home/lkn/src/pcloud/console-client/pCloudCC/main.cpp"
|
||||
],
|
||||
"directory": "/home/lkn/src/pcloud/console-client/pCloudCC",
|
||||
"file": "/home/lkn/src/pcloud/console-client/pCloudCC/main.cpp",
|
||||
"output": "/home/lkn/src/pcloud/console-client/pCloudCC/CMakeFiles/pcloudcc.dir/main.cpp.o"
|
||||
"directory": "/home/lkn/src/my/pcloudcc-lneely/pCloudCC",
|
||||
"file": "/home/lkn/src/my/pcloudcc-lneely/pCloudCC/pclsync_lib.cpp",
|
||||
"output": "/home/lkn/src/my/pcloudcc-lneely/pCloudCC/CMakeFiles/pcloudcc_lib.dir/pclsync_lib.cpp.o"
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
|
||||
namespace po = boost::program_options;
|
||||
namespace ct = control_tools;
|
||||
|
||||
namespace cc = console_client;
|
||||
static std::string version = "2.0.1";
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
int
|
||||
main(int argc, char **argv) {
|
||||
std::cout << "pCloud console client v." << version << std::endl;
|
||||
std::string username;
|
||||
std::string password;
|
||||
|
|
@ -19,97 +20,101 @@ int main(int argc, char **argv) {
|
|||
bool passwordsw = false;
|
||||
bool save_pass = false;
|
||||
bool crypto = false;
|
||||
po::variables_map vm;
|
||||
|
||||
try {
|
||||
po::options_description desc("Allowed options");
|
||||
desc.add_options()("help,h", "produce help message")(
|
||||
"username,u", po::value<std::string>(&username),
|
||||
"pCloud account name")("password,p", po::bool_switch(&passwordsw),
|
||||
"Ask pCloud account password")(
|
||||
"crypto,c", po::bool_switch(&crypto),
|
||||
"Ask crypto password")("passascrypto,y", po::value<std::string>(),
|
||||
"Use user password as crypto password also.")(
|
||||
"daemonize,d", po::bool_switch(&daemon), "Daemonize the process.")(
|
||||
"commands ,o", po::bool_switch(&commands),
|
||||
"Parent stays alive and processes commands. ")(
|
||||
"mountpoint,m", po::value<std::string>(),
|
||||
"Mount point where drive to be mounted.")(
|
||||
"commands_only,k", po::bool_switch(&commands_only),
|
||||
"Daemon already started pass only commands")(
|
||||
"newuser,n", po::bool_switch(&newuser),
|
||||
"Switch if this is a new user to be registered.")(
|
||||
"savepassword,s", po::bool_switch(&save_pass),
|
||||
"Save password in database.");
|
||||
|
||||
po::variables_map vm;
|
||||
desc.add_options()
|
||||
("help,h",
|
||||
"Show this help message.")
|
||||
("username,u", po::value<std::string>(&username),
|
||||
"pCloud account name.")
|
||||
("password,p", po::bool_switch(&passwordsw),
|
||||
"Ask for pCloud account password.")
|
||||
("crypto,c", po::bool_switch(&crypto),
|
||||
"Ask for crypto password.")
|
||||
("passascrypto,y", po::value<std::string>(), "User password is the same as crypto password.")
|
||||
("daemonize,d", po::bool_switch(&daemon),
|
||||
"Run the process as a background daemon.")
|
||||
("commands ,o", po::bool_switch(&commands),
|
||||
"Keep parent process alive and process commands. ")
|
||||
("mountpoint,m", po::value<std::string>(),
|
||||
"Specify where pCloud filesystem is mounted.")
|
||||
("commands_only,k", po::bool_switch(&commands_only),
|
||||
"Open command prompt to interact with running daemon.")
|
||||
("newuser,n", po::bool_switch(&newuser),
|
||||
"Register a new pCloud user account.")
|
||||
("savepassword,s", po::bool_switch(&save_pass),
|
||||
"Save user password in the database.");
|
||||
po::store(po::parse_command_line(argc, argv, desc), vm);
|
||||
po::notify(vm);
|
||||
|
||||
if (commands_only) {
|
||||
ct::process_commands();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
memset(argv[i], 0, strlen(argv[i]));
|
||||
if (daemon) {
|
||||
strncpy(argv[0], "pCloudDriveDeamon", strlen(argv[0]));
|
||||
} else {
|
||||
strncpy(argv[0], "pCloudDrive", strlen(argv[0]));
|
||||
}
|
||||
|
||||
if (vm.count("help")) {
|
||||
std::cout << desc << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((!vm.count("username"))) {
|
||||
std::cout << "Username option is required!!!"
|
||||
<< "\n";
|
||||
std::cout << "Username option is required, specify with " <<
|
||||
"-u or --username." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
console_client::clibrary::pclsync_lib::get_lib().set_username(username);
|
||||
|
||||
if (passwordsw) {
|
||||
console_client::clibrary::pclsync_lib::get_lib().get_pass_from_console();
|
||||
if (commands_only) {
|
||||
ct::process_commands();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
memset(argv[i], 0, strlen(argv[i]));
|
||||
}
|
||||
if (daemon) {
|
||||
strncpy(argv[0], "pCloudDriveDeamon", strlen(argv[0]));
|
||||
} else {
|
||||
strncpy(argv[0], "pCloudDrive", strlen(argv[0]));
|
||||
}
|
||||
|
||||
cc::clibrary::pclsync_lib::get_lib().set_username(username);
|
||||
if (passwordsw) {
|
||||
cc::clibrary::pclsync_lib::get_lib().get_pass_from_console();
|
||||
}
|
||||
if (crypto) {
|
||||
console_client::clibrary::pclsync_lib::get_lib().setup_crypto_ = true;
|
||||
if (vm.count("passascrypto"))
|
||||
console_client::clibrary::pclsync_lib::get_lib().set_crypto_pass(
|
||||
password);
|
||||
else {
|
||||
std::cout << "Enter crypto password."
|
||||
<< "\n";
|
||||
console_client::clibrary::pclsync_lib::get_lib()
|
||||
.get_cryptopass_from_console();
|
||||
cc::clibrary::pclsync_lib::get_lib().setup_crypto_ = true;
|
||||
if (vm.count("passascrypto")) {
|
||||
cc::clibrary::pclsync_lib::get_lib()
|
||||
.set_crypto_pass(password);
|
||||
} else {
|
||||
std::cout << "Enter crypto password." << std::endl;
|
||||
cc::clibrary::pclsync_lib::get_lib()
|
||||
.get_cryptopass_from_console();
|
||||
}
|
||||
} else
|
||||
console_client::clibrary::pclsync_lib::get_lib().setup_crypto_ = false;
|
||||
cc::clibrary::pclsync_lib::get_lib().setup_crypto_ = false;
|
||||
|
||||
if (vm.count("mountpoint"))
|
||||
console_client::clibrary::pclsync_lib::get_lib().set_mount(
|
||||
vm["mountpoint"].as<std::string>());
|
||||
if (vm.count("mountpoint")) {
|
||||
cc::clibrary::pclsync_lib::get_lib().set_mount(
|
||||
vm["mountpoint"].as<std::string>());
|
||||
}
|
||||
|
||||
console_client::clibrary::pclsync_lib::get_lib().newuser_ = newuser;
|
||||
console_client::clibrary::pclsync_lib::get_lib().set_savepass(save_pass);
|
||||
console_client::clibrary::pclsync_lib::get_lib().set_daemon(daemon);
|
||||
cc::clibrary::pclsync_lib::get_lib().newuser_ = newuser;
|
||||
cc::clibrary::pclsync_lib::get_lib().set_savepass(save_pass);
|
||||
cc::clibrary::pclsync_lib::get_lib().set_daemon(daemon);
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << "error: " << e.what() << "\n";
|
||||
std::cerr << "error: " << e.what() << std::endl;
|
||||
return 1;
|
||||
} catch (...) {
|
||||
std::cerr << "Exception of unknown type!\n";
|
||||
std::cerr << "Exception of unknown type!" << std::endl;
|
||||
}
|
||||
|
||||
if (daemon)
|
||||
if (daemon) {
|
||||
ct::daemonize(commands);
|
||||
else {
|
||||
if (commands)
|
||||
std::cout << "Option commnads/o ignored."
|
||||
<< "\n";
|
||||
if (!console_client::clibrary::pclsync_lib::get_lib().init())
|
||||
} else {
|
||||
if (commands) {
|
||||
std::cout << "Option commands /o ignored." << std::endl;
|
||||
}
|
||||
if (!cc::clibrary::pclsync_lib::get_lib().init()) {
|
||||
sleep(360000);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1,84 +1,87 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2015 pCloud Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of pCloud Ltd nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL pCloud Ltd BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
Copyright (c) 2013-2015 pCloud Ltd.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met: Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer. Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided with
|
||||
the distribution. Neither the name of pCloud Ltd nor the names of
|
||||
its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud
|
||||
Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
*/
|
||||
|
||||
#include "pclsync_lib.h"
|
||||
#include "psynclib.h"
|
||||
#include "pcompat.h"
|
||||
#include "psynclib.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
namespace cc = console_client;
|
||||
namespace clib = cc::clibrary;
|
||||
|
||||
namespace cc = console_client;
|
||||
namespace clib = cc::clibrary;
|
||||
|
||||
clib::pclsync_lib& clib::pclsync_lib::get_lib(){
|
||||
clib::pclsync_lib &clib::pclsync_lib::get_lib() {
|
||||
static clib::pclsync_lib g_lib;
|
||||
return g_lib;
|
||||
}
|
||||
|
||||
static std::string exec(const char* cmd) {
|
||||
FILE* pipe=popen(cmd, "r");
|
||||
if (!pipe) return "ERROR";
|
||||
char buffer[128];
|
||||
std::string result = "";
|
||||
while (!feof(pipe)) {
|
||||
if (fgets(buffer, 128, pipe) != NULL)
|
||||
result += buffer;
|
||||
static std::string
|
||||
exec(const char *cmd) {
|
||||
FILE *pipe;
|
||||
char buffer[128];
|
||||
std::string result = "";
|
||||
|
||||
pipe = popen(cmd, "r");
|
||||
if (!pipe) {
|
||||
return "ERROR";
|
||||
}
|
||||
while (!feof(pipe)) {
|
||||
if (fgets(buffer, 128, pipe)) {
|
||||
result += buffer;
|
||||
}
|
||||
pclose(pipe);
|
||||
return result;
|
||||
}
|
||||
pclose(pipe);
|
||||
return result;
|
||||
}
|
||||
|
||||
char * clib::pclsync_lib::get_token(){
|
||||
return psync_get_token();
|
||||
}
|
||||
char *clib::pclsync_lib::get_token() { return psync_get_token(); }
|
||||
|
||||
void clib::pclsync_lib::get_pass_from_console()
|
||||
{
|
||||
void clib::pclsync_lib::get_pass_from_console() {
|
||||
do_get_pass_from_console(password_);
|
||||
}
|
||||
|
||||
void clib::pclsync_lib::get_cryptopass_from_console()
|
||||
{
|
||||
void clib::pclsync_lib::get_cryptopass_from_console() {
|
||||
do_get_pass_from_console(crypto_pass_);
|
||||
}
|
||||
|
||||
void clib::pclsync_lib::do_get_pass_from_console(std::string& password)
|
||||
{
|
||||
void clib::pclsync_lib::do_get_pass_from_console(std::string &password) {
|
||||
if (daemon_) {
|
||||
std::cout << "Not able to read password when started as daemon." << std::endl;
|
||||
exit(1);
|
||||
std::cout << "Not able to read password when started as daemon."
|
||||
<< std::endl;
|
||||
exit(1);
|
||||
}
|
||||
#ifdef P_OS_POSIX
|
||||
termios oldt;
|
||||
|
|
@ -95,50 +98,68 @@ void clib::pclsync_lib::do_get_pass_from_console(std::string& password)
|
|||
DWORD modeon;
|
||||
DWORD mode;
|
||||
GetConsoleMode(hStdin, &mode);
|
||||
modeoff = mode & ~ENABLE_ECHO_INPUT;
|
||||
modeon = mode | ENABLE_ECHO_INPUT;
|
||||
modeoff = mode & ~ENABLE_ECHO_INPUT;
|
||||
modeon = mode | ENABLE_ECHO_INPUT;
|
||||
SetConsoleMode(hStdin, modeoff);
|
||||
std::cout << "Please, enter password" << std::endl;
|
||||
getline(std::cin, password);
|
||||
SetConsoleMode(hStdin, modeon);
|
||||
//std::cout << "Password is " << password << std::endl;
|
||||
// std::cout << "Password is " << password << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
void event_handler(psync_eventtype_t event, psync_eventdata_t eventdata){
|
||||
if (event<PEVENT_FIRST_USER_EVENT){
|
||||
if (event&PEVENT_TYPE_FOLDER)
|
||||
std::cout <<"folder event=" << event<<", syncid="<< eventdata.folder->syncid<<", folderid="<<eventdata.folder->folderid<<", name="
|
||||
<<eventdata.folder->name<<", local="<<eventdata.folder->localpath<<", remote="<< eventdata.folder->remotepath<<std::endl;
|
||||
else
|
||||
std::cout <<"file event=" << event<<", syncid="<< eventdata.folder->syncid<<", file="<<eventdata.file->fileid<<", name="
|
||||
<< eventdata.file->name<<", local="<<eventdata.file->localpath<<", remote="<< eventdata.file->remotepath<<std::endl;
|
||||
}
|
||||
else if (event>=PEVENT_FIRST_SHARE_EVENT)
|
||||
std::cout <<"share event=" << event<<", folderid="<< eventdata.share->folderid<<", sharename="<<eventdata.share->sharename<<
|
||||
", email="<< eventdata.share->toemail<<", message="<<eventdata.share->message<<", userid="<< eventdata.share->userid<<
|
||||
", shareid="<<eventdata.share->shareid<<", sharerequestid="<<eventdata.share->sharerequestid<<
|
||||
", created="<<eventdata.share->created<<", canread="<<eventdata.share->canread<<", cancreate="<<eventdata.share->cancreate<<
|
||||
", canmodify="<<eventdata.share->canmodify<<", candelete="<<eventdata.share->candelete<<std::endl;
|
||||
void event_handler(psync_eventtype_t event, psync_eventdata_t eventdata) {
|
||||
if (event < PEVENT_FIRST_USER_EVENT) {
|
||||
if (event & PEVENT_TYPE_FOLDER)
|
||||
std::cout << "folder event=" << event
|
||||
<< ", syncid=" << eventdata.folder->syncid
|
||||
<< ", folderid=" << eventdata.folder->folderid
|
||||
<< ", name=" << eventdata.folder->name
|
||||
<< ", local=" << eventdata.folder->localpath
|
||||
<< ", remote=" << eventdata.folder->remotepath << std::endl;
|
||||
else
|
||||
std::cout << "file event=" << event
|
||||
<< ", syncid=" << eventdata.folder->syncid
|
||||
<< ", file=" << eventdata.file->fileid
|
||||
<< ", name=" << eventdata.file->name
|
||||
<< ", local=" << eventdata.file->localpath
|
||||
<< ", remote=" << eventdata.file->remotepath << std::endl;
|
||||
} else if (event >= PEVENT_FIRST_SHARE_EVENT)
|
||||
std::cout << "share event=" << event
|
||||
<< ", folderid=" << eventdata.share->folderid
|
||||
<< ", sharename=" << eventdata.share->sharename
|
||||
<< ", email=" << eventdata.share->toemail
|
||||
<< ", message=" << eventdata.share->message
|
||||
<< ", userid=" << eventdata.share->userid
|
||||
<< ", shareid=" << eventdata.share->shareid
|
||||
<< ", sharerequestid=" << eventdata.share->sharerequestid
|
||||
<< ", created=" << eventdata.share->created
|
||||
<< ", canread=" << eventdata.share->canread
|
||||
<< ", cancreate=" << eventdata.share->cancreate
|
||||
<< ", canmodify=" << eventdata.share->canmodify
|
||||
<< ", candelete=" << eventdata.share->candelete << std::endl;
|
||||
else
|
||||
std::cout <<"event" << event << std::endl;
|
||||
std::cout << "event" << event << std::endl;
|
||||
}
|
||||
|
||||
static int lib_setup_cripto(){
|
||||
static int lib_setup_cripto() {
|
||||
int ret = 0;
|
||||
ret = psync_crypto_issetup();
|
||||
if (ret) {
|
||||
ret = psync_crypto_start(clib::pclsync_lib::get_lib().get_crypto_pass().c_str());
|
||||
ret = psync_crypto_start(
|
||||
clib::pclsync_lib::get_lib().get_crypto_pass().c_str());
|
||||
std::cout << "crypto is setup, login result=" << ret << std::endl;
|
||||
} else {
|
||||
std::cout << "crypto is not setup" << std::endl;
|
||||
ret = psync_crypto_setup(clib::pclsync_lib::get_lib().get_crypto_pass().c_str(), "no hint");
|
||||
ret = psync_crypto_setup(
|
||||
clib::pclsync_lib::get_lib().get_crypto_pass().c_str(), "no hint");
|
||||
if (ret)
|
||||
std::cout << "crypto setup failed" << std::endl;
|
||||
else{
|
||||
ret = psync_crypto_start(clib::pclsync_lib::get_lib().get_crypto_pass().c_str());
|
||||
else {
|
||||
ret = psync_crypto_start(
|
||||
clib::pclsync_lib::get_lib().get_crypto_pass().c_str());
|
||||
std::cout << "crypto setup successful, start=" << ret << std::endl;
|
||||
ret = psync_crypto_mkdir(0, "Crypto", NULL, NULL) ;
|
||||
ret = psync_crypto_mkdir(0, "Crypto", NULL, NULL);
|
||||
std::cout << "creating folder=" << ret << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -146,71 +167,91 @@ static int lib_setup_cripto(){
|
|||
clib::pclsync_lib::get_lib().crypto_on_ = true;
|
||||
}
|
||||
|
||||
static char const * status2string (uint32_t status){
|
||||
switch (status){
|
||||
case PSTATUS_READY: return "READY";
|
||||
case PSTATUS_DOWNLOADING: return "DOWNLOADING";
|
||||
case PSTATUS_UPLOADING: return "UPLOADING";
|
||||
case PSTATUS_DOWNLOADINGANDUPLOADING: return "DOWNLOADINGANDUPLOADING";
|
||||
case PSTATUS_LOGIN_REQUIRED: return "LOGIN_REQUIRED";
|
||||
case PSTATUS_BAD_LOGIN_DATA: return "BAD_LOGIN_DATA";
|
||||
case PSTATUS_BAD_LOGIN_TOKEN : return "BAD_LOGIN_TOKEN";
|
||||
case PSTATUS_ACCOUNT_FULL: return "ACCOUNT_FULL";
|
||||
case PSTATUS_DISK_FULL: return "DISK_FULL";
|
||||
case PSTATUS_PAUSED: return "PAUSED";
|
||||
case PSTATUS_STOPPED: return "STOPPED";
|
||||
case PSTATUS_OFFLINE: return "OFFLINE";
|
||||
case PSTATUS_CONNECTING: return "CONNECTING";
|
||||
case PSTATUS_SCANNING: return "SCANNING";
|
||||
case PSTATUS_USER_MISMATCH: return "USER_MISMATCH";
|
||||
case PSTATUS_ACCOUT_EXPIRED: return "ACCOUT_EXPIRED";
|
||||
default :return "Unrecognized status";
|
||||
static char const *status2string(uint32_t status) {
|
||||
switch (status) {
|
||||
case PSTATUS_READY:
|
||||
return "READY";
|
||||
case PSTATUS_DOWNLOADING:
|
||||
return "DOWNLOADING";
|
||||
case PSTATUS_UPLOADING:
|
||||
return "UPLOADING";
|
||||
case PSTATUS_DOWNLOADINGANDUPLOADING:
|
||||
return "DOWNLOADINGANDUPLOADING";
|
||||
case PSTATUS_LOGIN_REQUIRED:
|
||||
return "LOGIN_REQUIRED";
|
||||
case PSTATUS_BAD_LOGIN_DATA:
|
||||
return "BAD_LOGIN_DATA";
|
||||
case PSTATUS_BAD_LOGIN_TOKEN:
|
||||
return "BAD_LOGIN_TOKEN";
|
||||
case PSTATUS_ACCOUNT_FULL:
|
||||
return "ACCOUNT_FULL";
|
||||
case PSTATUS_DISK_FULL:
|
||||
return "DISK_FULL";
|
||||
case PSTATUS_PAUSED:
|
||||
return "PAUSED";
|
||||
case PSTATUS_STOPPED:
|
||||
return "STOPPED";
|
||||
case PSTATUS_OFFLINE:
|
||||
return "OFFLINE";
|
||||
case PSTATUS_CONNECTING:
|
||||
return "CONNECTING";
|
||||
case PSTATUS_SCANNING:
|
||||
return "SCANNING";
|
||||
case PSTATUS_USER_MISMATCH:
|
||||
return "USER_MISMATCH";
|
||||
case PSTATUS_ACCOUT_EXPIRED:
|
||||
return "ACCOUT_EXPIRED";
|
||||
default:
|
||||
return "Unrecognized status";
|
||||
}
|
||||
}
|
||||
|
||||
static void status_change(pstatus_t* status) {
|
||||
static int cryptocheck=0;
|
||||
static int mount_set=0;
|
||||
static void status_change(pstatus_t *status) {
|
||||
static int cryptocheck = 0;
|
||||
static int mount_set = 0;
|
||||
|
||||
char *err;
|
||||
err = (char*)malloc(1024);
|
||||
err = (char *)malloc(1024);
|
||||
|
||||
std::cout << "Down: " << status->downloadstr << "| Up: " << status->uploadstr <<", status is " << status2string(status->status) << std::endl;
|
||||
std::cout << "Down: " << status->downloadstr << "| Up: " << status->uploadstr
|
||||
<< ", status is " << status2string(status->status) << std::endl;
|
||||
*clib::pclsync_lib::get_lib().status_ = *status;
|
||||
if (status->status==PSTATUS_LOGIN_REQUIRED){
|
||||
if (status->status == PSTATUS_LOGIN_REQUIRED) {
|
||||
if (clib::pclsync_lib::get_lib().get_password().empty())
|
||||
clib::pclsync_lib::get_lib().get_pass_from_console();
|
||||
//std::cout << "Username: " << clib::pclsync_lib::get_lib().get_username().c_str() << "| Password: " << clib::pclsync_lib::get_lib().get_password().c_str() << std::endl;
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(), clib::pclsync_lib::get_lib().get_password().c_str(), (int) clib::pclsync_lib::get_lib().save_pass_);
|
||||
// std::cout << "Username: " <<
|
||||
// clib::pclsync_lib::get_lib().get_username().c_str() << "| Password: " <<
|
||||
// clib::pclsync_lib::get_lib().get_password().c_str() << std::endl;
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(),
|
||||
clib::pclsync_lib::get_lib().get_password().c_str(),
|
||||
(int)clib::pclsync_lib::get_lib().save_pass_);
|
||||
std::cout << "logging in" << std::endl;
|
||||
}
|
||||
else if (status->status==PSTATUS_BAD_LOGIN_DATA){
|
||||
} else if (status->status == PSTATUS_BAD_LOGIN_DATA) {
|
||||
if (!clib::pclsync_lib::get_lib().newuser_) {
|
||||
clib::pclsync_lib::get_lib().get_pass_from_console();
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(), clib::pclsync_lib::get_lib().get_password().c_str(), (int) clib::pclsync_lib::get_lib().save_pass_);
|
||||
}
|
||||
else {
|
||||
std::cout << "registering" << std::endl;
|
||||
if (psync_register(clib::pclsync_lib::get_lib().get_username().c_str(),
|
||||
clib::pclsync_lib::get_lib().get_password().c_str(),
|
||||
1,
|
||||
"bineapi.pcloud.com",
|
||||
2,
|
||||
&err)
|
||||
){
|
||||
std::cout << "both login and registration failed" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
else{
|
||||
std::cout << "registered, logging in" << std::endl;
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(), clib::pclsync_lib::get_lib().get_password().c_str(), (int) clib::pclsync_lib::get_lib().save_pass_);
|
||||
}
|
||||
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(),
|
||||
clib::pclsync_lib::get_lib().get_password().c_str(),
|
||||
(int)clib::pclsync_lib::get_lib().save_pass_);
|
||||
} else {
|
||||
std::cout << "registering" << std::endl;
|
||||
if (psync_register(clib::pclsync_lib::get_lib().get_username().c_str(),
|
||||
clib::pclsync_lib::get_lib().get_password().c_str(), 1,
|
||||
"bineapi.pcloud.com", 2, &err)) {
|
||||
std::cout << "both login and registration failed" << std::endl;
|
||||
exit(1);
|
||||
} else {
|
||||
std::cout << "registered, logging in" << std::endl;
|
||||
psync_set_user_pass(clib::pclsync_lib::get_lib().get_username().c_str(),
|
||||
clib::pclsync_lib::get_lib().get_password().c_str(),
|
||||
(int)clib::pclsync_lib::get_lib().save_pass_);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (status->status==PSTATUS_READY || status->status==PSTATUS_UPLOADING || status->status==PSTATUS_DOWNLOADING || status->status==PSTATUS_DOWNLOADINGANDUPLOADING){
|
||||
if (!cryptocheck){
|
||||
cryptocheck=1;
|
||||
if (status->status == PSTATUS_READY || status->status == PSTATUS_UPLOADING ||
|
||||
status->status == PSTATUS_DOWNLOADING ||
|
||||
status->status == PSTATUS_DOWNLOADINGANDUPLOADING) {
|
||||
if (!cryptocheck) {
|
||||
cryptocheck = 1;
|
||||
if (clib::pclsync_lib::get_lib().setup_crypto_) {
|
||||
lib_setup_cripto();
|
||||
}
|
||||
|
|
@ -218,64 +259,66 @@ static void status_change(pstatus_t* status) {
|
|||
psync_fs_start();
|
||||
}
|
||||
if (clib::pclsync_lib::get_lib().status_callback_)
|
||||
clib::pclsync_lib::get_lib().status_callback_((int)status->status, status2string(status->status));
|
||||
clib::pclsync_lib::get_lib().status_callback_(
|
||||
(int)status->status, status2string(status->status));
|
||||
}
|
||||
|
||||
int clib::pclsync_lib::statrt_crypto (const char* pass, void * rep) {
|
||||
std::cout << "calling startcrypto pass: "<<pass << std::endl;
|
||||
int clib::pclsync_lib::statrt_crypto(const char *pass, void *rep) {
|
||||
std::cout << "calling startcrypto pass: " << pass << std::endl;
|
||||
get_lib().crypto_pass_ = pass;
|
||||
return lib_setup_cripto();
|
||||
}
|
||||
int clib::pclsync_lib::stop_crypto (const char* path, void * rep) {
|
||||
int clib::pclsync_lib::stop_crypto(const char *path, void *rep) {
|
||||
int res = -1;
|
||||
psync_crypto_stop();
|
||||
get_lib().crypto_on_ = false;
|
||||
return res;
|
||||
}
|
||||
int clib::pclsync_lib::finalize (const char* path, void * rep) {
|
||||
int clib::pclsync_lib::finalize(const char *path, void *rep) {
|
||||
psync_destroy();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
int clib::pclsync_lib::list_sync_folders (const char* path, void * rep) {
|
||||
psync_folder_list_t * folders = psync_get_sync_list();
|
||||
int clib::pclsync_lib::list_sync_folders(const char *path, void *rep) {
|
||||
psync_folder_list_t *folders = psync_get_sync_list();
|
||||
rep = psync_malloc(sizeof(*folders));
|
||||
memcpy(rep, folders, sizeof(*folders));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const std::string client_name = "pCloud CC v3.0.0";
|
||||
int clib::pclsync_lib::init()//std::string& username, std::string& password, std::string* crypto_pass, int setup_crypto, int usesrypto_userpass)
|
||||
int clib::pclsync_lib::init() // std::string& username, std::string& password,
|
||||
// std::string* crypto_pass, int setup_crypto, int
|
||||
// usesrypto_userpass)
|
||||
{
|
||||
std::string software_string;
|
||||
//std::string software_string = exec("lsb_release -ds");
|
||||
// std::string software_string = exec("lsb_release -ds");
|
||||
|
||||
psync_set_software_string(client_name.c_str());
|
||||
|
||||
if (setup_crypto_ && crypto_pass_.empty() )
|
||||
if (setup_crypto_ && crypto_pass_.empty())
|
||||
return 3;
|
||||
|
||||
|
||||
if (psync_init()){
|
||||
std::cout <<"init failed\n";
|
||||
if (psync_init()) {
|
||||
std::cout << "init failed\n";
|
||||
return 1;
|
||||
}
|
||||
|
||||
was_init_ = true;
|
||||
if (!get_mount().empty())
|
||||
psync_set_string_setting("fsroot",get_mount().c_str());
|
||||
|
||||
// _tunnel = psync_ssl_tunnel_start("127.0.0.1", 9443, "62.210.116.50", 443);
|
||||
was_init_ = true;
|
||||
if (!get_mount().empty())
|
||||
psync_set_string_setting("fsroot", get_mount().c_str());
|
||||
|
||||
// _tunnel = psync_ssl_tunnel_start("127.0.0.1", 9443, "62.210.116.50", 443);
|
||||
|
||||
int isfsautostart = psync_get_bool_setting("autostartfs");
|
||||
|
||||
psync_start_sync(status_change, event_handler);
|
||||
char * username_old = psync_get_username();
|
||||
char *username_old = psync_get_username();
|
||||
|
||||
if (username_old){
|
||||
if (username_.compare(username_old) != 0){
|
||||
std::cout << "logged in with user " << username_old <<", not "<< username_ <<", unlinking"<<std::endl;
|
||||
if (username_old) {
|
||||
if (username_.compare(username_old) != 0) {
|
||||
std::cout << "logged in with user " << username_old << ", not "
|
||||
<< username_ << ", unlinking" << std::endl;
|
||||
psync_unlink();
|
||||
psync_free(username_old);
|
||||
return 2;
|
||||
|
|
@ -283,41 +326,36 @@ int clib::pclsync_lib::init()//std::string& username, std::string& password, std
|
|||
psync_free(username_old);
|
||||
}
|
||||
|
||||
psync_add_overlay_callback(20,&clib::pclsync_lib::statrt_crypto);
|
||||
psync_add_overlay_callback(21,&clib::pclsync_lib::stop_crypto);
|
||||
psync_add_overlay_callback(22,&clib::pclsync_lib::finalize);
|
||||
psync_add_overlay_callback(23,&clib::pclsync_lib::list_sync_folders);
|
||||
psync_add_overlay_callback(20, &clib::pclsync_lib::statrt_crypto);
|
||||
psync_add_overlay_callback(21, &clib::pclsync_lib::stop_crypto);
|
||||
psync_add_overlay_callback(22, &clib::pclsync_lib::finalize);
|
||||
psync_add_overlay_callback(23, &clib::pclsync_lib::list_sync_folders);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clib::pclsync_lib::login(const char* user, const char* pass, int save) {
|
||||
int clib::pclsync_lib::login(const char *user, const char *pass, int save) {
|
||||
set_username(user);
|
||||
set_password(pass);
|
||||
set_savepass(bool(save));
|
||||
psync_set_user_pass(user,pass, save);
|
||||
psync_set_user_pass(user, pass, save);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clib::pclsync_lib::logout () {
|
||||
int clib::pclsync_lib::logout() {
|
||||
set_password("");
|
||||
psync_logout();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int clib::pclsync_lib::unlink () {
|
||||
int clib::pclsync_lib::unlink() {
|
||||
set_username("");
|
||||
set_password("");
|
||||
psync_unlink();
|
||||
return 0;
|
||||
}
|
||||
|
||||
clib::pclsync_lib::pclsync_lib() : status_(new pstatus_struct_() ), was_init_(false), setup_crypto_(false)
|
||||
{}
|
||||
|
||||
clib::pclsync_lib::~pclsync_lib()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
clib::pclsync_lib::pclsync_lib()
|
||||
: status_(new pstatus_struct_()), was_init_(false), setup_crypto_(false) {}
|
||||
|
||||
clib::pclsync_lib::~pclsync_lib() {}
|
||||
|
|
|
|||
|
|
@ -1,104 +1,105 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2015 pCloud Ltd.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of pCloud Ltd nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL pCloud Ltd BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
Copyright (c) 2013-2015 pCloud Ltd.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met: Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer. Redistributions in binary form must reproduce the above
|
||||
copyright notice, this list of conditions and the following
|
||||
disclaimer in the documentation and/or other materials provided with
|
||||
the distribution. Neither the name of pCloud Ltd nor the names of
|
||||
its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL pCloud
|
||||
Ltd BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PCLSYNC_LIB_H
|
||||
#define PCLSYNC_LIB_H
|
||||
|
||||
#include <string>
|
||||
#include "pclsync_lib_c.h"
|
||||
#include <string>
|
||||
|
||||
struct pstatus_struct_;
|
||||
|
||||
namespace console_client {
|
||||
namespace clibrary {
|
||||
|
||||
struct pclsync_lib
|
||||
{
|
||||
public:
|
||||
namespace console_client {
|
||||
namespace clibrary {
|
||||
|
||||
~pclsync_lib();
|
||||
pclsync_lib();
|
||||
|
||||
//Getters
|
||||
const std::string& get_username() {return username_;}
|
||||
const std::string& get_password() {return password_;}
|
||||
const std::string& get_crypto_pass() {return crypto_pass_;};
|
||||
const std::string& get_mount() {return mount_;}
|
||||
//Setters
|
||||
void set_username(const std::string& arg) { username_ = arg;}
|
||||
void set_password(const std::string& arg) { password_ = arg;}
|
||||
void set_crypto_pass(const std::string& arg) { crypto_pass_ = arg;};
|
||||
void set_mount(const std::string& arg) { mount_ = arg;}
|
||||
void set_savepass(bool s) {save_pass_ = s;}
|
||||
void setupsetup_crypto(bool p) {setup_crypto_ = p;}
|
||||
void set_newuser(bool p) {newuser_ = p;}
|
||||
void set_daemon(bool p) {daemon_ = p;}
|
||||
void set_status_callback(status_callback_t p) {status_callback_ = p;}
|
||||
//Console
|
||||
void get_pass_from_console();
|
||||
void get_cryptopass_from_console();
|
||||
//API calls
|
||||
int init();//std::string& username, std::string& password, std::string* crypto_pass, int setup_crypto = 1, int usesrypto_userpass = 0);
|
||||
static int statrt_crypto (const char* pass, void * rep);
|
||||
static int stop_crypto (const char* path, void * rep);
|
||||
static int finalize (const char* path, void * rep);
|
||||
static int list_sync_folders (const char* path, void * rep);
|
||||
//Singelton
|
||||
static pclsync_lib& get_lib();
|
||||
char * get_token();
|
||||
int logout();
|
||||
int unlink();
|
||||
int login(const char* user, const char* pass, int save);
|
||||
|
||||
bool crypto_on_;
|
||||
bool save_pass_;
|
||||
bool setup_crypto_;
|
||||
pstatus_struct_* status_;
|
||||
bool newuser_;
|
||||
status_callback_t status_callback_;
|
||||
bool was_init_;
|
||||
class pclsync_lib {
|
||||
public:
|
||||
~pclsync_lib();
|
||||
pclsync_lib();
|
||||
|
||||
private:
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
std::string crypto_pass_;
|
||||
std::string mount_;
|
||||
|
||||
bool to_set_mount_;
|
||||
bool daemon_;
|
||||
// Getters
|
||||
const std::string &get_username() { return username_; }
|
||||
const std::string &get_password() { return password_; }
|
||||
const std::string &get_crypto_pass() { return crypto_pass_; };
|
||||
const std::string &get_mount() { return mount_; }
|
||||
|
||||
// Setters
|
||||
void set_username(const std::string &arg) { username_ = arg; }
|
||||
void set_password(const std::string &arg) { password_ = arg; }
|
||||
void set_crypto_pass(const std::string &arg) { crypto_pass_ = arg; };
|
||||
void set_mount(const std::string &arg) { mount_ = arg; }
|
||||
void set_savepass(bool s) { save_pass_ = s; }
|
||||
void setupsetup_crypto(bool p) { setup_crypto_ = p; }
|
||||
void set_newuser(bool p) { newuser_ = p; }
|
||||
void set_daemon(bool p) { daemon_ = p; }
|
||||
void set_status_callback(status_callback_t p) { status_callback_ = p; }
|
||||
|
||||
private:
|
||||
void do_get_pass_from_console(std::string& password);
|
||||
|
||||
// Console
|
||||
void get_pass_from_console();
|
||||
void get_cryptopass_from_console();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
// API calls
|
||||
int init(); // std::string& username, std::string& password, std::string*
|
||||
// crypto_pass, int setup_crypto = 1, int usesrypto_userpass = 0);
|
||||
static int statrt_crypto(const char *pass, void *rep);
|
||||
static int stop_crypto(const char *path, void *rep);
|
||||
static int finalize(const char *path, void *rep);
|
||||
static int list_sync_folders(const char *path, void *rep);
|
||||
// Singelton
|
||||
static pclsync_lib &get_lib();
|
||||
char *get_token();
|
||||
int logout();
|
||||
int unlink();
|
||||
int login(const char *user, const char *pass, int save);
|
||||
|
||||
bool crypto_on_;
|
||||
bool save_pass_;
|
||||
bool setup_crypto_;
|
||||
pstatus_struct_ *status_;
|
||||
bool newuser_;
|
||||
status_callback_t status_callback_;
|
||||
bool was_init_;
|
||||
|
||||
private:
|
||||
std::string username_;
|
||||
std::string password_;
|
||||
std::string crypto_pass_;
|
||||
std::string mount_;
|
||||
|
||||
bool to_set_mount_;
|
||||
bool daemon_;
|
||||
|
||||
private:
|
||||
void do_get_pass_from_console(std::string &password);
|
||||
};
|
||||
|
||||
} // namespace clibrary
|
||||
} // namespace console_client
|
||||
|
||||
#endif // PCLSYNC_LIB_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue