#include "rawcommand.h"
#include "logoutcommand.h"
#include "uptimecommand.h"
+#include "hash.h"
#include <QtDebug>
sendCommand(new LogoutCommand, true);
socket->waitForBytesWritten(5);
}
+
+ if (m_hashInstance)
+ delete m_hashInstance;
}
QString Client::host() const
}
}
+Client *Client::instance()
+{
+ if (!m_instance)
+ m_instance = new Client;
+
+ return m_instance;
+}
+
+void Client::destroy()
+{
+ delete m_instance;
+ m_instance = 0;
+}
+
+Hash *Client::hashInstance()
+{
+ if (!m_hashInstance)
+ m_hashInstance = new Hash;
+
+ return m_hashInstance;
+}
+
void Client::connect()
{
qDebug() << "Conneting";
return result;
}
+Client *Client::m_instance = 0;
+
CommandData::CommandData(AbstractCommand *command, const QByteArray &commandId, bool controlCommand) : QObject()
{
this->command = command;
static const int clientVersion;
static const int protocolVersion;
+protected:
Client(QObject *parent = 0);
virtual ~Client();
+public:
// ------------------ Properties ------------------
QString host() const;
void setHost(const QString &host, quint16 port = 0);
void clearCommandQueue();
+ static Client *instance();
+ static void destroy();
+
public slots:
void connect();
LogoutCommand *logoutCommand;
UptimeCommand *uptimeCommand;
+ static Client *m_instance;
static const int UDP_DATAGRAM_MAXIMUM_SIZE = 1400;
} // namespace AniDBUdpClient
#include <QScriptEngine>
-Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::Client, QObject*);
+//Q_SCRIPT_DECLARE_QMETAOBJECT(AniDBUdpClient::Client, QObject*);
#endif // ANIDBUDPCLIENT_H
tearDown();
}
+static Hash *Hash::instance()
+{
+ if (!m_instance)
+ m_instance = new Hash();
+
+ return m_instance;
+}
+
+static void Hash::destroy()
+{
+ delete m_instance;
+ m_instance = 0;
+}
+
void Hash::hashFile(const QFileInfo &file)
{
qDebug() << "Hash::hashFile";
buffer = 0;
}
+Hash *Hash::m_instance = 0;
+
} // namesapce AniDBUdpClient
Q_OBJECT
-public:
+protected:
Hash(QObject *parent = 0);
~Hash();
+public:
void hashFile(const QFileInfo &file);
+ static Hash *instance();
+ static void destroy();
+
signals:
void fileHashed(const QFileInfo &file, const QByteArray &hash);
void fileProgress(int percent);
QTime fileTime;
QTime totalTime;
+
+ static Hash *m_instance;
};
} // namesapce AniDBUdpClient