Desktop-Notify-0.03/0000755000175000001440000000000011315173737013370 5ustar steveusersDesktop-Notify-0.03/t/0000755000175000001440000000000011315173737013633 5ustar steveusersDesktop-Notify-0.03/t/01-connect.t0000644000175000001440000000075610616551636015700 0ustar steveusers#!perl -T use Test::More tests => 3; BEGIN { use_ok('Desktop::Notify'); } my $notify; eval { $notify = new Desktop::Notify }; ok($notify, 'connect with default options'); $notify = undef; eval { $notify = new Desktop::Notify (bus => Net::DBus->session, service => 'org.freedesktop.Notifications', objpath => '/org/freedesktop/Notifications', objiface => 'org.freedesktop.Notifications') }; ok($notify, 'connect with explicit options'); Desktop-Notify-0.03/t/boilerplate.t0000644000175000001440000000232510616541035016315 0ustar steveusers#!perl -T use strict; use warnings; use Test::More tests => 3; sub not_in_file_ok { my ($filename, %regex) = @_; open my $fh, "<", $filename or die "couldn't open $filename for reading: $!"; my %violated; while (my $line = <$fh>) { while (my ($desc, $regex) = each %regex) { if ($line =~ $regex) { push @{$violated{$desc}||=[]}, $.; } } } if (%violated) { fail("$filename contains boilerplate text"); diag "$_ appears on lines @{$violated{$_}}" for keys %violated; } else { pass("$filename contains no boilerplate text"); } } not_in_file_ok(README => "The README is used..." => qr/The README is used/, "'version information here'" => qr/to provide version information/, ); not_in_file_ok(Changes => "placeholder date/time" => qr(Date/time) ); sub module_boilerplate_ok { my ($module) = @_; not_in_file_ok($module => 'the great new $MODULENAME' => qr/ - The great new /, 'boilerplate description' => qr/Quick summary of what the module/, 'stub function definition' => qr/function[12]/, ); } module_boilerplate_ok('lib/Desktop/Notify.pm'); Desktop-Notify-0.03/t/pod-coverage.t0000644000175000001440000000025410616541035016365 0ustar steveusers#!perl -T use Test::More; eval "use Test::Pod::Coverage 1.04"; plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@; all_pod_coverage_ok(); Desktop-Notify-0.03/t/00-load.t0000644000175000001440000000023310616541035015143 0ustar steveusers#!perl -T use Test::More tests => 1; BEGIN { use_ok( 'Desktop::Notify' ); } diag( "Testing Desktop::Notify $Desktop::Notify::VERSION, Perl $], $^X" ); Desktop-Notify-0.03/t/pod.t0000644000175000001440000000021410616541035014570 0ustar steveusers#!perl -T use Test::More; eval "use Test::Pod 1.14"; plan skip_all => "Test::Pod 1.14 required for testing POD" if $@; all_pod_files_ok(); Desktop-Notify-0.03/META.yml0000644000175000001440000000117011315173737014640 0ustar steveusers--- #YAML:1.0 name: Desktop-Notify version: 0.03 abstract: Communicate with the Desktop Notifications framework author: - Stephen Cavilia license: unknown distribution_type: module configure_requires: ExtUtils::MakeMaker: 0 build_requires: ExtUtils::MakeMaker: 0 requires: Class::Accessor: 0 Net::DBus: 0 Test::More: 0 no_index: directory: - t - inc generated_by: ExtUtils::MakeMaker version 6.55_02 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Desktop-Notify-0.03/Changes0000644000175000001440000000100611315007731014646 0ustar steveusersRevision history for Desktop-Notify 0.03 2009-12-25 Fixed regression in 0.02 when creating notification with timeout Show a warning when closing a notification that has not been shown 0.02 2009-12-24 Fixed non-numeric id/timeout bugs 0.01 2007-05-07 Stuff that works: creating/displaying/modifying/updating/closing nofitications catching close signals Stuff that's not implemented yet: actions hints icons Desktop-Notify-0.03/lib/0000755000175000001440000000000011315173737014136 5ustar steveusersDesktop-Notify-0.03/lib/Desktop/0000755000175000001440000000000011315173737015547 5ustar steveusersDesktop-Notify-0.03/lib/Desktop/Notify/0000755000175000001440000000000011315173737017017 5ustar steveusersDesktop-Notify-0.03/lib/Desktop/Notify/Notification.pm0000644000175000001440000000707111315010303021763 0ustar steveuserspackage Desktop::Notify::Notification; use strict; use warnings; use base qw/Class::Accessor/; Desktop::Notify::Notification->mk_accessors(qw/summary body timeout/); =head1 NAME Desktop::Notify::Notification - a notification object for the desktop notifications framework =head1 VERSION Version 0.03 =cut our $VERSION = '0.03'; =head1 SYNOPSIS # $notify is an existing Desktop::Notify object my $note = $notify->create(summary => 'Rebuilding FooBar', body => 'Progress: 10%'); $note->show; ... # Update the notification later $note->body('Progress: 20%'); $note->show; ... # Take it off the screen $note->close; =head1 DESCRIPTION Desktop notification objects are represented as objects of this class. They are created by a L object. Displaying, closing, and modifying the notification is done by using methods in this class. =head1 METHODS =head2 new $notify, %params This is called internally by L to create a new notification object. =cut sub new { my ($class, $server, %params) = @_; my $self = \%params; $self->{server} = $server; $self->{id} = undef; bless $self, $class; } =head2 show Display the notification on the screen. If this notification had previously been shown and not closed yet, it will replace the existing notification. Show can be called multiple times on the same notification, probably with attribute changes between calls, and later show calls will cause the server to seamlessly replace the existing notification. =cut sub show { my $self = shift; $self->{id} = $self->{server}->{notify} ->Notify($self->{server}->{app_name}, $self->{id} || 0, '', $self->{summary}, $self->{body}, [], {}, $self->{timeout} || 0, ); $self->{server}->_register_notification($self); return $self; } =head2 close Close the notification if it is already being displayed. =cut sub close { my $self = shift; if (defined $self->{id}) { $self->{server}->{notify}->CloseNotification($self->{id}); delete $self->{id}; } else { warn "Trying to close notification that has not been shown."; } return $self; } =head1 ATTRIBUTES The following parameters can be set when creating the object or later modified using accessors (descriptions are from the specification at L) =over =item summary The summary text briefly describing the notification. =item body The optional detailed body text. Can be empty. =item timeout The timeout time in milliseconds since the display of the notification at which the notification should automatically close. If -1, the notification's expiration time is dependent on the notification server's settings, and may vary for the type of notification. If 0, never expire. =back The following extra parameters are included in the specification but not supported by L at this time =over =item app_icon The optional program icon of the calling application. =item actions Actions are sent over as a list of pairs. Each even element in the list (starting at index 0) represents the identifier for the action. Each odd element in the list is the localized string that will be displayed to the user. =item hints Optional hints that can be passed to the server from the client program. =back =cut 1; # End of Desktop::Notify::Notification Desktop-Notify-0.03/lib/Desktop/Notify.pm0000644000175000001440000001174711314755221017360 0ustar steveuserspackage Desktop::Notify; use warnings; use strict; use Net::DBus; use File::Basename; use Data::Dumper; use Desktop::Notify::Notification; =head1 NAME Desktop::Notify - Communicate with the Desktop Notifications framework =head1 VERSION Version 0.03 =cut our $VERSION = '0.03'; =head1 SYNOPSIS use Desktop::Notify; # Open a connection to the notification daemon my $notify = Desktop::Notify->new(); # Create a notification to display my $notification = $notify->create(summary => 'Desktop::Notify', body => 'Hello, world!', timeout => 5000); # Display the notification $notification->show(); # Close the notification later $notification->close(); =head1 DESCRIPTION This module provides a Perl interface to the Desktop Notifications framework. The framework allows applications to display pop-up notifications on an X desktop. This is implemented with two components: a daemon that displays the notifications, and a client library used by applications to send notifications to the daemon. These components communicate through the DBus message bus protocol. More information is available from L This module serves the same purpose as C, in an object-oriented Perl interface. It is not, however, an interface to C itself, but a separate implementation of the specification using L. =head1 METHODS =head2 new %opts Connect to the notification daemon. %opts can include the following options: =over =item app_name The application name to use for notifications. Default is C =item bus The Net::DBus mesage bus to use. Default is to call Net::DBus->session, which is usually where notification-daemon can be reached. =item service The DBus service name of the daemon. Default is I. =item objpath The path to the notifications DBus object. Default is I. =item objiface The DBus interface to access the notifications object as. Default is I. =back =cut sub new { my ($class, %opts) = @_; my $self = {}; $self->{bus} = $opts{bus} || Net::DBus->session; $self->{service} = $self->{bus} ->get_service($opts{service} || 'org.freedesktop.Notifications'); $self->{notify} = $self->{service} ->get_object($opts{objpath} || '/org/freedesktop/Notifications', $opts{objiface} || 'org.freedesktop.Notifications'); $self->{app_name} = $opts{app_name} || basename($0); $self->{notify}->connect_to_signal('NotificationClosed', sub {$self->_close_cb(@_)}); bless $self, $class; } =head2 create %params Creates a new notification object that can be displayed later. This will return a L object; see that module for information about using it. =cut sub create { my ($self, %params) = @_; return new Desktop::Notify::Notification($self, %params); } sub _register_notification { my ($self, $n) = @_; $self->{notes}->{$n->{id}} = $n; } sub _close_cb { my ($self, $nid) = @_; print __PACKAGE__, ": notification closed\n"; if ($self->{close_callback}) { print "invoking callback\n"; $self->{close_callback}->($self->{notes}->{$nid}); } delete $self->{notes}->{$nid}; } =head2 close_callback $coderef Sets a user-specified function to be called whenever a notification is closed. It will be called with one argument, which is the Notification object that was just closed. =cut sub close_callback { my ($self, $cb) = @_; print "callback is $cb\n"; $self->{close_callback} = $cb; } =head1 AUTHOR Stephen Cavilia, C<< >> =head1 SEE ALSO L L L =head1 BUGS Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT You can find documentation for this module with the perldoc command. perldoc Desktop::Notify You can also look for information at: =over 4 =item * AnnoCPAN: Annotated CPAN documentation L =item * CPAN Ratings L =item * RT: CPAN's request tracker L =item * Search CPAN L =back =head1 ACKNOWLEDGEMENTS =head1 COPYRIGHT & LICENSE Copyright 2007 Stephen Cavilia, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # End of Desktop::Notify Desktop-Notify-0.03/MANIFEST0000644000175000001440000000031310616552732014515 0ustar steveusersChanges MANIFEST META.yml # Will be created by "make dist" Makefile.PL README lib/Desktop/Notify.pm lib/Desktop/Notify/Notification.pm t/00-load.t t/01-connect.t t/boilerplate.t t/pod-coverage.t t/pod.t Desktop-Notify-0.03/Makefile.PL0000644000175000001440000000111611314712242015326 0ustar steveusersuse strict; use warnings; use ExtUtils::MakeMaker; WriteMakefile( NAME => 'Desktop::Notify', AUTHOR => 'Stephen Cavilia ', VERSION_FROM => 'lib/Desktop/Notify.pm', ABSTRACT_FROM => 'lib/Desktop/Notify.pm', PL_FILES => {}, PREREQ_PM => { 'Test::More' => 0, 'Net::DBus' => 0, 'Class::Accessor' => 0, }, dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', }, clean => { FILES => 'Desktop-Notify-*' }, ); Desktop-Notify-0.03/README0000644000175000001440000000160410616551263014246 0ustar steveusersDesktop-Notify This module provides a Perl interface to the Desktop Notifications framework. INSTALLATION To install this module, run the following commands: perl Makefile.PL make make test make install SUPPORT AND DOCUMENTATION After installing, you can find documentation for this module with the perldoc command. perldoc Desktop::Notify You can also look for information at: Search CPAN http://search.cpan.org/dist/Desktop-Notify CPAN Request Tracker: http://rt.cpan.org/NoAuth/Bugs.html?Dist=Desktop-Notify AnnoCPAN, annotated CPAN documentation: http://annocpan.org/dist/Desktop-Notify CPAN Ratings: http://cpanratings.perl.org/d/Desktop-Notify COPYRIGHT AND LICENCE Copyright (C) 2007 Stephen Cavilia This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.