File kdebase-kioslave-rar.patch of Package kdebase3

diff -Naru kdebase-3.5.10_orig/kioslave/Makefile.am kdebase-3.5.10/kioslave/Makefile.am
--- kdebase-3.5.10_orig/kioslave/Makefile.am	2005-09-10 08:25:38.000000000 +0000
+++ kdebase-3.5.10/kioslave/Makefile.am	2020-05-22 03:59:08.524801750 +0000
@@ -6,6 +6,6 @@
 SMB_SUBDIR=smb
 endif
 
-SUBDIRS = about cgi floppy filter fish info mac man nfs nntp pop3 smtp \
+SUBDIRS = about cgi floppy filter fish info mac man nfs nntp pop3 rar smtp \
   sftp tar finger thumbnail $(LDAP_SUBDIR) $(SMB_SUBDIR) settings trash media \
   remote home system
diff -Naru kdebase-3.5.10_orig/kioslave/rar/AUTHORS kdebase-3.5.10/kioslave/rar/AUTHORS
--- kdebase-3.5.10_orig/kioslave/rar/AUTHORS	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/AUTHORS	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1 @@
+Raul Fernandes <rgfbr@yahoo.com.br>
\ ファイル末尾に改行がありません
diff -Naru kdebase-3.5.10_orig/kioslave/rar/COPYING kdebase-3.5.10/kioslave/rar/COPYING
--- kdebase-3.5.10_orig/kioslave/rar/COPYING	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/COPYING	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff -Naru kdebase-3.5.10_orig/kioslave/rar/ChangeLog kdebase-3.5.10/kioslave/rar/ChangeLog
--- kdebase-3.5.10_orig/kioslave/rar/ChangeLog	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/ChangeLog	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,24 @@
+0.6
+Add a class to handle RAR archives
+Speedups
+
+0.5
+Fix several bugs
+Implement error messages
+Implement translations
+Implement put, rename and delete functions
+
+0.4
+Speedups
+
+0.3
+Support to rar program
+When you click UP in the root directory of RAR archive, the kioslave redirects to file:/ kioslave
+Initial support to copy function
+Several bugs fixed
+
+0.2
+Now, kio_rar handles directories correctly
+
+0.1
+Initial release.
\ ファイル末尾に改行がありません
diff -Naru kdebase-3.5.10_orig/kioslave/rar/Makefile.am kdebase-3.5.10/kioslave/rar/Makefile.am
--- kdebase-3.5.10_orig/kioslave/rar/Makefile.am	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/Makefile.am	2020-05-22 07:27:05.146543622 +0000
@@ -0,0 +1,23 @@
+## Makefile.am of kdebase/kioslave/rar
+
+INCLUDES = $(all_includes)
+AM_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+METASOURCES = AUTO
+
+kde_module_LTLIBRARIES = kio_rar.la kfile_rar.la
+
+kio_rar_la_SOURCES = krar.cpp kio_rar.cpp
+kio_rar_la_LIBADD = $(LIB_KSYCOCA)
+kio_rar_la_LDFLAGS = $(all_libraries) -module $(KDE_PLUGIN)
+
+kfile_rar_la_SOURCES = krar.cpp kfile_rar.cpp
+kfile_rar_la_LIBADD = $(LIB_KSYCOCA)
+kfile_rar_la_LDFLAGS = $(all_libraries) -module $(KDE_PLGUIN)
+
+noinst_HEADERS = krar.h
+
+kdelnk_DATA = rar.protocol
+kdelnkdir = $(kde_servicesdir)
+
+messages:
+	$(XGETTEXT) *.cc -o $(podir)/kio_rar.pot
diff -Naru kdebase-3.5.10_orig/kioslave/rar/README kdebase-3.5.10/kioslave/rar/README
--- kdebase-3.5.10_orig/kioslave/rar/README	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/README	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,2 @@
+A kioslave for RAR archives.
+This is a very basic kioslave that supports RAR archives. Only listing, reading and deleting files actions is currently support. It depends on unrar or rar to handle the archives.
diff -Naru kdebase-3.5.10_orig/kioslave/rar/kfile_rar.cpp kdebase-3.5.10/kioslave/rar/kfile_rar.cpp
--- kdebase-3.5.10_orig/kioslave/rar/kfile_rar.cpp	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/kfile_rar.cpp	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,85 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2006 by Raul Fernandes                             *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <config.h>
+#include "kfile_rar.h"
+#include "krar.h"
+
+#include <kgenericfactory.h>
+#include <kio/global.h>
+
+typedef KGenericFactory<KRarPlugin> KRarFactory;
+
+K_EXPORT_COMPONENT_FACTORY(kfile_rar, KRarFactory( "kfile_rar" ))
+
+KRarPlugin::KRarPlugin(QObject *parent, const char *name, const QStringList &args)
+           : KFilePlugin(parent, name, args)
+{
+    KFileMimeTypeInfo* info = addMimeTypeInfo( "application/x-rar-compressed" );
+
+    KFileMimeTypeInfo::GroupInfo* group = 0L;
+
+    group = addGroupInfo(info, "RarInfo", i18n("Rar Information"));
+
+    KFileMimeTypeInfo::ItemInfo* item;
+
+    item = addItemInfo(group, "Directories", i18n("Directories"), QVariant::UInt);
+    item = addItemInfo(group, "Files", i18n("Files"), QVariant::UInt);
+    item = addItemInfo(group, "Unpacked", i18n("Unpacked"), QVariant::ULongLong);
+    setUnit(item, KFileMimeTypeInfo::Bytes);
+    item = addItemInfo(group, "Packed", i18n("Packed"), QVariant::ULongLong);
+    setUnit(item, KFileMimeTypeInfo::Bytes);
+    item = addItemInfo(group, "Ratio", i18n("Ratio"), QVariant::String);
+    item = addItemInfo(group, "ArchiveVolume", i18n("Archive Volume"), QVariant::String);
+    item = addItemInfo(group, "Lock", i18n("Lock"), QVariant::String);
+    item = addItemInfo(group, "Solid", i18n("Solid"), QVariant::String);
+    item = addItemInfo(group, "Auth Info", i18n("Auth Info"), QVariant::String);
+}
+
+bool KRarPlugin::readInfo( KFileMetaInfo& info, uint /*what*/)
+{
+    KFileMetaInfoGroup group = appendGroup(info, "RarInfo");
+
+    if( info.url().protocol() != "file" ) return false;
+
+    KRar rar( info.path() );
+    if( !rar.open( IO_ReadOnly ) )
+    {
+      rar.close();
+      return false;
+    }
+
+    appendItem( group, "Directories", rar.dirs() );
+    appendItem( group, "Files", rar.files() );
+    appendItem( group, "Unpacked", rar.uncompressed() );
+    appendItem( group, "Packed", rar.compressed() );
+    appendItem( group, "Ratio", QString( "%1 %" ).arg( rar.ratio() ) );
+    if( rar.isArchiveVolume() ) appendItem( group, "ArchiveVolume", rar.volNum() );
+    else appendItem( group, "ArchiveVolume", i18n( "None" ) );
+    appendItem( group, "Lock", ( rar.isLocked() ? i18n( "Yes" ) : i18n( "No" ) ) );
+    appendItem( group, "Solid", ( rar.isSolid() ? i18n( "Yes" ) : i18n( "No" ) ) );
+    appendItem( group, "Auth Info", ( rar.hasAuthInfo() ? i18n( "Yes" ) : i18n( "No" ) ) );
+
+    rar.close();
+
+    return true;
+}
+
+#include "kfile_rar.moc"
diff -Naru kdebase-3.5.10_orig/kioslave/rar/kfile_rar.desktop kdebase-3.5.10/kioslave/rar/kfile_rar.desktop
--- kdebase-3.5.10_orig/kioslave/rar/kfile_rar.desktop	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/kfile_rar.desktop	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Encoding=UTF-8
+Type=Service
+Name=Rar Info
+Name[bg]=Информация за Rar
+Name[br]=Titouroù Rar
+Name[da]=RAR-info
+Name[es]=Información de Rar
+Name[ga]=Eolas faoi Rar
+Name[pt]=Informação do Rar
+Name[sv]=RAR-info
+Name[xx]=xxRar Infoxx
+ServiceTypes=KFilePlugin
+X-KDE-Library=kfile_rar
+MimeType=application/x-rar
+PreferredGroups=RarInfo
+PreferredItems=Solid,Lock,Auth Info,Directories,Files,Unpacked,Ratio
diff -Naru kdebase-3.5.10_orig/kioslave/rar/kfile_rar.h kdebase-3.5.10/kioslave/rar/kfile_rar.h
--- kdebase-3.5.10_orig/kioslave/rar/kfile_rar.h	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/kfile_rar.h	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,38 @@
+/***************************************************************************
+ *   Copyright (C) 2005-2006 by Raul Fernandes                             *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef __KFILE_RAR_H__
+#define __KFILE_RAR_H__
+
+#include <kfilemetainfo.h>
+
+class QStringList;
+
+class KRarPlugin: public KFilePlugin
+{
+    Q_OBJECT
+
+public:
+    KRarPlugin( QObject *parent, const char *name, const QStringList& args );
+
+    virtual bool readInfo( KFileMetaInfo& info, uint what);
+};
+
+#endif
diff -Naru kdebase-3.5.10_orig/kioslave/rar/kio_rar.cpp kdebase-3.5.10/kioslave/rar/kio_rar.cpp
--- kdebase-3.5.10_orig/kioslave/rar/kio_rar.cpp	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/kio_rar.cpp	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,499 @@
+/***************************************************************************
+ *   Copyright (C) 2004-2006 by Raul Fernandes                             *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include <qcstring.h>
+#include <qstringlist.h>
+#include <qbitarray.h>
+#include <qfile.h>
+
+#include <kdebug.h>
+#include <kinstance.h>
+#include <klocale.h>
+#include <kurl.h>
+#include <kprocio.h>
+#include <kprocess.h>
+#include <kglobal.h>
+#include <kstandarddirs.h>
+
+#include <sys/stat.h>
+#include <stdlib.h>
+#include "kio_rar.h"
+#include "kio_rar.moc"
+#include "krar.h"
+
+using namespace KIO;
+
+extern "C"
+{
+    int kdemain(int argc, char **argv)
+    {
+        KInstance instance( "kio_rar" );
+
+        kdDebug(7101) << "*** Starting kio_rar " << endl;
+
+        if (argc != 4) {
+            kdDebug(7101) << "Usage: kio_rar  protocol domain-socket1 domain-socket2" << endl;
+            exit(-1);
+        }
+
+        kio_rarProtocol slave(argv[2], argv[3]);
+        slave.dispatchLoop();
+
+        kdDebug(7101) << "*** kio_rar Done" << endl;
+        return 0;
+    }
+} 
+
+
+kio_rarProtocol::kio_rarProtocol(const QCString &pool_socket, const QCString &app_socket)
+    : SlaveBase("kio_rar", pool_socket, app_socket)
+{
+    kdDebug(7101) << "kio_rarProtocol::kio_rarProtocol()" << endl;
+    rarProgram = KGlobal::dirs()->findExe( "rar" );
+    if( rarProgram.isNull() )// Check if rar binary is available
+    {
+      rarProgram = KGlobal::dirs()->findExe( "unrar" );
+      if( rarProgram.isNull() )
+      {
+        error( KIO::ERR_SLAVE_DEFINED, i18n( "Neither rar nor unrar was not found in PATH. You should install one of them to work with this kioslave" ) );
+      }
+    }
+    m_archiveTime = 0L;
+    m_archiveFile = 0L;
+}
+
+
+kio_rarProtocol::~kio_rarProtocol()
+{
+    kdDebug(7101) << "kio_rarProtocol::~kio_rarProtocol()" << endl;
+}
+
+
+void kio_rarProtocol::get(const KURL& url )
+{
+    kdDebug(7101) << "kio_rar::get(const KURL& url)" << endl ;
+
+    KURL fileUrl;
+    int errorNum;
+
+    errorNum = checkFile( url, fileUrl );
+    if( errorNum == 1 )
+    {
+      // cannot open archive
+      return;
+    }
+
+    if( errorNum == 2 )
+    {
+      // it is not a RAR archive
+      // send the path to konqueror to redirect to file: kioslave
+      redirection( url.path() );
+      finished();
+      return;
+    }
+
+    if( !m_archiveFile->directory()->entry( fileUrl.path() ) )
+    {
+      error( KIO::ERR_DOES_NOT_EXIST, fileUrl.path() );
+      return;
+    }
+
+    procShell = new KShellProcess();
+    processed = 0;
+    connect( procShell, SIGNAL( receivedStdout( KProcess*, char*, int ) ), this, SLOT( receivedData( KProcess*, char*, int ) ) );
+
+    procShell->setEnvironment( "LC_ALL", KGlobal::locale()->language() );
+    //-ierr -idp
+    *procShell << rarProgram << "p -inul -c- -y" << "\"" + m_archiveFile->fileName() + "\"" << "\"" + fileUrl.path().remove( 0, 1 ) + "\"";
+
+    infoMessage( i18n( "Unpacking file..." ) );
+
+    procShell->start( KProcess::Block, KProcess::Stdout );
+
+    if( procShell->normalExit() )
+    {
+      //WARNING Non fatal error(s) occurred
+      if( procShell->exitStatus() == 1 ) warning( i18n( "Non fatal error(s) occurred" ) );
+      //FATAL ERROR A fatal error occurred
+      if( procShell->exitStatus() == 2 ) error( KIO::ERR_SLAVE_DIED, url.url() );
+      //CRC ERROR A CRC error occurred when unpacking
+      if( procShell->exitStatus() == 3 ) error( KIO::ERR_SLAVE_DEFINED, i18n( "CRC failed for file %1" ).arg( url.url() ) );
+      //WRITE ERROR Write to disk error
+      //for this error we should use ERR_COULD_NOT_WRITE or ERR_DISK_FULL ?
+      if( procShell->exitStatus() == 5 ) error( KIO::ERR_DISK_FULL, url.url() );
+      //OPEN ERROR Open file error
+      if( procShell->exitStatus() == 6 ) error( KIO::ERR_CANNOT_OPEN_FOR_READING, url.url() );
+      //MEMORY ERROR Not enough memory for operation
+      if( procShell->exitStatus() == 8 ) error( KIO::ERR_OUT_OF_MEMORY, url.url() );
+    }
+
+    data( QByteArray() );
+    finished();
+
+    delete procShell;
+    procShell = 0;
+}
+
+
+/*!
+    \fn kio_rarProtocol::listDir( const KURL & url )
+ */
+void kio_rarProtocol::listDir( const KURL & url )
+{
+    kdDebug(7101) << "kio_rar::listDir(const KURL& url)" << endl ;
+    KURL fileUrl;
+    int errorNum;
+
+    errorNum = checkFile( url, fileUrl );
+    if( errorNum == 1 )
+    {
+      // cannot open archive
+      return;
+    }
+
+    if( errorNum == 2 )
+    {
+      // it is not a RAR archive
+      // send the path to konqueror to redirect to file: kioslave
+      redirection( url.path() );
+      finished();
+      return;
+    }
+
+    infoMessage( i18n( "Listing directory..." ) );
+
+    const KArchiveDirectory *directory;
+    if( fileUrl.path().isEmpty() ) directory = m_archiveFile->directory();
+    else directory = ((const KArchiveDirectory*)(m_archiveFile->directory()->entry( fileUrl.path() )));
+    QStringList list = directory->entries();
+
+    UDSEntry entry;
+    UDSAtom atom;
+    const KArchiveEntry *archiveEntry;
+
+    if( list.count() !=  0 )
+    for(QStringList::Iterator it = list.begin(); it != list.end(); ++it)
+    {
+      archiveEntry = directory->entry(*it );
+      entry.clear();
+
+      atom.m_uds = KIO::UDS_NAME;
+      atom.m_str = archiveEntry->name();
+      entry.append(atom);
+
+      atom.m_uds = KIO::UDS_FILE_TYPE;
+      if( archiveEntry->isDirectory() ) atom.m_long = S_IFDIR;
+      else atom.m_long = S_IFREG;
+      entry.append(atom);
+
+      atom.m_uds = KIO::UDS_ACCESS;
+      atom.m_long = archiveEntry->permissions();
+      entry.append( atom );
+
+      atom.m_uds = UDS_SIZE;
+      atom.m_long = archiveEntry->isDirectory() ? 0L : ((KArchiveFile *)archiveEntry)->size() ;
+      entry.append( atom );
+
+      atom.m_uds = KIO::UDS_MODIFICATION_TIME;
+      atom.m_long = archiveEntry->datetime().toTime_t();
+      entry.append(atom);
+
+      listEntry( entry, false);
+    }
+
+    listEntry( entry, true);
+    finished();
+}
+
+
+
+/*!
+    \fn kio_rarProtocol::stat( const KURL & url )
+ */
+void kio_rarProtocol::stat( const KURL & url )
+{
+    kdDebug(7101) << "kio_rar::stat(const KURL& url)" << endl ;
+    KURL fileUrl;
+    int errorNum;
+
+    errorNum = checkFile( url, fileUrl );
+    if( errorNum == 1 )
+    {
+      // cannot open archive
+      return;
+    }
+
+    if( errorNum == 2 )
+    {
+      // it is not a RAR archive
+      // send the path to konqueror to redirect to file: kioslave
+      redirection( url.path() );
+      finished();
+      return;
+    }
+
+    UDSEntry entry;
+    UDSAtom atom;
+
+    // check if it is root directory
+    if( fileUrl.path( -1 ) == "/" )
+    {
+      atom.m_uds = KIO::UDS_NAME;
+      atom.m_str = "/";
+      entry.append(atom);
+      atom.m_uds = KIO::UDS_FILE_TYPE;
+      atom.m_long = S_IFDIR;
+      entry.append(atom);
+      statEntry(entry);
+      finished();
+      return;
+    }
+
+    const KArchiveEntry *archiveEntry = m_archiveFile->directory()->entry( fileUrl.path() );
+
+    if( !archiveEntry )
+    {
+      error( KIO::ERR_DOES_NOT_EXIST, fileUrl.path() );
+      return;
+    }
+
+    entry.clear();
+
+    atom.m_uds = KIO::UDS_NAME;
+    atom.m_str = archiveEntry->name();
+    entry.append(atom);
+
+    atom.m_uds = KIO::UDS_FILE_TYPE;
+    if( archiveEntry->isDirectory() ) atom.m_long = S_IFDIR;
+    else atom.m_long = S_IFREG;
+    entry.append(atom);
+
+    atom.m_uds = KIO::UDS_ACCESS;
+    atom.m_long = archiveEntry->permissions();
+    entry.append( atom );
+
+    atom.m_uds = UDS_SIZE;
+    atom.m_long = archiveEntry->isDirectory() ? 0L : ((KArchiveFile *)archiveEntry)->size() ;
+    entry.append( atom );
+
+    atom.m_uds = KIO::UDS_MODIFICATION_TIME;
+    atom.m_long = archiveEntry->datetime().toTime_t();
+    entry.append(atom);
+
+    statEntry( entry );
+    finished();
+}
+
+
+/*!
+    \fn kio_rarProtocol::checkFile( const KURL &url, KURL &fileUrl )
+ */
+int kio_rarProtocol::checkFile( const KURL &url, KURL &fileUrl )
+{
+    kdDebug(7101) << "kio_rar::checkFile(const KURL& url, KURL &fileUrl)" << endl ;
+    QString archiveUrl;
+    struct stat statbuf;
+
+    if( m_archiveFile && url.path().startsWith( m_archiveFile->fileName() ) )
+    {
+      fileUrl = url.path().section( m_archiveFile->fileName(), 1 );
+      // Has it changed ?
+      if ( ::stat( QFile::encodeName( m_archiveFile->fileName() ), &statbuf ) == 0 )
+      {
+        if ( m_archiveTime == statbuf.st_mtime )
+          return 0;
+      }
+      archiveUrl = m_archiveFile->fileName();
+    }else{
+      if( url.path().find( ".rar", false ) == -1 ) return 2;
+      archiveUrl = url.path().section( ".rar", 0, 0 ) + ".rar";
+      if( url.path().endsWith( ".rar" ) ) fileUrl = "/";
+      else fileUrl = url.path().section( ".rar", 1 );
+    }
+
+    if( m_archiveFile )
+    {
+      m_archiveFile->close();
+      delete m_archiveFile;
+    }
+    m_archiveFile = new KRar( archiveUrl );
+    if( !m_archiveFile->open( IO_ReadOnly ) )
+    {
+      error( ERR_CANNOT_OPEN_FOR_READING, archiveUrl );
+      return 1;
+    }
+    ::stat( QFile::encodeName( m_archiveFile->fileName() ), &statbuf );
+    m_archiveTime = statbuf.st_mtime;
+    return 0;
+}
+
+
+/*!
+    \fn kio_rarProtocol::receivedData( KProcess *, char* buffer, int len )
+ */
+void kio_rarProtocol::receivedData( KProcess *, char* buffer, int len )
+{
+  QByteArray d(len);
+  d.setRawData(buffer,len);
+  data(d);
+  d.resetRawData(buffer,len);
+  processed += len;
+  processedSize( processed );
+}
+
+
+/*!
+    \fn kio_rarProtocol::del( const KURL &url, bool isFile )
+ */
+void kio_rarProtocol::del( const KURL &url, bool /*isFile*/ )
+{
+    kdDebug(7101) << "kio_rar::del(const KURL &url, bool isFile)" << endl ;
+    KURL fileUrl;
+    int errorNum;
+
+    errorNum = checkFile( url, fileUrl );
+    if( errorNum == 1 )
+    {
+      // cannot open archive
+      return;
+    }
+
+    if( errorNum == 2 )
+    {
+      // it is not a RAR archive
+      // send the path to konqueror to redirect to file: kioslave
+      redirection( url.path() );
+      finished();
+      return;
+    }
+
+    if( !rarProgram.endsWith( "/rar" ) )
+    {
+      error( ERR_UNSUPPORTED_ACTION, i18n( "You need to have the rar binary in $PATH to use this action" ) );
+      return;
+    }
+
+    infoMessage( i18n( "Deleting file..." ) );
+
+    procShell = new KShellProcess();
+    procShell->setEnvironment( "LC_ALL", KGlobal::locale()->language() );
+    *procShell << rarProgram << "d" << "\"" + m_archiveFile->fileName() + "\"" << "\"" + fileUrl.path( -1 ).remove( 0, 1 ) + "\"";
+    procShell->start( KProcess::Block, KProcess::AllOutput );
+    if( !procShell->normalExit() ) error( KIO::ERR_CANNOT_LAUNCH_PROCESS, url.path() );
+
+    finished();
+}
+
+
+/*!
+    \fn kio_rarProtocol::put( const KURL &url, int permissions, bool overwrite, bool resume )
+ */
+//void kio_rarProtocol::put( const KURL &/*url*/, int /*permissions*/, bool /*overwrite*/, bool /*resume*/ )
+/*{
+    kdDebug(7101) << "kio_rar::put(const KURL &url, int permissions, bool overwrite, bool resume)" << endl ;
+    KURL fileUrl;
+    if( !checkName( url, fileUrl ) )
+    {
+      // it is not a rar archive
+      // return the error that cannot enter the directory
+      error(ERR_CANNOT_ENTER_DIRECTORY,url.path());
+      return;
+    }
+    if( !rarProgram.endsWith( "/rar" ) )
+    {
+      error( ERR_UNSUPPORTED_ACTION, i18n( "You need to have the rar binary in $PATH to use this action" ) );
+      return;
+    }
+
+    //TODO: check if the archive exits, if not, create a new rar archive
+    // QFile.exits();
+
+    infoMessage( i18n( "Adding file..." ) );
+
+    // receive the data
+    QByteArray buffer;
+    int length;
+    QFile file( "/tmp/" + fileUrl.fileName() );
+    file.open( IO_WriteOnly );
+    do
+    {
+      dataReq();
+      length = readData( buffer );
+      file.writeBlock( buffer );
+    }while( length > 0 );
+    file.close();
+
+    procShell = new KShellProcess();
+    procShell->setEnvironment( "LC_ALL", KGlobal::locale()->language() );
+    //New -st[name] switch to compress data from stdin (standard input).
+    *procShell << rarProgram << "a -inul -ep -ap" + fileUrl.directory().remove( 0, 1 ) << "\"" + m_archiveFile.fileName() + "\"" << "\"" + file.name() + "\"";
+    procShell->start( KProcess::Block, KProcess::NoCommunication );
+    //if( !proc->normalExit() ) error( KIO::ERR_CANNOT_LAUNCH_PROCESS, url.path() );
+
+    //delete the temporary file
+    file.remove();
+
+    delete procShell;
+    procShell = 0;
+
+    finished();
+}*/
+
+
+/*!
+    \fn kio_rarProtocol::rename( const KURL &src, const KURL &dest, bool overwrite )
+ */
+//void kio_rarProtocol::rename( const KURL &/*src*/, const KURL &/*dest*/, bool /*overwrite*/ )
+/*{
+    kdDebug(7101) << "kio_rar::rename(const KURL &src, const KURL &dest, bool overwrite)" << endl ;
+    KURL fileUrl;
+    if( !checkFile( src, fileUrl ) )
+    {
+      // it is not a rar archive
+      // return the error that cannot enter the directory
+      error( ERR_CANNOT_ENTER_DIRECTORY, src.path() );
+      return;
+    }
+
+    KURL destArchive;
+    KURL destUrl;
+    checkName( dest, destArchive, destUrl );
+    if( archiveUrl != destArchive )
+    {
+      // we can not rename files in diferent archives
+      error( ERR_CANNOT_ENTER_DIRECTORY, src.path() );
+      return;
+    }
+    if( !rarProgram.endsWith( "/rar" ) )
+    {
+      error( ERR_UNSUPPORTED_ACTION, i18n( "You need to have the rar binary in $PATH to use this action" ) );
+      return;
+    }
+
+    infoMessage( i18n( "Renaming file..." ) );
+
+    procShell = new KShellProcess();
+    procShell->setEnvironment( "LC_ALL", KGlobal::locale()->language() );
+    *procShell << rarProgram << "rn" << "\"" + m_archiveFile.fileName() + "\"" << "\"" + fileUrl.path( -1 ).remove( 0, 1 ) + "\"" << "\"" + destUrl.path( -1 ).remove( 0, 1 ) + "\"";
+    procShell->start( KProcess::Block );
+    //if( !proc->normalExit() ) error( KIO::ERR_CANNOT_LAUNCH_PROCESS, url.path() );
+
+    finished();
+}*/
diff -Naru kdebase-3.5.10_orig/kioslave/rar/kio_rar.h kdebase-3.5.10/kioslave/rar/kio_rar.h
--- kdebase-3.5.10_orig/kioslave/rar/kio_rar.h	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/kio_rar.h	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,59 @@
+/***************************************************************************
+ *   Copyright (C) 2004-2006 by Raul Fernandes                             *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef _kio_rar_H_
+#define _kio_rar_H_
+
+#include <kio/global.h>
+#include <kio/slavebase.h>
+
+class KShellProcess;
+class KProcess;
+class KProcIO;
+class KURL;
+class QCString;
+class KRar;
+
+class kio_rarProtocol : public QObject, public KIO::SlaveBase
+{
+Q_OBJECT
+public:
+    kio_rarProtocol(const QCString &pool_socket, const QCString &app_socket);
+    virtual ~kio_rarProtocol();
+    //virtual void mimetype(const KURL& url);
+    virtual void get(const KURL& url);
+    virtual void listDir( const KURL & url );
+    virtual void stat( const KURL & url );
+    virtual void del( const KURL &url, bool isFile );
+//    virtual void put( const KURL &url, int permissions, bool overwrite, bool resume );
+//    virtual void rename( const KURL &src, const KURL &dest, bool _overwrite );
+private:
+    QString rarProgram;
+    KIO::filesize_t processed;
+    KProcIO *proc;
+    KShellProcess *procShell;
+    time_t m_archiveTime;
+    KRar *m_archiveFile;
+    int checkFile( const KURL &url, KURL &fileUrl );
+public slots:
+    void receivedData( KProcess *, char* buffer, int len );
+};
+
+#endif /* _kio_rar_H_ */
diff -Naru kdebase-3.5.10_orig/kioslave/rar/krar.cpp kdebase-3.5.10/kioslave/rar/krar.cpp
--- kdebase-3.5.10_orig/kioslave/rar/krar.cpp	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/krar.cpp	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,335 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Raul Fernandes                                  *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#include "krar.h"
+
+#include <qfile.h>
+#include <qdir.h>
+#include <qdatetime.h>
+#include <qtextcodec.h>
+
+#include <kdebug.h>
+
+KRar::KRar( const QString &filename )
+  : KArchive( 0L )
+{
+  m_filename = filename;
+  m_dirs = 0;
+  m_files = 0;
+  m_uncompressed = 0;
+  m_compressed = 0;
+  m_ratio = 0;
+  m_volattr = false;
+  volnum = -1;
+  m_lock = false;
+  m_solid = false;
+  m_authenticity = false;
+}
+
+
+KRar::~KRar()
+{
+}
+
+
+/*!
+    \fn KRar::openArchive( int mode )
+ */
+bool KRar::openArchive( int mode )
+{
+  kdDebug() << "KRar::openArchive()" << endl;
+  switch( mode )
+  {
+    case IO_WriteOnly:
+    case IO_ReadWrite:
+      // Mode not supported
+      return false;
+    case IO_ReadOnly:
+      if ( !m_filename.isEmpty() )
+      {
+        setDevice( new QFile( m_filename ) );
+        if ( !device()->open( mode ) ) return false;
+      }
+      break;
+    default:
+      return false;
+  }
+  QIODevice* dev = device();
+  if( !dev ) return false;
+
+  // Marker block
+  // A valid RAR archive should have a marker block
+  char marker_block[8];
+  int a;
+  a = dev->readBlock( marker_block, 7 );
+  if( a < 7 ) return false;
+  if( memcmp( marker_block, "\x52\x61\x72\x21\x1a\x07\x00", 7 )) return false;
+
+  char header[8];
+  char fileHeader[25];
+  Q_UINT16 fileNameSize;
+  KArchiveFile *file;
+  Q_UINT32 pos;
+
+  // Archive block
+  // The second block should be a archive block
+  a = dev->readBlock( header, 7 );
+  if( header[2] != '\x73' ) return false;
+  m_volattr = header[3] & '\x01';
+  m_lock = header[3] & '\x04';
+  m_solid = header[3] & '\x08';
+  m_authenticity = header[3] & '\x20';
+  Q_UINT16 size = (uchar)header[5] | (uchar)header[6] << 8;
+  Q_UINT32 fileSize;
+  int second;
+  int minute;
+  int hour;
+  int day;
+  int month;
+  int year;
+  QDateTime *time;
+  QString filename;
+  a = dev->at(size+7);
+  mode_t mode;
+
+  // Other blocks
+  do
+  {
+    pos = dev->at();
+    fileNameSize = 0;
+    fileSize = 0;
+    size = 0;
+    a = dev->readBlock( header, 7 );
+    // TODO: read blocks other than file
+    if( header[2] == '\x74' ) // File header
+    {
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      a = dev->readBlock( fileHeader, 25 );
+      fileNameSize = fileHeader[19] | fileHeader[20] << 8;
+
+      char fileName[fileNameSize + 1];
+      a = dev->readBlock( fileName, fileNameSize );
+      fileName[fileNameSize] = '\0';
+      filename = fileName;
+      filename.replace( "\\", "/" );
+
+      // Date and time
+      second = (uchar)fileHeader[13] & '\x1f';
+      minute = ((uchar)fileHeader[13] & '\xe0') >> 5 | ((uchar)fileHeader[14] & '\x03') << 3;
+      hour = ((uchar)fileHeader[14] & '\xfc') >> 3;
+      day = (uchar)fileHeader[15] & '\x1f';
+      month = ((uchar)fileHeader[15] & '\xe0') >> 5 | ((uchar)fileHeader[16] & '\x01') << 3;
+      year = ((uchar)fileHeader[16] & '\xfe') >> 1;
+      time = new QDateTime( QDate( (1980 + year), month, day), QTime( hour, minute, second ) );
+
+      // Uncompressed file size
+      fileSize = (uchar)fileHeader[4] | (uchar)fileHeader[5] << 8 | (uchar)fileHeader[6] << 16 | (uchar)fileHeader[7] << 24;
+
+        // fileHeader[8] - Operating system used for archiving
+        // 0 - MS DOS
+        // 1 - OS/2
+        // 2 - Win32
+        // 3 - Unix
+/*
+            In Windows version is also possible to use symbols D, S, H,
+            A and R instead of a digital mask to denote directories
+            and files with system, hidden, archive and read-only attributes.
+            The order in which the attributes are given is not significant.
+            Unix version supports D and V symbols to define directory
+            and device attributes.
+            Bits
+                  A  D     (HS)
+            0  0  1  1  0  1  1 0
+*/
+/*         Unix attributes
+                     22                       21
+            1  1  0  0  0  0  0  1  1  1  1  1  1  1  1  1
+            A  D  L              r  w  x  r  w  x  r  w  x
+*/
+        mode = 0;
+        if( fileHeader[8] == '\x03' )
+        {
+          // Unix attributes
+          // owner permissions
+          if(fileHeader[22] & 1) mode |= S_IRUSR;
+          if(fileHeader[21] & 128) mode |= S_IWUSR;
+          if(fileHeader[21] & 64) mode |= S_IXUSR;
+          // group permissions
+          if(fileHeader[21] & 32) mode |= S_IRGRP;
+          if(fileHeader[21] & 16) mode |= S_IWGRP;
+          if(fileHeader[21] & 8) mode |= S_IXGRP;
+          // other permissions
+          if(fileHeader[21] & 4) mode |= S_IROTH;
+          if(fileHeader[21] & 2) mode |= S_IWOTH;
+          if(fileHeader[21] & 1) mode |= S_IXOTH;
+        }else{
+          // Convert the filename from codec used by windows port of RAR
+          QTextCodec *codec = QTextCodec::codecForName("IBM 850");
+          filename = codec->toUnicode( filename.ascii() );
+          // TODO: set the permissions to attributes for windows files
+          mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
+        }
+        if( (fileHeader[8] == '\x03' && fileHeader[22] & '\x40') || (fileHeader[8] != '\x03' && fileHeader[21] & '\x10') )
+        {
+          m_dirs++;
+          mode |= S_IFDIR;
+          // TODO: set the permissions to directories
+          if( !rootDir()->entry( filename ) )
+            findOrCreate( filename );
+        }
+        else{
+          m_files++;
+          m_uncompressed += fileSize;
+          // TODO: set the permissions to links
+          //if(fileHeader[22] & 32)
+          //{
+            // link
+            //mode |= S_IFLNK;
+            //file = new KArchiveFile( this, filename.right( filename.length() - filename.findRev( '/' ) - 1 ), mode, time->toTime_t(), rootDir()->user(), rootDir()->group(), QString::null, dev->at(), fileSize );
+          //}else{
+            mode |= S_IFREG;
+            file = new KArchiveFile( this, filename.right( filename.length() - filename.findRev( '/' ) - 1 ), mode, time->toTime_t(), rootDir()->user(), rootDir()->group(), QString::null, dev->at(), fileSize );
+          //}
+
+          // Test to see if the file is in root directory
+          if( filename.find( '/' ) == -1 ) rootDir()->addEntry( file );
+          else
+          {
+            // In some tar files we can find dir/./file => call cleanDirPath
+            QString path = QDir::cleanDirPath( filename.left( filename.findRev( '/' ) ) );
+
+            // Ensure container directory exists, create otherwise
+            KArchiveDirectory * tdir = findOrCreate( path );
+            tdir->addEntry(file);
+          }
+        }
+
+      // Compressed file size
+      fileSize = (uchar)fileHeader[0] | (uchar)fileHeader[1] << 8 | (uchar)fileHeader[2] << 16 | (uchar)fileHeader[3] << 24;
+      dev->at( pos + size + fileSize );
+      m_compressed += fileSize;
+    }else if( header[2] == '\x75' ) // Comment header
+    {
+      kdDebug() << "Comment header" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      if( header[3] & 0x8000)
+      {
+        a = dev->readBlock( header, 4 );
+        fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      }else fileSize = 0;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x76' ) // Extra information
+    {
+      kdDebug() << "Extra information" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      if( header[3] & 0x8000)
+      {
+        a = dev->readBlock( header, 4 );
+        fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      }else fileSize = 0;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x77' ) // Subblock
+    {
+      kdDebug() << "Subblock" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      a = dev->readBlock( header, 4 );
+      fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x78' ) // Recovery record
+    {
+      kdDebug() << "Recovery record" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      a = dev->readBlock( header, 4 );
+      fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x79' )
+    {
+      kdDebug() << "SIGN_HEAD" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      if( header[3] & 0x8000)
+      {
+        a = dev->readBlock( header, 4 );
+        fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      }else fileSize = 0;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x7a' )
+    {
+      kdDebug() << "NEWSUB_HEAD" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      a = dev->readBlock( header, 4 );
+      fileSize = (uchar)header[0] | (uchar)header[1] << 8 | (uchar)header[2] << 16 | (uchar)header[3] << 24;
+      dev->at( pos + size + fileSize );
+    }else if( header[2] == '\x7b' )
+    {
+      kdDebug() << "ENDARC_HEAD" << endl;
+      size = (uchar)header[5] | (uchar)header[6] << 8;
+      if( m_volattr )
+      {
+        a = dev->readBlock( header, 6 );
+        volnum = (uchar)header[4] | (uchar)header[5] << 8; // volume number
+      }
+      dev->at( pos + size );
+    }else if( header[2] != '\x7b' )
+    {
+      kdDebug() << "No known header" << endl;
+      return false;
+    }
+  }while( !dev->atEnd() );
+
+  m_ratio = ( m_compressed * 100 / m_uncompressed );
+  return true;
+}
+
+
+/*!
+    \fn KRar::closeArchive()
+ */
+bool KRar::closeArchive()
+{
+  device()->close();
+  return true;
+}
+
+
+/*!
+    \fn KRar::doneWriting( uint size )
+ */
+bool KRar::doneWriting( uint /*size*/ )
+{
+  return false;
+}
+
+
+/*!
+    \fn KRar::writeDir( const QString& name, const QString& user, const QString& group )
+ */
+bool KRar::writeDir( const QString& /*name*/, const QString& /*user*/, const QString& /*group*/ )
+{
+  return false;
+}
+
+
+/*!
+    \fn KRar::prepareWriting( const QString& name, const QString& user, const QString& group, uint size )
+ */
+bool KRar::prepareWriting( const QString& /*name*/, const QString& /*user*/, const QString& /*group*/, uint /*size*/ )
+{
+  return false;
+}
diff -Naru kdebase-3.5.10_orig/kioslave/rar/krar.h kdebase-3.5.10/kioslave/rar/krar.h
--- kdebase-3.5.10_orig/kioslave/rar/krar.h	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/krar.h	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,72 @@
+/***************************************************************************
+ *   Copyright (C) 2006 by Raul Fernandes                                  *
+ *   rgfbr@yahoo.com.br                                                    *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
+#ifndef KRAR_H
+#define KRAR_H
+
+#include <karchive.h>
+
+/**
+@author Raul Fernandes
+*/
+class KIO_EXPORT KRar : public KArchive
+{
+public:
+    KRar( const QString &filename );
+
+    ~KRar();
+
+    QString fileName() { return m_filename; }
+    bool doneWriting( uint size );
+    bool writeDir( const QString& name, const QString& user, const QString& group );
+    bool prepareWriting( const QString& name, const QString& user, const QString& group, uint size );
+    uint dirs() { return m_dirs; }
+    uint files() { return m_files; }
+    unsigned long long uncompressed() { return m_uncompressed; }
+    unsigned long long compressed() { return m_compressed; }
+    uint ratio() { return m_ratio; }
+    bool isArchiveVolume() { return m_volattr; };
+    int volNum() {
+      if( m_volattr ) return volnum;
+      else return -1;
+    }
+    bool isLocked() { return m_lock; };
+    bool isSolid() { return m_solid; };
+    bool hasAuthInfo() { return m_authenticity; };
+
+protected:
+    bool openArchive( int mode );
+    bool closeArchive();
+    uint m_dirs;
+    uint m_files;
+    unsigned long long m_uncompressed;
+    unsigned long long m_compressed;
+    uint m_ratio;
+    bool m_volattr;
+    int volnum;
+    bool m_lock;
+    bool m_solid;
+    bool m_authenticity;
+
+private:
+  QString m_filename;
+};
+
+#endif
diff -Naru kdebase-3.5.10_orig/kioslave/rar/rar.protocol kdebase-3.5.10/kioslave/rar/rar.protocol
--- kdebase-3.5.10_orig/kioslave/rar/rar.protocol	1970-01-01 00:00:00.000000000 +0000
+++ kdebase-3.5.10/kioslave/rar/rar.protocol	2020-05-22 03:57:32.269670732 +0000
@@ -0,0 +1,21 @@
+[Protocol]
+exec=kio_rar
+protocol=rar
+mimetype=application/x-rar
+input=none
+output=filesystem
+listing=Name,Size,Type,Date,Access,
+reading=true
+deleting=true
+Icon=tgz
+Description=A kioslave for RAR archives
+Description[bg]=kioslave за RAR архиви
+Description[br]=Ur c'hioslave evit an dielloù RAR
+Description[da]=En kioslave for RAR-arkiver
+Description[es]=Un kioslave para archivos RAR
+Description[ga]=kioslave le haghaidh cartlanna RAR
+Description[it]=Un kioslave per archivi RAR
+Description[pt]=Um 'kioslave' para pacotes RAR
+Description[sv]=En I/O-slav för RAR-arkiv
+Description[xx]=xxA kioslave for RAR archivesxx
+Class=:local