Add Messaging of Failures and UI fixes

master
JuanJakobo 2022-07-31 13:38:04 +02:00
parent 708efdbbdb
commit 10e04c056d
4 changed files with 37 additions and 15 deletions

View File

@ -198,6 +198,7 @@ string WebDAV::propfind(const string &pathUrl)
if (!Util::connectToNetwork()) if (!Util::connectToNetwork())
return ""; return "";
ShowHourglassForce();
//TODO for upload //TODO for upload
//get etag from current and then send request with FT_ENC_TAG //get etag from current and then send request with FT_ENC_TAG
@ -291,9 +292,11 @@ bool WebDAV::get(WebDAVItem &item)
} }
if (!Util::connectToNetwork()) if (!Util::connectToNetwork())
return ""; return false;
UpdateProgressbar(("Starting Download of " + item.localPath).c_str(), 0); ShowHourglassForce();
UpdateProgressbar(("Starting Download of " + item.path).c_str(), 0);
CURLcode res; CURLcode res;
CURL *curl = curl_easy_init(); CURL *curl = curl_easy_init();

View File

@ -38,6 +38,10 @@ EventHandler::EventHandler()
_menu = std::unique_ptr<MainMenu>(new MainMenu("Nextcloud")); _menu = std::unique_ptr<MainMenu>(new MainMenu("Nextcloud"));
if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0) if (iv_access(CONFIG_PATH.c_str(), W_OK) == 0)
{ {
//for backwards compatibilty
if (Util::accessConfig(CONFIG_PATH, Action::IReadString, "storageLocation").empty())
Util::accessConfig(CONFIG_PATH, Action::IWriteString, "storageLocation", "/mnt/ext1/nextcloud");
if (iv_access(Util::accessConfig(CONFIG_PATH, Action::IReadString, "storageLocation").c_str(), W_OK) != 0) if (iv_access(Util::accessConfig(CONFIG_PATH, Action::IReadString, "storageLocation").c_str(), W_OK) != 0)
iv_mkdir(Util::accessConfig(CONFIG_PATH, Action::IReadString, "storageLocation").c_str(), 0777); iv_mkdir(Util::accessConfig(CONFIG_PATH, Action::IReadString, "storageLocation").c_str(), 0777);
std::vector<WebDAVItem> currentWebDAVItems; std::vector<WebDAVItem> currentWebDAVItems;
@ -246,19 +250,32 @@ void EventHandler::contextMenuHandler(const int index)
//Sync //Sync
case 102: case 102:
{ {
startDownload(); if (_webDAVView->getCurrentEntry().state != FileState::ILOCAL)
{
startDownload();
}
else
{
//TODO upload to cloud
Message(ICON_ERROR, "Error", "The File is local and upload to cloud is currently not supported.", 2000);
_webDAVView->invertCurrentEntryColor();
}
break; break;
} }
//remove //remove
case 103: case 103:
{ {
ShowHourglassForce(); if (_webDAVView->getCurrentEntry().state != FileState::ICLOUD)
if (_webDAVView->getCurrentEntry().state == FileState::ISYNCED || _webDAVView->getCurrentEntry().state == FileState::IOUTSYNCED)
{ {
if (_webDAVView->getCurrentEntry().type == Itemtype::IFOLDER) if (_webDAVView->getCurrentEntry().type == Itemtype::IFOLDER)
{ {
string cmd = "rm -rf " + _webDAVView->getCurrentEntry().localPath + "/"; Message(ICON_ERROR, "Error", "Currently only files can be deleted.", 2000);
system(cmd.c_str()); //string cmd = "rm -rf " + _webDAVView->getCurrentEntry().localPath + '/';
//if (rmdir((_webDAVView->getCurrentEntry().localPath + '/').c_str()) == 0)
//Log::writeInfoLog("okay");
//if (system(cmd.c_str()) == 0)
//Log::writeInfoLog("success");
} }
else else
{ {
@ -268,8 +285,11 @@ void EventHandler::contextMenuHandler(const int index)
updateItems(currentWebDAVItems); updateItems(currentWebDAVItems);
drawWebDAVItems(currentWebDAVItems); drawWebDAVItems(currentWebDAVItems);
} }
else
HideHourglass(); {
Message(ICON_ERROR, "Error", "File is not available.", 1000);
_webDAVView->invertCurrentEntryColor();
}
break; break;
} }
default: default:
@ -403,6 +423,7 @@ void EventHandler::openItem()
_webDAVView->getCurrentEntry().fileType.find("text/plain") != string::npos || _webDAVView->getCurrentEntry().fileType.find("text/plain") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("text/html") != string::npos || _webDAVView->getCurrentEntry().fileType.find("text/html") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("text/rtf") != string::npos || _webDAVView->getCurrentEntry().fileType.find("text/rtf") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("text/markdown") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("application/msword") != string::npos || _webDAVView->getCurrentEntry().fileType.find("application/msword") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("application/x-mobipocket-ebook") != string::npos || _webDAVView->getCurrentEntry().fileType.find("application/x-mobipocket-ebook") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("application/vnd.openxmlformats-officedocument.wordprocessingml.document") != string::npos || _webDAVView->getCurrentEntry().fileType.find("application/vnd.openxmlformats-officedocument.wordprocessingml.document") != string::npos ||
@ -570,6 +591,7 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
if (items.at(itemID).state == FileState::IOUTSYNCED || items.at(itemID).state == FileState::ICLOUD) if (items.at(itemID).state == FileState::IOUTSYNCED || items.at(itemID).state == FileState::ICLOUD)
{ {
Log::writeInfoLog(path + "outsynced"); Log::writeInfoLog(path + "outsynced");
UpdateProgressbar(("Syncing folder" + path).c_str(), 0);
tempItems = _webDAV.getDataStructure(path); tempItems = _webDAV.getDataStructure(path);
updateItems(tempItems); updateItems(tempItems);
} }

View File

@ -23,12 +23,9 @@ void FileViewEntry::draw(const ifont *entryFont, const ifont *entryFontBold, int
SetFont(entryFont, BLACK); SetFont(entryFont, BLACK);
//DrawTextRect(_position.x, _position.y + heightOfTitle, _position.w, fontHeight, _entry.name.c_str(), ALIGN_LEFT);
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, _entry.path.c_str(), ALIGN_LEFT); DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, _entry.path.c_str(), ALIGN_LEFT);
std::string type = "File"; const char *type = _entry.type == Type::FFOLDER ? "Folder" : "File";
if(_entry.type == Type::FFOLDER) DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, type, ALIGN_RIGHT);
type = "Folder";
DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, type.c_str(), ALIGN_RIGHT);
int line = (_position.y + _position.h) - 1; int line = (_position.y + _position.h) - 1;
DrawLine(0, line, ScreenWidth(), line, BLACK); DrawLine(0, line, ScreenWidth(), line, BLACK);

View File

@ -31,7 +31,7 @@ void WebDAVViewEntry::draw(const ifont *entryFont, const ifont *entryFontBold, i
if (_entry.state == FileState::ILOCAL) if (_entry.state == FileState::ILOCAL)
{ {
DrawTextRect(_position.x, _position.y + heightOfTitle + 2 * fontHeight, _position.w, fontHeight, "Local", ALIGN_RIGHT); DrawTextRect(_position.x, _position.y + heightOfTitle + fontHeight, _position.w, fontHeight, "Local", ALIGN_RIGHT);
} }
else else
{ {