Project

General

Profile

0002-flickr-fix-large-file-and-no-password-backend.patch

jean-luc Le Corre, 06/22/2019 10:45 PM

View differences:

src/imageio/storage/flickr.c
81 81
  GtkWidget *export_tags;
82 82
  GtkBox *create_box;                               // Create album options...
83 83
  GtkWidget *permission_list, *album_list;
84
  char *user_token;
85
  char *user_token_secret;
86
  char *user_nsid;
87 84
  gboolean authenticated;
88 85
  /* List of albums */
89 86
  _flickr_album_t **albums;
......
324 321
  curl_easy_setopt(ctx->curl, CURLOPT_WRITEFUNCTION, curl_write_data_cb);
325 322
  curl_easy_setopt(ctx->curl, CURLOPT_SSL_VERIFYPEER, FALSE);
326 323
  curl_easy_setopt(ctx->curl, CURLOPT_FOLLOWLOCATION, 1L);
327
  curl_easy_setopt(ctx->curl, CURLOPT_TIMEOUT, 20L);
324
  //curl_easy_setopt(ctx->curl, CURLOPT_TIMEOUT, 20L);
328 325

  
329 326
  if(!ui->authenticated)
330 327
  {
......
381 378
        dt_control_log(_("Flickr request_token failed"));
382 379
        free(err);
383 380
        g_string_free(response, TRUE);
384
        ctx->error_occured = TRUE ;
381
        free(ctx);
385 382
        return NULL ;
386 383
      }
387 384
      auth_key = getParameterValue("oauth_token",response->str);
......
390 387
    else
391 388
    {
392 389
      g_string_free(response, TRUE);
393
      ctx->error_occured = TRUE ;
390
      free(ctx);
394 391
      return NULL ;
395 392
    }
396 393
    g_string_free(response, TRUE);
......
444 441
      ctx->user_name = strdup(flickr_user_name);
445 442
      ui->authenticated = TRUE;
446 443
      ui->flickr_api = ctx;
447
      ui->flickr_api->needsReauthentication = FALSE;
444
      // override the user entry with the account he actually used to log in to flickr
445
      gtk_entry_set_text(ui->user_entry, flickr_user_name);
448 446
      free(oauth_verifier);
449 447
      g_string_free(response, TRUE);
448
      ui->flickr_api->needsReauthentication = FALSE;
450 449
    }
451 450
    else
452 451
    {
......
808 807
static void flickr_entry_changed(GtkEntry *entry, gpointer data)
809 808
{
810 809
  dt_storage_flickr_gui_data_t *ui = (dt_storage_flickr_gui_data_t *)data;
811

  
812 810
  if(ui->flickr_api != NULL)
813 811
  {
814
    ui->flickr_api->needsReauthentication = TRUE;
815
    set_status(ui, _("not authenticated"), "#e07f7f");
816
    gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE);
812
    if(strcmp(ui->flickr_api->user_name, gtk_entry_get_text(ui->user_entry)) != 0) // dt set user_name after auth.
813
    {
814
      ui->flickr_api->needsReauthentication = TRUE;
815
      set_status(ui, _("not authenticated"), "#e07f7f");
816
      gtk_widget_set_sensitive(GTK_WIDGET(ui->album_list), FALSE);
817
    }
817 818
  }
818 819
}
819 820

  
820 821
static _flickr_album_t **flickr_photosets_getList(_flickr_api_context_t *ctx)
821 822
{
822 823
  CURLcode res;
823
  gint i, nb_albums;
824
  gint i, k, nb_albums;
824 825
  _flickr_album_t **albums = NULL ;
825 826
  ctx->error_occured = FALSE;
826 827
  GString *photoset_url = g_string_new("https://api.flickr.com/services/rest/?method=flickr.photosets.getList&api_key=");
......
852 853
    {
853 854
      nb_albums = json_array_get_length(jsalbums) ;
854 855
      albums = g_malloc0( (nb_albums + 1) * sizeof(_flickr_album_t *));
855
      for (i = 0; i < nb_albums; i++)
856
      for (i = 0, k=0 ; i < nb_albums; i++)
856 857
      {
857 858
        JsonObject *obj = json_array_get_object_element(jsalbums, i);
858 859
        if (obj == NULL) continue ;
......
860 861
        JsonObject *otitle = json_object_get_object_member(obj, "title");
861 862
        const char *name = json_object_get_string_member(otitle, "_content");
862 863
        const int photos = json_object_get_int_member(obj, "photos");
863
        albums[i] = g_malloc0(sizeof(_flickr_album_t));
864
        albums[i]->id = g_strdup(id);
865
        albums[i]->title = g_strdup(name);
866
        albums[i]->photos_count = photos ;
864
        if (strcmp(name, "Auto Upload") != 0) {  // not allowed for upload by fliclr 
865
          albums[k] = g_malloc0(sizeof(_flickr_album_t));
866
          albums[k]->id = g_strdup(id);
867
          albums[k]->title = g_strdup(name);
868
          albums[k]->photos_count = photos ;
869
          k++ ;
870
        }
867 871
      }
868 872
    }
869 873
  }
......
1356 1360
    }
1357 1361

  
1358 1362
    // Let UI forget about this api context and recreate a new one for further usage...
1359
    ui->flickr_api = _flickr_api_authenticate(ui);
1363
    // ui->flickr_api = _flickr_api_authenticate(ui);   
1360 1364
    if(ui->flickr_api)
1361 1365
    {
1362 1366
      set_status(ui, _("authenticated"), "#7fe07f");
1363
- 
Go to top