iberbox  2.1.0
node.h
Go to the documentation of this file.
1 
10 #ifndef NODE_H
11 #define NODE_H
12 
13 #include "iberbox/config.h"
14 #ifdef USE_SCAPIX
15 #include <scapix/bridge/object.h>
16 #endif
17 
18 #include <memory>
19 #include <vector>
20 #include <string>
21 #include "iberbox/error.h"
22 #include "account.h"
23 
24 #ifdef EMSCRIPTEN
25 typedef std::string NodeHandle;
26 #else
27 typedef uint64_t NodeHandle;
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,
147  META_LAST
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 
159  virtual ~NodeData();
160 
165  uint64_t getId() const;
171  int getType() const;
177  std::vector<uint8_t> *getKey() const;
183  std::vector<uint8_t> *getSparseHash() const;
189  std::vector<uint8_t> *getFullHash() const;
195  std::vector<uint8_t> *getFingerprint() const;
201  std::string getHumanKey() const;
207  std::string getHumanHash() const;
213  std::string getMetadataInfo() const;
219  uint64_t getSize() const;
225  const char *getName() const;
231  const std::string getNameString() const;
237  uint64_t getNumericId() const;
243  const NodeHandle &getHandle() const;
249  const std::string getBase64Handle() const;
255  const NodeHandle &getVirtualParentHandle() const;
261  const NodeHandle &getParentHandle() const;
267  uint64_t getParentId() const;
273  uint64_t getFilesystem() const;
279  uint64_t getCreationTime() const;
285  uint64_t getModificationtime() const;
291  unsigned getCrypto() const;
299  bool hasMetadataType(int type);
306  uint8_t getMetadataServer(int type);
313  uint64_t getMetadataHandle(int type);
319  const char *getDevice() const;
325  const std::string getDeviceNameString() const;
331  uint64_t getStartTime() const;
337  uint64_t getFinishTime() const;
343  uint8_t getFolderCount() const;
349  uint8_t getFileCount() const;
355  uint8_t getTransferErrorCount() const;
361  const char *getCronExpr() const;
367  const std::string getCronExprString() const;
373  const char *getLocalPath() const;
379  const std::string getLocalPathString() const;
385  int getMaxSnapshots() const;
391  int getStatus() const;
398  bool isEnabled() const;
405  bool isPending() const;
411  const char *getMessage() const;
417  const std::string getMessageString() const;
418  std::vector<uint8_t> *getInboxKey() const;
424  const char *getInboxMessage() const;
430  const std::string getInboxMessageString() const;
436  const char *getRecordContactInfo() const;
442  const std::string getRecordContactInfoString() const;
447  const char *getRecordInboxName() const;
452  const std::string getRecordInboxNameString() const;
458  const char *getRecordSubject() const;
464  const std::string getRecordSubjectString() const;
470  const char *getRecordMessage() const;
476  const std::string getRecordMessageString() const;
481  uint64_t getContactAccountId() const;
486  NodeHandle getContactAccountHandle() const;
491  const char *getOutboxInboxLink() const;
496  const std::string getOutboxInboxLinkString() const;
501  const char *getRecordLink() const;
507  const std::string getRecordLinkString() const;
512  uint64_t getExtraNumber() const;
517  std::vector<uint8_t> *getExtraData() const;
518  std::vector<uint8_t> *getPublicHandle() const;
524  AccountHandle getSourceHandle() const;
529  uint8_t getDepth() const;
535  bool isRoot() const;
542  bool isMultipleRoot() const;
548  bool isFile() const;
554  bool isFolder() const;
560  bool isPublic() const;
566  bool isFull() const;
573  bool isExternal() const;
574  int getErrorType() const;
575  const char* getErrorName() const;
576  const std::string getErrorNameString() const;
577 #ifndef USE_SCAPIX
578  Error getError() const;
579 #endif
580 
581  static const uint64_t INVALID_ID;
583  static const unsigned DEFAULT_CRYPTO;
584  static const std::string INVALID_NAME;
585  static const uint8_t METADATA_SIZE;
586 
587 protected:
588 
589  NodeData();
590  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,
591  const std::vector<uint8_t> *sparseHash, const std::vector<uint8_t> *fullHash, uint64_t size, uint64_t parentId, uint64_t filesystemId,
592  uint64_t creationTime, uint64_t modificationTime, BackupInfo *backupInfo, SnapshotInfo *snapshotInfo, InboxInfo *inboxInfo, RecordInfo *recordInfo,
593  uint64_t extraNumber, std::vector<uint8_t> *extraData, std::vector<uint8_t> *publicHandle, bool isPublic, bool isFull, bool isExternal);
594 
595  uint64_t mId;
596  int mType;
597  char *mName;
598  std::vector<uint8_t> *mKey;
599 
600  //<type:8><server:8><handle:64><type:8><server:8><handle:64>...
601  uint8_t *mMetadata;
602  //Number of metadata triplets
603  uint8_t mNumMetadata;
604 
605  std::vector<uint8_t> *mSparseHash;
606  std::vector<uint8_t> *mFullHash;
607 
608  std::string mHandle;
609  std::string mParentHandle;
610  uint64_t mSize;
611  uint64_t mParentId;
612  uint64_t mFilesystem;
613  uint64_t mCreationTime;
614  uint64_t mModificationTime;
615  uint8_t mCrypto;
616  bool mPublic;
617  bool mIsFull;
618  uint64_t mExtraNumber;
619  std::vector<uint8_t> *mExtraData;
620  std::vector<uint8_t> *mPublicHandle;
621  uint8_t mDepth;
622  bool mIsExternal;
623  Error mError;
624 
625  BackupInfo *mBackupInfo;
626  SnapshotInfo *mSnapshotInfo;
627  InboxInfo *mInboxInfo;
628  RecordInfo *mRecordInfo;
629 };
630 
631 typedef std::shared_ptr<NodeData> Node;
632 typedef std::vector<Node> NodeDataList;
633 typedef std::shared_ptr<NodeDataList> NodeList;
634 
635 typedef std::vector<int64_t> NumberVector;
636 typedef std::shared_ptr<NumberVector> NumberList;
637 
638 typedef std::vector<std::string> StringVector;
639 typedef std::shared_ptr<StringVector> StringList;
640 
641 }
642 
643 #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:585
static const std::string INVALID_NAME
Definition: node.h:584
uint64_t mFileCount
Definition: node.h:59
std::vector< Node > NodeDataList
Definition: node.h:632
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:27
Definition: node.h:121
Definition: node.h:116
std::shared_ptr< NodeData > Node
Definition: node.h:631
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
uint64_t AccountHandle
Definition: account.h:20
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:633
RecordStatus
Definition: node.h:82
char * mMessage
Definition: node.h:95
std::vector< std::string > StringVector
Definition: node.h:638
Definition: node.h:68
static const NodeHandle INVALID_HANDLE
Definition: node.h:582
std::shared_ptr< StringVector > StringList
Definition: node.h:639
char * mCronExpr
Definition: node.h:63
unsigned mMaxSnapshots
Definition: node.h:47
char * mLocalPath
Definition: node.h:64
The error class.
Definition: error.h:25
Definition: node.h:135
std::vector< int64_t > NumberVector
Definition: node.h:635
Definition: node.h:115
Definition: node.h:125
Definition: node.h:137
char * mContactInfo
Definition: node.h:93
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:636
static const unsigned DEFAULT_CRYPTO
Definition: node.h:583
Definition: node.h:118
static const uint64_t INVALID_ID
Definition: node.h:581
uint64_t mStartTime
Definition: node.h:61
BackupStatus
The backup status enum.
Definition: node.h:153