/** * gdata_tasks_service_query_tasks: * @self: a #GDataTasksService * @tasklist: a #GDataTasksTasklist * @query: (allow-none): a #GDataQuery with the query parameters, or %NULL * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @progress_callback: (allow-none) (scope call) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry is loaded, or %NULL * @progress_user_data: (closure): data to pass to the @progress_callback function * @error: (allow-none): a #GError, or %NULL * * Queries the service to return a list of tasks in the given @tasklist, which match @query. * * For more details, see gdata_service_query(). * * Return value: (transfer full): a #GDataFeed of query results; unref with g_object_unref() * * Since: 0.15.0 */ GDataFeed * gdata_tasks_service_query_tasks (GDataTasksService *self, GDataTasksTasklist *tasklist, GDataQuery *query, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GError **error) { gchar* request_uri; GDataFeed *feed; g_return_val_if_fail (GDATA_IS_TASKS_SERVICE (self), NULL); g_return_val_if_fail (GDATA_IS_TASKS_TASKLIST (tasklist), NULL); g_return_val_if_fail (gdata_entry_get_id (GDATA_ENTRY (tasklist)) != NULL, NULL); g_return_val_if_fail (query == NULL || GDATA_IS_QUERY (query), NULL); g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); /* Ensure we're authenticated first */ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)), get_tasks_authorization_domain ()) == FALSE) { g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, _("You must be authenticated to query your own tasks.")); return NULL; } /* Should add /tasks as requested by API */ request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.googleapis.com/tasks/v1/lists/", gdata_entry_get_id (GDATA_ENTRY (tasklist)), "/tasks", NULL); /* Execute the query */ feed = gdata_service_query (GDATA_SERVICE (self), get_tasks_authorization_domain (), request_uri, query, GDATA_TYPE_TASKS_TASK, cancellable, progress_callback, progress_user_data, error); g_free (request_uri); return feed; }
/** * gdata_tasks_service_query_tasks_async: * @self: a #GDataTasksService * @tasklist: a #GDataTasksTasklist * @query: (allow-none): a #GDataQuery with the query parameters, or %NULL * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @progress_callback: (allow-none) (closure progress_user_data): a #GDataQueryProgressCallback to call when an entry is loaded, or %NULL * @progress_user_data: (closure): data to pass to the @progress_callback function * @destroy_progress_user_data: (allow-none): the function to call when @progress_callback will not be called any more, or %NULL. This function will be * called with @progress_user_data as a parameter and can be used to free any memory allocated for it. * @callback: a #GAsyncReadyCallback to call when the query is finished * @user_data: (closure): data to pass to the @callback function * * Queries the service to return a list of tasks in the given @tasklist, which match @query. @self, @tasklist and @query are all reffed when this * function is called, so can safely be unreffed after this function returns. * * Get the results of the query using gdata_service_query_finish() in the @callback. * * For more details, see gdata_tasks_service_query_tasks(), which is the synchronous version of this function, and gdata_service_query_async(), * which is the base asynchronous query function. * * Since: 0.15.0 */ void gdata_tasks_service_query_tasks_async (GDataTasksService *self, GDataTasksTasklist *tasklist, GDataQuery *query, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GDestroyNotify destroy_progress_user_data, GAsyncReadyCallback callback, gpointer user_data) { gchar *request_uri; g_return_if_fail (GDATA_IS_TASKS_SERVICE (self)); g_return_if_fail (GDATA_IS_TASKS_TASKLIST (tasklist)); g_return_if_fail (gdata_entry_get_id (GDATA_ENTRY (tasklist)) != NULL); g_return_if_fail (query == NULL || GDATA_IS_QUERY (query)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); /* Ensure we're authenticated first */ if (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)), get_tasks_authorization_domain ()) == FALSE) { GSimpleAsyncResult *result = g_simple_async_result_new (G_OBJECT (self), callback, user_data, gdata_service_query_async); g_simple_async_result_set_error (result, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, "%s", _("You must be authenticated to query your own tasks.")); g_simple_async_result_complete_in_idle (result); g_object_unref (result); return; } /* Should add /tasks as requested by API */ request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.googleapis.com/tasks/v1/lists/", gdata_entry_get_id (GDATA_ENTRY (tasklist)), "/tasks", NULL); /* Execute the query */ gdata_service_query_async (GDATA_SERVICE (self), get_tasks_authorization_domain (), request_uri, query, GDATA_TYPE_TASKS_TASK, cancellable, progress_callback, progress_user_data, destroy_progress_user_data, callback, user_data); g_free (request_uri); }
static void pdf_load_job_from_google_documents (PdfLoadJob *job) { gchar *tmp_name; gchar *tmp_path, *pdf_path; GFile *pdf_file; job->original_file_mtime = gdata_entry_get_updated (job->gdata_entry); tmp_name = g_strdup_printf ("gnome-documents-%u.pdf", g_str_hash (gdata_entry_get_id (job->gdata_entry))); tmp_path = g_build_filename (g_get_user_cache_dir (), "gnome-documents", NULL); job->pdf_path = pdf_path = g_build_filename (tmp_path, tmp_name, NULL); g_mkdir_with_parents (tmp_path, 0700); pdf_file = g_file_new_for_path (pdf_path); g_file_query_info_async (pdf_file, G_FILE_ATTRIBUTE_TIME_MODIFIED, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, job->cancellable, gdata_cache_query_info_ready_cb, job); g_free (tmp_name); g_free (tmp_path); g_object_unref (pdf_file); }
static gboolean account_miner_job_process_entry (TrackerSparqlConnection *connection, GHashTable *previous_resources, const gchar *datasource_urn, GDataDocumentsService *service, GDataDocumentsEntry *doc_entry, GCancellable *cancellable, GError **error) { GDataEntry *entry = GDATA_ENTRY (doc_entry); gchar *resource = NULL; gchar *date, *identifier; const gchar *class = NULL; const gchar *mimetype_override = NULL; gboolean mtime_changed, resource_exists; gint64 new_mtime; GList *authors, *l, *parents = NULL; GDataAuthor *author; GDataLink *parent; GDataLink *alternate; const gchar *alternate_uri; GList *categories; GDataCategory *category; gboolean starred = FALSE; GDataFeed *access_rules = NULL; if (GDATA_IS_DOCUMENTS_FOLDER (doc_entry)) { GDataLink *link; link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF); identifier = g_strdup_printf ("gd:collection:%s%s", PREFIX_DRIVE, gdata_link_get_uri (link)); } else { const gchar *id; id = gdata_entry_get_id (entry); identifier = g_strdup_printf ("%s%s", PREFIX_DRIVE, id); } /* remove from the list of the previous resources, if any */ if (previous_resources != NULL) g_hash_table_remove (previous_resources, identifier); if (GDATA_IS_DOCUMENTS_PRESENTATION (doc_entry)) class = "nfo:Presentation"; else if (GDATA_IS_DOCUMENTS_SPREADSHEET (doc_entry))
static void get_json (GDataParsable *parsable, JsonBuilder *builder) { GDataAccessRule *access_rule; const gchar *id, *etag, *role, *scope_type, *scope_value; access_rule = GDATA_ACCESS_RULE (parsable); id = gdata_entry_get_id (GDATA_ENTRY (parsable)); if (id != NULL) { json_builder_set_member_name (builder, "id"); json_builder_add_string_value (builder, id); } json_builder_set_member_name (builder, "kind"); json_builder_add_string_value (builder, "calendar#aclRule"); /* Add the ETag, if available. */ etag = gdata_entry_get_etag (GDATA_ENTRY (parsable)); if (etag != NULL) { json_builder_set_member_name (builder, "etag"); json_builder_add_string_value (builder, etag); } role = gdata_access_rule_get_role (access_rule); if (role != NULL) { json_builder_set_member_name (builder, "role"); json_builder_add_string_value (builder, role_v2_to_v3 (role)); } gdata_access_rule_get_scope (access_rule, &scope_type, &scope_value); if (scope_type != NULL || scope_value != NULL) { json_builder_set_member_name (builder, "scope"); json_builder_begin_object (builder); if (scope_type != NULL) { json_builder_set_member_name (builder, "type"); json_builder_add_string_value (builder, scope_type_v2_to_v3 (scope_type)); } if (scope_value != NULL) { json_builder_set_member_name (builder, "value"); json_builder_add_string_value (builder, scope_value); } json_builder_end_object (builder); } }
static gchar * build_events_uri (GDataCalendarCalendar *calendar) { GString *uri; const gchar *calendar_id; calendar_id = (calendar != NULL) ? gdata_entry_get_id (GDATA_ENTRY (calendar)) : "default"; uri = g_string_new (_gdata_service_get_scheme ()); g_string_append (uri, "://www.googleapis.com/calendar/v3/calendars/"); g_string_append_uri_escaped (uri, calendar_id, NULL, FALSE); g_string_append (uri, "/events"); return g_string_free (uri, FALSE); }
/** * gdata_tasks_service_insert_task_async: * @self: a #GDataTasksService * @task: the #GDataTasksTask to insert * @tasklist: #GDataTasksTasklist to insert into * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @callback: a #GAsyncReadyCallback to call when insertion is finished * @user_data: (closure): data to pass to the @callback function * * Inserts @task by uploading it to the online tasks service into tasklist @tasklist. @self, @task and @tasklist are all reffed when this function is called, so can safely be * unreffed after this function returns. * * @callback should call gdata_service_insert_entry_finish() to obtain a #GDataTasksTask representing the inserted task and to check for possible * errors. * * For more details, see gdata_tasks_service_insert_task(), which is the synchronous version of this function, and * gdata_service_insert_entry_async(), which is the base asynchronous insertion function. * * Since: 0.15.0 */ void gdata_tasks_service_insert_task_async (GDataTasksService *self, GDataTasksTask *task, GDataTasksTasklist *tasklist, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { gchar *request_uri; g_return_if_fail (GDATA_IS_TASKS_SERVICE (self)); g_return_if_fail (GDATA_IS_TASKS_TASK (task)); g_return_if_fail (GDATA_IS_TASKS_TASKLIST (tasklist)); g_return_if_fail (gdata_entry_get_id (GDATA_ENTRY (tasklist)) != NULL); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.googleapis.com/tasks/v1/lists/", gdata_entry_get_id (GDATA_ENTRY (tasklist)), "/tasks", NULL); gdata_service_insert_entry_async (GDATA_SERVICE (self), get_tasks_authorization_domain (), request_uri, GDATA_ENTRY (task), cancellable, callback, user_data); g_free (request_uri); }
/** * gdata_tasks_service_insert_task: * @self: a #GDataTasksService * @task: the #GDataTasksTask to insert * @tasklist: #GDataTasksTasklist to insert into * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @error: (allow-none): a #GError, or %NULL * * Inserts @task by uploading it to the online tasks service into tasklist @tasklist. It is safe to unref @tasklist after function returns. * * For more details, see gdata_service_insert_entry(). * * Return value: (transfer full): an updated #GDataTasksTask, or %NULL; unref with g_object_unref() * * Since: 0.15.0 */ GDataTasksTask * gdata_tasks_service_insert_task (GDataTasksService *self, GDataTasksTask *task, GDataTasksTasklist *tasklist, GCancellable *cancellable, GError **error) { gchar *request_uri; GDataEntry *entry; g_return_val_if_fail (GDATA_IS_TASKS_SERVICE (self), NULL); g_return_val_if_fail (GDATA_IS_TASKS_TASK (task), NULL); g_return_val_if_fail (GDATA_IS_TASKS_TASKLIST (tasklist), NULL); g_return_val_if_fail (gdata_entry_get_id (GDATA_ENTRY (tasklist)) != NULL, NULL); g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.googleapis.com/tasks/v1/lists/", gdata_entry_get_id (GDATA_ENTRY (tasklist)), "/tasks", NULL); entry = gdata_service_insert_entry (GDATA_SERVICE (self), get_tasks_authorization_domain (), request_uri, GDATA_ENTRY (task), cancellable, error); g_free (request_uri); return GDATA_TASKS_TASK (entry); }
static gboolean account_miner_job_process_entry (GomAccountMinerJob *job, GDataDocumentsEntry *doc_entry, GError **error) { GDataEntry *entry = GDATA_ENTRY (doc_entry); gchar *resource = NULL; gchar *date, *identifier; const gchar *class = NULL; const gchar *mimetype_override = NULL; gboolean mtime_changed, resource_exists; gint64 new_mtime; GList *authors, *l, *parents = NULL; GDataAuthor *author; GDataLink *parent; GDataLink *alternate; const gchar *alternate_uri; GList *categories; GDataCategory *category; gboolean starred = FALSE; GDataFeed *access_rules = NULL; if (GDATA_IS_DOCUMENTS_FOLDER (doc_entry)) { GDataLink *link; link = gdata_entry_look_up_link (entry, GDATA_LINK_SELF); identifier = g_strdup_printf ("gd:collection:%s", gdata_link_get_uri (link)); } else identifier = g_strdup (gdata_entry_get_id (entry)); /* remove from the list of the previous resources */ g_hash_table_remove (job->previous_resources, identifier); if (GDATA_IS_DOCUMENTS_PRESENTATION (doc_entry)) class = "nfo:Presentation"; else if (GDATA_IS_DOCUMENTS_SPREADSHEET (doc_entry))