- osm_traces_upload_file(user, password, filename,
- oti->name, oti->description, oti->tags, oti->public);
-
+ 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 < 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);
+ }