/**
 * xviewer_postasa_plugin_init:
 *
 * Object initialisation method.  Sets up the (unauthenticated)
 * PicasaWeb service, a #GCancellable for login, and sets the
 * uploads_pending flag to %FALSE.
 **/
static void
xviewer_postasa_plugin_init (XviewerPostasaPlugin *plugin)
{
	xviewer_debug_message (DEBUG_PLUGINS, "XviewerPostasaPlugin initializing");

	plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, XVIEWER_TYPE_POSTASA_PLUGIN, XviewerPostasaPluginPrivate);

#ifdef HAVE_LIBGDATA_0_9
	plugin->priv->authorizer = gdata_client_login_authorizer_new ("XviewerPostasa", GDATA_TYPE_PICASAWEB_SERVICE);
	plugin->priv->service = gdata_picasaweb_service_new (GDATA_AUTHORIZER (plugin->priv->authorizer)); /* unref'd in xviewer_postasa_plugin_dispose() */
#else
	plugin->priv->service = gdata_picasaweb_service_new ("XviewerPostasa"); /* unref'd in xviewer_postasa_plugin_dispose() */
#endif
	plugin->priv->login_cancellable = g_cancellable_new (); /* unref'd in xviewer_postasa_plugin_dispose() */
	plugin->priv->uploads_pending = FALSE;
}
예제 #2
0
static void
test_query_events (void)
{
	GDataFeed *feed, *calendar_feed;
	GDataClientLoginAuthorizer *authorizer;
	GDataCalendarCalendar *calendar;
	GDataCalendarService *service;
	GList *calendars;
	GError *error = NULL;

	authorizer = gdata_client_login_authorizer_new (CLIENT_ID, GDATA_TYPE_CALENDAR_SERVICE);
	service = gdata_calendar_service_new (GDATA_AUTHORIZER (authorizer));

	/* Log in */
	gdata_client_login_authorizer_authenticate (authorizer, USERNAME, PASSWORD, NULL, &error);
	g_assert_no_error (error);

	/* Get a calendar */
	calendar_feed = gdata_calendar_service_query_own_calendars (service, NULL, NULL, NULL, NULL, &error);
	g_assert_no_error (error);

	calendars = gdata_feed_get_entries (calendar_feed);
	calendar = calendars->data;

	g_object_ref (calendar);
	g_object_unref (calendar_feed);

	/* Get the entry feed */
	feed = gdata_calendar_service_query_events (service, calendar, NULL, NULL, NULL, NULL, &error);
	g_assert_no_error (error);

	g_object_unref (feed);
	g_object_unref (calendar);
	g_object_unref (service);
	g_object_unref (authorizer);
}