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

intrigeri pushed a commit to branch experimental
in repository libnet-dbus-perl.

commit 7e279a2df4ca4590e81652ef8e109aa4dcf058bf
Author: Daniel P. Berrange <d...@berrange.com>
Date:   Wed Aug 10 19:26:29 2005 +0000

    Remove direct use of internal variables. Added "find" constructor to 
auto-magic determine session/system bus connection. Added convenience method 
for creating a service.
---
 lib/Net/DBus.pm | 45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/lib/Net/DBus.pm b/lib/Net/DBus.pm
index 2db7793..081254f 100644
--- a/lib/Net/DBus.pm
+++ b/lib/Net/DBus.pm
@@ -16,46 +16,51 @@ XSLoader::load('Net::DBus', $VERSION);
 use Net::DBus::Binding::Bus;
 use Net::DBus::Binding::Message;
 use Net::DBus::Binding::Value;
+use Net::DBus::Service;
 use Net::DBus::RemoteService;
 
 
+sub find {
+    my $class = shift;
+    
+    if (exists $ENV{DBUS_SESSION_BUS_ADDRESS} ||
+       (exists $ENV{DBUS_STARTER_BUS_TYPE} && 
+        $ENV{DBUS_STARTER_BUS_TYPE} eq "session")) {
+       return $class->session;
+    } elsif (exists $ENV{DBUS_SYSTEM_BUS_ADDRESS} ||
+            (exists $ENV{DBUS_STARTER_BUS_TYPE} && 
+             $ENV{DBUS_STARTER_BUS_TYPE} eq "system")) {
+       return $class->system;
+    } else {
+       return $class->system;
+    }
+}
 
 sub system {
     my $class = shift;
-    return $class->_new(&Net::DBus::Binding::Bus::SYSTEM);
+    return $class->_new(Net::DBus::Binding::Bus->new(type => 
&Net::DBus::Binding::Bus::SYSTEM));
 }
 
 sub session {
     my $class = shift;
-    return $class->_new(&Net::DBus::Binding::Bus::SESSION);
+    return $class->_new(Net::DBus::Binding::Bus->new(type => 
&Net::DBus::Binding::Bus::SESSION));
 }
 
-
-sub connection {
+sub new {
     my $class = shift;
-
-    my $self = {};
-    
-    $self->{connection} = Net::DBus::Binding::Bus->new(address => shift);
-    $self->{signals} = {};
-    
-    bless $self, $class;
-
-    $self->{connection}->add_filter(sub { $self->_signal_func(@_) });
-    
-    return $self;
+    return $class->_new(Net::DBus::Binding::Bus->new(address => shift));
 }
 
 sub _new {
     my $class = shift;
     my $self = {};
     
-    $self->{connection} = Net::DBus::Binding::Bus->new(type => shift);
+    $self->{connection} = shift;
     $self->{signals} = {};
     
     bless $self, $class;
 
-    $self->{connection}->add_filter(sub { $self->_signal_func(@_) });
+    $self->get_connection->add_filter(sub { $self->_signal_func(@_) });
     
     return $self;
 }
@@ -72,6 +77,12 @@ sub get_service {
     return Net::DBus::RemoteService->new($self, $name);
 }
 
+sub export_service {
+    my $self = shift;
+    my $name = shift;
+    return Net::DBus::Service->new($self, $name);
+}
+
 sub add_signal_receiver {
     my $self = shift;
     my $receiver = shift;

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-perl/packages/libnet-dbus-perl.git

_______________________________________________
Pkg-perl-cvs-commits mailing list
Pkg-perl-cvs-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits

Reply via email to