Пример #1
0
static void
hippo_add_model    (DDMDataModel *ddm_model,
                    void         *backend_data)
{
    HippoDataCache *cache = HIPPO_DATA_CACHE(backend_data);
    HippoConnection *connection;
    HippoModel *hippo_model;

    g_assert(get_hippo_model(ddm_model) == NULL);
    
    hippo_model = g_new0(HippoModel, 1);
    hippo_model->ddm_model = ddm_model;
    hippo_model->data_cache = cache;
    
    g_object_set_data(G_OBJECT(ddm_model), "hippo-data-model", hippo_model);

    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);
    
    g_signal_connect(connection, "has-auth-changed",
                     G_CALLBACK(on_connection_has_auth_changed), hippo_model);
    
    g_signal_connect(connection, "state-changed",
                     G_CALLBACK(on_connection_state_changed), hippo_model);
    
    open_disk_cache(hippo_model);
}
Пример #2
0
static HippoSettings*
get_and_ref_settings(DBusConnection *dbus_connection)
{
    HippoDataCache *cache;
    HippoConnection *connection;
    HippoSettings *settings;
    
    cache = hippo_app_get_data_cache(hippo_get_app());
    connection = hippo_data_cache_get_connection(cache);

    settings = hippo_settings_get_and_ref(connection);

    if (!g_object_get_data(G_OBJECT(settings), "dbus-connected")) {
        g_debug("connecting to ready-changed on HippoSettings");
        g_object_set_data(G_OBJECT(settings), "dbus-connected", GINT_TO_POINTER(TRUE));

        /* these refs are never dropped at the moment but in practice the dbus connection
         * should never be disconnected so it's fine */
        
        dbus_connection_ref(dbus_connection);
        g_signal_connect_data(G_OBJECT(settings), "ready-changed", G_CALLBACK(on_ready_changed),
                              dbus_connection, (GClosureNotify) dbus_connection_unref, 0);
        dbus_connection_ref(dbus_connection);
        g_signal_connect_data(G_OBJECT(settings), "setting-changed", G_CALLBACK(on_setting_changed),
                              dbus_connection, (GClosureNotify) dbus_connection_unref, 0);        
    }
    
    return settings;
}
Пример #3
0
static void
hippo_status_icon_activate(GtkStatusIcon *gtk_icon)
{
    HippoStatusIcon *icon = HIPPO_STATUS_ICON(gtk_icon);
    GdkEvent *event;
    guint button;
    guint32 time;
    
    event = gtk_get_current_event();
    if (event != NULL && event->type == GDK_BUTTON_PRESS)
        button = event->button.button;
    else
        button = 1;

    if (button == 1) {
        HippoConnection *connection;

        connection = hippo_data_cache_get_connection(icon->cache);
        if (!hippo_connection_get_connected(connection)) {
            HippoPlatform *platform;
            platform = hippo_connection_get_platform(connection);
            hippo_platform_show_disconnected_window(platform, connection);
        } else {
            /* the UI has to exist since we (the tray icon) are part of it */
            hippo_stack_manager_show_browser(hippo_stack_manager_get(icon->cache), TRUE);
        }
    } else if (button == 3) {
        time = gtk_get_current_event_time();
    
        hippo_status_icon_popup_menu(gtk_icon, button, time);
    }
}
Пример #4
0
HippoUI*
hippo_ui_new(HippoDataCache *cache,
             HippoDBus      *dbus)
{
    HippoUI *ui;

    hippo_canvas_set_load_image_hook(canvas_load_image_hook);
    
    ui = g_new0(HippoUI, 1);

    ui->cache = cache;
    g_object_ref(ui->cache);

    ui->connection = hippo_data_cache_get_connection(ui->cache);
    ui->platform = hippo_connection_get_platform(ui->connection);

    ui->dbus = dbus;
    g_object_ref(ui->dbus);
    
    ui->photo_cache = hippo_pixbuf_cache_new(ui->platform);
    
    hippo_stack_manager_manage(ui->cache);
    
    ui->icon = hippo_status_icon_new(ui->cache);

    g_signal_connect(G_OBJECT(ui->icon),
                     "size-changed",
                     G_CALLBACK(on_icon_size_changed),
                     ui);
    
    return ui;
}
HippoListenerProxyImpl::HippoListenerProxyImpl(HippoDataCache *dataCache, IHippoUIListener *listener)
{
    id_ = ++lastId_;
    dataCache_ = dataCache;
    listener_ = listener;

    connectedChanged_.connect(G_OBJECT(hippo_data_cache_get_connection(dataCache_)), "connected-changed", 
                              slot(this, &HippoListenerProxyImpl::onConnectedChanged));
}
Пример #6
0
STDMETHODIMP 
HippoChatRoomWrapper::Join(BOOL participant)
{
    hippoDebugLogW(L"HippoChatRoomWrapper::Join participant = %d", participant);

    hippo_connection_join_chat_room(hippo_data_cache_get_connection(cache_), delegate_,
        participant ? HIPPO_CHAT_STATE_PARTICIPANT : HIPPO_CHAT_STATE_VISITOR);

    return S_OK;
}
Пример #7
0
static void
on_toggle_connected_activated()
{
    HippoDataCache *cache = hippo_app_get_data_cache(hippo_get_app());
    HippoConnection *connection = hippo_data_cache_get_connection(cache);

    if (hippo_connection_get_connected(connection))
        hippo_connection_signout(connection);
    else
        hippo_connection_signin(connection);
}
Пример #8
0
HRESULT
HippoChatRoomWrapper::SendMessage(BSTR text)
{
    HippoConnection *connection = hippo_data_cache_get_connection(cache_);

    HippoUStr textU(text);

    hippo_connection_send_chat_room_message(connection, delegate_, textU.c_str());

    return S_OK;
}
Пример #9
0
static void
hippo_status_icon_finalize(GObject *object)
{
    HippoStatusIcon *icon = HIPPO_STATUS_ICON(object);

    g_signal_handlers_disconnect_by_func(hippo_data_cache_get_connection(icon->cache),
                                         G_CALLBACK(on_state_changed), icon);

    destroy_menu(icon);
    
    g_object_unref(icon->cache);
    
    G_OBJECT_CLASS(hippo_status_icon_parent_class)->finalize(object);
}
Пример #10
0
static void
hippo_send_update (DDMDataModel *ddm_model,
                   DDMDataQuery *query,
                   void         *backend_data)
{
    HippoDataCache *cache;
    HippoConnection *connection;    
    HippoModel *hippo_model;
    
    hippo_model = get_hippo_model(ddm_model);    

    cache = HIPPO_DATA_CACHE(backend_data);
    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);
}
Пример #11
0
static dbus_bool_t
handle_get_server(void            *object,
                  const char      *prop_name,
                  DBusMessageIter *append_iter,
                  DBusError       *error)
{
    char *server;
    HippoDataCache *cache = hippo_app_get_data_cache(hippo_get_app());
    HippoConnection *hippo_connection = hippo_data_cache_get_connection(cache);
    HippoPlatform *platform = hippo_connection_get_platform(hippo_connection);

    /* DESKTOP hardcoded here since this is the data model API, nothing to do with stacker */    
    server = hippo_platform_get_web_server(platform,
                                           HIPPO_SERVER_DESKTOP);
    
    dbus_message_iter_append_basic(append_iter, DBUS_TYPE_STRING, &server);
    
    g_free(server);
    
    return TRUE;
}
Пример #12
0
HippoStatusIcon*
hippo_status_icon_new(HippoDataCache *cache)
{
    HippoConnection *connection = hippo_data_cache_get_connection(cache);
    HippoStatusIcon *icon;
    
    icon = g_object_new(HIPPO_TYPE_STATUS_ICON,
                        "icon-name", get_icon_name(connection),
                        NULL);
    
    icon->cache = cache;
    g_object_ref(icon->cache);

    g_signal_connect(connection, "state-changed",
                     G_CALLBACK(on_state_changed), icon);

    gtk_status_icon_set_tooltip(GTK_STATUS_ICON(icon),
                                hippo_connection_get_tooltip(connection));

    return HIPPO_STATUS_ICON(icon);
}
Пример #13
0
static HippoConnection*
get_connection(HippoActions *actions)
{
    return hippo_data_cache_get_connection(actions->cache);
}
Пример #14
0
static void
model_set_initial_properties(HippoModel *hippo_model)
{
    HippoConnection *connection = hippo_data_cache_get_connection(hippo_model->data_cache);
    HippoPlatform *platform = hippo_connection_get_platform(connection);
    DDMDataResource *global_resource;
    DDMDataResource *self_resource;
    const char *self_id;
    DDMDataValue value;
    char *web_server;
    char *web_base_url;
    char *fallback_user_photo_url;
    
    global_resource = ddm_data_model_ensure_local_resource(hippo_model->ddm_model,
                                                           DDM_GLOBAL_RESOURCE, DDM_GLOBAL_RESOURCE_CLASS);
    ddm_data_model_set_global_resource(hippo_model->ddm_model, global_resource);
                                       
    self_id = hippo_connection_get_self_resource_id(connection);
    if (self_id) {
        self_resource = ddm_data_model_ensure_resource(hippo_model->ddm_model,
                                                       self_id, "http://mugshot.org/p/o/user");
        value.type = DDM_DATA_RESOURCE;
        value.u.resource = self_resource;
    } else {
        self_resource = NULL;
        value.type = DDM_DATA_NONE;
    }
    
    ddm_data_model_set_self_resource(hippo_model->ddm_model, self_resource);

    ddm_data_resource_update_property(global_resource,
                                      ddm_qname_get(DDM_GLOBAL_RESOURCE_CLASS, "self"),
                                      self_id ? DDM_DATA_UPDATE_REPLACE : DDM_DATA_UPDATE_DELETE,
                                      DDM_DATA_CARDINALITY_01,
                                      FALSE, NULL,
                                      &value);
    
    /* DESKTOP hardcoded here since this is the data model API, nothing to do with stacker */
    web_server = hippo_platform_get_web_server(platform, HIPPO_SERVER_DESKTOP);
    /* Note, no trailing '/', don't add one here because relative urls are given
     * starting with '/' and so you want to be able to do baseurl + relativeurl
     */
    web_base_url = g_strdup_printf("http://%s", web_server);

    fallback_user_photo_url = g_strdup_printf("%s/images2/user_pix1/nophoto.png", web_base_url);
    
    value.type = DDM_DATA_STRING;
    value.u.string = web_base_url;

    ddm_data_resource_update_property(global_resource,
                                      ddm_qname_get(DDM_GLOBAL_RESOURCE_CLASS, "webBaseUrl"),
                                      DDM_DATA_UPDATE_REPLACE,
                                      DDM_DATA_CARDINALITY_1,
                                      FALSE, NULL,
                                      &value);

    /* This should eventually come from the server, but right now the server has no
     * global object so it would be a pain; putting a hack here to create the property
     * seems cleaner than hardcoding the no photo url all over BigBoard etc.
     */
    value.type = DDM_DATA_URL;
    value.u.string = fallback_user_photo_url;

    ddm_data_resource_update_property(global_resource,
                                      ddm_qname_get(DDM_GLOBAL_RESOURCE_CLASS, "fallbackUserPhotoUrl"),
                                      DDM_DATA_UPDATE_REPLACE,
                                      DDM_DATA_CARDINALITY_1,
                                      FALSE, NULL,
                                      &value);

    g_free(fallback_user_photo_url);
    g_free(web_server);
    g_free(web_base_url);

    value.type = DDM_DATA_BOOLEAN;
    value.u.boolean = hippo_connection_get_connected(connection);

    ddm_data_resource_update_property(global_resource,
                                      ddm_qname_get(DDM_GLOBAL_RESOURCE_CLASS, "online"),
                                      DDM_DATA_UPDATE_REPLACE,
                                      DDM_DATA_CARDINALITY_1,
                                      FALSE, NULL,
                                      &value);
    
    value.type = DDM_DATA_STRING;
    value.u.string = hippo_data_cache_get_client_info(hippo_model->data_cache)->ddm_protocol_version;
    if (value.u.string == NULL)
        value.u.string = "0";
    
    ddm_data_resource_update_property(global_resource,
                                      ddm_qname_get(DDM_GLOBAL_RESOURCE_CLASS, "ddmProtocolVersion"),
                                      DDM_DATA_UPDATE_REPLACE,
                                      DDM_DATA_CARDINALITY_1,
                                      FALSE, NULL,
                                      &value);    
}
Пример #15
0
static HippoConnection*
get_connection(HippoQuipWindow *quip_window)
{
    return hippo_data_cache_get_connection(quip_window->cache);
}