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