annotate calcon.pl @ 8:37b9a5119474

add apple address book (Tiger 10.4)
author kono
date Sat, 07 May 2005 23:25:45 +0900
parents 13949e4d6f18
children 1a68139a269f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
144819f5d2f6 Initial revision
kono
parents:
diff changeset
1 #!/usr/bin/perl
144819f5d2f6 Initial revision
kono
parents:
diff changeset
2
144819f5d2f6 Initial revision
kono
parents:
diff changeset
3 use Calcon;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
4
144819f5d2f6 Initial revision
kono
parents:
diff changeset
5 use strict;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
6 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK
144819f5d2f6 Initial revision
kono
parents:
diff changeset
7 $opt_f $opt_t $opt_n $opt_d $opt_h $opt_F $opt_O $opt_a $opt_c
144819f5d2f6 Initial revision
kono
parents:
diff changeset
8 );
144819f5d2f6 Initial revision
kono
parents:
diff changeset
9
144819f5d2f6 Initial revision
kono
parents:
diff changeset
10 my %input = (
144819f5d2f6 Initial revision
kono
parents:
diff changeset
11 'Zaurus' => 'Calcon::Zaurus_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
12 'Backup Zaurus' => 'Calcon::Zaurus_backup_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
13 'Xcalendar' => 'Calcon::Xcalendar_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
14 'Vcard' => 'Calcon::Vcard_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
15 'SLA300' => 'Calcon::Sla300_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
16 'iApp' => 'Calcon::iApp_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
17 'Entourage' => 'Calcon::Entourage_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
18 'File' => 'Calcon::File_read',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
19 );
144819f5d2f6 Initial revision
kono
parents:
diff changeset
20
144819f5d2f6 Initial revision
kono
parents:
diff changeset
21 my %output = (
144819f5d2f6 Initial revision
kono
parents:
diff changeset
22 'Xcalendar' => 'Calcon::Xcalendar_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
23 'Vcard' => 'Calcon::Vcard_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
24 'SLA300' => 'Calcon::Sla300_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
25 'AppleScript' => 'Calcon::iApp_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
26 'iApp' => 'Calcon::iApp_write',
8
37b9a5119474 add apple address book (Tiger 10.4)
kono
parents: 7
diff changeset
27 'Address Book' => 'Calcon::Vcard_Apple_write',
1
144819f5d2f6 Initial revision
kono
parents:
diff changeset
28 'Entourage' => 'Calcon::Entourage_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
29 'Print' => 'Calcon::Print_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
30 'File' => 'Calcon::File_write',
144819f5d2f6 Initial revision
kono
parents:
diff changeset
31 );
144819f5d2f6 Initial revision
kono
parents:
diff changeset
32
144819f5d2f6 Initial revision
kono
parents:
diff changeset
33 use Getopt::Std;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
34
144819f5d2f6 Initial revision
kono
parents:
diff changeset
35 getopts('f:t:ndhO:acF');
144819f5d2f6 Initial revision
kono
parents:
diff changeset
36
144819f5d2f6 Initial revision
kono
parents:
diff changeset
37 if ($opt_h) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
38 print "Usage: $0 [-d -n] -f input_type -t output_type inputfile\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
39 print " input type: ",join(" ",keys %input),"\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
40 print " output type: ",join(" ",keys %output),"\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
41 exit 0;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
42 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
43
144819f5d2f6 Initial revision
kono
parents:
diff changeset
44 # print "option: $opt_f $opt_t\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
45 my $from_opts;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
46 my $to_opts;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
47
144819f5d2f6 Initial revision
kono
parents:
diff changeset
48 if (! @ARGV) { @ARGV = ('/dev/stdin'); }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
49 foreach my $file ( @ARGV ) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
50 my ($obj,$out);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
51
144819f5d2f6 Initial revision
kono
parents:
diff changeset
52 $opt_f = 'file' if (!$opt_f);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
53 $opt_t = 'file' if (!$opt_t);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
54
144819f5d2f6 Initial revision
kono
parents:
diff changeset
55 if ($opt_f =~ s/:.*//) { $from_opts = $&; }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
56 $opt_f =~ s/(\W)/\\$1/g;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
57 foreach my $key ( keys %input) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
58 if ($key =~ /^$opt_f/i) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
59 $obj = $input{$key};
144819f5d2f6 Initial revision
kono
parents:
diff changeset
60 last;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
61 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
62 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
63 $obj = $obj->new($from_opts);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
64
144819f5d2f6 Initial revision
kono
parents:
diff changeset
65 if ($opt_t =~ s/:.*//) { $to_opts = $&; }
7
13949e4d6f18 *** empty log message ***
kono
parents: 1
diff changeset
66 $to_opts .= '-n' if ($opt_n);
1
144819f5d2f6 Initial revision
kono
parents:
diff changeset
67 $opt_t =~ s/(\W)/\\$1/g;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
68 foreach my $key ( keys %output) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
69 if ($key =~ /^$opt_t/i) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
70 $out = $output{$key};
144819f5d2f6 Initial revision
kono
parents:
diff changeset
71 last;
144819f5d2f6 Initial revision
kono
parents:
diff changeset
72 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
73 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
74 $out = $out->new($to_opts);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
75 # print "$obj $out\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
76 $obj->set_output($out);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
77
7
13949e4d6f18 *** empty log message ***
kono
parents: 1
diff changeset
78 # $out->{'-file-out'} = $opt_n; too late
1
144819f5d2f6 Initial revision
kono
parents:
diff changeset
79
144819f5d2f6 Initial revision
kono
parents:
diff changeset
80 foreach my $o ( $obj, $out) {
144819f5d2f6 Initial revision
kono
parents:
diff changeset
81 $o->set_debug(1) if ($opt_d);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
82 $o->{'-address-only'} = 1 if ($opt_a);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
83 $o->{'-calendar-only'} = 1 if ($opt_c);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
84 $o->{'-future-only'} = 1 if ($opt_F);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
85 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
86
144819f5d2f6 Initial revision
kono
parents:
diff changeset
87 # print "option: $opt_f $opt_t\n";
144819f5d2f6 Initial revision
kono
parents:
diff changeset
88 $obj -> decode($file);
144819f5d2f6 Initial revision
kono
parents:
diff changeset
89 }
144819f5d2f6 Initial revision
kono
parents:
diff changeset
90
144819f5d2f6 Initial revision
kono
parents:
diff changeset
91 #
144819f5d2f6 Initial revision
kono
parents:
diff changeset
92
144819f5d2f6 Initial revision
kono
parents:
diff changeset
93 __END__
144819f5d2f6 Initial revision
kono
parents:
diff changeset
94
144819f5d2f6 Initial revision
kono
parents:
diff changeset
95 =head1 NAME
144819f5d2f6 Initial revision
kono
parents:
diff changeset
96
144819f5d2f6 Initial revision
kono
parents:
diff changeset
97 calcon.pl -- Convert Various Calendar/Address data format
144819f5d2f6 Initial revision
kono
parents:
diff changeset
98
144819f5d2f6 Initial revision
kono
parents:
diff changeset
99 =head1 SYNOPSIS
144819f5d2f6 Initial revision
kono
parents:
diff changeset
100
144819f5d2f6 Initial revision
kono
parents:
diff changeset
101 perl calcon.pl -f from -t form [-d] [-n]
144819f5d2f6 Initial revision
kono
parents:
diff changeset
102
144819f5d2f6 Initial revision
kono
parents:
diff changeset
103 =head1 DESCRIPTION
144819f5d2f6 Initial revision
kono
parents:
diff changeset
104
144819f5d2f6 Initial revision
kono
parents:
diff changeset
105 -f from-format
144819f5d2f6 Initial revision
kono
parents:
diff changeset
106 File format
144819f5d2f6 Initial revision
kono
parents:
diff changeset
107 Zaurus Read Zaurus MI C1 Compact Flast
144819f5d2f6 Initial revision
kono
parents:
diff changeset
108 Xcalendar
144819f5d2f6 Initial revision
kono
parents:
diff changeset
109 vCal/vCard
144819f5d2f6 Initial revision
kono
parents:
diff changeset
110 iApp via Applescript
144819f5d2f6 Initial revision
kono
parents:
diff changeset
111 Entourage via Applescript
144819f5d2f6 Initial revision
kono
parents:
diff changeset
112
144819f5d2f6 Initial revision
kono
parents:
diff changeset
113
144819f5d2f6 Initial revision
kono
parents:
diff changeset
114 -t from-format
144819f5d2f6 Initial revision
kono
parents:
diff changeset
115 File format
144819f5d2f6 Initial revision
kono
parents:
diff changeset
116 iCal and Addres Book Applescript execution (-f put result into files in script-out )
144819f5d2f6 Initial revision
kono
parents:
diff changeset
117 vCal/vCard
144819f5d2f6 Initial revision
kono
parents:
diff changeset
118 Zaurus SLA-300
144819f5d2f6 Initial revision
kono
parents:
diff changeset
119 Entourage via Applescript
8
37b9a5119474 add apple address book (Tiger 10.4)
kono
parents: 7
diff changeset
120 Address Book (Mac OS X 10.4 Address Book)
1
144819f5d2f6 Initial revision
kono
parents:
diff changeset
121
144819f5d2f6 Initial revision
kono
parents:
diff changeset
122 -a addres only
144819f5d2f6 Initial revision
kono
parents:
diff changeset
123 -c calendar only
144819f5d2f6 Initial revision
kono
parents:
diff changeset
124 -F future only
144819f5d2f6 Initial revision
kono
parents:
diff changeset
125
144819f5d2f6 Initial revision
kono
parents:
diff changeset
126 -h show help
144819f5d2f6 Initial revision
kono
parents:
diff changeset
127 -d debug
144819f5d2f6 Initial revision
kono
parents:
diff changeset
128 -n non-execution mode for applescript
144819f5d2f6 Initial revision
kono
parents:
diff changeset
129 scripts are put into script-out directory
144819f5d2f6 Initial revision
kono
parents:
diff changeset
130
144819f5d2f6 Initial revision
kono
parents:
diff changeset
131 =cut