PATCH: improve mab2vcard

View: New views
4 Messages — Rating Filter:   Alert me  

PATCH: improve mab2vcard

by Patrick Ammann-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

The following patch improves syncing of Thunderbird's
address book with the iPod. In case an entry as no "N"
vcard field it is now suppressed. Without this patch i get
a some empty entries within the iPod calendar.

Thanks,
Patrick


--- mab2vcard.org 2009-09-02 09:50:03.000000000 +0200
+++ mab2vcard 2009-09-02 09:44:58.000000000 +0200
@@ -429,6 +429,12 @@
 
  );
  foreach my $vcard (@$results) {
+ if ($vcard->{FirstName} eq '' && $vcard->{LastName} eq '')
+ {
+ # skip entries with empty N field
+ next;
+ }
+
  print "BEGIN:VCARD\n";
  foreach my $key (keys %map) {
  my @fields = @{$map{$key}};

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtkpod-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

Re: PATCH: improve mab2vcard

by Jorg Schuler-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Is this really an improvement? I guess most people would want these
entries to be copied anyway. Wouldn't it be better to set the string to
"<empty>" or similar?

JCS.

Patrick Ammann wrote:

> Hi
>
> The following patch improves syncing of Thunderbird's
> address book with the iPod. In case an entry as no "N"
> vcard field it is now suppressed. Without this patch i get
> a some empty entries within the iPod calendar.
>
> Thanks,
> Patrick
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gtkpod-devel mailing list
> Gtkpod-devel@...
> https://lists.sourceforge.net/lists/listinfo/gtkpod-devel


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtkpod-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

Re: PATCH: improve mab2vcard

by Patrick Ammann-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jorg

In my case all those entries (firstname and lastname are empty) are bogus,
however i agree that my first solution is not so nice.
What i see is that for sure "groups" make really no sense to convert into
an address card + make sure we do not have empty N and FN fields ->
add "<empty>" when needed. See attached patch. In my addressbook
however now have some "<empty>" card, that should not have put out,
as they were printed out properly before (no idea why yet), but i can live
with this for now, it is now anyway far better than before.

Thanks,
Patrick


Jorg Schuler wrote:

> Is this really an improvement? I guess most people would want these
> entries to be copied anyway. Wouldn't it be better to set the string
> to "<empty>" or similar?
>
> JCS.
>
> Patrick Ammann wrote:
>> Hi
>>
>> The following patch improves syncing of Thunderbird's
>> address book with the iPod. In case an entry as no "N"
>> vcard field it is now suppressed. Without this patch i get
>> a some empty entries within the iPod calendar.
>>
>> Thanks,
>> Patrick
>>
>> ------------------------------------------------------------------------
>>
>> ------------------------------------------------------------------------------
>>
>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>> 30-Day trial. Simplify your report design, integration and deployment
>> - and focus on what you do best, core application coding. Discover
>> what's new with Crystal Reports now.  http://p.sf.net/sfu/bobj-july
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Gtkpod-devel mailing list
>> Gtkpod-devel@...
>> https://lists.sourceforge.net/lists/listinfo/gtkpod-devel
>

--- mab2vcard.org 2009-09-02 09:50:03.000000000 +0200
+++ mab2vcard 2009-09-06 14:25:18.000000000 +0200
@@ -429,6 +429,19 @@
 
  );
  foreach my $vcard (@$results) {
+ if ($vcard->{ListTotalAddresses} ne '')
+ {
+ # skip groups: ListTotalAddresses = <number of entries>
+ # it makes no sense to have those anyway empty cards
+ next;
+ }
+
+ if ($vcard->{FirstName} eq '' && $vcard->{LastName} eq '')
+ {
+ # set at least something
+ $vcard->{LastName} = "<empty>"
+ }
+
  print "BEGIN:VCARD\n";
  foreach my $key (keys %map) {
  my @fields = @{$map{$key}};
@@ -464,7 +477,7 @@
  HomeAddress HomeAddress2 HomeCity HomeState HomeCountry HomeZipCode
  HomePhone FaxNumber WorkPhone CellularNumber PagerNumber PrimaryEmail SecondEmail
  NickName Notes Company Department JobTitle URL _AimScreenName
- PreferMailFormat WebPage1 WebPage2
+ PreferMailFormat WebPage1 WebPage2 ListTotalAddresses
  );
 
  foreach my $key (keys %vcard) {

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtkpod-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

Re: PATCH: improve mab2vcard

by Patrick Ammann-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Jorg

Here comes a better version.

Thanks,
Patrick


Patrick Ammann wrote:

> Hi Jorg
>
> In my case all those entries (firstname and lastname are empty) are
> bogus,
> however i agree that my first solution is not so nice.
> What i see is that for sure "groups" make really no sense to convert into
> an address card + make sure we do not have empty N and FN fields ->
> add "<empty>" when needed. See attached patch. In my addressbook
> however now have some "<empty>" card, that should not have put out,
> as they were printed out properly before (no idea why yet), but i can
> live
> with this for now, it is now anyway far better than before.
>
> Thanks,
> Patrick
>
>
> Jorg Schuler wrote:
>> Is this really an improvement? I guess most people would want these
>> entries to be copied anyway. Wouldn't it be better to set the string
>> to "<empty>" or similar?
>>
>> JCS.
>>
>> Patrick Ammann wrote:
>>> Hi
>>>
>>> The following patch improves syncing of Thunderbird's
>>> address book with the iPod. In case an entry as no "N"
>>> vcard field it is now suppressed. Without this patch i get
>>> a some empty entries within the iPod calendar.
>>>
>>> Thanks,
>>> Patrick
>>>
>>> ------------------------------------------------------------------------
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> Let Crystal Reports handle the reporting - Free Crystal Reports 2008
>>> 30-Day trial. Simplify your report design, integration and
>>> deployment - and focus on what you do best, core application coding.
>>> Discover what's new with Crystal Reports now.  
>>> http://p.sf.net/sfu/bobj-july
>>> ------------------------------------------------------------------------
>>>
>>>
>>> _______________________________________________
>>> Gtkpod-devel mailing list
>>> Gtkpod-devel@...
>>> https://lists.sourceforge.net/lists/listinfo/gtkpod-devel
>>
>
> ------------------------------------------------------------------------
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> ------------------------------------------------------------------------
>
> _______________________________________________
> Gtkpod-devel mailing list
> Gtkpod-devel@...
> https://lists.sourceforge.net/lists/listinfo/gtkpod-devel

--- mab2vcard.org 2009-09-02 09:50:03.000000000 +0200
+++ mab2vcard 2009-09-06 17:34:52.000000000 +0200
@@ -429,6 +429,13 @@
 
  );
  foreach my $vcard (@$results) {
+ if ($vcard->{ListTotalAddresses} ne '')
+ {
+ # skip groups: ListTotalAddresses = <number of entries>
+ # it makes no sense to have those anyway empty cards
+ next;
+ }
+
  print "BEGIN:VCARD\n";
  foreach my $key (keys %map) {
  my @fields = @{$map{$key}};
@@ -437,6 +444,9 @@
  $data = $vcard->{WebPage1}||$vcard->{WebPage2}||'';
  } elsif ($key eq 'X-MOZILLA-HTML') {
  $data = $vcard->{PreferMailFormat}==2 ? 'TRUE' : 'FALSE';
+ } elsif ($key eq 'FN' && $vcard->{FirstName} eq '' && $vcard->{LastName} eq '') {
+ # set at least something
+ $data = $vcard->{DisplayName} eq '' ? "<empty>" : $vcard->{DisplayName};
  } else {
  $data = join($fields[0],map {$vcard->{$_}||''} @fields[1..$#fields]);
  }
@@ -464,7 +474,7 @@
  HomeAddress HomeAddress2 HomeCity HomeState HomeCountry HomeZipCode
  HomePhone FaxNumber WorkPhone CellularNumber PagerNumber PrimaryEmail SecondEmail
  NickName Notes Company Department JobTitle URL _AimScreenName
- PreferMailFormat WebPage1 WebPage2
+ PreferMailFormat WebPage1 WebPage2 ListTotalAddresses
  );
 
  foreach my $key (keys %vcard) {

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Gtkpod-devel mailing list
Gtkpod-devel@...
https://lists.sourceforge.net/lists/listinfo/gtkpod-devel