00001 #ifndef ACCOUNT_H
00002 #define ACCOUNT_H
00003
00004 #include <QObject>
00005 #include <QDomDocument>
00006 #include <QFile>
00007 #include <QDebug>
00008 #include <QDir>
00009 #include <QMetaType>
00010 #include <QtConcurrentRun>
00011
00012 #include "qtransport.h"
00013 #include "friend.h"
00014 #include "utils/utils.h"
00015 #include "datatypes/message.h"
00016
00017
00018 #define FILE_ACCOUNT_DATA "profile.xml"
00019
00020
00021 #define NODE_ACCOUNT_ROOT "profile"
00022
00023
00024 #define NODE_ACCOUNT_LIBRARY "library"
00025
00026
00027 #define NODE_ACCOUNT_SETTINGS "settings"
00028
00029 #define FILE_FRIENDS_DATA "friends.xml"
00030
00031 #define NODE_FRIENDS_ROOT "friendsList"
00032
00033 #define FILE_MESSAGES_DATA "/messages.xml"
00034
00035 #define NODE_MESSAGES_ROOT "messageList"
00036
00037 #define FILE_DRAFTS_DATA "/drafts.xml"
00038
00039
00040
00041
00042 class Account: public QObject
00043 {
00044 Q_OBJECT
00045
00046 private:
00047 FriendList friends;
00048 AlbumList albums;
00049 MessageList messages;
00050 MessageList draftMessages;
00051 QString settings;
00052 QString oldSettings;
00053
00054
00055 Friend profile;
00056
00057
00058 bool isLibraryInit;
00059
00060 public:
00061 Account(QString libraryName);
00062 Account(QString libraryName, QString accountId);
00063 ~Account();
00064
00065 QTransport *transport;
00066
00067 bool ready() const;
00068
00069 void saveAccount();
00070 static Account* loadAccount(const QString& accountId);
00071
00072
00073 FriendList getFriendList();
00074
00075
00076 void setFriendList(const FriendList& list);
00077
00078 QString accountId() const;
00079
00080 QString serviceName() const;
00081
00087 AlbumList getAlbumList();
00088
00094 void setAlbumList(const AlbumList& list);
00095
00096 MessageList getMessageList();
00097
00098 void setMessageList(const MessageList&);
00099
00100 void setDraftMessages(const MessageList&);
00101
00102 MessageList getDraftMessages();
00103
00104 Friend getProfile(const bool isNeedUpdate);
00105
00106 void setProfile(const Friend& profile);
00107
00114 void setProxy(const QString& proxyHost, const int proxyPort);
00115
00116
00117 bool isFirstRequest;
00118
00119
00120 bool isNetworkEnabled;
00121
00122 signals:
00123 void draftsUpdated(MessageList draftMessages);
00124
00125 private slots:
00126 void gotSettings(QString accountId, QString settings);
00127 };
00128
00129 typedef QList<Account *> AccountList;
00130
00131 Q_DECLARE_METATYPE(Account *)
00132
00133 #endif // ACCOUNT_H