Skip to content

Commit

Permalink
Enhance logging and edit TODOS
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanJakobo committed Jul 29, 2022
1 parent 3822d31 commit c6ea754
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
5 changes: 1 addition & 4 deletions src/api/webDAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ string WebDAV::propfind(const string &pathUrl)
}

if (!Util::connectToNetwork())
{
Message(ICON_WARNING, "Warning", "Cannot connect to the internet. ", 2000);
return "";
}

//TODO for upload
//get etag from current and then send request with FT_ENC_TAG
Expand Down Expand Up @@ -257,7 +254,7 @@ string WebDAV::propfind(const string &pathUrl)
switch (response_code)
{
case 404:
Message(ICON_ERROR, "Error", "The URL seems to be incorrect. You can look up the WebDav URL in the files app under settings. ", 4000);
Message(ICON_ERROR, "Error", "The URL seems to be incorrect. You can look up the WebDav URL in the settings of the files webapp. ", 4000);
break;
case 401:
Message(ICON_ERROR, "Error", "Username/password incorrect.", 4000);
Expand Down
19 changes: 8 additions & 11 deletions src/handler/eventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ void EventHandler::mainMenuHandler(const int index)
//Actualize the current folder
case 101:
{
//TODO startfolder use same as above
//TODO parent path not needed
OpenProgressbar(1, "Actualizing current folder", ("Actualizing path" + _currentPath).c_str(), 0, NULL);
string childrenPath = _currentPath;
childrenPath = childrenPath.substr(NEXTCLOUD_ROOT_PATH.length(), childrenPath.length());
Expand Down Expand Up @@ -139,7 +137,7 @@ void EventHandler::mainMenuHandler(const int index)
for(auto &item : currentWebDAVItems)
{
Log::writeInfoLog(item.path);
if(item.state == FileState::IOUTSYNCED || item.state == FileState::ICLOUD)
if(item.type == Itemtype::IFOLDER && item.state == FileState::IOUTSYNCED)
{
UpdateProgressbar(("Upgrading " + item.path).c_str(), 0);
vector<WebDAVItem> tempWebDAVItems = _webDAV.getDataStructure(item.path);
Expand Down Expand Up @@ -392,7 +390,7 @@ void EventHandler::openItem()
_webDAVView->invertCurrentEntryColor();
if (_webDAVView->getCurrentEntry().state == FileState::ICLOUD)
{
Message(ICON_ERROR, "File not found.", "Could not find file.", 1000);
Message(ICON_ERROR, "Error", "Could not find file.", 1000);
}
else if(_webDAVView->getCurrentEntry().fileType.find("application/epub+zip") != string::npos ||
_webDAVView->getCurrentEntry().fileType.find("application/pdf") != string::npos ||
Expand All @@ -409,7 +407,7 @@ void EventHandler::openItem()
}
else
{
Message(ICON_INFORMATION, "Warning", "The filetype is currently not supported.", 1200);
Message(ICON_INFORMATION, "Info", "The filetype is currently not supported.", 1200);
}
}

Expand Down Expand Up @@ -566,14 +564,13 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
vector<WebDAVItem> tempItems;
if(items.at(itemID).state == FileState::IOUTSYNCED || items.at(itemID).state == FileState::ICLOUD)
{
Log::writeInfoLog("outsynced");
Log::writeInfoLog(path + "outsynced");
tempItems = _webDAV.getDataStructure(path);
//TODO twice?
updateItems(tempItems);
}
else
{
Log::writeInfoLog("synced");
Log::writeInfoLog(path + "synced");
tempItems = _sqllite.getItemsChildren(path);
}
//first item of the vector is the root path itself
Expand All @@ -583,15 +580,15 @@ void EventHandler::downloadFolder(vector<WebDAVItem> &items, int itemID)
downloadFolder(tempItems, i);
}
//TODO remove file parts that are no longer there, check for local path and delete these
//TODO else use offline structure to go down
//get items from DB, then compare to downloaded, if is in DB but not downloaded, remove

}
else
{
if(items.at(itemID).state == FileState::IOUTSYNCED || items.at(itemID).state == FileState::ICLOUD)
{
Log::writeInfoLog("outsynced");
//TODO
//TODO both direction
//1. check etag --> if is differnt, cloud has been updated
//2. check modification date and file size locally --> if is different, local has been updated
//3. if both --> create conflict
Expand Down Expand Up @@ -630,9 +627,9 @@ void EventHandler::startDownload()
UpdateProgressbar("Download completed", 100);
}

//TODO implement
//Util::updatePBLibrary(15);
CloseProgressbar();
//TODO does not work
_webDAVView->reDrawCurrentEntry();
}

Expand Down
2 changes: 2 additions & 0 deletions src/util/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ bool Util::connectToNetwork()
int result = NetConnect2(network_name, 1);
if (result != 0)
{
Message(ICON_WARNING, "Warning", "It was not possible to establish an internet connection.", 2000);
return false;
}

netinfo = NetInfo();
if (netinfo->connected)
return true;

Message(ICON_WARNING, "Warning", "It was not possible to establish an internet connection.", 2000);
return false;
}

Expand Down

0 comments on commit c6ea754

Please sign in to comment.