/***************************************************************************
 *            gosmroute.h
 *
 *  Thu Jul 19 19:00:10 2007
 *  Copyright  2007  Steffen Pohle
 *  steffen@gulpe.de
 ****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef _OSMROUTE_H_
#define _OSMROUTE_H_

#if defined(__MINGW32CE__) || defined(_WIN32_WCE)
  #define _WINDOWSCE_
#endif

#ifdef __MINGW32__
  #define _WINDOWS_
#endif

#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) && !defined(__MINGW32__)
  #include <locale.h>
  #include <errno.h>
  #define _LINUX_
#endif
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifndef FALSE
  #define FALSE 0
#endif

#ifndef TRUE
  #define TRUE 1
#endif

/* #ifdef HAVE_SDL
  #include <SDL.h>
  #define FALSE 0
  #define TRUE 1
#endif


#ifdef ANDROID
  #define FALSE 0
  #define TRUE 1
#endif
*/

/*
 * Standard gettext macros.
 */
#ifdef ENABLE_NLS
#  include <libintl.h>
#  undef _
#  define _(String) dgettext (PACKAGE, String)
#  ifdef gettext_noop
#    define N_(String) gettext_noop (String)
#  else
#    define N_(String) (String)
#  endif
#else
#  define textdomain(String) (String)
#  define gettext(String) (String)
#  define dgettext(Domain,Message) (Message)
#  define dcgettext(Domain,Message,Type) (Message)
#  define bindtextdomain(Domain,Directory) (Domain)
#  define _(String) (String)
#  define N_(String) (String)
#endif

#define MAPDOWNLOAD_OSM 0
#define MAPDOWNLOAD_MAP 1

#define LEN_FILENAME 128

/*
 * debug
 */

#include "map.h"
#include "system.h"
#include "memoryleak.h"

enum {	/* what we're doing at the moment */
	APPSTATUS_nothing,
	APPSTATUS_loadfromweb,
	APPSTATUS_saveall,
	APPSTATUS_quit
};


struct {
	int x;
	int y;
} typedef iPoint;


struct {
	float x;
	float y;
} typedef fPoint;

struct cfgdata {
	char mappath[LEN_FILENAME];
	char appdatapath[LEN_FILENAME];
	char configpath[LEN_FILENAME];
	char cachepath[LEN_FILENAME];
	char logpath[LEN_FILENAME];
	char temppath[LEN_FILENAME];

	char gps_device[LEN_FILENAME];
	int  gps_flags;
	
	float last_lon;
	float last_lat;
	float last_scale;

	int softkeyboard;
	
	int debug;
};

struct appdata {
	char statusline_text[255];
	float statusline_progress;  // value in 0.0 to 1.0
	int status;
	float debug_lon;
	float debug_lat;
};

extern struct cfgdata cfg;
extern struct appdata app;

#ifdef HAVE_GTK
#include "gtk_port.h"
#endif

#ifdef HAVE_WINAPI
#include "wince_port.h"
#endif

#ifdef HAVE_NCURSES
#include "ncurses_port.h"
#endif

#ifdef HAVE_SDL
#include "sdl_port.h"
#endif

#ifdef ANDROID
#include "android_port.h"
#endif


/* app_* will hold all application programm code undepending on systemcalls.. 
 * defined in main.c
 */
extern int app_init (int argc, char **argv);
extern int app_shutdown ();
extern void app_status (int status, char *text, float progress);
extern int app_loop ();

extern void config_init ();
extern void config_draw_load (char *fn);
extern void config_load ();
extern void config_draw_save (char *fn);
extern void config_save ();

extern void gui_enabled (int enabled);
extern void gpssetting_wnd_show ();
extern char *dialog_getfilename (char *caption, char *filter, int save);
extern void main_wnd_enable (int enabled);
extern void main_wnd_loop (long long int cur, long long int max);
extern void main_wnd_update ();

extern char *gui_sdir_show (char *startpath);

#endif
