Changeset 30 for maemo-blog
- Timestamp:
- 02/27/07 13:37:35 (2 years ago)
- Files:
-
- maemo-blog/branches/0.1.x/Makefile (modified) (8 diffs)
- maemo-blog/branches/0.1.x/blog-blogger.c (modified) (6 diffs)
- maemo-blog/branches/0.1.x/blog-metaweblog.c (modified) (10 diffs)
- maemo-blog/branches/0.1.x/blog-plugin.h (modified) (1 diff)
- maemo-blog/branches/0.1.x/blog.c (modified) (2 diffs)
- maemo-blog/branches/0.1.x/blog.h (modified) (2 diffs)
- maemo-blog/branches/0.1.x/debian/changelog (modified) (1 diff)
- maemo-blog/branches/0.1.x/gui.c (modified) (2 diffs)
- maemo-blog/branches/0.1.x/maemo-blog.desktop (modified) (1 diff)
- maemo-blog/branches/0.1.x/main.c (modified) (3 diffs)
- maemo-blog/tags/maemo-blog-0.1.8 (copied) (copied from maemo-blog/trunk)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
maemo-blog/branches/0.1.x/Makefile
r26 r30 1 1 # Makefile for maemo-blog 2 3 CLEAN = $(subst /,_,$(subst -,_,$(subst .,_,$(1)))) 2 4 3 5 VERSION := $(shell head -n1 debian/changelog | sed -e 's/^.*(\([^-]*\)\(-.*\)*).*$$/\1/') … … 25 27 26 28 PACKAGE=maemo-blog 27 TARGETS=maemo _blog libmetaweblog.la libblogger.la29 TARGETS=maemo-blog libmetaweblog.la libblogger.la 28 30 29 31 WARNINGS += -Werror … … 53 55 maemo_blog_LDFLAGS += `pkg-config gconf-2.0 gtk+-2.0 --libs` -export-dynamic 54 56 55 maemo_blog_SOURCES := main.c plugin-loader.c accounts.c login.c gui.c 57 maemo_blog_SOURCES := main.c plugin-loader.c accounts.c login.c gui.c blog.c 56 58 maemo_blog_HEADERS := blog.h blog-plugin.h plugin-loader.h accounts.h login.h gui.h 57 59 maemo_blog_DESKTOP := maemo-blog.desktop … … 60 62 libmetaweblog_la_CFLAGS += $(CFLAGS) `pkg-config glib-2.0 libsoup-2.2 --cflags` 61 63 libmetaweblog_la_LDFLAGS = `pkg-config glib-2.0 libsoup-2.2 --libs` -module -shared -rpath $(LIBDIR) -avoid-version 62 libmetaweblog_la_SOURCES := blog-metaweblog.c 63 libmetaweblog_la_HEADERS := blog-plugin.h 64 libmetaweblog_la_SOURCES := blog-metaweblog.c blog.c 65 libmetaweblog_la_HEADERS := blog-plugin.h blog.h 64 66 libmetaweblog_la_DIR := $(PLUGINDIR) 65 67 66 68 libblogger_la_CFLAGS += $(CFLAGS) `pkg-config glib-2.0 libsoup-2.2 --cflags` 67 69 libblogger_la_LDFLAGS = `pkg-config glib-2.0 libsoup-2.2 --libs` -module -shared -rpath $(LIBDIR) -avoid-version 68 libblogger_la_SOURCES := blog-blogger.c 69 libblogger_la_HEADERS := blog-plugin.h 70 libblogger_la_SOURCES := blog-blogger.c blog.c 71 libblogger_la_HEADERS := blog-plugin.h blog.h 70 72 libblogger_la_DIR := $(PLUGINDIR) 71 73 … … 77 79 all: $(patsubst %, %.build, ${TARGETS}) 78 80 79 $(PART): $(patsubst %.c, %.lo, ${$( subst .,_,${PART})_SOURCES}) ${$(subst .,_,${PART})_PC}81 $(PART): $(patsubst %.c, %.lo, ${$(call CLEAN,${PART})_SOURCES}) ${$(call CLEAN,${PART})_PC} 80 82 @echo -n " Linking..." 81 @$(LIBTOOL) --quiet --mode=link $(CC) $(patsubst %.c, %.lo, ${$( subst .,_,${PART})_SOURCES}) -o $@ ${$(subst .,_,${PART})_LDFLAGS}83 @$(LIBTOOL) --quiet --mode=link $(CC) $(patsubst %.c, %.lo, ${$(call CLEAN,${PART})_SOURCES}) -o $@ ${$(call CLEAN,${PART})_LDFLAGS} 82 84 @echo "done." 83 85 … … 86 88 @$(MAKE) LIBDIR="$(LIBDIR)" PLUGINDIR="$(PLUGINDIR)" -s PART="$(patsubst %.build,%,$@)" $(patsubst %.build,%,$@) 87 89 88 %.lo: %.c $($( subst .,_,${PART})_HEADERS)90 %.lo: %.c $($(call CLEAN,${PART})_HEADERS) 89 91 @echo -n " Building $@..." 90 @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $($( subst .,_,${PART})_CFLAGS) -c $< -o $@92 @$(LIBTOOL) --quiet --mode=compile $(CC) $(CFLAGS) $($(call CLEAN,${PART})_CFLAGS) -c $< -o $@ 91 93 92 94 @echo "done." … … 103 105 104 106 %.clean: 105 @libtool --quiet --mode=clean rm -f $(patsubst %.c, %.lo, ${$( subst .,_,$(patsubst %.clean,%,$@))_SOURCES})107 @libtool --quiet --mode=clean rm -f $(patsubst %.c, %.lo, ${$(call CLEAN,$(patsubst %.clean,%,$@))_SOURCES}) 106 108 107 109 .PHONY: distclean … … 114 116 115 117 %.install: %.build 116 @$(INSTALL_DIR) ${$( subst .,_,$(patsubst %.install,%,$@))_DIR}117 @libtool --quiet --mode=install $(INSTALL) $(patsubst %.install,%,$@) ${$( subst .,_,$(patsubst %.install,%,$@))_DIR}118 @if [ x != "x${$( subst .,_,$(patsubst %.install,%,$@))_PC}" ]; then $(INSTALL_DIR) ${$(subst .,_,$(patsubst %.install,%,$@))_PCDIR}; $(INSTALL_DATA) ${$(subst .,_,$(patsubst %.install,%,$@))_PC} ${$(subst .,_,$(patsubst %.install,%,$@))_PCDIR}; fi119 @if [ x != "x${$( subst .,_,$(patsubst %.install,%,$@))_DESKTOP}" ]; then $(INSTALL_DIR) ${$(subst .,_,$(patsubst %.install,%,$@))_DESKTOPDIR}; $(INSTALL_DATA) ${$(subst .,_,$(patsubst %.install,%,$@))_DESKTOP} ${$(subst .,_,$(patsubst %.install,%,$@))_DESKTOPDIR}; fi120 @if [ x != "x${$( subst .,_,$(patsubst %.install,%,$@))_PIXMAPS}" ]; then $(INSTALL_DIR) ${$(subst .,_,$(patsubst %.install,%,$@))_PIXMAPDIR}; $(INSTALL_DATA) ${$(subst .,_,$(patsubst %.install,%,$@))_PIXMAPS} ${$(subst .,_,$(patsubst %.install,%,$@))_PIXMAPDIR}; fi121 @if [ x != "x${$( subst .,_,$(patsubst %.install,%,$@))_INCLUDES}" ]; then $(INSTALL_DIR) ${$(subst .,_,$(patsubst %.install,%,$@))_INCLUDEDIR}; $(INSTALL_DATA) ${$(subst .,_,$(patsubst %.install,%,$@))_INCLUDES} ${$(subst .,_,$(patsubst %.install,%,$@))_INCLUDEDIR}; fi118 @$(INSTALL_DIR) ${$(call CLEAN,$(patsubst %.install,%,$@))_DIR} 119 @libtool --quiet --mode=install $(INSTALL) $(patsubst %.install,%,$@) ${$(call CLEAN,$(patsubst %.install,%,$@))_DIR} 120 @if [ x != "x${$(call CLEAN,$(patsubst %.install,%,$@))_PC}" ]; then $(INSTALL_DIR) ${$(call CLEAN,$(patsubst %.install,%,$@))_PCDIR}; $(INSTALL_DATA) ${$(call CLEAN,$(patsubst %.install,%,$@))_PC} ${$(call CLEAN,$(patsubst %.install,%,$@))_PCDIR}; fi 121 @if [ x != "x${$(call CLEAN,$(patsubst %.install,%,$@))_DESKTOP}" ]; then $(INSTALL_DIR) ${$(call CLEAN,$(patsubst %.install,%,$@))_DESKTOPDIR}; $(INSTALL_DATA) ${$(call CLEAN,$(patsubst %.install,%,$@))_DESKTOP} ${$(call CLEAN,$(patsubst %.install,%,$@))_DESKTOPDIR}; fi 122 @if [ x != "x${$(call CLEAN,$(patsubst %.install,%,$@))_PIXMAPS}" ]; then $(INSTALL_DIR) ${$(call CLEAN,$(patsubst %.install,%,$@))_PIXMAPDIR}; $(INSTALL_DATA) ${$(call CLEAN,$(patsubst %.install,%,$@))_PIXMAPS} ${$(call CLEAN,$(patsubst %.install,%,$@))_PIXMAPDIR}; fi 123 @if [ x != "x${$(call CLEAN,$(patsubst %.install,%,$@))_INCLUDES}" ]; then $(INSTALL_DIR) ${$(call CLEAN,$(patsubst %.install,%,$@))_INCLUDEDIR}; $(INSTALL_DATA) ${$(call CLEAN,$(patsubst %.install,%,$@))_INCLUDES} ${$(call CLEAN,$(patsubst %.install,%,$@))_INCLUDEDIR}; fi 122 124 123 125 %: %.in Makefile debian/changelog maemo-blog/branches/0.1.x/blog-blogger.c
r26 r30 102 102 if (soup_xmlrpc_value_array_get_iterator(value, &iter)) { 103 103 while (iter) { 104 Blog *blog = g_new0(Blog, 1);104 Blog *blog = blog_new(); 105 105 GHashTable *hash; 106 106 SoupXmlrpcValue *val; … … 128 128 } 129 129 } else { 130 Blog *blog = g_new0(Blog, 1);130 Blog *blog = blog_new(); 131 131 GHashTable *hash; 132 132 SoupXmlrpcValue *val; … … 155 155 } 156 156 157 clo->cb(retval, clo->user_data);157 clo->cb(retval, NULL, clo->user_data); 158 158 g_free(clo->uri); 159 159 g_free(clo->user); … … 238 238 soup_xmlrpc_value_get_boolean(value, &status); 239 239 } 240 clo->cb(clo->blog, clo->post, status, clo->user_data);240 clo->cb(clo->blog, clo->post, status, NULL, clo->user_data); 241 241 g_free(clo); 242 242 } … … 355 355 struct BlogBloggerFetchedClosure *clo = user_data; 356 356 357 clo->cb(clo->blog, clo->user_data);357 clo->cb(clo->blog, NULL, clo->user_data); 358 358 359 359 return FALSE; … … 423 423 } 424 424 425 clo->cb(clo->blog, clo->user_data);425 clo->cb(clo->blog, NULL, clo->user_data); 426 426 g_free(clo); 427 427 } maemo-blog/branches/0.1.x/blog-metaweblog.c
r26 r30 13 13 SoupSession *session; 14 14 }; 15 16 static gint _field_compare(gconstpointer a, gconstpointer b) 17 { 18 const BlogParameter *pa = a; 19 const BlogParameter *pb = b; 20 21 return strcmp(pa->name, pb->name); 22 } 15 23 16 24 static BlogCategory *category_lookup(Blog *blog, const gchar *name) … … 130 138 SoupXmlrpcValueArrayIterator *iter; 131 139 140 if (soup_xmlrpc_response_is_fault(response)) { 141 BlogPluginError error = { 0, NULL }; 142 error.error_string = "Unknown error"; 143 error.error_code = 404; 144 clo->cb(retval, &error, clo->user_data); 145 g_free(clo->uri); 146 g_free(clo->user); 147 g_free(clo->pass); 148 g_free(clo); 149 return; 150 } 151 132 152 soup_xmlrpc_value_array_get_iterator(value, &iter); 133 153 134 154 while (iter) { 135 Blog *blog = g_new0(Blog, 1);155 Blog *blog = blog_new(); 136 156 GHashTable *hash; 137 157 SoupXmlrpcValue *val; … … 165 185 } 166 186 167 clo->cb(retval, clo->user_data);187 clo->cb(retval, NULL, clo->user_data); 168 188 g_free(clo->uri); 169 189 g_free(clo->user); … … 248 268 soup_xmlrpc_value_get_boolean(value, &status); 249 269 } 250 clo->cb(clo->blog, clo->post, status, clo->user_data);270 clo->cb(clo->blog, clo->post, status, NULL, clo->user_data); 251 271 g_free(clo); 252 272 } … … 259 279 struct MetaweblogPluginData *data = blog->plugin->plugin_data; 260 280 SoupXmlrpcMessage *msg; 281 GSList *param_copy = NULL; 282 GSList *struct_stack = g_slist_prepend(NULL, g_strdup("")); 283 guint top_len = 0; 261 284 262 285 if (!post || !post->content) { … … 314 337 soup_xmlrpc_message_end_array(msg); 315 338 soup_xmlrpc_message_end_member(msg); 316 for (iter = post->extra_fields; iter; iter = iter->next) { 339 param_copy = g_slist_sort(g_slist_copy(post->extra_fields), 340 _field_compare); 341 for (iter = param_copy; iter; iter = iter->next) { 317 342 BlogParameter *parm = iter->data; 318 soup_xmlrpc_message_start_member(msg, parm->name); 343 gchar *temp = parm->name; 344 while (strncmp(struct_stack->data, parm->name, 345 top_len)) { 346 soup_xmlrpc_message_end_struct(msg); 347 soup_xmlrpc_message_end_member(msg); 348 g_free(struct_stack->data); 349 struct_stack = g_slist_delete_link(struct_stack, 350 struct_stack); 351 } 352 while ((temp = strchr(parm->name + top_len, 353 ':'))) { 354 gchar *struct_name = 355 g_strndup(parm->name + 356 top_len, 357 temp - parm->name - 358 top_len); 359 soup_xmlrpc_message_start_member(msg, struct_name); 360 g_free(struct_name); 361 top_len = temp - parm->name + 1; 362 struct_name = g_strndup(parm->name, top_len); 363 soup_xmlrpc_message_start_struct(msg); 364 struct_stack = g_slist_prepend(struct_stack, 365 struct_name); 366 } 367 soup_xmlrpc_message_start_member(msg, parm->name + strlen(struct_stack->data)); 319 368 switch (G_VALUE_TYPE(&parm->value)) { 320 369 case G_TYPE_STRING: … … 343 392 soup_xmlrpc_message_end_member(msg); 344 393 } 345 soup_xmlrpc_message_end_struct(msg); 394 while (struct_stack) { 395 soup_xmlrpc_message_end_struct(msg); 396 g_free(struct_stack->data); 397 struct_stack = g_slist_delete_link(struct_stack, struct_stack); 398 } 346 399 soup_xmlrpc_message_end_param(msg); 347 400 soup_xmlrpc_message_start_param(msg); … … 536 589 } 537 590 538 clo->cb(clo->blog, clo->user_data);591 clo->cb(clo->blog, NULL, clo->user_data); 539 592 g_free(clo); 540 593 } … … 636 689 } 637 690 638 clo->cb(clo->blog, clo->user_data);691 clo->cb(clo->blog, NULL, clo->user_data); 639 692 g_free(clo); 640 693 } … … 694 747 soup_xmlrpc_value_get_string(value, &url); 695 748 696 clo->cb(clo->blog, clo->image_name, url, clo->user_data);749 clo->cb(clo->blog, clo->image_name, url, NULL, clo->user_data); 697 750 g_free(url); 698 751 g_free(clo->image_name); maemo-blog/branches/0.1.x/blog-plugin.h
r2 r30 8 8 #include "blog.h" 9 9 10 typedef void (*BlogConnectedCb)(Blog **blogs, gpointer user_data); 11 typedef void (*BlogFetchCb)(Blog *blog, gpointer user_data); 12 typedef void (*BlogPostCb)(Blog *blog, BlogPost *post, gboolean status, gpointer user_data); 13 typedef void (*BlogUploadCb)(Blog *blog, const gchar *image_name, const gchar *image_path, gpointer user_data); 10 typedef struct _BlogPluginError BlogPluginError; 11 struct _BlogPluginError { 12 gint error_code; 13 const gchar *error_string; 14 }; 15 16 typedef void (*BlogConnectedCb)(Blog **blogs, const BlogPluginError *error, gpointer user_data); 17 typedef void (*BlogFetchCb)(Blog *blog, const BlogPluginError *error, gpointer user_data); 18 typedef void (*BlogPostCb)(Blog *blog, BlogPost *post, gboolean status, const BlogPluginError *error, gpointer user_data); 19 typedef void (*BlogUploadCb)(Blog *blog, const gchar *image_name, const gchar *image_path, const BlogPluginError *error, gpointer user_data); 14 20 15 21 struct _BlogPlugin { maemo-blog/branches/0.1.x/blog.c
r12 r30 1 1 #include "blog.h" 2 3 static void blog_free(Blog *blog); 2 4 3 5 void blog_parameter_free(BlogParameter *param) … … 24 26 } 25 27 26 void blog_free(Blog *blog) 28 Blog *blog_new() { 29 Blog *retval = g_new0(Blog, 1); 30 retval->refcount = 1; 31 return retval; 32 } 33 34 void blog_ref(Blog *blog) { 35 blog->refcount++; 36 } 37 38 void blog_unref(Blog *blog) 39 { 40 if (!(--blog->refcount)) { 41 blog_free(blog); 42 } 43 } 44 45 static void blog_free(Blog *blog) 27 46 { 28 47 g_free(blog->url); maemo-blog/branches/0.1.x/blog.h
r12 r30 21 21 GSList *categories; 22 22 GSList *posts; 23 gint refcount; 23 24 }; 24 25 … … 44 45 void blog_post_free(BlogPost *post); 45 46 void blog_category_free(BlogCategory *category); 46 void blog_free(Blog *blog); 47 Blog *blog_new(void); 48 void blog_ref(Blog *blog); 49 void blog_unref(Blog *blog); 47 50 48 51 #endif /* _BLOG_H_ */ maemo-blog/branches/0.1.x/debian/changelog
r26 r30 1 maemo-blog (0.1.8) mistral; urgency=low 2 3 * Add error reporting to blog plugin API. 4 5 -- Santtu Lakkala <inz@inz.fi> Tue, 27 Feb 2007 13:31:34 +0200 6 1 7 maemo-blog (0.1.7) mistral; urgency=low 2 8 maemo-blog/branches/0.1.x/gui.c
r12 r30 34 34 } 35 35 36 static void _uploaded(Blog *blog, const gchar *image_name, const gchar *image_path, gpointer user_data)36 static void _uploaded(Blog *blog, const gchar *image_name, const gchar *image_path, const BlogPluginError *error, gpointer user_data) 37 37 { 38 38 struct UploadClosure *closure = user_data; 39 39 (void)blog; 40 (void)error; 40 41 (void)image_name; 41 42 closure->name = g_strdup(image_path); … … 73 74 }; 74 75 75 static void _posted(Blog *blog, BlogPost *post, gboolean status, gpointer user_data)76 static void _posted(Blog *blog, BlogPost *post, gboolean status, const BlogPluginError *error, gpointer user_data) 76 77 { 77 78 struct PostClosure *closure = user_data; 78 79 (void)blog; 79 80 (void)post; 81 (void)error; 80 82 81 83 closure->status = status; maemo-blog/branches/0.1.x/maemo-blog.desktop
r15 r30 2 2 Encoding=UTF-8 3 3 Categories=Application;Network; 4 Exec=/usr/bin/maemo _blog4 Exec=/usr/bin/maemo-blog 5 5 Type=Application 6 6 X-Osso-Type=application/x-executable maemo-blog/branches/0.1.x/main.c
r2 r30 37 37 } */ 38 38 39 static void gotrec(Blog *blog, gpointer user_data)39 static void gotrec(Blog *blog, const BlogPluginError *error, gpointer user_data) 40 40 { 41 41 (void)blog; 42 (void)error; 42 43 struct Foo *foo = user_data; 43 44 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(foo->pbar), 1.00); … … 46 47 } 47 48 48 static void gotcat(Blog *blog, gpointer user_data)49 static void gotcat(Blog *blog, const BlogPluginError *error, gpointer user_data) 49 50 { 50 51 struct Foo *foo = user_data; 52 (void)error; 51 53 52 54 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(foo->pbar), "Getting recent posts..."); … … 55 57 } 56 58 57 static void connected(Blog **blogs, gpointer user_data)59 static void connected(Blog **blogs, const BlogPluginError *error, gpointer user_data) 58 60 { 59 61 struct Foo *foo = user_data; 60 62 guint i; 61 (void) blogs;63 (void)error; 62 64 63 65 *foo->blogs = blogs;
