Code Search for Developers
 
 
  

import_imho.html from AlphaMail at Krugle


Show import_imho.html syntax highlighted

% # vim:set syntax=mason:
<%args>
$cancel => 0
</%args>
<%init>
if($cancel) {
   $m->redirect("/mail/index.html");
}

my $user = Apache::SiteControl->getCurrentUser($r);
my $dir = $config->get("message_tmpdir", '/tmp');
my ($c, $headers, $message, $folder, $entity, $ab);
my $parser = new MIME::Parser;
my $book = new AlphaMail::AddressBook($user->getUsername(), $user->getAttribute('imap'), $config);

eval {
   $c = new AlphaMail::Middleware($user->getAttribute('imap'),
                                 $user->getUsername(), 
                                 $user->getAttribute('password'), 
                                 $config);
   $headers = $c->getMessageHeaders('mail/.imhoprefs', 1, 1, 'date');
   $message = $c->getMessage('mail/.imhoprefs', $headers->[0]{uid}, $headers->[0]{uidvalidity});
   $parser->output_under($dir);
   $parser->output_prefix($user->getUsername());
   $parser->decode_headers(0);
   $parser->ignore_errors(0);
   $entity = $parser->parse_open("<$message");
   $ab = get_addresses($entity);

   for my $k (sort keys %$ab) {
      $logger->debug("Merging $k: @{$ab->{$k}}");
      $book->merge($k, [ @{$ab->{$k}} ]);
   }
   $c->close;
   $message = "Your address book was successfully merged.";
};
if($@) {
   $logger->error("failed: $@");
   $message = "Error. Could not import old address book: $@";
}

$m->redirect(build_url('/mail/addressbook/index.html', { selected => 'Contacts',
   message => $message }));
</%init>
<%once>
use AlphaMail::HTMLHelper qw(build_url);
use AlphaMail::AddressBook;

our $logger = Log::Log4perl->get_logger('alphamail');

sub get_addresses
{
   my $entity = shift;
   my $result = {};
   my $foundit = 0;
   my $name;
   my $addresses;
   my @addrs;
 
   my $path = $entity->bodyhandle->path;
   open DATA, "<$path" or croak "Could not open $path";

   while(<DATA>) {
      $logger->debug($_);
      last if $foundit && m/^#/;
      $foundit = 1 if m/^#addressbook/;
      next if !$foundit;
      next if !m/(?:#addressbook\s*=\s*)?([^:]*):(.*)$/;
      $name = $1;
      $addresses = $2;
      $logger->debug("name: $name, addrs: $addresses");
      $addresses =~ s/\s*//g;
      $addresses =~ s/\Q<br>\E$//;
      @addrs = split /,/, $addresses;
      $result->{$name} = [ @addrs ];
   }

   return $result;
}
</%once>




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  autohandler
  edit.mhtml
  import.mhtml
  import_csv.html
  import_imho.html
  index.html
  process_edit.html
  take.html