r7185 - in dumbhippo/trunk/client/common: ddm hippo



Author: otaylor
Date: 2008-01-10 17:28:48 -0600 (Thu, 10 Jan 2008)
New Revision: 7185

Modified:
   dumbhippo/trunk/client/common/ddm/ddm-data-model.c
   dumbhippo/trunk/client/common/ddm/ddm-data-model.h
   dumbhippo/trunk/client/common/hippo/hippo-actions.c
   dumbhippo/trunk/client/common/hippo/hippo-connection.c
   dumbhippo/trunk/client/common/hippo/hippo-connection.h
   dumbhippo/trunk/client/common/hippo/hippo-data-model-backend.c
   dumbhippo/trunk/client/common/hippo/hippo-entity.c
   dumbhippo/trunk/client/common/hippo/hippo-entity.h
   dumbhippo/trunk/client/common/hippo/hippo-stack-manager.c
Log:
hippo-connection.c: Revert r7149; the self resource ID *is* dependent
  on the host name of the server.

hippo-actions.c: Use data model updates rather than method calls on 
  hippo-connections that send old IQ's.

hippo-data-model-backend.c: Handle a "local update" 
  online-desktop:/p/system#openUrl to open an URL in the web browser,
  since the stacker client won't have the correct browser to use.
  
  (Though maybe we should just go to the system default browser, rather
  than the one for which we found a cookie; local update infrastructure
  should be useful anyways...)

hippo-connection.c: Remove various unused code bits

hippo-stack-manager.c ddm-data-model.c hippo-data-model-backend.c: Rename
  ddm_data_model_get_connected() to ddm_data_model_is_online() and make it
  have the right value.

hippo-entity.[ch]: Add hippo_entity_get_resource(), not needed right now,
  but I keep on addding it locally and then removing it again.


Modified: dumbhippo/trunk/client/common/ddm/ddm-data-model.c
===================================================================
--- dumbhippo/trunk/client/common/ddm/ddm-data-model.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/ddm/ddm-data-model.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -215,11 +215,18 @@
 }
 
 gboolean
-ddm_data_model_get_connected(DDMDataModel   *model)
+ddm_data_model_is_online(DDMDataModel   *model)
 {
+    gboolean connected = FALSE;
+    
     g_return_val_if_fail(DDM_IS_DATA_MODEL(model), FALSE);
 
-    return model->connected;
+    if (model->global_resource != NULL)
+        ddm_data_resource_get(model->global_resource,
+                              "online", DDM_DATA_BOOLEAN, &connected,
+                              NULL);
+
+    return connected;
 }
 
 gboolean

Modified: dumbhippo/trunk/client/common/ddm/ddm-data-model.h
===================================================================
--- dumbhippo/trunk/client/common/ddm/ddm-data-model.h	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/ddm/ddm-data-model.h	2008-01-10 23:28:48 UTC (rev 7185)
@@ -47,7 +47,7 @@
                               const char         *default_children,
                               const char         *condition);
 
-gboolean      ddm_data_model_get_connected      (DDMDataModel   *model);
+gboolean      ddm_data_model_is_online          (DDMDataModel   *model);
 gboolean      ddm_data_model_is_ready           (DDMDataModel   *model);
 
 DDMDataResource *ddm_data_model_get_global_resource (DDMDataModel *model);

Modified: dumbhippo/trunk/client/common/hippo/hippo-actions.c
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-actions.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-actions.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -156,6 +156,12 @@
     return hippo_data_cache_get_connection(actions->cache);
 }
 
+static DDMDataModel*
+get_model(HippoActions *actions)
+{
+    return hippo_data_cache_get_model(actions->cache);
+}
+
 static HippoPlatform*
 get_platform(HippoActions *actions)
 {
@@ -166,14 +172,22 @@
 hippo_actions_visit_post(HippoActions   *actions,
                          HippoPost      *post)
 {
-    hippo_connection_visit_post(get_connection(actions), post);
+    const char *visit_url;
+    
+    ddm_data_resource_get(hippo_post_get_resource(post),
+                          "visitUrl", DDM_DATA_URL, &visit_url,
+                          NULL);
+
+    if (visit_url != NULL)
+        hippo_actions_open_url(actions, visit_url);
 }
 
 void
 hippo_actions_visit_entity(HippoActions    *actions,
                            HippoEntity     *entity)
 {
-    hippo_connection_visit_entity(get_connection(actions), entity);
+    const char *home_url = hippo_entity_get_home_url(entity);
+    hippo_actions_open_url(actions, home_url);
 }
 
 static void
@@ -214,19 +228,13 @@
                                  const char      *image_url,
                                  HippoCanvasItem *image_item)
 {
-    char *absolute;
-    
     if (actions->favicon_cache == NULL) {
         actions->favicon_cache = hippo_image_cache_new(get_platform(actions));
     }
 
     /* hippo_object_cache_debug_dump(HIPPO_OBJECT_CACHE(actions->favicon_cache)); */
     
-    absolute = hippo_connection_make_absolute_url(get_connection(actions),
-                                                  image_url);
-    load_image_url_async(actions, actions->favicon_cache, absolute, image_item);
-    
-    g_free(absolute);
+    load_image_url_async(actions, actions->favicon_cache, image_url, image_item);
 }
 
 void
@@ -234,19 +242,13 @@
                                    const char      *image_url,
                                    HippoCanvasItem *image_item)
 {
-    char *absolute;
-    
     if (actions->thumbnail_cache == NULL) {
         actions->thumbnail_cache = hippo_image_cache_new(get_platform(actions));
     }
 
     /* hippo_object_cache_debug_dump(HIPPO_OBJECT_CACHE(actions->thumbnail_cache)); */
     
-    absolute = hippo_connection_make_absolute_url(get_connection(actions),
-                                                  image_url);
-    load_image_url_async(actions, actions->thumbnail_cache, absolute, image_item);
-    
-    g_free(absolute);
+    load_image_url_async(actions, actions->thumbnail_cache, image_url, image_item);
 }
 
 void
@@ -254,19 +256,13 @@
                                          const char      *image_url,
                                          HippoCanvasItem *image_item)
 {
-    char *absolute;
-    
     if (actions->music_thumbnail_cache == NULL) {
         actions->music_thumbnail_cache = hippo_image_cache_new(get_platform(actions));
     }
 
     /* hippo_object_cache_debug_dump(HIPPO_OBJECT_CACHE(actions->music_thumbnail_cache)); */
     
-    absolute = hippo_connection_make_absolute_url(get_connection(actions),
-                                                  image_url);
-    load_image_url_async(actions, actions->music_thumbnail_cache, absolute, image_item);
-    
-    g_free(absolute);
+    load_image_url_async(actions, actions->music_thumbnail_cache, image_url, image_item);
 }
 
 void
@@ -277,7 +273,6 @@
 {
     const char *url;
     char *sized;
-    char *absolute;        
     
     url = hippo_entity_get_photo_url(entity);
     
@@ -298,11 +293,8 @@
 
     /* hippo_object_cache_debug_dump(HIPPO_OBJECT_CACHE(actions->entity_photo_cache)); */
     
-    absolute = hippo_connection_make_absolute_url(get_connection(actions),
-                                                  sized);
-    load_image_url_async(actions, actions->entity_photo_cache, absolute, image_item);
+    load_image_url_async(actions, actions->entity_photo_cache, sized, image_item);
     
-    g_free(absolute);
     g_free(sized);
 }
 
@@ -358,28 +350,75 @@
 void
 hippo_actions_open_home_page(HippoActions    *actions)
 {
-    hippo_connection_open_maybe_relative_url(get_connection(actions), "/");
+    DDMDataResource *self = ddm_data_model_get_self_resource(get_model(actions));
+    const char *home_url;
+
+    ddm_data_resource_get(self,
+                          "homeUrl", DDM_DATA_URL, &home_url,
+                          NULL);
+
+    if (home_url != NULL)
+        hippo_actions_open_url(actions, home_url);
 }
 
+static void
+on_open_url_error(DDMDataError  error,
+                     const char   *message,
+                     gpointer      data)
+{
+     g_warning("Failed to open URL in browser: %s", message);
+}
+
 void
-hippo_actions_open_url(HippoActions    *actions,
-                                const char      *url)
+hippo_actions_open_url(HippoActions *actions,
+                       const char   *url)
 {
-    hippo_connection_open_maybe_relative_url(get_connection(actions), url);
+    DDMDataQuery *query;
+
+    query = ddm_data_model_update(get_model(actions),
+                                  "online-desktop:/p/system#openUrl",
+                                  "url", url,
+                                  NULL);
+    
+    ddm_data_query_set_error_handler(query, on_open_url_error, actions);
 }
 
+static void
+on_set_block_hushed_error(DDMDataError  error,
+                     const char   *message,
+                     gpointer      data)
+{
+     g_warning("Failed to set block hush state: %s", message);
+}
+
+static void
+set_block_hushed(HippoActions *actions,
+                 HippoBlock   *block,
+                 gboolean      hushed)
+{
+    DDMDataQuery *query;
+
+    query = ddm_data_model_update(get_model(actions),
+                                  "http://mugshot.org/p/blocks#setBlockHushed";,
+                                  "blockId", hippo_block_get_guid(block),
+                                  "hushed", hushed ? "true" : "false",
+                                  NULL);
+    
+    ddm_data_query_set_error_handler(query, on_set_block_hushed_error, actions);
+}
+
 void
 hippo_actions_hush_block(HippoActions    *actions,
                          HippoBlock      *block)
 {
-    hippo_connection_set_block_hushed(get_connection(actions), hippo_block_get_guid(block), TRUE);
+    set_block_hushed(actions, block, TRUE);
 }
 
 void
 hippo_actions_unhush_block(HippoActions    *actions,
                            HippoBlock      *block)
 {
-    hippo_connection_set_block_hushed(get_connection(actions), hippo_block_get_guid(block), FALSE);
+    set_block_hushed(actions, block, FALSE);
 }
 
 void
@@ -396,14 +435,28 @@
     hippo_platform_show_chat_window(get_platform(actions), chat_id);
 }
 
+static void
+on_invite_user_error(DDMDataError  error,
+                     const char   *message,
+                     gpointer      data)
+{
+     g_warning("Failed to invite user to group: %s", message);
+}
+
 void
 hippo_actions_invite_to_group(HippoActions    *actions,
                               HippoGroup      *group,
                               HippoPerson     *person)
 {
-    hippo_connection_do_invite_to_group(get_connection(actions),
-                                        hippo_entity_get_guid(HIPPO_ENTITY(group)),
-                                        hippo_entity_get_guid(HIPPO_ENTITY(person)));
+    DDMDataQuery *query;
+
+    query = ddm_data_model_update(get_model(actions),
+                                  "http://mugshot.org/p/blocks#accountQuestionResponse";,
+                                  "groupId", hippo_entity_get_guid(HIPPO_ENTITY(group)),
+                                  "userId", hippo_entity_get_guid(HIPPO_ENTITY(person)),
+                                  NULL);
+    
+    ddm_data_query_set_error_handler(query, on_invite_user_error, actions);
 }
 
 gboolean
@@ -430,11 +483,26 @@
     g_object_unref(quip_window);
 }
 
+static void
+on_account_question_response_error(DDMDataError  error,
+                     const char   *message,
+                     gpointer      data)
+{
+     g_warning("Failed to set account question response: %s", message);
+}
+
 void 
 hippo_actions_send_account_question_response(HippoActions *actions,
                                              const char   *block_id,
                                              const char   *response)
 {
-    hippo_connection_send_account_question_response(get_connection(actions),
-                                                    block_id, response);
+    DDMDataQuery *query;
+
+    query = ddm_data_model_update(get_model(actions),
+                                  "http://mugshot.org/p/blocks#accountQuestionResponse";,
+                                  "blockId", block_id,
+                                  "response", response,
+                                  NULL);
+    
+    ddm_data_query_set_error_handler(query, on_account_question_response_error, actions);
 }

Modified: dumbhippo/trunk/client/common/hippo/hippo-connection.c
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-connection.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-connection.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -275,8 +275,6 @@
     char *download_url;
     char *tooltip;
     char *active_block_filter;
-    int request_blocks_id;
-    gint64 last_blocks_timestamp;
     gint64 server_time_offset;
     unsigned int too_old : 1;
     unsigned int upgrade_available : 1;
@@ -646,10 +644,29 @@
         
         const char *self_guid = hippo_connection_get_self_guid(connection);
 
-        /* The resource ID does not change according to which server we connect to,
-         * it is always mugshot.org
+        /* There isn't any notification when hippo_platform_get_web_server() changes
+         * but that won't happen in normal operation; right now the only time that
+         * it happens is when adjusting the web server in the hidden properties
+         * dialog on the windows client.
          */
-        connection->self_resource_id = g_strdup_printf("http://mugshot.org/o/user/%s";, self_guid);
+        const char *raw_server = hippo_platform_get_web_server(connection->platform,
+                                                               HIPPO_SERVER_STACKER);
+        char *server;
+
+        /* Somewhat hacky: we need to match the server's own idea of what it's
+         * URL is; we've added on :80 elsewhere to "canonicalize" the URL, and
+         * strip it out again here. We might be better off having the server
+         * send it's resource base (or the user's "self ID") in the initial
+         * handshake.
+         */
+        if (g_str_has_suffix(raw_server, ":80"))
+            server = g_strndup(raw_server, strlen(raw_server) - 3);
+        else
+            server = g_strdup(raw_server);
+        
+        connection->self_resource_id = g_strdup_printf("http://%s/o/user/%s";, server, self_guid);
+
+        g_free(server);
     }
 
     return connection->self_resource_id;
@@ -737,32 +754,6 @@
     }
 }
 
-void
-hippo_connection_do_invite_to_group (HippoConnection  *connection,
-                                     const char       *group_id,
-                                     const char       *person_id)
-{
-    LmMessage *message;
-    LmMessageNode *node;
-    LmMessageNode *method;
-            
-    g_return_if_fail(HIPPO_IS_CONNECTION(connection));
-    
-    message = lm_message_new_with_sub_type(HIPPO_ADMIN_JID, LM_MESSAGE_TYPE_IQ,
-                                           LM_MESSAGE_SUB_TYPE_SET);
-    node = lm_message_get_node(message);
-
-    method = lm_message_node_add_child (node, "groupSystem", NULL);
-    lm_message_node_set_attribute(method, "xmlns", "http://dumbhippo.com/protocol/groupSystem";);
-    lm_message_node_set_attribute(method, "op", "addMember");
-    lm_message_node_set_attribute(method, "groupId", group_id);
-    lm_message_node_set_attribute(method, "userId", person_id);    
- 
-    hippo_connection_send_message(connection, message, SEND_MODE_AFTER_AUTH);
-
-    lm_message_unref(message);
-}
-
 static void
 do_notify_music_changed(HippoConnection *connection,
                         gboolean         currently_playing,
@@ -1809,200 +1800,15 @@
     return connection->server_time_offset;
 }
 
+#if 0
 static void
 hippo_connection_update_server_time_offset(HippoConnection *connection,
                                            gint64           server_time)
 {
     connection->server_time_offset = server_time - hippo_current_time_ms();
 }
+#endif
  
-static void
-hippo_connection_update_filter(HippoConnection *connection,
-                               const char      *filter)
-{
-    g_free(connection->active_block_filter);
-    connection->active_block_filter = g_strdup(filter);
-    g_signal_emit(connection, signals[BLOCK_FILTER_CHANGED], 0, connection->active_block_filter);
-}
- 
-static gboolean
-hippo_connection_parse_blocks(HippoConnection *connection,
-                              LmMessageNode   *node)
-{
-    const char *filter = NULL;
-    gint64 server_timestamp;
-
-    /* g_debug("Parsing blocks list <%s>", node->name); */
-    
-    if (!hippo_xml_split(connection->cache, node, NULL,
-                         "filter", HIPPO_SPLIT_STRING | HIPPO_SPLIT_OPTIONAL, &filter,
-                         "serverTime", HIPPO_SPLIT_TIME_MS, &server_timestamp,
-                         NULL)) {
-        g_debug("missing serverTime on blocks");
-        return FALSE;
-    }
-
-    hippo_connection_update_server_time_offset(connection, server_timestamp);
-    if (filter)
-        hippo_connection_update_filter(connection, filter);
-    
-#if 0    
-    LmMessageNode *subchild;
-    
-    for (subchild = node->children; subchild; subchild = subchild->next) {
-        if (!hippo_data_cache_update_from_xml(connection->cache, subchild)) {
-            g_debug("Did not successfully update <%s> from xml", subchild->name);
-        } else {
-            /* g_debug("Updated <%s>", subchild->name) */ ;
-        }
-    }
-
-    /* g_debug("Done parsing blocks list <%s>", node->name); */
-#endif    
-    
-    return TRUE;
-}
-
-static LmHandlerResult
-on_request_blocks_reply(LmMessageHandler *handler,
-                        LmConnection     *lconnection,
-                        LmMessage        *message,
-                        gpointer          data)
-{
-    HippoConnection *connection = HIPPO_CONNECTION(data);
-    LmMessageNode *child;
-
-    child = message->node->children;
-
-    g_debug("got reply for blocks");
-
-    if (!message_is_iq_with_namespace(message, "http://dumbhippo.com/protocol/blocks";, "blocks")) {
-        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-    }
-
-    if (!hippo_connection_parse_blocks(connection, child))
-        g_warning("Failed to parse <blocks>");
-    
-    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-}
-
-void
-hippo_connection_request_blocks(HippoConnection *connection,
-                                gint64           last_timestamp,
-                                const char      *filter)
-{
-    LmMessage *message;
-    LmMessageNode *node;
-    LmMessageNode *child;
-    char *s;
-    
-    message = lm_message_new_with_sub_type(HIPPO_ADMIN_JID, LM_MESSAGE_TYPE_IQ,
-                                           LM_MESSAGE_SUB_TYPE_GET);
-    node = lm_message_get_node(message);
-    
-    child = lm_message_node_add_child (node, "blocks", NULL);
-    lm_message_node_set_attribute(child, "xmlns", "http://dumbhippo.com/protocol/blocks";);
-    s = g_strdup_printf("%" G_GINT64_FORMAT, last_timestamp);
-    lm_message_node_set_attribute(child, "lastTimestamp", s);
-    g_free(s);
-    if (filter) {
-        lm_message_node_set_attribute(child, "filter", filter);
-    }
-    if (filter != connection->active_block_filter) {
-        g_free(connection->active_block_filter);
-        connection->active_block_filter = g_strdup(filter);
-    }
-    
-    hippo_connection_send_message_with_reply(connection, message,
-                                             on_request_blocks_reply, SEND_MODE_AFTER_AUTH);
-
-    lm_message_unref(message);
-
-    g_debug("Sent request for blocks lastTimestamp %" G_GINT64_FORMAT, last_timestamp);
-}
-
-static LmHandlerResult
-on_block_hushed_reply(LmMessageHandler *handler,
-                      LmConnection     *lconnection,
-                      LmMessage        *message,
-                      gpointer          data)
-{
-    HippoConnection *connection = HIPPO_CONNECTION(data);
-    LmMessageNode *child;
-
-    child = message->node->children;
-
-    g_debug("got reply for <blockHushed/>");
-
-    if (!message_is_iq_with_namespace(message, "http://dumbhippo.com/protocol/blocks";, "blockHushed")) {
-        g_warning("Got unexpected reply for <blockHushed/>");
-        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-    }
-
-    if (!hippo_connection_parse_blocks(connection, child))
-        g_warning("Failed to parse <blockHushed/>");
-    
-    return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-}
-
-void
-hippo_connection_set_block_hushed(HippoConnection *connection,
-                                  const char      *block_id,
-                                  gboolean         hushed)
-{
-    LmMessage *message;
-    LmMessageNode *node;
-    LmMessageNode *child;
-    
-    message = lm_message_new_with_sub_type(HIPPO_ADMIN_JID, LM_MESSAGE_TYPE_IQ,
-                                           LM_MESSAGE_SUB_TYPE_SET);
-    node = lm_message_get_node(message);
-    
-    child = lm_message_node_add_child (node, "blockHushed", NULL);
-    lm_message_node_set_attribute(child, "xmlns", "http://dumbhippo.com/protocol/blocks";);
-    lm_message_node_set_attribute(child, "blockId", block_id);
-    lm_message_node_set_attribute(child, "hushed", hushed ? "true" : "false");
-
-    hippo_connection_send_message_with_reply(connection, message, on_block_hushed_reply, SEND_MODE_AFTER_AUTH);
-
-    lm_message_unref(message);
-
-    g_debug("Sent blockHushed=%d", hushed);
-}
-
-void
-hippo_connection_send_account_question_response(HippoConnection *connection,
-                                                const char      *block_id,
-                                                const char      *response)
-{
-    LmMessage *message;
-    LmMessageNode *node;
-    LmMessageNode *child;
-    
-    message = lm_message_new_with_sub_type(HIPPO_ADMIN_JID, LM_MESSAGE_TYPE_IQ,
-                                           LM_MESSAGE_SUB_TYPE_SET);
-    node = lm_message_get_node(message);
-    
-    child = lm_message_node_add_child (node, "response", NULL);
-    lm_message_node_set_attribute(child, "xmlns", "http://dumbhippo.com/protocol/accountQuestion";);
-    lm_message_node_set_attribute(child, "blockId", block_id);
-    lm_message_node_set_attribute(child, "response", response);
-
-    hippo_connection_send_message(connection, message, SEND_MODE_AFTER_AUTH);
-
-    lm_message_unref(message);
-}
-
-void
-hippo_connection_update_last_blocks_timestamp (HippoConnection *connection,
-                                               gint64           timestamp)
-{
-    if (timestamp >= connection->last_blocks_timestamp) {
-        g_debug("Have new latest block timestamp %" G_GINT64_FORMAT, timestamp);
-        connection->last_blocks_timestamp = timestamp;
-    }
-}
-
 static void 
 send_room_presence(HippoConnection *connection,
                    HippoChatRoom   *room,
@@ -2735,39 +2541,6 @@
 }
 
 static gboolean
-handle_blocks_changed(HippoConnection *connection,
-                      LmMessage       *message)
-{
-#if 0    
-    LmMessageNode *child;
-    gint64 last_timestamp;
-    
-    if (lm_message_get_sub_type(message) != LM_MESSAGE_SUB_TYPE_HEADLINE)
-        return FALSE;
-
-    child = find_child_node(message->node, "http://dumbhippo.com/protocol/blocks";, "blocksChanged");
-    if (child == NULL)
-        return FALSE;
-
-    if (!hippo_xml_split(connection->cache, child, NULL,
-                         "lastTimestamp", HIPPO_SPLIT_TIME_MS, &last_timestamp,
-                         NULL))
-        return TRUE;
-    
-    g_debug("handling blocksChanged message timestamp %" G_GINT64_FORMAT " our latest timestamp %" G_GINT64_FORMAT,
-            last_timestamp, connection->last_blocks_timestamp);
-
-    /* last_timestamp of -1 means the server has lost track of what the latest timestamp
-     * is, but something has potentially changed
-     */
-    if (last_timestamp < 0 || last_timestamp > connection->last_blocks_timestamp)
-        hippo_connection_queue_request_blocks(connection);
-#endif
-    
-    return TRUE;
-}
-
-static gboolean
 handle_prefs_changed(HippoConnection *connection,
                      LmMessage       *message)
 {
@@ -2853,10 +2626,6 @@
         return LM_HANDLER_RESULT_REMOVE_MESSAGE;
     }
     
-    if (handle_blocks_changed(connection, message)) {
-        return LM_HANDLER_RESULT_REMOVE_MESSAGE;
-    }
-    
     if (handle_prefs_changed(connection, message)) {
         return LM_HANDLER_RESULT_REMOVE_MESSAGE;
     }

Modified: dumbhippo/trunk/client/common/hippo/hippo-connection.h
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-connection.h	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-connection.h	2008-01-10 23:28:48 UTC (rev 7185)
@@ -67,9 +67,6 @@
 /* TRUE if user needs to log in (we think we have no login cookie) */
 gboolean         hippo_connection_get_need_login            (HippoConnection  *connection);
 
-void             hippo_connection_do_invite_to_group        (HippoConnection  *connection,
-                                                             const char       *group_id,
-                                                             const char       *person_id);                                                             
 void             hippo_connection_notify_music_changed      (HippoConnection  *connection,
                                                              gboolean          currently_playing,
                                                              const HippoSong  *song);
@@ -106,18 +103,9 @@
                                                              HippoSentiment   sentiment);
 
 void     hippo_connection_request_prefs             (HippoConnection *connection);
-void     hippo_connection_request_hotness           (HippoConnection *connection);
-void     hippo_connection_request_blocks            (HippoConnection *connection,
-                                                     gint64           last_timestamp,
-                                                     const char      *filter);
-
 void     hippo_connection_request_title_patterns    (HippoConnection *connection);
 
 
-void     hippo_connection_set_block_hushed          (HippoConnection *connection,
-                                                     const char      *block_id,
-                                                     gboolean         hushed);
-
 /* Sends a list of applications active over the last collection_period seconds
  * to the server for use in social application browsing; the applications can
  * be identified either by application ID (we'd get this from a title match)
@@ -128,19 +116,12 @@
                                                      GSList          *appids,
                                                      GSList          *wm_classes);
 
-void hippo_connection_send_account_question_response(HippoConnection *connection,
-                                                     const char      *block_id,
-                                                     const char      *response);
-
 void hippo_connection_send_query (HippoConnection *connection,
                                   DDMDataQuery    *query);
 
 /* Gets the number of milliseconds to add to the local time to get the server time */
 gint64   hippo_connection_get_server_time_offset    (HippoConnection *connection);
 
-void     hippo_connection_update_last_blocks_timestamp (HippoConnection *connection,
-                                                        gint64           timestamp);
-
 const char*      hippo_connection_get_tooltip       (HippoConnection *connection);
 
 /* return string form of enum values */

Modified: dumbhippo/trunk/client/common/hippo/hippo-data-model-backend.c
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-data-model-backend.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-data-model-backend.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -262,9 +262,6 @@
 
     connection = hippo_data_cache_get_connection(cache);
 
-    ddm_data_model_set_connected(hippo_model->ddm_model,
-                                 hippo_connection_get_connected(connection));
-    
     g_signal_connect(connection, "connected-changed",
                      G_CALLBACK(on_connection_connected_changed), hippo_model);
     
@@ -346,22 +343,39 @@
 }
 
 static gboolean
-do_offline_update_error(gpointer data)
+handle_local_update (HippoDataCache *cache,
+                     DDMDataQuery   *query)
 {
-    DDMDataQuery *query = data;
+    DDMQName *qname = ddm_data_query_get_qname(query);
+    if (!g_str_has_prefix(qname->uri, "online-desktop:"))
+        return FALSE;
 
-    ddm_data_query_error(query,
-                         DDM_DATA_ERROR_NO_CONNECTION,
-                         "Not connected to server");
+    if (strcmp(qname->uri, "online-desktop:/p/system") == 0) {
+        GHashTable *params = ddm_data_query_get_params(query);
+        HippoConnection *connection = hippo_data_cache_get_connection(cache);
+        
+        if (strcmp(qname->name, "openUrl") == 0) {
+            const char *url = g_hash_table_lookup(params, "url");
+            if (url == NULL) {
+                ddm_data_query_error_async(query,
+                                           DDM_DATA_ERROR_BAD_REQUEST,
+                                           "'url' parameter missing for openUrl request");
+                return TRUE;
+            }
 
-    return FALSE;
-}
+            hippo_connection_open_maybe_relative_url(connection, url);
 
-static void
-queue_offline_update_error(DDMDataModel *ddm_model,
-                           DDMDataQuery *query)
-{
-    g_idle_add(do_offline_update_error, query);
+            /* FIXME: signal success */
+            
+            return TRUE;
+        }
+    }
+
+    ddm_data_query_error_async(query,
+                               DDM_DATA_ERROR_BAD_REQUEST,
+                               "Unknown local data model update");
+
+    return TRUE;
 }
 
 static void
@@ -376,12 +390,17 @@
     hippo_model = get_hippo_model(ddm_model);    
 
     cache = HIPPO_DATA_CACHE(backend_data);
+
+    if (handle_local_update(cache, query))
+        return;
+    
     connection = hippo_data_cache_get_connection(cache);
-    
     if (hippo_connection_get_connected(connection))
         hippo_connection_send_query(connection, query);
     else
-        queue_offline_update_error(ddm_model, query);
+        ddm_data_query_error_async(query,
+                                   DDM_DATA_ERROR_NO_CONNECTION,
+                                   "Not connected to server");
 }
 
 static const DDMDataModelBackend hippo_backend = {

Modified: dumbhippo/trunk/client/common/hippo/hippo-entity.c
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-entity.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-entity.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -182,6 +182,14 @@
     return entity;
 }
 
+DDMDataResource *
+hippo_entity_get_resource(HippoEntity *entity)
+{
+    g_return_val_if_fail(HIPPO_IS_ENTITY(entity), NULL);
+
+    return entity->resource;
+}
+
 static void
 hippo_entity_update(HippoEntity *entity)
 {
@@ -259,13 +267,3 @@
     /* g_debug("Setting photo for '%s' to '%s'", entity->guid, url ? url : "null"); */
     hippo_entity_set_string(entity, &entity->photo_url, url);
 }
-
-void
-hippo_entity_set_in_network(HippoEntity    *entity,
-                            gboolean        in_network)
-{
-    g_return_if_fail(HIPPO_IS_ENTITY(entity));
-
-    entity->in_network = in_network != FALSE;
-    hippo_entity_notify(entity);
-}

Modified: dumbhippo/trunk/client/common/hippo/hippo-entity.h
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-entity.h	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-entity.h	2008-01-10 23:28:48 UTC (rev 7185)
@@ -26,12 +26,12 @@
 
 GType            hippo_entity_get_type            (void) G_GNUC_CONST;
 
+DDMDataResource *hippo_entity_get_resource        (HippoEntity    *entity);
 const char*      hippo_entity_get_guid            (HippoEntity    *entity);
 HippoEntityType  hippo_entity_get_entity_type     (HippoEntity    *entity);
 const char*      hippo_entity_get_name            (HippoEntity    *entity);
 const char*      hippo_entity_get_home_url        (HippoEntity    *entity);
 const char*      hippo_entity_get_photo_url       (HippoEntity    *entity);
-gboolean         hippo_entity_get_in_network      (HippoEntity    *entity);
 
 void             hippo_entity_set_name            (HippoEntity    *entity,
                                                    const char     *name);
@@ -39,9 +39,8 @@
                                                    const char     *link);
 void             hippo_entity_set_photo_url       (HippoEntity    *entity,
                                                    const char     *url);
-void             hippo_entity_set_in_network      (HippoEntity    *entity,
-                                                   gboolean        in_network);
 
+
 G_END_DECLS
 
 #endif /* __HIPPO_ENTITY_H__ */

Modified: dumbhippo/trunk/client/common/hippo/hippo-stack-manager.c
===================================================================
--- dumbhippo/trunk/client/common/hippo/hippo-stack-manager.c	2008-01-10 23:22:48 UTC (rev 7184)
+++ dumbhippo/trunk/client/common/hippo/hippo-stack-manager.c	2008-01-10 23:28:48 UTC (rev 7185)
@@ -1209,7 +1209,7 @@
 {
     g_return_if_fail(manager != NULL);
     
-    if (!ddm_data_model_get_connected(manager->model)) {
+    if (!ddm_data_model_is_online(manager->model)) {
         return;
     }
 
@@ -1221,7 +1221,7 @@
 {
     g_return_if_fail(manager != NULL);
     
-    if (!ddm_data_model_get_connected(manager->model)) {
+    if (!ddm_data_model_is_online(manager->model)) {
         g_debug("ignoring filter toggle due to current disconnection state");
         return;
     }
@@ -1234,7 +1234,7 @@
 {
     g_return_if_fail(manager != NULL);
     
-    if (!ddm_data_model_get_connected(manager->model)) {
+    if (!ddm_data_model_is_online(manager->model)) {
         g_debug("ignoring nofeed toggle due to current disconnection state");        
         return;
     }
@@ -1247,7 +1247,7 @@
 {
     g_return_if_fail(manager != NULL);
 
-    if (!ddm_data_model_get_connected(manager->model)) {
+    if (!ddm_data_model_is_online(manager->model)) {
         g_debug("ignoring noselfsource toggle due to current disconnection state");        
         return;
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]