File kdeutils-3.5.8-alt-ark-arj-format.patch of Package kdeutils3

diff -u'Nrpk~' kdeutils-3.5.8~/ark/arch.cpp kdeutils-3.5.8/ark/arch.cpp
--- kdeutils-3.5.8~/ark/arch.cpp	2007-11-08 13:32:30 +0300
+++ kdeutils-3.5.8/ark/arch.cpp	2007-11-02 15:07:36 +0300
@@ -60,6 +60,7 @@
 #include "ar.h"
 #include "sevenzip.h"
 #include "ace.h"
+#include "arj.h"
 
 Arch::ArchColumns::ArchColumns( int col, QRegExp reg, int length, bool opt )
   : colRef( col ), pattern( reg ), maxLength( length ), optional( opt )
@@ -401,6 +402,9 @@ Arch *Arch::archFactory( ArchType aType,
     case ACE_FORMAT:
       return new AceArch( parent, filename );
 
+    case ARJ_FORMAT:
+      return new ArjArch( parent, filename );
+
     case UNKNOWN_FORMAT:
     default:
       return 0;
diff -u'Nrpk~' kdeutils-3.5.8~/ark/arch.h kdeutils-3.5.8/ark/arch.h
--- kdeutils-3.5.8~/ark/arch.h	2007-11-08 13:32:30 +0300
+++ kdeutils-3.5.8/ark/arch.h	2007-11-02 14:47:03 +0300
@@ -65,7 +65,7 @@ class ArkWidget;
 
 enum ArchType { UNKNOWN_FORMAT, ZIP_FORMAT, TAR_FORMAT, AA_FORMAT,
                 LHA_FORMAT, RAR_FORMAT, ZOO_FORMAT, COMPRESSED_FORMAT,
-                SEVENZIP_FORMAT, ACE_FORMAT };
+                SEVENZIP_FORMAT, ACE_FORMAT, ARJ_FORMAT };
 
 typedef QValueList< QPair< QString, Qt::AlignmentFlags > > ColumnList;
 
diff -u'Nrpk~' kdeutils-3.5.8~/ark/archiveformatinfo.cpp kdeutils-3.5.8/ark/archiveformatinfo.cpp
--- kdeutils-3.5.8~/ark/archiveformatinfo.cpp	2006-01-19 19:49:29 +0300
+++ kdeutils-3.5.8/ark/archiveformatinfo.cpp	2007-11-02 14:51:57 +0300
@@ -79,6 +79,8 @@ void ArchiveFormatInfo::buildFormatInfos
 
   addFormatInfo( SEVENZIP_FORMAT, "application/x-7z", ".7z" );
 
+  addFormatInfo( ARJ_FORMAT, "application/x-arj", ".arj" );
+
   if ( ArkSettings::aceSupport() )
     addFormatInfo( ACE_FORMAT, "application/x-ace", ".ace" );
 }
diff -u'Nrpk~' kdeutils-3.5.8~/ark/arj.cpp kdeutils-3.5.8/ark/arj.cpp
--- kdeutils-3.5.8~/ark/arj.cpp	1970-01-01 03:00:00 +0300
+++ kdeutils-3.5.8/ark/arj.cpp	2007-11-14 17:46:07 +0300
@@ -0,0 +1,298 @@
+/*
+
+ ark -- archiver for the KDE project
+
+ Copyright (C)
+
+ 1997-1999: Rob Palmbos palm9744@kettering.edu
+ 1999: Francois-Xavier Duranceau duranceau@kde.org
+ 1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com)
+ 2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com)
+ 2007: ALT Linux (author: Sergey V Turchin, zerg@altlinux.org)
+
+ 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+
+// Qt includes
+#include <qdir.h>
+#include <qtextcodec.h>
+
+// KDE includes
+#include <kdebug.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+#include <kprocess.h>
+#include <kpassdlg.h>
+
+// ark includes
+#include "arj.h"
+#include "arkwidget.h"
+#include "settings.h"
+
+
+ArjArch::ArjArch( ArkWidget *_gui, const QString & _fileName )
+  : Arch(  _gui, _fileName )
+{
+  m_archiver_program = "arj";
+  m_unarchiver_program = "arj";
+  verifyCompressUtilityIsAvailable( m_archiver_program );
+  verifyUncompressUtilityIsAvailable( m_unarchiver_program );
+
+  m_headerString = "-----------";
+  m_numCols = 6;
+}
+
+void ArjArch::setHeaders()
+{
+  ColumnList list;
+  list.append( FILENAME_COLUMN );
+  list.append( SIZE_COLUMN );
+  list.append( PACKED_COLUMN );
+  list.append( RATIO_COLUMN );
+  list.append( TIMESTAMP_COLUMN );
+  list.append( PERMISSION_COLUMN );
+
+  emit headers( list );
+}
+
+void ArjArch::create()
+{
+  emit sigCreate( this, true, m_filename,
+                  Arch::Extract | Arch::Delete | Arch::Add | Arch::View );
+}
+
+void ArjArch::createPassword()
+{
+  if( m_password.isEmpty() && ArkSettings::askCreatePassword() )
+    KPasswordDialog::getNewPassword( m_password, i18n("Warning!\nUsing KGpg for encryption is more secure.\nCancel this dialog or enter password for %1 archiver:").arg(m_archiver_program) );
+}
+
+
+void ArjArch::addDir( const QString & _dirName )
+{
+  if ( !_dirName.isEmpty() )
+  {
+    QStringList list;
+    list.append( _dirName );
+    addFile( list );
+  }
+}
+
+void ArjArch::addFile( const QStringList & urls )
+{
+  KProcess *kp = m_currentProcess = new KProcess;
+
+  kp->clearArguments();
+  *kp << m_archiver_program;
+  *kp << "a";
+
+  if ( ArkSettings::replaceOnlyWithNewer() )
+    *kp << "-u";
+
+  if ( ArkSettings::rarRecurseSubdirs() )
+    *kp << "-r";
+
+  if ( !m_password.isEmpty() )
+    *kp << "-g"+m_password;
+
+  *kp << m_filename;
+
+  KURL dir( urls.first() );
+  QDir::setCurrent( dir.directory() );
+
+  QStringList::ConstIterator iter;
+  for ( iter = urls.begin(); iter != urls.end(); ++iter )
+  {
+    KURL url( *iter );
+    *kp << url.fileName();
+  }
+
+  connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( processExited(KProcess*) ),
+           SLOT( slotAddExited(KProcess*) ) );
+
+  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
+  {
+    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
+    emit sigAdd( false );
+  }
+}
+
+bool ArjArch::processLine( const QCString &line )
+{
+  QString unicode_line;
+
+  QTextCodec *codec = QTextCodec::codecForLocale();
+  QTextCodec *codec_alt = QTextCodec::codecForName("CP1251");
+  unicode_line = codec->toUnicode( line );
+
+  QStringList list;
+
+  QStringList l2 = QStringList::split( ' ', line );
+  if( l2.size() >= 2 && l2[0].endsWith(")") && l2[0].length() == 4 )
+  {
+    file_entry = line.mid(4);
+  }
+  else if( l2.size() > 3 )
+  {
+    if( l2[1] == "UNIX" )
+	list << codec->toUnicode(file_entry).stripWhiteSpace(); // filename
+    else
+	list << codec_alt->toUnicode(file_entry).stripWhiteSpace(); // filename
+
+    list << l2[ 2 ]; // size
+    list << l2[ 3 ]; // packed
+    double ratio = l2[4].toDouble();
+    if( ratio == 0 )
+	ratio = 1;
+    list << QString("%1").arg(100-100/ratio); // ratio
+
+    QStringList date =  QStringList::split( '-', l2[ 5 ] );
+    list << ArkUtils::fixYear( date[ 0 ].latin1() ) + '-' + date[ 1 ] + '-' + date [ 2 ] + ' ' + l2[6]; // date
+    list << l2[ 7 ]; // attributes
+
+    m_gui->fileList()->addItem( list ); // send to GUI
+    
+    file_entry = "";
+  }
+
+  return true;
+}
+
+
+void ArjArch::open()
+{
+  setHeaders();
+
+  m_buffer = "";
+  m_header_removed = false;
+  m_finished = false;
+
+  KProcess *kp = m_currentProcess = new KProcess;
+
+  *kp << m_unarchiver_program << "v" << m_filename;
+
+  connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
+           SLOT( slotReceivedTOC(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( processExited(KProcess*) ),
+           SLOT( slotOpenExited(KProcess*) ) );
+
+  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
+  {
+    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
+    emit sigOpen( this, false, QString::null, 0 );
+  }
+}
+
+void ArjArch::unarchFileInternal()
+{
+  // if fileList is empty, all files are extracted.
+  // if destDir is empty, abort with error.
+  if ( m_destDir.isEmpty() || m_destDir.isNull() )
+  {
+    kdError( 1601 ) << "There was no extract directory given." << endl;
+    return;
+  }
+
+  KProcess *kp = m_currentProcess = new KProcess;
+  kp->clearArguments();
+
+  *kp << m_unarchiver_program;
+  *kp << "x";
+
+  if ( !m_password.isEmpty() )
+    *kp << "-g" + m_password;
+
+  if ( ArkSettings::extractOverwrite() )
+    *kp << "-jyo";
+
+  *kp << "-jycv";
+
+  *kp << "-w" + m_destDir;
+  *kp << "-ht" + m_destDir;
+
+  QTextCodec *codec = QTextCodec::codecForLocale();
+  *kp << codec->fromUnicode(m_filename);
+
+  // if the list is empty, no filenames go on the command line,
+  // and we then extract everything in the archive.
+  if ( m_fileList )
+  {
+    QStringList::Iterator it;
+
+    for ( it = m_fileList->begin(); it != m_fileList->end(); ++it )
+    {
+      *kp << codec->fromUnicode(*it);
+    }
+  }
+
+  connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( processExited(KProcess*) ),
+           SLOT( slotExtractExited(KProcess*) ) );
+
+  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
+  {
+    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
+    emit sigExtract( false );
+  }
+}
+
+bool ArjArch::passwordRequired()
+{
+    return m_lastShellOutput.findRev("File is password encrypted") != -1;
+}
+
+void ArjArch::remove( QStringList *list )
+{
+  if ( !list )
+    return;
+
+  KProcess *kp = m_currentProcess = new KProcess;
+  kp->clearArguments();
+
+  *kp << m_archiver_program << "d" << m_filename;
+
+  QStringList::Iterator it;
+  for ( it = list->begin(); it != list->end(); ++it )
+  {
+    QString str = *it;
+    *kp << str;
+  }
+
+  connect( kp, SIGNAL( receivedStdout(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( receivedStderr(KProcess*, char*, int) ),
+           SLOT( slotReceivedOutput(KProcess*, char*, int) ) );
+  connect( kp, SIGNAL( processExited(KProcess*) ),
+           SLOT( slotDeleteExited(KProcess*) ) );
+
+  if ( !kp->start( KProcess::NotifyOnExit, KProcess::AllOutput ) )
+  {
+    KMessageBox::error( 0, i18n( "Could not start a subprocess." ) );
+    emit sigDelete( false );
+  }
+}
+
+#include "arj.moc"
diff -u'Nrpk~' kdeutils-3.5.8~/ark/arj.h kdeutils-3.5.8/ark/arj.h
--- kdeutils-3.5.8~/ark/arj.h	1970-01-01 03:00:00 +0300
+++ kdeutils-3.5.8/ark/arj.h	2007-11-14 17:26:46 +0300
@@ -0,0 +1,63 @@
+/*
+
+  ark -- archiver for the KDE project
+
+  Copyright (C)
+
+  1997-1999: Rob Palmbos palm9744@kettering.edu
+  1999: Francois-Xavier Duranceau duranceau@kde.org
+  1999-2000: Corel Corporation (author: Emily Ezust, emilye@corel.com)
+  2001: Corel Corporation (author: Michael Jarrett, michaelj@corel.com)
+  2007: ALT Linux (author: Sergey V Turchin, zerg@altlinux.org)
+
+  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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+*/
+
+#ifndef ARJARCH_H
+#define ARJARCH_H
+
+#include "arch.h"
+
+class QString;
+class QStringList;
+
+class ArkWidget;
+
+class ArjArch : public Arch
+{
+  Q_OBJECT
+  public:
+    ArjArch( ArkWidget *_gui, const QString & _fileName );
+    virtual ~ArjArch() { }
+
+    virtual void open();
+    virtual void create();
+    virtual void remove(QStringList*);
+    virtual void addFile(const QStringList&);
+    virtual void addDir(const QString&);
+
+    virtual void unarchFileInternal();
+    virtual bool passwordRequired();
+    virtual void createPassword();
+
+  protected slots:
+    virtual bool processLine( const QCString & );
+  private:
+    QCString file_entry;
+    void setHeaders();
+};
+
+#endif /* ARJARCH_H */
diff -u'Nrpk~' kdeutils-3.5.8~/ark/Makefile.am kdeutils-3.5.8/ark/Makefile.am
--- kdeutils-3.5.8~/ark/Makefile.am	2006-01-19 19:49:29 +0300
+++ kdeutils-3.5.8/ark/Makefile.am	2007-11-02 14:42:28 +0300
@@ -31,7 +31,7 @@ libarkpart_la_SOURCES = ark_part.cpp ark
                         arkwidget.cpp searchbar.cpp \
                         addition.ui extraction.ui general.ui \
                         arkviewer.cpp sevenzip.cpp extractiondialog.cpp \
-                        ace.cpp tarlistingthread.cpp
+                        ace.cpp tarlistingthread.cpp arj.cpp
 
 METASOURCES = AUTO
 
openSUSE Build Service is sponsored by