From 5eeebabb8af9526c036386a4e88957c9d4c7bd51 Mon Sep 17 00:00:00 2001
From: Fritz Elfert <felfert@to.com>
Date: Tue, 16 Jul 2002 17:43:56 +0000
Subject:  - Unified kioslave documentation  - Added merge-script for kioslave
 documentation

---
 conf/kiodoc-update.pl              | 110 +++++++++++++++++++++++++++++++++++++
 etc/plptools.spec.in               |  45 ++++++++++++---
 kde2/doc/kioslave/de/psion.docbook |  16 ++++--
 kde2/doc/kioslave/en/psion.docbook |  15 +++--
 po/de.po                           |   2 +-
 po/sv.po                           |   2 +-
 6 files changed, 168 insertions(+), 22 deletions(-)
 create mode 100644 conf/kiodoc-update.pl

diff --git a/conf/kiodoc-update.pl b/conf/kiodoc-update.pl
new file mode 100644
index 0000000..9af82e7
--- /dev/null
+++ b/conf/kiodoc-update.pl
@@ -0,0 +1,110 @@
+#! /usr/bin/perl -w
+#
+# $Id$
+
+chomp(my $htmldir = `kde-config --expandvars --install html`);
+
+sub from($) {
+	open(F, "<$_[0]") || die "Can't open $_[0] for read: $!\n";
+	chomp(my @lines = <F>);
+	close(F);
+	return @lines;
+}
+
+sub collect_specified($) {
+	my $cmd = "find $htmldir/*/kioslave -name $_[0].docbook";
+	open(F, "$cmd |") || die "Can't run $cmd: $!\n";
+	chomp(my @lines = <F>);
+	close F;
+	return grep(!/HTML\/default/, @lines);
+}
+
+sub get_id($) {
+	my @lines = from($_[0]);
+	foreach (@lines) {
+		if (/\<article\s+.*id=\"(.+)\".*\>/i) {
+			return "$1";
+		}
+		last if /\<title\>/i;
+	}
+	return "";
+}
+
+sub usage {
+	die "Usage: kiodoc-update -a|-r kioslaveName";
+}
+
+sub add_doc($) {
+	my @files = collect_specified($_[0]);
+	return if ($#files lt 0);
+	foreach $idx (@files) {
+		my $id = get_id($files[0]);
+		die "Can't read ID attribute\n" if ($id eq "");
+		my $ed = '<!ENTITY kio-' . $id . ' SYSTEM "' .
+			"$_[0].docbook" . '">';
+		my $er = '&kio-' . $id . ';';
+		$idx =~ s/$_[0].docbook/index.docbook/;
+		my @lines = from("$idx");
+		my $state = 0;
+		my @out = ();
+		foreach (@lines) {
+			$state = 3 if (($state == 2) && (/\&kio-/));
+			$state = 1 if (($state == 0) && (/\<\!ENTITY kio-/));
+			if ($state == 1) {
+				if (/% addindex/) {
+					push @out, "$ed\n";
+					$state = 2;
+				}
+				if ($_ gt $ed) {
+					push @out, "$ed\n";
+					$state = 2;
+				}
+			}
+			elsif ($state == 3) {
+				if ($_ gt $er) {
+					push @out, "$er\n";
+					$state = 4;
+				}
+				if (/<\/part\>/i) {
+					push @out, "$er\n";
+					$state = 4;
+				}
+			}
+			next if (/^$er$/);
+			next if (/^$ed$/);
+			push @out, "$_\n";
+		}
+		open(F, ">$idx") || die "Can't open $idx for write: $!\n";
+		print F @out;
+		close(F);
+	}
+}
+
+sub remove_doc($) {
+	my @files = collect_specified($_[0]);
+	return if ($#files lt 0);
+	my $re = "kio-" . get_id($files[0]) . '[\s;]';
+	foreach $idx (@files) {
+		$idx =~ s/$_[0].docbook/index.docbook/;
+		my @lines = from($idx);
+		@lines = grep(!/$re/, @lines);
+		open(F, ">$idx") || die "Can't open $idx for write: $!\n";
+		print F join("\n", @lines) . "\n";
+		close(F);
+	}
+}
+
+my $worker = \&usage;
+
+while (defined ($ARGV[0])) {
+	$_ = shift;
+	if (/^-a$/) {
+		$worker = \&add_doc;
+	}
+	elsif (/^-r$/) {
+		$worker = \&remove_doc;
+	}
+	else {
+		&$worker($_);
+	}
+}
diff --git a/etc/plptools.spec.in b/etc/plptools.spec.in
index b3f8b9d..1ef022a 100644
--- a/etc/plptools.spec.in
+++ b/etc/plptools.spec.in
@@ -164,6 +164,8 @@ make
 mkdir -p $RPM_BUILD_ROOT/%{_prefix} $RPM_BUILD_ROOT%{_initrddir} \
 # rpm's makeinstall doesn't work here!
 make DESTDIR=$RPM_BUILD_ROOT install
+install -m 644 conf/kiodoc-update.pl \
+	$RPM_BUILD_ROOT%{_datadir}/%{name}/kiodoc-update.pl
 %if "%{isSUSE}" > "0"
 %if "%{REL}" >= "8.0"
 mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig
@@ -229,14 +231,29 @@ cp /etc/rc.config /etc/rc.config.old && mv /etc/rc.config.$$ /etc/rc.config
 %endif
 %endif
 
+%if "%{isRH}" > "0"
+%triggerin kde -- kdebase, kde-i18n-German
+perl %{_datadir}/%{name}/kiodoc-update.pl -a psion
+%endif
+
+%if "%{isSUSE}" > "0"
+%if "%{REL}" >= "8.0"
+%triggerin kde -- kdebase3, kde-i18n-de
+perl %{_datadir}/%{name}/kiodoc-update.pl -a psion
+%else
+%triggerin kde -- kdebase, kde-i18n-de
+perl %{_datadir}/%{name}/kiodoc-update.pl -a psion
+%endif
+%endif
+
 %post kde
-%{_initrddir}/psion condrestart
 KONQRC=`kde-config --expandvars --install config`/konquerorrc
-if grep -q '\[Notification Messages\]' $KONQRC ; then
-	cat $KONQRC | grep -v "askSaveinode/x-psion-drive=No" | sed \
+if if test -f $KONQRC && grep -q '\[Notification Messages\]' $KONQRC ; then
+	cp $KONQRC $KONQRC.$$
+	cat $KONQRC.$$ | grep -v "askSaveinode/x-psion-drive=No" | sed \
 		-e '/\[Notification Messages\]/a\' \
-		-e 'askSaveinode/x-psion-drive=No' > /tmp/$$
-	mv /tmp/$$ $KONQRC
+		-e 'askSaveinode/x-psion-drive=No' > $KONQRC && \
+	rm -f $KONQRC.$$
 else
 cat>>$KONQRC<<EOF
 
@@ -245,13 +262,10 @@ askSaveinode/x-psion-drive=No
 EOF
 fi
 
-%preun kde
+%preun
 if [ "$1" = 0 ]
 then
 	%{_initrddir}/psion stop >/dev/null 2>&1
-	KONQRC=`kde-config --expandvars --install config`/konquerorrc
-	grep -v 'askSaveinode/x-psion-drive=' $KONQRC > /tmp/$$
-	mv /tmp/$$ $KONQRC
 %if "%{isSUSE}" > "0"
 %if "%{REL}" >= "8.0"
 	/sbin/chkconfig --del psion
@@ -264,6 +278,18 @@ then
 %endif
 fi
 
+%preun kde
+if [ "$1" = 0 ]
+then
+	perl %{_datadir}/%{name}/kiodoc-update.pl -r psion
+	KONQRC=`kde-config --expandvars --install config`/konquerorrc
+	if test -f $KONQRC ; then
+		cp $KONQRC $KONQRC.$$
+		grep -v 'askSaveinode/x-psion-drive=' $KONQRC.$$ > $KONQRC && \
+		rm -f $KONQRC.$$
+	fi
+fi
+
 %files
 %doc COPYING INSTALL CHANGES ChangeLog README TODO etc/*magic patches
 %{_bindir}/plpftp
@@ -303,6 +329,7 @@ fi
 %{_datadir}/locale/*/LC_MESSAGES/libplpprops.mo
 %{_datadir}/mimelnk/*/*
 %{_datadir}/doc/HTML/*/kioslave/*
+%{_datadir}/%{name}/kiodoc-update.pl
 
 %files -n kpsion
 %{_bindir}/kpsion
diff --git a/kde2/doc/kioslave/de/psion.docbook b/kde2/doc/kioslave/de/psion.docbook
index d777d16..eba9625 100644
--- a/kde2/doc/kioslave/de/psion.docbook
+++ b/kde2/doc/kioslave/de/psion.docbook
@@ -2,7 +2,7 @@
 <title>psion</title>
 
 <para>
-Der psion ioslave macht den Zugriff auf die Laufwerke eine angeschlossenen
+Das psion-Modul macht den Zugriff auf die Laufwerke eines angeschlossenen
 Psion PDAs möglich.
 </para>
 
@@ -14,16 +14,20 @@ oder (falls der Psion an einem anderen Rechner im Netz angeschlossen ist)
 </para>
 
 <para>
-Der psion ioslave stellt die Verbindung zum Psion unter Verwendung des
+Das psion-Modul stellt die Verbindung zum Psion unter Verwendung des
 ncpd Daemonen her. Daher ist es erforderlich, daß dieser Daemon auf dem
-entsprechenden Rechner am Laufen ist. Der psion ioslave, der Daemon sowie
+entsprechenden Rechner am Laufen ist. Das psion-Modul, der Daemon sowie
 weitere Dienstprogramme für Psion-Konnektivität sind Teil des Packetes
 plptoos. Dieses Packet ist auf <ulink url="http://plptools.sourceforge.net/"
 >http://plptools.sourceforge.net/</ulink> erhältlich.
 </para>
 
-<para>
-Autor: Fritz Elfert <email>felfert@users.sourceforge.net</email>
-</para>
+<articleinfo>
+<authorgroup>
+<author><firstname>Fritz</firstname><surname>Elfert</surname>
+<affiliation><address><email>felfert@users.sourceforge.net</email></address></affiliation>
+</author>
+</authorgroup>
+</articleinfo>
 </article>
 
diff --git a/kde2/doc/kioslave/en/psion.docbook b/kde2/doc/kioslave/en/psion.docbook
index 1e93c05..02b36a4 100644
--- a/kde2/doc/kioslave/en/psion.docbook
+++ b/kde2/doc/kioslave/en/psion.docbook
@@ -7,10 +7,12 @@ The psion ioslave enables you to browse the drives of a connected Psion PDA.
 
 <para>
 To see the drives of a Psion, enter
+</para>
 <userinput><command>psion:/</command></userinput>
+<para>
 or (if the Psion is connected at a remote machine)
-<userinput><command>psion://</command><replaceable>host</replaceable></userinput>.
 </para>
+<userinput><command>psion://</command><replaceable>host</replaceable></userinput>.
 
 <para>
 The psion ioslave connects to a Psion using the ncpd daemon. Therefore,
@@ -20,8 +22,11 @@ package. This package is available at <ulink url="http://plptools.sourceforge.ne
 >http://plptools.sourceforge.net/</ulink>.
 </para>
 
-<para>
-Author: Fritz Elfert <email>felfert@users.sourceforge.net</email>
-</para>
+<articleinfo>
+<authorgroup>
+<author><firstname>Fritz</firstname><surname>Elfert</surname>
+<affiliation><address><email>felfert@users.sourceforge.net</email></address></affiliation>
+</author>
+</authorgroup>
+</articleinfo>
 </article>
-
diff --git a/po/de.po b/po/de.po
index 346ceac..98eba59 100644
--- a/po/de.po
+++ b/po/de.po
@@ -5,7 +5,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: plptools 0.11\n"
-"POT-Creation-Date: 2002-07-16 06:23+0200\n"
+"POT-Creation-Date: 2002-07-16 19:30+0200\n"
 "PO-Revision-Date: 2002-07-08 00:06CET\n"
 "Last-Translator: Fritz Elfert <felfert@to.com>\n"
 "Language-Team: Deutsch <de@li.org>\n"
diff --git a/po/sv.po b/po/sv.po
index e09ffde..73adc41 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -6,7 +6,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: plptools 0.11\n"
-"POT-Creation-Date: 2002-07-16 06:23+0200\n"
+"POT-Creation-Date: 2002-07-16 19:30+0200\n"
 "PO-Revision-Date: 2002-07-11 09:10+0200\n"
 "Last-Translator: Daniel Brahneborg <basic@chello.se>\n"
 "Language-Team: SWEDISH <SE@li.org>\n"
-- 
cgit v1.2.3