00001
00002
00003
00004
00005 #ifndef _SLZDATABASE_H_INCLUDED
00006 #define _SLZDATABASE_H_INCLUDED
00007
00008 #include <qmap.h>
00009 #include <qobject.h>
00010
00011 #include "slzdtm.h"
00012 #include "slcategories.h"
00013
00014 using namespace SlZDtm;
00015 using namespace SlCategory;
00016
00017 struct SlZdbItemInfo;
00018 class SlZDataBaseItemInfo : public QMap<int,SlZdbItemInfo>
00019 {
00020 public:
00021 enum ItemType{
00022 TEXT = 0,
00023 UCHAR,
00024 USHORT,
00025 ULONG,
00026 COLOR,
00027 TIME,
00028 BINARY,
00029 CATEGORY
00030 };
00031 SlZDataBaseItemInfo();
00032 ~SlZDataBaseItemInfo();
00033
00034 void addItemInfo(int field,const char *itemName,
00035 ItemType type,const QString &title, bool isSearchable=true);
00036
00037 void toSlZdtmItemInfo(SlZDataManagerItemInfo *items) const;
00038
00039 const SlZdbItemInfo itemInfo(int field);
00040 };
00041
00042 class Contact;
00043 class Task;
00044 class Event;
00045
00046 class SlZDataBasePrivate;
00047 class SlZDataBase : public SlZDataManager
00048 {
00049 public:
00050
00051
00052 static const QString addressbookFileName(bool isBase=false);
00053 static const QString todolistFileName(bool isBase=false);
00054 static const QString datebookFileName(bool isBase=false);
00055 static const QString mailInboxFileName(int storage=0);
00056 static const QString mailOutboxFileName(int storage=0);
00057 static const QString memoFileName(bool isBase=false);
00058
00059
00060 static const QString addressbookMasterIdx(bool isBase=false);
00061 static const QString todolistMasterIdx(bool isBase=false);
00062 static const QString datebookMasterIdx(bool isBase=false);
00063 static const QString datebookStartIdx(bool isBase=false);
00064 static const QString datebookEndIdx(bool isBase=false);
00065 static const QString datebookMultiIdx(bool isBase=false);
00066 static const QString datebookRepeatIdx(bool isBase=false);
00067 static const QString mailInboxMasterIdx(int storage=0);
00068 static const QString mailOutboxMasterIdx(int storage=0);
00069 static const QString memoMasterIdx(bool isBase=false);
00070
00071
00072 static SlZDataBaseItemInfo addressbookItems();
00073 static SlZDataBaseItemInfo todolistItems();
00074 static SlZDataBaseItemInfo datebookItems();
00075 static SlZDataBaseItemInfo maillistItems();
00076
00077
00078 static bool createAddressbookFile(const SlZDataManagerIndexInfo &indexes);
00079 static bool createTodolistFile(const SlZDataManagerIndexInfo &indexes);
00080 static bool createDatebookFile(const SlZDataManagerIndexInfo &indexes);
00081 static bool createMailInboxFile(const SlZDataManagerIndexInfo &indexes, int storage);
00082 static bool createMailOutboxFile(const SlZDataManagerIndexInfo &indexes, int storage);
00083 static bool createMemoFile(const SlZDataManagerIndexInfo &indexes);
00084
00085
00086 enum CategoriesType{
00087
00088 CategoriesXml = 0,
00089
00090 CategoriesZdtm,
00091
00092 CategoriesNone
00093 };
00094
00095
00096 static bool addAddressbookEntry(SlZDataBase *zdb,
00097 CardId *cardId,const Contact &cnt,
00098 CategoriesType type = CategoriesZdtm);
00099 static bool addTodolistEntry(SlZDataBase *zdb,
00100 CardId *cardId,const Task &task,
00101 CategoriesType type = CategoriesZdtm);
00102 static bool addDatebookEntry(SlZDataBase *zdb,
00103 CardId *cardId,const Event &event,
00104 CategoriesType type = CategoriesZdtm);
00105
00106
00107 static bool addAddressbookEntry(SlZDataBase *zdb,CardId *cardId,
00108 SlZDataManager *zdtm,CardId card,
00109 SlCategories *boxCat=0);
00110 static bool addTodolistEntry(SlZDataBase *zdb,CardId *cardId,
00111 SlZDataManager *zdtm,CardId card,
00112 SlCategories *boxCat=0);
00113 static bool addDatebookEntry(SlZDataBase *zdb,CardId *cardId,
00114 SlZDataManager *zdtm,CardId card,
00115 SlCategories *boxCat=0);
00116
00117
00118
00119 static bool editAddressbookEntry(SlZDataBase *zdb,
00120 CardId *cardId,const Contact &cnt,
00121 CategoriesType type = CategoriesZdtm);
00122 static bool editTodolistEntry(SlZDataBase *zdb,
00123 CardId *cardId,const Task &task,
00124 CategoriesType type = CategoriesZdtm);
00125 static bool editDatebookEntry(SlZDataBase *zdb,
00126 CardId *cardId,const Event &event,
00127 CategoriesType type = CategoriesZdtm);
00128
00129
00130 static Contact toContact(SlZDataBase *zdb,CardId cardId,
00131 CategoriesType type = CategoriesZdtm);
00132 static Task toTask(SlZDataBase *zdb,CardId cardId,
00133 CategoriesType type = CategoriesZdtm);
00134 static Event toEvent(SlZDataBase *zdb,CardId cardId,
00135 CategoriesType type = CategoriesZdtm);
00136
00137
00138 static QArray<int> eventCategoryZdtmToXml(const QArray<int> &dtmIds);
00139 static QArray<int> eventCategoryXmlToZdtm(const QArray<int> &xmlIds);
00140
00141
00142 SlZDataBase(const char *boxFName,const SlZDataBaseItemInfo &items,
00143 QWidget *parent = NULL,bool isReadOnly=false);
00144 ~SlZDataBase();
00145
00146
00147
00148
00149
00150
00151
00152 QString readField(int field,CardId cardId=0);
00153 QDateTime readTimeField(int field,CardId cardId=0,bool isUtc=false);
00154 QDate readDateField(int field,CardId cardId=0);
00155 int readUcharField(int field,CardId cardId=0);
00156 int readUshortField(int field,CardId cardId=0);
00157 int readUlongField(int field,CardId cardId=0);
00158
00159 bool clearField(int field);
00160 bool writeField(int field,const char *data,ulong len);
00161 bool writeField(int field,const QDateTime &time);
00162 bool writeField(int field,const QDate &date);
00163 bool writeField(int field,const QString &data);
00164 bool writeField(int field,uchar value);
00165 bool writeField(int field,ushort value);
00166 bool writeField(int field,ulong value);
00167
00168 bool sortField(int field,bool isAscendent);
00169 bool searchField(CardId *cardId,QString string,
00170 int field,uchar searchMode,bool isNext=true);
00171
00172 DataType readFieldType(int field) const;
00173 int nameToFieldId(int field) const;
00174 QString itemName(int field) const;
00175
00176
00177 CardId resumeCardId();
00178
00179 private:
00180 SlZDataBasePrivate *p;
00181 };
00182
00183
00184
00185
00186
00187
00188 namespace ZdbAdrs
00189 {
00190
00191
00192 enum Fields {
00193
00194 Category = 0,
00195
00196 FullName,
00197
00198 Title,
00199
00200 LastName,
00201
00202 FirstName,
00203
00204 MiddleName,
00205
00206 Suffix,
00207
00208 FileAs,
00209
00210 LastNamePronunciation,
00211
00212 FirstNamePronunciation,
00213
00214 FullNamePronunciation,
00215
00216
00217 Company,
00218
00219 CompanyPronunciation,
00220
00221 Department,
00222
00223 JobTitle,
00224
00225 BusinessPhone,
00226
00227 BusinessFax,
00228
00229 BusinessMobile,
00230
00231 BusinessState,
00232
00233 BusinessCity,
00234
00235 BusinessStreet,
00236
00237 BusinessZip,
00238
00239 BusinessCountry,
00240
00241 BusinessWebPage,
00242
00243 Office,
00244
00245 Profession,
00246
00247 Assistant,
00248
00249 Manager,
00250
00251 BusinessPager,
00252
00253 HomeMobile,
00254
00255
00256 HomePhone,
00257
00258 HomeFax,
00259
00260 HomeState,
00261
00262 HomeCity,
00263
00264 HomeStreet,
00265
00266 HomeZip,
00267
00268 HomeCountry,
00269
00270 HomeWebPage,
00271
00272
00273 DefaultEmail,
00274
00275 Emails,
00276
00277
00278 Spouse,
00279
00280 Gender,
00281
00282 Birthday,
00283
00284 Anniversary,
00285
00286 Nickname,
00287
00288 Children,
00289
00290
00291 Notes,
00292
00293 Groups
00294
00295 };
00296 };
00297
00298
00299
00300
00301 namespace ZdbTodo
00302 {
00303
00304
00305 enum Fields {
00306
00307 Category = 0,
00308
00309 StartDate,
00310
00311 DueDate,
00312
00313 FinishDate,
00314
00315 Mark,
00316
00317 Priority,
00318
00319 Description,
00320
00321 Notes
00322 };
00323
00324
00325 enum Mark {
00326
00327 Completed = 0,
00328
00329 UnCompleted
00330 };
00331 };
00332
00333
00334
00335
00336 namespace ZdbDate
00337 {
00338
00339
00340 enum Fields{
00341
00342 Category = 0,
00343
00344 Description,
00345
00346 Location,
00347
00348 TimeZone,
00349
00350 Note,
00351
00352 StartDateTime,
00353
00354 EndDateTime,
00355
00356 Type,
00357
00358 Alarm,
00359
00360 AlarmTime,
00361
00362 SoundType,
00363
00364 RepeatType,
00365
00366 RepeatFrequency,
00367
00368 RepeatPosition,
00369
00370 RepeatDays,
00371
00372 RepeatHasEndDate,
00373
00374 RepeatEndDate,
00375
00376 AllDayStart,
00377
00378 AllDayEnd,
00379
00380 MultiDate,
00381 };
00382
00383
00384 enum Type {
00385
00386 Normal = 0,
00387
00388 AllDay
00389 };
00390
00391
00392 enum Alarm{
00393
00394 AlarmOn = 0,
00395
00396 AlarmOff
00397 };
00398
00399
00400 enum SoundType {
00401
00402 Silent = 0,
00403
00404 Loud
00405 };
00406
00407
00408 enum RepeatType {
00409
00410 Daily = 0,
00411
00412 Weekly,
00413
00414 MonthlyDay,
00415
00416 MonthlyDate,
00417
00418 Yearly
00419 };
00420
00421 enum Days {
00422 MON = 0x01,
00423 TUE = 0x02,
00424 WED = 0x04,
00425 THU = 0x08,
00426 FRI = 0x10,
00427 SAT = 0x20,
00428 SUN = 0x40
00429 };
00430
00431 enum MultiType {
00432 NonMulti =0,
00433 Multi
00434 };
00435 };
00436
00437
00438
00439
00440 namespace ZdbMail
00441 {
00442
00443
00444 enum Fields {
00445
00446 InternalId = 0,
00447
00448 Size,
00449
00450 MailType,
00451
00452
00453 MailRead,
00454
00455 Download,
00456
00457 OnServer,
00458
00459 ServerId,
00460
00461
00462 MailSent,
00463
00464 Modify,
00465
00466 Draft,
00467
00468
00469 SelectCheck,
00470
00471 AccountName,
00472
00473 MailBox,
00474
00475 RecvDateTime,
00476
00477 SendDateTime,
00478
00479 TimeZone,
00480
00481 FromAccount,
00482
00483 FromName,
00484
00485 From,
00486
00487 To,
00488
00489 Cc,
00490
00491 Bcc,
00492
00493 Reply,
00494
00495 Subject,
00496
00497 MailBody,
00498
00499 HtmlBody,
00500
00501
00502 EnclosureNum,
00504 ContentAttrribute,
00506 ContentType,
00507
00508 EnclosureFile,
00509
00510 Dummy
00511
00512 };
00513
00514
00515 enum Type {
00516
00517 ReadMail = 0,
00518
00519 SendMail
00520 };
00521
00522
00523 enum ReadStatus {
00524
00525 UnRead = 0,
00526
00527 Read,
00528 };
00529
00530
00531 enum SendStatus {
00532
00533 UnSent = 0,
00534
00535 Sent,
00536 };
00537
00538
00539 enum CheckStatus {
00540
00541 UnChecked = 0,
00542
00543 Checked
00544 };
00545
00546
00547 enum IsModify {
00548
00549 Modified = 0,
00550
00551 NewMail
00552 };
00553
00554
00555 enum IsDraft {
00556
00557 UnDraft = 0,
00558
00559 DraftMail
00560 };
00561
00562
00563 enum Disposal {
00564
00565 UnCompleted = 0,
00566
00567 Completed
00568 };
00569
00570 };
00571
00572 #endif