Call template using explict types
parent
fc030fa284
commit
f8c628105d
|
@ -57,16 +57,16 @@ std::vector<WebDAVItem> WebDAV::login(const string &Url, const string &Username,
|
||||||
uuid = Username;
|
uuid = Username;
|
||||||
}
|
}
|
||||||
auto tempPath = NEXTCLOUD_ROOT_PATH + uuid + "/";
|
auto tempPath = NEXTCLOUD_ROOT_PATH + uuid + "/";
|
||||||
Util::accessConfig( Action::IWriteString, "storageLocation", "/mnt/ext1/nextcloud");
|
Util::accessConfig<string>( Action::IWriteString, "storageLocation", "/mnt/ext1/nextcloud");
|
||||||
std::vector<WebDAVItem> tempItems = getDataStructure(tempPath);
|
std::vector<WebDAVItem> tempItems = getDataStructure(tempPath);
|
||||||
if (!tempItems.empty())
|
if (!tempItems.empty())
|
||||||
{
|
{
|
||||||
if (iv_access(CONFIG_PATH.c_str(), W_OK) != 0)
|
if (iv_access(CONFIG_PATH.c_str(), W_OK) != 0)
|
||||||
iv_buildpath(CONFIG_PATH.c_str());
|
iv_buildpath(CONFIG_PATH.c_str());
|
||||||
Util::accessConfig( Action::IWriteString, "url", _url);
|
Util::accessConfig<string>( Action::IWriteString, "url", _url);
|
||||||
Util::accessConfig( Action::IWriteString, "username", _username);
|
Util::accessConfig<string>( Action::IWriteString, "username", _username);
|
||||||
Util::accessConfig( Action::IWriteString, "UUID", uuid);
|
Util::accessConfig<string>( Action::IWriteString, "UUID", uuid);
|
||||||
Util::accessConfig( Action::IWriteSecret, "password", _password);
|
Util::accessConfig<string>( Action::IWriteSecret, "password", _password);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,11 +36,12 @@ EventHandler::EventHandler()
|
||||||
if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0)
|
if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0)
|
||||||
{
|
{
|
||||||
//for backwards compatibilty
|
//for backwards compatibilty
|
||||||
if (Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).empty())
|
if (Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).compare("error") == 0)
|
||||||
Util::accessConfig(Action::IWriteString, "storageLocation", "/mnt/ext1/nextcloud");
|
Util::accessConfig<string>(Action::IWriteString, "storageLocation", "/mnt/ext1/nextcloud");
|
||||||
|
|
||||||
if (iv_access(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), W_OK) != 0)
|
if (iv_access(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), W_OK) != 0)
|
||||||
iv_mkdir(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), 0777);
|
iv_mkdir(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), 0777);
|
||||||
|
|
||||||
std::vector<WebDAVItem> currentWebDAVItems;
|
std::vector<WebDAVItem> currentWebDAVItems;
|
||||||
string path = NEXTCLOUD_ROOT_PATH + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/';
|
string path = NEXTCLOUD_ROOT_PATH + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/';
|
||||||
|
|
||||||
|
@ -188,10 +189,10 @@ void EventHandler::mainMenuHandler(const int index)
|
||||||
switch (dialogResult)
|
switch (dialogResult)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
Util::accessConfig(Action::IWriteInt, "sortBy", 1);
|
Util::accessConfig<int>(Action::IWriteInt, "sortBy", 1);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
Util::accessConfig(Action::IWriteInt, "sortBy", 2);
|
Util::accessConfig<int>(Action::IWriteInt, "sortBy", 2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
@ -203,13 +204,16 @@ void EventHandler::mainMenuHandler(const int index)
|
||||||
case 104:
|
case 104:
|
||||||
{
|
{
|
||||||
|
|
||||||
_currentPath =+ (_currentPath.back() != '/') ? "/nextcloud" : "nextcloud";
|
_currentPath = _currentPath + ((_currentPath.back() != '/') ? "/nextcloud" : "nextcloud");
|
||||||
|
|
||||||
if (iv_mkdir(_currentPath.c_str(), 0777) != 0)
|
if (iv_mkdir(_currentPath.c_str(), 0777) != 0)
|
||||||
|
{
|
||||||
|
Log::writeErrorLog("choosen part " + _currentPath + " could not be created as permission are not sufficient.");
|
||||||
Message(ICON_ERROR, "Error", "The permissions are not sufficient.", 1000);
|
Message(ICON_ERROR, "Error", "The permissions are not sufficient.", 1000);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Util::accessConfig(Action::IWriteString, "storageLocation", _currentPath);
|
Util::accessConfig<string>(Action::IWriteString, "storageLocation", _currentPath);
|
||||||
std::vector<WebDAVItem> currentWebDAVItems = _webDAV.getDataStructure(NEXTCLOUD_ROOT_PATH + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/');
|
std::vector<WebDAVItem> currentWebDAVItems = _webDAV.getDataStructure(NEXTCLOUD_ROOT_PATH + Util::accessConfig<string>(Action::IReadString,"UUID",{}) + '/');
|
||||||
if (currentWebDAVItems.empty())
|
if (currentWebDAVItems.empty())
|
||||||
{
|
{
|
||||||
|
@ -377,11 +381,11 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Do you want to choose your own storage path or use the default one. \n (/mnt/ext1/nextcloud/)", "Choose my own path", "Choose standard path", NULL);
|
int dialogResult = DialogSynchro(ICON_QUESTION, "Action", "Do you want to choose your own storage path or use the default one. \n (/mnt/ext1/nextcloud/)", "Choose my own path", "Choose standard path", NULL);
|
||||||
auto path = "/mnt/ext1";
|
|
||||||
switch (dialogResult)
|
switch (dialogResult)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
|
auto path = "/mnt/ext1";
|
||||||
FileBrowser fileBrowser = FileBrowser(false);
|
FileBrowser fileBrowser = FileBrowser(false);
|
||||||
vector<FileItem> currentFolder = fileBrowser.getFileStructure(path);
|
vector<FileItem> currentFolder = fileBrowser.getFileStructure(path);
|
||||||
_currentPath = path;
|
_currentPath = path;
|
||||||
|
@ -390,7 +394,10 @@ int EventHandler::pointerHandler(const int type, const int par1, const int par2)
|
||||||
_fileView = std::unique_ptr<FileView>(new FileView(_menu->getContentRect(), currentFolder,1));
|
_fileView = std::unique_ptr<FileView>(new FileView(_menu->getContentRect(), currentFolder,1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 2:
|
||||||
default:
|
default:
|
||||||
|
if (iv_access(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), W_OK) != 0)
|
||||||
|
iv_mkdir(Util::accessConfig<string>(Action::IReadString, "storageLocation",{}).c_str(), 0777);
|
||||||
updateItems(currentWebDAVItems);
|
updateItems(currentWebDAVItems);
|
||||||
drawWebDAVItems(currentWebDAVItems);
|
drawWebDAVItems(currentWebDAVItems);
|
||||||
break;
|
break;
|
||||||
|
@ -549,6 +556,7 @@ int EventHandler::keyHandler(const int type, const int par1, const int par2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO use Filebrowser
|
||||||
void EventHandler::getLocalFileStructure(vector<WebDAVItem> &items)
|
void EventHandler::getLocalFileStructure(vector<WebDAVItem> &items)
|
||||||
{
|
{
|
||||||
//get local files, https://stackoverflow.com/questions/306533/how-do-i-get-a-list-of-files-in-a-directory-in-c
|
//get local files, https://stackoverflow.com/questions/306533/how-do-i-get-a-list-of-files-in-a-directory-in-c
|
||||||
|
@ -694,6 +702,7 @@ void EventHandler::updateItems(vector<WebDAVItem> &items)
|
||||||
{
|
{
|
||||||
for(auto &item : items)
|
for(auto &item : items)
|
||||||
{
|
{
|
||||||
|
//ICloud if is not found
|
||||||
item.state = _sqllite.getState(item.path);
|
item.state = _sqllite.getState(item.path);
|
||||||
|
|
||||||
if (item.type == Itemtype::IFILE)
|
if (item.type == Itemtype::IFILE)
|
||||||
|
|
|
@ -47,7 +47,7 @@ WebDAVView::WebDAVView(const irect &contentRect, vector<WebDAVItem> &items, int
|
||||||
|
|
||||||
sort(begin, items.end(), []( WebDAVItem &w1, WebDAVItem &w2) -> bool
|
sort(begin, items.end(), []( WebDAVItem &w1, WebDAVItem &w2) -> bool
|
||||||
{
|
{
|
||||||
if(Util::accessConfig(Action::IReadInt, "sortBy", 0) == 2)
|
if(Util::accessConfig<int>(Action::IReadInt, "sortBy", 0) == 2)
|
||||||
{
|
{
|
||||||
//sort by lastmodified
|
//sort by lastmodified
|
||||||
time_t t1 = mktime(&w1.lastEditDate);
|
time_t t1 = mktime(&w1.lastEditDate);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include "inkview.h"
|
#include "inkview.h"
|
||||||
#include "eventHandler.h"
|
#include "eventHandler.h"
|
||||||
|
|
||||||
|
#include "log.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
enum class Action
|
enum class Action
|
||||||
|
@ -65,9 +66,6 @@ public:
|
||||||
iconfig *config = OpenConfig(CONFIG_PATH.c_str(), temp);
|
iconfig *config = OpenConfig(CONFIG_PATH.c_str(), temp);
|
||||||
T returnValue;
|
T returnValue;
|
||||||
|
|
||||||
if constexpr(std::is_same<T, Entry>::value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
if constexpr(std::is_same<T, std::string>::value)
|
if constexpr(std::is_same<T, std::string>::value)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
|
@ -77,14 +75,14 @@ public:
|
||||||
returnValue = {};
|
returnValue = {};
|
||||||
break;
|
break;
|
||||||
case Action::IReadSecret:
|
case Action::IReadSecret:
|
||||||
returnValue = ReadSecret(config, name.c_str(), "");
|
returnValue = ReadSecret(config, name.c_str(), "error");
|
||||||
break;
|
break;
|
||||||
case Action::IWriteString:
|
case Action::IWriteString:
|
||||||
WriteString(config, name.c_str(), value.c_str());
|
WriteString(config, name.c_str(), value.c_str());
|
||||||
returnValue = {};
|
returnValue = {};
|
||||||
break;
|
break;
|
||||||
case Action::IReadString:
|
case Action::IReadString:
|
||||||
returnValue = ReadString(config, name.c_str(), "");
|
returnValue = ReadString(config, name.c_str(), "error");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue