iberbox  2.1.0
iberbox.h
Go to the documentation of this file.
1 
10 #ifndef IBERBOX_H
11 #define IBERBOX_H
12 
13 #include <atomic>
14 #include <memory.h>
15 
16 #include "iberbox/config.h"
17 #include "iberbox/task.h"
18 #include "iberbox/action.h"
19 #include "iberbox/node.h"
20 #include "iberbox/events.h"
21 
22 #ifdef USE_SCAPIX
23 #include <scapix/bridge/object.h>
24 #endif
25 
30 namespace iberbox {
31 
36 #ifdef USE_SCAPIX
37  : public scapix::bridge::object<IberboxSettings>
38 #endif
39 {
40 public:
55  IberboxSettings(const std::string &workingDirectory);
59  virtual ~IberboxSettings();
60 
65  void setWorkingDirectory(const std::string &path);
70  std::string getWorkingDirectory();
71 
76  void setUserAgent(const std::string &userAgent);
81  std::string getUserAgent();
82 
83 private:
87  std::string mWorkingDirectory;
91  std::string mUserAgent;
92 };
93 
94 #ifdef USE_SCAPIX
95 
98 typedef std::shared_ptr<IberboxSettings> IberboxSettingsType;
99 #else
100 
104 #endif
105 
106 class Loop;
107 class ApiClient;
108 class CallbackDispatcher;
113 class Iberbox
114 #ifdef USE_SCAPIX
115  : public scapix::bridge::object<Iberbox>
116 #endif
117 {
118 public:
126  {
127  SORT_ORDER_SIZE_R = -6,
133  SORT_ORDER_NONE = 0,
140  SORT_ORDER_LAST
141  };
142 
144  {
145  LOG_LEVEL_TRACE = 0,
146  LOG_LEVEL_DEBUG = 1,
147  LOG_LEVEL_INFO = 2,
148  LOG_LEVEL_WARN = 3,
149  LOG_LEVEL_ERROR = 4,
150  LOG_LEVEL_CRITICAL = 5,
151  LOG_LEVEL_OFF = 6
152  };
153 
155  {
156  AES256_CRYPTO_SCHEME = 0,
157  AES128_CRYPTO_SCHEME = 2
158  };
159 
165  static void globalInit(const std::string &appId, int appVersion);
169  static void globalCleanup();
175  static void enableCrashHandler(std::function<void (std::string, std::string)> callback);
176 
189  static void setLogLevel(int logLevel);
190 
203  static int getLogLevel();
204 
211  Iberbox(TaskManagerType taskManager = nullptr, IberboxSettingsType settings = nullptr);
215  virtual ~Iberbox();
221  int test();
230  void inviteEmail(const std::string &email, ActionListenerType listener = nullptr);
245  void verifyEmail(const std::string &email, const std::string &firstName, const std::string &lastName, ActionListenerType listener = nullptr);
263  void createAccount(const std::string &registrationId, const std::string &name, const std::string &lastName,
264  const std::string &email, const std::string &password,
265  int pin, ActionListenerType listener = nullptr);
283  void createAccountWithCoupon(const std::string &registrationId, const std::string &name, const std::string &lastName,
284  const std::string &email, const std::string &password, int pin, const std::string &coupon,
285  ActionListenerType listener = nullptr);
305  void createAccountWithPlan(const std::string &registrationId, const std::string &name, const std::string &lastName,
306  const std::string &email, const std::string &password, int pin, const std::string &coupon, int planId,
307  ActionListenerType listener = nullptr);
318  void createAccountForCurrentUser(const std::string &coupon, ActionListenerType listener = nullptr);
334  void forgotPassword(const std::string &email, ActionListenerType listener = nullptr);
344  void changePassword(const std::string &password, ActionListenerType listener = nullptr);
354  void getRecoveryKey(ActionListenerType listener = nullptr);
365  void generate2faUrl(ActionListenerType listener = nullptr);
375  void enable2fa(int code, ActionListenerType listener = nullptr);
385  void disable2fa(int code, ActionListenerType listener = nullptr);
404  void login2fa(const std::string &login, const std::string &password, int code, ActionListenerType listener = nullptr);
413  void testRequest(ActionListenerType listener = nullptr);
431  void loginIntoAccount(const std::string &login, const std::string &password, AccountHandle account, ActionListenerType listener = nullptr);
450  void loginIntoAccount2fa(const std::string &login, const std::string &password, int code, AccountHandle accountHandle, ActionListenerType listener = nullptr);
466  void login(const std::string &login, const std::string &password, ActionListenerType listener = nullptr);
476  void resumeSession(const std::string &session, ActionListenerType listener = nullptr);
486  void newSession(ActionListenerType listener = nullptr);
499  void newSessionIntoAccount(AccountHandle accountHandle, ActionListenerType listener = nullptr);
513  void recoverAccount(const std::string &recoveryId, const std::string &login, const std::string &recoveryKey, int pin, ActionListenerType listener = nullptr);
529  void recoverAccount2fa(const std::string &recoveryId, const std::string &login, const std::string &recoveryKey, int pin, int code, ActionListenerType listener = nullptr);
530 
539  void deleteAccount(const std::string &reason, ActionListenerType listener = nullptr);
540 
550  void getNodes(ActionListenerType listener = nullptr);
559  void logout(ActionListenerType listener = nullptr);
570  void currentEmail(ActionListenerType listener = nullptr);
586  void getRootNodes(ActionListenerType listener = nullptr);
603  void getRootNode(int type, ActionListenerType listener = nullptr);
613  void getChildren(NodeHandle id, ActionListenerType listener = nullptr);
623  void getChildFiles(NodeHandle id, ActionListenerType listener = nullptr);
633  void getChildFolders(NodeHandle id, ActionListenerType listener = nullptr);
645  void getSortedChildren(NodeHandle id, int sortOrder = SORT_ORDER_DEFAULT, ActionListenerType listener = nullptr);
657  void getSortedChildFiles(NodeHandle id, int sortOrder = SORT_ORDER_DEFAULT, ActionListenerType listener = nullptr);
669  void getSortedChildFolders(NodeHandle id, int sortOrder = SORT_ORDER_DEFAULT, ActionListenerType listener = nullptr);
680  void getNodeById(NodeHandle id, ActionListenerType listener = nullptr);
691  void getNodeByPath(const std::string &path, ActionListenerType listener = nullptr);
702  void getNodePath(NodeHandle id, ActionListenerType listener = nullptr);
714  void createFolder(NodeHandle parent, const std::string &name, ActionListenerType listener = nullptr);
726  void deleteNode(NodeHandle node, ActionListenerType listener = nullptr);
738  void deleteNodePermanently(NodeHandle node, ActionListenerType listener = nullptr);
750  void renameNode(NodeHandle node, const std::string &name, ActionListenerType listener = nullptr);
763  void moveNode(NodeHandle node, NodeHandle parent, ActionListenerType listener = nullptr);
776  void copyNode(NodeHandle node, NodeHandle parent, ActionListenerType listener = nullptr);
786  void getOpenSecrets(ActionListenerType listener = nullptr);
798  void createSecret(const std::string &name, const std::string &password, ActionListenerType listener = nullptr);
810  void openSecret(const std::string &name, const std::string &password, ActionListenerType listener = nullptr);
820  void closeSecret(NodeHandle secretHandle, ActionListenerType listener = nullptr);
833  void updateSecret(NodeHandle secretHandle, const std::string &name, const std::string &password, ActionListenerType listener = nullptr);
844  void getSecretRecoveryKey(NodeHandle secretHandle, ActionListenerType listener = nullptr);
859  void recoverSecret(const std::string &recoveryKey, const std::string &newName, const std::string &newPassword, ActionListenerType listener = nullptr);
869  void deleteSecret(NodeHandle secretHandle, ActionListenerType listener = nullptr);
882  void createLink(NodeHandle node, ActionListenerType listener = nullptr);
883 
897  void createSharedDriveLink(NodeHandle node, int accessLevel, ActionListenerType listener = nullptr);
898 
907  void deleteLink(const std::string &link, ActionListenerType listener = nullptr);
908 
920  void getLinkInfo(const std::string &link, ActionListenerType listener = nullptr);
932  void getUserInfo(ActionListenerType listener = nullptr);
944  void getAccountInfo(ActionListenerType listener = nullptr);
955  void getPublicAccountInfo(AccountHandle account, ActionListenerType listener = nullptr);
966  void getPublicAccountInfoByLink(const std::string &link, ActionListenerType listener = nullptr);
986  void setAccountCryptoScheme(int cryptoScheme, ActionListenerType listener = nullptr);
987 
1002  void setInvoicingAddress(const std::string &companyName, const std::string &companyAddress, const std::string &companyAddress2,
1003  const std::string &companyID, ActionListenerType listener = nullptr);
1013  void getInvoicingInfo(ActionListenerType listener = nullptr);
1024  void downloadInvoice(int invoiceId, const std::string &path, ActionListenerType listener = nullptr);
1036  void getSessionInfo(ActionListenerType listener = nullptr);
1047  void logEvent(int eventId, ActionListenerType listener = nullptr);
1059  void logEventData(int eventId, const std::string &message, ActionListenerType listener = nullptr);
1071  void testProxy(const std::string &url, const std::string &user,
1072  const std::string &password, ActionListenerType listener = nullptr);
1080  void removeProxy(ActionListenerType listener = nullptr);
1090  void setProxy(const std::string &url, ActionListenerType listener = nullptr);
1102  void setAuthProxy(const std::string &url, const std::string &user,
1103  const std::string &password, ActionListenerType listener = nullptr);
1114  void upload(const std::string &file, NodeHandle parent, ActionListenerType listener = nullptr);
1115 
1127  void uploadWithCustomData(const std::string &file, NodeHandle parent, const std::string &customData, ActionListenerType listener = nullptr);
1128 
1139  void download(NodeHandle node, const std::string &parent, ActionListenerType listener = nullptr);
1140 
1152  void downloadWithCustomData(NodeHandle node, const std::string &parent, const std::string &customData, ActionListenerType listener = nullptr);
1153 
1164  void downloadLink(const std::string &link, const std::string &parent, ActionListenerType listener = nullptr);
1165 
1177  void downloadLinkWithCustomData(const std::string &link, const std::string &parent, const std::string &customData, ActionListenerType listener = nullptr);
1178 
1189  void downloadZip(NodeHandle node, const std::string &parent, ActionListenerType listener = nullptr);
1190 
1202  void downloadZipWithCustomData(NodeHandle node, const std::string &parent, const std::string &customData, ActionListenerType listener = nullptr);
1203 
1213  void getTransfers(ActionListenerType listener = nullptr);
1224  void getUnfinishedTransfers(int type, ActionListenerType listener = nullptr);
1235  void getTransfersByType(int type, ActionListenerType listener = nullptr);
1247  void getTransfersByStatus(int type, int status, ActionListenerType listener = nullptr);
1256  void clearFinishedTransfers(ActionListenerType listener = nullptr);
1266  void clearFinishedTransfersByType(int type, ActionListenerType listener = nullptr);
1276  void clearFinishedTransferByTag(int tag, ActionListenerType listener = nullptr);
1285  void cancelTransfers(ActionListenerType listener = nullptr);
1295  void cancelTransfersByType(int type, ActionListenerType listener = nullptr);
1305  void cancelTransferByTag(int tag, ActionListenerType listener = nullptr);
1315  void setUploadSpeedLimit(int kbps, ActionListenerType listener = nullptr);
1325  void setDownloadSpeedLimit(int kbps, ActionListenerType listener = nullptr);
1335  void getUploadSpeedLimit(ActionListenerType listener = nullptr);
1345  void getDownloadSpeedLimit(ActionListenerType listener = nullptr);
1357  void readNode(NodeHandle file, uint64_t startPositon, uint64_t size, ActionListenerType listener = nullptr);
1369  void readLink(const std::string &link, uint64_t startPositon, uint64_t size, ActionListenerType listener = nullptr);
1383  void uploadMetadata(const std::string &file, NodeHandle node, int metadataType, ActionListenerType listener = nullptr);
1397  void downloadMetadata(NodeHandle node, int metadataType, const std::string &parent, ActionListenerType listener = nullptr);
1410  void downloadPublicMetadata(const std::string &metadataInfo, int metadataType, const std::string &parent, ActionListenerType listener = nullptr);
1421  void registerDevice(const std::string &name, ActionListenerType listener = nullptr);
1432  void selectDevice(NodeHandle deviceId, ActionListenerType listener = nullptr);
1442  void getCurrentDevice(ActionListenerType listener = nullptr);
1454  void getDeviceByName(const std::string &name, ActionListenerType listener = nullptr);
1466  void getDeviceById(NodeHandle deviceId, ActionListenerType listener = nullptr);
1476  void getDevices(ActionListenerType listener = nullptr);
1488  void renameDevice(NodeHandle deviceId, const std::string &newName, ActionListenerType listener = nullptr);
1498  void deleteDevice(NodeHandle deviceId, ActionListenerType listener = nullptr);
1512  void getBackupByName(NodeHandle deviceId, const std::string &name, ActionListenerType listener = nullptr);
1524  void getBackupById(NodeHandle backupId, ActionListenerType listener = nullptr);
1534  void getActiveBackups(ActionListenerType listener = nullptr);
1545  void getBackups(NodeHandle deviceId, ActionListenerType listener = nullptr);
1571  void createBackup(const std::string &name, uint64_t startTime, const std::string cronExpr, const std::string &localPath,
1572  int maxSnapshots, int status, ActionListenerType listener = nullptr);
1584  void renameBackup(NodeHandle backupId, const std::string &newName, ActionListenerType listener = nullptr);
1607  void changeBackupSchedule(NodeHandle backupId, uint64_t startTime, std::string cronExpr, ActionListenerType listener = nullptr);
1619  void changeBackupPath(NodeHandle backupId, const std::string &localPath, ActionListenerType listener = nullptr);
1646  void modifyBackup(NodeHandle backupId, const std::string &name, uint64_t startTime, const std::string cronExpr, const std::string &localPath,
1647  int maxSnapshots, int status, ActionListenerType listener = nullptr);
1660  void changeBackupStatus(NodeHandle backupId, int status, ActionListenerType listener = nullptr);
1670  void deleteBackup(NodeHandle backupId, ActionListenerType listener = nullptr);
1681  void authorizeBackup(NodeHandle backupId, ActionListenerType listener = nullptr);
1692  void deauthorizeBackup(NodeHandle backupId, ActionListenerType listener = nullptr);
1703  void getSnapshots(NodeHandle backupId, ActionListenerType listener = nullptr);
1714  void getNextSnapshots(ActionListenerType listener = nullptr);
1726  void getNextSnapshotsForDevice(NodeHandle deviceId, ActionListenerType listener = nullptr);
1739  void getNextSnapshotsForBackup(NodeHandle backupId, int count, ActionListenerType listener = nullptr);
1750  void getNextSnapshotsForAccount(ActionListenerType listener = nullptr);
1774  void getNextSnapshotsForSchedule(uint64_t startTime, const std::string cronExpr, int count, ActionListenerType listener = nullptr);
1784  void getLastSnapshots(ActionListenerType listener = nullptr);
1796  void getLastSnapshotsForDevice(NodeHandle deviceId, ActionListenerType listener = nullptr);
1809  void getLastSnapshotsForBackup(NodeHandle backupId, int count, ActionListenerType listener = nullptr);
1820  void getLastSnapshotsForAccount(ActionListenerType listener = nullptr);
1832  void createInbox(const std::string &name, const std::string &message, ActionListenerType listener = nullptr);
1845  void setInboxInfo(NodeHandle inboxHandle, const std::string &name, const std::string &message, ActionListenerType listener = nullptr);
1857  void getInboxInfo(const std::string &inboxLink, ActionListenerType listener = nullptr);
1867  void getExternalInbox(ActionListenerType listener = nullptr);
1878  void startRecord(const std::string &inboxLink, ActionListenerType listener = nullptr);
1889  void resumeRecord(const std::string &newRecordLink, ActionListenerType listener = nullptr);
1902  void setRecordInfo(const std::string &contactInfo, const std::string &subject, const std::string &message, ActionListenerType listener = nullptr);
1903 
1917  void setEmailRecordInfo(const std::string &from, const std::string &to, const std::string &subject, const std::string &message, ActionListenerType listener = nullptr);
1918 
1928  void uploadToRecord(const std::string &file, ActionListenerType listener = nullptr);
1938  void removeFromRecord(NodeHandle fileHandle, ActionListenerType listener = nullptr);
1948  void finishRecord(ActionListenerType listener = nullptr);
1958  void removeRecord(ActionListenerType listener = nullptr);
1970  void getRecordInfo(const std::string &recordLink, ActionListenerType listener = nullptr);
1982  void setRecordStatus(NodeHandle record, uint8_t status, ActionListenerType listener = nullptr);
1994  void getSubscriptionOptions(ActionListenerType listener = nullptr);
2008  void getSubscriptionOptionsWithFeatures(int features, ActionListenerType listener = nullptr);
2018  void setSubscription(int subscriptionId, ActionListenerType listener = nullptr);
2029  void getPaymentInfo(int subscriptionId, ActionListenerType listener = nullptr);
2038  void removePaymentMethod(ActionListenerType listener = nullptr);
2048  void loginLink(const std::string &folderLink, ActionListenerType listener = nullptr);
2057  void logoutLink(ActionListenerType listener = nullptr);
2074  void generateUpdate(const std::string &appName, int version,
2075  const std::string &platform, const std::string &updateFolder,
2076  const std::string &updateUrl, const std::string &changelog,
2077  const std::string &outputFile, const std::string &privateKey,
2078  ActionListenerType listener = nullptr);
2090  void checkUpdate(const std::string &appName, int version, ActionListenerType listener = nullptr);
2103  void downloadUpdate(const std::string &appName, int version, const std::string &downloadFolder, const std::string &installFolder, ActionListenerType listener = nullptr);
2116  void installUpdate(const std::string &appName, int version, const std::string &downloadFolder, const std::string &installFolder, ActionListenerType listener = nullptr);
2117 
2128  void getReferralsInfo(ActionListenerType listener = nullptr);
2138  void getBalancesInfo(ActionListenerType listener = nullptr);
2151  void getCouponInfo(const std::string &coupon, ActionListenerType listener = nullptr);
2161  void getAccountCoupons(ActionListenerType listener = nullptr);
2173  void createResellerCoupon(const std::string &email = std::string(), ActionListenerType listener = nullptr);
2186  void createResellerCouponWithPlan(int planId, const std::string &email = std::string(), ActionListenerType listener = nullptr);
2196  void deleteCoupon(int id, ActionListenerType listener = nullptr);
2205  void addResellerCodeAsPaymentMethod(const std::string &code, ActionListenerType listener = nullptr);
2216  void addDirectDebitAsPaymentMethod(const std::string &iban, const std::string &holder, ActionListenerType listener = nullptr);
2224  void addBankTransferAsPaymentMethod(ActionListenerType listener = nullptr);
2225 
2238  void createJoinLink(const std::string &email, ActionListenerType listener = nullptr);
2239 
2255  void createJoinLinkWithAccessLevel(const std::string &email, int accessLevel, ActionListenerType listener = nullptr);
2256 
2273  void checkJoinLink(const std::string &link, const std::string &email, ActionListenerType listener = nullptr);
2289  void joinAccountWithCurrentUser(AccountHandle account, const std::string &accountKey, ActionListenerType listener = nullptr);
2311  void joinAccount(AccountHandle account, const std::string &accountKey, const std::string &registrationId,
2312  const std::string &name, const std::string &lastName, const std::string &email,
2313  const std::string &password, int pin, ActionListenerType listener = nullptr);
2324  void setDefaultAccount(AccountHandle account, ActionListenerType listener = nullptr);
2334  void revokeAccountAccessOfCurrentUser(ActionListenerType listener = nullptr);
2345  void revokeAccountAccess(UserHandle user, ActionListenerType listener = nullptr);
2356  void addContact(NodeHandle account, const std::string &contactName, ActionListenerType listener = nullptr);
2368  void modifyContact(NodeHandle contact, const std::string &contactName, ActionListenerType listener = nullptr);
2378  void removeContact(NodeHandle contact, ActionListenerType listener = nullptr);
2390  void saveInbox(NodeHandle contact, const std::string &inboxLink, const std::string &outboxName, ActionListenerType listener = nullptr);
2401  void modifySavedInbox(NodeHandle outbox, const std::string &outboxName, ActionListenerType listener = nullptr);
2411  void removeSavedInbox(NodeHandle outbox, ActionListenerType listener = nullptr);
2422  void saveSentRecord(NodeHandle outbox, const std::string &recordLink, ActionListenerType listener = nullptr);
2423 
2434  void setAccessLevel(UserHandle user, int accessLevel, ActionListenerType listener = nullptr);
2445  void createSharedDrive(const std::string &name, ActionListenerType listener = nullptr);
2457  void createVirtuallyNestedSharedDrive(NodeHandle parent, const std::string &name, ActionListenerType listener = nullptr);
2467  void deleteSharedDrive(NodeHandle sharedDrive, ActionListenerType listener = nullptr);
2477  void getSharedDriveInfo(NodeHandle sharedDrive, ActionListenerType listener = nullptr);
2487  void getSharedDrives(ActionListenerType listener = nullptr);
2499  void shareDriveWithAccountByLink(NodeHandle sharedDrive, const std::string &accountLink, ActionListenerType listener = nullptr);
2514  void shareDriveWithAccountByLinkWithAccessLevel(NodeHandle sharedDrive, const std::string &accountLink, int accessLevel, ActionListenerType listener = nullptr);
2526  void shareDriveWithAccount(NodeHandle sharedDrive, AccountHandle account, ActionListenerType listener = nullptr);
2541  void shareDriveWithAccountAndAccessLevel(NodeHandle sharedDrive, AccountHandle account, int accessLevel, ActionListenerType listener = nullptr);
2552  void unshareDriveWithAccount(NodeHandle sharedDrive, AccountHandle account, ActionListenerType listener = nullptr);
2564  void getMeetingAccess(NodeHandle sharedDrive, ActionListenerType listener = nullptr);
2574  void sendCrashReport(const std::string &file, ActionListenerType listener = nullptr);
2581  void addEventListener(EventListenerType listener);
2588  void removeEventListener(EventListenerType listener);
2595  void addActionListener(ActionListenerType listener);
2602  void removeActionListener(ActionListenerType listener);
2603 
2604 protected:
2608  static bool mInitialized;
2612  static std::string mAppId;
2616  static int mAppVersion;
2620  CallbackDispatcher *mCallbackDispatcher;
2624  ApiClient *mClient;
2628  Loop *mLoop;
2629 };
2630 
2631 }
2632 
2633 #endif // IBERBOX
std::string getWorkingDirectory()
Gets the working directory path.
The iberbox namespace.
Definition: task.h:21
LogLevelType
Definition: iberbox.h:143
void setUserAgent(const std::string &userAgent)
Sets the user agent.
CryptoSchemeType
Definition: iberbox.h:154
uint64_t NodeHandle
Definition: node.h:27
The IberboxSettings class.
Definition: iberbox.h:35
uint64_t AccountHandle
Definition: account.h:20
IberboxSettings()
IberboxSettings default constructor.
virtual ~IberboxSettings()
IberboxSettings default destructor.
SortOrderType
The SortOrderType enum.
Definition: iberbox.h:125
void setWorkingDirectory(const std::string &path)
Sets the working directory.
The Task Manager class.
Definition: task.h:27
IberboxSettings * IberboxSettingsType
IberboxSettingsType.
Definition: iberbox.h:103
std::string getUserAgent()
Gets the current user agent.
Definition: iberbox.h:135
Definition: iberbox.h:139
Definition: iberbox.h:134
The Action Listener class.
Definition: action.h:667
The Iberbox class.
Definition: iberbox.h:113
Definition: events.h:207
UserId UserHandle
Definition: user.h:34