diff options
author | Olivier Blin <oblin@mandriva.com> | 2009-02-25 16:00:32 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2009-02-25 16:00:32 +0000 |
commit | bf76817d1333bbe66954fd59191a723d0f233409 (patch) | |
tree | c725e9c7d45574dbcd6f5f6891cf8e86de0fad42 | |
parent | 104603cc30d01e510c0d74685fa5a6c50342298d (diff) | |
download | drakx-net-bf76817d1333bbe66954fd59191a723d0f233409.tar drakx-net-bf76817d1333bbe66954fd59191a723d0f233409.tar.gz drakx-net-bf76817d1333bbe66954fd59191a723d0f233409.tar.bz2 drakx-net-bf76817d1333bbe66954fd59191a723d0f233409.tar.xz drakx-net-bf76817d1333bbe66954fd59191a723d0f233409.zip |
move dbus helpers in network::connection_manager
-rw-r--r-- | lib/network/connection_manager.pm | 27 | ||||
-rwxr-xr-x | lib/network/drakroam.pm | 27 |
2 files changed, 29 insertions, 25 deletions
diff --git a/lib/network/connection_manager.pm b/lib/network/connection_manager.pm index 05f345e..3ebbe83 100644 --- a/lib/network/connection_manager.pm +++ b/lib/network/connection_manager.pm @@ -425,4 +425,31 @@ sub update_on_status_change { } } +sub _get_network_event_message { + my ($connections, $member, @args) = @_; + #- FIXME: the hostname.d script and s2u use a different D-Bus interface + if ($member eq 'hostname') { + my ($hostname) = @args; + N("Hostname changed to \"%s\"", $hostname); + } elsif ($member eq 'status') { + my ($status, $interface) = @args; + my $event_connection = find { $_->get_interface eq $interface } @$connections; + $event_connection && $event_connection->get_status_message($status); + } +} + +sub setup_dbus_handlers { + my ($cmanagers, $connections, $on_network_event, $dbus) = @_; + #- FIXME: use network::monitor? + $dbus->{connection}->add_filter(sub { + my ($_con, $msg) = @_; + my $member = $msg->get_member; + my $message = get_network_event_message($droam, $member, $msg->get_args_list) or return; + $droam->{on_network_event}($message) if $droam->{on_network_event}; + $droam->update_networks if $member eq 'status'; + }); + $dbus->{connection}->add_match("type='signal',interface='com.mandriva.network'"); + dbus_object::set_gtk2_watch_helper($dbus); +} + 1; diff --git a/lib/network/drakroam.pm b/lib/network/drakroam.pm index ac5fa60..edf886e 100755 --- a/lib/network/drakroam.pm +++ b/lib/network/drakroam.pm @@ -53,19 +53,6 @@ sub update_on_connection_change { $droam->update_networks; } -sub get_network_event_message { - my ($droam, $member, @args) = @_; - #- FIXME: the hostname.d script and s2u use a different D-Bus interface - if ($member eq 'hostname') { - my ($hostname) = @args; - N("Hostname changed to \"%s\"", $hostname); - } elsif ($member eq 'status') { - my ($status, $interface) = @args; - my $event_connection = find { $_->get_interface eq $interface } @{$droam->{all_connections}}; - $event_connection && $event_connection->get_status_message($status); - } -} - sub create_drakroam_gui { my ($droam, $dbus, $title, $icon) = @_; @@ -89,18 +76,8 @@ sub create_drakroam_gui { my $m_id = $status_bar->push($status_bar_cid, $message); Glib::Timeout->add(20000, sub { $status_bar->remove($status_bar_cid, $m_id); 0 }); }; - if ($dbus) { - #- FIXME: use network::monitor? - $dbus->{connection}->add_filter(sub { - my ($_con, $msg) = @_; - my $member = $msg->get_member; - my $message = get_network_event_message($droam, $member, $msg->get_args_list) or return; - $droam->{on_network_event}($message) if $droam->{on_network_event}; - $droam->update_networks if $member eq 'status'; - }); - $dbus->{connection}->add_match("type='signal',interface='com.mandriva.network'"); - dbus_object::set_gtk2_watch_helper($dbus); - } + + network::connection_manager::setup_dbus_handlers([ $droam ], $droam->{all_connections}, $droam->{on_network_event}, $dbus) if $dbus; (undef, my $rootwin_height) = gtkroot()->get_size(); my $scrolled_height = $rootwin_height > 480 ? 300 : 225; |