Example #1
0
JsonParser* zenmoney_home_timeline (Zenmoney* self) {
	JsonParser* result = NULL;
	SoupSession* session = NULL;
	SoupSessionAsync* _tmp0_ = NULL;
	SoupMessage* message = NULL;
	OauthZenmoney* _tmp1_ = NULL;
	SoupMessage* _tmp2_ = NULL;
	JsonParser* parser = NULL;
	JsonParser* _tmp3_ = NULL;
	SoupMessageBody* _tmp20_ = NULL;
	SoupBuffer* _tmp21_ = NULL;
	SoupBuffer* _tmp22_ = NULL;
	guint8* _tmp23_ = NULL;
	gint _tmp23__length1 = 0;
	gchar* _tmp24_ = NULL;
	gchar* _tmp25_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_print ("Home_timeline /n");
	_tmp0_ = (SoupSessionAsync*) soup_session_async_new ();
	session = (SoupSession*) _tmp0_;
	_tmp1_ = self->priv->ot;
	_tmp2_ = oauth_zenmoney_Auth (_tmp1_, "POST", OWNER_INFO_URL, NULL);
	message = _tmp2_;
	soup_session_send_message (session, message);
	_tmp3_ = json_parser_new ();
	parser = _tmp3_;
	{
		SoupMessageBody* _tmp4_ = NULL;
		SoupBuffer* _tmp5_ = NULL;
		SoupBuffer* _tmp6_ = NULL;
		guint8* _tmp7_ = NULL;
		gint _tmp7__length1 = 0;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		gchar* _tmp10_ = NULL;
		gchar* _tmp11_ = NULL;
		SoupMessageBody* _tmp12_ = NULL;
		SoupBuffer* _tmp13_ = NULL;
		SoupBuffer* _tmp14_ = NULL;
		guint8* _tmp15_ = NULL;
		gint _tmp15__length1 = 0;
		_tmp4_ = message->response_body;
		_tmp5_ = soup_message_body_flatten (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _tmp6_->data;
		_tmp7__length1 = (gint) _tmp6_->length;
		_tmp8_ = g_strconcat ("response: ", (const gchar*) _tmp7_, NULL);
		_tmp9_ = _tmp8_;
		_tmp10_ = g_strconcat (_tmp9_, "\n", NULL);
		_tmp11_ = _tmp10_;
		g_print ("%s", _tmp11_);
		_g_free0 (_tmp11_);
		_g_free0 (_tmp9_);
		__vala_SoupBuffer_free0 (_tmp6_);
		_tmp12_ = message->response_body;
		_tmp13_ = soup_message_body_flatten (_tmp12_);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_->data;
		_tmp15__length1 = (gint) _tmp14_->length;
		json_parser_load_from_data (parser, (const gchar*) _tmp15_, (gssize) (-1), &_inner_error_);
		__vala_SoupBuffer_free0 (_tmp14_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch5_g_error;
		}
	}
	goto __finally5;
	__catch5_g_error:
	{
		GError* e = NULL;
		GError* _tmp16_ = NULL;
		const gchar* _tmp17_ = NULL;
		gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp16_ = e;
		_tmp17_ = _tmp16_->message;
		_tmp18_ = g_strconcat ("Error: ", _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		g_print ("%s", _tmp19_);
		_g_free0 (_tmp19_);
		_g_error_free0 (e);
	}
	__finally5:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (parser);
		_g_object_unref0 (message);
		_g_object_unref0 (session);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
	_tmp20_ = message->response_body;
	_tmp21_ = soup_message_body_flatten (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = _tmp22_->data;
	_tmp23__length1 = (gint) _tmp22_->length;
	_tmp24_ = g_strconcat ("response", (const gchar*) _tmp23_, NULL);
	_tmp25_ = _tmp24_;
	g_print ("%s", _tmp25_);
	_g_free0 (_tmp25_);
	__vala_SoupBuffer_free0 (_tmp22_);
	result = parser;
	_g_object_unref0 (message);
	_g_object_unref0 (session);
	return result;
}
Example #2
0
static void docker_gui_get_containers (DockerGui* self, GtkListStore* listmodel) {
	GtkTreeIter iter = {0};
	gchar* uri = NULL;
	gchar* _tmp0_ = NULL;
	SoupSession* session = NULL;
	SoupSession* _tmp1_ = NULL;
	SoupMessage* message = NULL;
	SoupMessage* _tmp2_ = NULL;
	JsonParser* parser = NULL;
	JsonParser* _tmp3_ = NULL;
	SoupMessageBody* _tmp4_ = NULL;
	SoupBuffer* _tmp5_ = NULL;
	SoupBuffer* _tmp6_ = NULL;
	guint8* _tmp7_ = NULL;
	gint _tmp7__length1 = 0;
	JsonArray* jsonContainers = NULL;
	JsonNode* _tmp8_ = NULL;
	JsonArray* _tmp9_ = NULL;
	JsonArray* _tmp10_ = NULL;
	JsonArray* _tmp11_ = NULL;
	GList* _tmp12_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (listmodel != NULL);
	_tmp0_ = g_strdup ("http://localhost:5555/containers/json");
	uri = _tmp0_;
	_tmp1_ = soup_session_new ();
	session = _tmp1_;
	_tmp2_ = soup_message_new ("GET", uri);
	message = _tmp2_;
	soup_session_send_message (session, message);
	_tmp3_ = json_parser_new ();
	parser = _tmp3_;
	_tmp4_ = message->response_body;
	_tmp5_ = soup_message_body_flatten (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = _tmp6_->data;
	_tmp7__length1 = (gint) _tmp6_->length;
	json_parser_load_from_data (parser, (const gchar*) _tmp7_, (gssize) (-1), &_inner_error_);
	__vala_SoupBuffer_free0 (_tmp6_);
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (parser);
		_g_object_unref0 (message);
		_g_object_unref0 (session);
		_g_free0 (uri);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_tmp8_ = json_parser_get_root (parser);
	_tmp9_ = json_node_get_array (_tmp8_);
	_tmp10_ = _json_array_ref0 (_tmp9_);
	jsonContainers = _tmp10_;
	_tmp11_ = jsonContainers;
	_tmp12_ = json_array_get_elements (_tmp11_);
	{
		GList* c_collection = NULL;
		GList* c_it = NULL;
		c_collection = _tmp12_;
		for (c_it = c_collection; c_it != NULL; c_it = c_it->next) {
			JsonNode* _tmp13_ = NULL;
			JsonNode* c = NULL;
			_tmp13_ = __vala_JsonNode_copy0 ((JsonNode*) c_it->data);
			c = _tmp13_;
			{
				JsonObject* o = NULL;
				JsonNode* _tmp14_ = NULL;
				JsonObject* _tmp15_ = NULL;
				JsonObject* _tmp16_ = NULL;
				gchar* Id = NULL;
				JsonObject* _tmp17_ = NULL;
				const gchar* _tmp18_ = NULL;
				gchar* _tmp19_ = NULL;
				gchar* Image = NULL;
				JsonObject* _tmp20_ = NULL;
				const gchar* _tmp21_ = NULL;
				gchar* _tmp22_ = NULL;
				FILE* _tmp23_ = NULL;
				const gchar* _tmp24_ = NULL;
				const gchar* _tmp25_ = NULL;
				GtkListStore* _tmp26_ = NULL;
				GtkTreeIter _tmp27_ = {0};
				GtkListStore* _tmp28_ = NULL;
				GtkTreeIter _tmp29_ = {0};
				const gchar* _tmp30_ = NULL;
				const gchar* _tmp31_ = NULL;
				_tmp14_ = c;
				_tmp15_ = json_node_get_object (_tmp14_);
				_tmp16_ = _json_object_ref0 (_tmp15_);
				o = _tmp16_;
				_tmp17_ = o;
				_tmp18_ = json_object_get_string_member (_tmp17_, "Id");
				_tmp19_ = g_strdup (_tmp18_);
				Id = _tmp19_;
				_tmp20_ = o;
				_tmp21_ = json_object_get_string_member (_tmp20_, "Image");
				_tmp22_ = g_strdup (_tmp21_);
				Image = _tmp22_;
				_tmp23_ = stdout;
				_tmp24_ = Id;
				_tmp25_ = Image;
				fprintf (_tmp23_, "%s - %s\n", _tmp24_, _tmp25_);
				_tmp26_ = listmodel;
				gtk_list_store_append (_tmp26_, &_tmp27_);
				iter = _tmp27_;
				_tmp28_ = listmodel;
				_tmp29_ = iter;
				_tmp30_ = Id;
				_tmp31_ = Image;
				gtk_list_store_set (_tmp28_, &_tmp29_, 0, _tmp30_, 1, _tmp31_, -1);
				_g_free0 (Image);
				_g_free0 (Id);
				_json_object_unref0 (o);
				__vala_JsonNode_free0 (c);
			}
		}
		_g_list_free0 (c_collection);
	}
	_json_array_unref0 (jsonContainers);
	_g_object_unref0 (parser);
	_g_object_unref0 (message);
	_g_object_unref0 (session);
	_g_free0 (uri);
}