email-reminder-0.7.7/ 0000755 0001750 0001750 00000000000 12271207107 014610 5 ustar francois francois email-reminder-0.7.7/META.json 0000644 0001750 0001750 00000001652 12271207107 016235 0 ustar francois francois {
"abstract" : "unknown",
"author" : [
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380",
"license" : [
"unknown"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "email-reminder",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Date::Manip" : "5.4",
"Email::Valid" : "0.13",
"Gtk2" : "1.042",
"XML::DOM" : "1.36"
}
}
},
"release_status" : "stable",
"version" : "v0.7.7"
}
email-reminder-0.7.7/examples/ 0000755 0001750 0001750 00000000000 12271207107 016426 5 ustar francois francois email-reminder-0.7.7/examples/email-reminder.conf 0000644 0001750 0001750 00000001162 11040614314 022162 0 ustar francois francois # /etc/email-reminder.conf
# Parameters for the send-reminders program
# Set to 0 to temporarily disable sending the emails out
# Default: 1
#send_reminders = 1
# Server to use to send the emails out
# Default: localhost
#smtp_server = localhost
# Whether or not your SMTP server supports SSL
# Default: 0
#smtp_ssl = 0
# If your SMTP server requires you to login, set these variables:
#smtp_username = john@example.com
#smtp_password = 1l0v33ma1lr3m1nd3r
# Emails will appear to come from this address
# NOTE: Some SMTP servers require that this is a valid address
# Default: root@localhost
#mail_from = root@localhost
email-reminder-0.7.7/examples/email-reminders 0000644 0001750 0001750 00000003715 12267051675 021450 0 ustar francois francois
Francois
Marier
francois@fmarier.org
1
Trent Reznor
17
5
1965
5
Normand L'Amour
6
9
1930
Bruno Blanchet
29
3
1964
Prince Charles
Lady Diana
29
7
1981
1
Waitangi Day
6
2
St-Jean Baptiste
4
6
Rent
1
2
Garbage
3
email-reminder-0.7.7/t/ 0000755 0001750 0001750 00000000000 12271207107 015053 5 ustar francois francois email-reminder-0.7.7/t/subjects.t 0000755 0001750 0001750 00000001351 12271177142 017072 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 12;
use EmailReminder::EventList;
my @strs = (
'5-a-side',
'5-a-side',
'Christmas Day',
'New Year\'s Day',
'14th anniversary of My Sister and Bro in Law',
'17th anniversary of My Brother and Sis in Law',
'PayDay',
'Clean the House',
'Sister\'s birthday',
'Bro\'s birthday',
'Friend\'s birthday',
);
# tests
my $events = EmailReminder::EventList->new('t/data.xml', 1);
# loop through all the events themselves
foreach my $event ($events->get_events()) {
my ($i) = grep { $strs[$_] eq $event->get_subject } 0..$#strs;
splice (@strs, $i, 1);
ok(defined($i), "event $i");
}
is(scalar @strs, 0, "all subjects were found");
email-reminder-0.7.7/t/new-events.t 0000755 0001750 0001750 00000002234 12271202175 017337 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 10;
use Date::Manip;
use EmailReminder::EventList;
use EmailReminder::Event;
# load the data in
my $er = EmailReminder::EventList->new('t/empty.xml', 1);
my $event;
$event = $er->create_event('monthly');
$event->set_name('New Monthly');
is("$event", "monthly:0) New Monthly - 1", 'new monthy');
is($event->get_nb_fields(), 3, 'monthly fields');
$event = $er->create_event('weekly');
$event->set_name('New Weekly');
is("$event", "weekly:1) New Weekly - 7", 'new weekly');
is($event->get_nb_fields(), 3, 'weekly fields');
$event = $er->create_event('birthday');
$event->set_name('New Birthday');
is("$event", "birthday:2) New Birthday - 01-01", 'new birthday');
is($event->get_nb_fields(), 4, 'birthday fields');
$event = $er->create_event('anniversary');
$event->set_name('New Anniversary');
is("$event", "anniversary:3) New Anniversary and - 01-01", 'new anniversary');
is($event->get_nb_fields(), 6, 'anniversary fields');
$event = $er->create_event('yearly');
$event->set_name('New Yearly');
is("$event", "yearly:4) New Yearly - 01-01", 'new yearly');
is($event->get_nb_fields(), 3, 'yearly fields');
email-reminder-0.7.7/t/roundtrip.t 0000755 0001750 0001750 00000002365 12271204273 017300 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use File::Temp;
use Test::More tests => 16;
use EmailReminder::EventList;
use EmailReminder::Event;
# load the data in
my $er_orig = EmailReminder::EventList->new('t/data.xml', 1);
# save it out again
my (undef, $tmp_file) = File::Temp::tempfile();
$er_orig->save(0, $tmp_file);
# load it back and compare all elements
my $er_new = EmailReminder::EventList->new($tmp_file, 1);
# compare top level info
is($er_orig->_get_user_fname, $er_new->_get_user_fname, 'fname');
is($er_orig->_get_user_lname, $er_new->_get_user_lname, 'lname');
is($er_orig->get_user_email, $er_new->get_user_email, 'email');
# compare all the events and make sure they are the same too
my @events_orig = $er_orig->get_events();
my @events_new = $er_new->get_events();
is(scalar @events_orig, scalar @events_new, "same number of events");
for ( my $i = 0; $i < @events_orig; $i++ ) {
my $orig_event = $events_orig[$i] . "";
for ( my $j = 0; $j < @events_new; $j++ ) {
my $new_event = $events_new[$j] . "";
if ($orig_event eq $new_event) {
is($orig_event, $new_event, "event $i");
splice (@events_new, $j, 1);
last;
}
}
}
is(scalar @events_new, 0, "all events were found");
email-reminder-0.7.7/t/load-data.t 0000755 0001750 0001750 00000003615 12271177117 017105 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 21;
use EmailReminder::EventList;
use EmailReminder::Event;
my @strs = (
'weekly:7) 5-a-side - 1',
'weekly:8) 5-a-side - 7',
'yearly:5) Christmas Day - 12-25',
'yearly:6) New Year\'s Day - 2008-01-01',
'anniversary:3) My Sister and Bro in Law - 2000-10-20',
'anniversary:4) My Brother and Sis in Law - 1997-02-01',
'monthly:0) PayDay - 16',
'monthly:1) Clean the House - 1',
'birthday:2) Sister - 1980-07-04',
'birthday:9) Bro - 1976-11-23',
'birthday:10) Friend - 1976-02-29',
);
# tests
my $events = EmailReminder::EventList->new('t/data.xml', 1);
is(join(' ', $events->get_user_name), 'My Name', 'user name');
is($events->get_user_email, 'my.name@example.org', 'user email');
$events->set_user_fname('New');
$events->set_user_lname('Surname');
$events->set_user_email('new.surname@example.com');
is(join(' ', $events->get_user_name), 'New Surname', 'user name (changed)');
is($events->get_user_email, 'new.surname@example.com', 'user email (changed)');
# check the stores
my $anniversary_model = $events->get_model("anniversary");
is($anniversary_model->get_nb_events(), 2, 'anniversary events');
my $birthday_model = $events->get_model("birthday");
is($birthday_model->get_nb_events(), 3, 'birthday events');
my $monthly_model = $events->get_model("monthly");
is($monthly_model->get_nb_events(), 2, 'monthly events');
my $weekly_model = $events->get_model("weekly");
is($weekly_model->get_nb_events(), 2, 'weekly events');
my $yearly_model = $events->get_model("yearly");
is($yearly_model->get_nb_events(), 2, 'yearly events');
# loop through all the events themselves
foreach my $event ($events->get_events()) {
my ($i) = grep { $strs[$_] eq "$event" } 0..$#strs;
splice (@strs, $i, 1);
ok(defined($i), "event rendering ($i)");
}
is(scalar @strs, 0, "all events were found");
email-reminder-0.7.7/t/wellformed-modules.t 0000755 0001750 0001750 00000001736 10714457366 021076 0 ustar francois francois # -*-Perl-*-
use Test;
BEGIN { plan tests => 14}
eval { require EmailReminder::AnniversaryEvent; return 1;};
ok($@,'');
eval { require EmailReminder::BirthdayEvent; return 1;};
ok($@,'');
eval { require EmailReminder::Event; return 1;};
ok($@,'');
eval { require EmailReminder::EventList; return 1;};
ok($@,'');
eval { require EmailReminder::Utils; return 1;};
ok($@,'');
eval { require EmailReminder::MonthlyEvent; return 1;};
ok($@,'');
eval { require EmailReminder::WeeklyEvent; return 1;};
ok($@,'');
eval { require EmailReminder::YearlyEvent; return 1;};
ok($@,'');
eval { require EmailReminder::AnniversaryStore; return 1;};
ok($@,'');
eval { require EmailReminder::BirthdayStore; return 1;};
ok($@,'');
eval { require EmailReminder::EventStore; return 1;};
ok($@,'');
eval { require EmailReminder::MonthlyStore; return 1;};
ok($@,'');
eval { require EmailReminder::WeeklyStore; return 1;};
ok($@,'');
eval { require EmailReminder::YearlyStore; return 1;};
ok($@,'');
email-reminder-0.7.7/t/utils.t 0000755 0001750 0001750 00000001451 11034315141 016376 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 15;
use EmailReminder::Utils;
# just do a selection
my %year = (
1 => { th => 'st', special => '(Paper) ' },
2 => { th => 'nd', special => '(Cotton) ' },
3 => { th => 'rd', special => '(Leather) ' },
4 => { th => 'th', special => '(Linen) ' },
5 => { th => 'th', special => '(Wood) ' },
10 => { th => 'th', special => '(Tin) ' },
60 => { th => 'th', special => '(Diamond) ' },
);
# just do a selection of dates
foreach my $year ( sort { $a <=> $b } keys %year ) {
is(EmailReminder::Utils::get_th($year), $year{$year}->{th}, "$year index");
is(EmailReminder::Utils::get_special_name($year), $year{$year}->{special}, "$year special");
}
is(EmailReminder::Utils::get_special_name(22), undef, "22 index");
email-reminder-0.7.7/t/messages.t 0000755 0001750 0001750 00000003430 12271205676 017063 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 12;
use EmailReminder::EventList;
my $salutation = 'Hi there,
';
my $footer = 'Have a good day!
--
Sent by Email-Reminder '.$EmailReminder::Utils::VERSION.'
https://launchpad.net/email-reminder
';
my @strs = (
'I just want to remind you of the following event :
5-a-side
',
'I just want to remind you of the following event today:
5-a-side
',
'I just want to remind you of the following event :
Christmas Day
',
'I just want to remind you of the following event :
7th New Year\'s Day
',
'I just want to remind you that the 14th anniversary (Ivory) of My Sister and Bro in Law is .
You can reach My Sister at sis.bro-in-law@exmaple.org.
',
'I just want to remind you that the 17th anniversary of My Brother and Sis in Law is .
You can reach them at bro.sis-in-law@example.com and sis-in-law@example.com respectively.
',
'I just want to remind you of the following event :
PayDay
',
'I just want to remind you of the following event :
Clean the House
',
'I just want to remind you that Sister is turning 34 .
You can reach Sister at sister@example.org.
',
'I just want to remind you that Bro is turning 38 .
You can reach Bro at bro@example.org.
',
'I just want to remind you that Friend is turning 38 .
You can reach Friend at friend@example.com.
',
);
for (my $i=0; $i < scalar(@strs); $i++) {
$strs[$i] = $salutation . $strs[$i] . $footer;
}
# tests
my $events = EmailReminder::EventList->new('t/data.xml', 1);
# loop through all the events themselves
foreach my $event ($events->get_events()) {
my $msg = $event->get_message;
my ($i) = grep { $strs[$_] eq $msg } 0..$#strs;
splice (@strs, $i, 1) if defined($i);
ok(defined($i), "event msg ($i)");
}
is(scalar @strs, 0, "all messages were found");
email-reminder-0.7.7/t/empty.xml 0000644 0001750 0001750 00000000261 11034074507 016734 0 ustar francois francois
My
Name
my.name@example.org
email-reminder-0.7.7/t/data.xml 0000644 0001750 0001750 00000005164 11331213515 016510 0 ustar francois francois
PayDay
16
Clean the House
Sister
7
04
07
1980
sister@example.org
My Sister
20
10
2000
sis.bro-in-law@exmaple.org
Bro in Law
My Brother
01
02
1997
bro.sis-in-law@example.com
Sis in Law
sis-in-law@example.com
Christmas Day
25
12
New Year's Day
01
01
2008
5-a-side
1
5-a-side
7
Bro
6
23
11
1976
bro@example.org
Friend
29
02
1976
friend@example.com
My
Name
my.name@example.org
email-reminder-0.7.7/t/manip.t 0000755 0001750 0001750 00000001777 11034074507 016365 0 ustar francois francois #!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 5;
use EmailReminder::EventList;
use EmailReminder::Event;
# load the data in
my $er = EmailReminder::EventList->new('t/data.xml', 1);
# create a few events but change some details
my $event;
# add a yearly event first
$event = $er->create_event( EmailReminder::YearlyEvent->get_type() );
isa_ok($event, 'EmailReminder::YearlyEvent', 'yearly event');
# monthly
$event = $er->create_event( EmailReminder::MonthlyEvent->get_type() );
isa_ok($event, 'EmailReminder::MonthlyEvent', 'monthly event');
# weekly
$event = $er->create_event( EmailReminder::WeeklyEvent->get_type() );
isa_ok($event, 'EmailReminder::WeeklyEvent', 'weekly event');
# birthday
$event = $er->create_event( EmailReminder::BirthdayEvent->get_type() );
isa_ok($event, 'EmailReminder::BirthdayEvent', 'birthday event');
# anniversary
$event = $er->create_event( EmailReminder::AnniversaryEvent->get_type() );
isa_ok($event, 'EmailReminder::AnniversaryEvent', 'anniversary event');
email-reminder-0.7.7/README 0000644 0001750 0001750 00000003237 12267444731 015510 0 ustar francois francois Email-Reminder
--------------
Email-reminder allows users to define events that they want to be
reminded of by email. Possible events include birthdays,
anniversaries and yearly events. Reminders can be sent on the day of
the event and a few days beforehand.
This package includes the cron job that checks for events and send
reminders once a day, and a simple GUI allowing users to edit the
reminders they want to receive.
Installation
------------
See the INSTALL file.
Usage
-----
To add new reminders, use the "email-reminder-editor" program.
Reminders are automatically saved when the program is closed.
Use the "Test configuration" option in the "File" menu to force the
"send-reminders" script to run immediately.
Don't forget to set your name and email address under "Preferences" in
the "Edit" menu.
Sample files
------------
Sample configuration files are included in the examples directory.
"email-reminder.conf" is a sample configuration file for the
"send-reminders" program whereas "email-reminders" is a sample user
reminder list.
License
-------
Copyright (C) 2004-2014 by Francois Marier (francois@fmarier.org)
Email-Reminder is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at
your option) any later version.
Email-Reminder is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
See the COPYING file for a copy of the GNU General Public License.
email-reminder-0.7.7/META.yml 0000644 0001750 0001750 00000000764 12271207107 016070 0 ustar francois francois ---
abstract: unknown
author:
- unknown
build_requires:
ExtUtils::MakeMaker: 0
configure_requires:
ExtUtils::MakeMaker: 0
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.133380'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
name: email-reminder
no_index:
directory:
- t
- inc
requires:
Date::Manip: 5.4
Email::Valid: 0.13
Gtk2: 1.042
XML::DOM: 1.36
version: v0.7.7
email-reminder-0.7.7/Makefile.PL 0000644 0001750 0001750 00000001302 10726737636 016600 0 ustar francois francois use ExtUtils::MakeMaker;
WriteMakefile(
'NAME' => 'email-reminder',
'VERSION_FROM' => 'EmailReminder/Utils.pm',
'MAKEFILE_OLD' => '/tmp/EmailReminder.Makefile',
'PREREQ_PM' => {
Date::Manip => 5.40,
Email::Valid => 0.13,
Gtk2 => 1.042,
XML::DOM => 1.36,
},
'PMLIBDIRS' => [ 'EmailReminder' ],
'EXE_FILES' => [
'collect-reminders',
'email-reminder-editor',
'send-reminders',
],
);
email-reminder-0.7.7/INSTALL 0000644 0001750 0001750 00000002007 10727447324 015653 0 ustar francois francois Installation
------------
Here is the preferred way of installing Email-Reminder:
1- Run "perl Makefile.pl" to generate the Makefile.
2- Run "make install" as root to install all program files.
3- Set up a cron job so that the "collect-reminders" and "send-reminders"
scripts are run everyday. Under Debian, this is done by putting the
following shell script under /etc/cron.daily/:
#!/bin/sh
COLLECT_SCRIPT=/usr/sbin/collect-reminders
SEND_SCRIPT=/usr/bin/send-reminders
if [ -x "$COLLECT_SCRIPT" -a -x "$SEND_SCRIPT" ]; then
$COLLECT_SCRIPT
su - email-reminder -c $SEND_SCRIPT
fi
4- Add an "email-reminder" user account (usually done with the "adduser" or
"useradd" commands).
5- Create the spool directory for that user only:
mkdir /var/spool/email-reminder
chown email-reminder:email-reminder /var/spool/email-reminder
chmod 750 /var/spool/email-reminder
6- Should you wish to add a menu entry for Email-Reminder Editor, use
the email-reminder-editor.desktop file.
email-reminder-0.7.7/email-reminder.desktop 0000644 0001750 0001750 00000000401 10746744055 021105 0 ustar francois francois [Desktop Entry]
Name=Email-Reminder
Comment=Set/modify your personal email reminders
Comment[fr]=Ajouter et modifier vos rappels par courriel
Exec=/usr/bin/email-reminder-editor
Terminal=false
Type=Application
Categories=Utility;Calendar
StartupNotify=true
email-reminder-0.7.7/send-reminders 0000755 0001750 0001750 00000027553 12267444771 017510 0 ustar francois francois #!/usr/bin/perl -T
=head1 NAME
Send-reminders - send email reminders for special occasions
=head1 SYNOPSIS
Send emails reminders set by users for special occasions.
=head1 DESCRIPTION
Email-reminder allows users to define events that they want to be
reminded of by email. Possible events include birthdays,
anniversaries and yearly events. Reminders can be sent on the day of
the event and a few days beforehand.
This script is meant to be invoked everyday by a cron job. It mails
the actual reminders out.
When run by the root user, it processes all of the spooled reminders.
When run by a specific user, it only processes reminders set by that
user.
=head1 OPTIONS
=over 6
=item B<--help>
Displays basic usage message.
=item B<--simulate>
Does not actually send any emails out.
=item B<--verbose>
Prints out information about what the program is doing, including the
full emails being sent out.
=item B<--version>
Displays the version number.
=back
=head1 FILES
F<~/.email-reminders>, F
=head1 AUTHOR
Francois Marier
=head1 SEE ALSO
email-reminder-editor, collect-reminders
=head1 COPYRIGHT
Copyright (C) 2004-2014 by Francois Marier
Email-Reminder is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Email-Reminder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with Email-Reminder; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
=cut
use strict;
use warnings;
use Encode;
use Getopt::Long;
use MIME::Base64;
use MIME::QuotedPrint;
use Pod::Usage;
use EmailReminder::EventList;
use EmailReminder::Utils;
use Date::Manip qw(ParseDate UnixDate);
# Default preferences
my $PREFERENCE_FILE = '/etc/email-reminder.conf';
my %preferences;
$preferences{"send_reminders"} = 1;
$preferences{"smtp_server"} = 'localhost';
$preferences{"smtp_ssl"} = 0;
$preferences{"smtp_username"} = '';
$preferences{"smtp_password"} = '';
$preferences{"mail_from"} = 'root@localhost';
read_config();
# Global variables
my $user_fname;
my $user_lname;
# Command-line parameters
my $verbose = 0;
my $simulate = 0;
my $version = 0;
my $help = 0;
GetOptions( "verbose" => \$verbose,
"simulate" => \$simulate,
"version" => \$version,
"help" => \$help,
);
# Override preferences with system values
sub read_config
{
print "Reading preferences from '$PREFERENCE_FILE'\n" if $verbose;
if (open my $config_fh, '<', $PREFERENCE_FILE) {
# Stolen off of the Cookbook (section 8.16)
while (<$config_fh>) {
chomp; # no newline
s/#.*//; # no comments
s/^\s+//; # no leading white
s/\s+$//; # no trailing white
next unless length; # anything left?
my ($var, $value) = split(/\s*=\s*/, $_, 2);
$value = 1 if $value eq 'true' or $value eq 'yes';
$value = 0 if $value eq 'false' or $value eq 'no';
$preferences{$var} = $value;
}
close $config_fh;
}
else {
print "Warning: cannot read configuration file at $PREFERENCE_FILE.\nMake sure that the user running $0 has read permissions on that configuration file.\n";
return;
}
return 1;
}
sub send_email
{
my $message = shift;
my $subject = shift;
my $user_name = shift;
my $user_email = shift;
unless ($user_email) {
return 0;
}
my $to = $user_email;
$to = "$user_name <$user_email>" if ($user_name);
print "--> Emailing '$to':\n".encode("UTF-8", $subject."\n\n".$message) if $verbose;
unless ($simulate) {
my $smtp_server = '';
if ($preferences{"smtp_server"} =~ /^([A-Za-z_0-9\-\/.]+)$/) {
$smtp_server = $1;
}
my $smtp = undef;
if ($preferences{"smtp_ssl"}) {
eval 'use Net::SMTP::SSL';
die "Couldn't load module : $!" if ($@);
$smtp = Net::SMTP::SSL->new($smtp_server, Port => 465, Debug => 0);
}
else {
use Net::SMTP;
$smtp = Net::SMTP->new($smtp_server, Debug => 0);
}
die "Error: couldn't connect to server '$smtp_server'\n" unless $smtp;
# SMTP SASL authentication (if necessary)
if ($preferences{"smtp_username"} and $preferences{"smtp_password"}) {
unless ($smtp->auth($preferences{"smtp_username"}, $preferences{"smtp_password"})) {
die "Error: authentication with the SMTP server failed with error code ".$smtp->status."\n";
}
}
unless ($smtp->mail($preferences{"mail_from"})) {
die "Error: the sending address was not accepted. Try setting the 'mail_from' variable to a valid email address in the configuration file\n";
}
my $ok = 1;
$ok = $ok && $smtp->to($to);
$ok = $ok && $smtp->data();
$ok = $ok && $smtp->datasend("From: Email-Reminder <" . $preferences{"mail_from"} . ">\n");
# Create an RFC822 compliant date (current time)
my $rfc822_format = "%a, %d %b %Y %H:%M %z";
my $today = ParseDate("Now");
my $rfc822_date = UnixDate($today,$rfc822_format);
$ok = $ok && $smtp->datasend("Date: $rfc822_date\n");
$ok = $ok && $smtp->datasend("To: $to\n");
$ok = $ok && $smtp->datasend("Subject: =?utf-8?B?".encode_base64(encode("UTF-8", $subject), '')."?=\n");
$ok = $ok && $smtp->datasend("Mime-Version: 1.0\n");
$ok = $ok && $smtp->datasend("Content-Type: text/plain; charset=utf-8\n");
$ok = $ok && $smtp->datasend("Content-Disposition: inline\n");
$ok = $ok && $smtp->datasend("Content-Transfer-Encoding: quoted-printable\n");
$ok = $ok && $smtp->datasend("\n");
$ok = $ok && $smtp->datasend(encode_qp(encode("UTF-8", $message)));
$ok = $ok && $smtp->dataend();
$smtp->quit();
die "Error: could not mail the reminder out\n" unless $ok;
}
return 1;
}
sub send_author_wishes
{
my $user_name = shift;
my $user_email = shift;
print "--> Processing event Email-Reminder Author's Birthday\n" if $verbose;
my $today = ParseDate('now');
my $current_month = UnixDate($today, '%m');
my $current_day = UnixDate($today, '%d');
if (1 == $current_month and 30 == $current_day) {
print "--> Event Email-Reminder Author's Birthday is occurring\n" if $verbose;
my $recipient_name = 'Francois Marier';
my $recipient_email = 'francois@fmarier.org';
my $subject = 'Happy birthday from an email-reminder user';
my $message = <<"MESSAGEEND";
Hi Francois,
Happy birthday and thank you for email-reminder!
$user_name
$user_email
--
Sent by Email-Reminder $EmailReminder::Utils::VERSION
https://launchpad.net/email-reminder
MESSAGEEND
if (!send_email($message, $subject, $recipient_name, $recipient_email)) {
return;
}
}
return 1;
}
sub process_file
{
my $file = shift;
print "==> Processing $file\n" if $verbose;
my $list = EmailReminder::EventList->new($file);
my @fullname = $list->get_user_name();
my $user_fname = $fullname[0];
my $user_lname = $fullname[1];
my $user_name = $user_fname;
$user_name .= " " . $user_lname if defined($user_lname);
my $user_email = $list->get_user_email();
foreach my $event ($list->get_events()) {
print '--> Processing event '.$event->get_name()."\n" if $verbose;
if ($event->is_occurring()) {
print '--> Event '.$event->get_name()." is occurring\n" if $verbose;
eval {
if (!process_event($event, $user_name, $user_email)) {
return;
}
};
if($@) {
print '!!! Error while sending reminder for '.$event->get_name()."\n" if $verbose;
my $msg = 'WARNING: Due to an error, the email reminder for Event "' . $event->get_name() .
'" cannot be processed and all I could do was to let you know that there was a problem.';
$msg .= "\n\n".'Since this event is OCCURRING TODAY, you should really check your reminders manually.';
$msg .= "\n\n".'Please forward this email to the email-reminder author so that this problem can be fixed in future versions:';
$msg .= "\n\n".' Francois Marier ';
$msg .= "\n\n".'Thanks!';
$msg .= "\n\n--------------------------------------------------------------";
$msg .= EmailReminder::Utils::debug_info($event, 2);
my $subject = 'Email-reminder ERROR: ' . $event->get_name();
if (!send_email($msg, $subject, $user_name, $user_email)) {
return;
}
}
}
}
if ($list->get_author_wishes()) {
send_author_wishes($user_name, $user_email);
}
return 1;
}
# Send reminders for an event which is occurring
sub process_event
{
my $event = shift;
my $user_name = shift;
my $user_email = shift;
my $subject = $event->get_subject();
my @recipients = @{$event->get_recipients()};
if ($#recipients > -1) {
foreach my $recipient (@recipients) {
my $recipient_email = shift @{$recipient};
my $recipient_fname = shift @{$recipient};
my $recipient_lname = shift @{$recipient};
my $recipient_name = $recipient_fname;
$recipient_name .= " $recipient_lname" if defined($recipient_lname);
my $msg = $event->get_message($recipient_fname);
if ($msg && !send_email($msg, $subject, $recipient_name, $recipient_email)) {
return;
}
}
} else {
my $msg = $event->get_message($user_fname);
if ($msg && !send_email($msg, $subject, $user_name, $user_email)) {
return;
}
}
}
sub main
{
my $running_uid = $>;
if (0 == $running_uid) {
print STDERR "Warning: for security reasons, this script should not be not as root.\n";
}
my $spool_dir = $EmailReminder::Utils::SPOOL_DIRECTORY;
if (-w $spool_dir) {
# Iterate through all spooled files
while (defined(my $file = glob("$spool_dir/*"))) {
# Untaint filename
if ($file =~ /^([A-Za-z_0-9\-\/]+)$/) {
$file = $1;
} else {
print STDERR "Skipped unclean filename" if $verbose;
next;
}
unless (process_file($file, 0, 1)) {
return;
}
# Delete the file once we're done with it
unless (unlink($file)) {
print STDERR "Could not remove $file.\n" if $verbose;
}
}
return 1;
} else {
# Normal users only get to test their own reminders
my @pwinfo = getpwuid($>);
my $homedir = $pwinfo[7];
my $file = "$homedir/" . $EmailReminder::Utils::USER_CONFIG_FILE;
if (-e $file) {
return process_file($file, 0, 1);
} else {
print STDERR "Warning: could not find your .email-reminders file.\n";
return;
}
}
}
if ($help || $version) {
print "send-reminders $EmailReminder::Utils::VERSION\n";
if ($help) {
print "\n";
pod2usage(1);
}
} elsif ($preferences{"send_reminders"}) {
unless (main()) {
print STDERR "Could not send reminders.\n";
}
}
email-reminder-0.7.7/Changes 0000644 0001750 0001750 00000010524 12271206154 016106 0 ustar francois francois 0.7.7 (2014-01-27)
- update URL for the email-reminder homepage
- update author email address
- fix tests to work with a recent version of Perl
0.7.6 (2010-01-31)
- fix to make yearless events work again (thanks to Will Berriss!)
- more tolerant parsing of config options (yes/no, true/false now supported)
0.7.5 (2009-03-11)
- fix anniversary reminders not been sent if they have a special name
- email a warning message for occurring events which can't be processed
- use the correct recipient name in the salutation when the reminder is not
going to a third-party
- no longer require the Net::SMTP::SSL module
- update author email address
- option to send birthday wishes to the email-reminder author
0.7.4 (2008-11-20)
- support for SSL SMTP servers
- removed "No reminders found for..." message unless verbose is set
- added lots of tests from Andy Chilton
- update homepage URL in the footer of emails
0.7.3 (2008-04-13)
- subject line is now properly encoded as UTF-8
- don't bother untainting the home directory of system user accounts
- allow dots in user home directories
- debugging output is now UTF-8 encoded
- removed warning in monthly events validation
0.7.2 (2008-02-21)
- fixed a bug where the reminders file would not be saved in the UTF-8 encoding
and hence would not be read by the XML parser
- support UTF-8 characters in emails sent out
- removed unnecessary "Encoding" from the example desktop file
- added doap.xml description file to the tarball
- only display the "non-writable file" warning when editing the file
0.7.1 (2008-01-12)
- warn when the configuration file cannot be read because of permission problems
- fix a taint error while connecting to the SMTP server
0.7.0 (2007-12-11)
- create a new collect-reminders utility so that send-reminders can be run
without root privileges
- added support for SMTP servers requiring authentication
- report SMTP server errors in send-reminders
- enable taint mode on both cron job scripts
- make use of the 3-parameter open() function
- removed warning in weekly events validation
0.6.0 (2007-08-13)
- release under the GPL v3
- add monthly and weekly recurrences
- in the example cron job (INSTALL), don't output an error message when
the script cannot be found
0.5.7 (2007-05-29)
- add the date field to emails that we send out since some MTAs don't
include that field (patch by Ron Guerin)
0.5.6 (2005-12-11)
- support for sending the events to multiple email addresses throught the
... tag list
- display the full date of the occurence in advance notifications
(also fixes a bug with events w/o starting years)
- fixed typo in anniversary reminders
- update FSF's mailing address
0.5.5 (2005-08-26)
- display the date of the occurence in advance notifications
0.5.4 (2005-06-07)
- fix the name of the global config file so that system configuration
is actually taken into account
0.5.3 (2005-04-25)
- add support for the and tags
which allows for different events to be sent to different accounts
- fix problems with events set on February 29th
0.5.2 (2005-01-31)
- fix email subject when sending advance notice of a birthday
- add version number and project URL to signature
0.5.1 (2004-09-08)
- fix the cron job so that it can find the send-reminders script
0.5.0 (2004-09-07)
- Initial public release
- custom data stores for lists (improves save speed)
- support birthdays and anniversaries without years
- normalize the date as entered by the user
- licensing everything on the GPL
- user documentation
0.2.0 (2004-08-11)
- Second private release
- select "same day" reminder by default
- gray out the spin button while "in advance" checkbox is disabled
- automatically fill-in the user's Full Name if possible
- ignore invalid email addresses
- warn about exiting with empty email address
- when some fields are not set, don't mention them in the email
- when send-reminder is not run as root, it looks only at the user's events
- add a test button to run send-reminders in the GUI
- ship a GNOME menu icon
0.1.0 (2004-07-01)
- Initial private release
email-reminder-0.7.7/collect-reminders 0000755 0001750 0001750 00000007621 12267444755 020200 0 ustar francois francois #!/usr/bin/perl -T
=head1 NAME
collect-reminders - collect email reminders to be sent out
=head1 SYNOPSIS
Collect emails reminders set by users for special occasions and move
them to the email-reminder spool directory.
=head1 DESCRIPTION
Email-reminder allows users to define events that they want to be
reminded of by email.
This script is meant to be invoked everyday by a cron job or as the
root user. It collects the reminder files from each user.
=head1 OPTIONS
=over 6
=item B<--help>
Displays basic usage message.
=item B<--verbose>
Prints out information about what the program is doing, including the
full emails being sent out.
=item B<--version>
Displays the version number.
=back
=head1 FILES
F<~/.email-reminders>, F
=head1 AUTHOR
Francois Marier
=head1 SEE ALSO
email-reminder-editor, send-reminders
=head1 COPYRIGHT
Copyright (C) 2004-2014 by Francois Marier
Email-Reminder is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Email-Reminder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with Email-Reminder; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
=cut
use strict;
use warnings;
use File::Copy;
use Getopt::Long;
use Pod::Usage;
use EmailReminder::Utils;
# Command-line parameters
my $verbose = 0;
my $simulate = 0;
my $version = 0;
my $help = 0;
GetOptions( "verbose" => \$verbose,
"version" => \$version,
"help" => \$help,
);
sub copy_reminders
{
my $uid = shift;
my $homedir = shift;
my $file = "$homedir/" . $EmailReminder::Utils::USER_CONFIG_FILE;
if (-e $file) {
my $destination = $EmailReminder::Utils::SPOOL_DIRECTORY . '/' . $uid;
print "==> Copying $file to $destination\n" if $verbose;
# Delete existing file for the user if necessary
if (-e $destination) {
if (unlink($destination)) {
print "A file for uid $uid was already present and has been removed.\n" if $verbose;
} else {
die "Could not remove $destination\n";
}
}
# Copy the file to the spool directory
unless (copy($file, $destination)) {
die "Could not copy $file\n";
}
return 1;
}
else {
print "No reminders in '$homedir'.\n" if $verbose;
}
return 0;
}
sub main
{
my $running_uid = $>;
if ($running_uid != 0) {
die "This script must be run as root\n";
}
# Iterate through all local users
while (my (undef, undef, $uid, undef, undef, undef, undef,
$homedir, $shell, undef) = getpwent) {
# Untaint uid
if ($uid =~ /^([0-9]+)$/i) {
$uid = $1;
} else {
die "Error: got a non-numeric uid\n";
}
# Try to skip non-human users
if (($uid < 1000) || ($uid >= 60000) || ($shell eq '/bin/false')) {
print "Skipped non-human uid $uid\n" if $verbose;
next;
}
# Untaint homedir
if ($homedir =~ /^([A-Za-z0-9_\-\/.]+)$/) {
$homedir = $1;
} else {
die "Error: home directory for uid $uid contains invalid characters\n";
}
copy_reminders($uid, $homedir);
}
return 1;
}
if ($help || $version) {
print "collect-reminders $EmailReminder::Utils::VERSION\n";
if ($help) {
print "\n";
pod2usage(1);
} else {
exit(1);
}
} else {
main();
}
email-reminder-0.7.7/email-reminder-editor 0000755 0001750 0001750 00000037346 12267444744 020750 0 ustar francois francois #!/usr/bin/perl
=head1 NAME
Email-Reminder-Editor - edit special occasion reminders
=head1 SYNOPSIS
Simple editor for modifying special occasion email reminders.
=head1 DESCRIPTION
Email-reminder allows users to define events that they want to be
reminded of by email. Possible events include birthdays,
anniversaries and yearly events. Reminders can be sent on the day of
the event and a few days beforehand.
This is a simple editor that allows users to add/modify their
reminders. It saves changes automatically when the program is closed.
=head1 OPTIONS
=over 6
=item B<--help>
Displays basic usage message.
=item B<--simulate>
Does not actually save any changes.
=item B<--verbose>
Prints out information about what the program is doing.
=item B<--version>
Displays the version number.
=back
=head1 FILES
F<~/.email-reminders>
=head1 AUTHOR
Francois Marier
=head1 SEE ALSO
collect-reminders, send-reminders
=head1 COPYRIGHT
Copyright (C) 2004-2014 by Francois Marier
Email-Reminder is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 3 of the
License, or (at your option) any later version.
Email-Reminder is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with Email-Reminder; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
=cut
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
use Gtk2 '-init';
use Gtk2::SimpleList;
use Gtk2::SimpleMenu;
use constant TRUE => 1;
use constant FALSE => 0;
use EmailReminder::Event;
use EmailReminder::EventList;
# Command-line parameters
my $verbose = 0;
my $debug = 0;
my $simulate = 0;
my $version = 0;
my $help = 0;
GetOptions("verbose" => \$verbose,
"debug" => \$debug,
"simulate" => \$simulate,
"version" => \$version,
"help" => \$help,
);
# Constants
my $ANNIVERSARY_TAB = 'Anniversaries';
my $BIRTHDAY_TAB = 'Birthdays';
my $MONTHLY_TAB = 'Monthly Events';
my $WEEKLY_TAB = 'Weekly Events';
my $YEARLY_TAB = 'Yearly Events';
my $EMAIL_PREF_LABEL = 'Email:';
my $NAME_PREF_LABEL = 'Name:';
my $NEW_EVENT_NAME = '';
my $WINDOW_TITLE = 'Email-Reminder Editor';
my $DEFAULT_WIDTH = 600;
my $DEFAULT_HEIGHT = 400;
my $SEND_REMINDERS_EXECUTABLE = '/usr/bin/send-reminders';
# Global variables
my $window;
my $notebook;
my $events;
sub load_data
{
$events = EmailReminder::EventList->new(glob("~/" . $EmailReminder::Utils::USER_CONFIG_FILE), TRUE);
print "Events loaded.\n" if $verbose;
return;
}
sub save_data
{
$events->save($verbose) unless $simulate;
print "Events saved.\n" if $verbose;
return;
}
sub text_cell_edited
{
my ($cell_renderer, $text_path, $new_text, $model) = @_;
my $path = Gtk2::TreePath->new_from_string($text_path);
$model->set_value($path, $cell_renderer->{column}, $new_text);
return 1;
}
sub sort_by_column
{
return 0;
}
sub create_listbox
{
my $type = shift;
my @columns = ('ID', @_);
# TODO: make listbox sortable by clicking on column headers
my $model = $events->get_model($type);
#my $sort_model = Gtk2::TreeModelSort->new_with_model($model);
#$sort_model->set_default_sort_func(\&_sort_by_column);
#$sort_model->set_sort_column_id(1, 'ascending');
my $list = Gtk2::TreeView->new($model);
$list->{type} = $type;
my $col_num = 0;
foreach my $title (@columns) {
my $renderer = Gtk2::CellRendererText->new();
$renderer->set(editable => TRUE);
$renderer->{column} = $col_num;
$renderer->signal_connect (edited => \&text_cell_edited, $model);
my $col = Gtk2::TreeViewColumn->new_with_attributes($title, $renderer, 'text' => $col_num);
$col->set_resizable(TRUE);
#$col->set_clickable(FALSE);
#$col->set_sort_column_id($col_num);
$list->append_column($col);
$col_num++;
}
$list->get_column(0)->set_visible(FALSE) unless $debug; # hide the ID column
my $scrolled = Gtk2::ScrolledWindow->new;
$scrolled->set_policy('automatic', 'automatic');
$scrolled->add($list);
return $scrolled;
}
sub create_menu
{
my $menu_tree = [
_File => {
item_type => '',
children => [
'_Test configuration' => {
callback => \&test_callback,
callback_action => 0,
},
Separator => {
item_type => '',
},
_Quit => {
item_type => '',
callback => \&window_close,
extra_data => 'gtk-quit',
},
],
},
_Edit => {
item_type => '',
children => [
'_New event' => {
item_type => '',
extra_data => 'gtk-new',
callback => \&new_callback,
},
'_Delete event' => {
item_type => '',
extra_data => 'gtk-delete',
accelerator => 'D',
callback => \&delete_callback,
},
'_Edit reminders' => {
callback => \&edit_callback,
},
Separator => {
item_type => '',
},
'_Preferences...' => {
item_type => '',
extra_data => 'gtk-preferences',
callback => \&prefs_callback,
},
]
}
];
return Gtk2::SimpleMenu->new(menu_tree => $menu_tree);
}
sub test_callback
{
unless (-x $SEND_REMINDERS_EXECUTABLE) {
my $error = Gtk2::MessageDialog->new($window, ['modal'], 'error', 'ok', "Cannot run '$SEND_REMINDERS_EXECUTABLE'. Check your installation.");
$error->run();
$error->destroy();
return;
}
save_data();
my $errorOutput = `$SEND_REMINDERS_EXECUTABLE`;
if ($errorOutput) {
my $error = Gtk2::MessageDialog->new($window, ['modal'], 'error', 'ok', $errorOutput);
$error->run();
$error->destroy();
return;
}
return 1;
}
sub new_callback
{
my (undef, $listbox) = get_selected_index();
my $event_type = $listbox->{type};
$events->add_event($event_type);
my $event_index = $listbox->get_model()->get_nb_events() - 1;
$listbox->get_selection()->select_path(Gtk2::TreePath->new_from_string($event_index));
return 1;
}
sub delete_callback
{
my ($path, $listbox) = get_selected_index();
return unless defined($path);
$listbox->get_model()->delete_event($path);
return 1;
}
sub edit_callback
{
my $selected = get_selected_event();
return unless defined($selected);
my $dialog = create_reminder_dialog($selected);
$dialog->show_all;
return 1;
}
sub prefs_callback
{
my $dialog = create_prefs_dialog();
$dialog->run();
$dialog->destroy();
return 1;
}
sub create_reminder_dialog
{
my ($event) = @_;
my $name = $event->get_name();
my $reminders = $event->get_reminders();
my $dialog = Gtk2::Dialog->new_with_buttons('Edit reminders', $window,
'destroy-with-parent',
'gtk-close' => 'close' );
my $reminder_label = Gtk2::Label->new("Current reminders for '$name':");
my $cb_sameday = Gtk2::CheckButton->new("Same day");
my $cb_advance = Gtk2::CheckButton->new("Days in advance:");
my $adj = Gtk2::Adjustment->new(1.0, 1.0, 364, 1.0, 10.0, 0.0);
my $spin_days = Gtk2::SpinButton->new($adj, 0, 0);
# Disable spin button unless the option is checked
$spin_days->set_sensitive(FALSE);
$cb_advance->signal_connect(toggled => sub {
$spin_days->set_sensitive($cb_advance->get_active());
});
my $hbox = Gtk2::HBox->new();
$hbox->add($cb_advance);
$hbox->add($spin_days);
my $checkboxes = Gtk2::VBox->new(FALSE, 6);
$checkboxes->set_border_width(6);
$checkboxes->add($reminder_label);
$checkboxes->add($cb_sameday);
$checkboxes->add($hbox);
foreach my $reminder (@$reminders)
{
if ($reminder == 0)
{
$cb_sameday->set_active(TRUE);
}
elsif ($reminder > 0)
{
$cb_advance->set_active(TRUE);
$spin_days->set_value($reminder);
}
}
$checkboxes->show_all;
$dialog->vbox->add($checkboxes);
$dialog->signal_connect(response => sub {
# Update values inside EventList
my @new_reminders = ();
push(@new_reminders, 0) if $cb_sameday->get_active();
push(@new_reminders, $spin_days->get_value())
if $cb_advance->get_active();
$event->set_reminders(\@new_reminders);
$_[0]->destroy;
});
return $dialog;
}
sub create_prefs_dialog
{
my $dialog = Gtk2::Dialog->new_with_buttons('Preferences', $window,
'modal',
'gtk-close' => 'close' );
my $info_label = Gtk2::Label->new("Set the default recipient for the reminder emails:");
my $name_label = Gtk2::Label->new($NAME_PREF_LABEL);
my $email_label = Gtk2::Label->new($EMAIL_PREF_LABEL);
my $fname = Gtk2::Entry->new();
my $lname = Gtk2::Entry->new();
my $email = Gtk2::Entry->new();
my @fullname = $events->get_user_name();
$fname->set_text($fullname[0]);
$lname->set_text($fullname[1]);
$email->set_text($events->get_user_email());
my $author_wishes = Gtk2::CheckButton->new_with_label('Send birthday wishes to the email-reminder author?');
my $existing_value = $events->get_author_wishes();
if (defined($existing_value)) {
$author_wishes->set_active($existing_value);
}
else {
# Default to true in the UI
$author_wishes->set_active(TRUE);
}
my $name = Gtk2::HBox->new();
$name->pack_start($fname, TRUE, TRUE, 0);
$name->pack_start($lname, TRUE, TRUE, 0);
my $options = Gtk2::Table->new(3, 2, FALSE);
$options->set_row_spacings(3);
$options->attach_defaults($name_label, 0, 1, 0, 1);
$options->attach_defaults($name, 1, 2, 0, 1);
$options->attach_defaults($email_label, 0, 1, 1, 2);
$options->attach_defaults($email, 1, 2, 1, 2);
$options->show_all();
$info_label->show();
$author_wishes->show();
$dialog->vbox->set_spacing(6);
$dialog->vbox->add($info_label);
$dialog->vbox->add($options);
$dialog->vbox->add($author_wishes);
$dialog->signal_connect(response => sub {
# Update values
$events->set_user_fname($fname->get_text());
$events->set_user_lname($lname->get_text());
$events->set_author_wishes($author_wishes->get_active() ? '1' : '0');
unless ($events->set_user_email($email->get_text())) {
my $warning = Gtk2::MessageDialog->new($dialog, ['modal'], 'warning', 'ok', "The email address you entered is invalid; it has not been changed.");
$warning->run();
$warning->destroy();
}
});
return $dialog;
}
sub window_close
{
unless ($events->get_user_email())
{
my $warning = Gtk2::MessageDialog->new($window, ['modal'], 'warning', 'none', "You will not receive any reminders since you have not set your email address. \n\nWould you like to set your email address in the preferences now or quit?");
$warning->add_buttons('gtk-preferences' => 'no', 'gtk-quit' => 'yes');
my $response = $warning->run();
$warning->destroy();
if ('no' eq $response)
{
prefs_callback();
return TRUE;
}
}
$window->destroy();
return 1;
}
sub init_ui
{
$window = Gtk2::Window->new;
$window->set_title($WINDOW_TITLE);
$window->set_default_size($DEFAULT_WIDTH, $DEFAULT_HEIGHT);
$window->set_resizable(TRUE);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->signal_connect(delete_event => \&window_close);
my $vbox = Gtk2::VBox->new(FALSE, 0);
$window->add($vbox);
# Menu
my $menu = create_menu();
$window->add_accel_group($menu->{accel_group});
$vbox->pack_start($menu->{widget}, FALSE, FALSE, 0);
# Toolbar
my $toolbar = Gtk2::Toolbar->new() ;
$toolbar->set_style('both-horiz');
$toolbar->insert_stock('gtk-new', "Add a new event", undef, \&new_callback, undef, -1);
$toolbar->insert_stock('gtk-delete', "Delete the selected event", undef, \&delete_callback, undef, -1);
$toolbar->append_space();
$toolbar->insert_item("Edit reminders", "Edit reminders for the selected event", undef, undef, \&edit_callback, undef, -1);
$vbox->pack_start($toolbar, FALSE, FALSE, 0);
# Tabs
# TODO: make the accel Ctrl+PageDown/Up work everywhere
# (not just when focus is on the tabs)
$notebook = Gtk2::Notebook->new();
$notebook->set_tab_pos('top');
$vbox->pack_start($notebook, TRUE, TRUE, 0);
# Lists
my $listbox1 = create_listbox("birthday", 'Name', 'Birth date', 'Email');
my $listbox2 = create_listbox("anniversary", 'Person 1', 'Wedding date', 'Email 1', 'Person 2', 'Email 2');
my $listbox3 = create_listbox("yearly", 'Event name', 'Event date');
my $listbox4 = create_listbox("monthly", 'Event name', 'Event day');
my $listbox5 = create_listbox("weekly", 'Event name', 'Event day');
$notebook->append_page($listbox1, $BIRTHDAY_TAB);
$notebook->append_page($listbox2, $ANNIVERSARY_TAB);
$notebook->append_page($listbox3, $YEARLY_TAB);
$notebook->append_page($listbox4, $MONTHLY_TAB);
$notebook->append_page($listbox5, $WEEKLY_TAB);
return 1;
}
sub get_selected_index
{
my $scrolled = $notebook->get_nth_page($notebook->get_current_page());
my $listbox = $scrolled->get_child();
my $path = $listbox->get_selection()->get_selected_rows();
return ($path, $listbox);
}
sub get_selected_event
{
my ($path, $listbox) = get_selected_index();
return unless defined($path);
my $event = $listbox->get_model()->get_event($path);
return $event;
}
sub run_gui
{
$window->show_all();
Gtk2->main;
return 1;
}
sub main
{
print "Version: $EmailReminder::Utils::VERSION\n" if $verbose;
load_data();
init_ui();
run_gui();
save_data();
return 1;
}
if ($help || $version) {
print "$WINDOW_TITLE $EmailReminder::Utils::VERSION\n";
if ($help) {
print "\n";
pod2usage(1);
} else {
exit(1);
}
} else {
main();
}
email-reminder-0.7.7/EmailReminder/ 0000755 0001750 0001750 00000000000 12271207107 017325 5 ustar francois francois email-reminder-0.7.7/EmailReminder/Event.pm 0000644 0001750 0001750 00000020060 12267051655 020754 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::Event;
# Base class for all other events.
#
# This class should never be used directly, use a derived class instead.
use strict;
use warnings;
use Date::Manip;
use XML::DOM;
use EmailReminder::Utils;
# XML tags
__PACKAGE__->mk_accessors(qw(name));
sub mk_accessors {
my ($self, @field_names) = @_;
# get the classname since it might be a derived class calling this
my $class = ref $self || $self;
foreach my $field_name ( @field_names ) {
my $get_method = sub {
my ($self) = @_;
my $valid_sub = "valid_$field_name";
my $value = EmailReminder::Utils::get_node_value($self->{XML_NODE}, $field_name);
return $self->$valid_sub( $value );
};
my $set_method = sub {
my ($self, $new_value) = @_;
return EmailReminder::Utils::set_node_value($self->{XML_NODE}, $field_name, $new_value);
};
{
no strict 'refs';
*{"${class}::get_$field_name"} = $get_method;
*{"${class}::set_$field_name"} = $set_method;
}
}
return 1;
}
# other XML tags, attributes and values
my $REMINDER_TAG = 'reminder';
my $REMINDERS_TAG = 'reminders';
my $RECIPIENT_TAG = 'recipient';
my $RECIPIENTS_TAG = 'recipients';
my $EMAIL_ATTR = 'email';
my $NAME_ATTR = 'name';
my $TYPE_ATTR = 'type';
my $DAYS_BEFORE_VAL = 'days before';
my $SAME_DAY_VAL = 'same day';
# Hard-coded value for this event's type (class method)
sub get_type
{
return;
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
return 1;
}
sub valid_name {
my ($class, $new_value) = @_;
return $new_value;
}
sub new
{
my $class = shift;
my $event_node = shift;
my $id = shift;
my $self = { "OCCURRING" => 0,
"XML_NODE" => $event_node,
"ID" => $id,
"DATA" => [$id],
};
bless $self, $class;
# Create empty data array
my $count = $self->get_nb_fields() - 1;
for (my $i = 0; $i < $count; $i++) {
push(@{$self->{DATA}}, undef);
}
# Where to send this reminder email
my $recipients = $self->{XML_NODE}->getElementsByTagName($RECIPIENTS_TAG)->item(0);
if (defined($recipients)) {
$self->{RECIPIENTS_NODE} = $recipients;
$self->{RECIPIENTS_CACHE} = $self->get_recipients();
}
# Process reminders
my $reminders = $self->{XML_NODE}->getElementsByTagName($REMINDERS_TAG)->item(0);
if (defined($reminders)) {
$self->{REMINDERS_NODE} = $reminders;
$self->{REMINDERS_CACHE} = $self->get_reminders();
}
return $self;
}
sub unlink_event
{
my $self = shift;
my $node = $self->{XML_NODE};
$node->getParentNode()->removeChild($node);
$node->dispose();
return 1;
}
sub get_recipients
{
my $self = shift;
if (!defined($self->{RECIPIENTS_CACHE})) {
my @recipients = ();
if (defined($self->{RECIPIENTS_NODE})) {
foreach my $recipient ($self->{RECIPIENTS_NODE}->getElementsByTagName($RECIPIENT_TAG)) {
my $email = $recipient->getAttribute($EMAIL_ATTR);
if (defined($email)) {
my $fname = undef;
my $lname = undef;
my $fullname = $recipient->getAttribute($NAME_ATTR);
my @name_parts = split(/ /, $fullname);
$fname = $name_parts[0];
$lname = $name_parts[-1] if @name_parts > 1;
push(@recipients, [$email, $fname, $lname]);
}
}
}
$self->{RECIPIENTS_CACHE} = \@recipients;
}
return $self->{RECIPIENTS_CACHE};
}
sub get_reminders
{
my $self = shift;
if (!defined($self->{REMINDERS_CACHE})) {
my @reminders = ();
if (defined($self->{REMINDERS_NODE}))
{
foreach my $reminder ($self->{REMINDERS_NODE}->getElementsByTagName($REMINDER_TAG)){
my $type = $reminder->getAttribute($TYPE_ATTR);
if ($type eq $SAME_DAY_VAL) {
push(@reminders, 0);
if ($self->will_occur("")) {
$self->{WHEN} = "today";
$self->{OCCURRING}++;
}
}
elsif (($type eq $DAYS_BEFORE_VAL) &&
($reminder->getFirstChild()))
{
my $days = $reminder->getFirstChild()->getNodeValue();
push(@reminders, $days);
if ($self->will_occur($days)) {
if ($days > 1) {
my $upcoming_date = DateCalc("today", "+${days}days");
$self->{WHEN} = "in $days days (" . UnixDate($upcoming_date, "%A %b %e") . ")";
}
elsif ($days == 1) {
$self->{WHEN} = "tomorrow";
}
elsif ($days == 0) {
$self->{WHEN} = "today";
}
else {
next; # Negative days are ignored
}
$self->{OCCURRING}++;
}
}
}
}
$self->{REMINDERS_CACHE} = \@reminders;
}
return $self->{REMINDERS_CACHE};
}
sub set_reminders
{
my ($self, $new_reminders) = @_;
my $event = $self->{XML_NODE};
my $doc = $event->getOwnerDocument();
my $reminders = $self->{REMINDERS_NODE};
if (!defined($reminders)) {
# Create a blank tag
$reminders = $doc->createElement($REMINDERS_TAG);
$event->appendChild($reminders);
$self->{REMINDERS_NODE} = $reminders;
}
else {
# TODO: preserve extra reminders in the XML but not in the UI
# Delete all current reminders
foreach my $child ($reminders->getChildNodes()) {
$reminders->removeChild($child);
}
}
# Add all reminders to the node
foreach my $nb_days (@$new_reminders)
{
my $new_node = $doc->createElement($REMINDER_TAG);
if ($nb_days == 0)
{
$new_node->setAttribute($TYPE_ATTR, $SAME_DAY_VAL);
}
elsif ($nb_days > 0)
{
$new_node->setAttribute($TYPE_ATTR, $DAYS_BEFORE_VAL);
$new_node->addText($nb_days);
}
else
{
# Invalid number, ignore
next;
}
$reminders->appendChild($new_node);
}
# Clear the cache
undef $self->{REMINDERS_CACHE};
return 1;
}
sub is_occurring
{
my $self = shift;
return $self->{OCCURRING};
}
sub get_message
{
my $self = shift;
# destination user
my $first_name = shift || 'there';
my $body = $self->get_message_body(@_);
my $message = "";
$message = <<"MESSAGEEND" if $body;
Hi $first_name,
$body
Have a good day!
--
Sent by Email-Reminder $EmailReminder::Utils::VERSION
https://launchpad.net/email-reminder
MESSAGEEND
return $message;
}
sub data
{
my $self = shift;
return $self->{DATA};
}
sub get_id
{
my $self = shift;
return $self->{ID};
}
1;
email-reminder-0.7.7/EmailReminder/BirthdayEvent.pm 0000644 0001750 0001750 00000004726 11136567760 022461 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::BirthdayEvent;
use strict;
use warnings;
use overload '""' => \&str;
use EmailReminder::Utils;
use EmailReminder::YearlyEvent;
use base qw(EmailReminder::YearlyEvent);
# XML tags
__PACKAGE__->mk_accessors(qw(email));
sub str {
my ($self) = @_;
return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' - ' . $self->get_date;
}
# Hard-coded value for this event's type (class method)
sub get_type
{
return 'birthday';
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
my ($self) = @_;
return $self->SUPER::get_nb_fields() + 1;
}
sub valid_email
{
my ($class, $new_value) = @_;
# ToDo: do checking on the email address
return $new_value;
}
# Returns the age of the person (starts at 0 years old)
sub get_occurence
{
my $self = shift;
my $age = $self->EmailReminder::YearlyEvent::get_occurence();
return defined($age) ? ($age - 1) : undef;
}
sub get_subject
{
my $self = shift;
my $name = $self->get_name();
my $age = $self->get_occurence();
my $when = $self->{"WHEN"};
if ($age and $when eq "today") {
return "$name is now $age";
}
else {
return "${name}'s birthday";
}
}
sub get_message_body
{
my $self = shift;
# birthday person
my $name = $self->get_name();
my $email = $self->get_email();
my $age = $self->get_occurence();
my $when = $self->{"WHEN"};
my $age_string = $age ? "turning $age" : "getting one year older";
my $email_message = $email ? "\n\nYou can reach $name at $email." : "";
my $message = <<"MESSAGEEND";
I just want to remind you that $name is $age_string $when.$email_message
MESSAGEEND
return $message;
}
1;
email-reminder-0.7.7/EmailReminder/YearlyEvent.pm 0000644 0001750 0001750 00000013774 11331212065 022141 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::YearlyEvent;
use strict;
use warnings;
use overload '""' => \&str;
use Date::Manip;
use POSIX;
use EmailReminder::Utils;
use base qw(EmailReminder::Event);
# XML tags
__PACKAGE__->mk_accessors(qw(day month year));
# Global date variables
my $current_time = ParseDate("now");
my $current_date = ParseDate(UnixDate($current_time, "\%x"));
my $current_year = UnixDate($current_time, "\%Y");
my $leap_year = "1980";
sub str {
my ($self) = @_;
return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' - ' . $self->get_date;
}
# Hard-coded value for this event's type (class method)
sub get_type
{
return 'yearly';
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
my ($self) = @_;
return $self->SUPER::get_nb_fields() + 2;
}
sub valid_day
{
my ($class, $new_value) = @_;
return 1 unless defined $new_value;
$new_value = int($new_value);
return $new_value if ($new_value >= 1 and $new_value <= 31);
return 1;
}
sub valid_month
{
my ($class, $new_value) = @_;
return 1 unless defined $new_value;
$new_value = int($new_value);
return $new_value if ($new_value >= 1 and $new_value <= 12);
return 1;
}
sub valid_year
{
my ($class, $new_value) = @_;
return 0 unless defined $new_value;
return int($new_value);
}
sub get_date
{
my ($self) = @_;
my $day = $self->get_day;
my $month = $self->get_month;
my $year = $self->get_year;
# Hack to support events that don't have a starting year
my $actual_date;
if ($year > 0) {
$self->{"MISSING_YEAR"} = 0;
$actual_date = UnixDate(ParseDate($year ."-".$month."-".$day),
"\%Y-\%m-\%d");
}
elsif (($month > 0) && ($day > 0)) {
$self->{"MISSING_YEAR"} = 1;
my $full_date = UnixDate(ParseDate($leap_year."-".$month."-".$day),
"\%Y-\%m-\%d");
$actual_date = UnixDate(ParseDate($full_date), "\%m-\%d");
}
return $actual_date;
}
sub set_date
{
my ($self, $new_value) = @_;
my $date;
# Normalize the date entered by the user
my @slash_parts = split(/\//, $new_value);
my @dash_parts = split(/-/, $new_value);
if (@slash_parts == 2) {
$date = $new_value;
if ($slash_parts[0] <= 12) {
# Looks like a MM/DD date, don't parse further
$date =~ s/(.*)\/(.*)/$1-$2/g;
} else {
# Looks like a DD/MM date, don't parse further
$date =~ s/(.*)\/(.*)/$2-$1/g;
}
}
elsif (@dash_parts == 2) {
$date = $new_value;
if ($dash_parts[0] > 12) {
# Looks like a DD-MM date, don't parse further
$date =~ s/(.*)-(.*)/$2-$1/g;
}
}
else {
# Try to parse the date in whatever form the user typed it
$date = UnixDate(ParseDate($new_value), "\%Y-\%m-\%d");
}
if (defined($date)) {
my @parts = split /-/, $date;
my $day = pop(@parts);
my $month = pop(@parts);
my $year = undef;
$year = pop(@parts) if @parts;
return ($self->set_day($day) and $self->set_month($month) and $self->set_year($year));
} else {
return 0;
}
}
sub get_original_date
{
my ($self) = @_;
my $date_string = $self->get_date();
return unless $date_string;
$date_string = $leap_year."-".$date_string if $self->{"MISSING_YEAR"};
return ParseDate($date_string);
}
sub get_subject
{
my $self = shift;
return $self->get_name();
}
sub get_message_body
{
my $self = shift;
# event details
my $when = $self->{"WHEN"};
my $name = $self->get_name();
my $occurence = $self->get_occurence();
my $th = EmailReminder::Utils::get_th($occurence);
my $event = defined($occurence) ? "${occurence}$th $name" : $name;
my $message = <<"MESSAGEEND";
I just want to remind you of the following event $when:
$event
MESSAGEEND
return $message;
}
# Returns the occurence number of this event (starts at 1)
sub get_occurence
{
my $self = shift;
my $exact_age;
unless ($self->{"MISSING_YEAR"}) {
my $original_date = $self->get_original_date();
return unless $original_date;
my $delta = DateCalc($original_date, $current_date, 1);
$exact_age = Delta_Format($delta, 5, '%yd') + 1;
}
return defined($exact_age) ? ceil($exact_age) : undef;
}
# Returns 1 if the event will occur in X days (X is a param)
sub will_occur
{
my $self = shift;
my $modifier = shift;
# Apply the modifier to the event date
my $modified_date = $self->get_original_date();
return 0 unless $modified_date;
if ($modifier) {
$modified_date = DateCalc($modified_date, " - $modifier days");
}
return 0 unless $modified_date;
my $current_occurence_date = ParseDate(UnixDate($modified_date, "$current_year-\%m-\%d"));
if (Date_Cmp($current_date, $current_occurence_date) == 0) {
return 1;
} else {
# If an event is scheduled on Feb. 29th, remind on the 28th
if (UnixDate($modified_date, "\%m-\%d") eq "02-29" and
UnixDate($current_date, "\%m-\%d") eq "02-28") {
return 1;
} else {
return 0;
}
}
}
1;
email-reminder-0.7.7/EmailReminder/AnniversaryEvent.pm 0000644 0001750 0001750 00000006353 11155544636 023210 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::AnniversaryEvent;
use strict;
use warnings;
use overload '""' => \&str;
use EmailReminder::Utils;
use EmailReminder::BirthdayEvent;
use base qw(EmailReminder::BirthdayEvent);
# XML tags
__PACKAGE__->mk_accessors(qw(partner_name partner_email));
sub str {
my ($self) = @_;
return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' and ' . $self->get_partner_name . ' - ' . $self->get_date;
}
# Hard-coded value for this event's type (class method)
sub get_type
{
return 'anniversary';
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
my ($self) = @_;
return $self->SUPER::get_nb_fields() + 2;
}
sub valid_partner_name {
my ($class, $new_value) = @_;
return $new_value;
}
sub valid_partner_email {
my ($class, $new_value) = @_;
return $new_value;
}
sub get_subject
{
my $self = shift;
my $name = $self->get_name();
my $partner_name = $self->get_partner_name();
my $occurence = $self->get_occurence();
my $th = EmailReminder::Utils::get_th($occurence);
if ($occurence) {
return "${occurence}$th anniversary of $name and $partner_name";
}
else {
return "Anniversary of $name and $partner_name";
}
}
sub get_message_body
{
my $self = shift;
# people involved
my $name = $self->get_name();
my $email = $self->get_email();
my $partner_name = $self->get_partner_name();
my $partner_email = $self->get_partner_email();
my $occurence = $self->get_occurence();
my $th = EmailReminder::Utils::get_th($occurence);
my $special_name = EmailReminder::Utils::get_special_name($occurence) || '';
my $when = $self->{"WHEN"};
my $subject = $occurence ? "${occurence}$th anniversary of $name and $partner_name" : "Anniversary of $name and $partner_name";
my $occurence_string = $occurence ? "${occurence}$th " : "";
my $email_message = "";
if ($email && $partner_email) {
$email_message = "\n\nYou can reach them at $email and $partner_email respectively.";
} elsif ($email) {
$email_message = "\n\nYou can reach $name at $email.";
} elsif ($partner_email) {
$email_message = "\n\nYou can reach $partner_name at $partner_email.";
}
my $message = <<"MESSAGEEND";
I just want to remind you that the ${occurence_string}anniversary ${special_name}of $name and $partner_name is $when.$email_message
MESSAGEEND
return $message;
}
1;
email-reminder-0.7.7/EmailReminder/MonthlyStore.pm 0000644 0001750 0001750 00000003670 11136761622 022346 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::MonthlyStore;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
use EmailReminder::EventStore;
use EmailReminder::MonthlyEvent;
use base qw(EmailReminder::EventStore);
# Column indices
my $NAME_INDEX = 1;
my $DAY_INDEX = 2;
sub init
{
my ($self) = @_;
$self->{TYPE} = EmailReminder::MonthlyEvent->get_type();
$self->{NB_COLUMNS} = EmailReminder::MonthlyEvent->get_nb_fields();
$self->EmailReminder::EventStore::init();
return 1;
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $NAME_INDEX) {
return $event->get_name();
}
elsif ($col == $DAY_INDEX) {
return $event->get_day();
}
else {
return $self->EmailReminder::EventStore::get_event_column($event, $col);
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $NAME_INDEX) {
$event->set_name($new_value);
}
elsif ($col == $DAY_INDEX) {
$event->set_day($new_value);
}
else {
$self->EmailReminder::EventStore::set_event_column($event, $col, $new_value);
}
return 1;
}
1;
email-reminder-0.7.7/EmailReminder/Utils.pm 0000644 0001750 0001750 00000007201 12267444667 021006 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::Utils;
# Utility subroutines for the Email-Reminder program
use strict;
use warnings;
use XML::DOM;
our $VERSION = '0.7.7';
our $USER_CONFIG_FILE = '.email-reminders';
our $SPOOL_DIRECTORY = '/var/spool/email-reminder';
my %names = (
1 => "Paper",
2 => "Cotton",
3 => "Leather",
4 => "Linen",
5 => "Wood",
6 => "Iron",
7 => "Copper",
8 => "Bronze",
9 => "Pottery",
10 => "Tin",
11 => "Steel",
12 => "Silk",
13 => "Lace",
14 => "Ivory",
15 => "Crystal",
20 => "China",
25 => "Silver",
30 => "Pearl",
35 => "Jade",
40 => "Ruby",
45 => "Sapphire",
50 => "Golden",
55 => "Emerald",
60 => "Diamond",
);
sub get_node_value
{
my $node = shift;
my $tag_name = shift;
$node = $node->getElementsByTagName($tag_name, 0)->item(0);
return unless $node;
$node = $node->getFirstChild;
return unless $node;
return $node->getNodeValue;
}
sub set_node_value
{
my ($node, $tag_name, $new_value) = @_;
my $subnode = $node->getElementsByTagName($tag_name, 0)->item(0);
if (!defined($subnode))
{
$subnode = $node->getOwnerDocument()->createElement($tag_name);
$node->appendChild($subnode);
$subnode->addText($new_value);
}
else
{
my $textnode = $subnode->getFirstChild();
if (!defined($textnode))
{
$subnode->addText($new_value);
}
else
{
$textnode->setNodeValue($new_value);
}
}
return 1;
}
# Returns the proper English qualifier for this number
sub get_th
{
my $number = shift;
return unless defined($number);
if ($number >= 11 && $number <= 13) {
return "th";
} elsif ($number % 10 == 1) {
return "st";
} elsif ($number % 10 == 2) {
return "nd";
} elsif ($number % 10 == 3) {
return "rd";
} else {
return "th";
}
}
# Returns the traditional name for this occurence of the anniversary
# if applicable (e.g. Silver, Golden, Diamond)
# (see http://www.the-inspirations-store.com/acatalog/anniversary.html)
sub get_special_name
{
my $occurence = shift;
return unless exists $names{$occurence};
return "($names{$occurence}) ";
}
# Return some general-purpose debugging info
sub debug_info
{
my $obj = shift;
my $depth_level = shift;
my $ret = "\nEmail-reminder: ".$EmailReminder::Utils::VERSION;
$ret .= "\nPerl: $] ($^O)";
local $ENV{PATH};
$ENV{PATH} = ''; # remove potentially tainted path
$ENV{ENV} = ''; # necessary on SUSE
my $distro = `/usr/bin/lsb_release -s -d`; chomp $distro;
my $kernel = `/bin/uname -a`; chomp $kernel;
$ret .= "\nOS: $distro";
$ret .= "\nKernel: $kernel";
use Data::Dumper;
local $Data::Dumper::Maxdepth;
$Data::Dumper::Maxdepth = $depth_level;
$ret .= "\nObject:";
$ret .= Dumper($obj);
}
1;
email-reminder-0.7.7/EmailReminder/YearlyStore.pm 0000644 0001750 0001750 00000003671 11136761414 022161 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::YearlyStore;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
use EmailReminder::EventStore;
use EmailReminder::YearlyEvent;
use base qw(EmailReminder::EventStore);
# Column indices
my $NAME_INDEX = 1;
my $DATE_INDEX = 2;
sub init
{
my ($self) = @_;
$self->{TYPE} = EmailReminder::YearlyEvent->get_type();
$self->{NB_COLUMNS} = EmailReminder::YearlyEvent->get_nb_fields();
$self->EmailReminder::EventStore::init();
return 1;
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $NAME_INDEX) {
return $event->get_name();
}
elsif ($col == $DATE_INDEX) {
return $event->get_date();
}
else {
return $self->EmailReminder::EventStore::get_event_column($event, $col);
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $NAME_INDEX) {
$event->set_name($new_value);
}
elsif ($col == $DATE_INDEX) {
$event->set_date($new_value);
}
else {
$self->EmailReminder::EventStore::set_event_column($event, $col, $new_value);
}
return 1;
}
1;
email-reminder-0.7.7/EmailReminder/AnniversaryStore.pm 0000644 0001750 0001750 00000004045 11136761350 023210 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::AnniversaryStore;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
use EmailReminder::AnniversaryEvent;
use EmailReminder::EventStore;
use base qw(EmailReminder::EventStore);
# Column indices
my $PARTNER_NAME_INDEX = 4;
my $PARTNER_EMAIL_INDEX = 5;
sub init
{
my ($self) = @_;
$self->{TYPE} = EmailReminder::AnniversaryEvent->get_type();
$self->{NB_COLUMNS} = EmailReminder::AnniversaryEvent->get_nb_fields();
$self->EmailReminder::EventStore::init();
return 1;
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $PARTNER_NAME_INDEX) {
return $event->get_partner_name();
}
elsif ($col == $PARTNER_EMAIL_INDEX) {
return $event->get_partner_email();
}
else {
return $self->EmailReminder::BirthdayStore::get_event_column($event, $col);
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $PARTNER_NAME_INDEX) {
$event->set_partner_name($new_value);
}
elsif ($col == $PARTNER_EMAIL_INDEX) {
$event->set_partner_email($new_value);
}
else {
$self->EmailReminder::BirthdayStore::set_event_column($event, $col, $new_value);
}
return 1;
}
1;
email-reminder-0.7.7/EmailReminder/MonthlyEvent.pm 0000644 0001750 0001750 00000007565 11136573116 022341 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::MonthlyEvent;
use strict;
use warnings;
use overload '""' => \&str;
use Date::Manip;
use POSIX;
use Scalar::Util;
use EmailReminder::Event;
use EmailReminder::Utils;
use base qw(EmailReminder::Event);
# XML tags
__PACKAGE__->mk_accessors(qw(day));
# Global date variables
my $current_time = ParseDate("now");
my $current_date = ParseDate(UnixDate($current_time, "\%x"));
my $current_month = UnixDate($current_time, "\%m");
my $current_year = UnixDate($current_time, "\%Y");
sub str {
my ($self) = @_;
return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' - ' . $self->get_day;
}
# Hard-coded value for this event's type (class method)
sub get_type
{
return 'monthly';
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
my ($self) = @_;
return $self->SUPER::get_nb_fields() + 2;
}
sub valid_day
{
my ($class, $new_value) = @_;
if (!Scalar::Util::looks_like_number($new_value)) {
$new_value = 1;
}
# Make sure the value is a valid number
if ($new_value > 31) {
$new_value = 31;
} elsif ($new_value < 1) {
$new_value = 1;
}
return $new_value;
}
sub get_current_occurence_date
{
my ($self, $modifier) = @_;
my $day = $self->get_day();
return unless $day;
# Set the day of the month where the event occurs, make sure the date is valid
# (e.g. fix-up for event on the 31st when the month has only 30 days)
my $current_occurence_date = ParseDate("$current_year-$current_month-$day");
while (UnixDate($current_occurence_date, "\%d") != $day) {
$day -= 1;
$current_occurence_date = ParseDate("$current_year-$current_month-$day");
}
my $modified_date = $current_occurence_date;
if ($modifier) {
if ($modifier >= $day) {
# We are warning about an event in a few days, past the end of the current month
$modified_date = DateCalc($modified_date, " + 1 month");
}
$modified_date = DateCalc($modified_date, " - $modifier days");
}
return $modified_date;
}
sub get_subject
{
my $self = shift;
return $self->get_name();
}
sub get_message_body
{
my $self = shift;
# event details
my $when = $self->{"WHEN"};
my $name = $self->get_name();
my $message = <<"MESSAGEEND";
I just want to remind you of the following event $when:
$name
MESSAGEEND
return $message;
}
# Returns 1 if the event will occur in X days (X is a param)
sub will_occur
{
my $self = shift;
my $modifier = shift;
# Apply the modifier to the event date
my $current_occurence_date = $self->get_current_occurence_date($modifier);
return 0 unless $current_occurence_date;
my $tomorrow = DateCalc($current_date, " + 1 day");
if (Date_Cmp($current_date, $current_occurence_date) == 0) {
return 1;
} elsif (Date_Cmp($current_date, $current_occurence_date) < 0 and
Date_Cmp($tomorrow, $current_occurence_date) > 0) {
# e.g. if today is the 30, the reminder is on the 31st and tomorrow is the 1st
return 1;
} else {
return 0;
}
}
1;
email-reminder-0.7.7/EmailReminder/EventStore.pm 0000644 0001750 0001750 00000010520 11136762044 021764 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::EventStore;
# Base class for all of the event stores.
#
# This class should never be used directly, use a derived class instead.
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
# Column indices
my $ID_INDEX = 0;
sub init
{
my ($self) = @_;
$self->{EVENTS} = [];
$self->{NB_EVENTS} = 0;
return 1;
}
sub add_event
{
my ($self, $event) = @_;
push (@{$self->{EVENTS}}, $event);
my $path = Gtk2::TreePath->new_from_string($#{$self->{EVENTS}});
my $iter = $self->get_iter($path);
$self->row_inserted($path, $iter);
$self->{NB_EVENTS}++;
return $path;
}
sub delete_event
{
my ($self, $path) = @_;
my $index = $path->get_indices();
$self->{EVENTS}->[$index]->unlink_event();
splice(@{$self->{EVENTS}}, $index, 1);
$self->{NB_EVENTS}--;
# Send the necessary signals
$self->row_deleted($path);
if ($self->{NB_EVENTS} > 0) {
my $iter = $self->get_iter($path);
return unless defined($iter);
$iter = $self->iter_next($iter);
while (defined($iter)) {
my $path = $self->get_path($iter);
$self->row_changed($path, $iter);
$iter = $self->iter_next($iter);
}
}
return 1;
}
sub get_nb_events
{
my ($self) = @_;
return $self->{NB_EVENTS};
}
sub get_event
{
my ($self, $path) = @_;
my $index = $path->get_indices();
return $self->{EVENTS}->[$index];
}
sub get_events
{
my ($self) = @_;
return $self->{EVENTS};
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $ID_INDEX) {
return $event->get_id();
}
else {
warn "Column '$col' is not a valid column.\n";
return;
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $ID_INDEX) {
warn "The ID column is read-only.\n";
}
else {
warn "Column '$col' is not a valid column for value '$new_value'.\n";
}
return 1;
}
sub set_value
{
my ($self, $path, $column, $new_value) = @_;
my $row_index = $path->get_indices();
my $event = $self->{EVENTS}->[$row_index];
$self->set_event_column($event, $column, $new_value);
return 1;
}
########################
# Tree Model Interface #
########################
sub GET_FLAGS
{
return 'list-only';
}
sub GET_N_COLUMNS
{
my $self = shift;
return $self->{NB_COLUMNS};
}
sub GET_COLUMN_TYPE
{
return 'Glib::String';
}
sub GET_ITER
{
my ($self, $path) = @_;
my $index = $path->get_indices();
my $iter = [ $index, $index, undef, undef ];
# Find the first non-deleted item
unless (exists($self->{EVENTS}->[$index])) {
$iter = $self->ITER_NEXT($iter);
}
return $iter;
}
sub GET_PATH
{
my ($self, $iter) = @_;
return Gtk2::TreePath->new($iter->[1]);
}
sub GET_VALUE
{
my ($self, $iter, $column) = @_;
my $index = $iter->[1];
my $event = $self->{EVENTS}->[$index];
return "(missing)" unless defined($event); # TODO: remove this
my $value = $self->get_event_column($event, $column);
return defined($value) ? $value : "";
}
sub ITER_NEXT
{
my ($self, $iter) = @_;
my $index = $iter->[1] + 1;
# Skip over deleted items
while ($index < @{$self->{EVENTS}}) {
if (exists($self->{EVENTS}->[$index])) {
return [ $index, $index, undef, undef ];
}
$index++;
}
return;
}
# This is a list store, there are no children
sub ITER_CHILDREN
{
return;
}
sub ITER_HAS_CHILD
{
return 0;
}
sub ITER_N_CHILDREN
{
return 0;
}
sub ITER_NTH_CHILD
{
return;
}
sub ITER_PARENT
{
return;
}
1;
email-reminder-0.7.7/EmailReminder/WeeklyStore.pm 0000644 0001750 0001750 00000003664 11136761374 022163 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::WeeklyStore;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
use EmailReminder::EventStore;
use EmailReminder::WeeklyEvent;
use base qw(EmailReminder::EventStore);
# Column indices
my $NAME_INDEX = 1;
my $DAY_INDEX = 2;
sub init
{
my ($self) = @_;
$self->{TYPE} = EmailReminder::WeeklyEvent->get_type();
$self->{NB_COLUMNS} = EmailReminder::WeeklyEvent->get_nb_fields();
$self->EmailReminder::EventStore::init();
return 1;
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $NAME_INDEX) {
return $event->get_name();
}
elsif ($col == $DAY_INDEX) {
return $event->get_day();
}
else {
return $self->EmailReminder::EventStore::get_event_column($event, $col);
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $NAME_INDEX) {
$event->set_name($new_value);
}
elsif ($col == $DAY_INDEX) {
$event->set_day($new_value);
}
else {
$self->EmailReminder::EventStore::set_event_column($event, $col, $new_value);
}
return 1;
}
1;
email-reminder-0.7.7/EmailReminder/EventList.pm 0000644 0001750 0001750 00000021465 11151141662 021607 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::EventList;
# Holds all user information and events.
#
# Events are stored in the proper EventStore and they can be accessed
# using this class. The main XML parsing and generation happen here.
use strict;
use warnings;
use Email::Valid;
use XML::DOM;
use EmailReminder::AnniversaryEvent;
use EmailReminder::AnniversaryStore;
use EmailReminder::BirthdayEvent;
use EmailReminder::BirthdayStore;
use EmailReminder::MonthlyEvent;
use EmailReminder::MonthlyStore;
use EmailReminder::Utils;
use EmailReminder::WeeklyEvent;
use EmailReminder::WeeklyStore;
use EmailReminder::YearlyEvent;
use EmailReminder::YearlyStore;
# XML tags, attributes and values
my $EMAIL_TAG = 'email';
my $EVENT_TAG = 'event';
my $EVENTS_TAG = 'events';
my $FIRST_NAME_TAG = 'first_name';
my $LAST_NAME_TAG = 'last_name';
my $USER_TAG = 'email-reminder_user';
my $AUTHOR_WISHES_TAG = 'send_author_wishes';
my $TYPE_ATTR = 'type';
sub new
{
my ($class, $filename, $create) = @_;
my $self = { "NEXT_EVENT_ID" => 0,
"LOADED_FILENAME" => $filename,
"XML_DOC" => undef,
"EVENTS_NODE" => undef,
"STORES" => {},
};
bless $self, $class;
$self->process_file($create);
return $self;
}
sub process_file
{
my ($self, $create, $readonly) = @_;
# Make sure the config file exists and is readable
my $filename = $self->{LOADED_FILENAME};
unless (-e $filename) {
if ($create and open my $config_fh, '>:utf8', "$filename") {
print $config_fh '';
close $config_fh;
}
else {
die "File '$filename' does not exist and it is impossible to create it.\n";
}
}
unless (-r $filename) {
die "File '$filename' exists but is not readable.\n";
}
if (!$readonly && !(-w $filename)) {
warn "WARNING: File '$filename' is not writable, your changes will be lost!\n";
}
# Start parsing the XML file
my $parser = XML::DOM::Parser->new();
my $doc;
eval {
$doc = $parser->parsefile($filename);
};
unless (defined($doc)) {
die "File '$filename' is an invalid XML file. Fix it or delete it.\n";
}
$self->{XML_DOC} = $doc;
# Read user info
my $user = $doc->getElementsByTagName($USER_TAG)->item(0);
unless (defined($user)) {
die "File '$filename' is an invalid XML file. Fix it or delete it.\n";
}
$self->{USER_NODE} = $user;
# Read events
my $events = $doc->getElementsByTagName($EVENTS_TAG)->item(0);
return unless defined($events);
$self->{EVENTS_NODE} = $events;
foreach my $event_node ($events->getElementsByTagName($EVENT_TAG)) {
my $type = $event_node->getAttribute($TYPE_ATTR);
my $event = $self->create_event($type, $event_node);
next unless defined($event);
# Add to proper EventStore
my $store = $self->get_model($type);
$store->add_event($event);
}
return 1;
}
sub create_event
{
my ($self, $type, $event_node) = @_;
if (!defined($event_node))
{
$event_node = $self->{XML_DOC}->createElement($EVENT_TAG);
$event_node->setAttribute($TYPE_ATTR, $type);
my $events = $self->{EVENTS_NODE};
unless (defined($events))
{
$events = $self->{XML_DOC}->createElement($EVENTS_TAG);
$self->{USER_NODE}->appendChild($events);
$self->{EVENTS_NODE} = $events;
}
$events->appendChild($event_node);
}
my $event;
my $id = $self->{NEXT_EVENT_ID}++;
if ($type eq EmailReminder::BirthdayEvent->get_type()) {
$event = EmailReminder::BirthdayEvent->new($event_node, $id);
}
elsif ($type eq EmailReminder::AnniversaryEvent->get_type()) {
$event = EmailReminder::AnniversaryEvent->new($event_node, $id);
}
elsif ($type eq EmailReminder::MonthlyEvent->get_type()) {
$event = EmailReminder::MonthlyEvent->new($event_node, $id);
}
elsif ($type eq EmailReminder::WeeklyEvent->get_type()) {
$event = EmailReminder::WeeklyEvent->new($event_node, $id);
}
elsif ($type eq EmailReminder::YearlyEvent->get_type()) {
$event = EmailReminder::YearlyEvent->new($event_node, $id);
}
return $event;
}
sub save
{
my $self = shift;
my $verbose = shift;
my $filename = shift || $self->{LOADED_FILENAME};
my $xml_document = $self->{XML_DOC}->toString();
print $xml_document if $verbose;
# Overwrite the file
if (open my $out_fh, '>:utf8', "$filename") {
print $out_fh $xml_document;
print "Sucessfully wrote reminders to '$filename'\n" if $verbose;
close $out_fh;
}
else {
print STDERR "Cannot write to file '$filename', your changes have been lost.\n";
}
return 1;
}
sub get_model
{
my ($self, $type) = @_;
my $store = $self->{STORES}->{$type};
unless (defined($store)) {
if ($type eq EmailReminder::AnniversaryEvent->get_type()) {
$store = EmailReminder::AnniversaryStore->new();
}
elsif ($type eq EmailReminder::BirthdayEvent->get_type()) {
$store = EmailReminder::BirthdayStore->new();
}
elsif ($type eq EmailReminder::MonthlyEvent->get_type()) {
$store = EmailReminder::MonthlyStore->new();
}
elsif ($type eq EmailReminder::WeeklyEvent->get_type()) {
$store = EmailReminder::WeeklyStore->new();
}
elsif ($type eq EmailReminder::YearlyEvent->get_type()) {
$store = EmailReminder::YearlyStore->new();
}
$store->init();
$self->{STORES}->{$type} = $store;
}
return $store;
}
sub get_events
{
my $self = shift;
my @events = ();
foreach my $store (values(%{$self->{STORES}})) {
push(@events, @{$store->get_events()});
}
return @events;
}
sub add_event
{
my ($self, $event_type) = @_;
my $event = $self->create_event($event_type);
return 0 unless defined($event);
$event->set_name("");
$event->set_reminders([0]); # default reminder: same day
return $self->{STORES}->{$event_type}->add_event($event);
}
# View/edit user properties
sub _get_user_fname {
my $self = shift;
return EmailReminder::Utils::get_node_value($self->{USER_NODE}, $FIRST_NAME_TAG) || '';
}
sub _get_user_lname {
my $self = shift;
return EmailReminder::Utils::get_node_value($self->{USER_NODE}, $LAST_NAME_TAG) || '';
}
sub get_user_name
{
my $self = shift;
my $fname = $self->_get_user_fname;
my $lname = $self->_get_user_lname;
if (!$fname && !$lname) {
# Get name from UNIX password file
my @pwinfo = getpwuid($>);
my $fullname = $pwinfo[6];
$fullname =~ s/[^0-9A-Za-z_\- ]//g;
my @name_parts = split(/ /, $fullname);
$fname = $name_parts[0];
$lname = $name_parts[-1] if @name_parts > 1;
} elsif (!$fname) {
$fname = $lname;
$lname = '';
}
return ($fname, $lname);
}
sub get_user_email
{
my $self = shift;
return EmailReminder::Utils::get_node_value($self->{USER_NODE}, $EMAIL_TAG) || "";
}
sub set_user_fname
{
my ($self, $new_fname) = @_;
return EmailReminder::Utils::set_node_value($self->{USER_NODE}, $FIRST_NAME_TAG, $new_fname);
}
sub set_user_lname
{
my ($self, $new_lname) = @_;
return EmailReminder::Utils::set_node_value($self->{USER_NODE}, $LAST_NAME_TAG, $new_lname);
}
sub get_author_wishes
{
my $self = shift;
return EmailReminder::Utils::get_node_value($self->{USER_NODE}, $AUTHOR_WISHES_TAG);
}
sub set_author_wishes
{
my ($self, $new_author_wishes) = @_;
return EmailReminder::Utils::set_node_value($self->{USER_NODE}, $AUTHOR_WISHES_TAG, $new_author_wishes);
}
# Return 0 if the email was ignored (invalid)
sub set_user_email
{
my ($self, $new_email) = @_;
if (!$new_email || Email::Valid->address($new_email)) {
return EmailReminder::Utils::set_node_value($self->{USER_NODE}, $EMAIL_TAG, $new_email);
} else {
return 0;
}
}
1;
email-reminder-0.7.7/EmailReminder/WeeklyEvent.pm 0000644 0001750 0001750 00000005754 11136573124 022144 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::WeeklyEvent;
use strict;
use warnings;
use overload '""' => \&str;
use Date::Manip;
use POSIX;
use Scalar::Util;
use EmailReminder::Event;
use EmailReminder::Utils;
use base qw(EmailReminder::Event);
# XML tags
__PACKAGE__->mk_accessors(qw(day));
# Global date variables
my $current_time = ParseDate("now");
my $current_date = ParseDate(UnixDate($current_time, "\%x"));
my $current_dayofweek = UnixDate($current_time, "\%w");
sub str {
my ($self) = @_;
return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' - ' . $self->get_day;
}
# Hard-coded value for this event's type (class method)
sub get_type
{
return 'weekly';
}
# Number of fields this event adds to its parent (class method)
sub get_nb_fields
{
my ($self) = @_;
return $self->SUPER::get_nb_fields() + 2;
}
sub valid_day
{
my ($class, $new_value) = @_;
if (!Scalar::Util::looks_like_number($new_value)) {
# Try to parse as a string
my $day = UnixDate(ParseDate($new_value), "\%w");
if ($day) {
$new_value = $day;
} else {
$new_value = 7; # Default: Sunday
}
}
if ($new_value > 7 or $new_value < 1) {
# Default to Sunday for out of range dates (since zero is
# both 0 and 7).
$new_value = 7;
}
return $new_value;
}
sub get_subject
{
my $self = shift;
return $self->get_name();
}
sub get_message_body
{
my $self = shift;
# event details
my $when = $self->{"WHEN"};
my $name = $self->get_name();
my $message = <<"MESSAGEEND";
I just want to remind you of the following event $when:
$name
MESSAGEEND
return $message;
}
# Returns 1 if the event will occur in X days (X is a param)
sub will_occur
{
my $self = shift;
my $modifier = shift;
# Apply the modifier to the event date
my $modified_day = $self->get_day();
return 0 unless $modified_day;
if ($modifier) {
$modified_day -= $modifier;
while ($modified_day > 7) {
$modified_day -= 7;
}
while ($modified_day < 1) {
$modified_day += 7;
}
}
if ($current_dayofweek == $modified_day) {
return 1;
} else {
return 0;
}
}
1;
email-reminder-0.7.7/EmailReminder/BirthdayStore.pm 0000644 0001750 0001750 00000003427 11136761510 022456 0 ustar francois francois # This file is part of Email-Reminder.
#
# Email-Reminder is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.
#
# Email-Reminder is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Email-Reminder; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
package EmailReminder::BirthdayStore;
use strict;
use warnings;
use Gtk2;
use Glib::Object::Subclass
Glib::Object::,
interfaces => [ Gtk2::TreeModel:: ],
;
use EmailReminder::BirthdayEvent;
use EmailReminder::EventStore;
use base qw(EmailReminder::EventStore);
# Column indices
my $EMAIL_INDEX = 3;
sub init
{
my ($self) = @_;
$self->{TYPE} = EmailReminder::BirthdayEvent->get_type();
$self->{NB_COLUMNS} = EmailReminder::BirthdayEvent->get_nb_fields();
$self->EmailReminder::EventStore::init();
return 1;
}
sub get_event_column
{
my ($self, $event, $col) = @_;
if ($col == $EMAIL_INDEX) {
return $event->get_email();
}
else {
return $self->EmailReminder::YearlyStore::get_event_column($event, $col);
}
}
sub set_event_column
{
my ($self, $event, $col, $new_value) = @_;
if ($col == $EMAIL_INDEX) {
$event->set_email($new_value);
}
else {
$self->EmailReminder::YearlyStore::set_event_column($event, $col, $new_value);
}
return 1;
}
1;
email-reminder-0.7.7/COPYING 0000644 0001750 0001750 00000104513 10714457365 015664 0 ustar francois francois GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
Copyright (C)
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
.