1 /** 2 * @file mega/command.h 3 * @brief Request command component 4 * 5 * (c) 2013-2014 by Mega Limited, Auckland, New Zealand 6 * 7 * This file is part of the MEGA SDK - Client Access Engine. 8 * 9 * Applications using the MEGA API must present a valid application key 10 * and comply with the the rules set forth in the Terms of Service. 11 * 12 * The MEGA SDK is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 * 16 * @copyright Simplified (2-clause) BSD License. 17 * 18 * You should have received a copy of the license along with this 19 * program. 20 */ 21 22 #ifndef MEGA_COMMAND_H 23 #define MEGA_COMMAND_H 1 24 25 #include "types.h" 26 #include "node.h" 27 #include "account.h" 28 #include "http.h" 29 30 namespace mega { 31 32 struct JSON; 33 struct MegaApp; 34 // request command component 35 class MEGA_API Command 36 { 37 static const int MAXDEPTH = 8; 38 39 char levels[MAXDEPTH]; 40 41 error result; 42 43 protected: 44 bool canceled; 45 46 string json; 47 48 public: 49 MegaClient* client; // non-owning 50 51 int tag; 52 53 char level; 54 bool persistent; 55 56 // some commands can only succeed if they are in their own batch. eg. smss, when the account is blocked pending validation 57 bool batchSeparately; 58 59 // some commands are guaranteed to work if we query without specifying a SID (eg. gmf) 60 bool suppressSID; 61 62 void cmd(const char*); 63 void notself(MegaClient*); 64 virtual void cancel(void); 65 66 void arg(const char*, const char*, int = 1); 67 void arg(const char*, const byte*, int); 68 void arg(const char*, m_off_t); 69 void addcomma(); 70 void appendraw(const char*); 71 void appendraw(const char*, int); 72 void beginarray(); 73 void beginarray(const char*); 74 void endarray(); 75 void beginobject(); 76 void beginobject(const char*); 77 void endobject(); 78 void element(int); 79 void element(handle, int = sizeof(handle)); 80 void element(const byte*, int); 81 void element(const char*); 82 83 void openobject(); 84 void closeobject(); 85 int elements(); 86 87 virtual void procresult(); 88 89 const char* getstring() const; 90 91 Command(); 92 virtual ~Command() = default; 93 94 bool checkError(Error &errorDetails, JSON &json); 95 96 MEGA_DEFAULT_COPY_MOVE(Command) 97 }; 98 99 // list of new file attributes to write 100 // file attribute put 101 struct MEGA_API HttpReqCommandPutFA : public HttpReq, public Command 102 { 103 handle th; // if th is UNDEF, just report the handle back to the client app rather than attaching to a node 104 fatype type; 105 m_off_t progressreported; 106 107 void procresult(); 108 109 // progress information 110 virtual m_off_t transferred(MegaClient*); 111 112 HttpReqCommandPutFA(MegaClient*, handle, fatype, std::unique_ptr<string> faData, bool); 113 114 private: 115 std::unique_ptr<string> data; 116 }; 117 118 class MEGA_API CommandGetFA : public Command 119 { 120 int part; 121 122 public: 123 void procresult(); 124 125 CommandGetFA(MegaClient *client, int, handle); 126 }; 127 128 class MEGA_API CommandPrelogin : public Command 129 { 130 string email; 131 132 public: 133 void procresult(); 134 135 CommandPrelogin(MegaClient*, const char*); 136 }; 137 138 class MEGA_API CommandLogin : public Command 139 { 140 bool checksession; 141 int sessionversion; 142 143 public: 144 void procresult(); 145 146 CommandLogin(MegaClient*, const char*, const byte *, int, const byte* = NULL, int = 0, const char* = NULL); 147 }; 148 149 class MEGA_API CommandSetMasterKey : public Command 150 { 151 byte newkey[SymmCipher::KEYLENGTH]; 152 string salt; 153 154 public: 155 void procresult(); 156 157 CommandSetMasterKey(MegaClient*, const byte*, const byte *, int, const byte* clientrandomvalue = NULL, const char* = NULL, string* = NULL); 158 }; 159 160 class MEGA_API CommandCreateEphemeralSession : public Command 161 { 162 byte pw[SymmCipher::KEYLENGTH]; 163 164 public: 165 void procresult(); 166 167 CommandCreateEphemeralSession(MegaClient*, const byte*, const byte*, const byte*); 168 }; 169 170 class MEGA_API CommandResumeEphemeralSession : public Command 171 { 172 byte pw[SymmCipher::KEYLENGTH]; 173 handle uh; 174 175 public: 176 void procresult(); 177 178 CommandResumeEphemeralSession(MegaClient*, handle, const byte*, int); 179 }; 180 181 class MEGA_API CommandCancelSignup : public Command 182 { 183 public: 184 void procresult(); 185 186 CommandCancelSignup(MegaClient*); 187 }; 188 189 class MEGA_API CommandWhyAmIblocked : public Command 190 { 191 public: 192 void procresult(); 193 194 CommandWhyAmIblocked(MegaClient*); 195 }; 196 197 class MEGA_API CommandSendSignupLink : public Command 198 { 199 public: 200 void procresult(); 201 202 CommandSendSignupLink(MegaClient*, const char*, const char*, byte*); 203 }; 204 205 class MEGA_API CommandSendSignupLink2 : public Command 206 { 207 public: 208 void procresult(); 209 210 CommandSendSignupLink2(MegaClient*, const char*, const char*); 211 CommandSendSignupLink2(MegaClient*, const char*, const char*, byte *, byte*, byte*); 212 }; 213 214 class MEGA_API CommandQuerySignupLink : public Command 215 { 216 string confirmcode; 217 218 public: 219 void procresult(); 220 221 CommandQuerySignupLink(MegaClient*, const byte*, unsigned); 222 }; 223 224 class MEGA_API CommandConfirmSignupLink2 : public Command 225 { 226 public: 227 void procresult(); 228 229 CommandConfirmSignupLink2(MegaClient*, const byte*, unsigned); 230 }; 231 232 class MEGA_API CommandConfirmSignupLink : public Command 233 { 234 public: 235 void procresult(); 236 237 CommandConfirmSignupLink(MegaClient*, const byte*, unsigned, uint64_t); 238 }; 239 240 class MEGA_API CommandSetKeyPair : public Command 241 { 242 public: 243 void procresult(); 244 245 CommandSetKeyPair(MegaClient*, const byte*, unsigned, const byte*, unsigned); 246 247 private: 248 std::unique_ptr<byte> privkBuffer; 249 unsigned len; 250 }; 251 252 // set visibility 253 class MEGA_API CommandRemoveContact : public Command 254 { 255 string email; 256 visibility_t v; 257 258 public: 259 void procresult(); 260 261 CommandRemoveContact(MegaClient*, const char*, visibility_t); 262 }; 263 264 // set user attributes with version 265 class MEGA_API CommandPutMultipleUAVer : public Command 266 { 267 userattr_map attrs; // attribute values 268 269 public: 270 CommandPutMultipleUAVer(MegaClient*, const userattr_map *attrs, int); 271 272 void procresult(); 273 }; 274 275 // set user attributes with version 276 class MEGA_API CommandPutUAVer : public Command 277 { 278 attr_t at; // attribute type 279 string av; // attribute value 280 281 public: 282 CommandPutUAVer(MegaClient*, attr_t, const byte*, unsigned, int); 283 284 void procresult(); 285 }; 286 287 // set user attributes 288 class MEGA_API CommandPutUA : public Command 289 { 290 attr_t at; // attribute type 291 string av; // attribute value 292 293 public: 294 CommandPutUA(MegaClient*, attr_t at, const byte*, unsigned, int, handle = UNDEF, int = 0, int64_t = 0); 295 296 void procresult(); 297 }; 298 299 class MEGA_API CommandGetUA : public Command 300 { 301 string uid; 302 attr_t at; // attribute type 303 string ph; // public handle for preview mode, in B64 304 isFromChatPreview()305 bool isFromChatPreview() { return !ph.empty(); } 306 307 public: 308 CommandGetUA(MegaClient*, const char*, attr_t, const char *, int); 309 310 void procresult(); 311 }; 312 313 #ifdef DEBUG 314 class MEGA_API CommandDelUA : public Command 315 { 316 string an; 317 318 public: 319 CommandDelUA(MegaClient*, const char*); 320 321 void procresult(); 322 }; 323 324 class MEGA_API CommandSendDevCommand : public Command 325 { 326 public: 327 void procresult(); 328 329 CommandSendDevCommand(MegaClient*, const char* command, const char* email = NULL); 330 }; 331 #endif 332 333 class MEGA_API CommandGetUserEmail : public Command 334 { 335 public: 336 void procresult(); 337 338 CommandGetUserEmail(MegaClient*, const char *uid); 339 }; 340 341 // reload nodes/shares/contacts 342 class MEGA_API CommandFetchNodes : public Command 343 { 344 public: 345 void procresult(); 346 347 CommandFetchNodes(MegaClient*, bool nocache = false); 348 }; 349 350 // update own node keys 351 class MEGA_API CommandNodeKeyUpdate : public Command 352 { 353 public: 354 CommandNodeKeyUpdate(MegaClient*, handle_vector*); 355 }; 356 357 class MEGA_API CommandShareKeyUpdate : public Command 358 { 359 public: 360 CommandShareKeyUpdate(MegaClient*, handle, const char*, const byte*, int); 361 CommandShareKeyUpdate(MegaClient*, handle_vector*); 362 }; 363 364 class MEGA_API CommandKeyCR : public Command 365 { 366 public: 367 CommandKeyCR(MegaClient*, node_vector*, node_vector*, const char*); 368 }; 369 370 class MEGA_API CommandMoveNode : public Command 371 { 372 handle h; 373 handle pp; // previous parent 374 handle np; // new parent 375 bool syncop; 376 syncdel_t syncdel; 377 378 public: 379 void procresult(); 380 381 CommandMoveNode(MegaClient*, Node*, Node*, syncdel_t, handle = UNDEF); 382 }; 383 384 class MEGA_API CommandSingleKeyCR : public Command 385 { 386 public: 387 CommandSingleKeyCR(handle, handle, const byte*, size_t); 388 }; 389 390 class MEGA_API CommandDelNode : public Command 391 { 392 handle h; 393 394 public: 395 void procresult(); 396 397 CommandDelNode(MegaClient*, handle, bool = false); 398 }; 399 400 class MEGA_API CommandDelVersions : public Command 401 { 402 public: 403 void procresult(); 404 405 CommandDelVersions(MegaClient*); 406 }; 407 408 class MEGA_API CommandKillSessions : public Command 409 { 410 handle h; 411 412 public: 413 void procresult(); 414 415 CommandKillSessions(MegaClient*, handle); 416 CommandKillSessions(MegaClient*); 417 }; 418 419 class MEGA_API CommandLogout : public Command 420 { 421 public: 422 void procresult(); 423 424 CommandLogout(MegaClient*); 425 }; 426 427 class MEGA_API CommandPubKeyRequest : public Command 428 { 429 User* u; 430 431 public: 432 void procresult(); 433 void invalidateUser(); 434 435 CommandPubKeyRequest(MegaClient*, User*); 436 }; 437 438 class MEGA_API CommandDirectRead : public Command 439 { 440 DirectReadNode* drn; 441 442 public: 443 void cancel(); 444 void procresult(); 445 446 CommandDirectRead(MegaClient *client, DirectReadNode*); 447 }; 448 449 class MEGA_API CommandGetFile : public Command 450 { 451 TransferSlot* tslot; 452 handle ph; 453 bool priv; 454 byte filekey[FILENODEKEYLENGTH]; 455 456 public: 457 void cancel(); 458 void procresult(); 459 460 CommandGetFile(MegaClient *client, TransferSlot*, const byte*, handle, bool, const char* = NULL, const char* = NULL, const char *chatauth = NULL); 461 }; 462 463 class MEGA_API CommandPutFile : public Command 464 { 465 TransferSlot* tslot; 466 467 public: 468 void cancel(void); 469 void procresult(); 470 471 CommandPutFile(MegaClient *client, TransferSlot*, int); 472 }; 473 474 class MEGA_API CommandPutFileBackgroundURL : public Command 475 { 476 string* result; 477 478 public: 479 void procresult(); 480 481 CommandPutFileBackgroundURL(m_off_t size, int putmbpscap, int ctag); 482 }; 483 484 485 class MEGA_API CommandAttachFA : public Command 486 { 487 handle h; 488 fatype type; 489 490 public: 491 void procresult(); 492 493 // use this one for attribute blobs 494 CommandAttachFA(MegaClient*, handle, fatype, handle, int); 495 496 // use this one for numeric 64 bit attributes (which must be pre-encrypted with XXTEA) 497 // multiple attributes can be added at once, encryptedAttributes format "<N>*<attrib>/<M>*<attrib>" 498 // only the fatype specified will be notified back to the app 499 CommandAttachFA(MegaClient*, handle, fatype, const std::string& encryptedAttributes, int); 500 }; 501 502 503 class MEGA_API CommandPutNodes : public Command 504 { 505 NewNode* nn; 506 int nnsize; 507 targettype_t type; 508 putsource_t source; 509 handle targethandle; 510 511 public: 512 void procresult(); 513 514 CommandPutNodes(MegaClient*, handle, const char*, NewNode*, int, int, putsource_t = PUTNODES_APP, const char *cauth = NULL); 515 }; 516 517 class MEGA_API CommandSetAttr : public Command 518 { 519 handle h; 520 string pa; 521 bool syncop; 522 523 public: 524 void procresult(); 525 526 CommandSetAttr(MegaClient*, Node*, SymmCipher*, const char* = NULL); 527 }; 528 529 class MEGA_API CommandSetShare : public Command 530 { 531 handle sh; 532 User* user; 533 accesslevel_t access; 534 string msg; 535 string personal_representation; 536 537 bool procuserresult(MegaClient*); 538 539 public: 540 void procresult(); 541 542 CommandSetShare(MegaClient*, Node*, User*, accesslevel_t, int, const char*, const char* = NULL); 543 }; 544 545 class MEGA_API CommandGetUserData : public Command 546 { 547 public: 548 void procresult(); 549 550 CommandGetUserData(MegaClient*); 551 552 protected: 553 void parseUserAttribute(std::string& value, std::string &version, bool asciiToBinary = true); 554 }; 555 556 class MEGA_API CommandGetMiscFlags : public Command 557 { 558 public: 559 void procresult(); 560 561 CommandGetMiscFlags(MegaClient*); 562 }; 563 564 class MEGA_API CommandSetPendingContact : public Command 565 { 566 opcactions_t action; 567 string temail; // target email 568 569 public: 570 void procresult(); 571 572 CommandSetPendingContact(MegaClient*, const char*, opcactions_t, const char* = NULL, const char* = NULL, handle = UNDEF); 573 }; 574 575 class MEGA_API CommandUpdatePendingContact : public Command 576 { 577 ipcactions_t action; 578 579 public: 580 void procresult(); 581 582 CommandUpdatePendingContact(MegaClient*, handle, ipcactions_t); 583 }; 584 585 class MEGA_API CommandGetUserQuota : public Command 586 { 587 AccountDetails* details; 588 bool mStorage; 589 bool mTransfer; 590 bool mPro; 591 592 public: 593 void procresult(); 594 595 CommandGetUserQuota(MegaClient*, AccountDetails*, bool, bool, bool, int source); 596 }; 597 598 class MEGA_API CommandQueryTransferQuota : public Command 599 { 600 public: 601 void procresult(); 602 603 CommandQueryTransferQuota(MegaClient*, m_off_t size); 604 }; 605 606 class MEGA_API CommandGetUserTransactions : public Command 607 { 608 AccountDetails* details; 609 610 public: 611 void procresult(); 612 613 CommandGetUserTransactions(MegaClient*, AccountDetails*); 614 }; 615 616 class MEGA_API CommandGetUserPurchases : public Command 617 { 618 AccountDetails* details; 619 620 public: 621 void procresult(); 622 623 CommandGetUserPurchases(MegaClient*, AccountDetails*); 624 }; 625 626 class MEGA_API CommandGetUserSessions : public Command 627 { 628 AccountDetails* details; 629 630 public: 631 void procresult(); 632 633 CommandGetUserSessions(MegaClient*, AccountDetails*); 634 }; 635 636 class MEGA_API CommandSetPH : public Command 637 { 638 handle h; 639 m_time_t ets; 640 641 public: 642 void procresult(); 643 644 CommandSetPH(MegaClient*, Node*, int, m_time_t); 645 }; 646 647 class MEGA_API CommandGetPH : public Command 648 { 649 handle ph; 650 byte key[FILENODEKEYLENGTH]; 651 int op; 652 bool havekey; 653 654 public: 655 void procresult(); 656 657 CommandGetPH(MegaClient*, handle, const byte*, int); 658 }; 659 660 class MEGA_API CommandPurchaseAddItem : public Command 661 { 662 public: 663 void procresult(); 664 665 CommandPurchaseAddItem(MegaClient*, int, handle, unsigned, const char*, unsigned, const char*, handle = UNDEF, int = 0, int64_t = 0); 666 }; 667 668 class MEGA_API CommandPurchaseCheckout : public Command 669 { 670 public: 671 void procresult(); 672 673 CommandPurchaseCheckout(MegaClient*, int); 674 }; 675 676 class MEGA_API CommandEnumerateQuotaItems : public Command 677 { 678 public: 679 void procresult(); 680 681 CommandEnumerateQuotaItems(MegaClient*); 682 }; 683 684 class MEGA_API CommandReportEvent : public Command 685 { 686 public: 687 void procresult(); 688 689 CommandReportEvent(MegaClient*, const char*, const char*); 690 }; 691 692 class MEGA_API CommandSubmitPurchaseReceipt : public Command 693 { 694 public: 695 void procresult(); 696 697 CommandSubmitPurchaseReceipt(MegaClient*, int, const char*, handle = UNDEF, int = 0, int64_t = 0); 698 }; 699 700 class MEGA_API CommandCreditCardStore : public Command 701 { 702 703 /* 704 'a':'ccs', // credit card store 705 'cc':<encrypted CC data of the required json format>, 706 'last4':<last four digits of the credit card number, plain text>, 707 'expm':<expiry month in the form "02">, 708 'expy':<expiry year in the form "2017">, 709 'hash':<sha256 hash of the card details in hex format> 710 */ 711 712 public: 713 void procresult(); 714 715 CommandCreditCardStore(MegaClient*, const char *, const char *, const char *, const char *, const char *); 716 }; 717 718 class MEGA_API CommandCreditCardQuerySubscriptions : public Command 719 { 720 public: 721 void procresult(); 722 723 CommandCreditCardQuerySubscriptions(MegaClient*); 724 }; 725 726 class MEGA_API CommandCreditCardCancelSubscriptions : public Command 727 { 728 public: 729 void procresult(); 730 731 CommandCreditCardCancelSubscriptions(MegaClient*, const char* = NULL); 732 }; 733 734 class MEGA_API CommandCopySession : public Command 735 { 736 public: 737 void procresult(); 738 739 CommandCopySession(MegaClient*); 740 }; 741 742 class MEGA_API CommandGetPaymentMethods : public Command 743 { 744 public: 745 void procresult(); 746 747 CommandGetPaymentMethods(MegaClient*); 748 }; 749 750 class MEGA_API CommandUserFeedbackStore : public Command 751 { 752 public: 753 void procresult(); 754 755 CommandUserFeedbackStore(MegaClient*, const char *, const char *, const char *); 756 }; 757 758 class MEGA_API CommandSendEvent : public Command 759 { 760 public: 761 void procresult(); 762 763 CommandSendEvent(MegaClient*, int, const char *); 764 }; 765 766 class MEGA_API CommandSupportTicket : public Command 767 { 768 public: 769 void procresult(); 770 771 CommandSupportTicket(MegaClient*, const char *message, int type = 1); // by default, 1:technical_issue 772 }; 773 774 class MEGA_API CommandCleanRubbishBin : public Command 775 { 776 public: 777 void procresult(); 778 779 CommandCleanRubbishBin(MegaClient*); 780 }; 781 782 class MEGA_API CommandGetRecoveryLink : public Command 783 { 784 public: 785 void procresult(); 786 787 CommandGetRecoveryLink(MegaClient*, const char *, int, const char* = NULL); 788 }; 789 790 class MEGA_API CommandQueryRecoveryLink : public Command 791 { 792 public: 793 void procresult(); 794 795 CommandQueryRecoveryLink(MegaClient*, const char*); 796 }; 797 798 class MEGA_API CommandGetPrivateKey : public Command 799 { 800 public: 801 void procresult(); 802 803 CommandGetPrivateKey(MegaClient*, const char*); 804 }; 805 806 class MEGA_API CommandConfirmRecoveryLink : public Command 807 { 808 public: 809 void procresult(); 810 811 CommandConfirmRecoveryLink(MegaClient*, const char*, const byte*, int, const byte*, const byte*, const byte*); 812 }; 813 814 class MEGA_API CommandConfirmCancelLink : public Command 815 { 816 public: 817 void procresult(); 818 819 CommandConfirmCancelLink(MegaClient *, const char *); 820 }; 821 822 class MEGA_API CommandResendVerificationEmail : public Command 823 { 824 public: 825 void procresult(); 826 827 CommandResendVerificationEmail(MegaClient *); 828 }; 829 830 class MEGA_API CommandResetSmsVerifiedPhoneNumber : public Command 831 { 832 public: 833 void procresult(); 834 835 CommandResetSmsVerifiedPhoneNumber(MegaClient *); 836 }; 837 838 class MEGA_API CommandValidatePassword : public Command 839 { 840 public: 841 void procresult(); 842 843 CommandValidatePassword(MegaClient*, const char*, uint64_t); 844 }; 845 846 class MEGA_API CommandGetEmailLink : public Command 847 { 848 public: 849 void procresult(); 850 851 CommandGetEmailLink(MegaClient*, const char*, int, const char *pin = NULL); 852 }; 853 854 class MEGA_API CommandConfirmEmailLink : public Command 855 { 856 string email; 857 bool replace; 858 public: 859 void procresult(); 860 861 CommandConfirmEmailLink(MegaClient*, const char*, const char *, const byte *, bool); 862 }; 863 864 class MEGA_API CommandGetVersion : public Command 865 { 866 public: 867 void procresult(); 868 869 CommandGetVersion(MegaClient*, const char*); 870 }; 871 872 class MEGA_API CommandGetLocalSSLCertificate : public Command 873 { 874 public: 875 void procresult(); 876 877 CommandGetLocalSSLCertificate(MegaClient*); 878 }; 879 880 #ifdef ENABLE_CHAT 881 class MEGA_API CommandChatCreate : public Command 882 { 883 userpriv_vector *chatPeers; 884 bool mPublicChat; 885 string mTitle; 886 string mUnifiedKey; 887 public: 888 void procresult(); 889 890 CommandChatCreate(MegaClient*, bool group, bool publicchat, const userpriv_vector*, const string_map *ukm = NULL, const char *title = NULL); 891 }; 892 893 class MEGA_API CommandChatInvite : public Command 894 { 895 handle chatid; 896 handle uh; 897 privilege_t priv; 898 string title; 899 900 public: 901 void procresult(); 902 903 CommandChatInvite(MegaClient*, handle, handle uh, privilege_t, const char *unifiedkey = NULL, const char *title = NULL); 904 }; 905 906 class MEGA_API CommandChatRemove : public Command 907 { 908 handle chatid; 909 handle uh; 910 911 public: 912 void procresult(); 913 914 CommandChatRemove(MegaClient*, handle, handle uh); 915 }; 916 917 class MEGA_API CommandChatURL : public Command 918 { 919 public: 920 void procresult(); 921 922 CommandChatURL(MegaClient*, handle); 923 }; 924 925 class MEGA_API CommandChatGrantAccess : public Command 926 { 927 handle chatid; 928 handle h; 929 handle uh; 930 931 public: 932 void procresult(); 933 934 CommandChatGrantAccess(MegaClient*, handle, handle, const char *); 935 }; 936 937 class MEGA_API CommandChatRemoveAccess : public Command 938 { 939 handle chatid; 940 handle h; 941 handle uh; 942 943 public: 944 void procresult(); 945 946 CommandChatRemoveAccess(MegaClient*, handle, handle, const char *); 947 }; 948 949 class MEGA_API CommandChatUpdatePermissions : public Command 950 { 951 handle chatid; 952 handle uh; 953 privilege_t priv; 954 955 public: 956 void procresult(); 957 958 CommandChatUpdatePermissions(MegaClient*, handle, handle, privilege_t); 959 }; 960 961 class MEGA_API CommandChatTruncate : public Command 962 { 963 handle chatid; 964 965 public: 966 void procresult(); 967 968 CommandChatTruncate(MegaClient*, handle, handle); 969 }; 970 971 class MEGA_API CommandChatSetTitle : public Command 972 { 973 handle chatid; 974 string title; 975 976 public: 977 void procresult(); 978 979 CommandChatSetTitle(MegaClient*, handle, const char *); 980 }; 981 982 class MEGA_API CommandChatPresenceURL : public Command 983 { 984 985 public: 986 void procresult(); 987 988 CommandChatPresenceURL(MegaClient*); 989 }; 990 991 class MEGA_API CommandRegisterPushNotification : public Command 992 { 993 public: 994 void procresult(); 995 996 CommandRegisterPushNotification(MegaClient*, int, const char*); 997 }; 998 999 class MEGA_API CommandArchiveChat : public Command 1000 { 1001 public: 1002 void procresult(); 1003 1004 CommandArchiveChat(MegaClient*, handle chatid, bool archive); 1005 1006 protected: 1007 handle mChatid; 1008 bool mArchive; 1009 }; 1010 1011 class MEGA_API CommandSetChatRetentionTime : public Command 1012 { 1013 public: 1014 void procresult(); 1015 1016 CommandSetChatRetentionTime(MegaClient*, handle , int); 1017 1018 protected: 1019 handle mChatid; 1020 }; 1021 1022 class MEGA_API CommandRichLink : public Command 1023 { 1024 public: 1025 void procresult(); 1026 1027 CommandRichLink(MegaClient *client, const char *url); 1028 }; 1029 1030 class MEGA_API CommandChatLink : public Command 1031 { 1032 public: 1033 void procresult(); 1034 1035 CommandChatLink(MegaClient*, handle chatid, bool del, bool createifmissing); 1036 1037 protected: 1038 bool mDelete; 1039 }; 1040 1041 class MEGA_API CommandChatLinkURL : public Command 1042 { 1043 public: 1044 void procresult(); 1045 1046 CommandChatLinkURL(MegaClient*, handle publichandle); 1047 }; 1048 1049 class MEGA_API CommandChatLinkClose : public Command 1050 { 1051 public: 1052 void procresult(); 1053 1054 CommandChatLinkClose(MegaClient*, handle chatid, const char *title); 1055 1056 protected: 1057 handle mChatid; 1058 string mTitle; 1059 }; 1060 1061 class MEGA_API CommandChatLinkJoin : public Command 1062 { 1063 public: 1064 void procresult(); 1065 1066 CommandChatLinkJoin(MegaClient*, handle publichandle, const char *unifiedkey); 1067 }; 1068 1069 #endif 1070 1071 class MEGA_API CommandGetMegaAchievements : public Command 1072 { 1073 AchievementsDetails* details; 1074 public: 1075 void procresult(); 1076 1077 CommandGetMegaAchievements(MegaClient*, AchievementsDetails *details, bool registered_user = true); 1078 }; 1079 1080 class MEGA_API CommandGetWelcomePDF : public Command 1081 { 1082 public: 1083 void procresult(); 1084 1085 CommandGetWelcomePDF(MegaClient*); 1086 }; 1087 1088 1089 class MEGA_API CommandMediaCodecs : public Command 1090 { 1091 public: 1092 typedef void(*Callback)(MegaClient* client, int codecListVersion); 1093 void procresult(); 1094 1095 CommandMediaCodecs(MegaClient*, Callback ); 1096 1097 private: 1098 Callback callback; 1099 }; 1100 1101 class MEGA_API CommandContactLinkCreate : public Command 1102 { 1103 public: 1104 void procresult(); 1105 1106 CommandContactLinkCreate(MegaClient*, bool); 1107 }; 1108 1109 class MEGA_API CommandContactLinkQuery : public Command 1110 { 1111 public: 1112 void procresult(); 1113 1114 CommandContactLinkQuery(MegaClient*, handle); 1115 }; 1116 1117 class MEGA_API CommandContactLinkDelete : public Command 1118 { 1119 public: 1120 void procresult(); 1121 1122 CommandContactLinkDelete(MegaClient*, handle); 1123 }; 1124 1125 class MEGA_API CommandKeepMeAlive : public Command 1126 { 1127 public: 1128 void procresult(); 1129 1130 CommandKeepMeAlive(MegaClient*, int, bool = true); 1131 }; 1132 1133 class MEGA_API CommandMultiFactorAuthSetup : public Command 1134 { 1135 public: 1136 void procresult(); 1137 1138 CommandMultiFactorAuthSetup(MegaClient*, const char* = NULL); 1139 }; 1140 1141 class MEGA_API CommandMultiFactorAuthCheck : public Command 1142 { 1143 public: 1144 void procresult(); 1145 1146 CommandMultiFactorAuthCheck(MegaClient*, const char*); 1147 }; 1148 1149 class MEGA_API CommandMultiFactorAuthDisable : public Command 1150 { 1151 public: 1152 void procresult(); 1153 1154 CommandMultiFactorAuthDisable(MegaClient*, const char*); 1155 }; 1156 1157 class MEGA_API CommandGetPSA : public Command 1158 { 1159 public: 1160 void procresult(); 1161 1162 CommandGetPSA(MegaClient*); 1163 }; 1164 1165 class MEGA_API CommandFetchTimeZone : public Command 1166 { 1167 public: 1168 void procresult(); 1169 1170 CommandFetchTimeZone(MegaClient*, const char *timezone, const char *timeoffset); 1171 }; 1172 1173 class MEGA_API CommandSetLastAcknowledged: public Command 1174 { 1175 public: 1176 void procresult(); 1177 1178 CommandSetLastAcknowledged(MegaClient*); 1179 }; 1180 1181 class MEGA_API CommandSMSVerificationSend : public Command 1182 { 1183 public: 1184 void procresult() override; 1185 1186 // don't request if it's definitely not a phone number 1187 static bool isPhoneNumber(const string& s); 1188 1189 CommandSMSVerificationSend(MegaClient*, const string& phoneNumber, bool reVerifyingWhitelisted); 1190 }; 1191 1192 class MEGA_API CommandSMSVerificationCheck : public Command 1193 { 1194 public: 1195 void procresult() override; 1196 1197 // don't request if it's definitely not a verification code 1198 static bool isVerificationCode(const string& s); 1199 1200 CommandSMSVerificationCheck(MegaClient*, const string& code); 1201 }; 1202 1203 class MEGA_API CommandGetRegisteredContacts : public Command 1204 { 1205 public: 1206 // static to be called from unit tests 1207 static void processResult(MegaApp& app, JSON& json); 1208 1209 void procresult() override; 1210 1211 CommandGetRegisteredContacts(MegaClient* client, const map<const char*, const char*>& contacts); 1212 }; 1213 1214 class MEGA_API CommandGetCountryCallingCodes : public Command 1215 { 1216 public: 1217 // static to be called from unit tests 1218 static void processResult(MegaApp& app, JSON& json); 1219 1220 void procresult() override; 1221 1222 explicit 1223 CommandGetCountryCallingCodes(MegaClient* client); 1224 }; 1225 1226 class MEGA_API CommandFolderLinkInfo: public Command 1227 { 1228 handle ph = UNDEF; 1229 public: 1230 void procresult(); 1231 1232 CommandFolderLinkInfo(MegaClient*, handle); 1233 }; 1234 1235 class MEGA_API CommandBackupPut : public Command 1236 { 1237 public: 1238 void procresult(); 1239 1240 // Register a new Sync 1241 CommandBackupPut(MegaClient* client, BackupType type, handle nodeHandle, const std::string& localFolder, const std::string& deviceId, const std::string& backupName, int state, int subState, const std::string& extraData); 1242 1243 // Update a Backup 1244 // Params that keep the same value are passed with invalid value to avoid to send to the server 1245 // Invalid values: 1246 // - type: BackupType::INVALID 1247 // - nodeHandle: UNDEF 1248 // - localFolder: nullptr 1249 // - deviceId: nullptr 1250 // - backupName: nullptr 1251 // - state: -1 1252 // - subState: -1 1253 // - extraData: nullptr 1254 CommandBackupPut(MegaClient* client, handle backupId, BackupType type, handle nodeHandle, const char* localFolder, const char* deviceId, const char* backupName, int state, int subState, const char* extraData); 1255 1256 private: 1257 bool mUpdate = false; 1258 }; 1259 1260 class MEGA_API CommandBackupRemove : public Command 1261 { 1262 public: 1263 void procresult(); 1264 1265 CommandBackupRemove(MegaClient* client, handle backupId); 1266 }; 1267 1268 class MEGA_API CommandBackupPutHeartBeat : public Command 1269 { 1270 public: 1271 void procresult(); 1272 1273 CommandBackupPutHeartBeat(MegaClient* client, handle backupId, uint8_t status, uint8_t progress, uint32_t uploads, uint32_t downloads, uint32_t ts, handle lastNode); 1274 }; 1275 1276 } // namespace 1277 1278 #endif 1279