# 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-2011, 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         const unsigned char* ParseField(const unsigned char *begin,
    00093                 const unsigned char *end, const IConverter *ic = 0);
    00094         uint8_t GetRecType() const { return RecType; }
    00095         uint32_t GetUniqueId() const { return RecordId; }
    00096         void SetIds(uint8_t Type, uint32_t Id) { RecType = Type; RecordId = Id; }
    00097         void ParseHeader(const Data &data, size_t &offset);
    00098         void ParseFields(const Data &data, size_t &offset, const IConverter *ic = 0);
    00099         void BuildHeader(Data &data, size_t &offset) const;
    00100         void BuildFields(Data &data, size_t &offset, const IConverter *ic = 0) const;
    00101
    00102         // operations (common among record classes
    00103         void Clear();
    00104         void Dump(std::ostream &os) const;
    00105         std::string GetDescription() const;
    00106
    00107         // Sorting - use enough data to make the sorting as
    00108         //           consistent as possible
    00109         bool operator<(const Bookmark &other) const;
    00110
    00111         // database name
    00112         static const char * GetDBName() { return "Browser Bookmarks"; }
    00113         static uint8_t GetDefaultRecType() { return 1; }
    00114 };
    00115
    00116 BXEXPORT inline std::ostream& operator<<(std::ostream &os, const Bookmark &msg) {
    00117         msg.Dump(os);
    00118         return os;
    00119 }
    00120
    00121 } // namespace Barry
    00122
    00123 #endif
    00124