예제 #1
0
void roadmap_lang_initialize (void) {

   const char *p;
   initialized = TRUE;

   roadmap_log (ROADMAP_INFO, "Starting 'roadmap_lang_initialize'");
   roadmap_lang_initialize_params();

   roadmap_lang_allocate ();

   lang_labels[0] = "English";
   lang_values[0] = "eng";
   p = roadmap_path_user ();
   LangNextLoginCb = Realtime_NotifyOnLogin (roadmap_lang_login_cb);

   roadmap_lang_conf_load(roadmap_path_downloads());


   RoadMapLangLoaded = roadmap_lang_load (p);
   if (!RoadMapLangLoaded){
      p = roadmap_path_downloads();
      RoadMapLangLoaded = roadmap_lang_load (p);
   }
   RoadMapLangRTL = (strcasecmp(roadmap_lang_get ("RTL"), "Yes") == 0);
   NOPH_SetSystemLanguage(roadmap_lang_get_system_lang());
}
예제 #2
0
static int roadmap_help_prepare (void) {

   const char *path;


   /* First look for the user directory. */
   path = roadmap_path_user();
   if (roadmap_file_exists(path, RDM_MANUAL)) {
      roadmap_help_make_url (path);
      return 1;
   }


   /* Then look throughout the system path list. */

   for (path = roadmap_path_first("config");
         path != NULL;
         path = roadmap_path_next("config", path))
   {
      if (roadmap_file_exists(path, RDM_MANUAL)) {

         roadmap_help_make_url (path);
         return 1;
      }
   }

   roadmap_log(ROADMAP_ERROR, "manual not found");
   return 0;
}
예제 #3
0
void editor_db_delete (int map_id) {

   char name[100];
  	const char *map_path;

   map_path = roadmap_db_map_path();
   snprintf (name, sizeof(name), "edt%05d.dat", map_id);
   
   if (roadmap_file_exists (map_path, name)) {

      char **files;
      char **cursor;
      char directory[512];
      char full_name[512];

      /* Delete notes wav files */
      /* FIXME this is broken for multiple counties */
      roadmap_path_format (directory, sizeof (directory), roadmap_path_user (), "markers");
      files = roadmap_path_list (directory, ".wav");

      for (cursor = files; *cursor != NULL; ++cursor) {

         roadmap_path_format (full_name, sizeof (full_name), directory, *cursor);
         roadmap_file_remove (NULL, full_name);
      }

      /* Remove the actual editor file */
      roadmap_file_remove (map_path, name);
   }
}
예제 #4
0
const char *roadmap_db_map_path (void) {

   const char *map_path;
   static char map_path_static[512];
   static int map_path_initialized = 0;
   
   if (!map_path_initialized) { 
   
	#ifdef J2ME
      map_path = roadmap_path_preferred("maps");;
      strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	#elif defined (WIN32)
		map_path = roadmap_path_join (roadmap_path_user(), "maps");
		strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
		roadmap_path_free (map_path);
	#elif IPHONE
	   map_path = roadmap_path_join (roadmap_main_bundle_path(), "maps");
	   strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	   roadmap_path_free (map_path);
	#else
	   map_path = roadmap_path_first ("maps");
	   while (map_path && !roadmap_file_exists (map_path,"")) {
	   	map_path = roadmap_path_next ("maps", map_path);
	   }
	   if (map_path) {
			strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	   } else {
	   	map_path_static[0] = '\0';
	   }
	#endif
		map_path_initialized = 1;
   }
   	
   return map_path_static;
}
예제 #5
0
/***********************************************************
 *  Name        : roadmap_camera_take_picture
 *  Purpose     : Shows the camera preview, passes target image attributes
 *                   and defines the target capture file location
 *
 */
BOOL roadmap_camera_take_picture( CameraImageFile* image_file, CameraImageBuf* image_thumbnail )
{
#if 1
	return FALSE;
#else
    int image_quality_percent;  // Image quality in percents
    int retVal, retValThumb = -1;
    int byte_per_pix = roadmap_camera_image_bytes_pp( image_thumbnail->pixfmt );
    // Transform to percent low - 34, medium - 67, high - 100
    image_quality_percent = 34 + 33 * (int) image_file->quality;

    // Set the target path
    CAMERA_IMG_FILE_SET_PATH( *image_file, roadmap_path_user(), gCaptureFileName );

    // Call the JNI for the file
    retVal = FreeMapNativeManager_TakePicture( image_file->width, image_file->height, image_quality_percent,
            image_file->folder, image_file->file );

    // Call the JNI for the thumbnail if requested and the picture was taken successfully
    if ( ( retVal == 0 ) && image_thumbnail )
    {
        // Assume 4 byte per pixel
        // Only int array can be accepted for the Android
        // Malloc SHOULD preserve 4-byte alignment so further casting is possible !!!!!!!
        image_thumbnail->buf = malloc( image_thumbnail->width * image_thumbnail->height * byte_per_pix );
        retValThumb = FreeMapNativeManager_GetThumbnail( image_thumbnail->width, image_thumbnail->height,
                                                                    byte_per_pix, (int*) image_thumbnail->buf );
        if ( retValThumb != 0 )
        {
            roadmap_log( ROADMAP_WARNING, "Thumbnail request to Android is failed" );
        }
    }
    return ( retVal == 0 );
#endif
}
예제 #6
0
ssd_contextmenu_ptr roadmap_factory_load_menu(
                        const char*          filename,
                        const RoadMapAction* actions)
{
   const char*          path = roadmap_path_first("config");
   ssd_contextmenu_ptr  menu = roadmap_factory_load_menu_file( 
                                          filename, 
                                          actions, 
#ifndef IPHONE
                                          roadmap_path_user());
#else
                                          roadmap_path_bundle());
#endif //IPHONE

   if( menu)
      return menu;
   
   path = roadmap_path_first("config");
   while( !menu && path)
   {
      menu = roadmap_factory_load_menu_file( filename, actions, path);
      path = roadmap_path_next("config", path);
   }
   
   return menu;
}
예제 #7
0
void editor_db_delete (int map_id) {

   char name[100];
  	const char *map_path;

#ifdef WIN32
	map_path = roadmap_path_join (roadmap_path_user(), "maps");
#else
   map_path = roadmap_path_first ("maps");
   while (map_path && !roadmap_file_exists (map_path,"")) {
   	map_path = roadmap_path_next ("maps", map_path);
   }
#endif
   snprintf (name, sizeof(name), "edt%05d.dat", map_id);
   
   if (roadmap_file_exists (map_path, name)) {

      char **files;
      char **cursor;
      char *directory;

      /* Delete notes wav files */
      /* FIXME this is broken for multiple counties */
      directory = roadmap_path_join (roadmap_path_user (), "markers");
      files = roadmap_path_list (directory, ".wav");

      for (cursor = files; *cursor != NULL; ++cursor) {

         char *full_name = roadmap_path_join (directory, *cursor);
         roadmap_file_remove (NULL, full_name);

         free (full_name);
      }

      free (directory);

      /* Remove the actual editor file */
      roadmap_file_remove (map_path, name);
   }
#ifdef WIN32
   roadmap_path_free(map_path);
#endif
}
예제 #8
0
const char *roadmap_path_gps (void)
{
   static char *RoadMapGps = NULL;

   if (RoadMapGps == NULL)
   {
	  RoadMapGps = roadmap_path_cat (roadmap_path_user(), RoadMapPathGpsSuffix );
      roadmap_path_create( RoadMapGps );
   }
   return RoadMapGps;
}
예제 #9
0
const char *roadmap_path_debug( void )
{
   static char *RoadMapPathDebug = NULL;

   if ( RoadMapPathDebug == NULL )
   {
      RoadMapPathDebug = roadmap_path_join( roadmap_path_user(), "debug" );
      roadmap_path_create( RoadMapPathDebug );
   }
   return RoadMapPathDebug;
}
예제 #10
0
const char *roadmap_path_images( void )
{
   static char *RoadMapPathImages = NULL;

   if ( RoadMapPathImages == NULL )
   {
	  RoadMapPathImages = roadmap_path_cat( roadmap_path_user(), "images" );
	  roadmap_path_create( RoadMapPathImages );
   }
   return RoadMapPathImages;
}
예제 #11
0
const char *roadmap_path_search_icon (const char *name)
{
   static char result[256];

   sprintf (result, "%s\\icons\\rm_%s.png", roadmap_path_user(), name);
   if (roadmap_file_exists(NULL, result)) return result;

   sprintf (result, "\\Storage Card\\Roadmap\\icons\\rm_%s.png", name);
   if (roadmap_file_exists(NULL, result)) return result;

   return NULL; /* Not found. */
}
예제 #12
0
void editor_marker_voice_file(int marker, char *file, int size) {
    char *path = roadmap_path_join (roadmap_path_user (), "markers");
    char file_name[100];
    char *full_name;

    roadmap_path_create (path);
    snprintf (file_name, sizeof(file_name), "voice_%d.wav", marker);

    full_name = roadmap_path_join (path, file_name);
    strncpy_safe (file, full_name, size);

    roadmap_path_free (full_name);
    roadmap_path_free (path);
}
예제 #13
0
const char *roadmap_path_trips (void)
{
   static char  RoadMapDefaultTrips[] = "trips";
   static char *RoadMapTrips = NULL;

   if (RoadMapTrips == NULL) {

      RoadMapTrips =
         roadmap_path_cat (roadmap_path_user(), RoadMapDefaultTrips);

      roadmap_path_create(RoadMapTrips);
   }
   return RoadMapTrips;
}
예제 #14
0
void roadmap_lang_reload(void){
   const char *p;

   RoadMapLangCount = 0;
   RoadMapLangSize = 0;
   roadmap_hash_free(RoadMapLangHash);
   roadmap_lang_allocate ();
   p = roadmap_path_user ();
   RoadMapLangLoaded = roadmap_lang_load (p);
   if (!RoadMapLangLoaded){
      p = roadmap_path_downloads();
      RoadMapLangLoaded = roadmap_lang_load (p);
   }

   RoadMapLangRTL = (strcasecmp(roadmap_lang_get ("RTL"), "Yes") == 0);
}
예제 #15
0
void roadmap_log_init(){
	long fileSize;
	const char *log_path;
	const char *log_path_temp;
	const char * path;
	const char * name;
	char lineFromLog[300];
#if defined (__SYMBIAN32__)
	#if defined (WINSCW)
      path = "C:\\";
      name = "waze_log.txt";
	#else
	  path = roadmap_db_map_path();
      name = "waze_log.txt";
	#endif
#elif defined(ANDROID)
      roadmap_path_sdcard();
      name = "waze_log.txt";
#elif !defined (J2ME)
      path = roadmap_path_user();
      name = "postmortem";
#endif
    
	fileSize = roadmap_file_length(path,name);
	if (fileSize > 0 ){ // file exists
		if(fileSize>MAX_SIZE_LOG_FILE){
		   FILE * LogFile = roadmap_file_fopen(path,name,"sa+");
		   FILE * tempLogFile = roadmap_file_fopen(path,"temp_log_file.txt","sa+");
		   fseek(LogFile, 0, SEEK_END-TO_KEEP_LOG_SIZE);
		   fgets (lineFromLog,300, LogFile );  
		   while (1){
		   	    fgets (lineFromLog,300, LogFile );
		   	    if(feof(LogFile))
		   	    	break;
		   		fputs (lineFromLog,tempLogFile ); 
		   }
		   fclose(LogFile);
		   fclose(tempLogFile);
		   log_path = roadmap_path_join (path, name);
		   log_path_temp = roadmap_path_join (path, "temp_log_file.txt");
	  	   roadmap_file_remove (path, name);
	  	   rename(log_path_temp,log_path);
	  	   roadmap_path_free (log_path);
	  	   roadmap_path_free (log_path_temp);
	    }
	}
}
예제 #16
0
const char *roadmap_log_path()
{
#if defined (__SYMBIAN32__)
#if defined (WINSCW)
   return ("C:\\");
#else
   return (roadmap_db_map_path());
#endif
#elif defined(ANDROID)
   // Only sdcard can be accessed for reading
   // For the debug purposes the log is appended
   return ( roadmap_path_sdcard());
#elif !defined (J2ME)
   return (roadmap_path_user());
#else
   //return ("file:///e:/FreeMap");
#endif
}   
예제 #17
0
/***********************************************************
 *  Name        : roadmap_camera_take_picture_async
 *  Purpose     : Asynchronous function. Main thread still running.
 *                Shows the camera preview, passes target image attributes
 *                   and defines the target capture file location
 *
 */
BOOL roadmap_camera_take_picture_async( CameraImageCaptureCallback callback, CameraImageCaptureContext* context )
{
    int image_quality_percent;  // Image quality in percents
    int retVal, retValThumb = -1;
    CameraImageBuf* image_thumbnail = &context->image_thumbnail;
    CameraImageFile* image_file = &context->image_file;
    // Transform to percent low - 34, medium - 67, high - 100
    image_quality_percent = 34 + 33 * (int) image_file->quality;

    // Set the target path
    CAMERA_IMG_FILE_SET_PATH( *image_file, roadmap_path_user(), gCaptureFileName );

    // Call the JNI for the file
    retVal = FreeMapNativeManager_TakePictureAsync( image_file->width, image_file->height, image_quality_percent,
            image_file->folder, image_file->file );

    sgCameraContext.context = context;
    sgCameraContext.capture_callback = callback;

    return TRUE;
}
예제 #18
0
static RoadMapPathList roadmap_path_find (const char *name)
{
   RoadMapPathList cursor;

   if (RoadMapPaths == NULL) {

      /* Add the hardcoded configuration. */
      roadmap_path_list_create ("user", RoadMapPathUser, roadmap_path_user());
      roadmap_path_list_create ("config", RoadMapPathConfig,
                                 RoadMapPathConfigPreferred);
      roadmap_path_list_create ("skin", RoadMapPathSkin,
                                 RoadMapPathSkinPreferred);
      roadmap_path_list_create ("maps", RoadMapPathMaps,
                                RoadMapPathMapsPreferred);
   }

   for (cursor = RoadMapPaths; cursor != NULL; cursor = cursor->next) {
      if (strcasecmp(cursor->name, name) == 0) break;
   }
   return cursor;
}
예제 #19
0
static char *roadmap_path_expand (const char *item, size_t length) {

   const char *expansion;
   size_t expansion_length;
   char *expanded;

   switch (item[0]) {
      case '&': expansion = roadmap_path_user(); item++; length--; break;
      default:  expansion = "";
   }
   expansion_length = strlen(expansion);

   expanded = malloc (length + expansion_length + 1);
   roadmap_check_allocated(expanded);

   strcpy (expanded, expansion);
   strncat (expanded, item, length);

   expanded[length+expansion_length] = 0;

   return expanded;
}
예제 #20
0
static void *load_resource (unsigned int type, unsigned int flags,
                            const char *name, int *mem) {

   const char *cursor;
   void *data = NULL;

   if (flags & RES_SKIN) {
#ifndef RIMAPI
      for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {
         switch (type) {
            case RES_BITMAP:
               *mem = 0;

               data = roadmap_canvas_load_image (cursor, name);
               break;
            case RES_SOUND:
               data = roadmap_sound_load (cursor, name, mem);
               break;
#ifdef IPHONE_NATIVE
            case RES_NATIVE_IMAGE:
               *mem = 0;

               data = roadmap_main_load_image (cursor, name);
               break;
#endif
         }
         if (data) break;
      }
#else // RIMAPI
      data = rim_load_resources(type, flags, name, mem);
#endif

   } else {

      const char *user_path = roadmap_path_user ();
      char path[512];
      switch (type) {
         case RES_BITMAP:
            *mem = 0;
            roadmap_path_format (path, sizeof (path), user_path, "icons");
            data = roadmap_canvas_load_image (path, name);
            break;
         case RES_SOUND:
            roadmap_path_format (path, sizeof (path), roadmap_path_downloads(), "sound");
            roadmap_path_format (path, sizeof (path), path, roadmap_prompts_get_name());
            data = roadmap_sound_load (path, name, mem);
            break;
#ifdef IPHONE_NATIVE
         case RES_NATIVE_IMAGE:
            *mem = 0;
            roadmap_path_format (path, sizeof (path), user_path, "icons");
            data = roadmap_main_load_image (path, name);
            break;
#endif
      }
   }

   return data;
}
예제 #21
0
const char *roadmap_path_downloads( void )
{
   return roadmap_path_user();
}
예제 #22
0
const char *roadmap_path_temporary (void) {

   return roadmap_path_user();
}
예제 #23
0
const char *roadmap_path_config( void )
{
	return roadmap_path_user();
}
예제 #24
0
void roadmap_canvas_agg_configure (unsigned char *buf, int width, int height, int stride) {

   roadmap_log( ROADMAP_ERROR, "roadmap_canvas_agg_configure, height =%d width=%d",height, width);
   agg_rbuf.attach(buf, width, height, stride);

   agg_renb.attach(agg_pixf);
   agg_renb.reset_clipping(true);
   ras.clip_box(0, 0, agg_renb.width() - 1, agg_renb.height() - 1);

   agg::glyph_rendering gren = agg::glyph_ren_outline;
   agg::glyph_rendering image_gren = agg::glyph_ren_agg_gray8;

   roadmap_config_declare
       ("preferences", &RoadMapConfigFont, "font.ttf", NULL);

   roadmap_config_declare
       ("preferences", &RoadMapConfigFontNormal, "font_normal.ttf", NULL);

   char *font_file = roadmap_path_join(roadmap_path_user(),
		   roadmap_config_get (&RoadMapConfigFont));

   if ((width) && (height))
      roadmap_screen_set_screen_type( width, height );

   if (!RoadMapCanvasFontLoaded) {

      if(m_feng.load_font(font_file, 0, gren) &&
            m_image_feng.load_font(font_file, 0, image_gren)) {

         m_feng.hinting(true);

         if ( roadmap_screen_is_hd_screen() )
         {
			 m_feng.height(22);
			 m_feng.width(22);
         }
         else
         {
#ifdef _WIN32
          m_feng.height(12);
          m_feng.width(12);
#else
          m_feng.height(15);
          m_feng.width(15);
#endif
         }

         m_feng.flip_y(true);

         m_image_feng.hinting(true);
         m_image_feng.flip_y(true);

         RoadMapCanvasFontLoaded = 1;
      } else {
         RoadMapCanvasFontLoaded = -1;
         char message[300];
         snprintf(message, sizeof(message), "Can't load font: %s\n", font_file);
         roadmap_messagebox("Error", message);
      }
   }
   RoadMapCanvasFontLoaded = 1;
   roadmap_path_free(font_file);

   font_file = roadmap_path_join(roadmap_path_user(),
         roadmap_config_get (&RoadMapConfigFontNormal));


   if(m_feng_nor.load_font(font_file, 0, gren) &&
            m_image_feng_nor.load_font(font_file, 0, image_gren)) {

         m_feng_nor.hinting(true);

         if ( roadmap_screen_is_hd_screen() )
         {
          m_feng_nor.height(22);
          m_feng_nor.width(22);
         }
         else
         {
#ifdef _WIN32
          m_feng_nor.height(12);
          m_feng_nor.width(12);
#else
          m_feng_nor.height(15);
          m_feng_nor.width(15);
#endif
         }

         m_feng_nor.flip_y(true);

         m_image_feng_nor.hinting(true);
         m_image_feng_nor.flip_y(true);
         RoadMapCanvasNormalFontLoaded = 1;
   }
}
예제 #25
0
void roadmap_log_purge (void) {

    roadmap_file_remove (roadmap_path_user(), "postmortem");
}
예제 #26
0
int export_sync (void) {

    int i;
    int res;
    char *messages[MAX_MSGS];
    int num_msgs = 0;
    int fips;

    if (!editor_is_enabled ()) {
        return 0;
    }

    res = roadmap_file_free_space (roadmap_path_user());

#if !defined(__SYMBIAN32__) || defined(QTMOBILITY)
    if ((res >= 0) && (res < MIN_FREE_SPACE)) {
        roadmap_messagebox ("Error",
                            "Please free at least 5MB of space before synchronizing.");
        return -1;
    }
#endif

    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Preparing export data..."));

    roadmap_warning_register (download_warning_fn, "edtsync");

    roadmap_main_flush ();
    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Uploading data..."));

    roadmap_main_flush ();

    Realtime_OfflineClose ();
#ifndef J2ME
    res = sync_do_upload ();
#endif
    Realtime_OfflineOpen (editor_sync_get_export_path (),
                          editor_sync_get_export_name ());


    fips = roadmap_locator_active ();

    if (fips < 0) {
        fips = 77001;
    }

#if 0
    if (roadmap_locator_activate (fips) == ROADMAP_US_OK) {
        now_t = time (NULL);
        map_time_t = atoi(roadmap_metadata_get_attribute ("Version", "UnixTime"));

        if ((map_time_t + 3600*24) > now_t) {
            /* Map is less than 24 hours old.
             * A new version may still be available.
             */

            now_tm = *gmtime(&now_t);
            map_time_tm = *gmtime(&map_time_t);

            if (now_tm.tm_mday == map_time_tm.tm_mday) {

                goto end_sync;
            } else {
                /* new day - only download if new maps were already generated. */
                if (now_tm.tm_hour < 2) goto end_sync;
            }
        }
    }
#endif //0

    SyncProgressItems = 1;
    SyncProgressCurrentItem = 0;
    roadmap_download_progress (0);

    snprintf (SyncProgressLabel, sizeof(SyncProgressLabel), "%s",
              roadmap_lang_get ("Downloading new maps..."));

    roadmap_label_clear (-1);
    navigate_graph_clear (-1);

    roadmap_main_flush ();
#ifndef J2ME
    res = editor_download_update_map (&SyncDownloadCallbackFunctions);

    if (res == -1) {
        roadmap_messagebox ("Download Error", roadmap_lang_get("Error downloading map update"));
    }
#endif

    for (i=0; i<num_msgs; i++) {
        roadmap_messagebox ("Info", messages[i]);
        free (messages[i]);
    }

    roadmap_warning_unregister (download_warning_fn);

    return 0;
}