[Xfce4-commits] [xfce/xfce4-power-manager] 03/03: Remove disk spin down feature (3/3)

noreply at xfce.org noreply at xfce.org
Mon Jul 14 16:30:18 CEST 2014


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository xfce/xfce4-power-manager.

commit dc6ef998a2f19b6c2fcbfb48164db04be44c885d
Author: Harald Judt <h.judt at gmx.at>
Date:   Sun Jul 13 21:34:22 2014 +0200

    Remove disk spin down feature (3/3)
    
    Finally, let's remove the low-level code and remaining definitions.
---
 src/Makefile.am   |    2 -
 src/xfpm-config.h |    5 -
 src/xfpm-disks.c  |  289 -----------------------------------------------------
 src/xfpm-disks.h  |   57 -----------
 4 files changed, 353 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index ed59ec9..c758a03 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,8 +12,6 @@ xfce4_power_manager_SOURCES =                   \
 	xfpm-battery.h				\
 	xfpm-xfconf.c				\
 	xfpm-xfconf.h				\
-	xfpm-disks.c				\
-	xfpm-disks.h				\
 	xfpm-console-kit.c			\
 	xfpm-console-kit.h			\
 	xfpm-systemd.c				\
diff --git a/src/xfpm-config.h b/src/xfpm-config.h
index a931c17..104d415 100644
--- a/src/xfpm-config.h
+++ b/src/xfpm-config.h
@@ -79,11 +79,6 @@ G_BEGIN_DECLS
 #define 	LID_SWITCH_ON_AC_CFG        	"lid-action-on-ac"
 #define 	LID_SWITCH_ON_BATTERY_CFG   	"lid-action-on-battery"
 
-#define         SPIN_DOWN_HDD			"spin-down-hdd"
-
-#define         SPIN_DOWN_ON_AC_TIMEOUT		"spin-down-on-ac-timeout"
-#define         SPIN_DOWN_ON_BATTERY_TIMEOUT	"spin-down-on-battery-timeout"
-
 #define         NETWORK_MANAGER_SLEEP           "network-manager-sleep"
 
 #define     LOGIND_HANDLE_POWER_KEY     "logind-handle-power-key"
diff --git a/src/xfpm-disks.c b/src/xfpm-disks.c
deleted file mode 100644
index f68e713..0000000
--- a/src/xfpm-disks.c
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-#include <dbus/dbus-glib.h>
-
-#include "xfpm-disks.h"
-#include "xfpm-polkit.h"
-#include "xfpm-xfconf.h"
-#include "xfpm-power.h"
-#include "xfpm-config.h"
-#include "xfpm-debug.h"
-
-static void xfpm_disks_finalize   (GObject *object);
-
-#define XFPM_DISKS_GET_PRIVATE(o) \
-(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFPM_TYPE_DISKS, XfpmDisksPrivate))
-
-struct XfpmDisksPrivate
-{
-    XfpmXfconf      *conf;
-    XfpmPower       *power;
-    XfpmPolkit      *polkit;
-    
-    DBusGConnection *bus;
-    DBusGProxy      *proxy;
-    gchar           *cookie;
-    gboolean         set;
-    gboolean         can_spin;
-};
-
-G_DEFINE_TYPE (XfpmDisks, xfpm_disks, G_TYPE_OBJECT)
-
-static void
-xfpm_disks_class_init (XfpmDisksClass *klass)
-{
-    GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-    object_class->finalize = xfpm_disks_finalize;
-
-    g_type_class_add_private (klass, sizeof (XfpmDisksPrivate));
-}
-
-static void
-xfpm_disks_disable_spin_down_timeouts (XfpmDisks *disks)
-{
-    GError *error = NULL;
-    
-    disks->priv->set = FALSE;
-    
-    XFPM_DEBUG ("Clearing spin down timeout");
-    
-    dbus_g_proxy_call (disks->priv->proxy, "DriveUnsetAllSpindownTimeouts", &error,
-		       G_TYPE_STRING, disks->priv->cookie,
-		       G_TYPE_INVALID,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("Failed to unset spindown timeouts : %s", error->message);
-	g_error_free (error);
-	disks->priv->set = TRUE;
-    }
-    
-    g_free (disks->priv->cookie);
-    disks->priv->cookie = NULL;
-}
-
-static void
-xfpm_disks_enable_spin_down_timeouts (XfpmDisks *disks, gint timeout)
-{
-    GError *error = NULL;
-    const gchar **options = { NULL };
-    
-    disks->priv->set = TRUE;
-    
-    XFPM_DEBUG ("Setting spin down timeout %d", timeout);
-    
-    dbus_g_proxy_call (disks->priv->proxy, "DriveSetAllSpindownTimeouts", &error,
-		       G_TYPE_INT, timeout,
-		       G_TYPE_STRV, options,
-		       G_TYPE_INVALID,
-		       G_TYPE_STRING, &disks->priv->cookie,
-		       G_TYPE_INVALID);
-		       
-    if ( error )
-    {
-	g_warning ("Failed to set spindown timeouts : %s", error->message);
-	g_error_free (error);
-	disks->priv->set = FALSE;
-    }
-}
-
-static void
-xfpm_disks_set_spin_timeouts (XfpmDisks *disks)
-{
-    gboolean enabled = FALSE;
-    gboolean on_battery;
-    gint timeout = 0;
-    gint value = 0;
-    
-    if (!disks->priv->can_spin )
-	return;
-    
-    g_object_get (G_OBJECT (disks->priv->power),
-		  "on-battery", &on_battery,
-		  NULL);
-
-    if ( !on_battery )
-    {
-	g_object_get (G_OBJECT (disks->priv->conf),
-		      SPIN_DOWN_HDD, &value,
-		      SPIN_DOWN_ON_AC_TIMEOUT, &timeout,
-		      NULL);
-	if ( value == SPIN_DOWN_HDD_PLUGGED_IN || value == SPIN_DOWN_HDD_ALWAYS )
-	{
-		enabled = TRUE;
-	}
-    }
-    else
-    {
-	g_object_get (G_OBJECT (disks->priv->conf),
-		      SPIN_DOWN_HDD, &value,
-		      SPIN_DOWN_ON_BATTERY_TIMEOUT, &timeout,
-		      NULL);
-	if ( value == SPIN_DOWN_HDD_ON_BATTERY || value == SPIN_DOWN_HDD_ALWAYS )
-	{
-		enabled = TRUE;
-	}
-    }
-    
-    XFPM_DEBUG ("On Battery=%d spin_down_enabled=%d timeout=%d\n", on_battery, enabled, timeout);
-    
-    if ( !enabled )
-    {
-	if ( disks->priv->set && disks->priv->cookie )
-	    xfpm_disks_disable_spin_down_timeouts (disks);
-    }
-    else if ( timeout != 0 && timeout > 120 && !disks->priv->set)
-    {
-	xfpm_disks_enable_spin_down_timeouts (disks, timeout);
-    }
-}
-
-static void
-xfpm_disks_get_is_auth_to_spin (XfpmDisks *disks)
-{
-    const gchar *action_id;
-
-    action_id = "org.freedesktop.udisks.drive-set-spindown";
-
-    disks->priv->can_spin = xfpm_polkit_check_auth (disks->priv->polkit, 
-						    action_id);
-						    
-    XFPM_DEBUG ("Is auth to spin down disks : %d", disks->priv->can_spin);
-}
-
-static void
-xfpm_disks_init (XfpmDisks *disks)
-{
-    GError *error = NULL;
-    
-    disks->priv = XFPM_DISKS_GET_PRIVATE (disks);
-    
-    disks->priv->can_spin = FALSE;
-    disks->priv->bus    = NULL;
-    disks->priv->proxy  = NULL;
-    disks->priv->conf   = NULL;
-    disks->priv->power  = NULL;
-    disks->priv->cookie = NULL;
-    disks->priv->polkit = NULL;
-
-    
-    disks->priv->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
-    
-    if ( error )
-    {
-	g_critical ("Unable to get system bus connection : %s", error->message);
-	g_error_free (error);
-	goto out;
-    }
-
-    disks->priv->proxy = dbus_g_proxy_new_for_name (disks->priv->bus,
-						    "org.freedesktop.UDisks",
-						    "/org/freedesktop/UDisks",
-						    "org.freedesktop.UDisks");
-    
-
-    disks->priv->conf = xfpm_xfconf_new ();
-    disks->priv->power  = xfpm_power_get ();
-    disks->priv->polkit = xfpm_polkit_get ();
-
-    xfpm_disks_get_is_auth_to_spin (disks);
-    
-    g_signal_connect_swapped (disks->priv->polkit, "auth-changed",
-			      G_CALLBACK (xfpm_disks_get_is_auth_to_spin), disks);
-
-    g_signal_connect_swapped (disks->priv->power, "on-battery-changed",
-			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
-
-    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_HDD,
-			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
-			
-    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_AC_TIMEOUT,
-			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
-    
-    g_signal_connect_swapped (disks->priv->conf, "notify::" SPIN_DOWN_ON_BATTERY_TIMEOUT,
-			      G_CALLBACK (xfpm_disks_set_spin_timeouts), disks);
-			      
-    xfpm_disks_set_spin_timeouts (disks);
-    
-out:
-    ;
-
-}
-
-static void
-xfpm_disks_finalize (GObject *object)
-{
-    XfpmDisks *disks;
-
-    disks = XFPM_DISKS (object);
-
-    if (disks->priv->can_spin && disks->priv->set )
-	xfpm_disks_disable_spin_down_timeouts (disks);
-    
-    if ( disks->priv->bus )
-	dbus_g_connection_unref (disks->priv->bus);
-	
-    if ( disks->priv->proxy )
-	g_object_unref (disks->priv->proxy);
-	
-    if ( disks->priv->polkit )
-	g_object_unref (disks->priv->polkit);
-	
-    if ( disks->priv->conf )
-	g_object_unref (disks->priv->conf);
-	
-    if ( disks->priv->power )
-	g_object_unref (disks->priv->power );
-
-    G_OBJECT_CLASS (xfpm_disks_parent_class)->finalize (object);
-}
-
-XfpmDisks *
-xfpm_disks_new (void)
-{
-    XfpmDisks *disks = NULL;
-    disks = g_object_new (XFPM_TYPE_DISKS, NULL);
-    return disks;
-}
-
-gboolean xfpm_disks_get_can_spin (XfpmDisks *disks)
-{
-    return disks->priv->can_spin;
-}
-
-gboolean xfpm_disks_kit_is_running (XfpmDisks *disks)
-{
-    return disks->priv->proxy != NULL ? TRUE : FALSE;
-}
diff --git a/src/xfpm-disks.h b/src/xfpm-disks.h
deleted file mode 100644
index e28d902..0000000
--- a/src/xfpm-disks.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * * Copyright (C) 2009-2011 Ali <aliov at xfce.org>
- *
- * Licensed under the GNU General Public License Version 2
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __XFPM_DISKS_H
-#define __XFPM_DISKS_H
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define XFPM_TYPE_DISKS        (xfpm_disks_get_type () )
-#define XFPM_DISKS(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), XFPM_TYPE_DISKS, XfpmDisks))
-#define XFPM_IS_DISKS(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), XFPM_TYPE_DISKS))
-
-typedef struct XfpmDisksPrivate XfpmDisksPrivate;
-
-typedef struct
-{
-    GObject         	  parent;
-    XfpmDisksPrivate     *priv;
-    
-} XfpmDisks;
-
-typedef struct
-{
-    GObjectClass 	  parent_class;
-    
-} XfpmDisksClass;
-
-GType        		  xfpm_disks_get_type        (void) G_GNUC_CONST;
-
-XfpmDisks                *xfpm_disks_new             (void);
-
-gboolean		  xfpm_disks_get_can_spin    (XfpmDisks *disks);
-
-gboolean		  xfpm_disks_kit_is_running  (XfpmDisks *disks);
-
-G_END_DECLS
-
-#endif /* __XFPM_DISKS_H */

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list