summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-08 13:47:12 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-08 17:40:19 +0100
commit33987d0226e04381a1bda79bdfeadfc815943e53 (patch)
treeaada710dee11a6d8d621815e96b20982d4a3a2d8
parentd78e084fbfaaeafc4085284febbc0925cd4b25aa (diff)
Remove McdController and inline its shutdown method into McdMaster
-rw-r--r--src/Makefile.am2
-rw-r--r--src/mcd-controller.c141
-rw-r--r--src/mcd-controller.h63
-rw-r--r--src/mcd-master.c51
-rw-r--r--src/mcd-master.h6
-rw-r--r--src/mcd-service.c2
6 files changed, 51 insertions, 214 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 7c2ac16c..f9c8eeca 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,6 @@ mc_headers = \
mcd-mission.h \
mcd-operation.h \
mcd-master.h \
- mcd-controller.h \
mcd-manager.h \
mcd-connection.h \
mcd-connection-plugin.h \
@@ -148,7 +147,6 @@ libmcd_convenience_la_SOURCES = \
mcd-mission.c \
mcd-mission-priv.h \
mcd-operation.c \
- mcd-controller.c \
mcd-master.c \
mcd-master-priv.h \
mcd-manager.c \
diff --git a/src/mcd-controller.c b/src/mcd-controller.c
deleted file mode 100644
index 149cab5e..00000000
--- a/src/mcd-controller.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* vi: set et sw=4 ts=8 cino=t0,(0: */
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/*
- * This file is part of mission-control
- *
- * Copyright (C) 2007-2009 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
- *
- */
-
-/**
- * SECTION:mcd-controller
- * @title: McdController
- * @short_description: Server controller class
- * @see_also:
- * @stability: Unstable
- * @include: mcd-controller.h
- *
- * This class implements the logic to control mission-control based on all
- * external device events and states. It also controls mission-control
- * life-cycle based on such events.
- */
-
-#include "config.h"
-
-#include "mcd-controller.h"
-
-/* Milliseconds to wait for Connectivity coming back up before exiting MC */
-#define EXIT_COUNTDOWN_TIME 5000
-
-#define MCD_CONTROLLER_PRIV(controller) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((controller), \
- MCD_TYPE_CONTROLLER, \
- McdControllerPrivate))
-
-G_DEFINE_TYPE (McdController, mcd_controller, MCD_TYPE_OPERATION);
-
-/* Private */
-typedef struct _McdControllerPrivate
-{
- /* Current pending sleep timer */
- gint shutdown_timeout_id;
-
- gboolean is_disposed;
-} McdControllerPrivate;
-
-static void
-mcd_controller_class_init (McdControllerClass * klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- g_type_class_add_private (object_class, sizeof (McdControllerPrivate));
-}
-
-static void
-mcd_controller_init (McdController * obj)
-{
-}
-
-/* Public */
-
-McdController *
-mcd_controller_new ()
-{
- McdController *obj;
- obj = MCD_CONTROLLER (g_object_new (MCD_TYPE_CONTROLLER, NULL));
- return obj;
-}
-
-static gboolean
-_mcd_controller_exit_by_timeout (gpointer data)
-{
- McdController *controller;
- McdControllerPrivate *priv;
-
- controller = MCD_CONTROLLER (data);
- priv = MCD_CONTROLLER_PRIV (controller);
-
- priv->shutdown_timeout_id = 0;
-
- /* Notify sucide */
- mcd_mission_abort (MCD_MISSION (controller));
-
- return FALSE;
-}
-
-void
-mcd_controller_shutdown (McdController *controller, const gchar *reason)
-{
- McdControllerPrivate *priv;
-
- g_return_if_fail (MCD_IS_CONTROLLER (controller));
- priv = MCD_CONTROLLER_PRIV (controller);
-
- if(!priv->shutdown_timeout_id)
- {
- DEBUG ("MC will bail out because of \"%s\" out exit after %i",
- reason ? reason : "No reason specified",
- EXIT_COUNTDOWN_TIME);
-
- priv->shutdown_timeout_id = g_timeout_add (EXIT_COUNTDOWN_TIME,
- _mcd_controller_exit_by_timeout,
- controller);
- }
- else
- {
- DEBUG ("Already shutting down. This one has the reason %s",
- reason ? reason:"No reason specified");
- }
- mcd_debug_print_tree (controller);
-}
-
-void
-mcd_controller_cancel_shutdown (McdController *controller)
-{
- McdControllerPrivate *priv;
-
- g_return_if_fail (MCD_IS_CONTROLLER (controller));
- priv = MCD_CONTROLLER_PRIV (controller);
-
- if (priv->shutdown_timeout_id)
- {
- DEBUG ("Cancelling exit timeout");
- g_source_remove (priv->shutdown_timeout_id);
- priv->shutdown_timeout_id = 0;
- }
-}
diff --git a/src/mcd-controller.h b/src/mcd-controller.h
deleted file mode 100644
index 73b25b5f..00000000
--- a/src/mcd-controller.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* vi: set et sw=4 ts=8 cino=t0,(0: */
-/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 8 -*- */
-/*
- * 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_CONTROLLER_H
-#define MCD_CONTROLLER_H
-
-#include <glib.h>
-#include <glib-object.h>
-
-#include "mcd-operation.h"
-
-G_BEGIN_DECLS
-
-#define MCD_TYPE_CONTROLLER (mcd_controller_get_type ())
-#define MCD_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MCD_TYPE_CONTROLLER, McdController))
-#define MCD_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), MCD_TYPE_CONTROLLER, McdControllerClass))
-#define MCD_IS_CONTROLLER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MCD_TYPE_CONTROLLER))
-#define MCD_IS_CONTROLLER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MCD_TYPE_CONTROLLER))
-#define MCD_CONTROLLER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MCD_TYPE_CONTROLLER, McdControllerClass))
-
-typedef struct _McdController McdController;
-typedef struct _McdControllerClass McdControllerClass;
-
-struct _McdController
-{
- McdOperation parent;
-};
-
-struct _McdControllerClass
-{
- McdOperationClass parent_class;
-};
-
-GType mcd_controller_get_type (void);
-McdController *mcd_controller_new (void);
-void mcd_controller_shutdown (McdController *controller, const gchar *reason);
-void mcd_controller_cancel_shutdown (McdController *controller);
-
-G_END_DECLS
-
-#endif /* MCD_CONTROLLER_H */
diff --git a/src/mcd-master.c b/src/mcd-master.c
index c9c6e2b8..1b02cc6c 100644
--- a/src/mcd-master.c
+++ b/src/mcd-master.c
@@ -43,9 +43,6 @@
* It is basically a container for all McdManager objects and
* takes care of their management. It also takes care of sleep and awake
* cycles (e.g. translates to auto away somewhere down the hierarchy).
- *
- * McdMaster is a subclass of McdConroller, which essentially means it
- * is subject to all device control.
*/
#include <config.h>
@@ -86,7 +83,7 @@
MCD_TYPE_MASTER, \
McdMasterPrivate))
-G_DEFINE_TYPE (McdMaster, mcd_master, MCD_TYPE_CONTROLLER);
+G_DEFINE_TYPE (McdMaster, mcd_master, MCD_TYPE_OPERATION);
typedef struct _McdMasterPrivate
{
@@ -101,6 +98,9 @@ typedef struct _McdMasterPrivate
GPtrArray *transport_plugins;
GList *account_connections;
+ /* Current pending sleep timer */
+ gint shutdown_timeout_id;
+
gboolean is_disposed;
gboolean low_memory;
gboolean idle;
@@ -697,3 +697,46 @@ _mcd_master_account_replace_transport (McdMaster *master,
g_hash_table_unref (conditions);
return connected;
}
+
+/* Milliseconds to wait for Connectivity coming back up before exiting MC */
+#define EXIT_COUNTDOWN_TIME 5000
+
+static gboolean
+_mcd_master_exit_by_timeout (gpointer data)
+{
+ McdMaster *self = MCD_MASTER (data);
+ McdMasterPrivate *priv = MCD_MASTER_PRIV (self);
+
+ priv->shutdown_timeout_id = 0;
+
+ /* Notify sucide */
+ mcd_mission_abort (MCD_MISSION (self));
+ return FALSE;
+}
+
+void
+mcd_master_shutdown (McdMaster *self,
+ const gchar *reason)
+{
+ McdMasterPrivate *priv;
+
+ g_return_if_fail (MCD_IS_MASTER (self));
+ priv = MCD_MASTER_PRIV (self);
+
+ if(!priv->shutdown_timeout_id)
+ {
+ DEBUG ("MC will bail out because of \"%s\" out exit after %i",
+ reason ? reason : "No reason specified",
+ EXIT_COUNTDOWN_TIME);
+
+ priv->shutdown_timeout_id = g_timeout_add (EXIT_COUNTDOWN_TIME,
+ _mcd_master_exit_by_timeout,
+ self);
+ }
+ else
+ {
+ DEBUG ("Already shutting down. This one has the reason %s",
+ reason ? reason : "No reason specified");
+ }
+ mcd_debug_print_tree (self);
+}
diff --git a/src/mcd-master.h b/src/mcd-master.h
index 6223fb15..f207af71 100644
--- a/src/mcd-master.h
+++ b/src/mcd-master.h
@@ -28,7 +28,6 @@
#include <glib.h>
#include <glib-object.h>
-#include "mcd-controller.h"
G_BEGIN_DECLS
#define MCD_TYPE_MASTER (mcd_master_get_type ())
@@ -47,12 +46,12 @@ typedef struct _McdMasterClass McdMasterClass;
struct _McdMaster
{
- McdController parent;
+ McdOperation parent;
};
struct _McdMasterClass
{
- McdControllerClass parent_class;
+ McdOperationClass parent_class;
McdManager *(*create_manager) (McdMaster *master,
const gchar *unique_name);
void (*_mc_reserved1) (void);
@@ -68,6 +67,7 @@ McdMaster *mcd_master_get_default (void);
McdDispatcher *mcd_master_get_dispatcher (McdMaster *master);
TpDBusDaemon *mcd_master_get_dbus_daemon (McdMaster *master);
+void mcd_master_shutdown (McdMaster *self, const gchar *reason);
G_END_DECLS
#endif /* MCD_MASTER_H */
diff --git a/src/mcd-service.c b/src/mcd-service.c
index 581befff..46f708e9 100644
--- a/src/mcd-service.c
+++ b/src/mcd-service.c
@@ -99,7 +99,7 @@ static void
mcd_service_disconnect (McdMission *mission)
{
MCD_MISSION_CLASS (mcd_service_parent_class)->disconnect (mission);
- mcd_controller_shutdown (MCD_CONTROLLER (mission), "Disconnected");
+ mcd_master_shutdown (MCD_MASTER (mission), "Disconnected");
}
static void