comparison Calcon.pm @ 15:d0692e1c031f

*** empty log message ***
author kono
date Sat, 08 Nov 2008 14:24:55 +0900
parents 6ee8b90426e7
children
comparison
equal deleted inserted replaced
14:6ee8b90426e7 15:d0692e1c031f
25 25
26 #our @EXPORT = qw( 26 #our @EXPORT = qw(
27 27
28 #); 28 #);
29 29
30 our $VERSION = '0.01'; 30 our $VERSION = '0.02';
31 31
32 32
33 # Preloaded methods go here. 33 # Preloaded methods go here.
34 34
35 # if you don't have NKF 35 # if you don't have NKF
1768 $self->value($id,$phone_id,'phone',$record); 1768 $self->value($id,$phone_id,'phone',$record);
1769 } 1769 }
1770 1770
1771 my $email_count = RunAppleScript("${tell}count of email of person $id\nend tell\n"); 1771 my $email_count = RunAppleScript("${tell}count of email of person $id\nend tell\n");
1772 foreach my $email_id ( 1..$email_count ) { 1772 foreach my $email_id ( 1..$email_count ) {
1773 $self->value($id,$email_id,'email',$record); 1773 $self->value($id,$email_id,'mail',$record);
1774 } 1774 }
1775 1775
1776 my $address_count = RunAppleScript("${tell}count of address of person $id\nend tell\n"); 1776 my $address_count = RunAppleScript("${tell}count of address of person $id\nend tell\n");
1777 foreach my $address_id ( 1..$address_count ) { 1777 foreach my $address_id ( 1..$address_count ) {
1778 $self->address($id,$address_id,'address',$record); 1778 $self->address($id,$address_id,'address',$record);
2539 'categories'=>'categories', 2539 'categories'=>'categories',
2540 'company'=>'office', 2540 'company'=>'office',
2541 'companypronunciation'=>'office-yomi', 2541 'companypronunciation'=>'office-yomi',
2542 'department'=>'section', 2542 'department'=>'section',
2543 'description'=>'memo', 2543 'description'=>'memo',
2544 'emails'=>'email', 2544 'emails'=>'mail',
2545 'end'=>'end-date', 2545 'end'=>'end-date',
2546 'firstname'=>'first-name', 2546 'firstname'=>'first-name',
2547 'firstnamepronunciation'=>'first-name-yomi', 2547 'firstnamepronunciation'=>'first-name-yomi',
2548 'homefax'=>'home-fax', 2548 'homefax'=>'home-fax',
2549 'homemobile'=>'home-keitai', 2549 'homemobile'=>'home-keitai',
2732 } 2732 }
2733 2733
2734 my ($address) = $adr->{'address'}; 2734 my ($address) = $adr->{'address'};
2735 my ($birth) = $adr->{'birth'}; 2735 my ($birth) = $adr->{'birth'};
2736 my ($company) = $adr->{'office'}; 2736 my ($company) = $adr->{'office'};
2737 my ($email) = $adr->{'email'}; 2737 my ($mail) = $adr->{'mail'};
2738 my ($fax) = $adr->{'fax'}; 2738 my ($fax) = $adr->{'fax'};
2739 my ($first_name) = $adr->{'first-name'}; 2739 my ($first_name) = $adr->{'first-name'};
2740 my ($first_name_yomi) = $adr->{'first-name-yomi'}; 2740 my ($first_name_yomi) = $adr->{'first-name-yomi'};
2741 my ($home_address) = $adr->{'home-address'}; 2741 my ($home_address) = $adr->{'home-address'};
2742 my ($home_fax) = $adr->{'home-fax'}; 2742 my ($home_fax) = $adr->{'home-fax'};
2773 $self->print ( "HomeMobile=\"$home_keitai\" " ) if ($home_keitai); 2773 $self->print ( "HomeMobile=\"$home_keitai\" " ) if ($home_keitai);
2774 $self->print ( "HomeFax=\"$home_fax\" " ) if ($home_fax); 2774 $self->print ( "HomeFax=\"$home_fax\" " ) if ($home_fax);
2775 $self->print ( "HomeStreet=\"$home_address\" " ) if ($home_address); 2775 $self->print ( "HomeStreet=\"$home_address\" " ) if ($home_address);
2776 $self->print ( "HomeState=\"$home_state\" " ) if ($home_state); 2776 $self->print ( "HomeState=\"$home_state\" " ) if ($home_state);
2777 $self->print ( "HomeZip=\"$home_zip\" " ) if ($home_zip); 2777 $self->print ( "HomeZip=\"$home_zip\" " ) if ($home_zip);
2778 $self->print ( "Emails=\"$email\" " ) if ($email); 2778 $self->print ( "Emails=\"$mail\" " ) if ($mail);
2779 $self->print ( "Notes=\"$memo\" " ) if ($memo); 2779 $self->print ( "Notes=\"$memo\" " ) if ($memo);
2780 $self->print ( "rid=\"$count\" "); 2780 $self->print ( "rid=\"$count\" ");
2781 $self->print ( "rinfo=\"1\" "); 2781 $self->print ( "rinfo=\"1\" ");
2782 $self->print ( "LastNamePronunciation=\"$name_yomi\" " ) if ($name_yomi); 2782 $self->print ( "LastNamePronunciation=\"$name_yomi\" " ) if ($name_yomi);
2783 $self->print ( "FirstNamePronunciation=\"$first_name_yomi\" " ) if ($first_name_yomi); 2783 $self->print ( "FirstNamePronunciation=\"$first_name_yomi\" " ) if ($first_name_yomi);
2822 # 2822 #
2823 2823
2824 sub initialize { 2824 sub initialize {
2825 my ($self) = @_; 2825 my ($self) = @_;
2826 $self->SUPER::initialize(); 2826 $self->SUPER::initialize();
2827 $self->{'-fake-allday'} = 1; 2827 $self->{'-fake-allday'} = 0;
2828 $self->{'-time-for-allday'} = 12*3600; 2828 $self->{'-time-for-allday'} = 12*3600;
2829 $self->{'-add-time-for-allday'} = 2*3600; 2829 $self->{'-add-time-for-allday'} = 2*3600;
2830 } 2830 }
2831 2831
2832 sub record { 2832 sub record {
2882 VERSION:2.0 2882 VERSION:2.0
2883 EOFEOF 2883 EOFEOF
2884 $self->{'-vcal-opening'} = 1; 2884 $self->{'-vcal-opening'} = 1;
2885 } 2885 }
2886 2886
2887 if ($record{'date'}->is_allday() && $self->{'-fake-allday'}) { 2887 # if ($record{'date'}->is_allday() && $self->{'-fake-allday'}) {
2888 $record{'date'}=$record{'date'}->add($self->{'-time-for-allday'}); 2888 # $record{'date'}=$record{'date'}->add($self->{'-time-for-allday'});
2889 } 2889 # }
2890 my $dtstart = "\nDTSTART;TZID=$timezone:".$self->date($record{'date'}); 2890 my $dtstart = "\nDTSTART;TZID=$timezone:".$self->date($record{'date'});
2891 my $dtend = ''; 2891 my $dtend = '';
2892 my $dtstamp = ''; 2892 my $dtstamp = '';
2893 2893
2894 if (! defined( $record{'end-date'}) || $record{'end-date'} == $record{'date'} ) { 2894 if (! $record{'date'}->is_allday()) {
2895 # $dtend = "\nDURATION:PT2H"; this is useless for iCal 2895 if (! defined( $record{'end-date'}) || $record{'end-date'} == $record{'date'} ) {
2896 $record{'end-date'} = $record{'date'}->add( 2896 # $dtend = "\nDURATION:PT2H"; this is useless for iCal
2897 $self->{'-add-time-for-allday'}); 2897 $record{'end-date'} = $record{'date'}->add(
2898 $dtend = "\nDTEND;TZID=$timezone:".$self->date($record{'end-date'}); 2898 $self->{'-add-time-for-allday'});
2899 $dtend = "\nDTEND;TZID=$timezone:".$self->date($record{'end-date'});
2900 } else {
2901 $dtend = "\nDTEND;TZID=$timezone:".$self->date($record{'end-date'});
2902 }
2899 } else { 2903 } else {
2900 $dtend = "\nDTEND;TZID=$timezone:".$self->date($record{'end-date'}); 2904 $dtend = '';
2905 $dtstart =~ s/T000000$//;
2901 } 2906 }
2902 if (defined( $record{'modify-date'})) { 2907 if (defined( $record{'modify-date'})) {
2903 $dtstamp = "\nDTSTAMP;TZID=$timezone:".$self->date($record{'modify-date'}); 2908 $dtstamp = "\nDTSTAMP;TZID=$timezone:".$self->date($record{'modify-date'});
2904 } 2909 }
2905 2910
3130 # $data = $data.";".$record{'office'}; 3135 # $data = $data.";".$record{'office'};
3131 # } 3136 # }
3132 # print "n:$data\n" if($data); 3137 # print "n:$data\n" if($data);
3133 } 3138 }
3134 # my $cat = 0; 3139 # my $cat = 0;
3135 # if(defined $record{'group'}) { 3140 if(defined $record{'group'}) {
3136 # $data = "$record{'group'}"; 3141 $data = "$record{'group'}";
3137 # $self->print("CATEGORIES:$data\n") if($data); 3142 $self->print("CATEGORIES:$data\n") if($data);
3138 # } 3143 }
3139 if(defined $record{'office'}) { 3144 if(defined $record{'office'}) {
3140 $data = "$record{'office'}"; 3145 $data = "$record{'office'}";
3141 $self->print("ORG:$data;\n") if($data); 3146 $self->print("ORG:$data;\n") if($data);
3142 # if ($cat==0) { 3147 # if ($cat==0) {
3143 # $self->print("CATEGORIES:$data\n") if($data); 3148 # $self->print("CATEGORIES:$data\n") if($data);
4215 } elsif (/^note:\s*(.*)/i) { $record->{'memo'} .= $1; 4220 } elsif (/^note:\s*(.*)/i) { $record->{'memo'} .= $1;
4216 } elsif (/^dtend(.*):\s*(.*)/i) { $record->{'end-date'} = $self->date($2,$1?$1:$record->{'timezone'}); 4221 } elsif (/^dtend(.*):\s*(.*)/i) { $record->{'end-date'} = $self->date($2,$1?$1:$record->{'timezone'});
4217 } elsif (/^dtstamp(.*):\s*(.*)/i) { $record->{'modify-date'} = $self->date($2,$1?$1:$record->{'timezone'}); 4222 } elsif (/^dtstamp(.*):\s*(.*)/i) { $record->{'modify-date'} = $self->date($2,$1?$1:$record->{'timezone'});
4218 } elsif (/^dtstart(.*):\s*(.*)/i) { $record->{'date'} = $self->date($2,$1?$1:$record->{'timezone'}); 4223 } elsif (/^dtstart(.*):\s*(.*)/i) { $record->{'date'} = $self->date($2,$1?$1:$record->{'timezone'});
4219 } elsif (/^duration:\s*(.*)/i) { $self->duration($record,$1); 4224 } elsif (/^duration:\s*(.*)/i) { $self->duration($record,$1);
4220 } elsif (/^email(.*):\s*(.*)/i) { $self->items($record,'email',$1,$2); 4225 } elsif (/^email(.*):\s*(.*)/i) { $self->items($record,'mail',$1,$2);
4221 } elsif (/^end:\s*vcard/i) { $self->vcard($record); 4226 } elsif (/^end:\s*vcard/i) { $self->vcard($record);
4222 } elsif (/^end:\s*vevent/i) { $self->event($record); 4227 } elsif (/^end:\s*vevent/i) { $self->event($record);
4223 } elsif (/^fn:\s*(.*)/i) { $self->name($record,$1); 4228 } elsif (/^fn:\s*(.*)/i) { $self->name($record,$1);
4224 } elsif (/^label(.*):\s*(.*)/i) { $self->items($record,'address',$1,$2); 4229 } elsif (/^label(.*):\s*(.*)/i) { $self->items($record,'address',$1,$2);
4225 } elsif (/^method:\s*(.*)/i) { $record->{'publish'} = $1; 4230 } elsif (/^method:\s*(.*)/i) { $record->{'publish'} = $1;