/** * a_acquire_set_filter_track: * * Sets application-wide track to use with filter. references the track. */ void a_acquire_set_filter_track ( VikTrack *tr ) { if ( filter_track ) vik_track_free ( filter_track ); filter_track = tr; vik_track_ref ( tr ); }
void a_acquire_set_filter_track ( VikTrack *tr, const gchar *name ) { if ( filter_track ) vik_track_free ( filter_track ); if ( filter_track_name ) g_free ( filter_track_name ); filter_track = tr; vik_track_ref ( tr ); filter_track_name = g_strdup(name); }
/** * uploading function executed by the background" thread */ static void osm_traces_upload_thread ( OsmTracesInfo *oti, gpointer threaddata ) { /* Due to OSM limits, we have to enforce ele and time fields also don't upload invisible tracks */ static GpxWritingOptions options = { TRUE, TRUE, FALSE, FALSE }; if (!oti) return; gchar *filename = NULL; /* writing gpx file */ if (oti->trk != NULL) { /* Upload only the selected track */ if ( oti->anonymize_times ) { VikTrack *trk = vik_track_copy(oti->trk, TRUE); vik_track_anonymize_times(trk); filename = a_gpx_write_track_tmp_file(trk, &options); vik_track_free(trk); } else filename = a_gpx_write_track_tmp_file (oti->trk, &options); } else { /* Upload the whole VikTrwLayer */ filename = a_gpx_write_tmp_file (oti->vtl, &options); } if ( !filename ) return; /* finally, upload it */ gint ans = osm_traces_upload_file(osm_user, osm_password, filename, oti->name, oti->description, oti->tags, oti->vistype); // // Show result in statusbar or failure in dialog for user feedback // // Get current time to put into message to show when result was generated // since need to show difference between operations (when displayed on statusbar) // NB If on dialog then don't need time. time_t timenow; struct tm* timeinfo; time ( &timenow ); timeinfo = localtime ( &timenow ); gchar timestr[80]; // Compact time only - as days/date isn't very useful here strftime ( timestr, sizeof(timestr), "%X)", timeinfo ); // // Test to see if window it was invoked on is still valid // Not sure if this test really works! (i.e. if the window was closed in the mean time) // if ( IS_VIK_WINDOW ((VikWindow *)VIK_GTK_WINDOW_FROM_LAYER(oti->vtl)) ) { gchar* msg; if ( ans == 0 ) { // Success msg = g_strdup_printf ( "%s (@%s)", _("Uploaded to OSM"), timestr ); } // Use UPPER CASE for bad news :( else if ( ans == 1001 ) { msg = g_strdup_printf ( "%s (@%s)", _("FAILED TO UPLOAD DATA TO OSM - Ensure the OSM access token preferences are setup."), timestr ); } else if ( ans < 0 ) { msg = g_strdup_printf ( "%s (@%s)", _("FAILED TO UPLOAD DATA TO OSM - CURL PROBLEM"), timestr ); } else { msg = g_strdup_printf ( "%s : %s %d (@%s)", _("FAILED TO UPLOAD DATA TO OSM"), _("HTTP response code"), ans, timestr ); } vik_window_statusbar_update ( (VikWindow*)VIK_GTK_WINDOW_FROM_LAYER(oti->vtl), msg, VIK_STATUSBAR_INFO ); g_free (msg); } /* Removing temporary file */ int ret = g_unlink(filename); if (ret != 0) { g_critical(_("failed to unlink temporary file: %s"), strerror(errno)); } }