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 / UsersConfig.pm < prev   
Encoding:
Perl POD Document  |  2006-08-14  |  2.8 KB  |  85 lines

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