aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-08-14 15:54:12 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-08-14 15:54:12 +0800
commitf35b1f02dae7791398b33fac0fe9088333fbd5d4 (patch)
treec31b50f542bfbea4611e7654d793d2c6e99c64eb /libempathy
parent5ba4bd76f4756f84f04faa318674b13f265331f8 (diff)
downloadgsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar.gz
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar.bz2
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar.lz
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar.xz
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.tar.zst
gsoc2013-empathy-f35b1f02dae7791398b33fac0fe9088333fbd5d4.zip
Reorder functions to not have to declare them in the beginning of the file
svn path=/trunk/; revision=1331
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-idle.c541
1 files changed, 259 insertions, 282 deletions
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index ce22b93a9..700c35210 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -68,29 +68,6 @@ typedef enum {
NM_STATE_DISCONNECTED
} NMState;
-static void idle_finalize (GObject *object);
-static void idle_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec);
-static void idle_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec);
-static void idle_presence_changed_cb (MissionControl *mc,
- McPresence state,
- gchar *status,
- EmpathyIdle *idle);
-static void idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
- gboolean is_idle,
- EmpathyIdle *idle);
-static void idle_nm_state_change_cb (DBusGProxy *proxy,
- guint state,
- EmpathyIdle *idle);
-static void idle_ext_away_start (EmpathyIdle *idle);
-static void idle_ext_away_stop (EmpathyIdle *idle);
-static gboolean idle_ext_away_cb (EmpathyIdle *idle);
-
enum {
PROP_0,
PROP_STATE,
@@ -102,6 +79,265 @@ enum {
G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT)
+static gboolean
+idle_ext_away_cb (EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (idle);
+
+ DEBUG ("Going to extended autoaway");
+ empathy_idle_set_state (idle, MC_PRESENCE_EXTENDED_AWAY);
+ priv->ext_away_timeout = 0;
+
+ return FALSE;
+}
+
+static void
+idle_ext_away_stop (EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (idle);
+
+ if (priv->ext_away_timeout) {
+ g_source_remove (priv->ext_away_timeout);
+ priv->ext_away_timeout = 0;
+ }
+}
+
+static void
+idle_ext_away_start (EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (idle);
+
+ idle_ext_away_stop (idle);
+ priv->ext_away_timeout = g_timeout_add_seconds (EXT_AWAY_TIME,
+ (GSourceFunc) idle_ext_away_cb,
+ idle);
+}
+
+static void
+idle_presence_changed_cb (MissionControl *mc,
+ McPresence state,
+ gchar *status,
+ EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (idle);
+
+ DEBUG ("Presence changed to '%s' (%d)", status, state);
+
+ g_free (priv->status);
+ priv->state = state;
+ priv->status = NULL;
+ if (!G_STR_EMPTY (status)) {
+ priv->status = g_strdup (status);
+ }
+
+ g_object_notify (G_OBJECT (idle), "state");
+ g_object_notify (G_OBJECT (idle), "status");
+}
+
+static void
+idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
+ gboolean is_idle,
+ EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (idle);
+
+ DEBUG ("Session idle state changed, %s -> %s",
+ priv->is_idle ? "yes" : "no",
+ is_idle ? "yes" : "no");
+
+ if (priv->state <= MC_PRESENCE_OFFLINE ||
+ priv->state == MC_PRESENCE_HIDDEN ||
+ !priv->auto_away) {
+ /* We are not online or we don't want to go auto away,
+ * nothing to do here */
+ priv->is_idle = is_idle;
+ return;
+ }
+
+ if (is_idle && !priv->is_idle) {
+ McPresence new_state;
+ /* We are now idle */
+
+ if (priv->state == MC_PRESENCE_AWAY ||
+ priv->state == MC_PRESENCE_EXTENDED_AWAY) {
+ /* User set away manually, when coming back we restore
+ * default presence. */
+ new_state = priv->state;
+ priv->away_saved_state = MC_PRESENCE_AVAILABLE;
+ priv->away_reset_status = TRUE;
+ } else {
+ new_state = MC_PRESENCE_AWAY;
+ priv->away_saved_state = priv->state;
+ priv->away_reset_status = FALSE;
+ }
+
+ DEBUG ("Going to autoaway");
+ empathy_idle_set_state (idle, new_state);
+
+ idle_ext_away_start (idle);
+ } else if (!is_idle && priv->is_idle) {
+ /* We are no more idle, restore state */
+ idle_ext_away_stop (idle);
+
+ DEBUG ("Restoring state to %d, reset status: %s",
+ priv->away_saved_state,
+ priv->away_reset_status ? "Yes" : "No");
+
+ if (priv->nm_connected) {
+ empathy_idle_set_presence (idle,
+ priv->away_saved_state,
+ priv->away_reset_status ? NULL : priv->status);
+ } else {
+ /* We can't restore state now, will do when NM gets
+ * connected. */
+ priv->nm_saved_state = priv->away_saved_state;
+ priv->nm_reset_status = priv->away_reset_status;
+ }
+
+ priv->away_saved_state = MC_PRESENCE_UNSET;
+ priv->away_reset_status = FALSE;
+ }
+
+ priv->is_idle = is_idle;
+}
+
+static void
+idle_nm_state_change_cb (DBusGProxy *proxy,
+ guint state,
+ EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv;
+ gboolean old_nm_connected;
+ gboolean new_nm_connected;
+
+ priv = GET_PRIV (idle);
+
+ DEBUG ("New network state (%d), in use = %s",
+ state, priv->use_nm ? "Yes" : "No");
+
+ if (!priv->use_nm) {
+ return;
+ }
+
+ old_nm_connected = priv->nm_connected;
+ new_nm_connected = !(state == NM_STATE_CONNECTING ||
+ state == NM_STATE_DISCONNECTED);
+ priv->nm_connected = TRUE; /* To be sure _set_state will work */
+
+ if (old_nm_connected && !new_nm_connected) {
+ /* We are no more connected */
+ idle_ext_away_stop (idle);
+
+ priv->nm_saved_state = priv->state;
+ empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);
+ }
+ else if (!old_nm_connected && new_nm_connected) {
+ /* We are now connected */
+ empathy_idle_set_presence (idle,
+ priv->nm_saved_state,
+ priv->nm_reset_status ? NULL : priv->status);
+ priv->nm_saved_state = MC_PRESENCE_UNSET;
+ priv->nm_reset_status = FALSE;
+ }
+
+ priv->nm_connected = new_nm_connected;
+}
+
+static void
+idle_finalize (GObject *object)
+{
+ EmpathyIdlePriv *priv;
+
+ priv = GET_PRIV (object);
+
+ g_free (priv->status);
+ g_object_unref (priv->mc);
+
+ if (priv->gs_proxy) {
+ g_object_unref (priv->gs_proxy);
+ }
+
+ idle_ext_away_stop (EMPATHY_IDLE (object));
+}
+
+static void
+idle_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyIdlePriv *priv;
+ EmpathyIdle *idle;
+
+ priv = GET_PRIV (object);
+ idle = EMPATHY_IDLE (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ g_value_set_enum (value, empathy_idle_get_state (idle));
+ break;
+ case PROP_STATUS:
+ g_value_set_string (value, empathy_idle_get_status (idle));
+ break;
+ case PROP_FLASH_STATE:
+ g_value_set_enum (value, empathy_idle_get_flash_state (idle));
+ break;
+ case PROP_AUTO_AWAY:
+ g_value_set_boolean (value, empathy_idle_get_auto_away (idle));
+ break;
+ case PROP_USE_NM:
+ g_value_set_boolean (value, empathy_idle_get_use_nm (idle));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+static void
+idle_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyIdlePriv *priv;
+ EmpathyIdle *idle;
+
+ priv = GET_PRIV (object);
+ idle = EMPATHY_IDLE (object);
+
+ switch (param_id) {
+ case PROP_STATE:
+ empathy_idle_set_state (idle, g_value_get_enum (value));
+ break;
+ case PROP_STATUS:
+ empathy_idle_set_status (idle, g_value_get_string (value));
+ break;
+ case PROP_FLASH_STATE:
+ empathy_idle_set_flash_state (idle, g_value_get_enum (value));
+ break;
+ case PROP_AUTO_AWAY:
+ empathy_idle_set_auto_away (idle, g_value_get_boolean (value));
+ break;
+ case PROP_USE_NM:
+ empathy_idle_set_use_nm (idle, g_value_get_boolean (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
static void
empathy_idle_class_init (EmpathyIdleClass *klass)
{
@@ -216,91 +452,6 @@ empathy_idle_init (EmpathyIdle *idle)
priv->nm_connected = TRUE;
}
-static void
-idle_finalize (GObject *object)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (object);
-
- g_free (priv->status);
- g_object_unref (priv->mc);
-
- if (priv->gs_proxy) {
- g_object_unref (priv->gs_proxy);
- }
-
- idle_ext_away_stop (EMPATHY_IDLE (object));
-}
-
-static void
-idle_get_property (GObject *object,
- guint param_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIdlePriv *priv;
- EmpathyIdle *idle;
-
- priv = GET_PRIV (object);
- idle = EMPATHY_IDLE (object);
-
- switch (param_id) {
- case PROP_STATE:
- g_value_set_enum (value, empathy_idle_get_state (idle));
- break;
- case PROP_STATUS:
- g_value_set_string (value, empathy_idle_get_status (idle));
- break;
- case PROP_FLASH_STATE:
- g_value_set_enum (value, empathy_idle_get_flash_state (idle));
- break;
- case PROP_AUTO_AWAY:
- g_value_set_boolean (value, empathy_idle_get_auto_away (idle));
- break;
- case PROP_USE_NM:
- g_value_set_boolean (value, empathy_idle_get_use_nm (idle));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
-static void
-idle_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyIdlePriv *priv;
- EmpathyIdle *idle;
-
- priv = GET_PRIV (object);
- idle = EMPATHY_IDLE (object);
-
- switch (param_id) {
- case PROP_STATE:
- empathy_idle_set_state (idle, g_value_get_enum (value));
- break;
- case PROP_STATUS:
- empathy_idle_set_status (idle, g_value_get_string (value));
- break;
- case PROP_FLASH_STATE:
- empathy_idle_set_flash_state (idle, g_value_get_enum (value));
- break;
- case PROP_AUTO_AWAY:
- empathy_idle_set_auto_away (idle, g_value_get_boolean (value));
- break;
- case PROP_USE_NM:
- empathy_idle_set_use_nm (idle, g_value_get_boolean (value));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
EmpathyIdle *
empathy_idle_new (void)
{
@@ -485,177 +636,3 @@ empathy_idle_set_use_nm (EmpathyIdle *idle,
g_object_notify (G_OBJECT (idle), "use-nm");
}
-static void
-idle_presence_changed_cb (MissionControl *mc,
- McPresence state,
- gchar *status,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Presence changed to '%s' (%d)", status, state);
-
- g_free (priv->status);
- priv->state = state;
- priv->status = NULL;
- if (!G_STR_EMPTY (status)) {
- priv->status = g_strdup (status);
- }
-
- g_object_notify (G_OBJECT (idle), "state");
- g_object_notify (G_OBJECT (idle), "status");
-}
-
-static void
-idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
- gboolean is_idle,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Session idle state changed, %s -> %s",
- priv->is_idle ? "yes" : "no",
- is_idle ? "yes" : "no");
-
- if (priv->state <= MC_PRESENCE_OFFLINE ||
- priv->state == MC_PRESENCE_HIDDEN ||
- !priv->auto_away) {
- /* We are not online or we don't want to go auto away,
- * nothing to do here */
- priv->is_idle = is_idle;
- return;
- }
-
- if (is_idle && !priv->is_idle) {
- McPresence new_state;
- /* We are now idle */
-
- if (priv->state == MC_PRESENCE_AWAY ||
- priv->state == MC_PRESENCE_EXTENDED_AWAY) {
- /* User set away manually, when coming back we restore
- * default presence. */
- new_state = priv->state;
- priv->away_saved_state = MC_PRESENCE_AVAILABLE;
- priv->away_reset_status = TRUE;
- } else {
- new_state = MC_PRESENCE_AWAY;
- priv->away_saved_state = priv->state;
- priv->away_reset_status = FALSE;
- }
-
- DEBUG ("Going to autoaway");
- empathy_idle_set_state (idle, new_state);
-
- idle_ext_away_start (idle);
- } else if (!is_idle && priv->is_idle) {
- /* We are no more idle, restore state */
- idle_ext_away_stop (idle);
-
- DEBUG ("Restoring state to %d, reset status: %s",
- priv->away_saved_state,
- priv->away_reset_status ? "Yes" : "No");
-
- if (priv->nm_connected) {
- empathy_idle_set_presence (idle,
- priv->away_saved_state,
- priv->away_reset_status ? NULL : priv->status);
- } else {
- /* We can't restore state now, will do when NM gets
- * connected. */
- priv->nm_saved_state = priv->away_saved_state;
- priv->nm_reset_status = priv->away_reset_status;
- }
-
- priv->away_saved_state = MC_PRESENCE_UNSET;
- priv->away_reset_status = FALSE;
- }
-
- priv->is_idle = is_idle;
-}
-
-static void
-idle_nm_state_change_cb (DBusGProxy *proxy,
- guint state,
- EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
- gboolean old_nm_connected;
- gboolean new_nm_connected;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("New network state (%d), in use = %s",
- state, priv->use_nm ? "Yes" : "No");
-
- if (!priv->use_nm) {
- return;
- }
-
- old_nm_connected = priv->nm_connected;
- new_nm_connected = !(state == NM_STATE_CONNECTING ||
- state == NM_STATE_DISCONNECTED);
- priv->nm_connected = TRUE; /* To be sure _set_state will work */
-
- if (old_nm_connected && !new_nm_connected) {
- /* We are no more connected */
- idle_ext_away_stop (idle);
-
- priv->nm_saved_state = priv->state;
- empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);
- }
- else if (!old_nm_connected && new_nm_connected) {
- /* We are now connected */
- empathy_idle_set_presence (idle,
- priv->nm_saved_state,
- priv->nm_reset_status ? NULL : priv->status);
- priv->nm_saved_state = MC_PRESENCE_UNSET;
- priv->nm_reset_status = FALSE;
- }
-
- priv->nm_connected = new_nm_connected;
-}
-
-static void
-idle_ext_away_start (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- idle_ext_away_stop (idle);
- priv->ext_away_timeout = g_timeout_add_seconds (EXT_AWAY_TIME,
- (GSourceFunc) idle_ext_away_cb,
- idle);
-}
-
-static void
-idle_ext_away_stop (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- if (priv->ext_away_timeout) {
- g_source_remove (priv->ext_away_timeout);
- priv->ext_away_timeout = 0;
- }
-}
-
-static gboolean
-idle_ext_away_cb (EmpathyIdle *idle)
-{
- EmpathyIdlePriv *priv;
-
- priv = GET_PRIV (idle);
-
- DEBUG ("Going to extended autoaway");
- empathy_idle_set_state (idle, MC_PRESENCE_EXTENDED_AWAY);
- priv->ext_away_timeout = 0;
-
- return FALSE;
-}
-