CloudBuilder  2.8.4
Making social games is easy !
CUserManager.h
Go to the documentation of this file.
1 //
2 // CUserManager.h
3 // CloudBuilder
4 //
5 // Created by Roland Van Leeuwen on 26/04/12.
6 // Copyright (c) 2012 Clan of the Cloud. All rights reserved.
7 //
8 
9 #ifndef CloudBuilder_CUserManager_h
10 #define CloudBuilder_CUserManager_h
11 
14 #include "CotCHelpers.h"
15 #include "CHJSON.h"
16 
17 extern "C" {
18  void LaunchAuthenticate(void);
19 }
20 
21 namespace CloudBuilder
22 {
23 
24  class CCloudResult;
25 
27  void AchieveRegisterDevice(unsigned long len, const void *bytes);
45  struct FACTORY_CLS CEventListener: CotCHelpers::CRefClass {
46  virtual void onEventReceived(const char *aDomain, const CCloudResult *aEvent) = 0;
47  virtual void onEventError(eErrorCode aErrorCode, const char *aDomain, const CCloudResult *result) = 0;
48  };
49 
56  class FACTORY_CLS CUserManager {
57  public:
58 
63  static CUserManager *Instance();
64 
78  void LoginAnonymous(CResultHandler *aHandler);
79 
100  void LoginNetwork(const CotCHelpers::CHJSON* aConfiguration, CResultHandler *aHandler);
101 
115  void ResumeSession(const CotCHelpers::CHJSON* aConfiguration, CResultHandler *aHandler);
116 
125  void Logout(CResultHandler *aHandler);
126 
134  void Link(const char *aNetwork, CResultHandler *aHandler);
135 
143  void Unlink(const char *aNetwork, CResultHandler *aHandler);
144 
153  void Convert(const char *aNetwork, CResultHandler *aHandler);
154 
167  void UserExist(const char *aIdent, const char *aNetwork, CResultHandler *aHandler);
168 
182  void MailPassword(const CotCHelpers::CHJSON *aJSON, CResultHandler *aHandler);
183 
193  void ChangePassword(const char *aNewPassword, CResultHandler *aHandler);
194 
204  void ChangeEmail(const char *aNewEmail, CResultHandler *aHandler);
205 
218  void SetProfile(const CotCHelpers::CHJSON *aJson, CResultHandler *aHandler);
219 
231  void GetProfile(CResultHandler *aHandler);
232 
249  void SetProperties(CResultHandler *aHandler, const CotCHelpers::CHJSON* aPropertiesList, const char *aDomain="private");
250  DEPRECATED void SetProperties(const CotCHelpers::CHJSON* aPropertiesList, CResultHandler *aHandler);
251 
263  void GetProperties(CResultHandler *aHandler, const char *aDomain="private");
264 
265 
281  void SetProperty(CResultHandler *aHandler, const CotCHelpers::CHJSON* aProperty, const char *aDomain="private");
282 
294  void GetProperty(CResultHandler *aHandler, const char *aField, const char *aDomain="private");
295 
307  void DeleteProperty(CResultHandler *aHandler, const char *aField, const char *aDomain="private");
308 
324  void Balance(const char *aDomain, CResultHandler *aHandler);
325 
345  DEPRECATED void Transaction(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
346 
373  void TxHistory(const char *aDomain, const CotCHelpers::CHJSON *aJSONOptions, CResultHandler *aHandler);
374 
386  void KeyValueRead(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
387 
402  void KeyValueWrite(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
403 
416  void KeyValueDelete(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
417 
430  void BinaryRead(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
431 
447  void BinaryWrite(const CotCHelpers::CHJSON *aConfiguration, const void *aPointer, size_t aSize, CResultHandler *aHandler);
448 
460  void BinaryDelete(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
461 
478  void RegisterEventListener(const char *aDomain, CEventListener *aListener);
479 
486  void UnregisterEventListener(const char *aDomain, CEventListener *aListener);
487 
507  void PushEvent(const char *aDomain, const char* aGamerID, const CotCHelpers::CHJSON *aEvent, const CotCHelpers::CHJSON *aNotification, CResultHandler *aHandler);
508 
515  const char *GetDisplayName();
516 
521  const char *GetGamerID();
522 
528  const char *GetMail();
529 
548  void Publish(const char *aNetwork, const CotCHelpers::CHJSON* aMessage, CResultHandler *aHandler);
549 
559  void GetGodfatherCode(CResultHandler *aHandler, const char *aDomain="private");
560 
575  void GetGodfather(CResultHandler *aHandler, const char *aDomain="private");
576 
600  void SetGodfather(const char *aCode, const CotCHelpers::CHJSON *aOptions, CResultHandler *aHandler);
601 
615  void GetGodchildren(CResultHandler *aHandler, const char *aDomain="private");
616 
621  void Outline(CResultHandler *aHandler);
622 
628  void RegisterForNotification();
629 
660  void ListAchievements(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
661 
671  void EarnAchievement(const char *aUnit, int aIncrement = 1, const CotCHelpers::CHJSON *aGamerData = NULL, CResultHandler *aHandler = NULL);
672 
698  void TransactionExtended(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
699 
709  void SetAchievementData(const CotCHelpers::CHJSON *aConfiguration, CResultHandler *aHandler);
710 
722  void Batch(CResultHandler *aHandler, const CotCHelpers::CHJSON *aConfiguration, const CotCHelpers::CHJSON *aParameters);
723 
726 private:
727  struct PersistedLoginParams {
728  CotCHelpers::cstring mGamerId, mGamerSecret;
729  };
730  static CUserManager *mInstance;
731  // Call ReadLoginParamsFromDisk prior to use, and PersistLoginParams after finishing modify these.
732  PersistedLoginParams persistedLoginParams;
733  CGloballyKeptHandler<CResultHandler> &loginDoneHandler, &linkDoneHandler, &convertDoneHandler;
734  CGloballyKeptHandler<CResultHandler> &binaryDoneHandler;
735  CotCHelpers::cstring mDeviceOS, mDeviceToken, mAccountNetwork;
736 
737  // Not intended to be overloaded
738  CUserManager();
739  ~CUserManager();
740 
741  // Use these in combinationn with access to persistedLoginParams
742  void CommitLoginParams();
743  void ReadLoginParams(PersistedLoginParams *dest);
744 
749  void DoSetupProcesses(CResultHandler *handler);
750 
751  void LogWithGP(eErrorCode ec, const CotCHelpers::CHJSON* options);
752  void LinkWithGP(eErrorCode ec);
753 
754  void LogWithFB(const CCloudResult *result, const CotCHelpers::CHJSON* options);
755  eErrorCode LinkWithFB(eErrorCode ec, const CotCHelpers::CHJSON* details);
756 
757  void LogWithGC(const CCloudResult *result, const CotCHelpers::CHJSON *aOptions);
758  eErrorCode LinkWithGC(eErrorCode ec, const char *gcid, const char *displayname);
759 
760  void LinkWithOther(const char *networkToExclude);
761  void linkDone(const CCloudResult *res);
762 
763  void LoginAnonymousDone(CCloudResult *res);
764  void LoginDone(CCloudResult *result);
765  void LogWithFBDone(const CCloudResult *result);
766  void LogWithGPDone(const CCloudResult *result);
767  void LogWithGCDone(const CCloudResult *result);
768  void ConvertToFB(CCloudResult *result);
769  void ConvertToGP(eErrorCode code);
770  void ConvertToGC(CCloudResult *result);
771  void convertDone(const CCloudResult *res);
772  void LogoutDone(CCloudResult *result);
773 
774  bool IsAnonymousAccount();
775 
776  void binaryWriteDone(const CCloudResult *result, const void *, size_t, CResultHandler *);
777  void binaryReadDone(const CCloudResult *result, CResultHandler *aHandler);
778 
779  void didLogin(const CCloudResult *result);
780 
784  void Terminate();
785 
786  friend class CClan;
787  friend struct CFacebookGlue;
788  friend class CGooglePlusGlue;
789  friend struct singleton_holder<CUserManager>;
790  friend void ::LaunchAuthenticate(void);
791  friend void publishUserAfterPermission(int err, void *params);
792 
793  void RegisterDevice(const char *aOS, const char *aToken);
794  friend void AchieveRegisterDevice(unsigned long len, const void *bytes);
795  friend FACTORY_FCT void CUserManager_ResetAchievements(const char *domain, CResultHandler *handler);
796  };
797 
798 }
799 
800 
801 #endif
Definition: CClan.h:30
Definition: CHJSON.h:28
Definition: CUserManager.h:56
Definition: CDelegate.h:17
CDelegate< void(eErrorCode errorCode, const CCloudResult *result)> CResultHandler
Definition: CDelegate.h:107
eErrorCode
Definition: CloudBuilder.h:52
Definition: CUserManager.h:45
Definition: CClan.h:18
Definition: CotCHelpers.h:289
Definition: CotCHelpers.h:93