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

List:       kde-commits
Subject:    branches/KDE/3.5/kdelibs/kio
From:       David Faure <faure () kde ! org>
Date:       2007-01-25 11:50:02
Message-ID: 1169725802.311390.22422.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 627004 by dfaure:

Forward mimetype signal from the get job to the FileCopyJob, to help kpdf with #140482.
 (and any other kpart that wants to know what it's opening exactly)
CCMAIL: Albert Astals Cid <aacid@kde.org>


 M  +9 -2      kio/job.cpp  
 M  +14 -1     kio/jobclasses.h  
 M  +18 -3     tests/jobtest.cpp  
 M  +2 -0      tests/jobtest.h  


--- branches/KDE/3.5/kdelibs/kio/kio/job.cpp #627003:627004
@@ -1808,8 +1808,10 @@
             connectSubjob( m_getJob ); // Progress info depends on get
             m_getJob->resume(); // Order a beer
 
-            connect( m_getJob, SIGNAL(data(KIO::Job *, const QByteArray&)),
-                     SLOT( slotData(KIO::Job *, const QByteArray&)));
+            connect( m_getJob, SIGNAL(data(KIO::Job*,const QByteArray&)),
+                     SLOT( slotData(KIO::Job*,const QByteArray&)) );
+            connect( m_getJob, SIGNAL(mimetype(KIO::Job*,const QString&) ),
+                     SLOT(slotMimetype(KIO::Job*,const QString&)) );
         }
         else // copyjob
         {
@@ -1870,6 +1872,11 @@
    m_buffer = QByteArray();
 }
 
+void FileCopyJob::slotMimetype( KIO::Job*, const QString& type )
+{
+    emit mimetype( this, type );
+}
+
 void FileCopyJob::slotResult( KIO::Job *job)
 {
    //kdDebug(7007) << "FileCopyJob this=" << this << " ::slotResult(" << job << ")" << endl;
--- branches/KDE/3.5/kdelibs/kio/kio/jobclasses.h #627003:627004
@@ -227,7 +227,7 @@
 	 * @see setWindow()
          */
         QWidget *window() const;
-        
+
         /**
          * Updates the last user action timestamp to the given time.
          * See KApplication::updateUserTimestamp() .
@@ -1300,10 +1300,23 @@
 	 */
         KURL destURL() const { return m_dest; }
 
+    signals:
+        /**
+         * Mimetype determined during a file copy.
+         * This is never emitted during a move, and might not be emitted during
+         * a copy, depending on the slave.
+         * @param job the job that emitted this signal
+         * @param type the mime type
+         *
+         * @since 3.5.7
+         */
+        void mimetype( KIO::Job *job, const QString &type );
+
     public slots:
         void slotStart();
         void slotData( KIO::Job *, const QByteArray &data);
         void slotDataReq( KIO::Job *, QByteArray &data);
+        void slotMimetype( KIO::Job *, const QString& type );
 
     protected slots:
         /**
--- branches/KDE/3.5/kdelibs/kio/tests/jobtest.cpp #627003:627004
@@ -473,8 +473,8 @@
 void JobTest::moveDirectoryNoPermissions()
 {
     kdDebug() << k_funcinfo << endl;
-    const QString src = "/etc/rc.d";
-    const QString dest = homeTmpDir() + "rc.d";
+    const QString src = "/etc/init.d";
+    const QString dest = homeTmpDir() + "init.d";
     assert( QFile::exists( src ) );
     assert( QFileInfo( src ).isDir() );
     KURL u;
@@ -564,7 +564,10 @@
     kdDebug() << "copying " << u << " to " << d << endl;
 
     // copy the file with file_copy
-    bool ok = KIO::NetAccess::file_copy( u, d );
+    KIO::FileCopyJob* job = KIO::file_copy( u, d );
+    connect( job, SIGNAL(mimetype(KIO::Job*,const QString&)),
+             this, SLOT(slotMimetype(KIO::Job*,const QString&)) );
+    bool ok = KIO::NetAccess::synchronousRun( job, 0 );
     assert( ok );
 
     QString dest = realSystemPath() + "fileFromHome_copied";
@@ -578,6 +581,12 @@
         // unless we use setModificationTime in the app code.
     }
 
+    // Check mimetype
+    kdDebug() << m_mimetype << endl;
+    // There's no mimemagic determination in kio_file in kde3. Fixing this for kde4...
+    assert( m_mimetype == "application/octet-stream" );
+    //assert( m_mimetype == "text/plain" );
+
     // cleanup and retry with KIO::copy()
     QFile::remove( dest );
     ok = KIO::NetAccess::dircopy( u, d, 0 );
@@ -595,4 +604,10 @@
     kio_resolve_local_urls = true;
 }
 
+void JobTest::slotMimetype(KIO::Job* job, const QString& type)
+{
+    assert( job );
+    m_mimetype = type;
+}
+
 #include "jobtest.moc"
--- branches/KDE/3.5/kdelibs/kio/tests/jobtest.h #627003:627004
@@ -56,6 +56,7 @@
 private slots:
     void slotEntries( KIO::Job*, const KIO::UDSEntryList& lst );
     void slotGetResult( KIO::Job* );
+    void slotMimetype(KIO::Job*,const QString&);
 
 private:
     QString homeTmpDir() const;
@@ -72,6 +73,7 @@
     int m_result;
     QByteArray m_data;
     QStringList m_names;
+    QString m_mimetype;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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