r_bookmark.h

Go to the documentation of this file.
00001 ///
00002 /// \file       r_bookmark.h
00003 ///             Record parsing class for call logs
00004 ///
00005 
00006 /*
00007     Copyright (C) 2008-2009, Nicolas VIVIEN
00008     Copyright (C) 2005-2012, Net Direct Inc. (http://www.netdirect.ca/)
00009 
00010     This program is free software; you can redistribute it and/or modify
00011     it under the terms of the GNU General Public License as published by
00012     the Free Software Foundation; either version 2 of the License, or
00013     (at your option) any later version.
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00018 
00019     See the GNU General Public License in the COPYING file at the
00020     root directory of this project for more details.
00021 */
00022 
00023 #ifndef __BARRY_RECORD_BOOKMARK_H__
00024 #define __BARRY_RECORD_BOOKMARK_H__
00025 
00026 #include "dll.h"
00027 #include "record.h"
00028 #include <vector>
00029 #include <string>
00030 #include <stdint.h>
00031 
00032 namespace Barry {
00033 
00034 // forward declarations
00035 class IConverter;
00036 
00037 class BXEXPORT Bookmark
00038 {
00039 public:
00040         typedef Barry::UnknownsType             UnknownsType;
00041 
00042         uint8_t RecType;
00043         uint32_t RecordId;
00044 
00045         uint8_t Index;
00046 
00047         std::string Name;
00048         std::string Icon;
00049         std::string Url;
00050 
00051         enum BrowserIdentityType
00052         {
00053                 IdentityAuto = 0,
00054                 IdentityBlackBerry,
00055                 IdentityFireFox,
00056                 IdentityInternetExplorer,
00057                 IdentityUnknown
00058         };
00059         BrowserIdentityType BrowserIdentity;
00060 
00061         enum DisplayModeType
00062         {
00063                 DisplayAuto = 0,
00064                 DisplayColomn,
00065                 DisplayPage,
00066                 DisplayUnknown
00067         };
00068         DisplayModeType DisplayMode;
00069 
00070         enum JavaScriptModeType
00071         {
00072                 JavaScriptAuto = 0,
00073                 JavaScriptEnabled,
00074                 JavaScriptDisabled,
00075                 JavaScriptUnknown
00076         };
00077         JavaScriptModeType JavaScriptMode;
00078 
00079         UnknownsType Unknowns;
00080 
00081 protected:
00082         const unsigned char* ParseStruct1Field(const unsigned char *begin,
00083                 const unsigned char *end, const IConverter *ic = 0);
00084         const unsigned char* ParseStruct2(const unsigned char *begin,
00085                 const unsigned char *end, const IConverter *ic = 0);
00086 
00087 public:
00088         Bookmark();
00089         ~Bookmark();
00090 
00091         // Parser / Builder API (see parser.h / builder.h)
00092         void Validate() const;
00093         const unsigned char* ParseField(const unsigned char *begin,
00094                 const unsigned char *end, const IConverter *ic = 0);
00095         uint8_t GetRecType() const { return RecType; }
00096         uint32_t GetUniqueId() const { return RecordId; }
00097         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
00098         void ParseHeader(const Data &data, size_t &offset);
00099         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
00100         void BuildHeader(Data &data, size_t &offset) const;
00101         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
00102 
00103         // operations (common among record classes
00104         void Clear();
00105         void Dump(std::ostream &os) const;
00106         std::string GetDescription() const;
00107 
00108         // Sorting - use enough data to make the sorting as
00109         //           consistent as possible
00110         bool operator<(const Bookmark &other) const;
00111 
00112         // database name
00113         static const char * GetDBName() { return "Browser Bookmarks"; }
00114         static uint8_t GetDefaultRecType() { return 1; }
00115 
00116         // Generic Field Handle support
00117         static const FieldHandle<Bookmark>::ListT& GetFieldHandles();
00118 };
00119 
00120 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Bookmark &msg) {
00121         msg.Dump(os);
00122         return os;
00123 }
00124 
00125 } // namespace Barry
00126 
00127 #endif
00128