aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@src.gnome.org>2008-03-17 18:23:17 +0800
committerXavier Claessens <xclaesse@src.gnome.org>2008-03-17 18:23:17 +0800
commit8a4b2321006fd56b417e3c995c737dd7c0f364bd (patch)
tree51296d33ea54750e15a2cc6c1a37eec525f5a86f
parent1ac788af54642510e3a091a42da692ad87ec8667 (diff)
downloadgsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar.gz
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar.bz2
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar.lz
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar.xz
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.tar.zst
gsoc2013-empathy-8a4b2321006fd56b417e3c995c737dd7c0f364bd.zip
Do not autoconnect if networkmanager says we are not connected at startup.
svn path=/trunk/; revision=815
-rw-r--r--src/empathy-status-icon.c24
-rw-r--r--src/empathy.c98
2 files changed, 66 insertions, 56 deletions
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index 7cd623b45..9ea0604fc 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -147,19 +147,6 @@ static void status_icon_event_free (StatusIconEvent *event
G_DEFINE_TYPE (EmpathyStatusIcon, empathy_status_icon, G_TYPE_OBJECT);
static void
-status_icon_notify_use_nm_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
-{
- EmpathyStatusIconPriv *priv = GET_PRIV (user_data);
- gboolean use_nm;
-
- if (empathy_conf_get_bool (conf, key, &use_nm)) {
- empathy_idle_set_use_nm (priv->idle, use_nm);
- }
-}
-
-static void
status_icon_notify_visibility_cb (EmpathyConf *conf,
const gchar *key,
gpointer user_data)
@@ -187,7 +174,6 @@ empathy_status_icon_init (EmpathyStatusIcon *icon)
{
EmpathyStatusIconPriv *priv;
GList *pendings, *l;
- gboolean use_nm;
priv = GET_PRIV (icon);
@@ -205,17 +191,7 @@ empathy_status_icon_init (EmpathyStatusIcon *icon)
MC_FILTER_PRIORITY_DIALOG,
MC_FILTER_FLAG_INCOMING);
- /* Setup EmpathyIdle */
priv->idle = empathy_idle_new ();
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_USE_NM,
- &use_nm);
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_USE_NM,
- status_icon_notify_use_nm_cb,
- icon);
- empathy_idle_set_auto_away (priv->idle, TRUE);
- empathy_idle_set_use_nm (priv->idle, use_nm);
/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
empathy_conf_notify_add (empathy_conf_get (),
diff --git a/src/empathy.c b/src/empathy.c
index 0d8992690..95c290ca7 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -34,7 +34,6 @@
#include <telepathy-glib/util.h>
#include <libmissioncontrol/mc-account.h>
-#include <libmissioncontrol/mc-account-monitor.h>
#include <libmissioncontrol/mission-control.h>
#include <libempathy/empathy-idle.h>
@@ -131,33 +130,67 @@ operation_error_cb (MissionControl *mc,
guint error_code,
gpointer user_data)
{
- empathy_debug (DEBUG_DOMAIN, "Error code %d during operation %d",
- error_code,
- operation_id);
-}
-
-static void
-start_mission_control (EmpathyIdle *idle)
-{
- McPresence presence;
-
- presence = empathy_idle_get_state (idle);
-
- if (presence > MC_PRESENCE_OFFLINE) {
- /* MC is already running and online, nothing to do */
- return;
+ const gchar *message;
+
+ switch (error_code) {
+ case MC_DISCONNECTED_ERROR:
+ message = _("Disconnected");
+ break;
+ case MC_INVALID_HANDLE_ERROR:
+ message = _("Invalid handle");
+ break;
+ case MC_NO_MATCHING_CONNECTION_ERROR:
+ message = _("No matching connection");
+ break;
+ case MC_INVALID_ACCOUNT_ERROR:
+ message = _("Invalid account");
+ break;
+ case MC_PRESENCE_FAILURE_ERROR:
+ message = _("Presence failure");
+ break;
+ case MC_NO_ACCOUNTS_ERROR:
+ message = _("No accounts");
+ break;
+ case MC_NETWORK_ERROR:
+ message = _("Network error");
+ break;
+ case MC_CONTACT_DOES_NOT_SUPPORT_VOICE_ERROR:
+ message = _("Contact does not support voice");
+ break;
+ case MC_LOWMEM_ERROR:
+ message = _("Lowmem");
+ break;
+ case MC_CHANNEL_REQUEST_GENERIC_ERROR:
+ message = _("Channel request generic error");
+ break;
+ case MC_CHANNEL_BANNED_ERROR:
+ message = _("Channel banned");
+ break;
+ case MC_CHANNEL_FULL_ERROR:
+ message = _("Channel full");
+ break;
+ case MC_CHANNEL_INVITE_ONLY_ERROR:
+ message = _("Channel invite only");
+ break;
+ default:
+ message = _("Unknown error code");
}
- empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
+ empathy_debug (DEBUG_DOMAIN, "Error during operation %d: %s",
+ operation_id, message);
}
static void
-account_enabled_cb (McAccountMonitor *monitor,
- gchar *unique_name,
- EmpathyIdle *idle)
+use_nm_notify_cb (EmpathyConf *conf,
+ const gchar *key,
+ gpointer user_data)
{
- empathy_debug (DEBUG_DOMAIN, "Account enabled: %s", unique_name);
- start_mission_control (idle);
+ EmpathyIdle *idle = user_data;
+ gboolean use_nm;
+
+ if (empathy_conf_get_bool (conf, key, &use_nm)) {
+ empathy_idle_set_use_nm (idle, use_nm);
+ }
}
static void
@@ -339,7 +372,6 @@ main (int argc, char *argv[])
EmpathyStatusIcon *icon;
GtkWidget *window;
MissionControl *mc;
- McAccountMonitor *monitor;
EmpathyIdle *idle;
EmpathyChandler *chandler;
gboolean autoconnect = TRUE;
@@ -392,12 +424,7 @@ main (int argc, char *argv[])
}
/* Setting up MC */
- monitor = mc_account_monitor_new ();
mc = empathy_mission_control_new ();
- idle = empathy_idle_new ();
- g_signal_connect (monitor, "account-enabled",
- G_CALLBACK (account_enabled_cb),
- idle);
g_signal_connect (mc, "ServiceEnded",
G_CALLBACK (service_ended_cb),
NULL);
@@ -405,12 +432,20 @@ main (int argc, char *argv[])
G_CALLBACK (operation_error_cb),
NULL);
+ /* Setting up Idle */
+ idle = empathy_idle_new ();
+ empathy_idle_set_auto_away (idle, TRUE);
+ use_nm_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_NM, idle);
+ empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_NM,
+ use_nm_notify_cb, idle);
+
+ /* Autoconnect */
empathy_conf_get_bool (empathy_conf_get(),
EMPATHY_PREFS_AUTOCONNECT,
&autoconnect);
-
- if (autoconnect) {
- start_mission_control (idle);
+ if (autoconnect &&
+ empathy_idle_get_state (idle) <= MC_PRESENCE_OFFLINE) {
+ empathy_idle_set_state (idle, MC_PRESENCE_AVAILABLE);
}
create_salut_account ();
@@ -438,7 +473,6 @@ main (int argc, char *argv[])
empathy_idle_set_state (idle, MC_PRESENCE_OFFLINE);
g_object_unref (chandler);
- g_object_unref (monitor);
g_object_unref (mc);
g_object_unref (idle);
g_object_unref (icon);