talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit a1bd253699b28147da57a160186f8cd742b26185
parent 2df2dd438ffc7f89ea31cdc1b05dba93944bf2a4
Author: Paul Mangan <paul@claws-mail.org>
Date:   Fri, 16 May 2008 10:31:50 +0000

2008-05-16 [paul]	3.4.0cvs45

	* tools/README
	* tools/csv2addressbook.pl
		add support for gmail exported csv address book

Diffstat:
MChangeLog | 6++++++
MPATCHSETS | 1+
Mconfigure.ac | 2+-
Mtools/README | 19++++++++++++++++---
Mtools/csv2addressbook.pl | 35+++++++++++++++++++++++++++--------
5 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-16 [paul] 3.4.0cvs45 + + * tools/README + * tools/csv2addressbook.pl + add support for gmail exported csv address book + 2008-05-16 [colin] 3.4.0cvs44 * configure.ac diff --git a/PATCHSETS b/PATCHSETS @@ -3340,3 +3340,4 @@ ( cvs diff -u -r 1.9.2.22 -r 1.9.2.23 src/gtk/sslcertwindow.c; ) > 3.4.0cvs42.patchset ( diff -u /dev/null manual/de/account.xml; diff -u /dev/null manual/it/account.xml; diff -u /dev/null manual/it/ack.xml; diff -u /dev/null manual/it/addrbook.xml; diff -u /dev/null manual/it/claws-mail-manual.xml; diff -u /dev/null manual/it/gpl.xml; diff -u /dev/null manual/it/intro.xml; diff -u /dev/null manual/it/starting.xml; ) > 3.4.0cvs43.patchset ( cvs diff -u -r 1.654.2.3400 -r 1.654.2.3401 configure.ac; cvs diff -u -r 1.1.2.19 -r 1.1.2.20 src/ldapupdate.c; ) > 3.4.0cvs44.patchset +( cvs diff -u -r 1.30.2.28 -r 1.30.2.29 tools/README; cvs diff -u -r 1.1.2.2 -r 1.1.2.3 tools/csv2addressbook.pl; ) > 3.4.0cvs45.patchset diff --git a/configure.ac b/configure.ac @@ -11,7 +11,7 @@ MINOR_VERSION=4 MICRO_VERSION=0 INTERFACE_AGE=0 BINARY_AGE=0 -EXTRA_VERSION=44 +EXTRA_VERSION=45 EXTRA_RELEASE= EXTRA_GTK2_VERSION= diff --git a/tools/README b/tools/README @@ -14,7 +14,7 @@ Action scripts: OpenOffice Addressbook conversion: - csv2addressbook.pl Import Becky, Thunderbird or Kmail address books + csv2addressbook.pl Import Becky, Thunderbird, Kmail Gmail address books eud2gc.py Convert Eudora address book to Gnomecard kmail2claws-mail.pl Import a Kmail address book (KDE2) kmail2claws-mail_v2.pl Import a Kmail address book (KDE3) @@ -142,8 +142,8 @@ Address book conversion * csv2addressbook.pl WHAT IT DOES - This perl script will import a Becky, Thunderbird and Kmail address - book. + This perl script will import a Becky, Thunderbird, Kmail and Gmail + address book. HOW TO USE IT (You must run claws-mail at least once before running this script.) @@ -190,6 +190,19 @@ Address book conversion WARNING: Kmail/Kaddressbook has a bug whereby it exports badly formatted CSV if the values are quoted. + Gmail + ----- + In the Gmail web interface you need to export your address book + as Outlook CSV format. + + Run the script with the following options: + + perl csv2addressbook.pl --type=gmail --csv=/full/path/to/file.csv + + Addtionally you can use the option '--name="My address book"', if + you don't use this option the new Claws address book will be + called 'gmail address book'. + You can also run the script with '--help' to get a brief usage message. Contact: Paul Mangan <paul@claws-mail.org> diff --git a/tools/csv2addressbook.pl b/tools/csv2addressbook.pl @@ -28,11 +28,13 @@ use Text::CSV_XS; # Thunderbird >= 2.0.0.6 # Kmail >= 1.9.7 / Kaddressbook >= 3.5.7 # ** kmail bug: can export badly formatted csv ** +# Gmail # # Becky: full export with titles # thunderbird: export as 'comma separated' # kmail/kaddressbook: Export CSV list +# gmail: export Outlook format ### my $quote_char = '"'; @@ -46,7 +48,7 @@ my $csvfile = ''; my $bookname = ''; my $iNeedHelp = ''; -my $known_types = qr/^(?:becky|thunderbird|kmail)$/; +my $known_types = qr/^(?:becky|thunderbird|kmail|gmail)$/; GetOptions("type=s" => \$type, "csv=s" => \$csvfile, @@ -82,6 +84,12 @@ my @kmail_fields = ('Formatted Name','Family Name','Given Name', 'Organisation','Department','Note','Homepage','Profession', 'Assistant\'s Name','Manager\'s Name','Partner\'s Name', 'Office','IM Address','Anniversary','Blog'); +my @gmail_fields = ('Name','E-mail Address','Notes','E-mail 2 Address', + 'E-mail 3 Address','Mobile Phone','Pager','Company', + 'Job Title','Home Phone','Home Phone 2','Home Fax', + 'Home Address','Business Phone','Business Phone 2', + 'Business Fax','Business Address','Other Phone','Other Fax', + 'Other Address','junk'); if (grep m/claws-mail/ => `ps -U $ENV{USER}`) { die("You must quit claws-mail before running this script\n"); @@ -103,10 +111,10 @@ if ($csvfile eq "" || $type eq "" || $type !~ m/$known_types/ || $iNeedHelp) { Usage: $script [OPTIONS] Options: - --help Show this screen - --type=becky|thunderbird|kmail Type of exported address book - --csv=FILENAME Full path to CSV file - --name="My new address book" Name of new Claws address book (optional) + --help Show this screen + --type=becky|thunderbird|kmail|gmail Type of exported address book + --csv=FILENAME Full path to CSV file + --name="My new address book" Name of new Claws address book (optional) ~; exit; } @@ -203,23 +211,30 @@ sub get_book_name { return("Thunderbird address book"); } elsif ($type eq "kmail") { return("Kmail address book"); + } elsif ($type eq "gmail") { + return("gmail address book"); } } sub check_fields { if ($type eq "becky") { if ($#csvfields != $#becky_fields) { - die("ERROR:\n\tNot enough fields!\n" + die("ERROR:\n\tInvalid field count!\n" ."\tYou need to do a Full Export With Titles\n"); } } elsif ($type eq "thunderbird") { if ($#csvfields != $#tbird_fields) { - die("ERROR:\n\tNot enough fields!\n" + die("ERROR:\n\tInvalid field count!\n" ."\tProblem with your exported CSV file\n"); } } elsif ($type eq "kmail") { if ($#csvfields != $#kmail_fields) { - die("ERROR:\n\tNot enough fields!\n" + die("ERROR:\n\tInvalid field count!\n" + ."\tProblem with your exported CSV file\n"); + } + } elsif ($type eq "gmail") { + if ($#csvfields != $#gmail_fields) { + die("ERROR:\n\tInvalid field count!\n" ."\tProblem with your exported CSV file\n"); } } @@ -315,6 +330,8 @@ sub get_items { return ('0','1','3','2','4','5','38'); } elsif ($type eq "kmail") { return ('2','1','6','0','28','34'); + } elsif ($type eq "gmail") { + return('0','0','0','0','1','2'); } } @@ -325,6 +342,8 @@ sub get_fields { return(@tbird_fields); } elsif ($type eq "kmail") { return(@kmail_fields); + } elsif ($type eq "gmail") { + return(@gmail_fields); } }