* fix crash in PersonalInviteDialog
[kdenetwork.git] / knewsticker / knt-0.1-0.2.pl
blob2ca9e30cade4cd7bc40006a3fd5c567fee21c5fa
1 #!/usr/bin/perl
2 # convert which file to which file?
3 # I did nto bother to build in any checks. so that file better exists and it is readable and the data will
4 # be written to a writeable directory. Since this is an old config file, it is safe to assume, that is the
5 # case.
7 #$file = $ARGV[0];
9 # Take your hands off the rest unless you darn well knwo what you are doing
10 ##################################################################################
11 ##################################################################################
13 open(INFO, $file);
14 my ($section, %data);
16 #read in all the data, split it up into hashes. Thanks again to malte for much input
17 while (<>) {
18 if (/\[(.*)\]/) {
19 $sections{$section} = {%data} if $section;
20 $section = $1;
21 undef %data;
22 next;
24 $data{$1} = $2 if /^([^=]*)=(.*)$/;
27 $sections{$section} = {%data} if $section;
29 # do the data writing magic
30 #first of all be check how many old news souerces we have
32 $sources = $sections{'General'}->{'News sources'};
33 #gather all news sources into a very pretty string before we write the global section
34 #also give some feedback to the user
35 for my $i (0..($sources-1)) {
36 $all .= "," .$sections{"News source #$i"}->{'Name'};
37 $all =~s/^,//;
40 # write the main section
41 print "[KNewsTicker]\n";
43 while (($key,$dat) = each(%{$sections{'General'}})) {
44 if ($key ne "News sources") {
45 if ($key eq "Interval") {
46 $key="Update interval";
48 if ($key eq "Scroll most recent only") {
49 $key="Scroll most recent headlines only";
51 print "$key=$dat\n";
52 } else {
53 print "News sources=".$all."\n";
58 # next merge the old scrolling section into the KNewticker Section
59 while (($key,$dat) = each(%{$sections{'Scrolling'}})) {
60 if ($key eq "Background") {
61 $key="Background color";
64 if ($key eq "Foreground") {
65 $key="Foreground color";
67 if ($key eq "Highlighted") {
68 $key="Highlighted color";
70 if ($key eq "Underline highlighted") {
71 $key="Underline highlighted headlines";
73 if (($key eq "Direction") && ($dat eq "Left")) {
74 $key ="Scrolling direction";
75 $dat = "0";
78 if (($key eq "Direction") && ($dat ne "Left")) {
80 $key ="Scrolling direction";
83 if ($key eq "Speed") {
84 $key="Scrolling speed";
89 print "$key=$dat\n";
92 # next we write the news sources, making sure we have the correct headers
93 for my $i (0..($sources-1)) {
95 print "\n[" .$sections{"News source #$i"}->{'Name'} ."]\n";
96 while (($key,$dat) = each(%{$sections{"News source #$i"}})) {
97 if ($key ne "Address") {
98 print "$key=$dat\n";
99 } else {
100 print "Source file=".$dat."\n";