Exemple #1
0
int main()
{
	GoaObject *goa_object;	
	GDataPicasaWebService *service;
	GDataPicasaWebAlbum *album, *inserted_album;
	GDataGoaAuthorizer *authorizer;
	GError *error;
	GoaClient *client;
	GList *accounts_list, *l;

	error = NULL;
	/*I am using sync version just to avoid some complexity and keeping it simple.*/
	client = goa_client_new_sync (NULL, &error);

	/*FYI, I have only experimented this with just one google account so account_lists assume 1 account only.*/
	accounts_list = goa_client_get_accounts (client);
	printf ("Accounts : %d\n", g_list_length (accounts_list));

	goa_object = accounts_list->data;
	authorizer = gdata_goa_authorizer_new (goa_object);	
	service = gdata_picasaweb_service_new (GDATA_AUTHORIZER (authorizer));

	/* Create a GDataPicasaWebAlbum entry for the new album, setting some information about it */
	album = gdata_picasaweb_album_new (NULL);
	gdata_entry_set_title (GDATA_ENTRY (album), "Test Album");
	gdata_entry_set_summary (GDATA_ENTRY (album), "This is just a testing album");
	gdata_picasaweb_album_set_location (album, "Ahmedabad");

	/* Insert the new album on the server. Note that this is a blocking operation. */
	inserted_album = gdata_picasaweb_service_insert_album (service, album, NULL, NULL);

	g_object_unref (album);
	g_object_unref (inserted_album);
	g_object_unref (service);
	g_object_unref (authorizer);
	printf("Album Created!");
}
Exemple #2
0
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;
}