1 package Thrasher
::Backend
::PyYahoo
;
5 use base
'Thrasher::Backend';
12 Thrasher::Backend::PyYahoo - Read-only backend for migration from
17 PyYIMt ( http://xmpppy.sourceforge.net/yahoo/ ) stores its backend
18 information in a GDBM file. This extract the useful information from
19 that GDBM file so that the migration script can use it as a
20 source to populate Thrasher's database with the proper values.
22 This translator will only get your username and password, since
23 that appears to be all it stores.
25 This just barely implements enough to allow migration out of this
32 my $parameters = shift;
34 my $self = bless $parameters, $class;
37 for my $required qw(location) {
38 if (!defined($self->{$required})) {
39 push @missing, $required;
43 die "$class required the following parameters that weren't "
44 ."provided: " . join(', ', @missing);
47 if (!-e
$self->{location
}) {
48 die "For PyYahoo, could not find the shelve file $self->{location}.";
51 my $python_program = <<PYTHON;
54 # technically, this will still fail if you have three quotes in
55 # your shelve file name, in which case all I can say is that
56 # what the heck were you thinking?
57 s = shelve.open("""/mail/jabber/spool/yahoouser.dbm""")
60 return "".join(['\%'+str(ord(x)) for x in s])
62 user_data = [(encode(x), encode(s[x]['username']),
63 encode(s[x]['password'])) for x in s.keys()]
65 for jid, username, password in user_data:
66 print jid, username, password
74 run
['python'], \
$python_program, \
$out;
77 my @lines = split (/\r?\n/m, $out);
79 print Dumper
(\
@lines);
81 for my $line (@lines) {
82 my ($jid, $username, $password) = map { decode
($_) } split(/ /, $line);
83 $self->{registrations
}->{$jid} = {username
=> $username,
84 password
=> $password};
90 # The inverse of that python encode function up there
93 $s =~ s/%(\d+)/chr($1)/ge;
99 my @jids = keys %{$self->{registrations
}};
107 return $self->{registrations
}->{$jid};
110 sub all_mappings
{ return {} }
111 sub get_roster
{ return {} }
112 sub all_avatars
{ return {} }