Update of /cvsroot/fink/fink/perlmod/Fink
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9128/perlmod/Fink

Modified Files:
        ChangeLog PkgVersion.pm Services.pm 
Log Message:
growl notifications, if available

Index: Services.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/Services.pm,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -d -r1.123 -r1.124
--- Services.pm 22 Oct 2004 17:12:58 -0000      1.123
+++ Services.pm 25 Oct 2004 22:09:30 -0000      1.124
@@ -46,7 +46,8 @@
                                          &pkglist2lol &lol2pkglist
                                          &file_MD5_checksum &get_arch &get_sw_vers
                                          &get_system_perl_version &get_path
-                                         &eval_conditional &count_files);
+                                         &eval_conditional &count_files
+                                         &growl);
 }
 our @EXPORT_OK;
 
@@ -1108,6 +1109,65 @@
        }
 }
 
+
+=item growl
+
+    growl($notificationName, $notificationTitle, $notificationDescription);
+
+Notifies the system that $notificationName event occurred, if Growl is
+installed.
+
+Currently available notifications used by fink are:
+
+=over 4
+
+=item packageInstallationPassed
+
+One or more packages was successfully installed.
+
+=item packageInstallationFailed
+
+One or more packages failed to install.
+
+=item packageRemovalPassed
+
+One or more packages was successfully removed.
+
+=item packageRemovalFailed
+
+One or more packages failed to be removed.
+
+=back
+
+=cut
+
+sub growl {
+       eval {
+               require Mac::Growl;
+       };
+       return undef if ($@);
+       my ($notificationName, $notificationTitle, $notificationDescription) = @_;
+
+       my @events = qw(
+               finkPackageInstallationPassed
+               finkPackageInstallationFailed
+               finkPackageRemovalPassed
+               finkPackageRemovalFailed
+       );
+
+       unless (grep(/^${notificationName}$/, @events)) {
+               warn "unknown notification $notificationName\n";
+               return undef;
+       }
+
+       eval {
+               Mac::Growl::RegisterNotifications("Fink", [EMAIL PROTECTED], [EMAIL 
PROTECTED]);
+               Mac::Growl::PostNotification("Fink", $notificationName, 
$notificationTitle, $notificationDescription);
+       };
+
+       return 1;
+}
+
 =back
 
 =cut

Index: PkgVersion.pm
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/PkgVersion.pm,v
retrieving revision 1.311
retrieving revision 1.312
diff -u -d -r1.311 -r1.312
--- PkgVersion.pm       16 Oct 2004 12:09:09 -0000      1.311
+++ PkgVersion.pm       25 Oct 2004 22:09:21 -0000      1.312
@@ -29,7 +29,7 @@
                                          &pkglist2lol &lol2pkglist
                                          &file_MD5_checksum &version_cmp
                                          &get_arch &get_system_perl_version
-                                         &get_path &eval_conditional);
+                                         &get_path &eval_conditional &growl);
 use Fink::CLI qw(&print_breaking &prompt_boolean &prompt_selection_new);
 use Fink::Config qw($config $basepath $libpath $debarch $buildpath);
 use Fink::NetAccess qw(&fetch_url_to_file);
@@ -2575,10 +2575,19 @@
        my @deb_installable = map { $_->find_debfile() } @installable;
        if (&execute("dpkg -i @deb_installable")) {
                if (@installable == 1) {
+                       growl('finkPackageInstallationFailed', 'Fink installation 
failed.', "can't install package ".$installable[0]->get_fullname());
                        die "can't install package 
".$installable[0]->get_fullname()."\n";
                } else {
+                       growl('finkPackageInstallationFailed', 'Fink installation of ' 
. int(@installable) . ' packages failed.',
+                               "can't batch-install packages: @deb_installable");
                        die "can't batch-install packages: @deb_installable\n";
                }
+       } else {
+               if (@installable == 1) {
+                       growl('finkPackageInstallationPassed', 'Fink installation 
passed.', "installed " . $installable[0]->get_fullname());
+               } else {
+                       growl('finkPackageInstallationPassed', 'Fink installation of ' 
. int(@installable) . ' packages passed.', "batch-installed packages: 
@deb_installable");
+               }
        }
 
        Fink::Status->invalidate();
@@ -2591,11 +2600,22 @@
 
        if (&execute("dpkg --remove @packages")) {
                if (@packages == 1) {
+                       growl('finkPackageRemovalFailed', 'Fink removal failed.', 
"can't remove package ".$packages[0]);
                        die "can't remove package ".$packages[0]."\n";
                } else {
+                       growl('finkPackageRemovalFailed', 'Fink removal of ' . 
int(@packages) . ' packages failed.',
+                               "can't batch-remove packages: @packages");
                        die "can't batch-remove packages: @packages\n";
                }
+       } else {
+               if (@packages == 1) {
+                       growl('finkPackageRemovalPassed', 'Fink removal passed.', 
"removed " . $packages[0]);
+               } else {
+                       growl('finkPackageRemovalPassed', 'Fink removal of ' . 
int(@packages) . ' packages passed.',
+                               "batch-removed packages: @packages");
+               }
        }
+
        Fink::Status->invalidate();
 }
 

Index: ChangeLog
===================================================================
RCS file: /cvsroot/fink/fink/perlmod/Fink/ChangeLog,v
retrieving revision 1.726
retrieving revision 1.727
diff -u -d -r1.726 -r1.727
--- ChangeLog   25 Oct 2004 06:28:33 -0000      1.726
+++ ChangeLog   25 Oct 2004 22:09:20 -0000      1.727
@@ -1,3 +1,8 @@
+2004-10-25  Benjamin Reed  <[EMAIL PROTECTED]>
+
+       * Services.pm, PkgVersion.pm: support for growl notifications if
+       Mac::Growl is available.
+
 2004-10-25  Daniel Macks  <[EMAIL PROTECTED]>
 
        * Engine.pm: Use named constants for fink list/apropos option bits.



-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Fink-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-commits

Reply via email to