~ubuntu-branches/ubuntu/wily/gnome-online-miners/wily

« back to all changes in this revision

Viewing changes to src/gom-gdata-miner.c

  • Committer: Package Import Robot
  • Author(s): Jackson Doak
  • Date: 2015-05-27 18:29:04 UTC
  • mfrom: (1.2.3) (3.1.5 sid)
  • Revision ID: package-import@ubuntu.com-20150527182904-3n7155exelk5mj0i
Tags: 3.14.3-1ubuntu1
* Merge from debian. Remaining changes:
  - debian/control.in: Switch dep to grilo-plugins-0.2-extra 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * GNOME Online Miners - crawls through your online content
3
 
 * Copyright (c) 2011, 2012, 2013, 2014 Red Hat, Inc.
 
3
 * Copyright (c) 2011, 2012, 2013, 2014, 2015 Red Hat, Inc.
4
4
 *
5
5
 * This program is free software; you can redistribute it and/or
6
6
 * modify it under the terms of the GNU General Public License
29
29
#include "gom-gdata-miner.h"
30
30
 
31
31
#define MINER_IDENTIFIER "gd:gdata:miner:86ec9bc9-c242-427f-aa19-77b5a2c9b6f0"
32
 
#define STARRED_CATEGORY_TERM "http://schemas.google.com/g/2005/labels#starred"
33
32
#define PARENT_LINK_REL "http://schemas.google.com/docs/2007#parent"
34
33
 
 
34
/* used by applications to identify the source of an entry */
 
35
#define PREFIX_DRIVE "google:drive:"
 
36
#define PREFIX_PICASAWEB "google:picasaweb:"
 
37
 
35
38
G_DEFINE_TYPE (GomGDataMiner, gom_gdata_miner, GOM_TYPE_MINER)
36
39
 
37
40
static gchar *
81
84
      GDataLink *link;
82
85
 
83
86
      link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF);
84
 
      identifier = g_strdup_printf ("gd:collection:%s", gdata_link_get_uri (link));
 
87
      identifier = g_strdup_printf ("gd:collection:%s%s", PREFIX_DRIVE, gdata_link_get_uri (link));
85
88
    }
86
89
  else
87
 
    identifier = g_strdup (gdata_entry_get_id (entry));
 
90
    {
 
91
      const gchar *id;
 
92
 
 
93
      id = gdata_entry_get_id (entry);
 
94
      identifier = g_strdup_printf ("%s%s", PREFIX_DRIVE, id);
 
95
    }
88
96
 
89
97
  /* remove from the list of the previous resources */
90
98
  g_hash_table_remove (job->previous_resources, identifier);
168
176
 
169
177
      parent = l->data;
170
178
      parent_resource_id =
171
 
        g_strdup_printf ("gd:collection:%s", gdata_link_get_uri (parent));
 
179
        g_strdup_printf ("gd:collection:%s%s", PREFIX_DRIVE, gdata_link_get_uri (parent));
172
180
 
173
181
      parent_resource_urn = gom_tracker_sparql_connection_ensure_resource
174
182
        (job->connection, job->cancellable, error,
195
203
  for (l = categories; l != NULL; l = l->next)
196
204
    {
197
205
      category = l->data;
198
 
      if (g_strcmp0 (gdata_category_get_term (category), STARRED_CATEGORY_TERM) == 0)
 
206
      if (g_strcmp0 (gdata_category_get_term (category), GDATA_CATEGORY_SCHEMA_LABELS_STARRED) == 0)
199
207
        {
200
208
          starred = TRUE;
201
209
          break;
327
335
                                 const gchar *parent_resource_urn,
328
336
                                 GError **error)
329
337
{
330
 
  GList *media_content;
 
338
  GList *l, *media_contents;
331
339
  gchar *resource = NULL, *equipment_resource = NULL;
332
 
  gchar *contact_resource, *date, *identifier;
 
340
  gchar *contact_resource, *date, *identifier = NULL;
333
341
  gboolean resource_exists, mtime_changed;
334
342
  gint64 new_mtime;
335
343
  gint64 timestamp;
358
366
  const gchar *alternate_uri;
359
367
 
360
368
  id = gdata_entry_get_id (GDATA_ENTRY (photo));
361
 
  identifier = g_strdup_printf ("google:picasaweb:%s", id);
 
369
 
 
370
  media_contents = gdata_picasaweb_file_get_contents (photo);
 
371
  for (l = media_contents; l != NULL; l = l->next)
 
372
    {
 
373
      GDataMediaContent *media_content = GDATA_MEDIA_CONTENT (l->data);
 
374
      GDataMediaMedium medium;
 
375
 
 
376
      medium = gdata_media_content_get_medium (media_content);
 
377
      if (medium != GDATA_MEDIA_IMAGE)
 
378
        {
 
379
          g_debug ("Skipping %s because medium(%d) is not an image", id, medium);
 
380
          goto out;
 
381
        }
 
382
    }
 
383
 
 
384
  identifier = g_strdup_printf ("%s%s", PREFIX_PICASAWEB, id);
362
385
 
363
386
  /* remove from the list of the previous resources */
364
387
  g_hash_table_remove (job->previous_resources, identifier);
427
450
  if (*error != NULL)
428
451
    goto out;
429
452
 
430
 
  media_content = gdata_picasaweb_file_get_contents (photo);
431
 
  mime = gdata_media_content_get_content_type (GDATA_MEDIA_CONTENT (media_content->data));
 
453
  mime = gdata_media_content_get_content_type (GDATA_MEDIA_CONTENT (media_contents->data));
432
454
  gom_tracker_sparql_connection_insert_or_replace_triple
433
455
    (job->connection,
434
456
     job->cancellable, error,
637
659
  const gchar *alternate_uri;
638
660
 
639
661
  album_id = gdata_entry_get_id (GDATA_ENTRY (album));
640
 
  identifier = g_strdup_printf ("photos:collection:google:picasaweb:%s", album_id);
 
662
  identifier = g_strdup_printf ("photos:collection:%s%s", PREFIX_PICASAWEB, album_id);
641
663
 
642
664
  /* remove from the list of the previous resources */
643
665
  g_hash_table_remove (job->previous_resources, identifier);
910
932
 
911
933
  miner_class->goa_provider_type = "google";
912
934
  miner_class->miner_identifier = MINER_IDENTIFIER;
913
 
  miner_class->version = 4;
 
935
  miner_class->version = 5;
914
936
 
915
937
  miner_class->create_services = create_services;
916
938
  miner_class->query = query_gdata;