]> Some of my projects - aniplayer-old.git/commitdiff
- Some fixes
authorAPTX <APTX@.(none)>
Sun, 30 Aug 2009 13:05:55 +0000 (15:05 +0200)
committerAPTX <APTX@.(none)>
Sun, 30 Aug 2009 13:05:55 +0000 (15:05 +0200)
lib/anidbudpclient/anidbudpclient.pro
lib/anidbudpclient/anidbudpclient_global.h
lib/anidbudpclient/client.h
lib/anidbudpclient/file.cpp
lib/anidbudpclient/file.h

index 9025a353ae89721e84be5a36bb4b30ba99a8ed8b..957596014edd01b59d8631683c640aab129bf990 100644 (file)
@@ -55,7 +55,7 @@ CONV_HEADERS += include/AniDBUdpClient/Client \
        include/AniDBUdpClient/FileCommand \
        include/AniDBUdpClient/File \
        include/AniDBUdpClient/UptimeCommand \
-       include/AniDBUdpClient/Hash
+       include/AniDBUdpClient/Hash \
     include/AniDBUdpClient/UptimeCommand \
 
 include(../../lib/qtstatemachine/src/qtstatemachine.pri)
index d0dacd724187a1c2412f6c0ea3ec1f8f95b888fd..86f32b2c4431a1c5735c62713a52e9ff9aa19dd2 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef ANIDBUDPCLIENT_GLOBAL_H
 #define ANIDBUDPCLIENT_GLOBAL_H
 
-#include <QtCore/qglobal.h>
 #include <QObject>
 
 #define CLIENT_NAME "anidbudpclient"
index 362fcb75120571afad053176db984cae6a309806..7fa97f9b4f6b28b88f49ca9f733b856d5b0e0e51 100644 (file)
@@ -33,7 +33,7 @@ class ANIDBUDPCLIENTSHARED_EXPORT Client : public QObject
        friend class CommandData;
 
        Q_OBJECT
-       Q_ENUMS(State Error IdlePolicy AbstractCommand::ReplyCode);
+       Q_ENUMS(AniDBUdpClient::State AniDBUdpClient::Error AniDBUdpClient::IdlePolicy AniDBUdpClientReplyCode);
 
        Q_PROPERTY(QString host READ host WRITE setHost);
        Q_PROPERTY(quint16 hostPort READ hostPort WRITE setHostPort);
index d3b490e8f44c4716f40847ac7eec4fee1d195398..9bb07f9ab5e370507222082a9c542aca698666af 100644 (file)
@@ -6,19 +6,22 @@ File::File(QObject *parent) : QObject(parent)
 {
 }
 
-QString File::file() const
+QFileInfo File::file() const
 {
        return m_file;
 }
 
-void File::setFile(const QString &file)
+void File::setFile(const QFileInfo &file)
 {
+       if (m_file == file)
+               return;
+
        m_file = file;
 }
 
 qint64 File::size()
 {
-       return m_size;
+       return m_file.size();
 }
 
 QByteArray File::ed2k()
@@ -28,11 +31,14 @@ QByteArray File::ed2k()
 
 void File::hash()
 {
-
+       if (m_ed2k.isEmpty())
+               actionsQueue.enqueue(Hashing);
 }
 
 bool File::rename()
 {
+       if (m_ed2k.isEmpty())
+               actionsQueue.enqueue(Hashing);
        return false;
 }
 
@@ -42,9 +48,12 @@ bool File::markWatched(bool watched)
 }
 
 
-void File::finishHashing()
+void File::finishHashing(const QFileInfo &file, const QByteArray &hash)
 {
-
+       if (m_file != file)
+               return;
+       m_ed2k = hash;
+       emit finished(Hashing);
 }
 
 void File::finishRenaming()
@@ -57,4 +66,31 @@ void File::finishMarking()
 
 }
 
+void File::startHashing()
+{
+
+}
+
+void File::startRenaming()
+{
+
+}
+
+void File::startMarking()
+{
+
+}
+
+void File::work()
+{
+       Action a = actionsQueue.dequeue();
+
+       switch (a)
+       {
+               case Hashing:
+               default:
+               break;
+       }
+}
+
 } // namespace AniDBUdpClient
index aa3d6088689e5dcc649a9992430e6f4d8ef9285d..3bade27483ef77b3403294a1566c10fd1a3c2e7f 100644 (file)
@@ -4,6 +4,9 @@
 #include "anidbudpclient_global.h"
 #include <QObject>
 
+#include <QFileInfo>
+#include <QQueue>
+
 namespace AniDBUdpClient {
 
 class FileCommand;
@@ -13,7 +16,7 @@ class ANIDBUDPCLIENTSHARED_EXPORT File : public QObject
 {
        Q_OBJECT
 
-       Q_PROPERTY(QString file READ file WRITE setFile);
+       Q_PROPERTY(QFileInfo file READ file WRITE setFile);
 
        Q_PROPERTY(qint64 size READ size);
        Q_PROPERTY(QByteArray ed2k READ ed2k);
@@ -30,8 +33,8 @@ public:
 
        File(QObject *parent = 0);
 
-       QString file() const;
-       void setFile(const QString &file);
+       QFileInfo file() const;
+       void setFile(const QFileInfo &file);
 
        qint64 size();
        QByteArray ed2k();
@@ -45,14 +48,20 @@ signals:
        void finished(Action action);
 
 private slots:
-       void finishHashing();
+       void finishHashing(const QFileInfo &file, const QByteArray &hash);
        void finishRenaming();
        void finishMarking();
 
 private:
+       void startHashing();
+       void startRenaming();
+       void startMarking();
+
+       void work();
+
+       QQueue<Action> actionsQueue;
 
-       QString m_file;
-       qint64 m_size;
+       QFileInfo m_file;
        QByteArray m_ed2k;
 
 };