Compare commits

..

No commits in common. "c696a369bd499a791713cc82dc8b90230f68436e" and "55808f9ef40b6cef825e3f0ab55edec4d78dacb4" have entirely different histories.

3 changed files with 20 additions and 30 deletions

View File

@ -60,8 +60,8 @@ void test_kona_search() {
kona_search_start(ks);
GMainLoop *loop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(loop);
//GMainLoop *loop = g_main_loop_new(NULL, FALSE);
//g_main_loop_run(loop);
}
int main(int argc, char *argv[])

View File

@ -3,10 +3,10 @@
#include <string.h>
struct _KonaImage {
GObject parent_instance; // Struct of parent (inherit)
kona_image_meta meta; // Meta info of the picture
GString* preview_file; // Local URL of the preview image
GString* full_file; // Local URL of the full image
GObject parent_instance; // struct of parent (inherit)
kona_image_meta meta;
GString* preview_url;
GString* full_url;
};
@ -26,10 +26,10 @@ static void kona_image_get_property(GObject *object, guint prop_id, GValue *valu
switch (prop_id) {
case PROP_FILE_PREVIEW:
g_value_set_string(value, (const gchar*) self->preview_file);
g_value_set_string(value, (const gchar*) self->preview_url);
break;
case PROP_FILE_FULL:
g_value_set_string(value, (const gchar*) self->full_file);
g_value_set_string(value, (const gchar*) self->full_url);
break;
case PROP_META:
g_value_set_pointer(value, &self->meta);
@ -45,29 +45,21 @@ static void kona_image_set_property(GObject *object, guint prop_id, const GValue
switch (prop_id) {
case PROP_FILE_FULL:
g_free(self->full_file);
self->full_file = (GString*) g_strdup(g_value_get_string(value));
g_free(self->full_url);
self->full_url = (GString*) g_strdup(g_value_get_string(value));
break;
case PROP_FILE_PREVIEW:
g_free(self->preview_file);
self->preview_file = (GString*) g_strdup(g_value_get_string(value));
g_free(self->preview_url);
self->preview_url = (GString*) g_strdup(g_value_get_string(value));
break;
case PROP_META:
meta = g_value_get_pointer(value);
self->meta.id = meta->id;
self->meta.width= meta->width;
self->meta.height = meta->height;
// Free URLs (strings)
g_free(self->meta.image_url);
self->meta.image_url = g_strdup(meta->image_url);
g_free(self->meta.preview_url);
self->meta.preview_url = g_strdup(meta->preview_url);
// Free tag list (string list)
g_list_free_full(self->meta.tags, g_free);
self->meta.tags = g_list_copy_deep(meta->tags, (GCopyFunc) g_strdup, NULL);
break;
default:
break;
@ -107,14 +99,12 @@ static void kona_image_dispose(GObject *self) {
static void kona_image_finalize(GObject *self) {
KonaImage *ki = (KonaImage*) self;
// Free strings
g_free(ki->full_file);
g_free(ki->preview_file);
// Free dynamic meta fields
g_free(ki->meta.image_url);
g_free(ki->meta.preview_url);
g_list_free(ki->meta.tags);
g_list_free_full(ki->meta.tags, g_free);
G_OBJECT_CLASS (kona_image_parent_class)->finalize (self);
}

View File

@ -41,7 +41,6 @@ static void kona_search_finalize(GObject *self)
{
KonaSearch *ks = (KonaSearch*) self;
//g_free(ks->postsSession);
g_free(ks->searchString);
G_OBJECT_CLASS (kona_search_parent_class)->finalize ((GObject*) self);
}
@ -61,24 +60,25 @@ void kona_search_start(KonaSearch *self)
gchar *url;
self->postsSession = soup_session_new();
self->postsCancellable = g_cancellable_new();
//self->postsCancellable = g_cancellable_new();
url = g_strdup_printf("http://konachan.com/post.xml?tag=%s", self->searchString);
msg = soup_message_new("GET", url);
g_free(url);
soup_session_send_async(self->postsSession, msg, self->postsCancellable, kona_search_posts_soup_cb, self);
//soup_session_send_async(self->postsSession, msg, self->postsCancellable, kona_search_posts_soup_cb, self);
printf("C"); fflush(stdout);
soup_session_send_message (self->postsSession, msg);
printf("D"); fflush(stdout);
}
static void kona_search_posts_soup_cb(GObject *object, GAsyncResult *result, gpointer user_data)
{
GInputStream *stream;
GError *error = NULL;
printf("D"); fflush(stdout);
stream = soup_session_send_finish (SOUP_SESSION (object), result, &error);
printf("RECEIVED!!\n");
fflush(stdout);
// MSG will be unref'd automatically
}