minor bugfix in main.cpp, formatting & licenses
This commit is contained in:
parent
25f7354bfe
commit
141bbb3c92
28
gitcommit.h
28
gitcommit.h
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
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 _GITCOMMIT_H
|
||||
#define _GITCOMMIT_H
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
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 <iostream>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
|
|||
|
|
@ -1,38 +1,40 @@
|
|||
/*
|
||||
* 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 CONTROL_TOOLS_H
|
||||
#define CONTROL_TOOLS_H
|
||||
|
||||
namespace control_tools {
|
||||
int start_crypto(const char * pass);
|
||||
int stop_crypto();
|
||||
int finalize();
|
||||
int daemonize(bool do_commands);
|
||||
void process_commands();
|
||||
int start_crypto(const char * pass);
|
||||
int stop_crypto();
|
||||
int finalize();
|
||||
int daemonize(bool do_commands);
|
||||
void process_commands();
|
||||
}
|
||||
|
||||
#endif //CONTROL_TOOLS_H
|
||||
#endif //CONTROL_TOOLS_H
|
||||
|
|
|
|||
|
|
@ -1,259 +0,0 @@
|
|||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.29
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
.PHONY : default_target
|
||||
|
||||
# Allow only one "make -f Makefile2" at a time, but pass parallelism.
|
||||
.NOTPARALLEL:
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canonical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : %,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : RCS/%,v
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : SCCS/s.%
|
||||
|
||||
# Disable VCS-based implicit rules.
|
||||
% : s.%
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Command-line flag to silence nested $(MAKE).
|
||||
$(VERBOSE)MAKESILENT = -s
|
||||
|
||||
#Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
# The shell in which to execute make rules.
|
||||
SHELL = /bin/sh
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = /usr/bin/cmake
|
||||
|
||||
# The command to remove a file.
|
||||
RM = /usr/bin/cmake -E rm -f
|
||||
|
||||
# Escaping for special characters.
|
||||
EQUALS = =
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = /home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/mbedtls
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = /home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/mbedtls
|
||||
|
||||
#=============================================================================
|
||||
# Targets provided globally by CMake.
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake cache editor..."
|
||||
/usr/bin/ccmake -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : edit_cache
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache/fast: edit_cache
|
||||
.PHONY : edit_cache/fast
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Running CMake to regenerate build system..."
|
||||
/usr/bin/cmake --regenerate-during-build -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : rebuild_cache
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache/fast: rebuild_cache
|
||||
.PHONY : rebuild_cache/fast
|
||||
|
||||
# Special rule for the target list_install_components
|
||||
list_install_components:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Available install components are: \"Unspecified\""
|
||||
.PHONY : list_install_components
|
||||
|
||||
# Special rule for the target list_install_components
|
||||
list_install_components/fast: list_install_components
|
||||
.PHONY : list_install_components/fast
|
||||
|
||||
# Special rule for the target install
|
||||
install: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Install the project..."
|
||||
/usr/bin/cmake -P cmake_install.cmake
|
||||
.PHONY : install
|
||||
|
||||
# Special rule for the target install
|
||||
install/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Install the project..."
|
||||
/usr/bin/cmake -P cmake_install.cmake
|
||||
.PHONY : install/fast
|
||||
|
||||
# Special rule for the target install/local
|
||||
install/local: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing only the local directory..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
||||
.PHONY : install/local
|
||||
|
||||
# Special rule for the target install/local
|
||||
install/local/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing only the local directory..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
|
||||
.PHONY : install/local/fast
|
||||
|
||||
# Special rule for the target install/strip
|
||||
install/strip: preinstall
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing the project stripped..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
||||
.PHONY : install/strip
|
||||
|
||||
# Special rule for the target install/strip
|
||||
install/strip/fast: preinstall/fast
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --cyan "Installing the project stripped..."
|
||||
/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
|
||||
.PHONY : install/strip/fast
|
||||
|
||||
# The main all target
|
||||
all: cmake_check_build_system
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/mbedtls/CMakeFiles /home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/mbedtls//CMakeFiles/progress.marks
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start /home/lkn/src/my/pcloudcc-lneely/pCloudCC/lib/mbedtls/CMakeFiles 0
|
||||
.PHONY : all
|
||||
|
||||
# The main clean target
|
||||
clean:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 clean
|
||||
.PHONY : clean
|
||||
|
||||
# The main clean target
|
||||
clean/fast: clean
|
||||
.PHONY : clean/fast
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall: all
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 preinstall
|
||||
.PHONY : preinstall/fast
|
||||
|
||||
# clear depends
|
||||
depend:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
|
||||
.PHONY : depend
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named apidoc
|
||||
|
||||
# Build rule for target.
|
||||
apidoc: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 apidoc
|
||||
.PHONY : apidoc
|
||||
|
||||
# fast build rule for target.
|
||||
apidoc/fast:
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/apidoc.dir/build.make CMakeFiles/apidoc.dir/build
|
||||
.PHONY : apidoc/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named mbedtls
|
||||
|
||||
# Build rule for target.
|
||||
mbedtls: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 mbedtls
|
||||
.PHONY : mbedtls
|
||||
|
||||
# fast build rule for target.
|
||||
mbedtls/fast:
|
||||
$(MAKE) $(MAKESILENT) -f library/CMakeFiles/mbedtls.dir/build.make library/CMakeFiles/mbedtls.dir/build
|
||||
.PHONY : mbedtls/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named polarssl
|
||||
|
||||
# Build rule for target.
|
||||
polarssl: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 polarssl
|
||||
.PHONY : polarssl
|
||||
|
||||
# fast build rule for target.
|
||||
polarssl/fast:
|
||||
$(MAKE) $(MAKESILENT) -f library/CMakeFiles/polarssl.dir/build.make library/CMakeFiles/polarssl.dir/build
|
||||
.PHONY : polarssl/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named polarssl-clean
|
||||
|
||||
# Build rule for target.
|
||||
polarssl-clean: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 polarssl-clean
|
||||
.PHONY : polarssl-clean
|
||||
|
||||
# fast build rule for target.
|
||||
polarssl-clean/fast:
|
||||
$(MAKE) $(MAKESILENT) -f library/CMakeFiles/polarssl-clean.dir/build.make library/CMakeFiles/polarssl-clean.dir/build
|
||||
.PHONY : polarssl-clean/fast
|
||||
|
||||
#=============================================================================
|
||||
# Target rules for targets named polarssl-install
|
||||
|
||||
# Build rule for target.
|
||||
polarssl-install: cmake_check_build_system
|
||||
$(MAKE) $(MAKESILENT) -f CMakeFiles/Makefile2 polarssl-install
|
||||
.PHONY : polarssl-install
|
||||
|
||||
# fast build rule for target.
|
||||
polarssl-install/fast:
|
||||
$(MAKE) $(MAKESILENT) -f library/CMakeFiles/polarssl-install.dir/build.make library/CMakeFiles/polarssl-install.dir/build
|
||||
.PHONY : polarssl-install/fast
|
||||
|
||||
# Help Target
|
||||
help:
|
||||
@echo "The following are some of the valid targets for this Makefile:"
|
||||
@echo "... all (the default if no target is provided)"
|
||||
@echo "... clean"
|
||||
@echo "... depend"
|
||||
@echo "... edit_cache"
|
||||
@echo "... install"
|
||||
@echo "... install/local"
|
||||
@echo "... install/strip"
|
||||
@echo "... list_install_components"
|
||||
@echo "... rebuild_cache"
|
||||
@echo "... apidoc"
|
||||
@echo "... polarssl"
|
||||
@echo "... polarssl-clean"
|
||||
@echo "... polarssl-install"
|
||||
@echo "... mbedtls"
|
||||
.PHONY : help
|
||||
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
$(CMAKE_COMMAND) -S$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
||||
Binary file not shown.
|
|
@ -1,3 +1,32 @@
|
|||
/*
|
||||
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 "control_tools.h"
|
||||
#include "pclsync_lib.h"
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
@ -54,16 +83,17 @@ main(int argc, char **argv) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
if ((!vm.count("username"))) {
|
||||
if (commands_only) {
|
||||
ct::process_commands();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if ((!vm.count("username"))) {
|
||||
std::cout << "Username option is required, specify with " <<
|
||||
"-u or --username." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (commands_only) {
|
||||
ct::process_commands();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; ++i) {
|
||||
memset(argv[i], 0, strlen(argv[i]));
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2013-2015 pCloud Ltd.
|
||||
All rights reserved.
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
/*
|
||||
Copyright (c) 2013-2015 pCloud Ltd.
|
||||
All rights reserved.
|
||||
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
|
||||
|
|
|
|||
|
|
@ -1,46 +1,81 @@
|
|||
/*
|
||||
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_c.h"
|
||||
#include "pclsync_lib.h"
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
namespace cc = console_client::clibrary;
|
||||
namespace cc = console_client::clibrary;
|
||||
|
||||
int init() {
|
||||
int
|
||||
init() {
|
||||
if (!cc::pclsync_lib::get_lib().was_init_)
|
||||
return cc::pclsync_lib::get_lib().init();
|
||||
else return 0;
|
||||
}
|
||||
|
||||
int start_crypto (const char* pass) {
|
||||
int
|
||||
start_crypto (const char* pass) {
|
||||
return cc::pclsync_lib::start_crypto (pass, NULL);
|
||||
}
|
||||
int stop_crypto () {
|
||||
int
|
||||
stop_crypto () {
|
||||
return cc::pclsync_lib::stop_crypto (NULL, NULL);
|
||||
}
|
||||
int finalize () {
|
||||
int
|
||||
finalize () {
|
||||
return cc::pclsync_lib::finalize(NULL, NULL);
|
||||
}
|
||||
void set_status_callback(status_callback_t c) {
|
||||
void
|
||||
set_status_callback(status_callback_t c) {
|
||||
cc::pclsync_lib::get_lib().set_status_callback(c);
|
||||
}
|
||||
|
||||
char * get_token(){
|
||||
char*
|
||||
get_token(){
|
||||
return cc::pclsync_lib::get_lib().get_token();
|
||||
}
|
||||
|
||||
int login(const char* user, const char* pass, int save) {
|
||||
int
|
||||
login(const char* user, const char* pass, int save) {
|
||||
return cc::pclsync_lib::get_lib().login(user, pass, save);
|
||||
}
|
||||
|
||||
int logout() {
|
||||
int
|
||||
logout() {
|
||||
return cc::pclsync_lib::get_lib().logout();
|
||||
}
|
||||
|
||||
int unlinklib() {
|
||||
int
|
||||
unlinklib() {
|
||||
return cc::pclsync_lib::get_lib().unlink();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,48 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void psync_fs_pause_until_login();
|
||||
void psync_fs_pause_until_login();
|
||||
|
||||
typedef void (*status_callback_t)(int status, const char *stat_string);
|
||||
typedef void (*status_callback_t)(int status, const char *stat_string);
|
||||
|
||||
int init();
|
||||
int start_crypto(const char *pass);
|
||||
int stop_crypto();
|
||||
int finalize();
|
||||
char *get_token();
|
||||
void set_status_callback(status_callback_t);
|
||||
int logout();
|
||||
int unlinklib();
|
||||
int login(const char *user, const char *pass, int save);
|
||||
int init();
|
||||
int start_crypto(const char *pass);
|
||||
int stop_crypto();
|
||||
int finalize();
|
||||
char *get_token();
|
||||
void set_status_callback(status_callback_t);
|
||||
int logout();
|
||||
int unlinklib();
|
||||
int login(const char *user, const char *pass, int save);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,30 @@
|
|||
/*
|
||||
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 "pcompat.h"
|
||||
#include "plibs.h"
|
||||
|
|
@ -10,7 +37,6 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#define _WIN32_WINNT 0x0601
|
||||
|
||||
|
||||
#include <windows.h>
|
||||
#include <dbt.h>
|
||||
#include <shlobj.h>
|
||||
|
|
@ -22,43 +48,50 @@
|
|||
|
||||
#define CLS_NAME "DUMMY_CLASS"
|
||||
#define HWND_MESSAGE ((HWND)-3)
|
||||
|
||||
#define WM_USER_MEDIACHANGED WM_USER+88
|
||||
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
static device_event_callback *callbacks;
|
||||
static int clbsize = 10;
|
||||
static int clbnum = 0;
|
||||
|
||||
typedef struct {
|
||||
DWORD dwItem1; // dwItem1 contains the previous PIDL or name of the folder.
|
||||
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
|
||||
} SHNOTIFYSTRUCT;
|
||||
|
||||
void padd_monitor_callback(device_event_callback callback) {
|
||||
if (callback) {
|
||||
if (clbnum == 0)
|
||||
callbacks = (device_event_callback *)psync_malloc(sizeof(device_event_callback)*clbsize);
|
||||
else {
|
||||
while (clbnum > clbsize) {
|
||||
device_event_callback *callbacks_old = callbacks;
|
||||
callbacks = (device_event_callback *)psync_malloc(sizeof(device_event_callback)*clbsize*2);
|
||||
memccpy(callbacks, callbacks_old, 0,sizeof(device_event_callback)*clbsize);
|
||||
clbsize = clbsize * 2;
|
||||
psync_free(callbacks_old);
|
||||
}
|
||||
}
|
||||
callbacks[clbnum] = callback;
|
||||
clbnum++;
|
||||
void
|
||||
padd_monitor_callback(device_event_callback callback) {
|
||||
if (callback) {
|
||||
if (clbnum == 0) {
|
||||
callbacks = (device_event_callback *)psync_malloc(sizeof(device_event_callback)*clbsize);
|
||||
} else {
|
||||
while (clbnum > clbsize) {
|
||||
device_event_callback *callbacks_old = callbacks;
|
||||
callbacks = (device_event_callback *)psync_malloc(sizeof(device_event_callback)*clbsize*2);
|
||||
memccpy(callbacks, callbacks_old, 0,sizeof(device_event_callback)*clbsize);
|
||||
clbsize = clbsize * 2;
|
||||
psync_free(callbacks_old);
|
||||
}
|
||||
}
|
||||
callbacks[clbnum] = callback;
|
||||
clbnum++;
|
||||
}
|
||||
}
|
||||
|
||||
static pdevice_info * new_dev_info( char *szPath, pdevice_types type, device_event evt) {
|
||||
static pdevice_info*
|
||||
new_dev_info(char *szPath, pdevice_types type,
|
||||
device_event evt) {
|
||||
pdevice_info *infop;
|
||||
|
||||
/*int pathsize = strlen(szPath);
|
||||
int infstrsize = sizeof(pdevice_info);
|
||||
int infsize = pathsize + infstrsize + 1;*/
|
||||
// pdevice_info *infop = (pdevice_info *)psync_malloc(infsize);
|
||||
pdevice_info *infop = (pdevice_info *)psync_malloc(sizeof(pdevice_info));
|
||||
// pdevice_info *infop = (pdevice_info *)psync_malloc(infsize);
|
||||
//ZeroMemory(infop, infsize);
|
||||
//infop->filesystem_path = (char *)(infop) + infstrsize;
|
||||
infop = (pdevice_info *)psync_malloc(sizeof(pdevice_info));
|
||||
infop->filesystem_path = _strdup(szPath);
|
||||
//infop->filesystem_path = (char *)(infop) + infstrsize;
|
||||
//memcpy(infop->filesystem_path, szPath, pathsize);
|
||||
//infop->filesystem_path[pathsize] = '\0';
|
||||
infop->event = evt;
|
||||
|
|
@ -69,8 +102,9 @@ static pdevice_info * new_dev_info( char *szPath, pdevice_types type, device_eve
|
|||
return infop;
|
||||
}
|
||||
|
||||
static put_into_storage(char **prop, char **dst, char* src, uint32_t size)
|
||||
{
|
||||
static void
|
||||
put_into_storage(char **prop, char **dst,
|
||||
char* src, uint32_t size) {
|
||||
*prop = *dst;
|
||||
memcpy(*dst, src, size);
|
||||
char * end = *dst;
|
||||
|
|
@ -78,27 +112,30 @@ static put_into_storage(char **prop, char **dst, char* src, uint32_t size)
|
|||
(*dst) += (size+1);
|
||||
}
|
||||
|
||||
static pdevice_extended_info * new_dev_ext_info(char *szPath, char * vendor, char *product, char* deviceid, pdevice_types type, device_event evt) {
|
||||
/*uint32_t pathsize = strlen(szPath);
|
||||
uint32_t vndsize = strlen(vendor);
|
||||
uint32_t prdsize = strlen(product);
|
||||
uint32_t devsize = strlen(deviceid);
|
||||
uint32_t infstrsize = sizeof(pdevice_extended_info);
|
||||
uint32_t infsize = pathsize + infstrsize + pathsize + vndsize + prdsize + 5;
|
||||
void * infovp = psync_malloc(infsize);
|
||||
pdevice_extended_info *infop = (pdevice_extended_info *)infovp;
|
||||
ZeroMemory(infop, infsize);
|
||||
char *storage_begin = (char *)(infovp)+infstrsize;
|
||||
put_into_storage(&infop->filesystem_path, &storage_begin, szPath, pathsize);
|
||||
put_into_storage(&infop->vendor, &storage_begin, vendor, vndsize);
|
||||
put_into_storage(&infop->product, &storage_begin, product, prdsize);
|
||||
put_into_storage(&infop->device_id, &storage_begin, deviceid, devsize);
|
||||
infop->type = type;
|
||||
infop->event = evt;
|
||||
infop->isextended = 1;
|
||||
infop->size = infsize;
|
||||
infop->me = infop;*/
|
||||
pdevice_extended_info *infop = (pdevice_extended_info *)psync_malloc(sizeof(pdevice_extended_info));
|
||||
static pdevice_extended_info *
|
||||
new_dev_ext_info(char *szPath, char * vendor, char *product, char* deviceid,
|
||||
pdevice_types type, device_event evt) {
|
||||
/*uint32_t pathsize = strlen(szPath);
|
||||
uint32_t vndsize = strlen(vendor);
|
||||
uint32_t prdsize = strlen(product);
|
||||
uint32_t devsize = strlen(deviceid);
|
||||
uint32_t infstrsize = sizeof(pdevice_extended_info);
|
||||
uint32_t infsize = pathsize + infstrsize + pathsize + vndsize + prdsize + 5;
|
||||
void * infovp = psync_malloc(infsize);
|
||||
pdevice_extended_info *infop = (pdevice_extended_info *)infovp;
|
||||
ZeroMemory(infop, infsize);
|
||||
char *storage_begin = (char *)(infovp)+infstrsize;
|
||||
put_into_storage(&infop->filesystem_path, &storage_begin, szPath, pathsize);
|
||||
put_into_storage(&infop->vendor, &storage_begin, vendor, vndsize);
|
||||
put_into_storage(&infop->product, &storage_begin, product, prdsize);
|
||||
put_into_storage(&infop->device_id, &storage_begin, deviceid, devsize);
|
||||
infop->type = type;
|
||||
infop->event = evt;
|
||||
infop->isextended = 1;
|
||||
infop->size = infsize;
|
||||
infop->me = infop;*/
|
||||
pdevice_extended_info *infop =
|
||||
(pdevice_extended_info *)psync_malloc(sizeof(pdevice_extended_info));
|
||||
infop->filesystem_path = _strdup(szPath);
|
||||
infop->vendor = _strdup(vendor);
|
||||
infop->product = _strdup(product);
|
||||
|
|
@ -111,7 +148,8 @@ static pdevice_extended_info * new_dev_ext_info(char *szPath, char * vendor, cha
|
|||
return infop;
|
||||
}
|
||||
|
||||
static void notify_callbacks_free_run(void * param) {
|
||||
static void
|
||||
notify_callbacks_free_run(void * param) {
|
||||
int i = 0;
|
||||
while (i < clbnum) {
|
||||
device_event_callback c = callbacks[i];
|
||||
|
|
@ -132,263 +170,276 @@ static void notify_callbacks_free_run(void * param) {
|
|||
psync_free(p);
|
||||
}
|
||||
|
||||
static void notify_callbacks_free(void * param) {
|
||||
static void
|
||||
notify_callbacks_free(void * param) {
|
||||
psync_run_thread1("Device notifications", notify_callbacks_free_run, param);
|
||||
}
|
||||
|
||||
static pdevice_types dev_decode_type(STORAGE_BUS_TYPE bustype, DWORD drivetype) {
|
||||
|
||||
static void
|
||||
pdevice_types dev_decode_type(STORAGE_BUS_TYPE bustype, DWORD drivetype) {
|
||||
switch (bustype) {
|
||||
case BusTypeScsi:
|
||||
case BusTypeiScsi:
|
||||
case BusTypeUsb:
|
||||
case BusTypeSata:
|
||||
if (drivetype == DRIVE_REMOVABLE)
|
||||
case BusTypeScsi: //fallthrough
|
||||
case BusTypeiScsi://fallthrough
|
||||
case BusTypeUsb: //fallthrough
|
||||
case BusTypeSata: //returns
|
||||
if (drivetype == DRIVE_REMOVABLE) {
|
||||
return Dev_Types_UsbRemovableDisk;
|
||||
else
|
||||
} else {
|
||||
return Dev_Types_UsbFixedDisk;
|
||||
break;
|
||||
case BusTypeSd:
|
||||
}
|
||||
case BusTypeSd: // returns
|
||||
return Dev_Types_AndroidDevice;
|
||||
break;
|
||||
case BusTypeMmc:
|
||||
case BusTypeMmc: // returns
|
||||
return Dev_Types_CameraDevice;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static DWORD GetPhysicalDriveParams(char *strdrivepath IN, DWORD drivetype, char *fspath, void **deviceinfo OUT)
|
||||
{
|
||||
DWORD dwRet = NO_ERROR;
|
||||
static DWORD
|
||||
GetPhysicalDriveParams(char *strdrivepath IN, DWORD drivetype,
|
||||
char *fspath, void **deviceinfo OUT) {
|
||||
DWORD dwRet;
|
||||
HANDLE hDevice;
|
||||
STORAGE_PROPERTY_QUERY storagePropertyQuery;
|
||||
STORAGE_DESCRIPTOR_HEADER storageDescriptorHeader;
|
||||
DWORD dwBytesReturned;
|
||||
const DWORD dwOutBufferSize;
|
||||
BYTE* pOutBuffer;
|
||||
STORAGE_DEVICE_DESCRIPTOR* pDeviceDescriptor;
|
||||
|
||||
HANDLE hDevice = CreateFileA(strdrivepath, 0, FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
dwRet = NO_ERROR;
|
||||
|
||||
hDevice = CreateFileA(strdrivepath, 0,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, NULL);
|
||||
|
||||
if (INVALID_HANDLE_VALUE == hDevice)
|
||||
return GetLastError();
|
||||
|
||||
STORAGE_PROPERTY_QUERY storagePropertyQuery;
|
||||
ZeroMemory(&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY));
|
||||
storagePropertyQuery.PropertyId = StorageDeviceProperty;
|
||||
storagePropertyQuery.QueryType = PropertyStandardQuery;
|
||||
|
||||
STORAGE_DESCRIPTOR_HEADER storageDescriptorHeader = { 0 };
|
||||
DWORD dwBytesReturned = 0;
|
||||
storageDescriptorHeader = { 0 };
|
||||
dwBytesReturned = 0;
|
||||
if (!DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY,
|
||||
&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY),
|
||||
&storageDescriptorHeader, sizeof(STORAGE_DESCRIPTOR_HEADER),
|
||||
&dwBytesReturned, NULL))
|
||||
{
|
||||
&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY),
|
||||
&storageDescriptorHeader, sizeof(STORAGE_DESCRIPTOR_HEADER),
|
||||
&dwBytesReturned, NULL)) {
|
||||
dwRet = GetLastError();
|
||||
CloseHandle(hDevice);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
// Alloc the output buffer
|
||||
const DWORD dwOutBufferSize = storageDescriptorHeader.Size;
|
||||
BYTE* pOutBuffer = (BYTE*)psync_malloc(dwOutBufferSize);
|
||||
dwOutBufferSize = storageDescriptorHeader.Size;
|
||||
pOutBuffer = (BYTE*)psync_malloc(dwOutBufferSize);
|
||||
ZeroMemory(pOutBuffer, dwOutBufferSize);
|
||||
|
||||
// Get the storage device descriptor
|
||||
if (!DeviceIoControl(hDevice, IOCTL_STORAGE_QUERY_PROPERTY,
|
||||
&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY),
|
||||
pOutBuffer, dwOutBufferSize,
|
||||
&dwBytesReturned, NULL))
|
||||
{
|
||||
&storagePropertyQuery, sizeof(STORAGE_PROPERTY_QUERY),
|
||||
pOutBuffer, dwOutBufferSize,
|
||||
&dwBytesReturned, NULL)) {
|
||||
dwRet = GetLastError();
|
||||
free(pOutBuffer);
|
||||
CloseHandle(hDevice);
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
STORAGE_DEVICE_DESCRIPTOR* pDeviceDescriptor = (STORAGE_DEVICE_DESCRIPTOR*)pOutBuffer;
|
||||
*deviceinfo = new_dev_ext_info(fspath,
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->VendorIdOffset),
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->ProductIdOffset),
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->SerialNumberOffset),
|
||||
dev_decode_type(pDeviceDescriptor->BusType, drivetype),
|
||||
Dev_Event_arrival);
|
||||
pDeviceDescriptor = (STORAGE_DEVICE_DESCRIPTOR*)pOutBuffer;
|
||||
*deviceinfo =
|
||||
new_dev_ext_info(fspath,
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->VendorIdOffset),
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->ProductIdOffset),
|
||||
(char *)(pOutBuffer + pDeviceDescriptor->SerialNumberOffset),
|
||||
dev_decode_type(pDeviceDescriptor->BusType, drivetype),
|
||||
Dev_Event_arrival);
|
||||
|
||||
// Do cleanup and return
|
||||
free (pOutBuffer);
|
||||
CloseHandle(hDevice);
|
||||
|
||||
return dwRet;
|
||||
}
|
||||
|
||||
static LRESULT
|
||||
message_handler(HWND *hwnd, UINT uint, WPARAM wparam, LPARAM lparam) {
|
||||
switch (uint) {
|
||||
case WM_NCCREATE:
|
||||
return 1;
|
||||
break;
|
||||
case WM_CREATE:
|
||||
return 0;
|
||||
break;
|
||||
case WM_DEVICECHANGE:
|
||||
return 0;
|
||||
break;
|
||||
case WM_USER_MEDIACHANGED:
|
||||
SHNOTIFYSTRUCT *shns;
|
||||
char szPath[MAX_PATH];
|
||||
pdevice_info *p;
|
||||
|
||||
shns == (SHNOTIFYSTRUCT *)wparam;
|
||||
ZeroMemory(&szPath, MAX_PATH);
|
||||
|
||||
typedef struct {
|
||||
DWORD dwItem1; // dwItem1 contains the previous PIDL or name of the folder.
|
||||
DWORD dwItem2; // dwItem2 contains the new PIDL or name of the folder.
|
||||
} SHNOTIFYSTRUCT;
|
||||
switch (lparam) {
|
||||
case SHCNE_MEDIAINSERTED: // media inserted event
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
p = new_dev_info(szPath, Dev_Types_CDRomMedia, Dev_Event_arrival);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
case SHCNE_MEDIAREMOVED: // media removed event
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
p = new_dev_info(szPath, Dev_Types_CDRomMedia, Dev_Event_removed);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
case SHCNE_DRIVEADD: // media removed event
|
||||
DWORD drivetype;
|
||||
HANDLE hDevice;
|
||||
PSTORAGE_DEVICE_DESCRIPTOR pDevDesc;
|
||||
pdevice_extended_info *deviceinfo;
|
||||
char szRootPath[];
|
||||
char szDevicePath[];
|
||||
char szVolumeAccessPath[];
|
||||
|
||||
static LRESULT message_handler(HWND *hwnd, UINT uint, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch (uint)
|
||||
{
|
||||
case WM_NCCREATE:
|
||||
return 1;
|
||||
break;
|
||||
case WM_CREATE:
|
||||
return 0;
|
||||
break;
|
||||
case WM_DEVICECHANGE:
|
||||
return 0;
|
||||
break;
|
||||
case WM_USER_MEDIACHANGED:
|
||||
{
|
||||
SHNOTIFYSTRUCT *shns = (SHNOTIFYSTRUCT *)wparam;
|
||||
char szPath[MAX_PATH];
|
||||
ZeroMemory(&szPath, MAX_PATH);
|
||||
switch (lparam)
|
||||
{
|
||||
case SHCNE_MEDIAINSERTED: // media inserted event
|
||||
{
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
pdevice_info *p = new_dev_info(szPath, Dev_Types_CDRomMedia, Dev_Event_arrival);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
}
|
||||
case SHCNE_MEDIAREMOVED: // media removed event
|
||||
{
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
pdevice_info *p = new_dev_info(szPath, Dev_Types_CDRomMedia, Dev_Event_removed);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
}
|
||||
case SHCNE_DRIVEADD: // media removed event
|
||||
{
|
||||
deviceinfo = NULL;
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1,
|
||||
szPath);
|
||||
|
||||
DWORD drivetype;
|
||||
HANDLE hDevice;
|
||||
PSTORAGE_DEVICE_DESCRIPTOR pDevDesc;
|
||||
pdevice_extended_info *deviceinfo = NULL;
|
||||
// "X:\" -> for GetDriveType
|
||||
szRootPath = "X:\\";
|
||||
szRootPath[0] = szPath[0];
|
||||
|
||||
// "X:" -> for QueryDosDevice
|
||||
szDevicePath = "X:";
|
||||
szDevicePath[0] = szPath[0];
|
||||
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
// "X:\" -> for GetDriveType
|
||||
char szRootPath[] = "X:\\";
|
||||
szRootPath[0] = szPath[0];
|
||||
// "X:" -> for QueryDosDevice
|
||||
char szDevicePath[] = "X:";
|
||||
szDevicePath[0] = szPath[0];
|
||||
|
||||
// "\\.\X:" -> to open the volume
|
||||
char szVolumeAccessPath[] = "\\\\.\\X:";
|
||||
szVolumeAccessPath[4] = szPath[0];
|
||||
drivetype = GetDriveTypeA(szRootPath);
|
||||
switch (drivetype)
|
||||
{
|
||||
case 0: // The drive type cannot be determined.
|
||||
debug(D_NOTICE, "The drive type cannot be determined!");
|
||||
break;
|
||||
case 1: // The root directory does not exist.
|
||||
debug(D_NOTICE, "The root directory does not exist!");
|
||||
break;
|
||||
case DRIVE_CDROM: // The drive is a CD-ROM drive.
|
||||
debug(D_NOTICE, "The drive is a CD-ROM drive.");
|
||||
case DRIVE_REMOVABLE: // The drive can be removed from the drive.
|
||||
case DRIVE_FIXED: // The disk cannot be removed from the drive.
|
||||
case DRIVE_REMOTE: // The drive is a remote (network) drive.
|
||||
GetPhysicalDriveParams(szVolumeAccessPath, drivetype, szDevicePath, &deviceinfo);
|
||||
if (deviceinfo)
|
||||
notify_callbacks_free(deviceinfo);
|
||||
else
|
||||
notify_callbacks_free(new_dev_info(szPath, dev_decode_type(BusTypeUsb, drivetype), Dev_Event_arrival));
|
||||
break;
|
||||
case DRIVE_RAMDISK: // The drive is a RAM disk.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SHCNE_DRIVEREMOVED: // media removed event
|
||||
{
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
pdevice_info *p = new_dev_info(szPath, Dev_Types_UsbFixedDisk, Dev_Event_removed);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
}
|
||||
// "\\.\X:" -> to open the volume
|
||||
szVolumeAccessPath = "\\\\.\\X:";
|
||||
szVolumeAccessPath[4] = szPath[0];
|
||||
|
||||
drivetype = GetDriveTypeA(szRootPath);
|
||||
switch (drivetype) {
|
||||
case 0: // The drive type cannot be determined.
|
||||
debug(D_NOTICE, "The drive type cannot be determined!");
|
||||
break;
|
||||
case 1: // The root directory does not exist.
|
||||
debug(D_NOTICE, "The root directory does not exist!");
|
||||
break;
|
||||
case DRIVE_CDROM: // The drive is a CD-ROM drive.
|
||||
debug(D_NOTICE, "The drive is a CD-ROM drive.");
|
||||
case DRIVE_REMOVABLE: // The drive can be removed from the drive.
|
||||
case DRIVE_FIXED: // The disk cannot be removed from the drive.
|
||||
case DRIVE_REMOTE: // The drive is a remote (network) drive.
|
||||
GetPhysicalDriveParams(szVolumeAccessPath, drivetype,
|
||||
szDevicePath, &deviceinfo);
|
||||
if (deviceinfo) {
|
||||
notify_callbacks_free(deviceinfo);
|
||||
} else {
|
||||
notify_callbacks_free(new_dev_info(szPath,
|
||||
dev_decode_type(BusTypeUsb, drivetype),
|
||||
Dev_Event_arrival));
|
||||
}
|
||||
break;
|
||||
case DRIVE_RAMDISK: // The drive is a RAM disk.
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SHCNE_DRIVEREMOVED: // media removed event
|
||||
SHGetPathFromIDListA((struct _ITEMIDLIST *)shns->dwItem1, szPath);
|
||||
p = new_dev_info(szPath, Dev_Types_UsbFixedDisk, Dev_Event_removed);
|
||||
notify_callbacks_free(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void device_change(void *param) {
|
||||
static void
|
||||
device_change(void *param) {
|
||||
pdevice_info * pd = (pdevice_info*)param;
|
||||
debug(D_NOTICE, "type [%d] event [%d] size [%d] isex [%d] fspath [%s] \n", pd->type, pd->event, pd->size, pd->isextended, pd->filesystem_path);
|
||||
debug(D_NOTICE, "type [%d] event [%d] size [%d] isex [%d] fspath [%s] \n",
|
||||
pd->type, pd->event, pd->size, pd->isextended, pd->filesystem_path);
|
||||
|
||||
if (pd->isextended) {
|
||||
pdevice_extended_info* pde = (pdevice_extended_info*)param;
|
||||
debug(D_NOTICE, "vendor [%s] product [%s] deviceid [%s] \n", pde->vendor, pde->product, pde->device_id);
|
||||
debug(D_NOTICE, "vendor [%s] product [%s] deviceid [%s] \n",
|
||||
pde->vendor, pde->product, pde->device_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pinit_device_monitor() {
|
||||
HWND hWnd = NULL;
|
||||
WNDCLASSEXA wx;
|
||||
void
|
||||
pinit_device_monitor() {
|
||||
HWND hWnd = NULL;
|
||||
WNDCLASSEXA wx;
|
||||
MSG msg;
|
||||
ULONG m_ulSHChangeNotifyRegister;
|
||||
LPITEMIDLIST ppidl;
|
||||
|
||||
#ifdef P_DEVICE_VERBOSE
|
||||
padd_monitor_callback(device_change);
|
||||
#endif
|
||||
ZeroMemory(&wx, sizeof(wx));
|
||||
|
||||
wx.cbSize = sizeof(WNDCLASSEXA);
|
||||
wx.lpfnWndProc = (WNDPROC) (message_handler);
|
||||
wx.hInstance = (HINSTANCE) (GetModuleHandleA(0));
|
||||
wx.style = CS_HREDRAW | CS_VREDRAW;
|
||||
//wx.hInstance = GetModuleHandle(0);
|
||||
wx.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
||||
wx.lpszClassName = CLS_NAME;
|
||||
ZeroMemory(&wx, sizeof(wx));
|
||||
|
||||
if (RegisterClassExA(&wx)) {
|
||||
hWnd = CreateWindowA(CLS_NAME, L"DevNotifWnd", WS_ICONIC,
|
||||
0, 0, CW_USEDEFAULT, 0, HWND_MESSAGE,
|
||||
NULL, GetModuleHandleA(0), NULL);//(void*)&guid);
|
||||
}
|
||||
wx.cbSize = sizeof(WNDCLASSEXA);
|
||||
wx.lpfnWndProc = (WNDPROC) (message_handler);
|
||||
wx.hInstance = (HINSTANCE) (GetModuleHandleA(0));
|
||||
wx.style = CS_HREDRAW | CS_VREDRAW;
|
||||
//wx.hInstance = GetModuleHandle(0);
|
||||
wx.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
||||
wx.lpszClassName = CLS_NAME;
|
||||
|
||||
if (hWnd == NULL) {
|
||||
if (RegisterClassExA(&wx)) {
|
||||
hWnd = CreateWindowA(CLS_NAME, L"DevNotifWnd", WS_ICONIC,
|
||||
0, 0, CW_USEDEFAULT, 0, HWND_MESSAGE,
|
||||
NULL, GetModuleHandleA(0), NULL);//(void*)&guid);
|
||||
}
|
||||
|
||||
if (hWnd == NULL) {
|
||||
debug(D_NOTICE, "Could not create message window! %d", GetLastError());
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, &ppidl) == NOERROR) {
|
||||
SHChangeNotifyEntry shCNE;
|
||||
|
||||
shCNE.pidl = ppidl;
|
||||
shCNE.fRecursive = TRUE;
|
||||
m_ulSHChangeNotifyRegister =
|
||||
SHChangeNotifyRegister(hWnd, SHCNE_DISKEVENTS,
|
||||
SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED
|
||||
| SHCNE_DRIVEREMOVED | SHCNE_DRIVEADD,
|
||||
WM_USER_MEDIACHANGED, 1, &shCNE);
|
||||
|
||||
if (m_ulSHChangeNotifyRegister == 0) {
|
||||
debug(D_NOTICE,
|
||||
"Shell Device Notify registration CD failed with error %d",
|
||||
GetLastError());
|
||||
return 2;
|
||||
}
|
||||
|
||||
ULONG m_ulSHChangeNotifyRegister;
|
||||
LPITEMIDLIST ppidl;
|
||||
if (SHGetSpecialFolderLocation(hWnd, CSIDL_DESKTOP, &ppidl) == NOERROR)
|
||||
{
|
||||
SHChangeNotifyEntry shCNE;
|
||||
shCNE.pidl = ppidl;
|
||||
shCNE.fRecursive = TRUE;
|
||||
|
||||
m_ulSHChangeNotifyRegister = SHChangeNotifyRegister(hWnd,
|
||||
SHCNE_DISKEVENTS,
|
||||
SHCNE_MEDIAINSERTED | SHCNE_MEDIAREMOVED | SHCNE_DRIVEREMOVED | SHCNE_DRIVEADD,
|
||||
WM_USER_MEDIACHANGED,
|
||||
1,
|
||||
&shCNE);
|
||||
|
||||
if (m_ulSHChangeNotifyRegister == 0) {
|
||||
debug(D_NOTICE, "Shell Device Notify registration CD failed with error %d", GetLastError());
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
debug(D_NOTICE, "Shell Device Notify registration CD failed with error %d ", GetLastError());
|
||||
|
||||
} else {
|
||||
debug(D_NOTICE,
|
||||
"Shell Device Notify registration CD failed with error %d ",
|
||||
GetLastError());
|
||||
}
|
||||
|
||||
debug(D_NOTICE, "waiting for new devices..");
|
||||
|
||||
MSG msg;
|
||||
while (GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
return 0;
|
||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
void padd_monitor_callback(device_event_callback callback) {}
|
||||
|
||||
void pinit_device_monitor() {return;}
|
||||
void
|
||||
padd_monitor_callback(device_event_callback callback) { /*noop*/ }
|
||||
|
||||
#endif //P_OS_WINDOWS
|
||||
void
|
||||
pinit_device_monitor() { /*noop*/ }
|
||||
|
||||
#endif //P_OS_WINDOWS
|
||||
|
|
|
|||
|
|
@ -1,3 +1,31 @@
|
|||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef _PDEVICE_MONITOR
|
||||
|
|
@ -17,7 +45,6 @@ typedef enum {
|
|||
} device_event;
|
||||
|
||||
typedef struct _pdevice_info pdevice_info;
|
||||
|
||||
struct _pdevice_info {
|
||||
pdevice_types type;
|
||||
device_event event;
|
||||
|
|
@ -28,7 +55,6 @@ struct _pdevice_info {
|
|||
};
|
||||
|
||||
typedef struct _pdevice_extended_info pdevice_extended_info;
|
||||
|
||||
struct _pdevice_extended_info {
|
||||
pdevice_types type;
|
||||
device_event event;
|
||||
|
|
@ -48,7 +74,6 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
void padd_monitor_callback(device_event_callback callback);
|
||||
|
||||
void pinit_device_monitor();
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Reference in New Issue