00001 #ifndef __NEWS_OBJECT__ 00002 #define __NEWS_OBJECT__ 00003 00014 #include <sys/time.h> 00015 class NewsObject 00016 { 00017 public: 00018 NewsObject(unsigned long len, const unsigned char *buf, 00019 struct timeval *creation_time); 00020 ~NewsObject(); 00021 00022 typedef enum 00023 { 00024 MENU, 00025 PLAIN_TEXT, 00026 TITLE_ONLY, 00027 LIST 00028 } object_type_id_t; 00029 00030 unsigned long getObjectId(); 00031 struct timeval getReceptionTime(); 00032 struct timeval getCreationTime(); 00033 void setReceptionTime(struct timeval *time); 00034 bool isStatic(); 00035 bool isCompressed(); 00036 void setUpdateFlag(); 00037 bool isUpdated(); 00038 unsigned char getRevisionIndex(); 00039 object_type_id_t getObjectType(); 00040 void copyNml(unsigned long *len, unsigned char *nml); 00041 00042 private: 00043 enum { MAX_NML_BYTES=2044 }; 00044 unsigned long d_object_id; 00045 object_type_id_t d_object_type; 00046 bool d_static_flag; 00047 bool d_compressed_flag; 00048 unsigned char d_revision_index; 00049 00050 unsigned long d_len; 00051 unsigned char d_nml[MAX_NML_BYTES]; 00052 00053 struct timeval d_creation_time; 00054 struct timeval d_reception_time; 00055 00056 // that flag is set if an object with the same 00057 // object id existed previously. 00058 // It is needed to determine wether an object is 00059 // first received or updated. 00060 bool d_obj_updated; 00061 00062 object_type_id_t convertObjectType(unsigned char in); 00063 }; 00064 00065 #endif