iberbox  2.1.2
node.h
Go to the documentation of this file.
1 
10 #ifndef NODE_H
11 #define NODE_H
12 
13 #ifdef USE_SCAPIX
14 #include <scapix/bridge/object.h>
15 #endif
16 
17 #include <memory>
18 #include <vector>
19 #include <string>
20 #include "iberbox/error.h"
21 
22 #ifdef EMSCRIPTEN
23 typedef std::string NodeHandle;
24 typedef std::string AccountHandle;
25 #else
26 typedef uint64_t NodeHandle;
27 typedef uint64_t AccountHandle;
28 #endif
29 
30 #ifdef USE_SCAPIX
31 #include <scapix/bridge/object.h>
32 #endif
33 
34 namespace iberbox {
35 
37 {
38 public:
39  BackupInfo();
40  BackupInfo(BackupInfo *info);
41  virtual ~BackupInfo();
42 
43  char *mDevice;
44  uint64_t mStartTime;
45  char *mCronExpr;
46  char *mLocalPath;
47  unsigned mMaxSnapshots;
48  uint8_t mStatus;
49 };
50 
52 {
53 public:
54  SnapshotInfo();
56  virtual ~SnapshotInfo();
57 
58  uint64_t mFolderCount;
59  uint64_t mFileCount;
61  uint64_t mStartTime;
62  uint64_t mFinishTime;
63  char *mCronExpr;
64  char *mLocalPath;
65  uint8_t mStatus;
66 };
67 
68 class InboxInfo
69 {
70 public:
71  InboxInfo();
72  InboxInfo(InboxInfo *info);
73  virtual ~InboxInfo();
74 
75  char *mMessage;
76  std::vector<uint8_t> *mKey;
77 };
78 
80 {
81 public:
83  {
87  };
88 
89  RecordInfo();
90  RecordInfo(RecordInfo *info);
91  virtual ~RecordInfo();
92 
93  char *mContactInfo;
94  char *mTarget;
95  char *mMessage;
96 };
97 
98 class NodeData
99 #ifdef USE_SCAPIX
100  : public scapix::bridge::object<NodeData>
101 #endif
102 {
103 public:
107  enum NodeType
108  {
109  INVALID = -1,
110 
111  // Root node types
112  CLOUD_ROOT = 0,
122 
123  // Regular node types
124  FILE = 20,
127 
128  // Special node types
129  DEVICE = 40,
138  };
139 
144  META_SIGNATURE = 0,
145  META_THUMBNAIL = 1,
146  META_PREVIEW = 2,
148  };
149 
154  BACKUP_STATUS_ENABLED = 0x00,
155  BACKUP_STATUS_DISABLED = 0x01,
156  BACKUP_STATUS_PENDING = 0x02, // Implies BACKUP_STATUS_ENABLED (bit0 = 0)
157  };
158 
162  enum TagType {
163  TAG_UNSET = 0, //> 0
164  TAG_PERSONAL = 1, //> 1
165  TAG_PUBLIC = 2, //> 2
166  TAG_GENERAL = 3, //> 3
167  TAG_CONFIDENTIAL = 4, //> 4
168  TAG_HIGHLY_CONFIDENTIAL = 5, //> 5
170  };
171 
172  virtual ~NodeData();
173 
178  uint64_t getId() const;
184  int getType() const;
190  std::vector<uint8_t> *getKey() const;
196  std::vector<uint8_t> *getSparseHash() const;
202  std::vector<uint8_t> *getFullHash() const;
208  std::vector<uint8_t> *getFingerprint() const;
214  std::string getHumanKey() const;
220  std::string getHumanHash() const;
226  std::string getMetadataInfo() const;
232  uint64_t getSize() const;
238  const char *getName() const;
244  const std::string getNameString() const;
250  uint64_t getNumericId() const;
256  const NodeHandle &getHandle() const;
262  const std::string getBase64Handle() const;
268  const NodeHandle &getVirtualParentHandle() const;
274  const NodeHandle &getParentHandle() const;
280  uint64_t getParentId() const;
286  uint64_t getFilesystem() const;
292  uint64_t getCreationTime() const;
298  uint64_t getModificationtime() const;
304  unsigned getCrypto() const;
312  bool hasMetadataType(int type);
319  uint8_t getMetadataServer(int type);
326  uint64_t getMetadataHandle(int type);
332  const char *getDevice() const;
338  const std::string getDeviceNameString() const;
344  uint64_t getStartTime() const;
350  uint64_t getFinishTime() const;
356  uint64_t getFolderCount() const;
362  uint64_t getFileCount() const;
368  uint64_t getTransferErrorCount() const;
374  const char *getCronExpr() const;
380  const std::string getCronExprString() const;
386  const char *getLocalPath() const;
392  const std::string getLocalPathString() const;
398  int getMaxSnapshots() const;
404  int getStatus() const;
411  bool isEnabled() const;
418  bool isPending() const;
424  const char *getMessage() const;
430  const std::string getMessageString() const;
431  std::vector<uint8_t> *getInboxKey() const;
437  const char *getInboxMessage() const;
443  const std::string getInboxMessageString() const;
449  const char *getRecordContactInfo() const;
455  const std::string getRecordContactInfoString() const;
460  const char *getRecordInboxName() const;
465  const std::string getRecordInboxNameString() const;
471  const char *getRecordSubject() const;
477  const std::string getRecordSubjectString() const;
483  const char *getRecordMessage() const;
489  const std::string getRecordMessageString() const;
494  uint64_t getContactAccountId() const;
499  AccountHandle getContactAccountHandle() const;
504  const char *getOutboxInboxLink() const;
509  const std::string getOutboxInboxLinkString() const;
514  const char *getRecordLink() const;
520  const std::string getRecordLinkString() const;
525  uint64_t getExtraNumber() const;
530  std::vector<uint8_t> *getExtraData() const;
531  std::vector<uint8_t> *getPublicHandle() const;
537  AccountHandle getSourceHandle() const;
542  uint8_t getDepth() const;
547  uint8_t getTag() const;
553  bool isRoot() const;
560  bool isMultipleRoot() const;
566  bool isFile() const;
572  bool isFolder() const;
578  bool isPublic() const;
584  bool isFull() const;
591  bool isArchived() const;
598  bool isExternal() const;
605  bool isSynced() const;
606  int getErrorType() const;
607  const char* getErrorName() const;
608  const std::string getErrorNameString() const;
609 #ifndef USE_SCAPIX
610  Error getError() const;
611 #endif
612 
613  static const uint64_t INVALID_ID;
615  static const unsigned DEFAULT_CRYPTO;
616  static const std::string INVALID_NAME;
617  static const uint8_t METADATA_SIZE;
618 
619 protected:
620 
621  NodeData();
622  NodeData(uint64_t id, int type, const char *name, uint8_t crypto, const std::vector<uint8_t> *key, const uint8_t *metadata, size_t metadataSize,
623  const std::vector<uint8_t> *sparseHash, const std::vector<uint8_t> *fullHash, uint64_t size, uint64_t parentId, uint64_t filesystemId,
624  uint64_t creationTime, uint64_t modificationTime, BackupInfo *backupInfo, SnapshotInfo *snapshotInfo, InboxInfo *inboxInfo, RecordInfo *recordInfo,
625  uint64_t extraNumber, std::vector<uint8_t> *extraData, std::vector<uint8_t> *publicHandle, bool isPublic, bool isFull, bool isExternal, bool isSynced, uint8_t tag);
626 
627  uint64_t mId;
628  int mType;
629  char *mName;
630  std::vector<uint8_t> *mKey;
631 
632  //<type:8><server:8><handle:64><type:8><server:8><handle:64>...
633  uint8_t *mMetadata;
634  //Number of metadata triplets
635  uint8_t mNumMetadata;
636 
637  std::vector<uint8_t> *mSparseHash;
638  std::vector<uint8_t> *mFullHash;
639 
640  std::string mHandle;
641  std::string mParentHandle;
642  uint64_t mSize;
643  uint64_t mParentId;
644  uint64_t mFilesystem;
645  uint64_t mCreationTime;
646  uint64_t mModificationTime;
647  uint8_t mCrypto;
648  bool mPublic;
649  bool mIsFull;
650  uint64_t mExtraNumber;
651  std::vector<uint8_t> *mExtraData;
652  std::vector<uint8_t> *mPublicHandle;
653  uint8_t mDepth;
654  uint8_t mTag;
655  bool mIsSynced;
656  bool mIsExternal;
657  uint8_t mStatus;
658  Error mError;
659 
660  BackupInfo *mBackupInfo;
661  SnapshotInfo *mSnapshotInfo;
662  InboxInfo *mInboxInfo;
663  RecordInfo *mRecordInfo;
664 };
665 
666 typedef std::shared_ptr<NodeData> Node;
667 typedef std::vector<Node> NodeDataList;
668 typedef std::shared_ptr<NodeDataList> NodeList;
669 
670 typedef std::vector<int64_t> NumberVector;
671 typedef std::shared_ptr<NumberVector> NumberList;
672 
673 typedef std::vector<std::string> StringVector;
674 typedef std::shared_ptr<StringVector> StringList;
675 
676 }
677 #endif // NODE_H
MetadataType
The metadata type enum.
Definition: node.h:143
Definition: node.h:131
Definition: node.h:134
static const uint8_t METADATA_SIZE
Definition: node.h:617
static const std::string INVALID_NAME
Definition: node.h:616
uint64_t mFileCount
Definition: node.h:59
std::vector< Node > NodeDataList
Definition: node.h:667
uint64_t mStartTime
Definition: node.h:44
char * mDevice
Definition: node.h:43
Definition: node.h:84
The iberbox namespace.
Definition: task.h:21
Definition: node.h:51
Definition: node.h:114
Definition: node.h:113
char * mCronExpr
Definition: node.h:45
Definition: node.h:136
Definition: node.h:98
uint64_t NodeHandle
Definition: node.h:26
Definition: node.h:121
Definition: node.h:116
uint64_t AccountHandle
Definition: node.h:27
std::shared_ptr< NodeData > Node
Definition: node.h:666
uint8_t mStatus
Definition: node.h:48
Definition: node.h:119
std::vector< uint8_t > * mKey
Definition: node.h:76
char * mMessage
Definition: node.h:75
char * mTarget
Definition: node.h:94
uint64_t mTransferErrorCount
Definition: node.h:60
Definition: node.h:79
Definition: node.h:133
uint8_t mStatus
Definition: node.h:65
uint64_t mFinishTime
Definition: node.h:62
char * mLocalPath
Definition: node.h:46
Definition: node.h:85
Definition: node.h:126
Definition: node.h:132
std::shared_ptr< NodeDataList > NodeList
Definition: node.h:668
RecordStatus
Definition: node.h:82
char * mMessage
Definition: node.h:95
std::vector< std::string > StringVector
Definition: node.h:673
Definition: node.h:68
static const NodeHandle INVALID_HANDLE
Definition: node.h:614
std::shared_ptr< StringVector > StringList
Definition: node.h:674
char * mCronExpr
Definition: node.h:63
unsigned mMaxSnapshots
Definition: node.h:47
char * mLocalPath
Definition: node.h:64
Definition: node.h:147
Definition: node.h:169
The error class.
Definition: error.h:25
Definition: node.h:135
std::vector< int64_t > NumberVector
Definition: node.h:670
Definition: node.h:115
Definition: node.h:125
Definition: node.h:137
char * mContactInfo
Definition: node.h:93
TagType
The tag type enum.
Definition: node.h:162
Definition: node.h:130
NodeType
The node type enum.
Definition: node.h:107
uint64_t mFolderCount
Definition: node.h:58
Definition: node.h:36
std::shared_ptr< NumberVector > NumberList
Definition: node.h:671
static const unsigned DEFAULT_CRYPTO
Definition: node.h:615
Definition: node.h:118
static const uint64_t INVALID_ID
Definition: node.h:613
uint64_t mStartTime
Definition: node.h:61
BackupStatus
The backup status enum.
Definition: node.h:153