Changeset 42

Show
Ignore:
Timestamp:
03/08/07 16:28:22 (2 years ago)
Author:
inz
Message:

Make contexts optional.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • blog-service/trunk/bs-manager.c

    r41 r42  
    259259 
    260260        if (error) { 
    261                 GError *gerror = g_error_new( 
    262                                 g_quark_from_string("blog-service"), 
    263                                 error->error_code, 
    264                                 "%s", 
    265                                 error->error_string); 
    266                 dbus_g_method_return_error(clo->context, gerror); 
     261                if (clo->context) { 
     262                        GError *gerror = g_error_new( 
     263                                        g_quark_from_string("blog-service"), 
     264                                        error->error_code, 
     265                                        "%s", 
     266                                        error->error_string); 
     267                        dbus_g_method_return_error(clo->context, gerror); 
     268                } 
    267269                blog_post_free(post); 
    268         } 
    269         dbus_g_method_return(clo->context, status); 
     270                return; 
     271        } 
     272        if (clo->context) { 
     273                dbus_g_method_return(clo->context, status); 
     274        } 
    270275 
    271276        if (!status) { 
     
    345350 
    346351        if (!(blog = g_hash_table_lookup(priv->blogs, blog_id))) { 
    347                 error = g_error_new(g_quark_from_string("blog-service"), 
    348                                 404, 
    349                                 "No such blog." 
    350                                 ); 
    351                 dbus_g_method_return_error(context, error); 
     352                if (context) { 
     353                        error = g_error_new(g_quark_from_string("blog-service"), 
     354                                        404, 
     355                                        "No such blog." 
     356                                        ); 
     357                        dbus_g_method_return_error(context, error); 
     358                } 
    352359                return FALSE; 
    353360        } 
     
    361368 
    362369        if (!clo->post->title || !clo->post->content) { 
    363                 error = g_error_new(g_quark_from_string("blog-service"), 
    364                                 412, 
    365                                 "No title or content." 
    366                                 ); 
    367370                blog_post_free(clo->post); 
    368371                g_free(clo); 
    369                 dbus_g_method_return_error(context, error); 
     372                if (context) { 
     373                        error = g_error_new(g_quark_from_string("blog-service"), 
     374                                        412, 
     375                                        "No title or content." 
     376                                        ); 
     377                        dbus_g_method_return_error(context, error); 
     378                } 
    370379                return FALSE; 
    371380        } 
     
    396405 
    397406        if (!(blog = g_hash_table_lookup(priv->blogs, blog_id))) { 
    398                 error = g_error_new(g_quark_from_string("blog-service"), 
    399                                 404, 
    400                                 "No such blog." 
    401                                 ); 
    402                 dbus_g_method_return_error(context, error); 
     407                if (context) { 
     408                        error = g_error_new(g_quark_from_string("blog-service"), 
     409                                        404, 
     410                                        "No such blog."); 
     411                        dbus_g_method_return_error(context, error); 
     412                } 
    403413                return FALSE; 
    404414        } 
     
    414424 
    415425        if (!post) { 
    416                 error = g_error_new(g_quark_from_string("blog-service"), 
    417                                 404, 
    418                                 "No such post." 
    419                                 ); 
    420                 dbus_g_method_return_error(context, error); 
     426                if (context) { 
     427                        error = g_error_new(g_quark_from_string("blog-service"), 
     428                                        404, 
     429                                        "No such post."); 
     430                        dbus_g_method_return_error(context, error); 
     431                } 
    421432                return FALSE; 
    422433        } 
     
    430441 
    431442        if (!clo->post->title || !clo->post->content) { 
    432                 error = g_error_new(g_quark_from_string("blog-service"), 
    433                                 412, 
    434                                 "No title or content." 
    435                                 ); 
    436443                blog_post_free(clo->post); 
    437444                g_free(clo); 
    438                 dbus_g_method_return_error(context, error); 
     445                if (context) { 
     446                        error = g_error_new(g_quark_from_string("blog-service"), 
     447                                        412, 
     448                                        "No title or content." 
     449                                        ); 
     450                        dbus_g_method_return_error(context, error); 
     451                } 
    439452                return FALSE; 
    440453        } 
     
    461474        struct UpdateClosure *closure = user_data; 
    462475        if (!(--closure->count)) { 
    463                 dbus_g_method_return(closure->context); 
     476                if (closure->context) { 
     477                        dbus_g_method_return(closure->context); 
     478                } 
    464479                g_free(user_data); 
    465480        }