00001
00002
00003
00004
00005
00006
00007
00008 #ifndef DIRECTORY_H_
00009 #define DIRECTORY_H_
00010
00011 #include <qvaluelist.h>
00012 #include <qlistview.h>
00013 #include <qptrlist.h>
00014 #include <qthread.h>
00015
00016 #include <mythtv/uitypes.h>
00017
00018
00019
00020
00021 #define TA_ROOT 0
00022 #define TA_DIR 1
00023 #define TA_DIRENTRY 2
00024 #define TA_VMAIL 3
00025 #define TA_VMAIL_ENTRY 4
00026 #define TA_CALLHISTENTRY 5
00027 #define TA_SPEEDDIALENTRY 6
00028
00029
00030 #define ICON_PRES_UNKNOWN 0
00031 #define ICON_PRES_ONLINE 1
00032 #define ICON_PRES_OFFLINE 2
00033 #define ICON_PRES_AWAY 3
00034
00035 class DirEntry
00036 {
00037
00038 public:
00039
00040 DirEntry(QString nn, QString uri, QString fn="", QString sn="", QString ph="", bool ohl=false);
00041 DirEntry(DirEntry *Original);
00042 ~DirEntry();
00043 QString getNickName() { return NickName; }
00044 QString getSurname() { return Surname; }
00045 QString getFirstName() { return FirstName; }
00046 QString getFullName() { if (FirstName.length() != 0) return FirstName + " " + Surname; else return Surname; }
00047 QString getPhotoFile() { return PhotoFile; }
00048 QString getUri() { return Uri; }
00049 bool getOnHomeLan() { return onHomeLan; }
00050 void setNickName(QString s) { NickName=s; changed=true; }
00051 void setSurname(QString s) { Surname=s; changed=true; }
00052 void setFirstName(QString s) { FirstName=s; changed=true; }
00053 void setPhotoFile(QString s) { PhotoFile=s; changed=true; }
00054 void setOnHomeLan(bool b) { onHomeLan=b; changed=true; }
00055 void setUri(QString s) { Uri=s; changed=true; }
00056 int getId() { return id; }
00057 void setDbId(int d) { dbId=d; }
00058 int getDbId() { return dbId; }
00059 void writeTree(GenericTree *tree_to_write_to, GenericTree *sdTree=0);
00060 void setSpeedDial(bool yn) { SpeedDial = yn; changed=true; }
00061 bool isSpeedDial() { return SpeedDial; }
00062 bool urlMatches(QString s);
00063 void setDBUpToDate() { changed=false; inDatabase=true; }
00064 void updateYourselfInDB(QString Dir);
00065 void deleteYourselfFromDB();
00066 GenericTree *getTreeNode() { return TreeNode; };
00067 GenericTree *getSpeeddialNode() { return SpeeddialNode; };
00068
00069
00070
00071 private:
00072
00073 QString NickName;
00074 QString FirstName;
00075 QString Surname;
00076 QString Uri;
00077 QString PhotoFile;
00078 int id;
00079 bool SpeedDial;
00080 bool onHomeLan;
00081
00082 bool inDatabase;
00083 bool changed;
00084 int dbId;
00085
00086 GenericTree *TreeNode;
00087 GenericTree *SpeeddialNode;
00088
00089
00090
00091
00092 };
00093
00094 class Directory : public QPtrList<DirEntry>
00095 {
00096 public:
00097
00098 Directory(QString Name);
00099 ~Directory();
00100 QString getName() { return name; }
00101 void writeTree(GenericTree *tree_to_write_to, GenericTree *sdTree);
00102 DirEntry *fetchById(int id);
00103 void getMatchingCalls(DirEntry *source, QPtrList<DirEntry> &CallList);
00104 virtual int compareItems(QPtrCollection::Item s1, QPtrCollection::Item s2);
00105 DirEntry *getDirEntrybyDbId(int dbId);
00106 DirEntry *getDirEntrybyUrl(QString Url);
00107 void saveChangesinDB();
00108 void deleteEntry(DirEntry *Entry);
00109 void AddAllEntriesToList(QStrList &l, bool SpeeddialsOnly);
00110 void ChangePresenceStatus(QString Uri, int Status, QString StatusString, bool SpeeddialsOnly);
00111
00112 private:
00113 QString name;
00114 };
00115
00116
00117 class CallRecord
00118 {
00119
00120 public:
00121
00122 CallRecord(QString dn, QString uri, bool callIn, QString ts);
00123 CallRecord(CallRecord *Original);
00124 CallRecord(DirEntry *Original, bool callIn, QString ts);
00125 ~CallRecord();
00126 QString getTimestamp() { return timestamp; }
00127 QString getDisplayName() { return DisplayName; }
00128 QString getUri() { return Uri; }
00129 int getId() { return id; }
00130 void setDuration(int d) { Duration = d; }
00131 int getDuration() { return Duration; }
00132 void setDbId(int d) { dbId=d; }
00133 void setDBUpToDate() { changed=false; inDatabase=true; }
00134 bool isIncoming() { return DirectionIn; }
00135 void writeTree(GenericTree *tree_to_write_to);
00136 void updateYourselfInDB();
00137 void deleteYourselfFromDB();
00138
00139 private:
00140
00141 QString DisplayName;
00142 QString Uri;
00143 int id;
00144 QString timestamp;
00145 int Duration;
00146 bool DirectionIn;
00147
00148 bool inDatabase;
00149 bool changed;
00150 int dbId;
00151 };
00152
00153
00154 class CallHistory : public QPtrList<CallRecord>
00155 {
00156 public:
00157
00158 CallHistory() : QPtrList<CallRecord>() {};
00159 ~CallHistory();
00160 void writeTree(GenericTree *placed_tree, GenericTree *received_tree);
00161 CallRecord *fetchById(int id);
00162 virtual int compareItems(QPtrCollection::Item s1, QPtrCollection::Item s2);
00163 void saveChangesinDB();
00164 void deleteRecords();
00165 private:
00166 };
00167
00168
00169
00170 class DirectoryContainer
00171 {
00172 public:
00173
00174 DirectoryContainer();
00175 ~DirectoryContainer();
00176 void Load();
00177 void writeTree();
00178 DirEntry *fetchDirEntryById(int id);
00179 CallRecord *fetchCallRecordById(int id);
00180 void AddEntry(DirEntry *entry, QString Dir, bool addToUITree);
00181 void ChangeEntry(DirEntry *entry, QString nn, QString Url, QString fn, QString sn, QString ph, bool OnHomeLan);
00182 QStrList getDirectoryList(void);
00183 GenericTree *addToTree(QString DirName);
00184 void getRecentCalls(DirEntry *source, CallHistory &RecentCalls);
00185 void AddToCallHistory(CallRecord *entry, bool addToUITree);
00186 void clearCallHistory();
00187 DirEntry *getDirEntrybyDbId(int dbId);
00188 void saveChangesinDB();
00189 void addToTree(DirEntry *newEntry, QString Dir);
00190 void deleteFromTree(GenericTree *treeObject, DirEntry *entry);
00191 void createTree();
00192 GenericTree *getTreeRoot() { return TreeRoot; }
00193 void setSpeedDial(DirEntry *entry);
00194 void removeSpeedDial(DirEntry *entry);
00195 void clearAllVoicemail();
00196 void deleteVoicemail(QString vmailName);
00197 DirEntry *FindMatchingDirectoryEntry(QString url);
00198 QStrList ListAllEntries(bool SpeeddialsOnly);
00199 void ChangePresenceStatus(QString Uri, int Status, QString StatusString, bool SpeeddialsOnly);
00200
00201
00202 private:
00203 Directory *fetch(QString Dir);
00204 GenericTree *findInTree(GenericTree *Root, int at1, int atv1, int at2, int atv2);
00205 void PutVoicemailInTree(GenericTree *tree_to_write_to);
00206
00207 QPtrList<Directory> AllDirs;
00208 CallHistory *callHistory;
00209
00210 GenericTree *TreeRoot,
00211 *voicemailTree,
00212 *receivedcallsTree,
00213 *placedcallsTree,
00214 *speeddialTree;
00215 };
00216
00217
00218
00219
00220 #endif