Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP, trying to work again on the cURL based download from pgrandin #1134

Draft
wants to merge 47 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d4a3317
Adding basic UI town search tests
pgrandin Jan 2, 2017
9e7fda3
Add pointer icon when clicking via CI
pgrandin Jan 2, 2017
f753bd6
Fetch zlib from github, reduces download issues
pgrandin Jan 2, 2017
fa0669e
Download a sample map for UI tests
pgrandin Jan 2, 2017
b102259
Start navit in the background
pgrandin Jan 2, 2017
cb5fde9
Fixed Demo vehicle activation
pgrandin Jan 2, 2017
454b9ab
Set a destination for UI tests
pgrandin Jan 2, 2017
57d1b88
UI tests to switch to 3d view
pgrandin Jan 2, 2017
61b76bb
Capture image when clicking for UI tests
pgrandin Jan 2, 2017
591c5f0
Append 5 frames of usage to the UI tests
pgrandin Jan 2, 2017
7645396
Added a map downloader stub
pgrandin Jan 22, 2017
91803c9
Added a map downloader stub
pgrandin Jan 22, 2017
e976b88
Added a menu entry for the map downloader
pgrandin Jan 22, 2017
6440ce4
Close file descriptor when download is finished
pgrandin Jan 23, 2017
e6962f7
Implemented download resume
pgrandin Jan 25, 2017
3a83eef
Enable map after download
pgrandin Jan 26, 2017
675ab3b
Ensures libcurl is installed for this branch
hoehnp Aug 6, 2023
dfd885f
Made the download feature a generic flag
pgrandin Jan 26, 2017
e552e7e
Dummy commit to trigger a build
pgrandin Oct 29, 2017
9176b4f
fixed code-factor problems
hoehnp Aug 11, 2021
7d8f506
remove probably unrelated files
hoehnp Aug 11, 2021
67c7ac8
removed leftovers from rebasing
hoehnp Aug 11, 2021
7b90d06
added installation of sanity script packages
hoehnp Aug 11, 2021
eb41312
add sudo for installation
hoehnp Aug 11, 2021
4d50853
fixing sanity checks round 1
hoehnp Aug 11, 2021
bcc485f
further style check corrections
hoehnp Aug 12, 2021
1a63e91
ändrad: navit/gui/internal/gui_internal_map_downloader.c
hoehnp Aug 12, 2021
7a1c913
ändrad: navit/gui/internal/gui_internal_map_downloader.c
hoehnp Aug 12, 2021
a3a6e43
further corrections of coding style
hoehnp Aug 12, 2021
1c505ea
hopefully network.c is also clean now, only xml files missing
hoehnp Aug 12, 2021
ad4fac2
map download now working, next step is generation of menu based on json
hoehnp Sep 7, 2021
ec01fb5
correct error from sanity check
hoehnp Sep 7, 2021
8e8889d
added missing files for later JSON processing
hoehnp Sep 8, 2021
e14dd4a
added python script to generate json file for menu
hoehnp Sep 27, 2021
1d3b096
added generated and add json file for download menu
hoehnp Sep 27, 2021
3fb6d49
added cJSON.c file for compilation
hoehnp Oct 5, 2021
6e9948e
changed from included source code to cJSON library via CMake
hoehnp Oct 18, 2021
abe6079
WiP commit while building up menu
hoehnp Oct 19, 2021
d9c8daf
Add:ci:Use fdroidserver:buildserver image for build_fdroid (#1205)
hoehnp Aug 6, 2023
a93e587
Made the download feature a generic flag
hoehnp Nov 20, 2022
388a462
add script to scrape file sizes for every region to JSON file consumed
hoehnp Nov 19, 2022
ed078c2
remove json format in favour of a simpler csv format
hoehnp Nov 20, 2022
9b7fc5f
change to tsv format for menu
hoehnp Nov 20, 2022
5add383
intermediate commit
hoehnp Feb 4, 2023
712356f
intermediate commit
hoehnp Feb 4, 2023
fc4be10
WiP gui internal map downloader
hoehnp Aug 6, 2023
fc53e46
resolve conflicting files
hoehnp Aug 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ jobs:
- image: circleci/android:api-29-ndk
steps:
- checkout
- run:
name: setup sanity check requirements
command: bash scripts/setup_sanitycheck_requirements.sh
- run:
name: run sanity check script
command: bash scripts/ci_sanity_checks.sh
Expand All @@ -32,7 +35,7 @@ jobs:
name: Setup requirements
command: |
bash scripts/setup_common_requirements.sh
apt-get install -y libpng-dev libfreetype6-dev libdbus-glib-1-dev libgtk2.0-dev curl
apt-get install -y libpng-dev libfreetype6-dev libdbus-glib-1-dev libgtk2.0-dev curl libcurl4-gnutls-dev
- run:
name: Build for Linux
command: bash scripts/build_linux.sh
Expand Down Expand Up @@ -180,6 +183,7 @@ jobs:

# APP_CI: just build our own app
$fdroid build --verbose --on-server --no-tarball

- store_artifacts:
name: Store APK
path: unsigned
Expand All @@ -199,7 +203,7 @@ jobs:
apt-get install -y software-properties-common
add-apt-repository -y ppa:george-edison55/cmake-3.x
apt-get remove -y cmake
apt-get install -y cmake3 mingw-w64 mingw-w64-tools default-jdk nsis libsaxonb-java curl
apt-get install -y cmake3 mingw-w64 mingw-w64-tools default-jdk nsis libsaxonb-java curl libcurl4-gnutls-dev
- run:
name: Build for Windows
command: |
Expand Down
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ add_module(vehicle/qt5 "Qt5 libraries not found" FALSE)
add_module(speech/speech_dispatcher "speech_dispatcher lib not found" FALSE)
add_module(map/garmin "Garmin library not found" FALSE)
add_feature(USE_NATIVE_LANGUAGE_SUPPORT "Gettext not found and not on Windows" FALSE)
add_feature(USE_DOWNLOAD "libcurl not found" FALSE)
set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/cpack.cmake")
set(CPACK_PACKAGE_VENDOR "Navit team")
set(CPACK_PACKAGE_VERSION_MAJOR ${NAVIT_VERSION_MAJOR})
Expand Down Expand Up @@ -238,6 +239,8 @@ find_package(Gettext)
find_package(PNG)
find_package(PythonLibs)
find_package(Threads)
find_package(CURL)
find_package(cJSON)

#Qt detection
if (NOT DISABLE_QT)
Expand Down Expand Up @@ -511,6 +514,21 @@ if (GETTEXT_FOUND)
set_with_reason(USE_NATIVE_LANGUAGE_SUPPORT "Gettext found" TRUE)
endif(GETTEXT_FOUND)

if (CURL_FOUND)
set_with_reason(USE_DOWNLOAD "libcurl found" TRUE)
list(APPEND NAVIT_LIBS "-lcurl")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -u download_map")
set(USE_DOWNLOAD 1)
endif(CURL_FOUND)

if (cJSON_FOUND)
set(HAVE_CJSON 1)
include_directories(${CJSON_INCLUDE_DIRS})
list(APPEND NAVIT_LIBS ${CJSON_LIBRARIES})
else(cJSON_FOUND)
set_with_reason(support/cjson "cJSON not found" TRUE ${INTL_LIBS})
endif(cJSON_FOUND)

#Independent modules
add_module(graphics/null "Default" TRUE)
add_module(osd/core "Default" TRUE)
Expand Down
Binary file added ci/pointer-64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,4 @@

#cmakedefine ENABLE_ROLL 1

#cmakedefine USE_DOWNLOAD 1
4 changes: 4 additions & 0 deletions navit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ set(NAVIT_SRC announcement.c atom.c attr.c cache.c callback.c command.c config_.
profile.c profile_option.c projection.c roadprofile.c route.c script.c search.c speech.c start_real.c sunriset.c transform.c track.c
search_houseno_interpol.c traffic.c util.c vehicle.c vehicleprofile.c xmlconfig.c )

if(USE_DOWNLOAD)
list(APPEND NAVIT_SRC network.c)
endif(USE_DOWNLOAD)

if(NOT USE_PLUGINS)
list(APPEND NAVIT_SRC ${CMAKE_CURRENT_BINARY_DIR}/builtin.c)
endif(NOT USE_PLUGINS)
Expand Down
10 changes: 7 additions & 3 deletions navit/gui/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ if (GUI_INTERNAL_VISUAL_DBG)
add_definitions ("-DGUI_INTERNAL_VISUAL_DBG")
endif(GUI_INTERNAL_VISUAL_DBG)

module_add_library(gui_internal gui_internal.c gui_internal_bookmark.c gui_internal_command.c gui_internal_gesture.c
gui_internal_html.c gui_internal_menu.c gui_internal_poi.c gui_internal_search.c gui_internal_widget.c
gui_internal_keyboard.c)
if(USE_DOWNLOAD)
set(map_downloader_sources gui_internal_map_downloader.c )
endif(USE_DOWNLOAD)

module_add_library(gui_internal ${map_downloader_sources} gui_internal.c gui_internal_bookmark.c gui_internal_command.c
gui_internal_gesture.c gui_internal_html.c gui_internal_menu.c gui_internal_poi.c gui_internal_search.c
gui_internal_widget.c gui_internal_keyboard.c)
104 changes: 23 additions & 81 deletions navit/gui/internal/gui_internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
#include "gui_internal_poi.h"
#include "gui_internal_command.h"
#include "gui_internal_keyboard.h"

#include "network.h"

/**
* Indexes into the config_profiles array.
Expand Down Expand Up @@ -1714,44 +1714,13 @@ static void gui_internal_window_closed(struct gui_priv *this) {
static void gui_internal_cmd_map_download_do(struct gui_priv *this, struct widget *wm, void *data) {
char *text=g_strdup_printf(_("Download %s"),wm->name);
struct widget *w, *wb;
struct map *map=data;
double bllon,bllat,trlon,trlat;

wb=gui_internal_menu(this, text);
g_free(text);
w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
w->spy=this->spacing*3;
gui_internal_widget_append(wb, w);
if (sscanf(wm->prefix,"%lf,%lf,%lf,%lf",&bllon,&bllat,&trlon,&trlat) == 4) {
struct coord_geo g;
struct map_selection sel;
struct map_rect *mr;
struct item *item;

sel.next=NULL;
sel.order=255;
g.lng=bllon;
g.lat=trlat;
transform_from_geo(projection_mg, &g, &sel.u.c_rect.lu);
g.lng=trlon;
g.lat=bllat;
transform_from_geo(projection_mg, &g, &sel.u.c_rect.rl);
sel.range.min=type_none;
sel.range.max=type_last;
mr=map_rect_new(map, &sel);
while ((item=map_rect_get_item(mr))) {
dbg(lvl_info,"item");
}
map_rect_destroy(mr);
}

dbg(lvl_info,"bbox=%s",wm->prefix);
gui_internal_menu_render(this);
struct map_download_info *dl_info=data;
download_map(dl_info);
}

void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, void *data) {
struct attr on, off, download_enabled, download_disabled;
struct widget *w,*wb,*wma;
struct widget *w,*wb,*wma, *wl, *row;
struct map *map=data;
FILE *f;
char *search,buffer[256];
Expand All @@ -1772,9 +1741,9 @@ void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, voi
on.u.num=1;
off.u.num=0;
wb=gui_internal_menu(this, wm->name?wm->name:_("Map Download"));
w=gui_internal_box_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill);
w->spy=this->spacing*3;
w=gui_internal_widget_table_new(this, gravity_top_center|orientation_vertical|flags_expand|flags_fill,1);
gui_internal_widget_append(wb, w);

if (!search) {
wma=gui_internal_button_map_attr_new(this, _("Active"), gravity_left_center|orientation_horizontal|flags_fill, map, &on,
&off, 1);
Expand All @@ -1784,52 +1753,25 @@ void gui_internal_cmd_map_download(struct gui_priv *this, struct widget *wm, voi
download_enabled.type=download_disabled.type=attr_update;
download_enabled.u.num=1;
download_disabled.u.num=0;
wma=gui_internal_button_map_attr_new(this
, _("Download Enabled")
, gravity_left_center|orientation_horizontal|flags_fill
, map
, &download_enabled
, &download_disabled
, 0);
gui_internal_widget_append(w, wma);

f = fopen("maps/menu.tsv", "r");

f=fopen("maps/areas.tsv","r");

while (f && fgets(buffer, sizeof(buffer), f)) {
char *nl,*description,*description_size,*bbox,*size=NULL;
int sp=0;
if ((nl=strchr(buffer,'\n')))
*nl='\0';
if ((nl=strchr(buffer,'\r')))
*nl='\0';
while(buffer[sp] == ' ')
sp++;
if ((bbox=strchr(buffer,'\t')))
*bbox++='\0';
if (bbox && (size=strchr(bbox,'\t')))
*size++='\0';
if (search && !strcmp(buffer, search)) {
wma=gui_internal_button_new_with_callback(this, _("Download completely"), NULL,
gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, map);
wma->name=g_strdup(buffer+sp);
wma->prefix=g_strdup(bbox);
gui_internal_widget_append(w, wma);
found=1;
} else if (sp < sp_match)
found=0;
if (sp == sp_match && found && buffer[sp]) {
description=g_strdup(buffer+sp);
if (size)
description_size=g_strdup_printf("%s (%s)",description,size);
else
description_size=g_strdup(description);
wma=gui_internal_button_new_with_callback(this, description_size, NULL,
gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download, map);
g_free(description_size);
wma->prefix=g_strdup(buffer);
wma->name=description;
gui_internal_widget_append(w, wma);
}
gui_internal_widget_append(w, row=gui_internal_widget_table_row_new(this,
gravity_left|orientation_horizontal|flags_fill));

struct map_download_info *dl_info = g_malloc(sizeof(struct map_download_info));

dl_info->name = g_strsplit(buffer,"\t",0)[0];
dl_info->path = g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/maps/", dl_info->name, ".bin", NULL);
dl_info->xml = g_strjoin(NULL, navit_get_user_data_directory(TRUE), "/maps/", dl_info->name, ".xml", NULL);
dl_info->url = g_strjoin(NULL, "https://github.com/navit-gps/gh-actions-mapserver/releases/download/", g_date_time_format(g_date_time_new_now_local(), "%Y-%m-%d"), "/", dl_info->name, "-", g_date_time_format(g_date_time_new_now_local(), "%Y-%m-%d"), ".bin", NULL);

wl=gui_internal_button_new_with_callback(this, buffer, NULL,
gravity_left_center|orientation_horizontal|flags_fill, gui_internal_cmd_map_download_do, dl_info);

gui_internal_widget_append(row, wl);

}

gui_internal_menu_render(this);
Expand Down
35 changes: 35 additions & 0 deletions navit/gui/internal/gui_internal_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include <ifaddrs.h>
#include <arpa/inet.h>
#endif
#ifdef USE_DOWNLOAD
#include "gui_internal_map_downloader.h"
#endif

static int gui_internal_cmd_escape(struct gui_priv *this, char *function, struct attr **in, struct attr ***out) {
struct attr escaped;
Expand Down Expand Up @@ -1214,6 +1217,38 @@ static struct command_table commands[] = {
#if HAS_IFADDRS
{"network_info",command_cast(gui_internal_cmd2)},
#endif
#ifdef USE_DOWNLOAD
{"map_downloader", command_cast (gui_internal_cmd_map_download)},
#endif
{"E",command_cast(gui_internal_cmd_escape)},
{"abort_navigation",command_cast(gui_internal_cmd2_abort_navigation)},
{"back",command_cast(gui_internal_cmd2_back)},
{"back_to_map",command_cast(gui_internal_cmd2_back_to_map)},
{"bookmarks",command_cast(gui_internal_cmd2)},
{"debug",command_cast(gui_internal_cmd_debug)},
{"formerdests",command_cast(gui_internal_cmd2)},
{"get_data",command_cast(gui_internal_get_data)},
{"img",command_cast(gui_internal_cmd_img)},
{"locale",command_cast(gui_internal_cmd2)},
{"log",command_cast(gui_internal_cmd_log)},
{"menu",command_cast(gui_internal_cmd_menu2)},
{"position",command_cast(gui_internal_cmd2_position)},
{"pois",command_cast(gui_internal_cmd2)},
{"redraw_map",command_cast(gui_internal_cmd_redraw_map)},
{"refresh",command_cast(gui_internal_cmd2_refresh)},
{"route_description",command_cast(gui_internal_cmd2)},
{"route_height_profile",command_cast(gui_internal_cmd2)},
{"set",command_cast(gui_internal_cmd2_set)},
{"setting_layout",command_cast(gui_internal_cmd2)},
{"setting_maps",command_cast(gui_internal_cmd2)},
{"setting_rules",command_cast(gui_internal_cmd2)},
{"setting_vehicle",command_cast(gui_internal_cmd2)},
{"town",command_cast(gui_internal_cmd2)},
{"enter_coord",command_cast(gui_internal_cmd2)},
{"quit",command_cast(gui_internal_cmd2_quit)},
{"waypoints",command_cast(gui_internal_cmd2)},
{"write",command_cast(gui_internal_cmd_write)},
{"about",command_cast(gui_internal_cmd2)},
};

void gui_internal_command_init(struct gui_priv *this, struct attr **attrs) {
Expand Down
Loading