Profile 相关的类

加载Profile的流程

virtual class ProfileManager


ProfileManager* CreateManager();  //创建一个ProfileManagerImpl的实例
//创建、删除、切换 Profile
ProfilePtr CreateProfile(); 
viod DeleteProfile(ProfilePtr profile);   
ProfilePtr ChangeCurrentProfile(ProfilePtr profile);
ProfilePtr ChangeCurrentProfile(uint64_t vid);
//Profile 的存取方法
Profile* GetCurrentProfile();
GrandProfile*  GetGrandProfile(); //获取大账户的登录态
const ProfileList& GetAllProfiles();


</br>

class ProfileManagerImpl

ProfileManager的实现类,在哪些情况下会新增Profile?1. 首次登录 2. 加入了新的企业;

  • APP启动时,ApplicationImpl请求ProfileManage创建一个ProfileMangerImpl的实例,如果是首次登录,ProfileManagerImpl在创建的过程中,新建一个Profile 作为当前账户。
  • 如果非首次登录,ProfileManagerImpl在创建的过程中,遍历Profile文件夹,从每个子目录中加载一个账户,并从"setting.json"中读取当前账户的vid,从而找到当前账户。
  • 一个账户对应一个ProfileImpl对象,创建ProfileImpl的任务由 ProfileFactory 完成。创建一个 ProfileImpl,需要Profile文件路径(已有账户)、大账户信息(全新创建)和公司信息(如果是新加入企业)。
    • 全新创建:

//ProfileManagerImpl 的创建,从本地数据库中加载或者创建大账户和小账户
ProfileManagerImpl();

//添加、删除、切换 Profile
void AddProfile(const ProfilePtr& profile);
void RemoveProfile(ProfilePtr& profile);
ProfilePtr ChangeCurrentProfile(ProfilePtr profile);
ProfilePtr ChangeCurrentProfile(uint64_t vid);
//Profile 的存取方法
Profile* GetCurrentProfile();
GrandProfile*  GetGrandProfile(); //获取大账户的登录态
const ProfileList& GetAllProfiles();

// 作为 GrandSession 的委托,在大账户登录完拉回来企业列表之后为每个企业创建一个 Profile
void OnGetCorpList(const std::vector<CRTX::CorpBriefInfo> &corp_vec);



</br>

virtual class Profile


继承关系

class Profile : public ObserverWrapper<ProfileObserver> 
// Profile 的状态变化可以通知到 ProfileObserver

账户信息


uint64_t                            vid();
const                               CRTX::UserInfo& UserInfo(); 
const                               LoginKeys& GetLoginKeys(); //登录态
ProfileSettings*                    GetSettings();  //个人设置信息
const allconfig:systemconfig&       GetSystemInfo(); //系统配置信息
const CRTX::CorpConfig&             GetCorpInfo(); //公司配置信息

账户状态

typedef num
{
   state_InValid,
   state_Login,
   state_Logout
} State;

账户加载与反加载

void    Load();
void    UnLoad();
bool    IsLoaded();


</br>

class ProfileData

包装Profile的数据


账户加载与反加载

virtual void OnVidChange(Profile* profile) = 0; // vid 发生切换时通知观察者


</br>

class ProfileImpl


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,429评论 25 709
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,404评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,054评论 6 342
  • 早晨开车上班,途径海州花园,边开车视线边习惯性的扫视马路。对面的车道,此时没有车辆,空阔的马路上,远远地,...
    小草生月love素素阅读 1,410评论 0 2
  • 01 前天,我新写的一篇文章分享到简书的群里之后,接到一个好友申请,通过验证之后,对方直接甩过来一个链接和一句话:...
    迅图阅读 5,828评论 2 4