static gboolean
parse_json (GDataParsable *parsable, JsonReader *reader, gpointer user_data, GError **error)
{
	GDataFreebaseTopicResultPrivate *priv = GDATA_FREEBASE_TOPIC_RESULT (parsable)->priv;
	const gchar *member_name;

	GDATA_PARSABLE_CLASS (gdata_freebase_topic_result_parent_class)->parse_json (parsable, reader, user_data, error);

	member_name = json_reader_get_member_name (reader);

	if (member_name == NULL)
		return FALSE;

	if (strcmp (member_name, "id") == 0) {
		/* We only expect one member containing information */
		g_assert (priv->object == NULL);
		priv->object = object_new (json_reader_get_string_value (reader));
	} else if (strcmp (member_name, "property") == 0) {
		reader_get_properties (reader, priv->object, error);
	} else {
		return FALSE;
	}

	return TRUE;
}
static void
gdata_freebase_topic_result_finalize (GObject *self)
{
	GDataFreebaseTopicResultPrivate *priv = GDATA_FREEBASE_TOPIC_RESULT (self)->priv;

	gdata_freebase_topic_object_unref (priv->object);

	G_OBJECT_CLASS (gdata_freebase_topic_result_parent_class)->finalize (self);
}
Пример #3
0
/**
 * gdata_freebase_service_get_topic:
 * @self: a #GDataFreebaseService
 * @query: a #GDataFreebaseTopicQuery containing the topic ID
 * @cancellable: (allow-none): optional #GCancellable object, or %NULL
 * @error: (allow-none): a #GError, or %NULL
 *
 * Queries information about a topic, identified through a Freebase ID. You can find out more about topic queries in the
 * <ulink type="http" url="https://developers.google.com/freebase/v1/topic-response">online documentation</ulink>.
 *
 * Return value: (transfer full): a #GDataFreebaseTopicResult containing information about the topic; unref with g_object_unref()
 *
 * Since: 0.15.1
 * Deprecated: 0.17.7: Google Freebase has been permanently shut down.
 */
GDataFreebaseTopicResult *
gdata_freebase_service_get_topic (GDataFreebaseService *self, GDataFreebaseTopicQuery *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_TOPIC_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 (), "topic",
						  GDATA_QUERY (query), GDATA_TYPE_FREEBASE_TOPIC_RESULT, cancellable, error);
	if (entry == NULL)
		return NULL;

	return GDATA_FREEBASE_TOPIC_RESULT (entry);
}