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; }
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 (); }
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); }
/************************************************************************************************* * roadmap_canvas_agg_load_image() * */ RoadMapImage roadmap_canvas_load_image ( const char *path, const char *file_name ) { char *full_path = roadmap_path_join( path, file_name ); RoadMapImage image = NULL; roadmap_log( ROADMAP_INFO, "Loading image : %s\n", file_name ); if ( check_file_suffix( file_name, ".bmp" ) ) { image = roadmap_canvas_load_bmp( full_path ); } else { image = roadmap_canvas_load_png( full_path ); } if ( image ) { image->full_path = full_path; image->isCached = 1; } else { free( full_path ); } return image; }
static int open_data_file (void) { char *file_name; if (track_file) return 0; file_name = roadmap_path_join(roadmap_config_get(&RoadMapConfigMapPath), "track_data.bin"); track_file = roadmap_file_fopen(NULL, file_name, "a"); roadmap_path_free(file_name); if (track_file == NULL) { roadmap_messagebox("Error", "Can't open track_data"); return -1; } if (ftell(track_file) == 0) { unsigned char version[4] = {0, 10, 0, 1}; if (fwrite(version, sizeof(version), 1, track_file) != 1) { roadmap_messagebox("Error", "Can't write to track_data"); fclose(track_file); track_file = NULL; return -1; } } return 0; }
RoadMapSound roadmap_sound_load (const char *path, const char *file, int *mem) { char *full_name = roadmap_path_join (path, file); const char *seq; RoadMapFileContext sound; char sound_filename[MAX_SOUND_NAME]; return NULL; snprintf( sound_filename, sizeof(sound_filename), "%s.mp3", full_name); seq = roadmap_file_map (NULL, sound_filename, NULL, "r", &sound); roadmap_path_free (full_name); if (seq == NULL) { *mem = 0; return NULL; } *mem = roadmap_file_size (sound); return (RoadMapSound) sound; }
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); } } }
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); }
int editor_db_open (int map_id) { char name[100]; const char *map_path; char *file_name; int do_read = 0; editor_log_push ("editor_db_open"); map_path = roadmap_db_map_path(); if (!map_path) { editor_log (ROADMAP_ERROR, "Can't find editor path"); editor_log_pop (); return -1; } snprintf (name, sizeof(name), "edt%05d.dat", map_id); file_name = roadmap_path_join(map_path, name); if (roadmap_file_exists (map_path, name)) { EditorDataFile = roadmap_file_open(file_name, "rw"); do_read = 1; } else { roadmap_path_create (map_path); EditorDataFile = roadmap_file_open(file_name, "w"); } #ifdef WIN32 roadmap_path_free(map_path); #endif do { if (!ROADMAP_FILE_IS_VALID(EditorDataFile)) { editor_log (ROADMAP_ERROR, "Can't open/create new database: %s/%s", map_path, name); roadmap_path_free(file_name); editor_log_pop (); return -1; } if (do_read) { do_read = 0; if (editor_db_read () == -1) { editor_db_free (); roadmap_messagebox("Error", "Offline data file is currupt: Re-Initializing data"); roadmap_file_close (EditorDataFile); roadmap_file_remove (NULL, file_name); EditorDataFile = roadmap_file_open(file_name, "w"); } } } while (do_read); roadmap_path_free(file_name); EditorActiveMap = map_id; editor_log_pop (); return 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 }
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; }
const char *roadmap_mood_get(){ const char * mood_cfg; if (!initialized) roadmap_mood_init(); mood_cfg = roadmap_config_get (&MoodCfg); if (strstr(mood_cfg, "wazer")) return strdup(mood_cfg); else return roadmap_path_join("moods", mood_cfg); }
/* * Called once one file was sent successfully. Starts the sending of the next file, if there is one. */ static void upload_done( void *context, const char *format, ... ) { upload_context * uContext = (upload_context *)context; int new_count; char ** new_cursor; const char * target_url; char * new_full_path; char msg[500]; int total; va_list ap; if(format){ va_start(ap, format); vsnprintf(msg,sizeof(msg),format,ap); va_end(ap); roadmap_log(ROADMAP_DEBUG,"done uploading log file : %s. Received response : %s",*uContext->cursor,msg); } new_cursor = (uContext->cursor)+1; new_count = (uContext->file_num)+1; total = uContext->total; roadmap_file_remove(NULL, uContext->full_path); // remove the previous file if(new_count==total){ // finished - sent all the files! in_process = 0 ; roadmap_path_list_free(uContext->files); ssd_progress_msg_dialog_hide(); roadmap_messagebox_timeout("Thank you!!!", "Logs submitted successfully to waze",3); }else{ // still more files - call the next one upload_context * new_context; sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Uploading logs..."),new_count+1, total); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); new_full_path = roadmap_path_join( roadmap_path_debug(), *new_cursor ); new_context= malloc(sizeof(upload_context)); new_context->cursor = new_cursor; new_context->files = uContext->files; new_context->full_path = new_full_path; new_context->file_num = new_count; new_context->total = total; target_url = roadmap_config_get ( &RMCfgDebugInfoServer); if ( editor_upload_auto( new_full_path, &gUploadCallbackFunctions, target_url, LOG_UPLOAD_CONTENT_TYPE,(void *)new_context) ) { roadmap_log( ROADMAP_ERROR, "File upload error. for file %s , number %d", new_full_path, new_count); roadmap_path_free(new_full_path); roadmap_path_list_free (new_context->files); ssd_progress_msg_dialog_hide(); roadmap_messagebox_timeout("Error", "Error sending files",5); in_process = 0; } } roadmap_path_free(uContext->full_path); free(uContext); }
char *roadmap_path_parent (const char *path, const char *name) { char *separator; char *full_name = roadmap_path_join (path, name); separator = strrchr (full_name, '\\'); if (separator == NULL) { return "."; } *separator = 0; return full_name; }
/* * Called once one file was sent successfully. Starts the sending of the next file, if there is one. */ static void upload_done( void *context, char *last_modified, const char *format, ... ) { upload_context * uContext = (upload_context *)context; char msg[MAX_SIZEOF_RESPONSE_MSG]; va_list ap; char ** new_cursor; char * new_full_path; if(format) { va_start(ap, format); vsnprintf(msg,sizeof(msg),format,ap); va_end(ap); roadmap_log(ROADMAP_DEBUG,"done uploading file : %s. Received response : %s",*uContext->cursor,msg); strncpy(SyncUploadMessages[SyncUploadNumMessages], msg, MAX_SIZEOF_RESPONSE_MSG); } SyncProgressCurrentItem ++ ; SyncProgressLoaded = 0; SyncUploadNumMessages ++; new_cursor = (uContext->cursor)+1; roadmap_file_remove(NULL, uContext->full_path); // remove the previous file if( (*new_cursor == NULL ) || ( SyncUploadNumMessages == MAX_MSGS ) ) { roadmap_path_list_free(uContext->files); roadmap_log(ROADMAP_DEBUG, "finished uploading editor_sync files"); } else { int size; const char *header; upload_context * new_context; new_full_path = roadmap_path_join( editor_sync_get_export_path(), *new_cursor ); new_context= malloc(sizeof(upload_context)); new_context->cursor = new_cursor; new_context->files = uContext->files; new_context->full_path = new_full_path; size = roadmap_file_length (NULL, new_full_path); header = roadmap_http_async_get_upload_header(DEFAULT_CONTENT_TYPE, new_full_path, size, RealTime_GetUserName(), Realtime_GetPassword()); if (!roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)new_context, editor_upload_get_url(), header, new_full_path, size)) { roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", new_full_path); roadmap_path_free(new_full_path); roadmap_path_list_free (new_context->files); free(new_context); } } roadmap_path_free(uContext->full_path); free(uContext); }
void roadmap_skin_set_subskin (const char *sub_skin) { const char *base_path = roadmap_path_preferred ("skin"); char path[255]; char *skin_path; char *subskin_path; CurrentSubSkin = sub_skin; skin_path = roadmap_path_join (base_path, CurrentSkin); subskin_path = roadmap_path_join (skin_path, CurrentSubSkin); snprintf (path, sizeof(path), "%s,%s", subskin_path, skin_path); roadmap_path_set ("skin", path); roadmap_path_free (subskin_path); roadmap_path_free (skin_path); roadmap_config_reload ("schema"); notify_listeners (); roadmap_screen_redraw (); }
/* Name : roadmap_recorder_voice_uploader() * Purpose : Upload the voice to the server. Auxiliary static function * Params : (in) voice_folder * : (in) voice_file * : (out) voice_id - the string containing the resulting voice ID, received from the server * the input buffer must be of size ROADMAP_VOICE_ID_BUF_LEN * : (out) message - parsed response from the server */ static BOOL roadmap_recorder_voice_uploader( const char *voice_folder, const char *voice_file, char* voice_id, RecorderVoiceUploadCallback cb, void * context) { BOOL res = FALSE; char* full_path; const char* target_url; upload_context * ctx; int size; const char *header; if( !voice_id ) { roadmap_log( ROADMAP_ERROR, "File upload error: voice id buffer is not available!!" ); return FALSE; } // Get the full path to the file full_path = roadmap_path_join( voice_folder, voice_file ); // Set the target to upload to target_url = get_upload_url(); roadmap_log( ROADMAP_DEBUG, "Uploading file: %s. ", full_path ); ctx = malloc(sizeof(upload_context)); ctx->context = context; ctx->cb = cb; ctx->full_path = full_path; ctx->voice_id = voice_id; // Upload and get the response size = roadmap_file_length (NULL, full_path); header = roadmap_http_async_get_upload_header(VOICE_UPLOAD_CONTENT_TYPE, full_path, size, NULL, NULL); if (roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)ctx, target_url, header, full_path, size)) { //change to debug and comment. roadmap_log( ROADMAP_DEBUG, "Started Async connection for file : %s", full_path ); res = TRUE; } else { roadmap_log( ROADMAP_WARNING, "File upload error on socket connect %s", full_path ); roadmap_path_free( full_path ); free( ctx ); res = FALSE; } return res; }
static void track_rec_upload (void) { char *file_name; if (RecordGpsData) { track_end (); RecordGpsData = 0; close_data_file(); } file_name = roadmap_path_join(roadmap_config_get(&RoadMapConfigMapPath), "track_data.bin"); NOPH_try(exception_handler, NULL) { editor_upload_file (file_name, 1); } NOPH_catch();
static int sync_do_upload () { char **files; char **cursor; const char* directory = editor_sync_get_export_path(); int count; upload_context * context; char * full_path; int size; const char *header; files = roadmap_path_list (directory, ".wud"); count = 0; for (cursor = files; *cursor != NULL; ++cursor) { count++; } // cursor = files; count = 0; // context= malloc(sizeof(upload_context)); context->cursor = cursor; context->files = files; full_path = roadmap_path_join( directory, *cursor ); context->full_path = full_path; SyncProgressItems = count; SyncProgressCurrentItem = 1; SyncProgressLoaded = 0; SyncUploadNumMessages = 0; // this starts the async sending sequence. Further progress is done through the callbacks. size = roadmap_file_length (NULL, full_path); header = roadmap_http_async_get_upload_header(DEFAULT_CONTENT_TYPE, full_path, size, RealTime_GetUserName(), Realtime_GetPassword()); if (!roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)context, editor_upload_get_url(), header, full_path, size)) { roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", full_path); // roadmap_path_free(full_path); // roadmap_path_list_free (files); // free(context); return 0; } return 1; }
/* * Called once one file was sent successfully. Starts the sending of the next file, if there is one. */ static void upload_done( void *context, const char *format, ... ) { upload_context * uContext = (upload_context *)context; char msg[MAX_SIZEOF_RESPONSE_MSG]; va_list ap; char ** new_cursor; char * new_full_path; if(format){ va_start(ap, format); vsnprintf(msg,sizeof(msg),format,ap); va_end(ap); roadmap_log(ROADMAP_DEBUG,"done uploading file : %s. Received response : %s",*uContext->cursor,msg); strncpy(SyncUploadMessages[SyncUploadNumMessages], msg, MAX_SIZEOF_RESPONSE_MSG); } SyncProgressCurrentItem ++ ; SyncProgressLoaded = 0; SyncUploadNumMessages ++; new_cursor = (uContext->cursor)+1; roadmap_file_remove(NULL, uContext->full_path); // remove the previous file if( (*new_cursor == NULL ) || ( SyncUploadNumMessages == MAX_MSGS ) ) { roadmap_path_list_free(uContext->files); roadmap_log(ROADMAP_DEBUG, "finished uploading editor_sync files"); }else{ upload_context * new_context; new_full_path = roadmap_path_join( editor_sync_get_export_path(), *new_cursor ); new_context= malloc(sizeof(upload_context)); new_context->cursor = new_cursor; new_context->files = uContext->files; new_context->full_path = new_full_path; if ( editor_upload_auto( new_full_path, &gUploadCallbackFunctions, NULL, NULL ,(void *)new_context) ) { roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", new_full_path); roadmap_path_free(new_full_path); roadmap_path_list_free (new_context->files); free(new_context); } } roadmap_path_free(uContext->full_path); free(uContext); }
RoadMapImage roadmap_canvas_agg_load_image (const char *path, const char *file_name) { char *full_name = roadmap_path_join (path, file_name); RoadMapImage image; if ((strlen(file_name) > 4) && !strcasecmp (file_name + strlen(file_name) - 4, ".png")) { image = load_png (full_name); } else { image = load_bmp (full_name); } free (full_name); return image; }
static int sync_do_upload () { char **files; char **cursor; const char* directory = editor_sync_get_export_path(); int count; upload_context * context; char * full_path; files = roadmap_path_list (directory, ".wud"); count = 0; for (cursor = files; *cursor != NULL; ++cursor) { count++; } // cursor = files; count = 0; // context= malloc(sizeof(upload_context)); context->cursor = cursor; context->files = files; full_path = roadmap_path_join( directory, *cursor ); context->full_path = full_path; SyncProgressItems = count; SyncProgressCurrentItem = 1; SyncProgressLoaded = 0; SyncUploadNumMessages = 0; // this starts the async sending sequence. Further progress is done through the callbacks. if ( editor_upload_auto( full_path, &gUploadCallbackFunctions, NULL, NULL ,(void *)context) ) { roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", full_path); roadmap_path_free(full_path); roadmap_path_list_free (files); free(context); return 0; } return 1; }
/* Name : roadmap_recorder_voice_download() * Purpose : Constructs the url and downloads the voice. * * Params : (in) voice_id - the voice id to download * * : (out) download_cb - the full path to the downloaded voice file - user responsibility to * deallocate the memory!!!! * * Notes : * */ BOOL roadmap_recorder_voice_download( const char* voice_id, void* context_cb, VoiceDownloadCallback download_cb ) { BOOL res = FALSE; char *url; char *voice_file, *voice_path; DownloadContext* context; roadmap_log( ROADMAP_DEBUG, "Downloading the voice. ID: %s", voice_id ); // Target file name from the voice id voice_file = malloc( strlen( voice_id ) + strlen( ROADMAP_VOICE_DOWNLOAD_FILE_SUFFIX ) + 1 ); strcpy( voice_file, voice_id ); strcat( voice_file, ROADMAP_VOICE_DOWNLOAD_FILE_SUFFIX ); // Target full path for the output voice_path = roadmap_path_join( roadmap_path_voices(), voice_file ); if (roadmap_file_exists( NULL, voice_path ) ) { // Add file to cache download_cache_add( voice_path ); // The file exists - no need to download download_cb( context_cb, 0, voice_path ); roadmap_path_free( voice_path ); } else { url = get_download_url( voice_id ); // Init the download process context context = malloc( sizeof( DownloadContext ) ); context->voice_path = voice_path; context->context_cb = context_cb; context->download_cb = download_cb; context->data = NULL; // Show the message ssd_progress_msg_dialog_show( roadmap_lang_get( "Downloading voice ..." ) ); // Start the process roadmap_http_async_copy( &gHttpAsyncCallbacks, context, url ,0 ); free( url ); } free( voice_file ); return res; }
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 (); }
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; } }
/////////////////////////////////////////////////////// // Compress files and prepare for upload int upload () { const char* directory = roadmap_path_debug(); const char* target_url; char *full_path; upload_context * context; #ifndef RIMAPI char **files = roadmap_path_list (directory, ".gz"); #else char ** files = malloc(sizeof(char *)*2); // temporary workaround, until path list is implemented files[0] = strdup(zipped_log_name); files[1] = NULL; #endif int count; int total; char **cursor; // Set the target to upload to sprintf (warning_message,"%s",roadmap_lang_get("Uploading logs...")); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); count = 0; for (cursor = files; *cursor != NULL; ++cursor) { count++; } cursor = files; total = count; count = 0; target_url = roadmap_config_get ( &RMCfgDebugInfoServer); context= malloc(sizeof(upload_context)); context->cursor = cursor; context->files = files; context->file_num = count; context->total = total; full_path = roadmap_path_join( directory, *cursor ); context->full_path = full_path; sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Uploading logs..."),count+1, context->total); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); // this starts the async sending sequence. Further progress is done through the callbacks. if ( editor_upload_auto( full_path, &gUploadCallbackFunctions, target_url, LOG_UPLOAD_CONTENT_TYPE,(void *)context) ) { roadmap_log( ROADMAP_ERROR, "File upload error. for file %s ", full_path); roadmap_path_free(full_path); roadmap_path_list_free (files); ssd_progress_msg_dialog_hide(); free(context); return 0; } return 1; }
const char* roadmap_mood_to_string(MoodType mood){ switch(mood) { case Mood_Happy: return roadmap_path_join("moods",MOOD_Name_Happy); case Mood_Sad: return roadmap_path_join("moods",MOOD_Name_Sad); case Mood_Mad: return roadmap_path_join("moods",MOOD_Name_Mad); case Mood_Bored: return roadmap_path_join("moods",MOOD_Name_Bored); case Mood_Speedy: return roadmap_path_join("moods",MOOD_Name_Speedy); case Mood_Starving: return roadmap_path_join("moods",MOOD_Name_Starving); case Mood_Sleepy: return roadmap_path_join("moods",MOOD_Name_Sleepy); case Mood_Cool: return roadmap_path_join("moods",MOOD_Name_Cool); case Mood_InLove: return roadmap_path_join("moods",MOOD_Name_InLove); case Mood_LOL: return roadmap_path_join("moods",MOOD_Name_LOL); case Mood_Peaceful: return roadmap_path_join("moods",MOOD_Name_Peaceful); case Mood_Singing: return roadmap_path_join("moods",MOOD_Name_Singing); case Mood_Wondering: return roadmap_path_join("moods",MOOD_Name_Wondering); case Mood_Happy_Female: return roadmap_path_join("moods",MOOD_Name_Happy_Female); case Mood_Sad_Female: return roadmap_path_join("moods",MOOD_Name_Sad_Female); case Mood_Mad_Female: return roadmap_path_join("moods",MOOD_Name_Mad_Female); case Mood_Bored_Female: return roadmap_path_join("moods",MOOD_Name_Bored_Female); case Mood_Speedy_Female: return roadmap_path_join("moods",MOOD_Name_Speedy_Female); case Mood_Starving_Female: return roadmap_path_join("moods",MOOD_Name_Starving_Female); case Mood_Sleepy_Female: return roadmap_path_join("moods",MOOD_Name_Sleepy_Female); case Mood_Cool_Female: return roadmap_path_join("moods",MOOD_Name_Cool_Female); case Mood_InLove_Female: return roadmap_path_join("moods",MOOD_Name_InLove_Female); case Mood_LOL_Female: return roadmap_path_join("moods",MOOD_Name_LOL_Female); case Mood_Peaceful_Female: return roadmap_path_join("moods",MOOD_Name_Peaceful_Female); case Mood_Singing_Female: return roadmap_path_join("moods",MOOD_Name_Singing_Female); case Mood_Wondering_Female: return roadmap_path_join("moods",MOOD_Name_Wondering_Female); case Mood_Bronze: return strdup(MOOD_Name_Bronze); case Mood_Silver: return strdup(MOOD_Name_Silver); case Mood_Gold: return strdup(MOOD_Name_Gold); case Mood_Busy: return roadmap_path_join("moods",MOOD_Name_Busy); case Mood_Busy_Female: return roadmap_path_join("moods",MOOD_Name_Busy_Female); case Mood_In_a_Hurry: return roadmap_path_join("moods",MOOD_Name_In_A_Hurry); case Mood_In_a_Hurry_Female:return roadmap_path_join("moods",MOOD_Name_In_A_Hurry_Female); case Mood_Baby: return strdup(MOOD_Name_Baby); default: return roadmap_path_join("moods",MOOD_Name_Happy); } }