File: licq2ickle.pl

package info (click to toggle)
ickle 0.2.2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,252 kB
  • ctags: 2,353
  • sloc: cpp: 12,371; sh: 6,963; makefile: 144; perl: 76
file content (58 lines) | stat: -rwxr-xr-x 1,605 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/perl

#
# perl script to convert licq's contact list across
# to ickle
# (c) Barnaby Gray 2001 <barnaby@beedesign.co.uk>
#

print "licq2ickle.pl script\n";
print "--------------------\n\n";

if (!defined $ENV{'HOME'}) {
    print "Problem: Couldn't figure out home directory, environment\nvariable HOME is not set.\n\n";
    exit(-1);
}

$home = $ENV{'HOME'};
$licq_dir = "$home/.licq/";
$licq_users_dir = "$home/.licq/users/";
$ickle_dir = "$home/.ickle/";
$ickle_users_dir = "$home/.ickle/contacts/";

die ("Problem: Directory $licq_dir doesn't exist\n") unless (-d $licq_dir);
die ("Problem: Directory $licq_users_dir doesn't exist\n") unless (-d $licq_users_dir);

@users = glob("${licq_users_dir}*.uin");

die ("Problem: Creating directory $ickle_dir: $!") unless ( -d $ickle_dir or mkdir($ickle_dir, 0700));
die ("Problem: Creating directory $ickle_users_dir: $!") unless ( -d $ickle_users_dir or mkdir($ickle_users_dir, 0700));

foreach $filename (@users) {
    my ($uin, $alias, $mobile_no);
    next if ($filename !~ /\/(\d+).uin$/);
    $uin = $1;

    open USER, "<$filename";
    while(<USER>) {
	chomp;
	if (/^Alias = (.+)$/) {
	    $alias = $1;
	} elsif (/^CellularNumber = (.+)$/) {
	    $mobile_no = $1;
	    $mobile_no =~ s/\D//g;
	}
    }
    close USER;

    open(USER, ">${ickle_users_dir}${uin}.user") or die("Couldn't create ${ickle_users_dir}${uin}.user\n");
    print USER "uin = $uin\n";
    print USER "alias = $alias\n";
    print USER "mobile_no = $mobile_no\n";
    close USER;
    
    print "Created user $alias ($uin)\n";
}

print "Finished successfully.\n\n";