diff --git a/ChangeLog b/ChangeLog
index c910d54..0653e12 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,17 +1,37 @@
RCS file: RCS/imapsync,v
Working file: imapsync
-head: 1.580
+head: 1.584
branch:
locks: strict
- gilles: 1.580
+ gilles: 1.584
access list:
symbolic names:
keyword substitution: kv
-total revisions: 580; selected revisions: 580
+total revisions: 584; selected revisions: 584
description:
----------------------------
-revision 1.580 locked by: gilles;
+revision 1.584 locked by: gilles;
+date: 2014/02/05 00:40:59; author: gilles; state: Exp; lines: +77 -50
+Debug. Print separator given by NAMESPACE even when --sep1 oe --sep2 is used.
+Debug. Prints prefix given by NAMESPACE even when --prefix1 or --prefix2 is used.
+(Preparation for advising not to use --prefix unless suggested)
+----------------------------
+revision 1.583
+date: 2014/02/04 03:04:35; author: gilles; state: Exp; lines: +15 -11
+Bug fix. --ssl1 --tls2 was buggy because of default SSL_VERIFY_PEER. "Can not go to tls encryption on [localhost]:Unable to start TLS: Cannot determine peer hostname for verificationerror:00000000:lib(0):func(0):reason(0)"
+----------------------------
+revision 1.582
+date: 2014/01/24 01:43:19; author: gilles; state: Exp; lines: +20 -12
+Bugfix. Check if going to tls is ok, exit otherwise with explicit error message.
+Thanks to Dennis Schridde for reporting this ugly bug.
+----------------------------
+revision 1.581
+date: 2014/01/15 02:42:06; author: gilles; state: Exp; lines: +41 -15
+Added --debugmaxlinelength
+Added --minmaxlinelength to select messages with long lines only.
+----------------------------
+revision 1.580
date: 2013/12/25 02:52:36; author: gilles; state: Exp; lines: +51 -27
Added --skipcrossduplicates to avoid copying messages that are already copied in another folder.
Added --debugcrossduplicates to print which messages (UIDs) are skipped with --skipcrossduplicates (and in what other folders they are).
diff --git a/FAQ b/FAQ
index 74b5b58..58d2c84 100644
--- a/FAQ
+++ b/FAQ
@@ -1,5 +1,5 @@
#!/bin/cat
-# $Id: FAQ,v 1.161 2013/12/25 03:25:18 gilles Exp gilles $
+# $Id: FAQ,v 1.166 2014/01/27 02:23:30 gilles Exp gilles $
+------------------+
| FAQ for imapsync |
@@ -1601,11 +1601,15 @@ R. This error message comes from Exchange IMAP server when it
encounters any problem. Most of the time it is one of the following:
* Some messages are bigger than the size limit. 10 MB by default
- on Exchange. It can be upped by configuration.
- Or use option --maxsize 10000000 (for 10 MB, change it if needed)
- to tell imapsync to skip those messages.
+ on Exchange. It can be upped by configuration for Exchange.
+ If you configure this limit then use option --maxsize 10000000
+ for 10 MB, change it if needed) to tell imapsync to skip those messages.
+ This value is 25 MB for Office365 --maxsize 25000000
- imapsync ... --maxsize 10000000
+ imapsync ... --maxsize 10000000 # 10 MB for Exchange
+
+ imapsync ... --maxsize 25000000 # 25 MB for Office365
+
* Quota reached. The whole account is full.
It can be upped by configuration.
@@ -1645,45 +1649,7 @@ Thanks to Dave Murray and Simon Savva for reporting and solving
this issue.
=======================================================================
-Q. From Zimbra to XXX
-
-imapsync ... \
- --exclude "Conversation Action Settings" \
- --exclude "Quick Step Settings" \
- --exclude "News Feed"
-
-=======================================================================
-Q. From or to HMailServer version 4.4.1.
-
-R. You have to add prefix and separator manually because 4.4.1 doesn't
-honor the NAMESPACE imap command.
-
-Example for host1:
-
-imapsync ... \
- --prefix1 "" --sep1 .
-
-No specific option for HMailServer 5.3.3 since NAMESPACE is supported.
-
-Maybe --subscribe_all will help you to see all migrated folders.
-
-
-=======================================================================
-Q. Synchronizing from SmarterMail to XXX
-
-imapsync --host1 imap.d1.org --user1 joe --password1 secret1 --sep1 "/" \
- --host2 imap.d2.org --user2 joe --password2 secret2 \
- --noauthmd5 \
- --prefix1 "" \
- --regextrans2 's#^Inbox$#INBOX#' \
- --regextrans2 's#Sent Items$#Sent#' \
- --dry --justfolders
-
-Maybe add other --regextrans2 to change folder names and see the result.
-When satisfied, run without --dry --justfolders
-
-=======================================================================
-Q. Synchronizing from XXX to Gmail
+Q. Synchronizing from XXX to Gmail
R. There are some details to get the special [Gmail] sub-folders
right. Here's an example of migrating an old "Sent" folder to
@@ -1692,37 +1658,36 @@ R. There are some details to get the special [Gmail] sub-folders
imapsync --host1 mail.oldhost.com \
--user1 my_email@oldhost.com \
--password1 password \
- --host2 imap.gmail.com --ssl2 \
+ --host2 imap.gmail.com \
--user2 my_email@gmail.com \
--password2 password \
+ --ssl2 \
--exitwhenover 500000000 \
- --exclude "\[Gmail\]$" \
--addheader \
- --regextrans2 "s,^Sent$,[Gmail]/Sent Mail," \
- --regextrans2 "s/[ ]+/_/g" \
- --regextrans2 "s/[\^]/_/g" \
- --regextrans2 "s/['\"\\\\]/_/g"
+ --exclude "\[Gmail\]$" \
+ --regextrans2 "s/[ ]+/_/g" \
+ --regextrans2 "s/[\^]/_/g" \
+ --regextrans2 "s/['\"\\\\]/_/g" \
+ --regextrans2 "s,^Sent$,[Gmail]/Sent Mail,"
+Explanations:
-If you're using a different language in Gmail you might adapt
-this example with the folder name translated, an example in French:
+--ssl2 is mandatory since Gmail only supports imap ssl connections.
-imapsync ...
- --regextrans2 "s,^Messages envoy&AOk-s$,[Gmail]/Messages envoy&AOk-s," \
+--exitwhenover 500000000 option is here to avoid locking when
+transfers exceed maximum limit.
+See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
+--exitwhenover is not mandatory in the sense you may be able to
+use an upper value than 500 MB without disconnections; I don't
+know the hard value, it seems to vary, so just have some tries
+and report me what you discover in case you detect something.
The --addheader option is there because "Sent" folder messages
-sometimes lack the "Message-Id" header needed by imapsync
-to identify messages (only when --useuid is not used).
-So option --addheader adds a "Message-Id" header.
-
-You can add --folder "INBOX.Sent" in the example in case
-you want to sync only the "Sent" folder.
-
-The "All Mail" archive pseudo-folder should be updated automaticaly.
-
---exitwhenover option is here to avoid locking when transfers
-exceed maximum limit.
-See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
+sometimes lack the "Message-Id:" and "Received:" headers needed
+by imapsync to identify messages (only when --useuid is not used).
+So option --addheader adds a "Message-Id" header consiting fo
+the imap UID of the message on the host1 folder, like
+"Message-Id: 12345@imapsync".
--exclude "\[Gmail\]$" is there to avoid a small examine/select error:
"Could not examine: 43 NO [NONEXISTENT] Unknown Mailbox: [Gmail]
@@ -1740,9 +1705,25 @@ not accepted by gmail, character ^ to character _ underscore.
--regextrans2 "s/['\"\\\\]/_/g" is optional. It converts
characters ' or " or \ to character _ underscore.
+--regextrans2 "s,^Sent$,[Gmail]/Sent Mail," is to transform the
+folder name "Sent" and adapt it to Gmail "Sent Mail" folder.
+If you're using a different language in Gmail you might adapt
+this example with the folder name translated, an example in French:
+
+imapsync ...
+ --regextrans2 "s,^Messages envoy&AOk-s$,[Gmail]/Messages envoy&AOk-s," \
+
+
+You can add --folder "INBOX.Sent" in the example in case
+you want to sync only the "Sent" folder.
+
You can select folders exported to imap within the gmail preferences,
unselect all "System labels" depending on your needs.
+The "All Mail" archive pseudo-folder should be updated automaticaly.
+
+
+
=======================================================================
Q. Some of the folders are getting created with [IMAP] prefix on Google
side. How to stop creating folder with this prefix?
@@ -1752,21 +1733,47 @@ R. No switch in imapsync since [IMAP]/ prefix is done by Gmail,
it might be configurable with Gmail parameters.
=======================================================================
-Q. Synchronizing from Gmail to XXX
+Q. Synchronizing from Gmail to XXX
R. Gmail needs SSL
./imapsync \
--host1 imap.gmail.com \
- --ssl1 \
--user1 gilles.lamiral@gmail.com \
--password1 gmailsecret \
- --exitwhenover 2500000000 \
--host2 localhost
--user2 tata \
--password2 tatasecret \
+ --ssl1 \
+ --exitwhenover 2500000000 \
--useheader="X-Gmail-Received" \
- --useheader 'Message-Id'
+ --useheader "Message-Id" \
+ --skipcrossduplicates \
+ --folderfirst "Work" \
+ --folderfirst "Friends" \
+ --folderlast "CanWait" \
+ --folderlast "[Gmail]/All Mail"
+
+
+Explanations:
+
+--ssl1 is mandatory since Gmail only supports imap ssl connections.
+
+--exitwhenover 2500000000 option is here to avoid locking when
+transfers exceed maximum limit.
+See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
+--exitwhenover is not mandatory in the sense you may be able to
+use an upper value than 2.5 GB without disconnections; I don't
+know the hard value, it seems to vary, so just have some tries
+and report me what you discover in case you detect something.
+
+--useheader="X-Gmail-Received" --useheader "Message-Id" are not
+mandatory. I use them because I found (several years ago, it may
+have changed) that Gmail always adds a different header
+"X-Gmail-Received:" to all messages it gets. So the identification
+by imapsync can not fall using this header. "Message-Id" is there
+for safety about this Gmail rule.
+
If your destination imap server doesn't like "[Gmail]" name, just add
option:
@@ -1779,6 +1786,27 @@ unselect all "System labels".
exceed maximum limit.
See http://support.google.com/a/bin/answer.py?hl=en&answer=1071518
+--skipcrossduplicates is optional but it can save Gigabytes of hard
+disk memory. Within imap protocol, Gmail presents Gmail labels as
+folders so a message labeled "Work" "ProjectX" "Urgent" ends up
+in three different imap folders "Work" "ProjectX" and "Urgent"
+after an imap sync. --skipcrossduplicates prevent this behavior.
+
+An issue with --skipcrossduplicates is that the first label synced
+by imapsync goes to its corresponding folder and other labels are
+ignored. This way, at least you can choose what labels have the
+priority by using the --folderfirst option. For example
+--folderfirst "Work" will sync messages labeled "Work" before
+messages labeled "CanWait" or "Urgent". By default imapsync
+syncs folders (Gmail labels) using the classical alphanumeric order.
+
+--folderlast "CanWait" will sync only messages that have the
+label CanWait and only it.
+
+--folderlast "[Gmail]/All Mail", in conjonction with option
+--skipcrossduplicates, will only put in "[Gmail]/All Mail"
+the messages that are not labeled at all.
+
=======================================================================
Q. How to use XOAUTH to globally authenticate gmail users?
@@ -1826,6 +1854,43 @@ http://www.linux-france.org/prj/imapsync_list/msg00639.html
http://biasecurities.com/blog/2009/migrate-email-from-gmail-to-google-apps/
http://www.thamtech.com/blog/2008/03/29/gmail-to-google-apps-email-migration/
+=======================================================================
+Q. From Zimbra to XXX
+
+imapsync ... \
+ --exclude "Conversation Action Settings" \
+ --exclude "Quick Step Settings" \
+ --exclude "News Feed"
+
+=======================================================================
+Q. From or to HMailServer version 4.4.1.
+
+R. You have to add prefix and separator manually because 4.4.1 doesn't
+honor the NAMESPACE imap command.
+
+Example for host1:
+
+imapsync ... \
+ --prefix1 "" --sep1 .
+
+No specific option for HMailServer 5.3.3 since NAMESPACE is supported.
+
+Maybe --subscribe_all will help you to see all migrated folders.
+
+
+=======================================================================
+Q. Synchronizing from SmarterMail to XXX
+
+imapsync --host1 imap.d1.org --user1 joe --password1 secret1 --sep1 "/" \
+ --host2 imap.d2.org --user2 joe --password2 secret2 \
+ --prefix1 "" \
+ --regextrans2 "s#Sent Items$#Sent#" \
+ --dry --justfolders
+
+Maybe add other --regextrans2 to change folder names and see the result.
+When satisfied, run without --dry --justfolders
+
+
=======================================================================
Q. Synchronizing from Yahoo to XXX
diff --git a/Makefile b/Makefile
index 2740d1d..b9ce90e 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
-# $Id: Makefile,v 1.139 2013/12/25 11:36:53 gilles Exp gilles $
+# $Id: Makefile,v 1.141 2014/02/13 03:18:50 gilles Exp gilles $
.PHONY: help usage all
@@ -8,6 +8,10 @@ help: usage
usage:
@echo " imapsync $(VERSION), You can do :"
@echo "make install # as root"
+ @echo "make install_dependencies # it installs needed Perl modules from CPAN"
+ @echo ""
+ @echo "All other goals are for the upstream developper"
+
@echo "make testf # run tests"
@echo "make testv # run tests verbosely"
@echo "make test_quick # few tests verbosely"
@@ -92,6 +96,9 @@ install: testp imapsync.1
install imapsync.1 $(DESTDIR)$(PREFIX)/share/man/man1/imapsync.1
chmod 644 $(DESTDIR)$(PREFIX)/share/man/man1/imapsync.1
+install_dependencies:
+ sh examples/install_modules_linux.sh
+
.PHONY: cidone ci
ci: cidone
@@ -345,6 +352,7 @@ upload_lfo:
.valid.index.shtml: index.shtml
+ tidy -q index.shtml> /dev/null
validate --verbose index.shtml
touch .valid.index.shtml
diff --git a/README b/README
index 60ba875..f0b43c9 100644
--- a/README
+++ b/README
@@ -4,7 +4,7 @@ NAME
More than 52 different IMAP server softwares supported with success, few
failures.
- $Revision: 1.580 $
+ $Revision: 1.584 $
SYNOPSIS
To synchronize imap account "foo" on "imap.truc.org" to imap account
@@ -383,7 +383,8 @@ IMAP SERVERS
- Samsung Contact IMAP server 8.5.0
- Scalix v10.1, 10.0.1.3, 11.0.0.431, 11.4.6
- Sendmail Mail Store IMAP4rev1 (5.5.6/mstore-5-5-build-1874 [host1].
- - SmarterMail, Smarter Mail 5.0 Enterprise, Smarter Mail 5.5 [host1], SmarterMail Professional 10.2 [host1].
+ - SmarterMail, Smarter Mail 5.0 Enterprise, Smarter Mail 5.5 [host1],
+ SmarterMail Professional 10.2 [host1], Smarter Mail 11.7 [host1][host2].
- Softalk Workgroup Mail 7.6.4 [host1].
- SunONE Messaging server 5.2, 6.0 (SUN JES - Java Enterprise System)
- Sun Java(tm) System Messaging Server 6.2-2.05, 6.2-7.05, 6.3
@@ -471,5 +472,5 @@ SIMILAR SOFTWARES
Feedback (good or bad) will often be welcome.
- $Id: imapsync,v 1.580 2013/12/25 02:52:36 gilles Exp gilles $
+ $Id: imapsync,v 1.584 2014/02/05 00:40:59 gilles Exp gilles $
diff --git a/VERSION b/VERSION
index ef68d40..5136b76 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.580
+1.584
diff --git a/VERSION_EXE b/VERSION_EXE
index ef68d40..5136b76 100644
--- a/VERSION_EXE
+++ b/VERSION_EXE
@@ -1 +1 @@
-1.580
+1.584
diff --git a/W/.BUILD_EXE_TIME b/W/.BUILD_EXE_TIME
index ec754ed..58622a6 100644
--- a/W/.BUILD_EXE_TIME
+++ b/W/.BUILD_EXE_TIME
@@ -263,3 +263,9 @@
1387941690 BEGIN 1.580 : mercredi 25 décembre 2013, 04:21:30 (UTC+0100)
1387967067 BEGIN 1.580 : mercredi 25 décembre 2013, 11:24:28 (UTC+0100)
1387967901 END 1.580 : mercredi 25 décembre 2013, 11:38:21 (UTC+0100)
+1390615061 BEGIN 1.582 : samedi 25 janvier 2014, 02:57:41 (UTC+0100)
+1390685504 END 1.582 : samedi 25 janvier 2014, 22:31:44 (UTC+0100)
+1390874372 BEGIN 1.582 : mardi 28 janvier 2014, 02:59:33 (UTC+0100)
+1390875240 END 1.582 : mardi 28 janvier 2014, 03:14:00 (UTC+0100)
+1391561330 BEGIN 1.584 : mercredi 5 février 2014, 01:48:50 (UTC+0100)
+1391562789 END 1.584 : mercredi 5 février 2014, 02:13:09 (UTC+0100)
diff --git a/W/Mail-IMAPClient-3.35.tar.gz b/W/Mail-IMAPClient-3.35.tar.gz
deleted file mode 100644
index d38f41e..0000000
Binary files a/W/Mail-IMAPClient-3.35.tar.gz and /dev/null differ
diff --git a/W/learn/imap_tcpdump b/W/learn/imap_tcpdump
new file mode 100644
index 0000000..10200dc
--- /dev/null
+++ b/W/learn/imap_tcpdump
@@ -0,0 +1,3 @@
+
+tcpdump -s0 -A -i lo port imap
+
diff --git a/W/learn/longline b/W/learn/longline
new file mode 100755
index 0000000..e04abdb
--- /dev/null
+++ b/W/learn/longline
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+
+# Generate messages with line lenght of 10000 11000 ... up to 99000 characters
+for M in `count 10 99`; do
+ echo $M
+ { echo Hello Guys; echo ; perl -e "print 'L' x ${M}000" ; echo; echo END; } \
+ | mail.mailutils -s "line of ${M}000 char" tata@localhost.
+done
+
diff --git a/W/learn/longline_10000_11000 b/W/learn/longline_10000_11000
new file mode 100755
index 0000000..5eb5425
--- /dev/null
+++ b/W/learn/longline_10000_11000
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# $Id: longline_10000_11000,v 1.2 2014/01/15 02:21:38 gilles Exp gilles $
+
+# Test Exchange limit for maxlinelenght
+# Generate messages with line lenght of 10000 10100 ... up to 10990 characters
+for M in `count 10 99`; do
+ echo $M
+ { echo Hello Guys; echo ; perl -e "print 'L' x 10${M}0" ; echo; echo END; } \
+ | mail.mailutils -s "line of 10${M}0 characters" tata@localhost.
+done
+
diff --git a/W/paypal_reply/memo b/W/paypal_reply/memo
index f64a5d3..544bb81 100644
--- a/W/paypal_reply/memo
+++ b/W/paypal_reply/memo
@@ -28,7 +28,35 @@ Europe a un autre assujetti : Article 262 ter => Exoneration
EOF
}
-echo paypal_bilan_bncexport2
+
+echo paypal_bilan_tva_taux_20
+paypal_bilan_tva_taux_20() {
+# DID output diff between paypal_bilan_1.70 and 1.71
+(
+#set -x
+perl -c /g/public_html/imapsync/W/paypal_reply/paypal_bilan || return 1
+/g/public_html/imapsync/W/paypal_reply/paypal_bilan_1.70 --bnc --debug --details --debug_invoice --first_in 147 \
+ --avoid_numbers '292 293 643 644 731 732 1093
+1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298
+2625 2626 2970 2971 2972 3093' \
+ /g/paypal/paypal_201[01234]_??_complet.csv \
+ > /g/var/paypal_bilan/tests/paypal_invoice.out1 2>&1
+
+/g/public_html/imapsync/W/paypal_reply/paypal_bilan --bnc --debug --details --debug_invoice --first_in 147 \
+ --avoid_numbers '292 293 643 644 731 732 1093
+1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298
+2625 2626 2970 2971 2972 3093' \
+ /g/paypal/paypal_201[01234]_??_complet.csv \
+ > /g/var/paypal_bilan/tests/paypal_invoice.out2 2>&1
+
+echo diff /g/var/paypal_bilan/tests/paypal_invoice.out1 /g/var/paypal_bilan/tests/paypal_invoice.out2
+ diff /g/var/paypal_bilan/tests/paypal_invoice.out1 /g/var/paypal_bilan/tests/paypal_invoice.out2
+)
+}
+
+
+
+#echo paypal_bilan_bncexport2
paypal_bilan_bncexport2() {
# DID output diff between paypal_bilan_1.66 and 1.67
(
@@ -54,7 +82,7 @@ echo diff /g/var/paypal_bilan/tests/paypal_invoice.out1 /g/var/paypal_bilan/test
}
-echo paypal_bilan_bncexport
+#echo paypal_bilan_bncexport
paypal_bilan_bncexport() {
# DID output diff between paypal_bilan_1.66 and 1.67
(
diff --git a/W/paypal_reply/paypal_bilan b/W/paypal_reply/paypal_bilan
index 1187e88..be96933 100755
--- a/W/paypal_reply/paypal_bilan
+++ b/W/paypal_reply/paypal_bilan
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: paypal_bilan,v 1.68 2013/06/07 06:59:41 gilles Exp gilles $
+# $Id: paypal_bilan,v 1.72 2014/01/18 01:38:35 gilles Exp gilles $
use strict;
use warnings;
@@ -13,7 +13,7 @@ use Test::More 'no_plan' ;
die unless (utf8_supported_charset('ISO-8859-1'));
-my $rcs = '$Id: paypal_bilan,v 1.68 2013/06/07 06:59:41 gilles Exp gilles $ ' ;
+my $rcs = '$Id: paypal_bilan,v 1.72 2014/01/18 01:38:35 gilles Exp gilles $ ' ;
$rcs =~ m/,v (\d+\.\d+)/ ;
my $VERSION = ($1) ? $1: "UNKNOWN" ;
@@ -140,7 +140,7 @@ foreach my $invoice ( @invoices_wanted ) {
if ( $invoice_sent ) {
$invoice_sent{ $invoice }++ ;
- #build_invoice( $invoice ) ;
+ build_invoice( $invoice ) if ( $debug_invoice or $debug_invoice_utf8 ) ;
}elsif( not ( $invoice_canceled{ $invoice } or $invoice_refund{ $invoice } ) ) {
$invoice_not_sent{ $invoice }++ ;
build_invoice( $invoice ) ;
@@ -371,10 +371,11 @@ sub tests_exportbnc {
sub tests {
tests_next_invoice( ) ;
- #tests_half( ) ;
tests_cut( ) ;
tests_invoice_00000( ) ;
- tests_exportbnc( ) ;
+ #tests_exportbnc( ) ;
+ tests_tva_rate( ) ;
+ tests_tva_rate_str( ) ;
}
sub compute_line {
@@ -677,7 +678,7 @@ sub build_invoice {
$priceTTCusd,
$HTorTTC
)
- = tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet ) ;
+ = tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet, $Date ) ;
my $object_type = object_type( $Titre_de_l_objet ) ;
@@ -1058,6 +1059,62 @@ sub date_aaaa_mm_jj {
}
+sub tva_rate {
+ my $date_aaaa_mm_jj = shift ;
+
+ if ( '2014_01_01' gt $date_aaaa_mm_jj ) {
+ #print "tva_rate 0.196\n" ;
+ #return( 0 ) ;
+ return( 0.196 ) ;
+ }
+
+ if ( '2014_01_01' le $date_aaaa_mm_jj ) {
+ #print "tva_rate 0.2\n" ;
+ return( 0.2 ) ;
+ }
+ #print "tva_rate 0\n" ;
+ return( 0 ) ;
+}
+
+sub tests_tva_rate {
+ ok( 0.196 == tva_rate( '2013_01_01' ), 'tva_rate: old 0.196' ) ;
+ ok( 0.196 == tva_rate( '2013_12_31' ), 'tva_rate: old 0.196' ) ;
+ ok( 0.2 == tva_rate( '2014_01_01' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2014_12_31' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2050_01_01' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2050_12_31' ), 'tva_rate: new 0.2' ) ;
+ return( 0 ) ;
+}
+
+
+sub tva_rate_str {
+ my $date_aaaa_mm_jj = shift ;
+
+ if ( '2014_01_01' gt $date_aaaa_mm_jj ) {
+ #print "tva_rate 0.196\n" ;
+ return( '19,60\%' ) ;
+ }
+
+ if ( '2014_01_01' le $date_aaaa_mm_jj ) {
+ return( '20\%' ) ;
+ }
+ #print "tva_rate 0\n" ;
+ return( '' ) ;
+}
+
+sub tests_tva_rate_str {
+ ok( '19,60\%' eq tva_rate_str( '2013_01_01' ), 'tva_rate_str: old 0.196' ) ;
+ ok( '19,60\%' eq tva_rate_str( '2013_12_31' ), 'tva_rate_str: old 0.196' ) ;
+ ok( '20,00\%' eq tva_rate_str( '2014_01_01' ), 'tva_rate_str: new 0.2' ) ;
+ ok( '20,00\%' eq tva_rate_str( '2014_12_31' ), 'tva_rate_str: new 0.2' ) ;
+ ok( '20,00\%' eq tva_rate_str( '2050_01_01' ), 'tva_rate_str: new 0.2' ) ;
+ ok( '20,00\%' eq tva_rate_str( '2050_12_31' ), 'tva_rate_str: new 0.2' ) ;
+ return( 0 ) ;
+}
+
+
+
+
sub tva_line {
my( $Devise, $Montant2, $Pays, $Nom_Option_1, $Valeur_Option_1, $Titre_de_l_objet, $Date ) = @_ ;
my( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) = ( 0, 0, 0 ) ;
@@ -1080,8 +1137,8 @@ sub tva_line {
or
( 'France' eq $Pays )
) {
- $montant_HT_EUR_ass = $Montant2 / 1.196 ;
- $montant_TVA_EUR = $Montant2 / 1.196 * 0.196 ;
+ $montant_HT_EUR_ass = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ;
+ $montant_TVA_EUR = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ;
$debug_dev and print "$Montant2 $Pays $Valeur_Option_1\n" ;
}else{
$montant_HT_EUR_exo = $Montant2 ;
@@ -1096,8 +1153,8 @@ sub tva_line {
or
( '2013_02_19' gt $date_aaaa_mm_jj )
) {
- $montant_HT_EUR_sup = $Montant2 / 1.196 ;
- $montant_TVA_EUR_sup = $Montant2 / 1.196 * 0.196 ;
+ $montant_HT_EUR_sup = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ;
+ $montant_TVA_EUR_sup = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ;
}else{
$montant_HT_EUR_sup_exo = $Montant2 ;
}
@@ -1109,10 +1166,12 @@ sub tva_line {
sub tva_stuff {
- my( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet ) = @_ ;
+ my( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet, $Date ) = @_ ;
my $priceTTCusd = '' ;
$Hors_taxe =~ s{,}{.} ;
+
+ my $date_aaaa_mm_jj = date_aaaa_mm_jj( $Date ) ;
if ( $Devise eq 'USD' ) {
$priceTTCusd = "(usd $Hors_taxe)" ;
@@ -1134,10 +1193,10 @@ sub tva_stuff {
or
( 'France' eq $Pays )
) {
- $priceHT = sprintf('%2.2f', $Hors_taxe/1.196) ;
- $tvaFR = '19,60\%';
- $tvaEN = '';
- $priceTVA = sprintf('%2.2f', $Hors_taxe/1.196*0.196) ;
+ $priceHT = sprintf('%2.2f', $Hors_taxe / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ) ;
+ $tvaFR = tva_rate_str( $date_aaaa_mm_jj ) ;
+ $tvaEN = '' ;
+ $priceTVA = sprintf('%2.2f', $Hors_taxe / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ) ;
$priceTTC = sprintf('%2.2f', $Hors_taxe) ;
$HTorTTC = 'TTC' ;
$messageTVAFR = '' ;
@@ -1246,19 +1305,6 @@ $addr = "
}
-sub half {
- my $string = shift ;
- my $half = int( lenght( $string ) / 2 ) ;
- # TO BE DONE
-
-}
-
-sub tests_half {
- my( $aa, $bb ) = half( 'aa bb' ) ;
- ok( 'aa' eq $aa, 'half: aa' ) ;
- ok( 'bb' eq $bb, 'half: bb' ) ;
-}
-
sub cut {
my $string = shift ;
my $offset = shift ;
diff --git a/W/paypal_reply/paypal_bilan_1.66 b/W/paypal_reply/paypal_bilan_1.70
similarity index 91%
rename from W/paypal_reply/paypal_bilan_1.66
rename to W/paypal_reply/paypal_bilan_1.70
index c9c3d7a..762bb29 100755
--- a/W/paypal_reply/paypal_bilan_1.66
+++ b/W/paypal_reply/paypal_bilan_1.70
@@ -1,6 +1,6 @@
#!/usr/bin/perl
-# $Id: paypal_bilan,v 1.66 2013/03/26 19:50:20 gilles Exp gilles $
+# $Id: paypal_bilan,v 1.70 2014/01/17 15:27:11 gilles Exp gilles $
use strict;
use warnings;
@@ -13,7 +13,7 @@ use Test::More 'no_plan' ;
die unless (utf8_supported_charset('ISO-8859-1'));
-my $rcs = '$Id: paypal_bilan,v 1.66 2013/03/26 19:50:20 gilles Exp gilles $ ' ;
+my $rcs = '$Id: paypal_bilan,v 1.70 2014/01/17 15:27:11 gilles Exp gilles $ ' ;
$rcs =~ m/,v (\d+\.\d+)/ ;
my $VERSION = ($1) ? $1: "UNKNOWN" ;
@@ -87,10 +87,9 @@ if ( $tests ) {
my @files = @ARGV ;
-my %action_of_invoice ;
+my %action_invoice ;
my %invoice_paypal ;
-#$invoice_paypal{ $first_invoice } = 1 ;
my @invoices_wanted = split( /\s+/, $invoices ) if $invoices ;
@@ -100,41 +99,24 @@ my %avoid_numbers ;
#print "@invoices\n" ;
+my @actions ;
+
foreach my $file ( @files ) {
- my @actions = parse_file( $file ) ;
-
- foreach my $action (@actions) {
- my %action = %$action ;
- #print $action->{ Nom }, "\n" ;
- my( $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
- $Devise, $Montant, $Numero_davis_de_reception, $Solde,
- $Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe, $Titre_de_l_objet, $Nom_Option_2, $Option_2_Valeur,
- $Impact_sur_le_solde )
- = @action{ ( 'Date', 'Heure', 'Fuseau horaire', 'Nom', 'Type', 'Etat',
- 'Devise', 'Montant', "Numéro d'avis de réception", 'Solde',
- 'Pays', 'Nom Option 1', 'Valeur Option 1', 'Hors taxe', "Titre de l'objet", 'Nom Option 2', 'Option 2 Valeur',
- 'Impact sur le solde') } ;
- #print "[$Option_2_Valeur] [$Impact_sur_le_solde]\n" ;
- #next;
- ( $Etat ) = @action{ ( 'Etat' ) } || @action{ ( 'État' ) } ;
- ( $Hors_taxe ) = @action{ ( 'Hors taxe' ) } || @action{ ( 'Avant commission' ) } ;
- $Impact_sur_le_solde ||= '' ;
-
- my $invoice = 'NONE' ;
- $Montant = $action->{ 'Net' } if not defined $Montant;
- # compute_line() adds $action->{ 'invoice' } if needed
- compute_line( $action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
- $Devise, $Montant, $Numero_davis_de_reception, $Solde,
- $Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe, $Titre_de_l_objet,
- $Impact_sur_le_solde ) ;
-
- # index by invoice number
- $action_of_invoice{ $action->{ 'invoice' } } = $action ;
- }
- delete $action_of_invoice{ 'NONE' } ;
+ my @actions_file = parse_file( $file ) ;
+ push( @actions, @actions_file ) ;
}
+foreach my $action (@actions) {
+ # compute_line() adds $action->{ 'invoice' } if needed
+ compute_line( $action ) ;
+
+ # index by invoice number
+ $action_invoice{ $action->{ 'invoice' } } = $action ;
+}
+delete $action_invoice{ 'NONE' } ;
+
+
my $last_invoice ;
my @invoice_paypal = sort { $a <=> $b } keys %invoice_paypal ;
$last_invoice = $invoice_paypal[-1] || 0 ;
@@ -149,7 +131,7 @@ my %invoice_not_sent ;
foreach my $invoice ( @invoices_wanted ) {
- my $action = $action_of_invoice{ $invoice } ;
+ my $action = $action_invoice{ $invoice } ;
next if ! $action ;
my $email_address = $action->{ "De l'adresse email" } ;
@@ -158,7 +140,7 @@ foreach my $invoice ( @invoices_wanted ) {
if ( $invoice_sent ) {
$invoice_sent{ $invoice }++ ;
- #build_invoice( $invoice ) ;
+ build_invoice( $invoice ) if ( $debug_invoice or $debug_invoice_utf8 ) ;
}elsif( not ( $invoice_canceled{ $invoice } or $invoice_refund{ $invoice } ) ) {
$invoice_not_sent{ $invoice }++ ;
build_invoice( $invoice ) ;
@@ -385,18 +367,38 @@ sub tests_exportbnc {
}
+
+
sub tests {
tests_next_invoice( ) ;
- #tests_half( ) ;
tests_cut( ) ;
tests_invoice_00000( ) ;
- tests_exportbnc( ) ;
+ #tests_exportbnc( ) ;
+ tests_tva_rate( ) ;
}
sub compute_line {
- my( $action, $invoice, $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
- $Devise, $Montant, $Numero_davis_de_reception, $Solde,
- $Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe_paypal, $Titre_de_l_objet, $Impact_sur_le_solde ) = @_ ;
+
+ my $action = shift ;
+ my %action = %$action ;
+
+ my( $Date, $Heure, $Fuseau_horaire, $Nom, $Type, $Etat,
+ $Devise, $Montant, $Numero_davis_de_reception, $Solde,
+ $Pays, $Nom_Option_1, $Valeur_Option_1, $Hors_taxe_paypal, $Titre_de_l_objet, $Nom_Option_2, $Option_2_Valeur,
+ $Impact_sur_le_solde )
+ = @action{ ( 'Date', 'Heure', 'Fuseau horaire', 'Nom', 'Type', 'Etat',
+ 'Devise', 'Montant', "Numéro d'avis de réception", 'Solde',
+ 'Pays', 'Nom Option 1', 'Valeur Option 1', 'Hors taxe', "Titre de l'objet", 'Nom Option 2', 'Option 2 Valeur',
+ 'Impact sur le solde') } ;
+ #print "[$Option_2_Valeur] [$Impact_sur_le_solde]\n" ;
+ #next;
+ ( $Etat ) = @action{ ( 'Etat' ) } || @action{ ( 'État' ) } ;
+ ( $Hors_taxe_paypal ) = @action{ ( 'Hors taxe' ) } || @action{ ( 'Avant commission' ) } ;
+ $Impact_sur_le_solde ||= '' ;
+
+ my $invoice = 'NONE' ;
+ $Montant = $action->{ 'Net' } if not defined $Montant;
+
$debug and print( "#" x 78, "\n",
"[$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] ",
@@ -437,7 +439,7 @@ sub compute_line {
$total_HT_EUR_exo += $montant_HT_EUR_exo ;
$total_HT_EUR_ass += $montant_HT_EUR_ass ;
$total_TVA_EUR += $montant_TVA_EUR ;
- #$invoice = $first_invoice + $nb_invoice ;
+
$invoice = next_invoice( ) ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde] [$Impact_sur_le_solde]\n" ) ;
@@ -465,8 +467,6 @@ sub compute_line {
$total_TVA_EUR_sup += $montant_TVA_EUR_sup ;
$total_HT_EUR_sup_exo += $montant_HT_EUR_sup_exo ;
-
- #$invoice = $first_invoice + $nb_invoice ;
$invoice = next_invoice( ) ;
$nb_invoice++ ;
$print_details and print ( "[$invoice] [$Date] [$Heure] [$Fuseau_horaire] [$Nom] [$Type] [$Etat] [$Devise] [$Montant] [$Numero_davis_de_reception] [$Solde] [$Impact_sur_le_solde]\n" ) ;
@@ -576,7 +576,7 @@ sub build_invoice {
return if ! $invoice ;
- my $action = $action_of_invoice{ $invoice } ;
+ my $action = $action_invoice{ $invoice } ;
my $refund = '' ;
$refund = 'REFUND ' if $invoice_refund{ $invoice } ;
my %action = %$action if $action ;
@@ -677,7 +677,7 @@ sub build_invoice {
$priceTTCusd,
$HTorTTC
)
- = tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet ) ;
+ = tva_stuff( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet, $Date ) ;
my $object_type = object_type( $Titre_de_l_objet ) ;
@@ -813,6 +813,9 @@ Hello $name,
First of all, I'm sorry for the delay in getting back to you.
+Last imapsync release is available from the page
+http://imapsync.lamiral.info/paypal_return.shtml
+
You'll find in the attachment the invoice of imapsync
software you bought and paid (dd/mm/yyyy $date).
The invoice file is named facture_imapsync-${invoice}.pdf
@@ -851,6 +854,9 @@ Hello $name,
First of all, I'm sorry for the delay in getting back to you.
+Last imapsync release is available from the page
+http://imapsync.lamiral.info/paypal_return.shtml
+
You'll find in the attachment the invoice of imapsync
support you bought and paid (dd/mm/yyyy $date).
The invoice file is named facture_imapsync-${invoice}.pdf
@@ -1052,6 +1058,34 @@ sub date_aaaa_mm_jj {
}
+sub tva_rate {
+ my $date_aaaa_mm_jj = shift ;
+
+ if ( '2014_01_01' gt $date_aaaa_mm_jj ) {
+ #print "tva_rate 0.196\n" ;
+ #return( 0 ) ;
+ return( 0.196 ) ;
+ }
+
+ if ( '2014_01_01' le $date_aaaa_mm_jj ) {
+ #print "tva_rate 0.2\n" ;
+ return( 0.2 ) ;
+ }
+ #print "tva_rate 0\n" ;
+ return( 0 ) ;
+}
+
+sub tests_tva_rate {
+ ok( 0.196 == tva_rate( '2013_01_01' ), 'tva_rate: old 0.196' ) ;
+ ok( 0.196 == tva_rate( '2013_12_31' ), 'tva_rate: old 0.196' ) ;
+ ok( 0.2 == tva_rate( '2014_01_01' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2014_12_31' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2050_01_01' ), 'tva_rate: new 0.2' ) ;
+ ok( 0.2 == tva_rate( '2050_12_31' ), 'tva_rate: new 0.2' ) ;
+ return( 0 ) ;
+}
+
+
sub tva_line {
my( $Devise, $Montant2, $Pays, $Nom_Option_1, $Valeur_Option_1, $Titre_de_l_objet, $Date ) = @_ ;
my( $montant_HT_EUR_exo, $montant_HT_EUR_ass, $montant_TVA_EUR ) = ( 0, 0, 0 ) ;
@@ -1074,8 +1108,8 @@ sub tva_line {
or
( 'France' eq $Pays )
) {
- $montant_HT_EUR_ass = $Montant2 / 1.196 ;
- $montant_TVA_EUR = $Montant2 / 1.196 * 0.196 ;
+ $montant_HT_EUR_ass = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ;
+ $montant_TVA_EUR = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ;
$debug_dev and print "$Montant2 $Pays $Valeur_Option_1\n" ;
}else{
$montant_HT_EUR_exo = $Montant2 ;
@@ -1090,8 +1124,8 @@ sub tva_line {
or
( '2013_02_19' gt $date_aaaa_mm_jj )
) {
- $montant_HT_EUR_sup = $Montant2 / 1.196 ;
- $montant_TVA_EUR_sup = $Montant2 / 1.196 * 0.196 ;
+ $montant_HT_EUR_sup = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ;
+ $montant_TVA_EUR_sup = $Montant2 / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ;
}else{
$montant_HT_EUR_sup_exo = $Montant2 ;
}
@@ -1103,10 +1137,12 @@ sub tva_line {
sub tva_stuff {
- my( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet ) = @_ ;
+ my( $clientTypeEN, $Pays, $Hors_taxe, $Devise, $Titre_de_l_objet, $Date ) = @_ ;
my $priceTTCusd = '' ;
$Hors_taxe =~ s{,}{.} ;
+
+ my $date_aaaa_mm_jj = date_aaaa_mm_jj( $Date ) ;
if ( $Devise eq 'USD' ) {
$priceTTCusd = "(usd $Hors_taxe)" ;
@@ -1128,10 +1164,10 @@ sub tva_stuff {
or
( 'France' eq $Pays )
) {
- $priceHT = sprintf('%2.2f', $Hors_taxe/1.196) ;
+ $priceHT = sprintf('%2.2f', $Hors_taxe / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) ) ;
$tvaFR = '19,60\%';
$tvaEN = '';
- $priceTVA = sprintf('%2.2f', $Hors_taxe/1.196*0.196) ;
+ $priceTVA = sprintf('%2.2f', $Hors_taxe / ( 1 + tva_rate( $date_aaaa_mm_jj ) ) * tva_rate( $date_aaaa_mm_jj ) ) ;
$priceTTC = sprintf('%2.2f', $Hors_taxe) ;
$HTorTTC = 'TTC' ;
$messageTVAFR = '' ;
@@ -1240,19 +1276,6 @@ $addr = "
}
-sub half {
- my $string = shift ;
- my $half = int( lenght( $string ) / 2 ) ;
- # TO BE DONE
-
-}
-
-sub tests_half {
- my( $aa, $bb ) = half( 'aa bb' ) ;
- ok( 'aa' eq $aa, 'half: aa' ) ;
- ok( 'bb' eq $bb, 'half: bb' ) ;
-}
-
sub cut {
my $string = shift ;
my $offset = shift ;
diff --git a/W/paypal_reply/paypal_build_invoices b/W/paypal_reply/paypal_build_invoices
index 09a4a8e..2815765 100755
--- a/W/paypal_reply/paypal_build_invoices
+++ b/W/paypal_reply/paypal_build_invoices
@@ -1,6 +1,6 @@
#!/bin/sh
-# $Id: paypal_build_invoices,v 1.60 2013/12/14 17:30:04 gilles Exp gilles $
+# $Id: paypal_build_invoices,v 1.63 2014/01/18 01:26:53 gilles Exp gilles $
# usage: sh paypal_build_invoices /g/var/paypal_invoices/????
@@ -44,7 +44,9 @@ cp /home/gilles/public_html/AGIL/factures/000/facture_imapsync-000.tex /g/var/pa
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 2820 /g/paypal/paypal_2013_09_complet.csv
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 2891 /g/paypal/paypal_2013_10_complet.csv
#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 2973 /g/paypal/paypal_2013_11_complet.csv
-/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 3040 /g/paypal/paypal_2013_12_complet.csv
+#/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 3040 /g/paypal/paypal_2013_12_complet.csv
+
+/g/public_html/imapsync/W/paypal_reply/paypal_bilan --write_invoices --first_in 3094 /g/paypal/paypal_2014_01_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 147 /g/paypal/paypal_2010_11_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 214 /g/paypal/paypal_2010_12_complet.csv
@@ -82,22 +84,26 @@ cp /home/gilles/public_html/AGIL/factures/000/facture_imapsync-000.tex /g/var/pa
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 2741 /g/paypal/paypal_2013_08_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 2820 /g/paypal/paypal_2013_09_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 2891 /g/paypal/paypal_2013_10_complet.csv
-
-set -x
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 2973 /g/paypal/paypal_2013_11_complet.csv
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 3040 /g/paypal/paypal_2013_12_complet.csv
+set -x
+: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --first_in 3094 /g/paypal/paypal_2014_01_complet.csv
set +x
# La totale
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan --bnc --debug \
- --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298 2625 2626 2970 2971 2972' \
+ --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093
+1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298
+2625 2626 2970 2971 2972 3093' \
/g/paypal/paypal_201?_??_complet.csv
set -v
: /g/public_html/imapsync/W/paypal_reply/paypal_bilan \
- --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093 1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298 2625 2626 2970 2971 2972' \
+ --first_in 147 --avoid_numbers '292 293 643 644 731 732 1093
+1330 1331 1332 1333 1334 1652 1653 2131 2132 2295 2296 2297 2298
+2625 2626 2970 2971 2972 3093' \
/g/paypal/paypal_201?_??_complet.csv
set +v
diff --git a/examples/imapsync_example.sh b/examples/imapsync_example.sh
new file mode 100644
index 0000000..ada9cc3
--- /dev/null
+++ b/examples/imapsync_example.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+# imapsync example shell for Unix users
+# lines beginning with # are just comments
+
+# Replace imap.foo.org toto secretoto 192.168.42.4 titi secretiti with your own values
+
+./imapsync --host1 imap.foo.org --user1 toto --password1 "secretoto" \
+ --host2 192.168.42.4 --user2 titi --password2 "secretiti"
+
diff --git a/imapsync b/imapsync
index 23e17ac..e4eb922 100755
--- a/imapsync
+++ b/imapsync
@@ -22,7 +22,7 @@ Synchronises mailboxes between two imap servers.
Good at IMAP migration. More than 52 different IMAP server softwares
supported with success, few failures.
-$Revision: 1.580 $
+$Revision: 1.584 $
=head1 SYNOPSIS
@@ -433,7 +433,8 @@ Success stories reported with the following 57 imap servers
- Samsung Contact IMAP server 8.5.0
- Scalix v10.1, 10.0.1.3, 11.0.0.431, 11.4.6
- Sendmail Mail Store IMAP4rev1 (5.5.6/mstore-5-5-build-1874 [host1].
- - SmarterMail, Smarter Mail 5.0 Enterprise, Smarter Mail 5.5 [host1], SmarterMail Professional 10.2 [host1].
+ - SmarterMail, Smarter Mail 5.0 Enterprise, Smarter Mail 5.5 [host1],
+ SmarterMail Professional 10.2 [host1], Smarter Mail 11.7 [host1][host2].
- Softalk Workgroup Mail 7.6.4 [host1].
- SunONE Messaging server 5.2, 6.0 (SUN JES - Java Enterprise System)
- Sun Java(tm) System Messaging Server 6.2-2.05, 6.2-7.05, 6.3
@@ -541,7 +542,7 @@ Entries for imapsync:
Feedback (good or bad) will often be welcome.
-$Id: imapsync,v 1.580 2013/12/25 02:52:36 gilles Exp gilles $
+$Id: imapsync,v 1.584 2014/02/05 00:40:59 gilles Exp gilles $
=cut
@@ -581,7 +582,7 @@ use IPC::Open3 'open3' ;
my(
$rcs, $pidfile, $pidfilelocking,
$debug, $debugimap, $debugimap1, $debugimap2, $debugcontent, $debugflags,
- $debugLIST, $debugsleep, $debugdev, $debugmemory,
+ $debugLIST, $debugsleep, $debugdev, $debugmemory, $debugmaxlinelength,
$nb_errors,
$host1, $host2, $port1, $port2,
$user1, $user2, $domain1, $domain2,
@@ -664,6 +665,7 @@ my(
$messageidnodomain,
$fixInboxINBOX,
$maxlinelength,
+ $minmaxlinelength,
$uidnext_default,
$fixcolonbug,
$create_folder_old,
@@ -676,7 +678,7 @@ my(
# global variables initialisation
-$rcs = '$Id: imapsync,v 1.580 2013/12/25 02:52:36 gilles Exp gilles $ ';
+$rcs = '$Id: imapsync,v 1.584 2014/02/05 00:40:59 gilles Exp gilles $ ';
$total_bytes_transferred = 0;
$total_bytes_skipped = 0;
@@ -1029,8 +1031,11 @@ print "Host1 capability: ", join(" ", @{ $imap1->capability_update() || [] }), "
print "Host2 capability: ", join(" ", @{ $imap2->capability_update() || [] }), "\n";
-exit_clean(0) if ($justlogin);
-
+if ( $justlogin ) {
+ $imap1->logout( ) ;
+ $imap2->logout( ) ;
+ exit_clean( 0 ) ;
+}
#
# Folder stuff
#
@@ -1130,17 +1135,17 @@ $checkselectable and do {
my($h1_sep,$h2_sep);
# what are the private folders separators for each server ?
-$debug and print "Getting separators\n";
-$h1_sep = get_separator($imap1, $sep1, "--sep1");
-$h2_sep = get_separator($imap2, $sep2, "--sep2");
+$debug and print "Getting separators\n" ;
+$h1_sep = get_separator( $imap1, $sep1, "--sep1", "Host1" ) ;
+$h2_sep = get_separator( $imap2, $sep2, "--sep2", "Host2" ) ;
-my($h1_prefix,$h2_prefix);
-$h1_prefix = get_prefix($imap1, $prefix1, "--prefix1");
-$h2_prefix = get_prefix($imap2, $prefix2, "--prefix2");
+my( $h1_prefix, $h2_prefix ) ;
+$h1_prefix = get_prefix( $imap1, $prefix1, "--prefix1", "Host1" ) ;
+$h2_prefix = get_prefix( $imap2, $prefix2, "--prefix2", "Host2" ) ;
-print "Host1 separator and prefix: [$h1_sep][$h1_prefix]\n";
-print "Host2 separator and prefix: [$h2_sep][$h2_prefix]\n";
+print "Host1 separator and prefix: [$h1_sep][$h1_prefix]\n" ;
+print "Host2 separator and prefix: [$h2_sep][$h2_prefix]\n" ;
#my $h1_xlist_folders = $imap1->xlist_folders( ) ;
#my $h2_xlist_folders = $imap2->xlist_folders( ) ;
@@ -1991,11 +1996,14 @@ sub connect_imap {
$imap->Debug($mydebugimap);
$imap->connect()
or die_clean("Can not open imap connection on [$host]: $@\n");
- #myconnect($imap)
- # or die_clean("Can not open imap connection on [$host]: $@\n");
+
my $banner = $imap->Results()->[0] ;
$imap->Banner( $banner ) ;
- $imap->starttls( ) if ( $imap->Tls( ) ) ;
+
+ if ( $imap->Tls( ) ) {
+ $imap->starttls( )
+ or die_clean("Can not go to tls encryption on [$host]:", $imap->LastError, "\n" ) ;
+ }
return( $imap ) ;
}
@@ -2083,7 +2091,10 @@ sub login_imap {
}
}
- $imap->starttls( ) if ( $imap->Tls( ) ) ;
+ if ( $imap->Tls( ) ) {
+ $imap->starttls( )
+ or die_clean("Can not go to tls encryption on [$host]:", $imap->LastError, "\n" ) ;
+ }
authenticate_imap( $imap, @allargs ) ;
@@ -2173,12 +2184,13 @@ sub set_ssl {
#
$SSL_version = $SSL_version || '' ;
#print "[$SSL_version]\n" ;
- IO::Socket::SSL::set_ctx_defaults(
+
+ my $sslargs = [
SSL_verify_mode => 'SSL_VERIFY_PEER',
SSL_verifycn_scheme => 'imap',
SSL_version => $SSL_version,
- ) ;
- $imap->Ssl( $ssl ) ;
+ ] ;
+ $imap->Ssl( $sslargs ) ;
return( ) ;
}
@@ -2307,8 +2319,8 @@ sub banner_imapsync {
my @argv = @_ ;
my $banner_imapsync = join("",
'$RCSfile: imapsync,v $ ',
- '$Revision: 1.580 $ ',
- '$Date: 2013/12/25 02:52:36 $ ',
+ '$Revision: 1.584 $ ',
+ '$Date: 2014/02/05 00:40:59 $ ',
"\n",localhost_info(), "\n",
"Command line used:\n",
"$0 ", command_line_nopassword( @argv ), "\n",
@@ -2680,59 +2692,86 @@ sub tests_compare_lists {
-sub get_prefix {
- my( $imap, $prefix_in, $prefix_opt ) = @_ ;
+sub get_prefix {
+ my( $imap, $prefix_in, $prefix_opt, $Side ) = @_ ;
my( $prefix_out ) ;
- $debug and print "Getting prefix namespace\n" ;
- if ( defined( $prefix_in ) ) {
- print "Using [$prefix_in] given by $prefix_opt\n" ;
- $prefix_out = $prefix_in ;
- return( $prefix_out ) ;
- }
- $debug and print "Calling namespace capability\n" ;
+ $debug and print "$Side: Getting prefix\n" ;
+
+ $debug and print "$Side: Calling namespace capability\n" ;
if ( $imap->has_capability( "namespace" ) ) {
my $r_namespace = $imap->namespace( ) ;
$prefix_out = $r_namespace->[0][0][0] ;
- return($prefix_out) ;
+ print "$Side: prefix given by NAMESPACE: [$prefix_out]\n" ;
+ if ( defined( $prefix_in ) ) {
+ print "$Side: but using [$prefix_in] given by $prefix_opt\n" ;
+ $prefix_out = $prefix_in ;
+ return( $prefix_out ) ;
+ }else{
+ # all good
+ return( $prefix_out ) ;
+ }
}
else{
- print
- "No NAMESPACE capability in imap server ",
- $imap->Server( ),"\n",
- help_to_guess_prefix( $imap, $prefix_opt ) ;
- exit_clean( 1 ) ;
+ if ( defined( $prefix_in ) ) {
+ print "$Side: using [$prefix_in] given by $prefix_opt\n" ;
+ $prefix_out = $prefix_in ;
+ return( $prefix_out ) ;
+ }else{
+ print
+ "$Side: No NAMESPACE capability in imap server ",
+ $imap->Server( ),"\n",
+ help_to_guess_prefix( $imap, $prefix_opt ) ;
+ exit_clean( 1 ) ;
+ }
}
return( ) ;
}
-sub get_separator {
- my($imap, $sep_in, $sep_opt) = @_;
- my($sep_out);
+sub get_separator {
+ my( $imap, $sep_in, $sep_opt, $Side ) = @_ ;
+ my( $sep_out ) ;
- if ( defined( $sep_in ) ) {
- print "Using [$sep_in] given by $sep_opt\n" ;
- $sep_out = $sep_in ;
- return( $sep_out ) ;
- }
- $debug and print "Calling namespace capability\n" ;
- if ($imap->has_capability( "namespace" ) ) {
+ $debug and print "$Side: calling namespace capability\n" ;
+ if ( $imap->has_capability( "namespace" ) ) {
$sep_out = $imap->separator( ) ;
- return($sep_out) if defined $sep_out ;
- print
- "NAMESPACE request failed for ",
- $imap->Server(), ": ", $imap->LastError, "\n",
- help_to_guess_sep( $imap, $sep_opt ) ;
- exit_clean( 1 ) ;
+ if ( defined( $sep_out ) ) {
+ print "$Side: separator given by NAMESPACE: [$sep_out]\n" ;
+ if ( defined( $sep_in ) ) {
+ print "$Side: but using [$sep_in] given by $sep_opt\n" ;
+ $sep_out = $sep_in ;
+ return( $sep_out ) ;
+ }else{
+ return( $sep_out ) ;
+ }
+ }else{
+ if ( defined( $sep_in ) ) {
+ print "$Side: NAMESPACE request failed but using [$sep_in] given by $sep_opt\n" ;
+ $sep_out = $sep_in ;
+ return( $sep_out ) ;
+ }else{
+ print
+ "$Side: NAMESPACE request failed for ",
+ $imap->Server(), ": ", $imap->LastError, "\n",
+ help_to_guess_sep( $imap, $sep_opt ) ;
+ exit_clean( 1 ) ;
+ }
+ }
}
else{
- print
- "No NAMESPACE capability in imap server ",
- $imap->Server(),"\n",
- help_to_guess_sep( $imap, $sep_opt ) ;
- exit_clean( 1 ) ;
+ if ( defined( $sep_in ) ) {
+ print "$Side: No NAMESPACE capability but using [$sep_in] given by $sep_opt\n" ;
+ $sep_out = $sep_in ;
+ return( $sep_out ) ;
+ }else{
+ print
+ "$Side: No NAMESPACE capability in imap server ",
+ $imap->Server(),"\n",
+ help_to_guess_sep( $imap, $sep_opt ) ;
+ exit_clean( 1 ) ;
+ }
}
return( ) ;
}
@@ -2941,7 +2980,8 @@ sub foldersizes {
$nb_errors++ ;
next ;
}
-
+ last if $imap->IsUnconnected() ;
+
my $hash_ref = { } ;
my @msgs = select_msgs( $imap, undef, $search_cmd, $folder ) ;
$nb_msgs = scalar( @msgs ) ;
@@ -3474,6 +3514,8 @@ sub copy_message {
if ( size_filtered( $h1_size, $h1_msg, $h1_fold, $h2_fold ) ) {
+ $total_bytes_skipped += $h1_size;
+ $nb_msg_skipped += 1;
$h1_nb_msg_processed +=1 ;
return( ) ;
}
@@ -3483,6 +3525,8 @@ sub copy_message {
if ( $checkmessageexists and not message_exists( $imap1, $h1_msg ) ) {
+ $total_bytes_skipped += $h1_size;
+ $nb_msg_skipped += 1;
$h1_nb_msg_processed +=1 ;
return( ) ;
}
@@ -3492,17 +3536,34 @@ sub copy_message {
if ( not defined( $string ) and not defined( $string_len ) ) {
print "- msg $h1_fold/$h1_msg skipped. Could not be fetched\n" ;
+ $total_bytes_skipped += $h1_size;
+ $nb_msg_skipped += 1;
+ $h1_nb_msg_processed +=1 ;
return( ) ;
}
# Lines two long => do no copy
- if ( ( defined ( $maxlinelength ) )
- and ( max_line_length( $string ) > $maxlinelength ) ) {
- my $subject = subject( $string ) ;
- #print "[$subject]\n" ;
- print "- msg $h1_fold/$h1_msg skipped S[$h1_size] F[$h1_flags] I[$h1_idate] "
- . "(Subject:[$subject]) (line length exceeds maxlinelength $maxlinelength bytes)\n" ;
- return( ) ;
+ if ( defined ( $maxlinelength ) or defined ( $minmaxlinelength ) ) {
+ my $maxlinelength_string = max_line_length( $string ) ;
+ $debugmaxlinelength and print "msg $h1_fold/$h1_msg maxlinelength: $maxlinelength_string\n" ;
+ if ( defined ( $maxlinelength ) and ( $maxlinelength_string > $maxlinelength ) ) {
+ my $subject = subject( $string ) ;
+ print "- msg $h1_fold/$h1_msg skipped S[$h1_size] F[$h1_flags] I[$h1_idate] "
+ . "(Subject:[$subject]) (line length exceeds maxlinelength $maxlinelength bytes)\n" ;
+ $h1_nb_msg_processed +=1 ;
+ $total_bytes_skipped += $h1_size;
+ $nb_msg_skipped += 1;
+ return( ) ;
+ }
+ if ( defined ( $minmaxlinelength ) and ( $maxlinelength_string <= $minmaxlinelength ) ) {
+ my $subject = subject( $string ) ;
+ $debugdev and print "- msg $h1_fold/$h1_msg skipped S[$h1_size] F[$h1_flags] I[$h1_idate] "
+ . "(Subject:[$subject]) (max line length under minmaxlinelength $minmaxlinelength bytes)\n" ;
+ $h1_nb_msg_processed +=1 ;
+ $total_bytes_skipped += $h1_size;
+ $nb_msg_skipped += 1;
+ return( ) ;
+ }
}
my $h1_date = date_for_host2( $h1_msg, $h1_idate ) ;
@@ -3530,6 +3591,8 @@ sub copy_message {
return( $new_id ) ;
}
+
+
sub message_for_host2 {
my ( $h1_msg, $h1_fold, $h1_size, $h1_flags, $h1_idate, $h1_fir_ref ) = @_ ;
@@ -4945,7 +5008,7 @@ sub check_last_release {
}
sub imapsync_version {
- my $rcs_imapsync = '$Id: imapsync,v 1.580 2013/12/25 02:52:36 gilles Exp gilles $ ' ;
+ my $rcs_imapsync = '$Id: imapsync,v 1.584 2014/02/05 00:40:59 gilles Exp gilles $ ' ;
my $imapsync_version ;
if ( $rcs_imapsync =~ m{,v\s+(\d+\.\d+)}xo ) {
@@ -5846,7 +5909,7 @@ Several options are mandatory.
--exitwhenover Alternatives to imapsync are listed in the Similar softwares section.
Imapsync used to be free, open and gratis, before november 2010.
+ Imapsync used to be free, open and gratis, that was before november 2010.
Now imapsync is free, open and not gratis from the homepage.
-It is the best decision I've done about imapsync to continue to maintain it.
+Imapsync is still under the NOLIMIT license,
+claiming no limit to do anything with this work and this license,
+so one of the most open license of the universe.
+
+It is the best decisions I've made about imapsync to continue to maintain it.
See detailed explanation and motivation here when
I looked for a business model.
"Download and donate if happy" doesn't work well.
-"Pay for download and I pay back if unhappy" works well.
+"Pay for download and I pay back if unhappy" works well, a 100 times better.
Where all those numbers come from?
-To know wether a newer imapsync exists or not imapsync does a http GET to VERSION.
-Via the User-agent parameter it also send:Facts and figures for 2011-2013
+Facts and figures for 2011-2014
-
-
Good changed made before, listed because they can help: +
Good changes made before, listed because they can help:
@@ -346,6 +337,31 @@ example. + + +
Buy latest imapsync Perl source code for 50 EUR @@ -391,7 +407,7 @@ name="submit" alt="PayPal - The safer, easier way to pay online!"/>
-You will receive a download link just after the payment from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
+
You will receive a download link just after the payment from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
You will also receive a gpg signed invoice within a few days by email.
Please give a delivery postal address where the invoice will be needed
(your company for example), since reedit is not easy (and forbidden by law).
@@ -440,7 +456,7 @@ name="submit" alt="PayPal - The safer, easier way to pay online!"/>
You will receive a download link just after the payment, from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
+
You will receive a download link just after the payment, from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
You will also receive a gpg signed invoice within a few days by email.
Please give a delivery postal address where the invoice will be needed
(your company for example), since reedit is not easy (and forbidden by law).
@@ -449,7 +465,7 @@ Please give a delivery postal address where the invoice will be needed
@@ -496,7 +512,7 @@ It's 2 letters followed by 11 digits, for example mine is FR74429303332.
You will receive instructions to contact me just after the payment, from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
+
You will receive instructions to contact me just after the payment, from gilles.lamiral@laposte.net (can fall in Spam folder sometimes).
You will also receive a gpg signed invoice within a few days by email.
Please give a delivery postal address where the invoice will be needed
(your company for example), since reedit is not easy (and forbidden by law).
@@ -622,7 +638,7 @@ I like it.
(http://www.communigate.com/)