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 / HostsConfig.pm < prev    next >
Encoding:
Perl POD Document  |  2006-08-14  |  2.4 KB  |  83 lines

  1. #-*- Mode: perl; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  
  3. # DBus object for the Hosts location config
  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 HostsConfig;
  24.  
  25. use base qw(Net::DBus::Object);
  26. use Net::DBus::Exporter ($Utils::Backend::DBUS_PREFIX);
  27. use Network::Hosts;
  28.  
  29. my $OBJECT_NAME = "HostsConfig";
  30. my $OBJECT_PATH = "$Utils::Backend::DBUS_PATH/$OBJECT_NAME";
  31.  
  32. sub new
  33. {
  34.   my $class   = shift;
  35.   my $service = shift;
  36.   my $self    = $class->SUPER::new ($service, $OBJECT_PATH);
  37.  
  38.   bless $self, $class;
  39.  
  40. #  Utils::Monitor::monitor_files (&Users::Groups::get_files (),
  41. #                                 $self, $OBJECT_NAME, "changed");
  42.  
  43.   return $self;
  44. }
  45.  
  46. dbus_method ("get", [],
  47.              [ "string", "string", 
  48.                [ "array", [ "struct", "string", [ "array", "string" ]]],
  49.                [ "array", "string" ],
  50.                [ "array", "string" ]]);
  51. dbus_method ("set",
  52.              [ "string", "string",
  53.                [ "array", [ "struct", "string", [ "array", "string" ]]],
  54.                [ "array", "string" ],
  55.                [ "array", "string" ]], []);
  56.  
  57. dbus_signal ("changed", []);
  58.  
  59. sub get
  60. {
  61.   my ($self) = @_;
  62.   my ($hostname, $domainname);
  63.  
  64.   ($hostname, $domainname) = Network::Hosts::get_fqdn ();
  65.  
  66.   return ($hostname, $domainname,
  67.           Network::Hosts::get_hosts (),
  68.           Network::Hosts::get_dns (),
  69.           Network::Hosts::get_search_domains ());
  70. }
  71.  
  72. sub set
  73. {
  74.   my ($self, @config) = @_;
  75.  
  76.   Network::Hosts::set_hosts ($config[2], $config[0], $config[1]);
  77.   Network::Hosts::set_dns ($config[3]);
  78.   Network::Hosts::set_search_domains ($config[4]);
  79.   Network::Hosts::set_fqdn ($config[0], $config[1]);
  80. }
  81.  
  82. 1;
  83.