Changeset 2563

Show
Ignore:
Timestamp:
02/07/06 00:51:00
Author:
chipx86
Message:

When a status is added, compute the object path and send it back to the caller.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/galago-daemon/protocol-cleanup/ChangeLog

    r2561 r2563  
     1Tue Feb 07 00:50:39 PST 2006  Christian Hammond <chipx86@chipx86.com> 
     2 
     3    * src/presence.c: 
     4      - When a status is added, compute the object path and send it back 
     5        to the caller. 
     6 
    17Mon Feb 06 01:10:05 PST 2006  Christian Hammond <chipx86@chipx86.com> 
    28 
  • branches/galago-daemon/protocol-cleanup/src/presence.c

    r2528 r2563  
    2323#include "utils.h" 
    2424 
     25static char * 
     26galagod_status_generate_path(GalagoPresence *presence, GalagoStatus *status) 
     27{ 
     28    return g_strdup_printf("%s/%s", 
     29        galago_object_get_dbus_path(GALAGO_OBJECT(presence)), 
     30        galago_status_get_id(status)); 
     31} 
     32 
    2533static void 
    2634_galagod_dbus_presence_emit_status_added(GalagoPresence *presence, 
     
    7280{ 
    7381    GalagoStatus *status; 
    74     GalagodMetaPresence *meta_presence
     82    GalagodMetaPresence *meta_presence = GALAGOD_META_PRESENCE(presence)
    7583    GalagoPresence *main_presence; 
    7684    DBusMessageIter iter; 
     85    DBusMessage *reply; 
    7786    const GList* l; 
    7887    const char *status_id; 
    7988    int status_weight = 0; 
    80  
    81     meta_presence = GALAGOD_META_PRESENCE(presence); 
     89    char *obj_path; 
    8290 
    8391    dbus_message_iter_init(message, &iter); 
    8492    status = galago_dbus_message_iter_get_object(&iter, GALAGO_TYPE_STATUS); 
    85     dbus_message_iter_next(&iter); 
    86  
     93 
     94    /* Pull out the status ID and object path, and set it back on the status */ 
    8795    status_id = galago_status_get_id(status); 
     96    obj_path = galagod_status_generate_path(presence, status); 
     97    galago_object_set_dbus_path(GALAGO_OBJECT(status), obj_path); 
     98 
     99    /* Send the reply containing the object path. */ 
     100    reply = dbus_message_new_method_return(message); 
     101    dbus_message_iter_init_append(reply, &iter); 
     102    dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &obj_path); 
     103    dbus_connection_send(dbus_conn, reply, NULL); 
     104    dbus_message_unref(reply); 
     105    g_free(obj_path); 
    88106 
    89107    if (!galago_presence_has_status(presence, status_id)) 
    90         galago_presence_add_status(presence, galago_status_duplicate(status)); 
     108    { 
     109        GalagoStatus *dup_status = galago_status_duplicate(status); 
     110 
     111        obj_path = galagod_status_generate_path(presence, dup_status); 
     112        galago_object_set_dbus_path(GALAGO_OBJECT(dup_status), obj_path); 
     113        g_free(obj_path); 
     114        galago_presence_add_status(presence, dup_status); 
     115    } 
    91116 
    92117    for (l = galagod_meta_presence_get_presences(meta_presence); 
     
    104129    main_presence = galagod_meta_presence_get_presence(meta_presence); 
    105130 
    106     if (status_weight > 0) 
    107     { 
    108         if (!galago_presence_has_status(main_presence, status_id)) 
    109         { 
    110             galago_context_push(galagod_get_context()); 
    111  
    112             galago_presence_add_status(main_presence, 
    113                                        galago_status_duplicate(status)); 
    114  
    115             galago_context_pop(); 
    116  
    117             _galagod_dbus_presence_emit_status_added(main_presence, status); 
    118         } 
     131    if (status_weight > 0 && 
     132        !galago_presence_has_status(main_presence, status_id)) 
     133    { 
     134        GalagoStatus *dup_status; 
     135 
     136        galago_context_push(galagod_get_context()); 
     137        dup_status = galago_status_duplicate(status); 
     138        obj_path = galagod_status_generate_path(main_presence, dup_status); 
     139        galago_object_set_dbus_path(GALAGO_OBJECT(dup_status), obj_path); 
     140        g_free(obj_path); 
     141        galago_presence_add_status(main_presence, dup_status); 
     142        galago_context_pop(); 
     143 
     144        _galagod_dbus_presence_emit_status_added(main_presence, status); 
    119145    } 
    120146 
    121147    g_object_unref(status); 
    122  
    123     galagod_dbus_send_empty_reply(dbus_conn, message); 
    124148 
    125149    return DBUS_HANDLER_RESULT_HANDLED;