[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    kdenonbeta/karchiver
From:       Eric Coquelle <eric.coquelle () gmail ! com>
Date:       2006-09-11 22:05:14
Message-ID: 1158012314.983761.7677.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 583278 by coquelle:

Fixed a crash after converting archives. Fixed 7z for Linux compressor's name \
(7za...). Improved the CArchiveOperationSfx to create either KArchiver's "universal" \
Sfx archive, or 7z's sfx module (for Windows only)



 M  +1 -1      Makefile.am  
 M  +6 -5      c7z.cpp  
 M  +105 -6    carchiveoperation.cpp  
 M  +11 -2     carchiveoperation.h  
 M  +2 -2      cchoixfichier.cpp  
 M  +15 -7     cwizardmainpage.cpp  
 M  +1 -0      cwizardmainpage.h  
 M  +19 -6     karchiveur.cpp  


--- trunk/kdenonbeta/karchiver/Makefile.am #583277:583278
@@ -37,7 +37,7 @@
 	czip.cpp ctarbz2.cpp ctargz.cpp carchive.cpp chistorique.cpp karchiveurpart.cpp \
 	caddfilesdata.cpp caddfiles.cpp ktipofday.cpp cfinddata.cpp cfind.cpp \
 	cproprietes.cpp cpreferencesdata.cpp cpreferences.cpp clistview.cpp car.cpp \
                csit.cpp\
-	cwizardstep3data.cpp cwizardstep3.cpp \
+	cwizardstep3data.cpp cwizardstep3.cpp cwizardsfx.cpp \
 	cwizardstep1patch.cpp cwizardinstallation.cpp cwizardcutt.cpp \
 	cwizardconversion.cpp cwizardmainpage.cpp cscript.cpp cutt.cpp \
 	crecherche.cpp cnavigateurdata.cpp cnavigateur.cpp cinfosdata.cpp cinfos.cpp \
--- trunk/kdenonbeta/karchiver/c7z.cpp #583277:583278
@@ -21,6 +21,7 @@
 #include <kstddirs.h>
 #include <kmessagebox.h> 
 #include <qdir.h>
+#include <math.h>
 
 C7z::C7z(){
   CArchive();
@@ -53,7 +54,7 @@
 
   initializeReadingArchive();
   	
-    processread << "7z";
+    processread << "7za";
   	processread << "l" << archiveName;
 
     m_buffer[0]='\0';
@@ -251,7 +252,7 @@
 {
   
   processextract7z.clearArguments();
-  processextract7z << "7z";
+  processextract7z << "7za";
   processextract7z << "e";
 
   processextract7z << "-p";
@@ -332,7 +333,7 @@
 /** delete @param filestodelete from current archive */
 void C7z::removeFilesFromArchive( QStringList filestodelete ){
  	processread.clearArguments();
- 	processread << "7z" << "d";
+ 	processread << "7za" << "d";
  	processread << archiveName;
   for (QStringList::Iterator f = filestodelete.begin(); f!=filestodelete.end(); ++f \
)  {
@@ -353,7 +354,7 @@
 		QDir::setCurrent(relativepath);
 
 	processadd.clearArguments();
-	processadd << "7z";
+	processadd << "7za";
 
     switch(action)
     {
@@ -369,7 +370,7 @@
   if(!archivePassword.isEmpty())
     processadd  << "-p" << archivePassword;
   
-    processadd << QString("-m%1").arg(compressrate);
+  processadd << QString("-mx=%1").arg((int)(round(compressrate/4.5)*4.5));//Valid \
arguments are 0, 5 or 9  processadd << archiveName;
     for (QStringList::Iterator f = filestoadd.begin(); f!=filestoadd.end(); ++f )
     {
--- trunk/kdenonbeta/karchiver/carchiveoperation.cpp #583277:583278
@@ -690,9 +690,10 @@
   KFileOpenWithHandler* owh;
   QDir d(tempdir);
   listoffilestoview=getAllFiles(d);
-  
-  for ( QStringList::Iterator it = listoffilestoview.begin(); it != \
                listoffilestoview.end(); ++it ) {
-  kdDebug()<<QString("Viewing of %1").arg(*it)<<endl;
+  kdDebug()<<QString("Will view %1 files in \
%2").arg(listoffilestoview.count()).arg(tempdir)<<endl; +  for ( \
QStringList::Iterator it = listoffilestoview.begin(); it != listoffilestoview.end(); \
++it ) +  {
+    kdDebug()<<QString("Viewing of %1").arg(*it)<<endl;
     KFileItem fi(0,0,KURL(*it));
     if(fi.isFile())
     {
@@ -875,7 +876,7 @@
 }
 
 /** Extract current archive in tempdirsfx */
-void CArchiveOperationSfx::makeSfxArchive()
+void CArchiveOperationSfx::makeSfxArchive(QString namesfxarchive=QString::null, int \
type=UNIVERSAL_SFX)  {
   if( archiveobj== NULL )
   {
@@ -884,12 +885,16 @@
   }
   
   QString tmp=NULL;
+  newarchivename=namesfxarchive;
   //We will extract the archive to a temp folder, so let's clean it
   eraseTempDir();
 
   progressbar->reset();
   progressbar->setTotalSteps ( archiveobj->countFiles() );
-  connect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotExtractProcessEnded())); +  if(type==UNIVERSAL_SFX)
+    connect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotExtractProcessEnded())); +  else
+    connect(archiveobj, SIGNAL(archiveReadEnded()), this, SLOT(slotMake7zSfx()));
   archiveobj->extractArchive(tempdirsfx,0,tmp);
 }
 
@@ -906,7 +911,8 @@
   
   disconnect(archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slotExtractProcessEnded()));  
-  newarchivename=KFileDialog::getSaveFileName(QDir::homeDirPath(), QString::null, \
0L, i18n("Please give a name to your SelfExtracting archive")); +  \
if(newarchivename.isEmpty()) +    \
newarchivename=KFileDialog::getSaveFileName(QDir::homeDirPath(), QString::null, 0L, \
i18n("Please give a name to your SelfExtracting archive"));  
   sfxmodulepath=KGlobal::dirs()->findResource("data", \
"karchiver/KArchiverSfxModule.jar");  
@@ -944,8 +950,101 @@
   delete sfx_archiveobj;
 }
 
+/** Create the 7z Sfx archive from the files extracted in tempdirsfx */
+void CArchiveOperationSfx::slotMake7zSfx()
+{
+  archiveobj->getAllFiles();
+  QString baserep;
+  QString file;
+  CFileInfo fileinfo;
+  QString sfxmodulepath;
+  QStringList filestoadd;
+  QStringList fileswithpathtoadd;
+  
+  disconnect(archiveobj, SIGNAL(archiveReadEnded()), this, SLOT(slotMake7zSfx()));
 
+  if(newarchivename.isEmpty())
+    newarchivename=KFileDialog::getSaveFileName(QDir::homeDirPath(), QString::null, \
0L, i18n("Please give a name to your SelfExtracting archive")); +  
+  sfxmodulepath=KGlobal::dirs()->findResource("data", \
"karchiver/SevenzSfxModule.sfx"); +  
+  if(newarchivename.isEmpty()||sfxmodulepath.isNull())
+  {
+    emit operationEnded(CANNOT_PERFORM_OPERATION, i18n("Sfx module not found"));
+    return;
+  }
 
+  exearchivename=newarchivename+".exe";
+  newarchivename=tempdir+QFileInfo(newarchivename).baseName()+".7z";
+  
+  //Creates a .7z archive and then append it to the sfx module
+  filestoadd=archiveobj->getAllFiles();
+  for (QStringList::Iterator fp = filestoadd.begin(); fp!=filestoadd.end(); ++fp )
+  {
+    file=*fp;
+    if(file.startsWith("/"))
+      file=file.remove(0,1);
+    fileswithpathtoadd.append(file);
+  }
+
+  sfx_archiveobj=new C7z();
+  connect(sfx_archiveobj, SIGNAL(archiveReadEnded()), this, SLOT(slot7zSfxReady()));
+  sfx_archiveobj->setArchiveName(newarchivename);
+  sfx_archiveobj->addFilesToArchive( fileswithpathtoadd, false, \
ADD_AND_REPLACE_FILES, tempdirsfx); +}
+
+void CArchiveOperationSfx::slot7zSfxReady()
+{
+  disconnect(sfx_archiveobj, SIGNAL(archiveReadEnded()), this, \
SLOT(slot7zSfxReady())); +  
+  KProcess proc;
+  QString sfxmodulepath=KGlobal::dirs()->findResource("data", \
"karchiver/SevenzSfxModule.sfx"); +  
+  proc << "cp" << "--force" << sfxmodulepath << exearchivename;
+  proc.start(KProcess::Block);
+  
+  cat();
+  
+  proc.clearArguments();
+  proc << "rm" << "-f" << newarchivename;
+  proc.start(KProcess::Block);
+  
+  emit operationEnded(SFX_ARCHIVE_CREATED, i18n("Your Sfx \
archive")+"\n"+exearchivename+"\n"+i18n("is ready")); +  delete sfx_archiveobj;
+}
+
+/** Catenates an archive to its sfx module */
+void CArchiveOperationSfx::cat()
+{
+  int j;
+  int MaxL;
+  
+  QFile filesfx(exearchivename);
+  filesfx.open(IO_WriteOnly | IO_Append);
+  
+  QFile filearchive(newarchivename);
+  filearchive.open(IO_ReadOnly);
+
+  const int size=filearchive.size();
+  const int sizebuffer=100000;
+  char  data[sizebuffer];
+  const int fullsizeblock = size / sizebuffer;
+  const int partialblock = size % sizebuffer;
+
+  for (j = 1; j <= fullsizeblock; j++)
+  {
+    filearchive.readBlock(data, sizebuffer);
+    filesfx.writeBlock(data, sizebuffer);
+  }
+  filearchive.readBlock(data, partialblock);
+  filesfx.writeBlock(data, partialblock);
+  
+  filearchive.close();
+  filesfx.close();
+}
+
+
+
 //////////////////////////////////////////////////////////////////////////////////////
  /**The CArchiveOperationTest class
   * extracts the content of current archive to @param temp_dir
--- trunk/kdenonbeta/karchiver/carchiveoperation.h #583277:583278
@@ -56,7 +56,7 @@
   virtual void displayArchiveContent(){};
   virtual void extractCurrentArchive(){};
   virtual void extractMultiFiles( QStringList , bool , QCString , bool  ){};
-  virtual void makeSfxArchive(){};
+  virtual void makeSfxArchive(QString=QString::null, int=0){};
   virtual void displayFile(QListViewItem* ){};
   virtual void displaySelectedFiles(){};
   virtual void createNewArchive(){};
@@ -259,17 +259,26 @@
   public:
     CArchiveOperationSfx(CArchive* archive_obj, QProgressBar* progress_bar, QString \
temp_dir );  /** Extract current archive in tempdirsfx */
-    void makeSfxArchive();
+    void makeSfxArchive(QString, int);
 
+  protected:
+    /** Catenates an archive to its sfx module */
+    void cat();
+    
   protected slots:
     /** Create the Sfx archive from the files extracted in tempdirsfx */
     virtual void slotExtractProcessEnded();
     virtual void slotFilesAdded();
+    virtual void slotMake7zSfx();
+    virtual void slot7zSfxReady();
     
   private:
     CArchive* sfx_archiveobj;
   protected:
     QString tempdirsfx;
+    QString exearchivename;
+  public:
+    enum possiblesfxtypes {UNIVERSAL_SFX=0, SEVENZ_SFX};
 };
 
 
--- trunk/kdenonbeta/karchiver/cchoixfichier.cpp #583277:583278
@@ -160,7 +160,7 @@
       }
     else if(archive.right(3)==".7z")
     {
-        nameofCompressor="7z";
+        nameofCompressor="7za";
         reader="l";
         uncompressor="e";
         kindofCompressor=SEVENZ;
@@ -218,7 +218,7 @@
     installedcompressors=installedcompressors|ZIP;
   if(KStandardDirs::findExe("unarj")!=NULL)
     installedcompressors=installedcompressors|ARJ;
-  if(KStandardDirs::findExe("7z")!=NULL)
+  if(KStandardDirs::findExe("7za")!=NULL)
     installedcompressors=installedcompressors|SEVENZ;
   if(KStandardDirs::findExe("ar")!=NULL)
     installedcompressors=installedcompressors|AR;
--- trunk/kdenonbeta/karchiver/cwizardmainpage.cpp #583277:583278
@@ -87,18 +87,26 @@
   radiosplit->setText(i18n("Split this archive"));
   vbox->addWidget(radiosplit);
 
+  radiosfx= new QRadioButton(QButtonGroup_1,"radioSfx");
+  radiosfx->setText(i18n("Create a Sfx archive"));
+  vbox->addWidget(radiosfx);
+
 }
 
 /** get wether it's a patch or an install wizard */
 int CWizardMainPage::getTypeOperation()
 {
-	if(radiopatch->isChecked())
-		return 0;
-	else if(radioinstall->isChecked())
-		return 1;
-	else if(radioconvert->isChecked())
-		return 2;
-	return -1;
+  if(radiopatch->isChecked())
+          return 0;
+  else if(radioinstall->isChecked())
+          return 1;
+  else if(radioconvert->isChecked())
+          return 2;
+  else if(radiosplit->isChecked())
+    return 3;
+  else if(radiosfx->isChecked())
+    return 4;
+  return -1;
 }
 
 #include "cwizardmainpage.moc"
--- trunk/kdenonbeta/karchiver/cwizardmainpage.h #583277:583278
@@ -53,6 +53,7 @@
   QRadioButton *radioinstall;
   QRadioButton *radioconvert;
   QRadioButton *radiosplit;
+  QRadioButton *radiosfx;
   QButtonGroup* bgroupe;	
 };
 
--- trunk/kdenonbeta/karchiver/karchiveur.cpp #583277:583278
@@ -1618,8 +1618,8 @@
 /** a process in CArchive has ended. So make
 the necessary with the operation variable */
 void KarchiveurApp::slotEndProcess(){
-	int kindofCompressor=archivechoice->getKindOfCompressor();
- kdDebug()<<QString("KarchiveurApp::slotEndProcess: operation= \
%1").arg(operation)<<endl; +  int \
kindofCompressor=archivechoice->getKindOfCompressor(); +  \
kdDebug()<<QString("KarchiveurApp::slotEndProcess: operation= \
%1").arg(operation)<<endl;  
 	if(operation==SCRIPT)
 	{
@@ -1677,7 +1677,7 @@
 
 		typescript=objetscript.startWizard(namefichselect,repbase,archivechoice->getArchiveName());
                
                 kdDebug()<<QString("EndingWizard: typescript= \
                %1").arg(typescript)<<endl;
-                if(typescript==2)
+                if(typescript==CScript::WIZ_CONVERSION)
 		{
 			//User has chosen to convert the archive
     archiveoperation=new CArchiveOperationConversion(tmpdir, archiveobj, progress);
@@ -1689,12 +1689,23 @@
 //    archiveoperation->convertCurrentArchive(newarchivename);
 
 		}
-		else if(typescript==3)
+  else if(typescript==CScript::WIZ_UNCUTT)
 		{
 			//User has chosen to split/unsplit archive
 			if(objetscript.getDirectoryCutt()!=NULL)
 				doCuttUnCutt(objetscript.getDirectoryCutt(),objetscript.getCuttSize());
 		}
+  else if(typescript==CScript::WIZ_SFX)
+  {
+    //User has chosen to create a Sfx archive
+    led->setColor(QColor("red"));
+    slotStatusMsg(i18n("Make a Self-extract archive..."));
+
+    archiveoperation=new CArchiveOperationSfx(archiveobj, progress, tmpdir);
+    connect(archiveoperation, SIGNAL(operationEnded(int, QString)), this, \
SLOT(slotMessageArchiveOperation(int , QString ))); +    operation = MAKESFX;
+    archiveoperation->makeSfxArchive(objetscript.getSfxArchiveName(), \
objetscript.getSfxArchiveType()); +  }
 		led->setColor(QColor("green"));
 	}
   
@@ -2039,8 +2050,10 @@
         process->start(KProcess::Block);
       }
       led->setColor(QColor("green"));
+      
       archivechoice->setArchiveName(archiveoperation->getArchiveName());
-      displayArchiveContent();
+      
+      //displayArchiveContent();
       break;
     }
     case DISPLAY_ACHIEVED:
@@ -2157,7 +2170,7 @@
     enableMenus(false);
   }
   
-  if((message==ARCHIVE_CREATION_ACHIEVED)||(message==ADD_FILES_ACHIEVED)||(message==ADD_FILES_ANOTHER_ARCHIVE_ACHIEVED))
 +  if((message==ARCHIVE_CREATION_ACHIEVED)||(message==ADD_FILES_ACHIEVED)||(message==ADD_FILES_ANOTHER_ARCHIVE_ACHIEVED)||(message==CONVERSION_ACHIEVED))
  {
     displayArchiveContent();
   }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic