5 use base
'Text::vCard';
11 my $remote = LJ
::get_remote
();
13 return $class->new_remote( $remote, @_ );
22 my $upic = $u->userpic;
23 my $file = $upic ?
$upic->imagedata : undef;
25 my $vcard = $class->SUPER::new
;
26 $vcard->UID("$LJ::DOMAIN-uid-$u->{userid}");
27 $vcard->add_node({ 'node_type' => 'ADR', });
28 $vcard->add_node({ 'node_type' => 'N', });
29 $vcard->EMAIL($u->email_visible($remote));
30 $vcard->NICKNAME($u->{user
});
31 $vcard->URL($u->journal_base . "/");
33 $u->preload_props(qw(city state zip country
34 aolim icq yahoo msn jabber google_talk skype gizmo));
40 $node = $vcard->add_node({
41 'node_type' => 'PHOTO;BASE64',
43 my $photo = encode_base64
($file);
44 my $enphoto = "\n " . join("\n ", split(/\n/, $photo));
45 $node->{value
} = $enphoto;
48 if ($u->share_contactinfo($remote)) {
49 my @chats = qw(aolim icq yahoo msn jabber google_talk skype gizmo);
50 foreach my $c (@chats) {
53 $field = "AIM" if $c eq "aolim";
54 my $value = $u->prop($c)
56 $node = $vcard->add_node({
57 'node_type' => "X-$field;type=WORK;type=pref",
59 $node->{value
} = $value;
63 my $bday = $u->bday_string;
64 if ($bday && $u->can_show_full_bday) {
65 $bday = "0000-$bday" unless $bday =~ /\d\d\d\d/;
66 $node = $vcard->add_node({
67 'node_type' => 'BDAY;value=date',
69 $node->{value
} = $bday;
72 $node= $vcard->add_node({
73 'node_type' => 'X-RSS',
75 $node->{value
} = $u->journal_base . "/data/rss";
77 # Setting values on an address element
78 #$node->[0]->street('123 Fake');
79 if ($u->can_show_location) {
80 $node = $vcard->get({ 'node_type' => 'addresses' });
82 $node->[0]->city($u->prop('city'));
83 $node->[0]->region($u->prop('state'));
84 $node->[0]->post_code($u->prop('zip'));
85 $node->[0]->country($u->prop('country'));
88 $node = $vcard->get({ 'node_type' => 'name' });
90 #$node->[0]->family('Aker');
91 $node->[0]->given($u->{name
});
96 package LJ
::vCard
::Addressbook
;
98 use base
'Text::vCard::Addressbook';
102 my $vcards = $self->vcards;