aboutsummaryrefslogtreecommitdiffstats
path: root/Credentials.h
blob: b23dc0b03e888e8a7603d98f55baf9c50729485c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Copyright 2008 Jason A. Donenfeld <Jason@zx2c4.com>
 */

#ifndef CREDENTIALS_H
#define CREDENTIALS_H

#include <QString>
#include <QDialog>
#include <QUrl>
#include <QLineEdit>
#include <QList>

class QLabel;
class QHttp;
class Song;
class QBuffer;
class QProgressBar;
class QStatusBar;

class Credentials : public QDialog
{
	Q_OBJECT

public:	
	Credentials(QString host, QString listingPath, QString songPath, QWidget *parent = 0);
	QUrl songUrl(QString hash) const;
	void setDownloadProgressBar(QProgressBar *bar) { m_downloadProgressBar = bar; };
	QProgressBar* downloadProgressBar() { return m_downloadProgressBar; };
	void setStatusBar(QStatusBar *bar) { m_statusBar = bar; };
	QStatusBar* statusBar() { return m_statusBar; };
	
private:
	QString m_host;
	int m_port;
	QString m_listingPath;
	QString m_songPath;
	QLabel *m_errorLabel;
	QLineEdit *m_usernameEdit;
	QLineEdit *m_passwordEdit;
	QHttp *m_downloader;
	QBuffer *m_buffer;
	int m_downloadId;
	QProgressBar *m_downloadProgressBar;
	QStatusBar *m_statusBar;
	void databaseDownloadFailed();

private slots:
	void requestFinished(int id, bool error);
	void dataReadProgress(int done, int total);
	void login();

signals:
	void receivedList(const QList<Song*> songList);
};

#endif //CREDENTIALS_H