1 |
#!/usr/bin/perl |
2 |
|
3 |
# ================================== |
4 |
# startup |
5 |
# ================================== |
6 |
|
7 |
use strict; |
8 |
use warnings; |
9 |
|
10 |
# load configuration-data from ini-file |
11 |
BEGIN { |
12 |
use lib '../libs'; |
13 |
use loadConfig; |
14 |
} |
15 |
|
16 |
use Torus::API; |
17 |
|
18 |
=pod |
19 |
# autodispatch to Torus::API |
20 |
use SOAP::Lite +autodispatch => |
21 |
proxy => "http://" . $config->get("soapservice_host") . ":" . $config->get("soapservice_port"), |
22 |
; |
23 |
=cut |
24 |
|
25 |
|
26 |
# for accessing MAPI via Win32::OLE ("Outlook.Application") |
27 |
use Torus::Driver::mapi; |
28 |
|
29 |
# dumping data or arbitrary objects |
30 |
use Data::Dumper; |
31 |
|
32 |
use Getopt::Long; |
33 |
|
34 |
|
35 |
our $VERSION = '0.08'; |
36 |
|
37 |
# ================================== |
38 |
# main |
39 |
# ================================== |
40 |
|
41 |
my $DEBUGLEVEL = $config->get("debug_level"); |
42 |
|
43 |
my $options; |
44 |
GetOptions( |
45 |
'mapidump' => \$options->{mapidump}, |
46 |
); |
47 |
|
48 |
my $hr = "-" x 60 . "\n"; |
49 |
|
50 |
#Torus::Driver::mapi::readFieldMapping($config->get('file_mapping')); |
51 |
Torus::Driver::mapi::start(); |
52 |
|
53 |
# V1 - get the default "Contact"-folder |
54 |
#my $Contacts = Torus::Driver::mapi::getContactFolder(); |
55 |
# V2 - get an arbitrary specified folder |
56 |
#my $Contacts = Torus::Driver::mapi::getContactFolder("test"); |
57 |
# V3 - work with multiple folders |
58 |
|
59 |
my $foldernames = $config->get("folders_use"); |
60 |
foreach my $foldername (@$foldernames) { |
61 |
#Torus::Driver::ldap::clearDnCache(); |
62 |
print $hr, " trying to access MAPI-Folder \"", $foldername, "\"", "\n", $hr; |
63 |
if (my $Contacts = Torus::Driver::mapi::getContactFolder($foldername)) { |
64 |
print " - syncing MAPI-Folder \"", $Contacts->name, "\"", "\n"; |
65 |
Torus::Driver::mapi::readMapiFolder($Contacts, $foldername, \&cb_getContact, $options); |
66 |
print "\n"; |
67 |
} else { |
68 |
print " - could not access MAPI-Folder \"", $foldername, "\"", "\n"; |
69 |
} |
70 |
} |
71 |
|
72 |
Torus::Driver::mapi::stop(); |
73 |
|
74 |
Torus::Driver::ldap::showCriticalEntries(); |
75 |
Torus::Driver::ldap::showGoodEntries(); |
76 |
|
77 |
|
78 |
# callback-function, recieves each Contact-Item data (attributes) as hash |
79 |
sub cb_getContact { |
80 |
# reference to hash with object-attributes |
81 |
my $sourceFolderName = shift; |
82 |
my $contact = shift; |
83 |
Torus::API->sendContact($sourceFolderName, $contact); |
84 |
print "." if $DEBUGLEVEL <= 1; |
85 |
} |
86 |
|
87 |
print "\n" if $DEBUGLEVEL <= 1; |
88 |
print "ready.", "\n"; |