summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Mardegan <mardy@users.sourceforge.net>2008-05-13 12:19:46 +0000
committerAlberto Mardegan <mardy@users.sourceforge.net>2008-05-13 12:19:46 +0000
commit1f083ebd3f39226131a40f2be97f6768b6930d75 (patch)
treebc256e69c1a2b4d1c0fb0dd415febaa3a3f4bbf3
parent20f255a3571e381e05749a7b3f5da4d056104336 (diff)
Tag beta85.0.beta8
git-svn-id: https://mission-control.svn.sourceforge.net/svnroot/mission-control/trunk@389 d91c8aed-3f2b-0410-a83d-924a1c20a0ba
-rw-r--r--ChangeLog12
-rw-r--r--configure.ac2
-rw-r--r--doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml5
-rw-r--r--src/Makefile.am4
-rw-r--r--src/mcd-account-config.h106
-rw-r--r--src/mcd-account-connection.c123
-rw-r--r--src/mcd-account-connection.h40
-rw-r--r--src/mcd-account-manager-query.c1
-rw-r--r--src/mcd-account-manager.c2
-rw-r--r--src/mcd-account-priv.h53
-rw-r--r--src/mcd-account.c62
-rw-r--r--src/mcd-connection-plugin.h49
-rw-r--r--src/mcd-connection.c14
-rw-r--r--src/mcd-connection.h2
-rw-r--r--src/mcd-manager.c1
-rw-r--r--src/mcd-master.c51
-rw-r--r--src/mcd-master.h5
-rw-r--r--src/mcd-plugin.h6
18 files changed, 440 insertions, 98 deletions
diff --git a/ChangeLog b/ChangeLog
index c439fbac..a5fd996e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+=== telepathy-mission-control 5.0.beta8 ===
+
+2008-05-13 Alberto Mardegan <alberto.mardegan@nokia.com>
+
+ * doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml,
+ src/Makefile.am, src/mcd-account-config.h,
+ src/mcd-account-connection.[hc], src/mcd-account-manager-query.c,
+ src/mcd-account-manager.c, src/mcd-account-priv.h, src/mcd-account.c,
+ src/mcd-connection-plugin.h, src/mcd-connection.[hc],
+ src/mcd-manager.c, src/mcd-master.[hc], src/mcd-plugin.h:
+ Add support for account connection plugins.
+
2008-05-08 Alberto Mardegan <alberto.mardegan@nokia.com>
* src/mcd-account-conditions.[hc], src/mcd-master.c:
diff --git a/configure.ac b/configure.ac
index 58870479..e36baf9b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT(telepathy-mission-control, 5.0.beta7)
+AC_INIT(telepathy-mission-control, 5.0.beta8)
AC_CONFIG_SRCDIR(Makefile.am)
AM_INIT_AUTOMAKE([tar-ustar])
AM_CONFIG_HEADER(config.h)
diff --git a/doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml b/doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml
index 044b9e3f..d75197bc 100644
--- a/doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml
+++ b/doc/reference/libmissioncontrol-server/tmpl/mcd-dispatcher.sgml
@@ -66,11 +66,6 @@ McdDispatcher
</para>
-<!-- ##### ARG McdDispatcher:plugin-dir ##### -->
-<para>
-
-</para>
-
<!-- ##### STRUCT McdDispatcherStatus ##### -->
<para>
diff --git a/src/Makefile.am b/src/Makefile.am
index d2e537e5..cfa64a14 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -8,6 +8,7 @@ mission_control_include = \
mcd-account.h \
mcd-account-compat.h \
mcd-account-conditions.h \
+ mcd-account-connection.h \
mcd-account-manager.h \
mcd-account-manager-query.h \
mcd-dbusprop.h \
@@ -18,6 +19,7 @@ mission_control_include = \
mcd-controller.h \
mcd-manager.h \
mcd-connection.h \
+ mcd-connection-plugin.h \
mcd-plugin.h \
mcd-presence-frame.h \
mcd-channel.h \
@@ -57,6 +59,7 @@ nodist_libmissioncontrol_server_la_SOURCES = \
mission_control_include_HEADERS = \
$(mission_control_include) \
+ mcd-account-config.h \
mcd-account-priv.h \
mcd-enum-types.h
@@ -86,6 +89,7 @@ libmissioncontrol_server_la_SOURCES = \
mcd-account.c \
mcd-account-compat.c \
mcd-account-conditions.c \
+ mcd-account-connection.c \
mcd-account-manager.c \
mcd-account-manager-query.c \
mcd-dbusprop.c \
diff --git a/src/mcd-account-config.h b/src/mcd-account-config.h
new file mode 100644
index 00000000..009d5dbf
--- /dev/null
+++ b/src/mcd-account-config.h
@@ -0,0 +1,106 @@
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2007 Nokia Corporation.
+ *
+ * Contact: Naba Kumar <naba.kumar@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __MCD_ACCOUNT_CONFIG_H__
+#define __MCD_ACCOUNT_CONFIG_H__
+
+#define MC_ACCOUNTS_KEY_MANAGER "manager"
+#define MC_ACCOUNTS_KEY_PROTOCOL "protocol"
+#define MC_ACCOUNTS_KEY_PRESETS "presets"
+#define MC_ACCOUNTS_KEY_GROUPS "groups"
+#define MC_ACCOUNTS_KEY_DISPLAY_NAME "DisplayName"
+#define MC_ACCOUNTS_KEY_ICON_NAME "icon_name"
+#define MC_ACCOUNTS_KEY_NORMALIZED_NAME "NormalizedName"
+#define MC_ACCOUNTS_KEY_ENABLED "Enabled"
+#define MC_ACCOUNTS_KEY_DELETED "deleted"
+#define MC_ACCOUNTS_KEY_PROFILE "profile"
+#define MC_ACCOUNTS_KEY_PARAM_ACCOUNT "account"
+#define MC_ACCOUNTS_KEY_AVATAR_TOKEN "avatar_token"
+#define MC_ACCOUNTS_KEY_AVATAR_MIME "AvatarMime"
+#define MC_ACCOUNTS_KEY_AVATAR_ID "avatar_id"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_TYPE "AutomaticPresenceType"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_STATUS "AutomaticPresenceStatus"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_MESSAGE "AutomaticPresenceMessage"
+#define MC_ACCOUNTS_KEY_CONNECT_AUTOMATICALLY "ConnectAutomatically"
+#define MC_ACCOUNTS_KEY_DATA_DIR "data_dir"
+#define MC_ACCOUNTS_KEY_ALIAS "Nickname"
+#define MC_ACCOUNTS_KEY_SECONDARY_VCARD_FIELDS "secondary_vcard_fields"
+
+#define PRESETS_GROUP "Presets"
+#define PRESETS_GROUP_DEFAULTS "Defaults"
+
+#endif /* __MCD_ACCOUNT_CONFIG_H__ */
+
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2007 Nokia Corporation.
+ *
+ * Contact: Naba Kumar <naba.kumar@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __MCD_ACCOUNT_PRIV_H__
+#define __MCD_ACCOUNT_PRIV_H__
+
+#define MC_ACCOUNTS_KEY_MANAGER "manager"
+#define MC_ACCOUNTS_KEY_PROTOCOL "protocol"
+#define MC_ACCOUNTS_KEY_PRESETS "presets"
+#define MC_ACCOUNTS_KEY_GROUPS "groups"
+#define MC_ACCOUNTS_KEY_DISPLAY_NAME "DisplayName"
+#define MC_ACCOUNTS_KEY_ICON_NAME "icon_name"
+#define MC_ACCOUNTS_KEY_NORMALIZED_NAME "NormalizedName"
+#define MC_ACCOUNTS_KEY_ENABLED "Enabled"
+#define MC_ACCOUNTS_KEY_DELETED "deleted"
+#define MC_ACCOUNTS_KEY_PROFILE "profile"
+#define MC_ACCOUNTS_KEY_PARAM_ACCOUNT "account"
+#define MC_ACCOUNTS_KEY_AVATAR_TOKEN "avatar_token"
+#define MC_ACCOUNTS_KEY_AVATAR_MIME "AvatarMime"
+#define MC_ACCOUNTS_KEY_AVATAR_ID "avatar_id"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_TYPE "AutomaticPresenceType"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_STATUS "AutomaticPresenceStatus"
+#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_MESSAGE "AutomaticPresenceMessage"
+#define MC_ACCOUNTS_KEY_CONNECT_AUTOMATICALLY "ConnectAutomatically"
+#define MC_ACCOUNTS_KEY_DATA_DIR "data_dir"
+#define MC_ACCOUNTS_KEY_ALIAS "Nickname"
+#define MC_ACCOUNTS_KEY_SECONDARY_VCARD_FIELDS "secondary_vcard_fields"
+
+#define PRESETS_GROUP "Presets"
+#define PRESETS_GROUP_DEFAULTS "Defaults"
+
+#endif /* __MCD_ACCOUNT_PRIV_H__ */
+
diff --git a/src/mcd-account-connection.c b/src/mcd-account-connection.c
new file mode 100644
index 00000000..5529172e
--- /dev/null
+++ b/src/mcd-account-connection.c
@@ -0,0 +1,123 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <glib/gstdio.h>
+#include <glib/gi18n.h>
+#include <config.h>
+
+#include "mcd-master.h"
+#include "mcd-account.h"
+#include "mcd-account-priv.h"
+#include "mcd-account-connection.h"
+#include "mcd-account-manager.h"
+
+typedef struct {
+ GHashTable *params;
+ gint i_filter;
+} McdAccountConnectionContext;
+
+static GQuark account_connection_context_quark;
+
+static void
+context_free (gpointer ptr)
+{
+ McdAccountConnectionContext *ctx = ptr;
+
+ g_free (ctx);
+}
+
+void
+mcd_account_connection_begin (McdAccount *account)
+{
+ McdAccountConnectionContext *ctx;
+
+ /* get account params */
+ /* create dynamic params HT */
+ /* run the handlers */
+ ctx = g_malloc (sizeof (McdAccountConnectionContext));
+ ctx->i_filter = 0;
+ ctx->params = mcd_account_get_parameters (account);
+ g_object_set_qdata_full ((GObject *)account,
+ account_connection_context_quark,
+ ctx, context_free);
+
+ mcd_account_connection_proceed (account, TRUE);
+}
+
+void
+mcd_account_connection_proceed (McdAccount *account, gboolean success)
+{
+ McdAccountConnectionContext *ctx;
+ McdAccountConnectionFunc func = NULL;
+ gpointer userdata;
+ McdMaster *master;
+
+ /* call next handler, or terminate the chain (emitting proper signal).
+ * if everything is fine, call mcd_manager_create_connection() and
+ * mcd_connection_connect () with the dynamic parameters. Remove that call
+ * from mcd_manager_create_connection() */
+ ctx = g_object_get_qdata ((GObject *)account,
+ account_connection_context_quark);
+ g_return_if_fail (ctx != NULL);
+
+ if (success)
+ {
+ master = mcd_master_get_default ();
+ mcd_master_get_nth_account_connection (master, ctx->i_filter++,
+ &func, &userdata);
+ }
+ if (func)
+ {
+ func (account, ctx->params, userdata);
+ }
+ else
+ {
+ /* end of the chain */
+ g_signal_emit (account, _mcd_account_signals[CONNECTION_PROCESS], 0,
+ success);
+ if (success)
+ {
+ _mcd_account_connect (account, ctx->params);
+ }
+ g_object_set_qdata ((GObject *)account,
+ account_connection_context_quark, NULL);
+ }
+}
+
+inline void
+_mcd_account_connection_class_init (McdAccountClass *klass)
+{
+ _mcd_account_signals[CONNECTION_PROCESS] =
+ g_signal_new ("connection-process",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
+ G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+ account_connection_context_quark = g_quark_from_static_string ("accontext");
+}
+
diff --git a/src/mcd-account-connection.h b/src/mcd-account-connection.h
new file mode 100644
index 00000000..5944db0c
--- /dev/null
+++ b/src/mcd-account-connection.h
@@ -0,0 +1,40 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __MCD_ACCOUNT_CONNECTION_H__
+#define __MCD_ACCOUNT_CONNECTION_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "mcd-plugin.h"
+#include "mcd-connection-plugin.h"
+
+G_BEGIN_DECLS
+
+void mcd_account_connection_begin (McdAccount *account);
+inline void _mcd_account_connection_class_init (McdAccountClass *klass);
+
+G_END_DECLS
+
+#endif /* __MCD_ACCOUNT_CONNECTION_H__ */
diff --git a/src/mcd-account-manager-query.c b/src/mcd-account-manager-query.c
index 33fa6f55..f119105e 100644
--- a/src/mcd-account-manager-query.c
+++ b/src/mcd-account-manager-query.c
@@ -32,7 +32,6 @@
#include <telepathy-glib/gtypes.h>
#include <telepathy-glib/util.h>
#include "mcd-account.h"
-#include "mcd-account-priv.h"
#include "mcd-account-manager.h"
#include "mcd-account-manager-query.h"
#include "_gen/interfaces.h"
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 73a8ab16..d1781212 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -35,7 +35,7 @@
#include "mcd-account-manager.h"
#include "mcd-account-manager-query.h"
#include "mcd-account.h"
-#include "mcd-account-priv.h"
+#include "mcd-account-config.h"
#include "mcd-dbusprop.h"
#include "_gen/interfaces.h"
diff --git a/src/mcd-account-priv.h b/src/mcd-account-priv.h
deleted file mode 100644
index f3c7c59a..00000000
--- a/src/mcd-account-priv.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * This file is part of mission-control
- *
- * Copyright (C) 2007 Nokia Corporation.
- *
- * Contact: Naba Kumar <naba.kumar@nokia.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA
- *
- */
-
-#ifndef __MCD_ACCOUNT_PRIV_H__
-#define __MCD_ACCOUNT_PRIV_H__
-
-#define MC_ACCOUNTS_KEY_MANAGER "manager"
-#define MC_ACCOUNTS_KEY_PROTOCOL "protocol"
-#define MC_ACCOUNTS_KEY_PRESETS "presets"
-#define MC_ACCOUNTS_KEY_GROUPS "groups"
-#define MC_ACCOUNTS_KEY_DISPLAY_NAME "DisplayName"
-#define MC_ACCOUNTS_KEY_ICON_NAME "icon_name"
-#define MC_ACCOUNTS_KEY_NORMALIZED_NAME "NormalizedName"
-#define MC_ACCOUNTS_KEY_ENABLED "Enabled"
-#define MC_ACCOUNTS_KEY_DELETED "deleted"
-#define MC_ACCOUNTS_KEY_PROFILE "profile"
-#define MC_ACCOUNTS_KEY_PARAM_ACCOUNT "account"
-#define MC_ACCOUNTS_KEY_AVATAR_TOKEN "avatar_token"
-#define MC_ACCOUNTS_KEY_AVATAR_MIME "AvatarMime"
-#define MC_ACCOUNTS_KEY_AVATAR_ID "avatar_id"
-#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_TYPE "AutomaticPresenceType"
-#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_STATUS "AutomaticPresenceStatus"
-#define MC_ACCOUNTS_KEY_AUTO_PRESENCE_MESSAGE "AutomaticPresenceMessage"
-#define MC_ACCOUNTS_KEY_CONNECT_AUTOMATICALLY "ConnectAutomatically"
-#define MC_ACCOUNTS_KEY_DATA_DIR "data_dir"
-#define MC_ACCOUNTS_KEY_ALIAS "Nickname"
-#define MC_ACCOUNTS_KEY_SECONDARY_VCARD_FIELDS "secondary_vcard_fields"
-
-#define PRESETS_GROUP "Presets"
-#define PRESETS_GROUP_DEFAULTS "Defaults"
-
-#endif /* __MCD_ACCOUNT_PRIV_H__ */
-
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 7255ee91..36b5b9fc 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -35,6 +35,7 @@
#include "mcd-account-priv.h"
#include "mcd-account-compat.h"
#include "mcd-account-conditions.h"
+#include "mcd-account-connection.h"
#include "mcd-account-manager.h"
#include "mcd-signals-marshal.h"
#include "mcd-manager.h"
@@ -133,18 +134,7 @@ enum
PROP_NAME,
};
-enum
-{
- CONNECTION_STATUS_CHANGED,
- CURRENT_PRESENCE_CHANGED,
- REQUESTED_PRESENCE_CHANGED,
- VALIDITY_CHANGED,
- AVATAR_CHANGED,
- ALIAS_CHANGED,
- LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL] = { 0 };
+guint _mcd_account_signals[LAST_SIGNAL] = { 0 };
static void
process_online_request (gpointer key, gpointer cb_userdata, gpointer userdata)
@@ -236,24 +226,37 @@ mcd_account_request_presence_int (McdAccount *account,
if (type >= TP_CONNECTION_PRESENCE_TYPE_AVAILABLE && !priv->connection)
{
+ mcd_account_connection_begin (account);
+ }
+
+ g_signal_emit (account,
+ _mcd_account_signals[REQUESTED_PRESENCE_CHANGED], 0,
+ type, status, message);
+ return TRUE;
+}
+
+void
+_mcd_account_connect (McdAccount *account, GHashTable *params)
+{
+ McdAccountPrivate *priv = account->priv;
+
+ if (!priv->connection)
+ {
if (!priv->manager && !load_manager (priv))
{
g_warning ("%s: Could not find manager `%s'",
G_STRFUNC, priv->manager_name);
- return TRUE;
+ return;
}
priv->connection = mcd_manager_create_connection (priv->manager,
account);
- g_return_val_if_fail (priv->connection != NULL, TRUE);
+ g_return_if_fail (priv->connection != NULL);
g_object_ref (priv->connection);
g_signal_connect (priv->connection, "abort",
G_CALLBACK (on_connection_abort), account);
}
-
- g_signal_emit (account, signals[REQUESTED_PRESENCE_CHANGED], 0,
- type, status, message);
- return TRUE;
+ mcd_connection_connect (priv->connection, params);
}
#ifdef DELAY_PROPERTY_CHANGED
@@ -1379,7 +1382,7 @@ mcd_account_class_init (McdAccountClass * klass)
G_PARAM_CONSTRUCT_ONLY));
/* Signals */
- signals[CONNECTION_STATUS_CHANGED] =
+ _mcd_account_signals[CONNECTION_STATUS_CHANGED] =
g_signal_new ("connection-status-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
@@ -1387,7 +1390,7 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, mcd_marshal_VOID__UINT_UINT,
G_TYPE_NONE,
2, G_TYPE_UINT, G_TYPE_UINT);
- signals[CURRENT_PRESENCE_CHANGED] =
+ _mcd_account_signals[CURRENT_PRESENCE_CHANGED] =
g_signal_new ("current-presence-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
@@ -1395,7 +1398,7 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, mcd_marshal_VOID__UINT_STRING_STRING,
G_TYPE_NONE,
3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals[REQUESTED_PRESENCE_CHANGED] =
+ _mcd_account_signals[REQUESTED_PRESENCE_CHANGED] =
g_signal_new ("requested-presence-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
@@ -1403,7 +1406,7 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, mcd_marshal_VOID__UINT_STRING_STRING,
G_TYPE_NONE,
3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING);
- signals[VALIDITY_CHANGED] =
+ _mcd_account_signals[VALIDITY_CHANGED] =
g_signal_new ("validity-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
@@ -1411,7 +1414,7 @@ mcd_account_class_init (McdAccountClass * klass)
NULL, NULL, mcd_marshal_VOID__BOOLEAN,
G_TYPE_NONE, 1,
G_TYPE_BOOLEAN);
- signals[AVATAR_CHANGED] =
+ _mcd_account_signals[AVATAR_CHANGED] =
g_signal_new ("avatar-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
@@ -1420,13 +1423,14 @@ mcd_account_class_init (McdAccountClass * klass)
G_TYPE_NONE, 2,
dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR),
G_TYPE_STRING);
- signals[ALIAS_CHANGED] =
+ _mcd_account_signals[ALIAS_CHANGED] =
g_signal_new ("alias-changed",
G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_DETAILED,
0,
NULL, NULL, g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
+ _mcd_account_connection_class_init (klass);
}
static void
@@ -1698,7 +1702,7 @@ mcd_account_set_current_presence (McdAccount *account,
/* TODO: when the McdPresenceFrame is removed, check if this signal is
* still used by someone else, or remove it */
- g_signal_emit (account, signals[CURRENT_PRESENCE_CHANGED], 0,
+ g_signal_emit (account, _mcd_account_signals[CURRENT_PRESENCE_CHANGED], 0,
presence, status, message);
}
@@ -1860,7 +1864,7 @@ mcd_account_set_avatar (McdAccount *account, const GArray *avatar,
g_key_file_set_string (priv->keyfile, priv->unique_name,
MC_ACCOUNTS_KEY_AVATAR_MIME, mime_type);
- g_signal_emit (account, signals[AVATAR_CHANGED], 0,
+ g_signal_emit (account, _mcd_account_signals[AVATAR_CHANGED], 0,
avatar, mime_type);
mcd_account_manager_write_conf (priv->keyfile);
@@ -1995,7 +1999,8 @@ mcd_account_set_connection_status (McdAccount *account,
}
if (changed)
- g_signal_emit (account, signals[CONNECTION_STATUS_CHANGED], 0,
+ g_signal_emit (account,
+ _mcd_account_signals[CONNECTION_STATUS_CHANGED], 0,
status, reason);
}
@@ -2033,7 +2038,8 @@ mcd_account_check_validity (McdAccount *account)
g_debug ("Account validity changed (old: %d, new: %d)",
priv->valid, valid);
priv->valid = valid;
- g_signal_emit (account, signals[VALIDITY_CHANGED], 0, valid);
+ g_signal_emit (account, _mcd_account_signals[VALIDITY_CHANGED], 0,
+ valid);
g_value_init (&value, G_TYPE_BOOLEAN);
g_value_set_boolean (&value, valid);
mcd_account_changed_property (account, "Valid", &value);
diff --git a/src/mcd-connection-plugin.h b/src/mcd-connection-plugin.h
new file mode 100644
index 00000000..7f6dafc7
--- /dev/null
+++ b/src/mcd-connection-plugin.h
@@ -0,0 +1,49 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 8 -*- */
+/*
+ * This file is part of mission-control
+ *
+ * Copyright (C) 2008 Nokia Corporation.
+ *
+ * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __MCD_CONNECTION_PLUGIN_H__
+#define __MCD_CONNECTION_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include "mcd-plugin.h"
+
+G_BEGIN_DECLS
+
+typedef void (*McdAccountConnectionFunc) (McdAccount *account, GHashTable *parameters, gpointer userdata);
+
+void mcd_account_connection_proceed (McdAccount *account, gboolean success);
+
+#define MCD_ACCOUNT_CONNECTION_PRIORITY_POLICY 10000
+#define MCD_ACCOUNT_CONNECTION_PRIORITY_TRANSPORT 20000
+#define MCD_ACCOUNT_CONNECTION_PRIORITY_PARAMS 30000
+
+void mcd_plugin_register_account_connection (McdPlugin *plugin,
+ McdAccountConnectionFunc func,
+ gint priority,
+ gpointer userdata);
+
+G_END_DECLS
+
+#endif /* __MCD_CONNECTION_PLUGIN_H__ */
diff --git a/src/mcd-connection.c b/src/mcd-connection.c
index 2b8a72fd..0948d5ba 100644
--- a/src/mcd-connection.c
+++ b/src/mcd-connection.c
@@ -387,6 +387,7 @@ _mcd_connection_set_presence (McdConnection * connection,
if (!priv->tp_conn)
{
+ g_warning ("%s: tp_conn is NULL!", G_STRFUNC);
_mcd_connection_setup (connection);
return;
}
@@ -1388,9 +1389,8 @@ mcd_connection_get_params_and_connect (McdConnection *connection)
g_debug ("%s: Trying connect account: %s",
G_STRFUNC, (gchar *) account_name);
- params = mcd_account_get_parameters (priv->account);
+ params = g_object_get_data ((GObject *)connection, "params");
_mcd_connection_connect (connection, params);
- g_hash_table_destroy (params);
}
static void
@@ -2372,12 +2372,18 @@ mcd_connection_restart (McdConnection *connection)
/**
* mcd_connection_connect:
* @connection: the #McdConnection.
+ * @params: a #GHashTable of connection parameters.
*
- * Activate @connection.
+ * Activate @connection. The connection takes ownership of @params.
*/
void
-mcd_connection_connect (McdConnection *connection)
+mcd_connection_connect (McdConnection *connection, GHashTable *params)
{
+ /* TODO: we should probably not save the parameters, but instead restart
+ * the full account connection process when we want to reconnect the
+ * connection */
+ g_object_set_data_full ((GObject *)connection, "params", params,
+ (GDestroyNotify)g_hash_table_destroy);
_mcd_connection_setup (connection);
}
diff --git a/src/mcd-connection.h b/src/mcd-connection.h
index 9a5d0ece..e8b4758e 100644
--- a/src/mcd-connection.h
+++ b/src/mcd-connection.h
@@ -92,7 +92,7 @@ gboolean mcd_connection_remote_avatar_changed (McdConnection *connection,
void mcd_connection_account_changed (McdConnection *connection);
void mcd_connection_restart (McdConnection *connection);
-void mcd_connection_connect (McdConnection *connection);
+void mcd_connection_connect (McdConnection *connection, GHashTable *params);
void mcd_connection_close (McdConnection *connection);
G_END_DECLS
diff --git a/src/mcd-manager.c b/src/mcd-manager.c
index c4c391be..c5103e95 100644
--- a/src/mcd-manager.c
+++ b/src/mcd-manager.c
@@ -1137,7 +1137,6 @@ mcd_manager_create_connection (McdManager *manager, McdAccount *account)
priv->dispatcher);
mcd_operation_take_mission (MCD_OPERATION (manager),
MCD_MISSION (connection));
- mcd_connection_connect (connection);
g_debug ("%s: Created a connection %p for account: %s", G_STRFUNC,
connection, mcd_account_get_unique_name (account));
diff --git a/src/mcd-master.c b/src/mcd-master.c
index e579c0a9..1cbafbf5 100644
--- a/src/mcd-master.c
+++ b/src/mcd-master.c
@@ -65,6 +65,7 @@
#include "mcd-account-conditions.h"
#include "mcd-plugin.h"
#include "mcd-transport.h"
+#include "mcd-account-connection.h"
#define MCD_MASTER_PRIV(master) (G_TYPE_INSTANCE_GET_PRIVATE ((master), \
MCD_TYPE_MASTER, \
@@ -97,6 +98,7 @@ typedef struct _McdMasterPrivate
GPtrArray *plugins;
GPtrArray *transport_plugins;
+ GList *account_connections;
gboolean is_disposed;
} McdMasterPrivate;
@@ -116,6 +118,12 @@ typedef struct {
McdTransport *transport;
} TransportData;
+typedef struct {
+ gint priority;
+ McdAccountConnectionFunc func;
+ gpointer userdata;
+} McdAccountConnectionData;
+
static McdMaster *default_master = NULL;
static inline void
@@ -442,6 +450,9 @@ _mcd_master_finalize (GObject * object)
{
McdMasterPrivate *priv = MCD_MASTER_PRIV (object);
+ g_list_foreach (priv->account_connections, (GFunc)g_free, NULL);
+ g_list_free (priv->account_connections);
+
g_free (priv->awake_presence_message);
G_OBJECT_CLASS (mcd_master_parent_class)->finalize (object);
@@ -1231,3 +1242,43 @@ mcd_plugin_register_transport (McdPlugin *plugin,
g_ptr_array_add (priv->transport_plugins, transport_plugin);
}
+void
+mcd_plugin_register_account_connection (McdPlugin *plugin,
+ McdAccountConnectionFunc func,
+ gint priority,
+ gpointer userdata)
+{
+ McdMasterPrivate *priv = MCD_MASTER_PRIV (plugin);
+ McdAccountConnectionData *acd;
+ GList *list;
+
+ g_debug ("%s called", G_STRFUNC);
+ acd = g_malloc (sizeof (McdAccountConnectionData));
+ acd->priority = priority;
+ acd->func = func;
+ acd->userdata = userdata;
+ for (list = priv->account_connections; list; list = list->next)
+ if (((McdAccountConnectionData *)list->data)->priority >= priority) break;
+
+ priv->account_connections =
+ g_list_insert_before (priv->account_connections, list, acd);
+}
+
+void
+mcd_master_get_nth_account_connection (McdMaster *master, gint i,
+ McdAccountConnectionFunc *func,
+ gpointer *userdata)
+{
+ McdMasterPrivate *priv = MCD_MASTER_PRIV (master);
+ McdAccountConnectionData *acd;
+
+ acd = g_list_nth_data (priv->account_connections, i);
+ if (acd)
+ {
+ *func = acd->func;
+ *userdata = acd->userdata;
+ }
+ else
+ *func = NULL;
+}
+
diff --git a/src/mcd-master.h b/src/mcd-master.h
index 7cafec75..ce050292 100644
--- a/src/mcd-master.h
+++ b/src/mcd-master.h
@@ -42,6 +42,7 @@ typedef struct _McdMasterClass McdMasterClass;
#include <mcd-manager.h>
#include <mcd-connection.h>
+#include <mcd-connection-plugin.h>
struct _McdMaster
{
@@ -112,5 +113,9 @@ void mcd_master_add_connection_parameter (McdMaster *master, const gchar *name,
const GValue *value);
GHashTable * mcd_master_get_connection_parameters (McdMaster *master);
+void mcd_master_get_nth_account_connection (McdMaster *master, gint i,
+ McdAccountConnectionFunc *func,
+ gpointer *userdata);
+
G_END_DECLS
#endif /* MCD_MASTER_H */
diff --git a/src/mcd-plugin.h b/src/mcd-plugin.h
index 4ba6a9f3..e0cc95b7 100644
--- a/src/mcd-plugin.h
+++ b/src/mcd-plugin.h
@@ -21,13 +21,13 @@
#ifndef __MCD_PLUGIN_H__
#define __MCD_PLUGIN_H__
-#include "mcd-dispatcher.h"
-#include "mcd-transport.h"
-
G_BEGIN_DECLS
typedef struct _McdPlugin McdPlugin;
+#include "mcd-dispatcher.h"
+#include "mcd-transport.h"
+
typedef void (*McdPluginInitFunc) (McdPlugin *plugin);
#define MCD_PLUGIN_INIT_FUNC "mcd_plugin_init"