This forum has been archived. All content is frozen. Please use KDE Discuss instead.

[patch] Add up- and download time to webinterface

Tags: None
(comma "," separated)
suicide
Registered Member
Posts
1
Karma
0
Hi, i'd like to see the current upload and download time in the web interface plugin. So here is my patch against 3.3.4

Code: Select all
diff -crB ktorrent-org/plugins/webinterface/torrentlistgenerator.cpp ktorrent-3.3.4/plugins/webinterface/torrentlistgenerator.cpp
*** ktorrent-org/plugins/webinterface/torrentlistgenerator.cpp   2010-02-07 11:02:39.000000000 +0100
--- ktorrent-3.3.4/plugins/webinterface/torrentlistgenerator.cpp   2010-04-01 09:54:45.000000000 +0200
***************
*** 18,23 ****
--- 18,24 ----
   *   Free Software Foundation, Inc.,                                       *
   *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.          *
   ***************************************************************************/
+ #include <cstdio>
  #include <QXmlStreamWriter>
  #include <util/sha1hash.h>
  #include <util/functions.h>
***************
*** 80,85 ****
--- 81,105 ----
           writeElement(out,"running",s.running ? "1" : "0");
           writeElement(out,"percentage",QString::number(Percentage(s),'f',2));
           writeElement(out,"num_files",QString::number(ti->getNumFiles()));
+          
+          long seconds = ti->getRunningTimeUL() - ti->getRunningTimeDL();
+          int seedseconds = seconds%60;
+          int minutes = (seconds/60) % 60;
+          int hours = (seconds/3600) % 3600;
+          int seeddays = (seconds/86400);
+          char timeString[] = "     00:00:00";
+          snprintf(timeString, 13, "%01dT %02d:%02d:%02d", seeddays, hours, minutes, seedseconds);
+          writeElement(out,"seed_time", timeString);
+          
+          seconds = ti->getRunningTimeDL();
+          seedseconds = seconds%60;
+          minutes = (seconds/60) % 60;
+          hours = (seconds/3600) % 3600;
+          seeddays = (seconds/86400);
+          char dlTimeString[] = "     00:00:00";
+          snprintf(dlTimeString, 13, "%01dT %02d:%02d:%02d", seeddays, hours, minutes, seedseconds);
+          
+          writeElement(out,"dl_time",dlTimeString);
           out.writeEndElement();
           i++;
        }
diff -crB ktorrent-org/plugins/webinterface/www/common/torrent_list.js ktorrent-3.3.4/plugins/webinterface/www/common/torrent_list.js
*** ktorrent-org/plugins/webinterface/www/common/torrent_list.js   2010-02-07 11:02:38.000000000 +0100
--- ktorrent-3.3.4/plugins/webinterface/www/common/torrent_list.js   2010-04-01 10:00:23.000000000 +0200
***************
*** 121,126 ****
--- 121,138 ----
        node.appendData(' %');
        cell.appendChild(node);
     }
+
+    //time
+    {
+       var cell = row.insertCell(8);
+       var seedTime = get_text(torrent, 'seed_time');
+       var dlTime = get_text(torrent, 'dl_time');
+       seeders.appendData(" up");
+       leechers.appendData(" down");
+       cell.appendChild(seedTime);
+       cell.appendChild(document.createElement('br'));
+       cell.appendChild(dlTime);
+    }
     
  }
 
***************
*** 128,134 ****
  {
     headers = new Array(
   "Actions","File","Status","Transferred","Size",
!  "Speed","Peers","Complete"
     );
 
     for (var i in headers)
--- 140,146 ----
  {
     headers = new Array(
   "Actions","File","Status","Transferred","Size",
!  "Speed","Peers","Complete","Time"
     );
 
     for (var i in headers)


regards,
szd


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]