defuze.me
Client
|
00001 /************************************************************************** 00002 ** defuze.me Epitech Innovative Project 00003 ** 00004 ** Copyright 2010-2011 00005 ** Athena Calmettes - Jocelyn De La Rosa - Francois Gaillard 00006 ** Adrien Jarthon - Alexandre Moore - Luc Peres - Arnaud Sellier 00007 ** 00008 ** All rights reserved. 00009 **************************************************************************/ 00010 00011 #ifndef SOURCE_HPP 00012 #define SOURCE_HPP 00013 00014 #include <QString> 00015 #include <QDateTime> 00016 #include <QUrl> 00017 00018 namespace Library 00019 { 00020 class Source : public QObject 00021 { 00022 Q_OBJECT 00023 00024 enum Type 00025 { 00026 LOCAL = 0, 00027 HTTP = 1, 00028 FTP = 2 00029 }; 00030 00031 enum Status 00032 { 00033 OK = 0, 00034 OUTDATED = 1, 00035 ERROR = 2, 00036 UNINITIALIZED = 3 00037 }; 00038 00039 public: 00040 Source(Type type, const QString &path, bool resursive = false, 00041 const QString &host = QString(), 00042 unsigned short port = 0, 00043 const QString &username = QString(), 00044 const QString &password = QString(), 00045 const QString &filename = QString()); 00046 Source(int id); 00047 static Source* getSource(int id); 00048 Status update(); 00049 bool newRecord() const; 00050 void save(); 00051 void merge(Source *oldSource); 00052 QUrl toUrl() const; 00053 bool isRecursive() const; 00054 int getId() const; 00055 const QString& getPath() const; 00056 static Type typeFromScheme(const QString &scheme); 00057 void remove(); 00058 00059 signals: 00060 void progressValueChange(int progressValue); 00061 void addToMaximumProgress(int maxValue); 00062 00063 private: 00064 int id; 00065 Type type; 00066 unsigned short port; 00067 QString host, path; 00068 QString username, password; 00069 QString filename; 00070 QDateTime updatedAt; 00071 Status status; 00072 bool recursive; 00073 00074 static QMap<int, Source*> sourcesMap; 00075 }; 00076 } 00077 #endif // SOURCE_HPP