home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / system-tools-backends-2.0 / scripts / GroupsConfig.pm next >
Encoding:
Perl POD Document  |  2006-08-14  |  2.0 KB  |  70 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # DBus object for the Groups list
  4. #
  5. # Copyright (C) 2005 Carlos Garnacho
  6. #
  7. # Authors: Carlos Garnacho Parro  <carlosg@gnome.org>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Library General Public License as published
  11. # by the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. # GNU Library General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU Library General Public License
  20. # along with this program; if not, write to the Free Software
  21. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23. package GroupsConfig;
  24.  
  25. use base qw(Net::DBus::Object);
  26. use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX);
  27. use Utils::Backend;
  28. use Users::Groups;
  29. use Users::Users;
  30.  
  31. my $OBJECT_NAME = "GroupsConfig";
  32. my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME";
  33.  
  34. sub new
  35. {
  36.   my $class   = shift;
  37.   my $service = shift;
  38.   my $self    = $class->SUPER::new ($service, $OBJECT_PATH);
  39.  
  40.   bless $self, $class;
  41.  
  42.   Utils::Monitor::monitor_files (&Users::Groups::get_files (),
  43.                                  $self, $OBJECT_NAME, "changed");
  44.   return $self;
  45. }
  46.  
  47. dbus_method ("get", [], [[ "array", [ "struct", "string", "string", "int32", [ "array", "string" ]]], "int32", "int32" ]);
  48. dbus_method ("set", [[ "array", [ "struct", "string", "string", "int32", [ "array", "string" ]]], "int32", "int32" ], []);
  49. dbus_signal ("changed", []);
  50.  
  51. sub get
  52. {
  53.   my ($self) = @_;
  54.   my $groups, $logindefs;
  55.  
  56.   $groups = Users::Groups::get ();
  57.   $logindefs = &Users::Users::get_logindefs ();
  58.  
  59.   return ($groups, $$logindefs{"gmin"}, $$logindefs{"gmax"});
  60. }
  61.  
  62. sub set
  63. {
  64.   my ($self, $config) = @_;
  65.  
  66.   Users::Groups::set ($config);
  67. }
  68.  
  69. 1;
  70.