Started preparing some soup.
This commit is contained in:
parent
185733d5f2
commit
55808f9ef4
@ -1,13 +1,10 @@
|
||||
aux_source_directory(. SRC_LIST)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(PC_LIBSOUP REQUIRED libsoup-2.4)
|
||||
|
||||
include_directories(${PC_LIBSOUP_INCLUDE_DIRS} ../libkonaclient)
|
||||
link_directories(${GTK3_LIBRARY_DIRS} ${PC_LIBSOUP_LIBRARY_DIRS} libkonaclient)
|
||||
include_directories(../libkonaclient)
|
||||
link_directories(${GTK3_LIBRARY_DIRS} libkonaclient)
|
||||
add_definitions(${GTK3_CFLAGS_OTHER})
|
||||
|
||||
add_executable(libkonaclient-test ${SRC_LIST})
|
||||
|
||||
# Link the target to the GTK+ libraries
|
||||
target_link_libraries(libkonaclient-test ${PC_LIBSOUP_LIBRARIES} konaclient)
|
||||
target_link_libraries(libkonaclient-test konaclient)
|
||||
|
@ -56,7 +56,12 @@ void test_kona_search() {
|
||||
KonaSearch *ks;
|
||||
|
||||
PRINT_TEST_HEADER();
|
||||
ks = kona_search_new();
|
||||
ks = kona_search_new("yuri");
|
||||
|
||||
kona_search_start(ks);
|
||||
|
||||
//GMainLoop *loop = g_main_loop_new(NULL, FALSE);
|
||||
//g_main_loop_run(loop);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -1,4 +1,10 @@
|
||||
# Build library
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(PC_LIBSOUP REQUIRED libsoup-2.4)
|
||||
|
||||
include_directories(${PC_LIBSOUP_INCLUDE_DIRS})
|
||||
link_directories(${PC_LIBSOUP_LIBRARY_DIRS})
|
||||
|
||||
aux_source_directory(. LIBSRC_LIST)
|
||||
add_library(konaclient SHARED ${LIBSRC_LIST})
|
||||
target_link_libraries(konaclient ${GLIB2_LIBRARIES} ${GOBJECT2_LIBRARIES})
|
||||
target_link_libraries(konaclient ${GLIB2_LIBRARIES} ${PC_LIBSOUP_LIBRARIES} ${GOBJECT2_LIBRARIES})
|
||||
|
@ -1,39 +1,84 @@
|
||||
#include "konasearch.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <libsoup/soup.h>
|
||||
|
||||
static void kona_search_posts_soup_cb(GObject *object, GAsyncResult *result, gpointer user_data);
|
||||
|
||||
/*** GLIB object start ***/
|
||||
|
||||
struct _KonaSearch {
|
||||
GObject parent_instance; // struct of parent (inherit)
|
||||
gchar *searchString;
|
||||
|
||||
SoupSession *postsSession;
|
||||
GCancellable *postsCancellable;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(KonaSearch, kona_search, G_TYPE_OBJECT)
|
||||
|
||||
static void kona_search_class_init(KonaSearchClass *klass) {
|
||||
static void kona_search_class_init(KonaSearchClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
//object_class->set_property = kona_image_set_property;
|
||||
//object_class->get_property = kona_image_get_property;
|
||||
//object_class->set_property = kona_search_set_property;
|
||||
//object_class->get_property = kona_search_get_property;
|
||||
object_class->dispose = kona_search_dispose;
|
||||
object_class->finalize = kona_search_finalize;
|
||||
}
|
||||
|
||||
static void kona_search_init (KonaSearch *self) {
|
||||
static void kona_search_init (KonaSearch *self)
|
||||
{
|
||||
printf("kona_search_init\n");
|
||||
}
|
||||
|
||||
static void kona_search_dispose(GObject *self) {
|
||||
static void kona_search_dispose(GObject *self)
|
||||
{
|
||||
G_OBJECT_CLASS (kona_search_parent_class)->dispose((GObject*) self);
|
||||
}
|
||||
|
||||
static void kona_search_finalize(GObject *self) {
|
||||
static void kona_search_finalize(GObject *self)
|
||||
{
|
||||
KonaSearch *ks = (KonaSearch*) self;
|
||||
//g_free(ks->postsSession);
|
||||
G_OBJECT_CLASS (kona_search_parent_class)->finalize ((GObject*) self);
|
||||
}
|
||||
|
||||
KonaSearch *kona_search_new()
|
||||
KonaSearch *kona_search_new(gchar *search)
|
||||
{
|
||||
return g_object_new(KONA_TYPE_SEARCH, 0);
|
||||
KonaSearch *ks;
|
||||
ks = g_object_new(KONA_TYPE_SEARCH, 0);
|
||||
ks->searchString = g_strdup(search);
|
||||
return G_OBJECT(ks);
|
||||
}
|
||||
|
||||
/*** GLIB object end ***/
|
||||
|
||||
void kona_search_start(KonaSearch *self)
|
||||
{
|
||||
SoupMessage *msg;
|
||||
gchar *url;
|
||||
|
||||
self->postsSession = soup_session_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);
|
||||
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");
|
||||
}
|
||||
|
@ -6,10 +6,11 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define KONA_TYPE_SEARCH (kona_search_get_type())
|
||||
//#define KONA_SEARCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KONA_TYPE_SEARCH, KonaSearch))
|
||||
|
||||
G_DECLARE_FINAL_TYPE (KonaSearch, kona_search, KONA, SEARCH, GObject)
|
||||
|
||||
KonaSearch *kona_search_new();
|
||||
KonaSearch *kona_search_new(gchar *search);
|
||||
static void kona_search_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
||||
static void kona_search_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
||||
static void kona_search_class_init(KonaSearchClass *klass);
|
||||
@ -17,6 +18,8 @@ static void kona_search_init (KonaSearch *self);
|
||||
static void kona_search_dispose(GObject *self);
|
||||
static void kona_search_finalize(GObject *self);
|
||||
|
||||
void kona_search_start(KonaSearch *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // KONASEARCH_H
|
||||
|
Loading…
Reference in New Issue
Block a user