/usr/share/perl5/VUser/Google/EmailSettings/V2_0.pm is in libvuser-google-api-perl 1.0.1-1.
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 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | package VUser::Google::EmailSettings::V2_0;
use warnings;
use strict;
# Copyright (C) 2009 Randy Smith, perlstalker at vuser dot org
our $VERSION = '0.1.0';
use Moose;
extends 'VUser::Google::EmailSettings';
# BUG: This should work but doesn't seem to. WTF?
#has '+google' => (isa => 'VUser::Google::ApiProtocol::V2_0');
has '+base_url' => (default => 'https://apps-apis.google.com/a/feeds/emailsettings/2.0/');
## Methods
# Constructor
sub BUILD {}
override 'CreateLabel' => sub {
my $self = shift;
my %options = @_;
my $label = $options{'label'};
$self->google()->Login();
my $url = $self->base_url().$self->google()->domain().'/'.$self->user().'/label';
my $post = "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns:apps=\"http://schemas.google.com/apps/2006\">
<apps:property name=\"label\" value=\"$label\" />
</atom:entry>";
return $self->google->Request('POST', $url, $post);
};
override 'CreateFilter' => sub {
my $self = shift;
my %options = @_;
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/filter';
my $post = '<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
## Add criteria
if (defined $options{hasAttachment}) {
$options{hasAttachment} = $options{hasAttachment}? 'true':'false';
}
foreach my $crit qw(from to subject hasTheWord doesNotHaveTheWord hasAttachment) {
if (defined $options{$crit}) {
$post .= sprintf ("<apps:property name=\"%s\" value=\"%s\" />",
$crit, $options{$crit});
}
}
## Add actions
foreach my $act qw(shouldMarkAsRead shouldArchive) {
$options{$act} = $options{$act}? 'true':'false';
}
foreach my $act qw(label shouldMarkAsRead shouldArchive) {
if (defined $options{$act}) {
$post .= sprintf ("<apps:property name=\"%s\" value=\"%s\" />",
$act, $options{$act});
}
}
$post .= '</atom:entry>';
return $self->google->Request('POST', $url, $post);
};
override 'CreateSendAsAlias' => sub {
my $self = shift;
my %options = @_;
my $name = $options{'name'};
my $address = $options{'address'};
my $reply_to = $options{'replyTo'};
my $make_default = $options{'makeDefault'};
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/sendas';
my $post = '<?xml version="1.0" encoding="utf-8"?>
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
$post .= "<apps:property name='name' value='$name' />";
$post .= "<apps:property name='address' value='$address' />";
if (defined $reply_to) {
$post .= "<apps:property name='replyTo' value='$reply_to' />";
}
if (defined $make_default) {
$post .= sprintf("<apps:property name='makeDefault' value='%s' />",
$make_default? 'true' : 'false'
);
}
$post .= '</atom:entry>';
return $self->google->Request('POST', $url, $post);
};
override 'UpdateWebClip' => sub {
my $self = shift;
my %options = @_;
my $enable = $options{'enable'};
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/webclip';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
$post .= sprintf('<apps:property name="enable" value="%s" />',
$enable ? 'true' : 'false'
);
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateForwarding' => sub {
my $self = shift;
my %options = @_;
my $enable = $options{'enable'};
my $forward_to = $options{'forwardTo'};
my $action = $options{'action'};
$action = uc($action);
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/forwarding';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
if (defined $enable) {
$post .= sprintf('<apps:property name="enable" value="%s" />',
$enable ? 'true' : 'false');
}
if ($enable) {
if ($forward_to) {
$post .= "<apps:property name='forwardTo' value='$forward_to' />";
}
if ($action) {
if ($action ne 'KEEP'
and $action ne 'ARCHIVE'
and $action ne 'DELETE'
) {
die "action must be KEEP, ARCHIVE or DELETE";
}
$post .= "<apps:property name='action' value='$action' />";
}
}
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdatePOP' => sub {
my $self = shift;
my %options = @_;
my $enable = $options{'enable'};
my $enable_for = $options{'enableFor'};
my $action = $options{'action'};
$action = uc($action);
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/pop';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
if (defined $enable) {
$post .= sprintf('<apps:property name="enable" value="%s" />',
$enable ? 'true' : 'false');
}
if ($enable) {
if ($enable_for) {
$post .= "<apps:property name='enableFor' value='$enable_for' />";
}
if ($action) {
if ($action ne 'KEEP'
and $action ne 'ARCHIVE'
and $action ne 'DELETE'
) {
die "action must be KEEP, ARCHIVE or DELETE";
}
$post .= "<apps:property name='action' value='$action' />";
}
}
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateIMAP' => sub {
my $self = shift;
my %options = shift;
my $enable = $options{'enable'};
$self->google()->Login();
my $url = $self->base_url().$self->google->domain().'/'.$self->user().'/imap';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
if (defined $enable) {
$post .= sprintf('<apps:property name="enable" value="%s" />',
$enable ? 'true' : 'false');
}
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateVacationResponder' => sub {
my $self = shift;
my %options = @_;
my $enable = $options{'enable'};
my $subject = $options{'subject'};
my $message = $options{'message'};
my $contacts = $options{'contactsOnly'};
$self->google->Login();
my $url = $self->base_url().$self->google->domain.'/'.$self->user.'/vacation';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
$post .= sprintf('<apps:property name="enable" value="%s" />',
$enable ? 'true' : 'false');
if (defined $enable) {
$post .= sprintf('<apps:property name="subject" value="%s" />',
defined $subject ? $subject : '');
$post .= sprintf('<apps:property name="message" value="%s" />',
defined $message ? $message : '');
$post .= sprintf('<apps:property name="contactsOnly" value="%s" />',
$contacts ? 'true' : 'false');
}
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateSignature' => sub {
my $self = shift;
my %options = shift;
my $sig = $options{'signature'};
$self->google->Login();
my $url = $self->base_url().$self->google->domain.'/'.$self->user.'/signature';
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
$post .= sprintf('<apps:property name="signature" value="%s" />',
$sig ? $sig : '');
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateLanguage' => sub {
my $self = shift;
my %options = shift;
my $lang = $options{'language'};
$self->google->Login();
my $url = $self->base_url().$self->google->domain.'/'.$self->user.'/language';
if ($lang !~ /^\w\w(?:-\w\w)?/i) {
$lang = 'en-US';
}
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
$post .= sprintf('<apps:property name="language" value="%s" />',
$lang ? $lang : '');
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
override 'UpdateGeneral' => sub {
my $self = shift;
my %options = @_;
$self->google->Login();
my $url = $self->base_url().$self->google->domain.'/'.$self->user.'/general';
foreach my $opt qw(shortcuts arrows snippets unicode) {
$options{$opt} = $options{$opt}? 'true':'false';
}
my $post = '<?xml version="1.0" encoding="utf-8"?>';
$post .= '<atom:entry xmlns:atom="http://www.w3.org/2005/Atom" xmlns:apps="http://schemas.google.com/apps/2006">';
foreach my $opt (keys %options) {
if (defined $options{$opt}) {
$post .= sprintf ("<apps:property name=\"%s\" value=\"%s\" />",
$opt, $options{$opt});
}
}
$post .= '</atom:entry>';
return $self->google->Request('PUT', $url, $post);
};
no Moose;
1;
__END__
=head1 NAME
VUser::Google::EmailSettings::V2_0 - Support version 2.0 of the Google Email Settings API
=head1 SEE ALSO
L<VUser::Google::EmailSettings>, L<VUser::Google::ApiProtocol>,
L<VUser::Google::ApiProtocol::V2_0>
=over 4
=item Google Email Settings API
http://code.google.com/apis/apps/email_settings/developers_guide_protocol.html
=back
=head1 BUGS
Report bugs at http://code.google.com/p/vuser/issues/list.
=head1 AUTHOR
Randy Smith, perlstalker at vuser dot net
=head1 COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.5 or,
at your option, any later version of Perl 5 you may have available.
If you make useful modification, kindly consider emailing then to me for inclusion in a future version of this module.
=cut
|