1
0
mirror of https://github.com/imapsync/imapsync.git synced 2024-11-17 00:02:29 +01:00
This commit is contained in:
Nick Bebout 2011-03-12 02:43:47 +00:00
parent 564aed33ea
commit 1ae8613d80
6 changed files with 83 additions and 44 deletions

View File

@ -1,15 +1,41 @@
RCS file: RCS/imapsync,v RCS file: RCS/imapsync,v
Working file: imapsync Working file: imapsync
head: 1.31 head: 1.37
branch: branch:
locks: strict locks: strict
access list: access list:
symbolic names: symbolic names:
keyword substitution: kv keyword substitution: kv
total revisions: 31; selected revisions: 31 total revisions: 37; selected revisions: 37
description: description:
---------------------------- ----------------------------
revision 1.37
date: 2003/10/16 01:37:52; author: gilles; state: Exp; lines: +9 -8
Added a loop in case there is several identical key header
----------------------------
revision 1.36
date: 2003/10/16 01:23:51; author: gilles; state: Exp; lines: +4 -38
Removed commented code in parse section.
----------------------------
revision 1.35
date: 2003/10/16 01:22:52; author: gilles; state: Exp; lines: +20 -19
Use of parse_header_msg() in "to" server
----------------------------
revision 1.34
date: 2003/10/16 01:18:07; author: gilles; state: Exp; lines: +49 -24
Wrote parse_header_msg()
Use of parse_header_msg for "from" server.
----------------------------
revision 1.33
date: 2003/10/16 00:47:43; author: gilles; state: Exp; lines: +6 -6
Added prefix in debug output for headers
----------------------------
revision 1.32
date: 2003/10/16 00:36:17; author: gilles; state: Exp; lines: +17 -5
Added code to check internal dates
Commented code about internal dates
----------------------------
revision 1.31 revision 1.31
date: 2003/08/28 16:07:28; author: gilles; state: Exp; lines: +5 -5 date: 2003/08/28 16:07:28; author: gilles; state: Exp; lines: +5 -5
Fixed bug converting separators Fixed bug converting separators

4
README
View File

@ -1,7 +1,7 @@
NAME NAME
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.31 $ $Revision: 1.37 $
INSTALL INSTALL
Get imapsync at http://www.linux-france.org/prj/imapsync/dist/ Get imapsync at http://www.linux-france.org/prj/imapsync/dist/
@ -126,5 +126,5 @@ SIMILAR SOFTWARES
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.31 2003/08/28 16:07:28 gilles Exp $ $Id: imapsync,v 1.37 2003/10/16 01:37:52 gilles Exp $

8
TODO
View File

@ -9,3 +9,11 @@ Update the list of tested IMAP servers (successes and failures).
Add a CREDITS file. Add a CREDITS file.
Pb with namespace INBOX.
http://www.inter7.com/courierimap/FAQ.html#namespace
http://www.rfc-editor.org/rfc/rfc2342.txt
Pb with date
Pb with \Recent flag

View File

@ -1 +1 @@
1.31 1.37

View File

@ -4,7 +4,7 @@
imapsync - synchronize mailboxes between two imap servers. imapsync - synchronize mailboxes between two imap servers.
$Revision: 1.31 $ $Revision: 1.37 $
=head1 INSTALL =head1 INSTALL
@ -146,7 +146,7 @@ Rate imapsync : http://freshmeat.net/projects/imapsync/
Feedback (good or bad) will be always welcome. Feedback (good or bad) will be always welcome.
$Id: imapsync,v 1.31 2003/08/28 16:07:28 gilles Exp $ $Id: imapsync,v 1.37 2003/10/16 01:37:52 gilles Exp $
=cut =cut
@ -169,12 +169,12 @@ my(
use vars qw ($opt_G); # missing code for this will be option. use vars qw ($opt_G); # missing code for this will be option.
$rcs = ' $Id: imapsync,v 1.31 2003/08/28 16:07:28 gilles Exp $ '; $rcs = ' $Id: imapsync,v 1.37 2003/10/16 01:37:52 gilles Exp $ ';
$rcs =~ m/,v (\d+\.\d+)/; $rcs =~ m/,v (\d+\.\d+)/;
$VERSION = ($1) ? $1 : "UNKNOWN"; $VERSION = ($1) ? $1 : "UNKNOWN";
$error=0; $error=0;
my $banner = '$RCSfile: imapsync,v $ ' . '$Revision: 1.31 $ ' . '$Date: 2003/08/28 16:07:28 $ ' . "\n"; my $banner = '$RCSfile: imapsync,v $ ' . '$Revision: 1.37 $ ' . '$Date: 2003/10/16 01:37:52 $ ' . "\n";
get_options(); get_options();
@ -318,44 +318,12 @@ FOLDER: foreach my $f_fold (@f_folders) {
$debug and print "From Parse\n"; $debug and print "From Parse\n";
foreach my $m (@f_msgs) { foreach my $m (@f_msgs) {
$debug and print "-" x 50, "\nMSG $m\n"; parse_header_msg($m, $from, "F", \%f_hash);
my $head = $from->parse_headers($m,"ALL");
my $headstr;
$debug and print "Head NUM:", scalar(keys(%$head)), "\n";
next unless(scalar(keys(%$head)));
foreach my $h (sort keys(%$head)){
my $val = $head->{$h}[0];
# no accent in headers !
$val =~ y/éèàù/XXXX/;
$debug and print "H $h:", $val, "\n";
$headstr .= "$h:". $val;
}
my $m_md5 = md5_base64($headstr);
my $size = $from->size($m);
$debug and print "From $m:$m_md5:$size\n";
$f_hash{"$m_md5:$size"}{'5'} = "$m_md5:$size";
$f_hash{"$m_md5:$size"}{'s'} = $size;
$f_hash{"$m_md5:$size"}{'m'} = $m;
} }
$debug and print "To Parse\n"; $debug and print "To Parse\n";
foreach my $m (@t_msgs) { foreach my $m (@t_msgs) {
$debug and print "-" x 50, "\nMSG $m\n"; parse_header_msg($m, $to, "T", \%t_hash);
my $head = $to->parse_headers($m,"ALL");
my $headstr;
$debug and print "Head NUM:", scalar(keys(%$head)), "\n";
next unless(scalar(keys(%$head)));
foreach my $h (sort keys(%$head)){
$debug and print "$h:", $head->{$h}[0], "\n";
$headstr .= "$h:".$head->{$h}[0];
}
my $m_md5 = md5_base64($headstr);
my $size = $to->size($m);
$debug and print "To $m:$m_md5:$size\n";
$t_hash{"$m_md5:$size"}{'5'} = "$m_md5:$size";
$t_hash{"$m_md5:$size"}{'s'} = $size;
$t_hash{"$m_md5:$size"}{'m'} = $m;
} }
$debug and print "Verifying\n"; $debug and print "Verifying\n";
# messages in "from" that are not good in "to" # messages in "from" that are not good in "to"
@ -370,6 +338,10 @@ FOLDER: foreach my $f_fold (@f_folders) {
print "Copying msg #$f_msg:$f_size to folder $t_fold\n"; print "Copying msg #$f_msg:$f_size to folder $t_fold\n";
unless ($dry) { unless ($dry) {
my $string = $from->message_string($f_msg); my $string = $from->message_string($f_msg);
#my $d = $from->internaldate($f_msg);
#my $date_f = `date -d"$d" "+%d-%b-%Y %T %z"`;
#print "date from 1: [$d]\n";
#print "date from 2: [$date_f]\n";
my $flags_f = join(" ", @{$from->flags($f_msg)}); my $flags_f = join(" ", @{$from->flags($f_msg)});
my $new_id; my $new_id;
print "flags from : [$flags_f]\n"; print "flags from : [$flags_f]\n";
@ -404,7 +376,15 @@ FOLDER: foreach my $f_fold (@f_folders) {
$debug and print $debug and print
"flags from : @flags_f\n", "flags from : @flags_f\n",
"flags to : @flags_t\n"; "flags to : @flags_t\n";
$debug and print "Looking dates\n";
my $d_f = $from->internaldate($f_msg);
my $d_t = $to->internaldate($t_msg);
$debug and print
"idate from : $d_f\n",
"idate to : $d_t\n";
#unless ($d_f eq $d_t) {
# print "!!! Dates differ !!!\n";
#}
unless ($f_size == $t_size) { unless ($f_size == $t_size) {
# Bad size # Bad size
print print
@ -471,6 +451,31 @@ sub get_options
} }
sub parse_header_msg {
my ($m, $imap, $s, $s_hash) = @_;
$debug and print "-" x 50, "\nMSG $m\n";
my $head = $imap->parse_headers($m,"ALL");
my $headstr;
$debug and print "Head NUM:", scalar(keys(%$head)), "\n";
return unless(scalar(keys(%$head)));
foreach my $h (sort keys(%$head)){
foreach my $val ( @{$head->{$h}}) {
# no accent in headers !
$val =~ y/éèàù/XXXX/;
$debug and print "${s}H $h:", $val, "\n";
$headstr .= "$h:". $val;
}
}
my $m_md5 = md5_base64($headstr);
my $size = $imap->size($m);
$debug and print "$s msg $m:$m_md5:$size\n";
$s_hash->{"$m_md5:$size"}{'5'} = "$m_md5:$size";
$s_hash->{"$m_md5:$size"}{'s'} = $size;
$s_hash->{"$m_md5:$size"}{'m'} = $m;
}
sub firstline { sub firstline {
# extract the first line of a file (without \n) # extract the first line of a file (without \n)

View File