static void handle_account_manager_ready () { TpConnectionPresenceType presence; presence = empathy_account_manager_get_global_presence (acc_manager, NULL, NULL); if (presence < TP_CONNECTION_PRESENCE_TYPE_AVAILABLE) return; }
static void account_manager_ready_cb (EmpathyAccountManager *account_manager, GParamSpec *pspec, EmpathyIdle *idle) { EmpathyIdlePriv *priv; TpConnectionPresenceType state; gchar *status, *status_message; priv = GET_PRIV (idle); state = empathy_account_manager_get_global_presence (priv->manager, &status, &status_message); idle_presence_changed_cb (account_manager, state, status, status_message, idle); g_free (status); g_free (status_message); }
static void empathy_idle_init (EmpathyIdle *idle) { EmpathyIdlePriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (idle, EMPATHY_TYPE_IDLE, EmpathyIdlePriv); idle->priv = priv; priv->is_idle = FALSE; priv->manager = empathy_account_manager_dup_singleton (); if (empathy_account_manager_is_ready (priv->manager)) { priv->state = empathy_account_manager_get_global_presence (priv->manager, NULL, &priv->status); } else { g_signal_connect (priv->manager, "notify::ready", G_CALLBACK (account_manager_ready_cb), idle); } g_signal_connect (priv->manager, "global-presence-changed", G_CALLBACK (idle_presence_changed_cb), idle); priv->gs_proxy = dbus_g_proxy_new_for_name (tp_get_bus (), "org.gnome.SessionManager", "/org/gnome/SessionManager/Presence", "org.gnome.SessionManager.Presence"); if (priv->gs_proxy) { dbus_g_proxy_add_signal (priv->gs_proxy, "StatusChanged", G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal (priv->gs_proxy, "StatusChanged", G_CALLBACK (idle_session_status_changed_cb), idle, NULL); } else { DEBUG ("Failed to get gs proxy"); } priv->connectivity = empathy_connectivity_dup_singleton (); priv->state_change_signal_id = g_signal_connect (priv->connectivity, "state-change", G_CALLBACK (idle_state_change_cb), idle); }