aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2007-09-20 18:46:27 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2007-09-20 18:46:27 +0800
commitc51d527f11b2d253ed13788830136bc1787029b1 (patch)
tree7ef6a806bcb9614fd1949f409730e47f9c615e6b
parentf637a06fb631be72db06bc5f45ad2449f80e35e7 (diff)
downloadgsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar.gz
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar.bz2
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar.lz
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar.xz
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.tar.zst
gsoc2013-empathy-c51d527f11b2d253ed13788830136bc1787029b1.zip
Add 2 properties to EmpathyIdle to activate auto-away and auto-disconnect,
2007-09-20 Xavier Claessens <xclaesse@gmail.com> * libempathy-gtk/empathy-status-icon.c: * libempathy/empathy-idle.c: * libempathy/empathy-idle.h: * doc/libempathy/tmpl/empathy-idle.sgml: Add 2 properties to EmpathyIdle to activate auto-away and auto-disconnect, default to off. Only empathy main client will turn them on, like that if other processes are running with an EmpathyIdle instance they won't change presence in the same time than Empathy client. svn path=/trunk/; revision=301
-rw-r--r--ChangeLog11
-rw-r--r--doc/libempathy/tmpl/empathy-idle.sgml10
-rw-r--r--libempathy-gtk/empathy-status-icon.c2
-rw-r--r--libempathy/empathy-idle.c81
-rw-r--r--libempathy/empathy-idle.h34
5 files changed, 120 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 5df2d6cd5..d90001b45 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2007-09-20 Xavier Claessens <xclaesse@gmail.com>
+
+ * libempathy-gtk/empathy-status-icon.c:
+ * libempathy/empathy-idle.c:
+ * libempathy/empathy-idle.h:
+ * doc/libempathy/tmpl/empathy-idle.sgml: Add 2 properties to EmpathyIdle
+ to activate auto-away and auto-disconnect, default to off. Only empathy
+ main client will turn them on, like that if other processes are
+ running with an EmpathyIdle instance they won't change presence in the
+ same time than Empathy client.
+
2007-09-19 Xavier Claessens <xclaesse@gmail.com>
* libempathy-gtk/empathy-smiley-manager.c: Fix a leak.
diff --git a/doc/libempathy/tmpl/empathy-idle.sgml b/doc/libempathy/tmpl/empathy-idle.sgml
index 8971b783f..68edcafed 100644
--- a/doc/libempathy/tmpl/empathy-idle.sgml
+++ b/doc/libempathy/tmpl/empathy-idle.sgml
@@ -29,6 +29,16 @@ EmpathyIdle
</para>
+<!-- ##### ARG EmpathyIdle:auto-away ##### -->
+<para>
+
+</para>
+
+<!-- ##### ARG EmpathyIdle:auto-disconnect ##### -->
+<para>
+
+</para>
+
<!-- ##### ARG EmpathyIdle:flash-state ##### -->
<para>
diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c
index 1fdc00953..4fc1ca055 100644
--- a/libempathy-gtk/empathy-status-icon.c
+++ b/libempathy-gtk/empathy-status-icon.c
@@ -157,6 +157,8 @@ empathy_status_icon_init (EmpathyStatusIcon *icon)
priv->icon = gtk_status_icon_new ();
priv->idle = empathy_idle_new ();
+ empathy_idle_set_auto_away (priv->idle, TRUE);
+ empathy_idle_set_auto_disconnect (priv->idle, TRUE);
priv->manager = empathy_contact_manager_new ();
priv->mc = empathy_mission_control_new ();
priv->text_filter = empathy_filter_new ("org.gnome.Empathy.Chat",
diff --git a/libempathy/empathy-idle.c b/libempathy/empathy-idle.c
index 4c7344e9b..87389277c 100644
--- a/libempathy/empathy-idle.c
+++ b/libempathy/empathy-idle.c
@@ -54,13 +54,15 @@ struct _EmpathyIdlePriv {
MissionControl *mc;
DBusGProxy *gs_proxy;
DBusGProxy *nm_proxy;
- gboolean is_idle;
McPresence state;
McPresence flash_state;
gchar *status;
McPresence saved_state;
gchar *saved_status;
+ gboolean is_idle;
gboolean nm_connected;
+ gboolean auto_away;
+ gboolean auto_disconnect;
guint ext_away_timeout;
};
@@ -92,7 +94,9 @@ enum {
PROP_0,
PROP_STATE,
PROP_STATUS,
- PROP_FLASH_STATE
+ PROP_FLASH_STATE,
+ PROP_AUTO_AWAY,
+ PROP_AUTO_DISCONNECT
};
G_DEFINE_TYPE (EmpathyIdle, empathy_idle, G_TYPE_OBJECT)
@@ -130,6 +134,22 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
MC_PRESENCE_UNSET,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_AUTO_AWAY,
+ g_param_spec_boolean ("auto-away",
+ "Automatic set presence to away",
+ "Should it set presence to away if inactive",
+ FALSE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (object_class,
+ PROP_AUTO_DISCONNECT,
+ g_param_spec_boolean ("auto-disconnect",
+ "Automatic set presence to offline",
+ "Should it set presence to offline if NM is disconnected",
+ FALSE,
+ G_PARAM_READWRITE));
+
g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
}
@@ -258,6 +278,12 @@ idle_get_property (GObject *object,
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_AUTO_DISCONNECT:
+ g_value_set_boolean (value, empathy_idle_get_auto_disconnect (idle));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -286,6 +312,9 @@ idle_set_property (GObject *object,
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;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -414,6 +443,44 @@ empathy_idle_set_presence (EmpathyIdle *idle,
NULL, NULL);
}
+gboolean
+empathy_idle_get_auto_away (EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ return priv->auto_away;
+}
+
+void
+empathy_idle_set_auto_away (EmpathyIdle *idle,
+ gboolean auto_away)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ priv->auto_away = auto_away;
+
+ g_object_notify (G_OBJECT (idle), "auto-away");
+}
+
+gboolean
+empathy_idle_get_auto_disconnect (EmpathyIdle *idle)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ return priv->auto_disconnect;
+}
+
+void
+empathy_idle_set_auto_disconnect (EmpathyIdle *idle,
+ gboolean auto_disconnect)
+{
+ EmpathyIdlePriv *priv = GET_PRIV (idle);
+
+ priv->auto_disconnect = auto_disconnect;
+
+ g_object_notify (G_OBJECT (idle), "auto-disconnect");
+}
+
static void
idle_presence_changed_cb (MissionControl *mc,
McPresence state,
@@ -450,8 +517,10 @@ idle_session_idle_changed_cb (DBusGProxy *gs_proxy,
is_idle ? "yes" : "no");
if (priv->state <= MC_PRESENCE_OFFLINE ||
- priv->state == MC_PRESENCE_HIDDEN) {
- /* We are not online so nothing to do here */
+ 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;
}
@@ -507,6 +576,10 @@ idle_nm_state_change_cb (DBusGProxy *proxy,
empathy_debug (DEBUG_DOMAIN, "New network state (%d)", state);
+ if (!priv->auto_disconnect) {
+ return;
+ }
+
if (state != NM_STATE_CONNECTED && priv->nm_connected) {
/* We are no more connected */
idle_ext_away_stop (idle);
diff --git a/libempathy/empathy-idle.h b/libempathy/empathy-idle.h
index 011d2494a..b2f3e634a 100644
--- a/libempathy/empathy-idle.h
+++ b/libempathy/empathy-idle.h
@@ -48,20 +48,26 @@ struct _EmpathyIdleClass {
GObjectClass parent_class;
};
-GType empathy_idle_get_type (void) G_GNUC_CONST;
-EmpathyIdle *empathy_idle_new (void);
-McPresence empathy_idle_get_state (EmpathyIdle *idle);
-void empathy_idle_set_state (EmpathyIdle *idle,
- McPresence state);
-const gchar *empathy_idle_get_status (EmpathyIdle *idle);
-void empathy_idle_set_status (EmpathyIdle *idle,
- const gchar *status);
-McPresence empathy_idle_get_flash_state (EmpathyIdle *idle);
-void empathy_idle_set_flash_state (EmpathyIdle *idle,
- McPresence state);
-void empathy_idle_set_presence (EmpathyIdle *idle,
- McPresence state,
- const gchar *status);
+GType empathy_idle_get_type (void) G_GNUC_CONST;
+EmpathyIdle *empathy_idle_new (void);
+McPresence empathy_idle_get_state (EmpathyIdle *idle);
+void empathy_idle_set_state (EmpathyIdle *idle,
+ McPresence state);
+const gchar *empathy_idle_get_status (EmpathyIdle *idle);
+void empathy_idle_set_status (EmpathyIdle *idle,
+ const gchar *status);
+McPresence empathy_idle_get_flash_state (EmpathyIdle *idle);
+void empathy_idle_set_flash_state (EmpathyIdle *idle,
+ McPresence state);
+void empathy_idle_set_presence (EmpathyIdle *idle,
+ McPresence state,
+ const gchar *status);
+gboolean empathy_idle_get_auto_away (EmpathyIdle *idle);
+void empathy_idle_set_auto_away (EmpathyIdle *idle,
+ gboolean auto_away);
+gboolean empathy_idle_get_auto_disconnect (EmpathyIdle *idle);
+void empathy_idle_set_auto_disconnect (EmpathyIdle *idle,
+ gboolean auto_disconnect);
G_END_DECLS