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;
}
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;
}
Exemple #3
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;
}
Exemple #4
0
void roadmap_lang_initialize (void) {

   const char *p;
   initialized = TRUE;

   roadmap_lang_initialize_params();

   roadmap_lang_allocate ();

   lang_labels[0] = "English";
   lang_values[0] = "eng";

   LangNextLoginCb = Realtime_NotifyOnLogin (roadmap_lang_login_cb);


   roadmap_lang_conf_load(roadmap_path_downloads());

   for (p = roadmap_path_first("user");
        p != NULL && !RoadMapLangLoaded;
        p = roadmap_path_next("user", p))
   {
      RoadMapLangLoaded = roadmap_lang_load (p);
   }
   RoadMapLangRTL = (strcasecmp(roadmap_lang_get ("RTL"), "Yes") == 0);

#ifdef QTMOBILITY
   roadmap_lang_loaded();
#endif

}
Exemple #5
0
static void roadmap_config_update (RoadMapConfig *config, int force) {

   FILE *file;
   const char *value;
   const char *p = NULL;
   RoadMapConfigItem *item;


   if (force || (config->state == ROADMAP_CONFIG_DIRTY))
   {
#ifndef J2ME
	   for ( p = roadmap_path_first( config->set );
			   p != NULL;
			   p = roadmap_path_next( config->set, p ) )
	   {
		   if ( roadmap_file_exists( p, "" ) )
			   break;
	   }
#endif
	   if ( p == NULL )
	   {
		   p = roadmap_path_config();
	   }
	   
#ifdef J2ME
	   char file_name[100];
	   sprintf(file_name,"%s_j2me",config->name);
	   file = roadmap_file_fopen (p, file_name, "w");
#else
   	   file = roadmap_file_fopen ( p, config->name, "w" );
#endif
	  

       if ( file )
       {

         for (item = config->first_item; item != NULL; item = item->next) {

            if ((! force) && (item->state == ROADMAP_CONFIG_SHARED)) continue;

            if (item->value != NULL) {
               value = item->value;
            } else {
               value = item->default_value;
            }
#ifdef J2ME
            char name_to_write[100]; // this will be of the category.type name
            sprintf(name_to_write,"%s.%s", item->category, item->name);
            roadmap_config_write_name_value_to_binary(name_to_write,value,file);
#else
			fprintf (file, "%s.%s: %s\n", item->category, item->name, value);
#endif            
         }

         fclose (file);
         config->state = ROADMAP_CONFIG_CLEAN;
      }
   }
}
Exemple #6
0
int  roadmap_config_reload (const char *name) {

   const char *p;
   RoadMapConfig *file;

  

   for (file = RoadMapConfigFiles; file->name != NULL; ++file) {
      if (!strcmp (file->name, name)) break;
   }

   if (file->name == NULL) {
      roadmap_log
         (ROADMAP_ERROR,
          "config_reload found no '%s' config file", name);

      return -1;

   } else {
      int loaded = 0;
	  file->age++;
      
	  for (p = roadmap_path_first(file->set);
           p != NULL;
           p = roadmap_path_next(file->set, p)) {

         //printf("loading set '%s'\n",file->set);
         loaded = roadmap_config_load (p, file, ROADMAP_CONFIG_CLEAN);

         if (loaded) {
			 //printf("loaded ok\n");
        	 //printf("loaded %s: %s\n",file->set,p);
			 //printf("name: %s\n",name);
        	 break;
         }
      }
      
      if ( p == NULL )
      {
          p = roadmap_path_config();
          loaded = roadmap_config_load (p, file, ROADMAP_CONFIG_CLEAN);
      }
      
      if (file->required && (!loaded)) {
         roadmap_log
            (ROADMAP_ERROR,
             "found no '%s' config file, check RoadMap installation",
             file->name);
         return -1;
      }

      return 0;
   }
}
Exemple #7
0
void roadmap_skin_set_subskin (const char *sub_skin) {
   const char *base_path = roadmap_path_preferred ("skin");
   char path[1024];
   char *skin_path = NULL;
   char *subskin_path;
   const char *cursor;
   char *subskin_path2 = NULL;
   CurrentSubSkin = sub_skin;

   skin_path = roadmap_path_join (base_path, CurrentSkin);
   subskin_path = roadmap_path_join (skin_path, CurrentSubSkin);
//   offset = strlen(path);

   if (!strcmp(CurrentSubSkin,"day")){
	   if (strlen(get_map_schema())> 0) {
		  subskin_path2 = roadmap_path_join (subskin_path, get_map_schema());

		  snprintf (path, sizeof(path), "%s", subskin_path2);
		  roadmap_path_free (subskin_path2);
	   }
	   else {
		      snprintf (path, sizeof(path), "%s", subskin_path);
	   }
   }
   else{
      snprintf (path, sizeof(path), "%s", subskin_path);
   }

   for ( cursor = roadmap_path_first ("skin");
                  cursor != NULL;
			  cursor = roadmap_path_next ("skin", cursor))
   {
	 if ( !((strstr(cursor,"day") || strstr(cursor,"night")))){
	   strcat(path, ",");
		strcat(path, cursor);

	 }
   }

   roadmap_path_set ("skin", path);

   roadmap_path_free (subskin_path);
   roadmap_path_free (skin_path);

   roadmap_config_reload ("schema");
   notify_listeners ();

   roadmap_screen_redraw ();

}
Exemple #8
0
void roadmap_car_dialog (RoadMapCallback callback) {

    char **files;
    const char *cursor;
    char **cursor2;
    char *directory;
    int count = 0; 	
    
    static roadmap_car_list_dialog context = {"roadmap_car", NULL};	
   	static char *labels[MAX_CAR_ENTRIES] ;
	static void *values[MAX_CAR_ENTRIES] ;
	static void *icons[MAX_CAR_ENTRIES];


	context.callback = callback;
    for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {

	    directory = roadmap_path_join (cursor, "cars");
    	
    	files = roadmap_path_list (directory, ".png");

   		for (cursor2 = files; *cursor2 != NULL; ++cursor2) {
   	  			labels[count]  =   (char *)roadmap_lang_get(*cursor2);
   	  			values[count] =   strtok(*cursor2,".");
   	  			icons[count]   =   roadmap_path_join("cars", *cursor2);
      			count++;
   		}
   }   

    ssd_generic_icon_list_dialog_show (roadmap_lang_get ("Select your car"),
                  count,
                  (const char **)labels,
                  (const void **)values,
                  (const char **)icons,
                  NULL,
                  roadmap_car_call_back,
                  NULL,
                  &context,
                  NULL,
                  NULL,
                  70,
                  0,
                  FALSE);
                  
}
Exemple #9
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
}
Exemple #10
0
static void roadmap_config_update (RoadMapConfig *config, int force) {

   FILE *file;
   const char *value;
   const char *p;
   RoadMapConfigItem *item;


   if (force || (config->state == ROADMAP_CONFIG_DIRTY))
   {
	   for ( p = roadmap_path_first( config->set );
			   p != NULL;
			   p = roadmap_path_next( config->set, p ) )
	   {
		   if ( roadmap_file_exists( p, "" ) )
			   break;
	   }
	   if ( p == NULL )
	   {
		   p = roadmap_path_config();
	   }
	   file = roadmap_file_fopen ( p, config->name, "w" );

       if ( file )
       {

         for (item = config->first_item; item != NULL; item = item->next) {

            if ((! force) && (item->state == ROADMAP_CONFIG_SHARED)) continue;

            if (item->value != NULL) {
               value = item->value;
            } else {
               value = item->default_value;
            }
            fprintf (file, "%s.%s: %s\n", item->category, item->name, value);
         }

         fclose (file);
         config->state = ROADMAP_CONFIG_CLEAN;
      }
   }
}
Exemple #11
0
void roadmap_lang_reload(void){
   const char *p;

   RoadMapLangCount = 0;
   RoadMapLangSize = 0;
   roadmap_hash_free(RoadMapLangHash);
   roadmap_lang_allocate ();

   for (p = roadmap_path_first("user");
        p != NULL && !RoadMapLangLoaded;
        p = roadmap_path_next("user", p))
   {
      RoadMapLangLoaded = roadmap_lang_load (p);
   }

   RoadMapLangRTL = (strcasecmp(roadmap_lang_get ("RTL"), "Yes") == 0);

#ifdef QTMOBILITY
   roadmap_lang_loaded();
#endif
}
Exemple #12
0
void roadmap_mood_dialog (RoadMapCallback callback) {

    char **files;
    const char *cursor;
    char **cursor2;
    char *directory = NULL;
    int count = 0;
    SsdWidget moodDlg;
    SsdWidget list;
    SsdWidget exclusive_list;
    SsdWidget baby_list;
    SsdWidget text;
    int i;
    BOOL only_baby_mood = Realtime_IsNewbie();
    int row_height = ssd_container_get_row_height();
    SsdListCallback exclusive_callback = NULL;

    SsdListCallback regular_mood_callback = roadmap_mood_call_back;
    int flags = 0;
    int width = SSD_MAX_SIZE;

    static roadmap_mood_list_dialog context = {"roadmap_mood", NULL};
    static char *labels[MAX_MOOD_ENTRIES] ;
    static void *values[MAX_MOOD_ENTRIES] ;
    static void *icons[MAX_MOOD_ENTRIES];

    static char *exclusive_labels[MAX_EXCLUSIVE_ICONS] ;
    static void *exclusive_values[MAX_EXCLUSIVE_ICONS] ;
    static void *exclusive_icons[MAX_EXCLUSIVE_ICONS];

    static char *baby_labels[1] ;
    static void *baby_values[1] ;
    static void *baby_icons[1];


    flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_CONTAINER_FLAGS;
    width = ssd_container_get_width();


    moodDlg   = ssd_dialog_new ( "MoodDlg", roadmap_lang_get ("Select your mood"), NULL, SSD_CONTAINER_TITLE);
    moodDlg->context = (void *)callback;
    exclusive_list = ssd_list_new ("list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);

    ssd_list_resize ( exclusive_list, row_height );

    baby_list = ssd_list_new ("baby_list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);

    ssd_list_resize ( baby_list, row_height );

    exclusive_labels[0] = (char *)roadmap_lang_get("wazer_gold");
    exclusive_values[0] = "wazer_gold";
    exclusive_icons[0] = "wazer_gold";

    exclusive_labels[1] = (char *)roadmap_lang_get("wazer_silver");
    exclusive_values[1] = "wazer_silver";
    exclusive_icons[1] = "wazer_silver";

    exclusive_labels[2] = (char *)roadmap_lang_get("wazer_bronze");
    exclusive_values[2] = "wazer_bronze";
    exclusive_icons[2] = "wazer_bronze";

    if (roadmap_mood_get_exclusive_moods() > 0){
       exclusive_callback = roadmap_exclusive_mood_call_back;
    }

    ssd_list_populate (exclusive_list, 3, (const char **)exclusive_labels, (const void **)exclusive_values, (const char **)exclusive_icons, NULL, exclusive_callback, NULL, FALSE);

    if (only_baby_mood){
       char msg[150];
       baby_labels[0] = (char *)roadmap_lang_get("Baby");
       baby_values[0] = "wazer_baby";
       baby_icons[0] = "wazer_baby";
       ssd_list_populate (baby_list, 1, (const char **)baby_labels, (const void **)baby_values, (const char **)baby_icons, NULL, NULL, NULL, FALSE);

       ssd_dialog_add_hspace(moodDlg, 20, 0);
       text = ssd_text_new ("Baby Mood Txt", roadmap_lang_get("Waze newbie"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
       ssd_widget_add(moodDlg, text);
       ssd_dialog_add_hspace(moodDlg, 20, 0);
       snprintf(msg, sizeof(msg), roadmap_lang_get("(Gotta drive %d+ %s to access other moods)"), roadmap_mood_get_number_of_newbie_miles(), roadmap_lang_get(roadmap_math_trip_unit()));
       text = ssd_text_new ("Gold Mood Txt", msg, 12, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
       ssd_widget_add(moodDlg, text);
       ssd_widget_add (moodDlg, baby_list);

    }
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(5),0);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("Exclusive moods"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("(Available only to top weekly scoring wazers)"), SSD_FOOTER_TEXT_SIZE, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(3),0);
    ssd_widget_add (moodDlg, exclusive_list);

    for (i = 0; i < (3 - roadmap_mood_get_exclusive_moods()); i++){
           SsdWidget row = ssd_list_get_row(exclusive_list, i);
           if (row){
              SsdWidget label = ssd_widget_get(row,"label");
              if (label)
                 ssd_text_set_color(label,"#999999");
           }
    }



    list = ssd_list_new ("list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);
    exclusive_list->key_pressed = NULL;
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(10), 0);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("Everyday moods"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("(Available to all)"), SSD_FOOTER_TEXT_SIZE, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(3),0);
    ssd_widget_add (moodDlg, list);
    ssd_list_resize ( list, row_height );

    context.callback = callback;
    for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {

       directory = roadmap_path_join (cursor, "moods");

      files = roadmap_path_list (directory, ".png");
      if ( *files == NULL )
      {
         files = roadmap_path_list (directory, NULL);
      }

         for (cursor2 = files; *cursor2 != NULL; ++cursor2) {
               labels[count]  =   (char *)(strtok(*cursor2,"."));
               count++;
         }
   }


    qsort((void *) &labels[0], count, sizeof(void *), cstring_cmp);

    for (i = 0; i< count; i++){
       values[i] = labels[i];
       icons[i]   =   roadmap_path_join("moods", labels[i]);
       labels[i] = (char *)roadmap_lang_get(labels[i]);
    }



    if (only_baby_mood){
       regular_mood_callback = NULL;
    }

    free(directory);
    ssd_list_populate (list, count, (const char **)labels, (const void **)values, (const char **)icons, NULL, regular_mood_callback, NULL, FALSE);

    if (only_baby_mood){
       for (i = 0; i< count; i++){
          SsdWidget row = ssd_list_get_row(list, i);
          if (row){
             SsdWidget label = ssd_widget_get(row,"label");
             if (label)
                ssd_text_set_color(label,"#999999");
          }
       }
    }
//    else{
//       SsdWidget row = ssd_list_get_row(baby_list,0 );
//       if (row){
//          SsdWidget label = ssd_widget_get(row,"label");
//          if (label)
//             ssd_text_set_color(label,"#999999");
//       }
//    }

    exclusive_list->key_pressed = NULL;
    ssd_dialog_activate ("MoodDlg", NULL);
    ssd_dialog_draw ();

}
Exemple #13
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;
}