const char* on_create_poi_res(int NumParams,const char* pData){ char *argv[ahi__count]; void * history; int id; //ID pData = ReadIntFromString( pData, // [in] Source string ",\r\n", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &id, // [out] Put it here TRIM_ALL_CHARS); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_create_poi_res() - Failed to read ID"); return NULL; } if (id > MAX_REQUESTS) return pData; roadmap_log( ROADMAP_DEBUG, "on_create_poi_res - id=%d",id ); history = g_request_cursors[id]; if (history == NULL) return pData; roadmap_history_get (ADDRESS_FAVORITE_CATEGORY, history, argv); roadmap_log( ROADMAP_DEBUG, "on_create_poi_res updating favorite id=%d name=%s",id, argv[ahi_name] ); argv[ahi_synced] = "true"; roadmap_history_update(history, ADDRESS_FAVORITE_CATEGORY, argv); roadmap_history_save(); g_request_cursors[id] = NULL; return pData; }
void roadmap_address_history (void) { #define MAX_HISTORY_ENTRIES 100 static char *labels[MAX_HISTORY_ENTRIES]; static void *values[MAX_HISTORY_ENTRIES]; static int count = -1; void *history; static RoadMapAddressDialog context = {"Location", 0, 0, NULL, NULL, NULL, NULL, 0}; if (count == -1) { roadmap_history_declare ('A', 7); labels[0] = (char *)roadmap_lang_get ("Other city"); } history = roadmap_history_latest ('A'); count = 1; while (history && (count < MAX_HISTORY_ENTRIES)) { void *prev = history; int i; BOOL exist; char *argv[4]; roadmap_history_get ('A', history, argv); exist = FALSE; for (i=0; i< count; i++){ if (!strcmp(labels[i], argv[2])){ exist = TRUE; } } if (!exist){ if (labels[count]) free (labels[count]); labels[count] = strdup(argv[2]); values[count] = strdup(argv[2]); count++; } history = roadmap_history_before ('A', history); if (history == prev) break; } ssd_generic_list_dialog_show (roadmap_lang_get ("Address search"), count, (const char **)labels, (const void **)values, history_callback, history_delete_callback, &context, SSD_GEN_LIST_ENTRY_HEIGHT ); }
void roadmap_reminder_init(void){ void *history; void *prev; int count = 0; roadmap_config_declare_enumeration ("preferences", &RoadMapConfigFeatureEnabled, NULL, "no", "yes", NULL); ReminderTable.iCount = 0; roadmap_history_declare (REMINDER_CATEGORY, reminder_hi__count); if (!roadmap_reminder_feature_enabled()) return; history = roadmap_history_latest (REMINDER_CATEGORY); while (history && (count < MAX_REMINDER_ENTRIES)) { char *argv[reminder_hi__count]; roadmap_history_get (REMINDER_CATEGORY, history, argv); prev = history; if (!strcmp(argv[reminder_hi_add_reminder], "1")){ ReminderTable.reminder[count].position.latitude = atoi(argv[reminder_hi_latitude]); ReminderTable.reminder[count].position.longitude = atoi(argv[reminder_hi_longtitude]); ReminderTable.reminder[count].distance= atoi(argv[reminder_hi_distance]); ReminderTable.reminder[count].history = history; ReminderTable.reminder[count].displayed = FALSE; ReminderTable.reminder[count].in_use = TRUE; ReminderTable.reminder[count].repeat = atoi(argv[reminder_hi_repeat]); snprintf (ReminderTable.reminder[count].title, MAX_REMINDER_TITLE, "%s", argv[reminder_hi_title]); snprintf (ReminderTable.reminder[count].description, MAX_REMINDER_DESC, "%s", argv[reminder_hi_description]); remider_add_pin(count, &ReminderTable.reminder[count].position); count++; } history = roadmap_history_before (REMINDER_CATEGORY, history); if (history == prev) break; } ReminderTable.iCount = count; if(count > 0) register_gps_listener(); }
static int history_callback (SsdWidget widget, const char *new_value, const void *value, void *data) { RoadMapAddressDialog *context = (RoadMapAddressDialog *)data; if (!new_value[0] || !strcmp(new_value, roadmap_lang_get ("Other city"))) { roadmap_address_search_dialog (NULL, roadmap_address_city_result, data); } else if (!strchr(new_value, ',')) { /* We only got a city */ if (context->city_name) free(context->city_name); context->city_name = strdup (new_value); roadmap_address_search_dialog (context->city_name, roadmap_address_street_result, data); } else { /* We got a full address */ char *argv[4]; roadmap_history_get ('A', (void *) ssd_dialog_get_data ("list"), argv); context->navigate = 1; if (context->city_name) free(context->city_name); if (context->street_name) free(context->street_name); context->city_name = strdup (argv[2]); context->street_name = strdup (argv[1]); if (roadmap_address_show (context->city_name, context->street_name, argv[0], context)) { ssd_generic_list_dialog_hide (); } context->navigate = 0; return 1; } ssd_generic_list_dialog_hide (); return 1; }
static void roadmap_trip_server_after_login_delayed (void) { void *cursor; void *prev; char *argv[ahi__count]; static count = 0; roadmap_main_remove_periodic(roadmap_trip_server_after_login_delayed); roadmap_log( ROADMAP_DEBUG, "roadmap_trip_server_after_login" ); cursor = roadmap_history_latest (ADDRESS_FAVORITE_CATEGORY); if( !cursor){ return; } while (cursor){ roadmap_history_get (ADDRESS_FAVORITE_CATEGORY, cursor, argv); prev = cursor; if (strcmp(argv[ahi_synced], "true")){ RoadMapPosition coordinates; count++; if (count > 3) //limit syncing to 3 return; roadmap_log( ROADMAP_DEBUG, "roadmap_trip_server_after_login_delayed - Syncing favorite (%s) with server",argv[ahi_name] ); coordinates.latitude = atoi(argv[ahi_latitude]); coordinates.longitude = atoi(argv[ahi_longtitude]); create_poi(argv[ahi_name], &coordinates, TRUE, cursor); } else{ roadmap_log( ROADMAP_DEBUG, "roadmap_trip_server_after_login_delayed - Favorite (%s) already synced with server",argv[ahi_name] ); } cursor = roadmap_history_before (ADDRESS_FAVORITE_CATEGORY, cursor); if (cursor == prev) break; } roadmap_log( ROADMAP_DEBUG, "roadmap_trip_server_after_login_delayed end" ); }