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