/** * gdata_freebase_service_search_async: * @self: a #GDataFreebaseService * @query: a #GDataFreebaseQuery with the MQL query * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @callback: a #GAsyncReadyCallback to call when authentication is finished * @user_data: (closure): data to pass to the @callback function * * Performs a search for any given search term. @self and @query are all reffed when this * function is called, so can safely be unreffed after this function returns. * * For more details, see gdata_freebase_service_search(), which is the synchronous version of * this function. * * Since: 0.15.1 * Deprecated: 0.17.7: Google Freebase has been permanently shut down. */ void gdata_freebase_service_search_async (GDataFreebaseService *self, GDataFreebaseSearchQuery *query, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_return_if_fail (GDATA_IS_FREEBASE_SERVICE (self)); g_return_if_fail (GDATA_IS_FREEBASE_SEARCH_QUERY (query)); g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); g_return_if_fail (callback != NULL); gdata_service_query_single_entry_async (GDATA_SERVICE (self), get_freebase_authorization_domain (), "search", GDATA_QUERY (query), GDATA_TYPE_FREEBASE_SEARCH_RESULT, cancellable, callback, user_data); }
/** * gdata_freebase_service_search: * @self: a #GDataFreebaseService * @query: a #GDataFreebaseSearchQuery containing the topic ID * @cancellable: (allow-none): optional #GCancellable object, or %NULL * @error: (allow-none): a #GError, or %NULL * * Performs a search for any given search term, filters can be set on @query to narrow down the results. The results returned * are ordered by relevance. You can find out more about topic queries in the * <ulink type="http" url="https://developers.google.com/freebase/v1/search-cookbook">online documentation</ulink>. * * Return value: (transfer full): a #GDataFreebaseSearchResult containing the results for the given search query; unref with g_object_unref() * * Since: 0.15.1 * Deprecated: 0.17.7: Google Freebase has been permanently shut down. */ GDataFreebaseSearchResult * gdata_freebase_service_search (GDataFreebaseService *self, GDataFreebaseSearchQuery *query, GCancellable *cancellable, GError **error) { GDataEntry *entry; g_return_val_if_fail (GDATA_IS_FREEBASE_SERVICE (self), NULL); g_return_val_if_fail (GDATA_IS_FREEBASE_SEARCH_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); entry = gdata_service_query_single_entry (GDATA_SERVICE (self), get_freebase_authorization_domain (), "search", GDATA_QUERY (query), GDATA_TYPE_FREEBASE_SEARCH_RESULT, cancellable, error); if (entry == NULL) return NULL; return GDATA_FREEBASE_SEARCH_RESULT (entry); }
/** * gdata_contacts_service_query_groups: * @self: a #GDataContactsService * @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: a #GError, or %NULL * * Queries the service to return a list of groups matching the given @query. * * For more details, see gdata_service_query(). * * Return value: (transfer full): a #GDataFeed of query results; unref with g_object_unref() * * Since: 0.7.0 **/ GDataFeed * gdata_contacts_service_query_groups (GDataContactsService *self, GDataQuery *query, GCancellable *cancellable, GDataQueryProgressCallback progress_callback, gpointer progress_user_data, GError **error) { GDataFeed *feed; gchar *request_uri; g_return_val_if_fail (GDATA_IS_CONTACTS_SERVICE (self), 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_contacts_authorization_domain ()) == FALSE) { g_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED, _("You must be authenticated to query contact groups.")); return NULL; } request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.google.com/m8/feeds/groups/default/full", NULL); feed = gdata_service_query (GDATA_SERVICE (self), get_contacts_authorization_domain (), request_uri, GDATA_QUERY (query), GDATA_TYPE_CONTACTS_GROUP, cancellable, progress_callback, progress_user_data, error); g_free (request_uri); return feed; }
/** * gdata_contacts_service_query_groups_async: * @self: a #GDataContactsService * @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 groups matching the given @query. @self and @query are all reffed when this function is called, so can * safely be unreffed after this function returns. * * For more details, see gdata_contacts_service_query_groups(), which is the synchronous version of this function, and gdata_service_query_async(), * which is the base asynchronous query function. * * Since: 0.9.1 **/ void gdata_contacts_service_query_groups_async (GDataContactsService *self, 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_CONTACTS_SERVICE (self)); 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_contacts_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 contact groups.")); g_simple_async_result_complete_in_idle (result); g_object_unref (result); return; } request_uri = g_strconcat (_gdata_service_get_scheme (), "://www.google.com/m8/feeds/groups/default/full", NULL); gdata_service_query_async (GDATA_SERVICE (self), get_contacts_authorization_domain (), request_uri, GDATA_QUERY (query), GDATA_TYPE_CONTACTS_GROUP, cancellable, progress_callback, progress_user_data, destroy_progress_user_data, callback, user_data); g_free (request_uri); }
gint main (void) { GDataDocumentsFeed *feed = NULL; GDataDocumentsQuery *query = NULL; GDataDocumentsService *service = NULL; GError *error = NULL; GList *accounts = NULL; GList *entries; GList *l; GoaClient *client = NULL; client = goa_client_new_sync (NULL, &error); if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); goto out; } accounts = goa_client_get_accounts (client); for (l = accounts; l != NULL; l = l->next) { GoaAccount *account; GoaObject *object = GOA_OBJECT (l->data); const gchar *provider_type; account = goa_object_peek_account (object); provider_type = goa_account_get_provider_type (account); if (g_strcmp0 (provider_type, "google") == 0) { GDataGoaAuthorizer *authorizer; authorizer = gdata_goa_authorizer_new (object); service = gdata_documents_service_new (GDATA_AUTHORIZER (authorizer)); g_object_unref (authorizer); } } if (service == NULL) { g_warning ("Account not found"); goto out; } query = gdata_documents_query_new_with_limits (NULL, 1, 10); gdata_documents_query_set_show_folders (query, TRUE); while (TRUE) { feed = gdata_documents_service_query_documents (service, query, NULL, NULL, NULL, &error); if (error != NULL) { g_warning ("%s", error->message); g_error_free (error); goto out; } entries = gdata_feed_get_entries (GDATA_FEED (feed)); if (entries == NULL) { goto out; } for (l = entries; l != NULL; l = l->next) { GDataEntry *entry = GDATA_ENTRY (l->data); const gchar *title; title = gdata_entry_get_title (entry); g_message ("%s", title); } gdata_query_next_page (GDATA_QUERY (query)); g_object_unref (feed); } out: g_clear_object (&feed); g_clear_object (&query); g_clear_object (&service); g_clear_object (&client); g_list_free_full (accounts, g_object_unref); return 0; }