summaryrefslogtreecommitdiff
path: root/mission-control
diff options
context:
space:
mode:
authorStef Walter <stefw@collabora.co.uk>2011-03-01 17:35:41 +0100
committerStef Walter <stefw@collabora.co.uk>2011-03-01 17:54:06 +0100
commitf546d6a5754ff5e85b4132650eed7287c58edf73 (patch)
tree79f01b8d914e6dff47d6ac168e773a0e49492445 /mission-control
parent239b1643d07e069760e109dfc3150357553f699b (diff)
Initial rough mission-control ytstenut plugin.
* Advertises a single account unconditionally. * That account is hidden.
Diffstat (limited to 'mission-control')
-rw-r--r--mission-control/Makefile.am22
-rw-r--r--mission-control/mcp-account-manager-ytstenut.c264
-rw-r--r--mission-control/mcp-account-manager-ytstenut.h67
-rw-r--r--mission-control/mission-control-plugin.c51
4 files changed, 404 insertions, 0 deletions
diff --git a/mission-control/Makefile.am b/mission-control/Makefile.am
new file mode 100644
index 0000000..e74a3b8
--- /dev/null
+++ b/mission-control/Makefile.am
@@ -0,0 +1,22 @@
+AM_CFLAGS = \
+ -I$(top_srcdir) \
+ $(MISSION_CONTROL_MODULE_CFLAGS) \
+ $(TELEPATHY_GLIB_CFLAGS)
+
+pluginsdir = $(MISSION_CONTROL_PLUGINS_DIR)
+plugins_LTLIBRARIES = \
+ mcp-account-manager-ytstenut.la
+
+mcp_account_manager_ytstenut_la_SOURCES = \
+ mission-control-plugin.c \
+ mcp-account-manager-ytstenut.c mcp-account-manager-ytstenut.h
+
+mcp_account_manager_ytstenut_la_LIBADD = \
+ $(MISSION_CONTROL_MODULE_LIBS) \
+ $(TELEPATHY_GLIB_LIBS)
+
+mcp_account_manager_ytstenut_la_LDFLAGS = \
+ -module \
+ -avoid-version \
+ -no-undefined \
+ -export-symbols-regex mcp_plugin_ref_nth_object
diff --git a/mission-control/mcp-account-manager-ytstenut.c b/mission-control/mcp-account-manager-ytstenut.c
new file mode 100644
index 0000000..81d8dd6
--- /dev/null
+++ b/mission-control/mcp-account-manager-ytstenut.c
@@ -0,0 +1,264 @@
+/*
+ * mcp-account-manager-ytstenut.c
+ *
+ * McpAccountManagerYtstenut - a Mission Control plugin to create ytstenut
+ * account to Mission Control.
+ *
+ * Copyright (C) 2010-2011 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
+ * Stef Walter <stefw@collabora.co.uk>
+ */
+
+#include "config.h"
+
+#include "mcp-account-manager-ytstenut.h"
+
+#include <telepathy-glib/telepathy-glib.h>
+
+#include <glib/gi18n-lib.h>
+
+#define DEBUG g_debug
+#define PLUGIN_NAME "ytstenut"
+#define PLUGIN_PRIORITY (MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_KEYRING + 20)
+#define PLUGIN_DESCRIPTION "Provide Telepathy Accounts from ytstenut"
+#define PLUGIN_PROVIDER "com.meego.xpmn.ytstenut"
+#define YTSTENUT_ACCOUNT_NAME "salut/local-ytstenut/automatic_account"
+
+typedef struct {
+ char *key;
+ char *value;
+} Parameter;
+
+static const Parameter account_parameters[] = {
+ { "manager", "salut" },
+ { "protocol", "local-ytstenut" },
+ { "Icon", "im-facebook" },
+ { "Service", "facebook" },
+ { "ConnectAutomatically", "true" },
+ { "Hidden", "true" },
+ { "Enabled", "true" },
+};
+
+static const Parameter account_translated_parameters[] = {
+ { "DisplayName", N_("Ytstenut Messaging") },
+};
+
+static void mcp_account_manager_ytstenut_account_storage_iface_init (
+ McpAccountStorageIface *iface);
+
+G_DEFINE_TYPE_WITH_CODE (McpAccountManagerYtstenut,
+ mcp_account_manager_ytstenut, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (MCP_TYPE_ACCOUNT_STORAGE,
+ mcp_account_manager_ytstenut_account_storage_iface_init));
+
+/* -----------------------------------------------------------------------------
+ * INTERNAL
+ */
+
+static void
+account_manager_get_all_keys (const McpAccountManager *am,
+ const gchar *account)
+{
+ const Parameter *param;
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (account_parameters); i++)
+ {
+ param = &account_parameters[i];
+ DEBUG ("Loading %s = %s", param->key, param->value);
+ mcp_account_manager_set_value (am, account, param->key, param->value);
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (account_translated_parameters); i++)
+ {
+ const gchar *tvalue = gettext (param->value);
+ param = &account_translated_parameters[i];
+ DEBUG ("Loading %s = %s", param->key, tvalue);
+ mcp_account_manager_set_value (am, account, param->key, tvalue);
+ }
+}
+
+static gboolean
+account_manager_get_key (const McpAccountManager *am,
+ const gchar *account,
+ const gchar *key)
+{
+ const Parameter *param;
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (account_parameters); i++)
+ {
+ param = &account_parameters[i];
+ if (!tp_strdiff (param->key, key))
+ {
+ DEBUG ("Loading %s = %s", param->key, param->value);
+ mcp_account_manager_set_value (am, account, param->key, param->value);
+ return TRUE;
+ }
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (account_translated_parameters); i++)
+ {
+ param = &account_translated_parameters[i];
+ if (!tp_strdiff (param->key, key))
+ {
+ const gchar *tvalue = gettext (param->value);
+ DEBUG ("Loading %s = %s", param->key, tvalue);
+ mcp_account_manager_set_value (am, account, param->key, tvalue);
+ return TRUE;
+ }
+ }
+
+ return TRUE;
+}
+
+/* -----------------------------------------------------------------------------
+ * OBJECT
+ */
+
+static void
+mcp_account_manager_ytstenut_init (McpAccountManagerYtstenut *self)
+{
+ DEBUG ("Plugin initialised");
+}
+
+static void
+mcp_account_manager_ytstenut_class_init (McpAccountManagerYtstenutClass *klass)
+{
+
+}
+
+static gboolean
+mcp_account_manager_ytstenut_get (const McpAccountStorage *storage,
+ const McpAccountManager *manager,
+ const gchar *account,
+ const gchar *key)
+{
+ DEBUG ("%s: %s, %s", G_STRFUNC, account, key);
+
+ if (tp_strdiff (account, YTSTENUT_ACCOUNT_NAME))
+ return FALSE;
+
+ if (key == NULL)
+ {
+ account_manager_get_all_keys (manager, account);
+ return TRUE;
+ }
+ else
+ {
+ return account_manager_get_key (manager, account, key);
+ }
+}
+
+static gboolean
+mcp_account_manager_ytstenut_set (const McpAccountStorage *storage,
+ const McpAccountManager * manager,
+ const gchar *account,
+ const gchar *key,
+ const gchar *val)
+{
+ DEBUG ("%s: (%s, %s, %s)", G_STRFUNC, account, key, val);
+
+ if (tp_strdiff (account, YTSTENUT_ACCOUNT_NAME))
+ return FALSE;
+
+ /*
+ * TODO: Just pretend we saved. Is this really what we want to do here?
+ * I copied the behavior from meego-facebook-plugins.
+ */
+ return TRUE;
+}
+
+static GList *
+mcp_account_manager_ytstenut_list (const McpAccountStorage *storage,
+ const McpAccountManager *manager)
+{
+ DEBUG (G_STRFUNC);
+ return g_list_prepend (NULL, g_strdup (YTSTENUT_ACCOUNT_NAME));
+}
+
+static gboolean
+mcp_account_manager_ytstenut_delete (const McpAccountStorage *storage,
+ const McpAccountManager *manager,
+ const gchar *account,
+ const gchar *key)
+{
+ DEBUG ("%s: (%s, %s)", G_STRFUNC, account, key);
+
+ if (tp_strdiff (account, YTSTENUT_ACCOUNT_NAME))
+ return FALSE;
+
+ /*
+ * TODO: Just pretend we deleted. Is this really what we want to do here?
+ * I copied the behavior from meego-facebook-plugins.
+ */
+ return TRUE;
+}
+
+static gboolean
+mcp_account_manager_ytstenut_commit (const McpAccountStorage *storage,
+ const McpAccountManager *manager)
+{
+ DEBUG ("%s", G_STRFUNC);
+ return TRUE;
+}
+
+static void
+mcp_account_manager_ytstenut_ready (const McpAccountStorage *storage,
+ const McpAccountManager *manager)
+{
+ McpAccountManagerYtstenut *self = MCP_ACCOUNT_MANAGER_YTSTENUT (storage);
+ DEBUG (G_STRFUNC);
+ g_signal_emit_by_name (self, "created", YTSTENUT_ACCOUNT_NAME);
+}
+
+static guint
+mcp_account_manager_ytstenut_get_restrictions (const McpAccountStorage *storage,
+ const gchar *account)
+{
+ if (tp_strdiff (account, YTSTENUT_ACCOUNT_NAME))
+ return 0;
+
+ return TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_PARAMETERS |
+ TP_STORAGE_RESTRICTION_FLAG_CANNOT_SET_SERVICE;
+}
+
+static void
+mcp_account_manager_ytstenut_account_storage_iface_init (
+ McpAccountStorageIface *iface)
+{
+ mcp_account_storage_iface_set_name (iface, PLUGIN_NAME);
+ mcp_account_storage_iface_set_desc (iface, PLUGIN_DESCRIPTION);
+ mcp_account_storage_iface_set_priority (iface, PLUGIN_PRIORITY);
+ mcp_account_storage_iface_set_provider (iface, PLUGIN_PROVIDER);
+
+ mcp_account_storage_iface_implement_get (iface,
+ mcp_account_manager_ytstenut_get);
+ mcp_account_storage_iface_implement_list (iface,
+ mcp_account_manager_ytstenut_list);
+ mcp_account_storage_iface_implement_set (iface,
+ mcp_account_manager_ytstenut_set);
+ mcp_account_storage_iface_implement_delete (iface,
+ mcp_account_manager_ytstenut_delete);
+ mcp_account_storage_iface_implement_commit (iface,
+ mcp_account_manager_ytstenut_commit);
+ mcp_account_storage_iface_implement_ready (iface,
+ mcp_account_manager_ytstenut_ready);
+ mcp_account_storage_iface_implement_get_restrictions (iface,
+ mcp_account_manager_ytstenut_get_restrictions);
+}
diff --git a/mission-control/mcp-account-manager-ytstenut.h b/mission-control/mcp-account-manager-ytstenut.h
new file mode 100644
index 0000000..da26ea1
--- /dev/null
+++ b/mission-control/mcp-account-manager-ytstenut.h
@@ -0,0 +1,67 @@
+/*
+ * mcp-account-manager-ytstenut.h
+ *
+ * McpAccountManagerYtstenut - a Mission Control plugin to create ytstenut
+ * account to Mission Control.
+ *
+ * Copyright (C) 2010-2011 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
+ * Stef Walter <stefw@collabora.co.uk>
+ */
+
+#include <mission-control-plugins/mission-control-plugins.h>
+
+#ifndef __MCP_ACCOUNT_MANAGER_YTSTENUT_H__
+#define __MCP_ACCOUNT_MANAGER_YTSTENUT_H__
+
+G_BEGIN_DECLS
+
+#define MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT \
+ (mcp_account_manager_ytstenut_get_type ())
+#define MCP_ACCOUNT_MANAGER_YTSTENUT(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST ((obj), MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT, \
+ McpAccountManagerYtstenut))
+#define MCP_ACCOUNT_MANAGER_YTSTENUT_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_CAST ((obj), MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT, \
+ McpAccountManagerYtstenutClass))
+#define MCP_IS_ACCOUNT_MANAGER_YTSTENUT(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT))
+#define MCP_IS_ACCOUNT_MANAGER_YTSTENUT_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE ((obj), MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT))
+#define MCP_ACCOUNT_MANAGER_YTSTENUT_GET_CLASS(obj) \
+ (G_TYPE_INSTANCE_GET_CLASS ((obj), MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT, \
+ McpAccountManagerYtstenutClass))
+
+typedef struct _McpAccountManagerYtstenut McpAccountManagerYtstenut;
+typedef struct _McpAccountManagerYtstenutClass McpAccountManagerYtstenutClass;
+
+struct _McpAccountManagerYtstenut
+{
+ GObject parent;
+};
+
+struct _McpAccountManagerYtstenutClass
+{
+ GObjectClass parent_class;
+};
+
+GType mcp_account_manager_ytstenut_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/mission-control/mission-control-plugin.c b/mission-control/mission-control-plugin.c
new file mode 100644
index 0000000..22b1c1e
--- /dev/null
+++ b/mission-control/mission-control-plugin.c
@@ -0,0 +1,51 @@
+/*
+ * mission-control-plugin.c
+ *
+ * A Mission Control plugin to expose ytstenut account to Mission Control
+ *
+ * Copyright (C) 2010-2011 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Danielle Madeley <danielle.madeley@collabora.co.uk>
+ * Stef Walter <danielle.madeley@collabora.co.uk>
+ */
+
+#include <mission-control-plugins/mission-control-plugins.h>
+
+#include "mcp-account-manager-ytstenut.h"
+
+GObject *
+mcp_plugin_ref_nth_object (guint n)
+{
+ static void *plugin_0 = NULL;
+
+ if (plugin_0 == NULL)
+ plugin_0 = g_object_new (MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT, NULL);
+
+ switch (n)
+ {
+ case 0:
+ if (plugin_0 == NULL)
+ plugin_0 = g_object_new (MCP_TYPE_ACCOUNT_MANAGER_YTSTENUT, NULL);
+ else
+ g_object_ref (plugin_0);
+
+ return plugin_0;
+
+ default:
+ return NULL;
+ }
+}