/usr/share/perl5/EmailReminder/EventStore.pm is in email-reminder 0.7.8-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | # 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;
|