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

List:       kde-commits
Subject:    KDE/kdenetwork/kfile-plugins
From:       Urs Wolfer <uwolfer () kde ! org>
Date:       2007-01-19 13:59:31
Message-ID: 1169215171.962048.8978.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 625209 by uwolfer:

readd torrent file plugin
* make it compile
* less use us Q3 classes and QT3_SUPPORT
* less warnings

 M  +1 -3      CMakeLists.txt  
 M  +9 -10     torrent/bdict.cpp  
 M  +0 -1      torrent/bdict.h  
 M  +7 -8      torrent/bint.cpp  
 M  +0 -1      torrent/bint.h  
 M  +4 -4      torrent/blist.cpp  
 M  +5 -5      torrent/blist.h  
 M  +7 -7      torrent/bstring.cpp  
 M  +0 -1      torrent/bstring.h  
 M  +3 -3      torrent/bytetape.cpp  
 M  +5 -7      torrent/bytetape.h  
 M  +2 -3      torrent/kfile_torrent.cpp  
 M  +1 -1      torrent/kfile_torrent.h  


--- trunk/KDE/kdenetwork/kfile-plugins/CMakeLists.txt #625208:625209
@@ -1,3 +1 @@
-MESSAGE(STATUS "Readd torrent")
-#add_subdirectory( torrent ) 
-
+add_subdirectory(torrent)
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bdict.cpp #625208:625209
@@ -18,8 +18,7 @@
  */
 #include <qstringlist.h>
 #include <qiodevice.h>
-//Added by qt3to4:
-#include <Q3CString>
+#include <QByteArray>
 
 #include <kdebug.h>
 
@@ -163,13 +162,13 @@
     const char *e_str = "e";
     Q_LONG written = 0, result = 0;
 
-    written = device.writeBlock (d_str, 1);
+    written = device.write (d_str, 1);
     while (written < 1)
     {
         if (written < 0 || result < 0)
             return false;
 
-        result = device.writeBlock (d_str, 1);
+        result = device.write (d_str, 1);
         written += result;
     }
 
@@ -189,16 +188,16 @@
     QStringList::Iterator key_iter;
     for (key_iter = key_list.begin(); key_iter != key_list.end(); ++key_iter)
     {
-        Q3CString utfString = (*key_iter).toUtf8();
+        QByteArray utfString = (*key_iter).toUtf8();
         QString str = QString("%1:").arg(utfString.size() - 1);
 
-        Q3CString lenString = str.toUtf8();
+        QByteArray lenString = str.toUtf8();
 
         // Write out length of key
-        device.writeBlock(lenString.data(), lenString.size() - 1);
+        device.write(lenString.data(), lenString.size() - 1);
 
         // Write out actual key
-        device.writeBlock(utfString.data(), utfString.size() - 1);
+        device.write(utfString.data(), utfString.size() - 1);
 
         // Write out the key's data
         BBase *base = m_map.find(*key_iter);
@@ -206,13 +205,13 @@
             return false;
     }
 
-    written = device.writeBlock (e_str, 1);
+    written = device.write (e_str, 1);
     while ((uint) written < 1)
     {
         if (written < 0 || result < 0)
             return false;
 
-        result = device.writeBlock (e_str, 1);
+        result = device.write (e_str, 1);
         written += result;
     }
 
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bdict.h #625208:625209
@@ -20,7 +20,6 @@
 #define _BDICT_H
 
 #include <q3dict.h>
-#include <q3cstring.h> // QByteArray
 #include "bytetape.h"
 #include "bbase.h"
 
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bint.cpp #625208:625209
@@ -17,7 +17,6 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 #include <qstring.h>
-#include <q3cstring.h>
 #include <qiodevice.h>
 
 #include "bytetape.h"
@@ -46,19 +45,19 @@
     tape ++; // Move to start of digits
 
     QByteArray &dict (tape.data());
-    if (dict.find('e', tape.pos()) == -1)
+    if (dict.indexOf('e', tape.pos()) == -1)
         return;
 
     // Copy the part from the start to the e.  The values in-between
     // should be digits, perhaps preceded by a negative sign.
-    int length = dict.find('e', tape.pos()) - tape.pos();
+    int length = dict.indexOf('e', tape.pos()) - tape.pos();
     char *ptr = dict.data(); // Get start of buffer
     ptr += tape.pos(); // Advance to current position in tape
 
     // Allocate temporary data buffer
-    QByteArray buffer(length + 1);
+    QByteArray buffer(length + 1, ' ');
 
-    qmemmove (buffer.data(), ptr, length);
+    memmove (buffer.data(), ptr, length);
     buffer[length] = 0; // Null-terminate
 
     QString numberString (buffer);
@@ -87,13 +86,13 @@
         arg (m_value);
 
     Q_LONG written = 0, result = 0;
-    written = device.writeBlock (str.latin1(), str.length());
-    while ((uint) written < str.length())
+    written = device.write (str.toLatin1(), str.length());
+    while (written < str.length())
     {
         if (written < 0 || result < 0)
             return false;
 
-        result = device.writeBlock(str.latin1() + written,
+        result = device.write((str + written).toLatin1(),
                 str.length() - written);
         written += result;
     }
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bint.h #625208:625209
@@ -19,7 +19,6 @@
 #ifndef _BINT_H
 #define _BINT_H
 
-#include <q3cstring.h>
 #include "bbase.h"
 #include "bytetape.h"
 
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/blist.cpp #625208:625209
@@ -145,13 +145,13 @@
     const char *e_str = "e";
     Q_LONG written = 0, result = 0;
     
-    written = device.writeBlock (l_str, 1);
+    written = device.write (l_str, 1);
     while (written < 1)
     {
         if (written < 0 || result < 0)
             return false;
             
-        result = device.writeBlock (l_str, 1);
+        result = device.write (l_str, 1);
         written += result;
     }
     
@@ -162,13 +162,13 @@
             return false;
     }
     
-    written = device.writeBlock (e_str, 1);
+    written = device.write (e_str, 1);
     while (written < 1)
     {
         if (written < 0 || result < 0)
             return false;
             
-        result = device.writeBlock (e_str, 1);
+        result = device.write (e_str, 1);
         written += result;
     }
     
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/blist.h #625208:625209
@@ -19,18 +19,18 @@
 #ifndef _BLIST_H
 #define _BLIST_H
 
-#include <q3valuelist.h>
-#include <q3cstring.h>
+#include <QList>
+
 #include "bbase.h"
 #include "bytetape.h"
 
-typedef Q3ValueList<BBase *> BBaseVector;
-typedef Q3ValueList<BBase *>::iterator BBaseVectorIterator;
+typedef QList<BBase *> BBaseVector;
+typedef QList<BBase *>::iterator BBaseVectorIterator;
 
 // Predeclare the following classes
 class BDict;
 class BString;
-class BInt;  
+class BInt;
 
 /**
  * Class to construct a list of BBase objects from a b-encoded
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bstring.cpp #625208:625209
@@ -16,7 +16,7 @@
  * If not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
-#include <q3cstring.h>
+#include <QByteArray>
 #include <qiodevice.h>
 
 #include <kdebug.h>
@@ -44,7 +44,7 @@
 {
     QByteArray &dict(tape.data());
 
-    if (dict.find(':', tape.pos()) == -1)
+    if (dict.indexOf(':', tape.pos()) == -1)
     {
         kDebug(7034) << "Can't find : for string!" << endl;
         return;
@@ -52,12 +52,12 @@
 
     // Copy the part from start to :, as it will be a number
     // That number is the number of characters to read
-    int length = dict.find(':', tape.pos()) - tape.pos();
+    int length = dict.indexOf(':', tape.pos()) - tape.pos();
     char *ptr = dict.data();
 
     ptr += tape.pos();
 
-    QByteArray buffer (length + 1);
+    QByteArray buffer (length + 1, ' ');
     memmove (buffer.data(), ptr, length);
     buffer[length] = 0;
 
@@ -106,13 +106,13 @@
     QString str = QString("%1:").
         arg(get_len());
 
-    Q3CString utfString = str.toUtf8();
+    QByteArray utfString = str.toUtf8();
 
     /* Don't write null terminator */
-    device.writeBlock (utfString.data(), utfString.size() - 1);
+    device.write (utfString.data(), utfString.size() - 1);
 
     // Output the actual data
-    device.writeBlock (m_data.data(), m_data.size() - 1);
+    device.write (m_data.data(), m_data.size() - 1);
 
     // Done
     return true;
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bstring.h #625208:625209
@@ -20,7 +20,6 @@
 #define _BSTRING_H
 
 #include <qstring.h>
-#include <q3cstring.h>
 
 #include "bytetape.h"
 #include "bbase.h"
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bytetape.cpp #625208:625209
@@ -32,7 +32,7 @@
 {
 }
 
-ByteTape& ByteTape::operator += (const unsigned int i)
+ByteTape& ByteTape::operator += (const int i)
 {
     m_shared->pos += i;
     if (m_array.size() <= m_shared->pos)
@@ -44,7 +44,7 @@
     return *this;
 }
 
-ByteTape& ByteTape::operator -= (const unsigned int i)
+ByteTape& ByteTape::operator -= (const int i)
 {
     if (i > m_shared->pos)
     {
@@ -57,7 +57,7 @@
     return *this;
 }
 
-char ByteTape::operator [] (const unsigned int i)
+char ByteTape::operator [] (const int i)
 {
     if (i < m_array.size())
         return m_array[i];
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/bytetape.h #625208:625209
@@ -21,13 +21,11 @@
 
 #include <ksharedptr.h>
 
-#include <q3cstring.h>
-
 class ByteTapeShared : public KShared
 {
     public:
 
-    unsigned int pos;
+    int pos;
 };
 
 /**
@@ -73,7 +71,7 @@
      * @param i the amount to increment the current position by
      * @return t reference to the object incremented
      */
-    ByteTape & operator += (const unsigned int i);
+    ByteTape & operator += (const int i);
 
     /**
      * Decrements the current position by @p i.  It is the responsibility
@@ -85,7 +83,7 @@
      * @param i the amount to decrement the current position by
      * @return a reference to the object decremented
      */
-    ByteTape & operator -= (const unsigned int i);
+    ByteTape & operator -= (const int i);
 
     /**
      * Increments the current position by 1.  This is a postfix
@@ -138,7 +136,7 @@
      * @return the byte at the given index.  0 may be returned on error,
      *         but does not necessarily indicate an error.
      */
-    char operator [] (const unsigned int i);
+    char operator [] (const int i);
 
     /**
      * Returns the byte at the tape's current position.  You can assign
@@ -164,7 +162,7 @@
      *
      * @return the tape head's current position
      */
-    unsigned int pos() const { return m_shared->pos; }
+    int pos() const { return m_shared->pos; }
 
     /**
      * Sets the current position of the tape head to @p pos.  If the
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/kfile_torrent.cpp #625208:625209
@@ -37,9 +37,8 @@
 QStringList filesList (BList *list);
 qulonglong filesLength (BList *list);
 
-KTorrentPlugin::KTorrentPlugin (QObject *parent, const char *name,
-                                const QStringList &args)
-    : KFilePlugin (parent, name, args), m_failed(true), m_dict(0)
+KTorrentPlugin::KTorrentPlugin (QObject *parent, const QStringList &args)
+    : KFilePlugin (parent, args), m_failed(true), m_dict(0)
 {
     KFileMimeTypeInfo *info = addMimeTypeInfo ("application/x-bittorrent");
     if (!info)
--- trunk/KDE/kdenetwork/kfile-plugins/torrent/kfile_torrent.h #625208:625209
@@ -47,7 +47,7 @@
      * @param name the name of this object (not user-readable)
      * @param args unused by this class
      */
-    KTorrentPlugin (QObject *parent, const char *name, const QStringList &args);
+    KTorrentPlugin (QObject *parent, const QStringList &args);
 
     /**
      * Destructor that closes the dictionary holding the torrent information.
[prev in list] [next in list] [prev in thread] [next in thread] 

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