00001
00007 #ifndef FRIEND_H
00008 #define FRIEND_H
00009
00010 #include <QObject>
00011 #include <QString>
00012 #include <QDomDocument>
00013 #include <QFile>
00014 #include <QDebug>
00015 #include <QMetaType>
00016
00017 class Friend;
00018
00019 #include "album.h"
00020 #include "utils/utils.h"
00021 #include "utils/qrefreshlist.h"
00022
00026 #define FILE_ALBUMS_DATA "albums_%1.xml"
00027
00028 #define NODE_ALBUMS_ROOT "albums"
00029
00030 #define NODE_FRIEND_ROOT "friend"
00031 #define NODE_FRIEND_ID "id"
00032 #define NODE_FRIEND_FIRST_NAME "firstname"
00033 #define NODE_FRIEND_NICK_NAME "nickname"
00034 #define NODE_FRIEND_LAST_NAME "lastname"
00035 #define NODE_FRIEND_ICON "icon"
00036 #define NODE_FRIEND_ICON_URL "iconUrl"
00037 #define NODE_FRIEND_GENDER "gender"
00038 #define NODE_FRIEND_BIRTHDAY "birthday"
00039 #define NODE_FRIEND_MOBILE_PHONE "mobilePhone"
00040 #define NODE_FRIEND_HOME_PHONE "homePhone"
00041 #define NODE_FRIEND_CITY "city"
00042 #define NODE_FRIEND_COUNTRY "country"
00043
00044 #define FILE_OWNER_DATA "owner_%1.xml"
00045
00046 typedef QRefreshList<Friend> FriendList;
00047
00048 Q_DECLARE_METATYPE(Friend)
00049 Q_DECLARE_METATYPE(FriendList)
00050
00054 class Friend : public QObject
00055 {
00056 Q_OBJECT
00057
00058 private:
00059 QString _firstName;
00060 QString _nickName;
00061 QString _lastName;
00062 QString _gender;
00063 QString _birthday;
00064 QString _mobilePhone;
00065 QString _homePhone;
00066 QString _city;
00067 QString _country;
00068 QString _icon;
00069 QString _icon_url;
00071
00072
00075 bool _online;
00076
00080 bool _isMainProfile;
00081
00082 FriendList _profiles;
00084 public:
00086 Friend();
00087
00089
00094 Friend(const Friend&);
00095
00097 ~Friend();
00098
00099 QString ownerId;
00100 QString accountId;
00101 QString serviceId;
00108 void setFirstName(const QString& val);
00109
00115 QString firstName() const;
00116
00122 void setNickName(const QString& val);
00123
00129 QString nickName() const;
00130
00136 void setLastName(const QString &val);
00137
00143 QString lastName() const;
00144
00150 void setOnline(const bool val);
00151
00157 bool online() const;
00158
00164 void setGender(const QString& val);
00165
00171 QString gender() const;
00172
00178 void setBirthday(const QString& val);
00179
00185 QString birthday() const;
00186
00192 void setMobilePhone(const QString& val);
00193
00199 QString mobilePhone() const;
00200
00206 void setHomePhone(const QString &val);
00207
00213 QString homePhone() const;
00214
00220 void setCity(const QString& val);
00221
00227 QString city() const;
00228
00234 void setCountry(const QString &val);
00235
00241 QString country() const;
00242
00248 void setIcon_url(const QString& val);
00249
00255 QString icon_url() const;
00256
00262 void setIcon(const QString& icon);
00263
00269 QString icon() const;
00270
00276 bool isMetaProfile() const;
00277
00283 bool hasFullProfile() const;
00284
00290 FriendList getProfileList() const;
00291
00299 void addProfile(const Friend& fr, const bool isMainProfile);
00300
00308 bool hasProfile(const Friend& fr) const;
00309
00319 bool hasProfile(const QString& serviceId, const QString& ownerId) const;
00320
00330 static FriendList mergeLists(FriendList src1, FriendList src2);
00331
00337 QString name() const;
00338
00344 AlbumList getAlbumList() const;
00345
00355 static void setAlbumList(const AlbumList& list, const QString& accountId, const QString& friendId);
00356
00368 static QDomElement toQDomElement(QDomDocument& doc, const Friend& src, const bool addOptionalInfo);
00369
00381 static Friend fromQDomElement(const QDomElement& fr, const QString& accountId, const QString& serviceId);
00382
00388 Friend& operator=(const Friend&);
00389
00393 bool operator <(const Friend& fr1) const;
00394
00398 bool operator ==(const Friend& fr1) const;
00399
00407 static void copyData(Friend *dst, const Friend *src);
00408
00412 void storeData();
00413
00425 static Friend loadData(const QString& serviceId, const QString& accountId, const QString& ownerId);
00426
00427 bool isEmpty() const;
00428 };
00429
00430 #endif // FRIEND_H