clean up and refactor
parent
bbb8379dae
commit
ef842c94f1
|
@ -2,37 +2,42 @@
|
|||
# This file has been adapted from the PocketBook SDK
|
||||
#
|
||||
|
||||
PROJECT (Pocketbook-Nextcloud)
|
||||
PROJECT (Pocketbook-Nextcloud-Client)
|
||||
CMAKE_MINIMUM_REQUIRED (VERSION 3.10.1)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
|
||||
SET (TOOLCHAIN_PATH "../../SDK/pocketbook-sdk5-master")
|
||||
SET (TOOLCHAIN_PREFIX "arm-obreey-linux-gnueabi")
|
||||
SET (TOOLCHAIN_INSTALL "sysroot/usr")
|
||||
ADD_DEFINITIONS(-DPLATFORM_FC)
|
||||
|
||||
|
||||
IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET (CMAKE_BUILD_TYPE Debug)
|
||||
ENDIF (NOT CMAKE_BUILD_TYPE)
|
||||
|
||||
#For target "ARM"
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/arm-obreey-linux-gnueabi/sysroot/usr
|
||||
SET(CMAKE_INSTALL_PREFIX "${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}/${TOOLCHAIN_INSTALL}" CACHE PATH "Install path prefix" FORCE)
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/bin/arm-obreey-linux-gnueabi-gcc
|
||||
SET (CMAKE_C_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-gcc)
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/bin/arm-obreey-linux-gnueabi-g++
|
||||
SET (CMAKE_CXX_COMPILER ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++)
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/bin/arm-obreey-linux-gnueabi--g++
|
||||
SET (CMAKE_LINK ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-g++)
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/bin/arm-obreey-linux-gnueabi--arr
|
||||
SET (CMAKE_ARR ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-arr)
|
||||
|
||||
#../../SDK/pocketbook-sdk5-master/bin/arm-obreey-linux-gnueabi-strip
|
||||
SET (CMAKE_STRIP ${CMAKE_CURRENT_SOURCE_DIR}/${TOOLCHAIN_PATH}/bin/${TOOLCHAIN_PREFIX}-strip)
|
||||
|
||||
SET (TARGET_INCLUDE "")
|
||||
|
||||
SET (TARGET_LIB pthread inkview freetype z curl)
|
||||
|
||||
IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
MESSAGE (STATUS "Build for ARM Debug")
|
||||
SET (CMAKE_C_FLAGS_DEBUG "-DDEBUG -fsigned-char -W -Wall -Wextra -Wno-format-y2k -fomit-frame-pointer -O0 -g3")
|
||||
|
@ -59,13 +64,17 @@ set(SOURCES ${CMAKE_SOURCE_DIR}/src/main.cpp
|
|||
|
||||
add_executable(Nextcloud.app ${SOURCES})
|
||||
|
||||
#SET (TARGET_INCLUDE "")
|
||||
|
||||
include_directories(
|
||||
$(TARGET_INCLUDE)
|
||||
#$(TARGET_INCLUDE)
|
||||
${CMAKE_SOURCE_DIR}/src/handler/
|
||||
${CMAKE_SOURCE_DIR}/src/util/
|
||||
${CMAKE_SOURCE_DIR}/src/ui/
|
||||
)
|
||||
|
||||
SET (TARGET_LIB pthread inkview freetype z curl)
|
||||
|
||||
TARGET_LINK_LIBRARIES (Nextcloud.app ${TARGET_LIB})
|
||||
|
||||
INSTALL (TARGETS Nextcloud.app)
|
||||
|
|
13
README.md
13
README.md
|
@ -1,4 +1,7 @@
|
|||
# Pocketbook Nextcloud
|
||||
# Pocketbook Nextcloud Client
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
### Tested on
|
||||
|
@ -6,6 +9,14 @@
|
|||
|
||||
## Screenshots
|
||||
|
||||
### Installation
|
||||
|
||||
|
||||
### Usage
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Disclamer
|
||||
|
||||
|
|
|
@ -1,77 +1,71 @@
|
|||
//------------------------------------------------------------------
|
||||
// menuHandler.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 14.06.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "inkview.h"
|
||||
#include "menuHandler.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
|
||||
MenuHandler::MenuHandler(const string &name)
|
||||
{
|
||||
//Define panel size
|
||||
panelMenuHeight = ScreenHeight() / 18;
|
||||
panelMenuBeginY = 0;
|
||||
mainMenuWidth = ScreenWidth()/3;
|
||||
panelMenuBeginX = ScreenWidth() - mainMenuWidth;
|
||||
_panelMenuHeight = ScreenHeight() / 18;
|
||||
_panelMenuBeginY = 0;
|
||||
_mainMenuWidth = ScreenWidth() / 3;
|
||||
_panelMenuBeginX = ScreenWidth() - _mainMenuWidth;
|
||||
|
||||
menuButtonRect = iRect(mainMenuWidth*2,panelMenuBeginY,mainMenuWidth,panelMenuHeight,ALIGN_RIGHT);
|
||||
_menuButtonRect = iRect(_mainMenuWidth * 2, _panelMenuBeginY, _mainMenuWidth, _panelMenuHeight, ALIGN_RIGHT);
|
||||
|
||||
menuFont = OpenFont("LiberationMono-Bold",panelMenuHeight/2,1);
|
||||
SetFont(menuFont, BLACK);
|
||||
_menuFont = OpenFont("LiberationMono-Bold", _panelMenuHeight / 2, 1);
|
||||
SetFont(_menuFont, BLACK);
|
||||
|
||||
DrawTextRect(0,panelMenuBeginY,ScreenWidth(),panelMenuHeight,name.c_str(),ALIGN_CENTER);
|
||||
DrawTextRect2(&menuButtonRect,"Menu");
|
||||
DrawLine(0,panelMenuHeight-1,ScreenWidth(),panelMenuHeight-1,BLACK);
|
||||
DrawTextRect(0, _panelMenuBeginY, ScreenWidth(), _panelMenuHeight, name.c_str(), ALIGN_CENTER);
|
||||
DrawTextRect2(&_menuButtonRect, "Menu");
|
||||
DrawLine(0, _panelMenuHeight - 1, ScreenWidth(), _panelMenuHeight - 1, BLACK);
|
||||
|
||||
contentRect = iRect(0,panelMenuHeight,ScreenWidth(),(ScreenHeight() - PanelHeight() - panelMenuHeight),0);
|
||||
_contentRect = iRect(0, _panelMenuHeight, ScreenWidth(), (ScreenHeight() - PanelHeight() - _panelMenuHeight), 0);
|
||||
|
||||
SetHardTimer("PANELUPDATE", panelHandlerStatic, 110000);
|
||||
DrawPanel(NULL, "", NULL, -1);
|
||||
|
||||
DrawPanel(NULL, "", NULL, -1);
|
||||
}
|
||||
|
||||
MenuHandler::~MenuHandler()
|
||||
{
|
||||
CloseFont(menuFont);
|
||||
CloseFont(_menuFont);
|
||||
}
|
||||
|
||||
void MenuHandler::panelHandlerStatic()
|
||||
void MenuHandler::panelHandlerStatic()
|
||||
{
|
||||
DrawPanel(NULL, "", NULL, -1);
|
||||
SetHardTimer("PANELUPDATE", panelHandlerStatic, 110000);
|
||||
}
|
||||
|
||||
|
||||
int MenuHandler::createMenu(bool loggedIn, iv_menuhandler handler)
|
||||
{
|
||||
imenu mainMenu[]=
|
||||
{
|
||||
{ ITEM_HEADER, 0, "Menu", NULL},
|
||||
//show always
|
||||
{ ITEM_ACTIVE, 101, "Exit"},
|
||||
{ 0, 0, NULL, NULL}
|
||||
};
|
||||
imenu mainMenu[] =
|
||||
{
|
||||
{ITEM_HEADER, 0, "Menu", NULL},
|
||||
//show always
|
||||
{ITEM_ACTIVE, 101, "Exit"},
|
||||
{0, 0, NULL, NULL}};
|
||||
|
||||
if(loggedIn)
|
||||
if (loggedIn)
|
||||
{
|
||||
mainMenu[1].type=ITEM_ACTIVE;
|
||||
mainMenu[1].type = ITEM_ACTIVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
mainMenu[1].type=ITEM_ACTIVE;
|
||||
}
|
||||
mainMenu[1].type = ITEM_ACTIVE;
|
||||
}
|
||||
|
||||
OpenMenu(mainMenu, 0, _panelMenuBeginX, _panelMenuBeginY, handler);
|
||||
|
||||
OpenMenu(mainMenu,0,panelMenuBeginX,panelMenuBeginY,handler);
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
//------------------------------------------------------------------
|
||||
// eventHandler.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 14.06.2020
|
||||
// Description: Handles the menubar and the menu
|
||||
// Description: Handles the menubar and the menu
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#ifndef MENU_HANDLER
|
||||
|
@ -11,51 +11,52 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
class MenuHandler {
|
||||
public:
|
||||
|
||||
/**
|
||||
using std::string;
|
||||
|
||||
class MenuHandler
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Defines fonds, sets global Event Handler and starts new content
|
||||
*
|
||||
* @param name name of the application
|
||||
*/
|
||||
MenuHandler(const std::string &name);
|
||||
MenuHandler(const string &name);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~MenuHandler();
|
||||
~MenuHandler();
|
||||
|
||||
irect* getContentRect(){return &contentRect;};
|
||||
irect* getMenuButtonRect(){return &menuButtonRect;};
|
||||
irect *getContentRect() { return &_contentRect; };
|
||||
irect *getMenuButtonRect() { return &_menuButtonRect; };
|
||||
|
||||
/**
|
||||
/**
|
||||
* Shows the menu on the screen, lets the user choose menu options and then redirects the handler to the caller
|
||||
*
|
||||
* @param loogedIn the status if the user is logged in
|
||||
* @param handler handles the clicks on the menu
|
||||
* @return int returns if the event was handled
|
||||
*/
|
||||
int createMenu(bool loggedIn, iv_menuhandler handler);
|
||||
int createMenu(bool loggedIn, iv_menuhandler handler);
|
||||
|
||||
private:
|
||||
ifont* menuFont;
|
||||
private:
|
||||
ifont *_menuFont;
|
||||
|
||||
int panelMenuBeginX;
|
||||
int panelMenuBeginY;
|
||||
int panelMenuHeight;
|
||||
int mainMenuWidth;
|
||||
irect menuButtonRect;
|
||||
int _panelMenuBeginX;
|
||||
int _panelMenuBeginY;
|
||||
int _panelMenuHeight;
|
||||
int _mainMenuWidth;
|
||||
irect _menuButtonRect;
|
||||
|
||||
imenu mainMenu;
|
||||
irect contentRect;
|
||||
imenu _mainMenu;
|
||||
irect _contentRect;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Functions needed to call C function, handles the panel
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
static void panelHandlerStatic();
|
||||
|
||||
static void panelHandlerStatic();
|
||||
};
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
//------------------------------------------------------------------
|
||||
// listView.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "inkview.h"
|
||||
|
@ -15,100 +15,101 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
|
||||
ListView::ListView(irect* ContentRect, const vector<Item>& Items): contentRect(ContentRect), items(Items)
|
||||
ListView::ListView(irect *contentRect, const vector<Item> &items) : _contentRect(contentRect), _items(items)
|
||||
{
|
||||
loadingScreenRect = iRect(contentRect->w/2-100,contentRect->h/2-50,200,100,ALIGN_CENTER);
|
||||
_loadingScreenRect = iRect(_contentRect->w / 2 - 100, _contentRect->h / 2 - 50, 200, 100, ALIGN_CENTER);
|
||||
_font = OpenFont("LiberationMono", 30, 1);
|
||||
SetFont(_font, BLACK);
|
||||
FillAreaRect(_contentRect, WHITE);
|
||||
|
||||
font = OpenFont("LiberationMono",30,1);
|
||||
SetFont(font,BLACK);
|
||||
FillAreaRect(contentRect,WHITE);
|
||||
|
||||
entries.clear();
|
||||
_entries.clear();
|
||||
|
||||
int itemCount = 7;
|
||||
footerHeight = 100;
|
||||
headerHeight = 40;
|
||||
int entrySize = (contentRect->h-footerHeight-headerHeight)/itemCount;
|
||||
_footerHeight = 100;
|
||||
_headerHeight = 40;
|
||||
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / itemCount;
|
||||
|
||||
shownPage = 1;
|
||||
page = 1;
|
||||
_shownPage = 1;
|
||||
_page = 1;
|
||||
|
||||
auto i = items.size();
|
||||
auto i = _items.size();
|
||||
auto z = 0;
|
||||
|
||||
while(i > 0)
|
||||
{
|
||||
if(z>=itemCount)
|
||||
_entries.reserve(i);
|
||||
|
||||
while (i > 0)
|
||||
{
|
||||
if (z >= itemCount)
|
||||
{
|
||||
page++;
|
||||
z=0;
|
||||
_page++;
|
||||
z = 0;
|
||||
}
|
||||
|
||||
irect rect = iRect(contentRect->x,z*entrySize+headerHeight+contentRect->y,contentRect->w,entrySize,0);
|
||||
this->entries.push_back(ListViewEntry(page, rect));
|
||||
irect rect = iRect(_contentRect->x, z * entrySize + _headerHeight + _contentRect->y, _contentRect->w, entrySize, 0);
|
||||
this->_entries.emplace_back(_page, rect);
|
||||
i--;
|
||||
z++;
|
||||
}
|
||||
|
||||
pageButton = iRect(contentRect->w-100,contentRect->h+contentRect->y-footerHeight,100,footerHeight,ALIGN_CENTER);
|
||||
_pageButton = iRect(_contentRect->w - 100, _contentRect->h + _contentRect->y - _footerHeight, 100, _footerHeight, ALIGN_CENTER);
|
||||
|
||||
drawEntries();
|
||||
drawFooter();
|
||||
|
||||
}
|
||||
|
||||
ListView::~ListView()
|
||||
{
|
||||
delete font;
|
||||
delete _font;
|
||||
}
|
||||
|
||||
void ListView::drawHeader(const string &headerText)
|
||||
{
|
||||
font = OpenFont("LiberationMono",35,1);
|
||||
SetFont(font,BLACK);
|
||||
_font = OpenFont("LiberationMono", 35, 1);
|
||||
SetFont(_font, BLACK);
|
||||
|
||||
DrawTextRect(contentRect->x,contentRect->y,contentRect->w,headerHeight-1,headerText.c_str(),ALIGN_LEFT);
|
||||
DrawTextRect(_contentRect->x, _contentRect->y, _contentRect->w, _headerHeight - 1, headerText.c_str(), ALIGN_LEFT);
|
||||
|
||||
int line = (contentRect->y+headerHeight)-2;
|
||||
DrawLine(0,line,ScreenWidth(),line,BLACK);
|
||||
int line = (_contentRect->y + _headerHeight) - 2;
|
||||
DrawLine(0, line, ScreenWidth(), line, BLACK);
|
||||
}
|
||||
|
||||
void ListView::drawFooter()
|
||||
{
|
||||
string footer = Util::intToString(shownPage) + "/" + Util::intToString(page);
|
||||
SetFont(font, WHITE);
|
||||
FillAreaRect(&pageButton, BLACK);
|
||||
DrawTextRect2(&pageButton,footer.c_str());
|
||||
string footer = Util::intToString(_shownPage) + "/" + Util::intToString(_page);
|
||||
SetFont(_font, WHITE);
|
||||
FillAreaRect(&_pageButton, BLACK);
|
||||
DrawTextRect2(&_pageButton, footer.c_str());
|
||||
}
|
||||
|
||||
void ListView::drawEntries()
|
||||
{
|
||||
for(auto i = 0; i < entries.size(); i++)
|
||||
for (auto i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if(entries[i].getPage()==shownPage)
|
||||
entries[i].draw(items[i]);
|
||||
if (_entries[i].getPage() == _shownPage)
|
||||
_entries[i].draw(_items[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int ListView::listClicked(int x, int y)
|
||||
{
|
||||
SetFont(font,BLACK);
|
||||
SetFont(_font, BLACK);
|
||||
|
||||
if(IsInRect(x,y,&pageButton))
|
||||
if (IsInRect(x, y, &_pageButton))
|
||||
{
|
||||
if(page>1)
|
||||
if (_page > 1)
|
||||
{
|
||||
FillAreaRect(contentRect,WHITE);
|
||||
FillAreaRect(_contentRect, WHITE);
|
||||
|
||||
if(shownPage>=page)
|
||||
if (_shownPage >= _page)
|
||||
{
|
||||
shownPage = 1;
|
||||
_shownPage = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
shownPage++;
|
||||
_shownPage++;
|
||||
}
|
||||
|
||||
drawEntries();
|
||||
|
@ -117,14 +118,14 @@ int ListView::listClicked(int x, int y)
|
|||
}
|
||||
else
|
||||
{
|
||||
FillAreaRect(contentRect,WHITE);
|
||||
FillAreaRect(_contentRect, WHITE);
|
||||
|
||||
for(unsigned int i = 0; i < entries.size(); i++)
|
||||
for (unsigned int i = 0; i < _entries.size(); i++)
|
||||
{
|
||||
if(entries[i].getPage()==shownPage && IsInRect(x,y,entries[i].getRect())==1)
|
||||
if (_entries[i].getPage() == _shownPage && IsInRect(x, y, _entries[i].getPosition()) == 1)
|
||||
{
|
||||
DrawTextRect2(&loadingScreenRect,"Loading...");
|
||||
PartialUpdate(loadingScreenRect.x,loadingScreenRect.y,loadingScreenRect.w,loadingScreenRect.h);
|
||||
DrawTextRect2(&_loadingScreenRect, "Loading...");
|
||||
PartialUpdate(_loadingScreenRect.x, _loadingScreenRect.y, _loadingScreenRect.w, _loadingScreenRect.h);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------
|
||||
// listView.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
// Description: An UI class to display items in a listview
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -16,65 +16,64 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
using std::vector;
|
||||
|
||||
class ListView
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
public:
|
||||
/**
|
||||
* Displays a list view
|
||||
*
|
||||
* @param ContentRect area of the screen where the list view is placed
|
||||
* @param Items items that shall be shown in the listview
|
||||
*/
|
||||
ListView(irect* ContentRect, const vector<Item> &Items);
|
||||
ListView(irect *contentRect, const vector<Item> &items);
|
||||
|
||||
/**
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~ListView();
|
||||
~ListView();
|
||||
|
||||
/**
|
||||
/**
|
||||
* draws the header including an item to navigate a page up
|
||||
*
|
||||
*/
|
||||
void drawHeader(const string &headerText);
|
||||
void drawHeader(const string &headerText);
|
||||
|
||||
/**
|
||||
/**
|
||||
* draws the footer including a page changer
|
||||
*
|
||||
*/
|
||||
void drawFooter();
|
||||
void drawFooter();
|
||||
|
||||
/**
|
||||
/**
|
||||
* iterates through the items and sends them to the listViewEntry Class for drawing
|
||||
*
|
||||
*/
|
||||
void drawEntries();
|
||||
void drawEntries();
|
||||
|
||||
/**
|
||||
/**
|
||||
* Checkes if the listview has been clicked and either changes the page or returns item ID
|
||||
*
|
||||
* @param x x-coordinate
|
||||
* @param y y-coordinate
|
||||
* @return int Item ID that has been clicked, -1 if no Item was clicked
|
||||
*/
|
||||
int listClicked(int x, int y);
|
||||
int listClicked(int x, int y);
|
||||
|
||||
private:
|
||||
irect* contentRect;
|
||||
const vector<Item> &items;
|
||||
|
||||
irect loadingScreenRect;
|
||||
ifont* font;
|
||||
private:
|
||||
irect *_contentRect;
|
||||
const vector<Item> _items;
|
||||
|
||||
vector<ListViewEntry> entries;
|
||||
int page;
|
||||
int shownPage;
|
||||
irect pageButton;
|
||||
int footerHeight;
|
||||
int headerHeight;
|
||||
irect _loadingScreenRect;
|
||||
ifont *_font;
|
||||
|
||||
vector<ListViewEntry> _entries;
|
||||
int _page;
|
||||
int _shownPage;
|
||||
irect _pageButton;
|
||||
int _footerHeight;
|
||||
int _headerHeight;
|
||||
};
|
||||
#endif
|
|
@ -1,57 +1,51 @@
|
|||
//------------------------------------------------------------------
|
||||
// listViewEntry.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "inkview.h"
|
||||
#include "item.h"
|
||||
#include "listViewEntry.h"
|
||||
#include "util.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
ListViewEntry::ListViewEntry(int Page, irect Rect): rect(Rect), page(Page)
|
||||
ListViewEntry::ListViewEntry(int page, irect rect) : _page(page), _position(rect)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ListViewEntry::draw(const Item &item) const
|
||||
{
|
||||
{
|
||||
int fontHeight = 30;
|
||||
|
||||
irect pageButton = iRect(rect.x,rect.y,100,rect.h-30,ALIGN_LEFT);
|
||||
irect pageButton = iRect(_position.x, _position.y, 100, _position.h - 30, ALIGN_LEFT);
|
||||
|
||||
if(item.getType()==IFILE)
|
||||
if (item.getType() == IFILE)
|
||||
{
|
||||
FillAreaRect(&pageButton, BLACK);
|
||||
DrawTextRect2(&pageButton,"bitmap");
|
||||
DrawTextRect(pageButton.w,rect.y+2*fontHeight,rect.w,fontHeight,item.getFiletype().c_str(),ALIGN_LEFT);
|
||||
if(item.isDownloaded())
|
||||
DrawTextRect2(&pageButton, "bitmap");
|
||||
DrawTextRect(pageButton.w, _position.y + 2 * fontHeight, _position.w, fontHeight, item.getFiletype().c_str(), ALIGN_LEFT);
|
||||
if (item.isDownloaded())
|
||||
{
|
||||
DrawTextRect(rect.x,rect.y+3*fontHeight,rect.w,fontHeight,"Synced",ALIGN_RIGHT);
|
||||
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, "Synced", ALIGN_RIGHT);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTextRect(rect.x,rect.y+3*fontHeight,rect.w,fontHeight,"Download",ALIGN_RIGHT);
|
||||
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, "Download", ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
FillAreaRect(&pageButton, BLACK);
|
||||
DrawTextRect2(&pageButton,"bitmap");
|
||||
DrawTextRect2(&pageButton, "bitmap");
|
||||
}
|
||||
|
||||
DrawTextRect(pageButton.w,rect.y,rect.w,fontHeight,item.getTitle().c_str(),ALIGN_LEFT);
|
||||
DrawTextRect(pageButton.w,rect.y+3*fontHeight,rect.w,fontHeight,item.getSize().c_str(),ALIGN_LEFT);
|
||||
|
||||
DrawTextRect(rect.x,rect.y+2*fontHeight,rect.w,fontHeight,item.getLastEditDate().c_str(),ALIGN_RIGHT);
|
||||
DrawTextRect(pageButton.w, _position.y, _position.w, fontHeight, item.getTitle().c_str(), ALIGN_LEFT);
|
||||
DrawTextRect(pageButton.w, _position.y + 3 * fontHeight, _position.w, fontHeight, Util::intToString(item.getSize()).c_str(), ALIGN_LEFT);
|
||||
|
||||
DrawTextRect(_position.x, _position.y + 2 * fontHeight, _position.w, fontHeight, item.getLastEditDate().c_str(), ALIGN_RIGHT);
|
||||
|
||||
int line = (rect.y+rect.h)-1;
|
||||
DrawLine(0,line,ScreenWidth(),line,BLACK);
|
||||
|
||||
int line = (_position.y + _position.h) - 1;
|
||||
DrawLine(0, line, ScreenWidth(), line, BLACK);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------
|
||||
// listViewEntry.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
// Description: An listViewEntry that handles an item of a listview
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -12,34 +12,29 @@
|
|||
#include "inkview.h"
|
||||
#include "item.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
class ListViewEntry
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
public:
|
||||
/**
|
||||
* Creates an ListViewEntry
|
||||
*
|
||||
* @param Page site of the listView the Entry is shown
|
||||
* @param Rect area of the screen the item is positioned
|
||||
*/
|
||||
ListViewEntry(int Page, irect Rect);
|
||||
ListViewEntry(int page, irect position);
|
||||
|
||||
irect* getRect(){return ▭};
|
||||
int getPage(){return page;};
|
||||
irect *getPosition() { return &_position; }
|
||||
int getPage() const { return _page; }
|
||||
|
||||
/**
|
||||
/**
|
||||
* draws the listViewEntry to the screen
|
||||
*
|
||||
* @param item item that shall be drawn
|
||||
*/
|
||||
void draw(const Item &item) const;
|
||||
void draw(const Item &item) const;
|
||||
|
||||
private:
|
||||
irect rect;
|
||||
int page;
|
||||
private:
|
||||
int _page;
|
||||
irect _position;
|
||||
};
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
//------------------------------------------------------------------
|
||||
// item.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "item.h"
|
||||
|
@ -17,38 +17,38 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
Item::Item(const string& xmlItem)
|
||||
Item::Item(const string &xmlItem)
|
||||
{
|
||||
path = Util::getXMLAttribute(xmlItem,"d:href");
|
||||
lastEdithDate = Util::getXMLAttribute(xmlItem,"d:getlastmodified");
|
||||
title = path;
|
||||
_path = Util::getXMLAttribute(xmlItem, "d:href");
|
||||
_lastEditDate = Util::getXMLAttribute(xmlItem, "d:getlastmodified");
|
||||
_title = _path;
|
||||
|
||||
if(path.back()=='/')
|
||||
{
|
||||
type=IFOLDER;
|
||||
title = title.substr(0,path.length()-1);
|
||||
size = Util::getXMLAttribute(xmlItem,"d:quota-used-bytes");
|
||||
}
|
||||
else
|
||||
{
|
||||
type=IFILE;
|
||||
size = Util::getXMLAttribute(xmlItem,"d:getcontentlength");
|
||||
fileType = Util::getXMLAttribute(xmlItem,"d:getcontenttype");
|
||||
downloaded = false;
|
||||
}
|
||||
if (_path.back() == '/')
|
||||
{
|
||||
_type = IFOLDER;
|
||||
_title = _title.substr(0, _path.length() - 1);
|
||||
_size = atoi(Util::getXMLAttribute(xmlItem, "d:quota-used-bytes").c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
_type = IFILE;
|
||||
_size = atoi(Util::getXMLAttribute(xmlItem, "d:getcontentlength").c_str());
|
||||
_fileType = Util::getXMLAttribute(xmlItem, "d:getcontenttype");
|
||||
_downloaded = false;
|
||||
}
|
||||
|
||||
title = title.substr(title.find_last_of("/")+1,title.length());
|
||||
_title = _title.substr(_title.find_last_of("/") + 1, _title.length());
|
||||
}
|
||||
|
||||
string Item::isClicked()
|
||||
{
|
||||
if(type==IFILE)
|
||||
if (_type == IFILE)
|
||||
{
|
||||
//downloadFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
return path;
|
||||
return _path;
|
||||
}
|
||||
|
||||
return "";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------
|
||||
// item.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
// Description: Describes an WEBDAV item
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -13,48 +13,49 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
|
||||
enum Itemtype {IFILE,IFOLDER};
|
||||
enum Itemtype
|
||||
{
|
||||
IFILE,
|
||||
IFOLDER
|
||||
};
|
||||
|
||||
class Item
|
||||
{
|
||||
public:
|
||||
public:
|
||||
Item(const string &xmlItem);
|
||||
|
||||
Item(const string& xmlItem);
|
||||
void setPath(const string &path) { _path = path; };
|
||||
string getPath() const { return _path; };
|
||||
|
||||
void setPath(const string& Path) {path=Path;};
|
||||
string getPath() const {return path;};
|
||||
Itemtype getType() const { return _type; };
|
||||
|
||||
Itemtype getType() const {return type;};
|
||||
void setTitle(const string &title) { _title = title; };
|
||||
string getTitle() const { return _title; };
|
||||
|
||||
void setTitle(const string& Title) {title=Title;};
|
||||
string getTitle() const {return title;};
|
||||
bool isDownloaded() const { return _downloaded; };
|
||||
|
||||
bool isDownloaded() const {return downloaded;};
|
||||
string getLastEditDate() const { return _lastEditDate; };
|
||||
|
||||
string getLastEditDate() const {return lastEdithDate;};
|
||||
int getSize() const { return _size; };
|
||||
|
||||
string getSize() const {return size;};
|
||||
string getFiletype() const { return _fileType; };
|
||||
|
||||
string getFiletype() const {return fileType;};
|
||||
|
||||
/**
|
||||
/**
|
||||
* downloads a file from WEBDAV and saves it
|
||||
*
|
||||
* @return true - sucessfull, false - error
|
||||
*/
|
||||
string isClicked();
|
||||
|
||||
private:
|
||||
string path;
|
||||
Itemtype type;
|
||||
string title;
|
||||
bool downloaded;
|
||||
string lastEdithDate;
|
||||
string size;
|
||||
string fileType;
|
||||
|
||||
string isClicked();
|
||||
|
||||
private:
|
||||
string _path;
|
||||
Itemtype _type;
|
||||
string _title;
|
||||
bool _downloaded;
|
||||
string _lastEditDate;
|
||||
int _size;
|
||||
string _fileType;
|
||||
};
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
//------------------------------------------------------------------
|
||||
// log.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
#include "log.h"
|
||||
|
@ -12,20 +12,20 @@
|
|||
#include <string>
|
||||
#include <fstream>
|
||||
|
||||
void Log::writeLog(const string& text)
|
||||
void Log::writeLog(const string &text)
|
||||
{
|
||||
std::ofstream log(CONFIG_PATH + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out);
|
||||
std::ofstream log(CONFIG_PATH + std::string("/logfile.txt"), std::ios_base::app | std::ios_base::out);
|
||||
|
||||
time_t rawtime;
|
||||
struct tm * timeinfo;
|
||||
struct tm *timeinfo;
|
||||
char buffer[80];
|
||||
|
||||
time (&rawtime);
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime(buffer,sizeof(buffer),"%d/%b/%Y:%H:%M:%S %z",timeinfo);
|
||||
strftime(buffer, sizeof(buffer), "%d/%b/%Y:%H:%M:%S %z", timeinfo);
|
||||
|
||||
log << buffer << ":" << text << "\n";
|
||||
log << buffer << ":" << text << "\n";
|
||||
|
||||
log.close();
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------
|
||||
// log.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 05.08.2020
|
||||
// Description: Deals with log entries
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -13,21 +13,19 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
|
||||
using std::string;
|
||||
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
public:
|
||||
/**
|
||||
* Writes a log entry to the log file
|
||||
*
|
||||
* @param text that shall be written to the log
|
||||
*/
|
||||
static void writeLog(const string& text);
|
||||
static void writeLog(const string &text);
|
||||
|
||||
private:
|
||||
Log() {}
|
||||
private:
|
||||
Log() {}
|
||||
};
|
||||
#endif
|
|
@ -1,9 +1,9 @@
|
|||
//------------------------------------------------------------------
|
||||
// util.cpp
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------------
|
||||
#include "util.h"
|
||||
#include "inkview.h"
|
||||
|
@ -13,70 +13,74 @@
|
|||
#include <math.h>
|
||||
#include <fstream>
|
||||
|
||||
string Util::intToString(int value)
|
||||
using std::ostringstream;
|
||||
using std::string;
|
||||
|
||||
string Util::intToString(const int value)
|
||||
{
|
||||
std::ostringstream stm;
|
||||
stm << value ;
|
||||
ostringstream stm;
|
||||
stm << value;
|
||||
return stm.str();
|
||||
}
|
||||
|
||||
size_t Util::writeCallback(void *contents, size_t size, size_t nmemb, void *userp)
|
||||
{
|
||||
((std::string*)userp)->append((char*)contents, size * nmemb);
|
||||
((string *)userp)->append((char *)contents, size * nmemb);
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
size_t Util::writeData(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
size_t Util::writeData(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
size_t written = iv_fwrite(ptr, size, nmemb, stream);
|
||||
size_t written = iv_fwrite(ptr, size, nmemb, stream);
|
||||
return written;
|
||||
}
|
||||
|
||||
bool Util::connectToNetwork()
|
||||
{
|
||||
iv_netinfo *netinfo = NetInfo();
|
||||
if (netinfo->connected)
|
||||
return true;
|
||||
iv_netinfo *netinfo = NetInfo();
|
||||
if (netinfo->connected)
|
||||
return true;
|
||||
|
||||
const char *network_name = nullptr;
|
||||
int result = NetConnect2(network_name, 1);
|
||||
if (result != 0) {
|
||||
Message(3,"Warning","cannot connect to Internet.",200);
|
||||
return false;
|
||||
}
|
||||
const char *network_name = nullptr;
|
||||
int result = NetConnect2(network_name, 1);
|
||||
if (result != 0)
|
||||
{
|
||||
Message(3, "Warning", "cannot connect to Internet.", 200);
|
||||
return false;
|
||||
}
|
||||
|
||||
netinfo = NetInfo();
|
||||
if (netinfo->connected)
|
||||
return true;
|
||||
netinfo = NetInfo();
|
||||
if (netinfo->connected)
|
||||
return true;
|
||||
|
||||
Message(3,"Warning","cannot connect to Internet.",200);
|
||||
return false;
|
||||
Message(3, "Warning", "cannot connect to Internet.", 200);
|
||||
return false;
|
||||
}
|
||||
|
||||
int Util::progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
int Util::progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
|
||||
{
|
||||
if (dltotal <= 0.0)
|
||||
return 0;
|
||||
|
||||
int percentage = round(dlnow/dltotal * 100);
|
||||
if(percentage%10==0)
|
||||
UpdateProgressbar("Downloading issue",percentage);
|
||||
int percentage = round(dlnow / dltotal * 100);
|
||||
if (percentage % 10 == 0)
|
||||
UpdateProgressbar("Downloading issue", percentage);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
string Util::getXMLAttribute(const string& buffer, const string& name)
|
||||
string Util::getXMLAttribute(const string &buffer, const string &name)
|
||||
{
|
||||
string returnString = buffer;
|
||||
string searchString = "<" + name + ">";
|
||||
string returnString = buffer;
|
||||
string searchString = "<" + name + ">";
|
||||
size_t found = buffer.find(searchString);
|
||||
|
||||
if (found!=std::string::npos)
|
||||
if (found != std::string::npos)
|
||||
{
|
||||
returnString = returnString.substr(found+searchString.length());
|
||||
|
||||
return returnString.substr(0,returnString.find("</" + name + ">"));
|
||||
returnString = returnString.substr(found + searchString.length());
|
||||
|
||||
return returnString.substr(0, returnString.find("</" + name + ">"));
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
//------------------------------------------------------------------
|
||||
// util.h
|
||||
//
|
||||
// Author: JuanJakobo
|
||||
// Author: JuanJakobo
|
||||
// Date: 04.08.2020
|
||||
// Description: Various utility methods
|
||||
//-------------------------------------------------------------------
|
||||
|
@ -13,50 +13,49 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
using namespace std;
|
||||
using std::string;
|
||||
|
||||
class Util
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Converts an int to an string, as C++11 command is not supported
|
||||
*
|
||||
* @param value the int value that shall be converted
|
||||
* @return same value in string format
|
||||
*/
|
||||
static string intToString(int value);
|
||||
static string intToString(const int value);
|
||||
|
||||
/**
|
||||
* Handles the return of curl command
|
||||
*
|
||||
*/
|
||||
static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp);
|
||||
static size_t writeCallback(void *contents, size_t size, size_t nmemb, void *userp);
|
||||
|
||||
/**
|
||||
* Saves the return of curl command
|
||||
*
|
||||
*/
|
||||
static size_t writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
static size_t writeData(void *ptr, size_t size, size_t nmemb, FILE *stream);
|
||||
|
||||
/**
|
||||
* Checks if a network connection can be established
|
||||
*
|
||||
* @return true - network access succeeded, false - network access failed
|
||||
*/
|
||||
static bool connectToNetwork();
|
||||
static bool connectToNetwork();
|
||||
|
||||
/**
|
||||
* Returns an integer representing the download progress
|
||||
*
|
||||
*/
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow);
|
||||
|
||||
/**
|
||||
* Returns an integer representing the download progress
|
||||
*
|
||||
*/
|
||||
static string getXMLAttribute(const string& buffer, const string& name);
|
||||
static string getXMLAttribute(const string &buffer, const string &name);
|
||||
|
||||
private:
|
||||
Util() {}
|
||||
|
|
Loading…
Reference in New Issue