3a3276aebd4bebaae2d356a43686c1b0d7921561
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCUserManager.h
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 //==========================================================================
11 /**
12  *  @file   CicoSCUserManager.h
13  *
14  *  @brief  This file is definition of CicoSCUserManager class
15  */
16 //==========================================================================
17 #ifndef __CICO_SC_USER_MANAGER_H__
18 #define __CICO_SC_USER_MANAGER_H__
19
20 #include <string.h>
21 #include <vector>
22
23 //==========================================================================
24 //  Forward declaration
25 //==========================================================================
26 class CicoSCCommand;
27 class CicoSCUser;
28 class CicoSCUserConf;
29
30 typedef std::pair<int, std::string> pairPidAppid;
31
32 //==========================================================================
33 /*
34  *  @brief  This class manages control of user and access to user information
35  */
36 //==========================================================================
37 class CicoSCUserManager
38 {
39 public:
40     // get CicoSCUserManager instance
41     static CicoSCUserManager* getInstance(void);
42
43     // handle command
44     void handleCommand(const CicoSCCommand * cmd);
45
46     // load configuration file
47     int load(const std::string & confFile);
48     // initialize
49     int initialize(void);
50
51     // get information
52     const CicoSCUser* getLoginUser(void);
53     const std::vector<CicoSCUser*>& getUserList(void);
54     const std::vector<std::string>& getHomeScreenList(void);
55
56     // change user
57     void changeUser(const std::string & name, const std::string & passwd);
58
59     // dump log
60     void dumpUserList(void);
61     void dumpHomeScreenList(void);
62
63     // application daed watcher
64     bool appDeadHandler(int pid);
65 private:
66     // default constructor
67     CicoSCUserManager();
68
69     // destructor
70     ~CicoSCUserManager();
71
72     // assignment operator
73     CicoSCUserManager& operator=(const CicoSCUserManager &object);
74
75     // copy constructor
76     CicoSCUserManager(const CicoSCUserManager &object);
77
78     // callback
79     void userlistCB(const std::string & appid);
80     void lastinfoCB(const std::string & appid);
81
82     // save last user name to file
83     void saveLastUser(void);
84     // load last user name from file
85     void loadLastUser(void);
86     // load last information from file
87     void loadLastInfo(void);
88
89     // set login user info from config file
90     void setLoginUser(const boost::property_tree::ptree & root);
91     // create list from config file
92     void createUserList(const boost::property_tree::ptree & root);
93     void createHomeScreenList(const boost::property_tree::ptree & root);
94
95     // set application's last information
96     void setLastInfo(const std::string & appid, const std::string & info);
97
98     // find user config by user name
99     const CicoSCUser* findUserConfbyName(const std::string & name);
100
101     // Imprinting to file, that file is application's running information 
102     bool impritingLastApps(const std::string& ofnm);
103
104     // Killing running application and homeScreen
105     bool killingAppsAndHS(const std::string& usrnm);
106
107     // working user directory make
108     void getWorkingDir(const std::string& usr, std::string& dir);
109
110     // launch homescreen request
111     bool launchHomescreenReq(const std::string& usr,
112                              const std::string& appid_hs);
113
114     // flag file control
115     void flagFileOn(const char* text = NULL);
116     void flagFileOff();
117
118 private:
119     static CicoSCUserManager*   ms_myInstance;  ///< CicoSCUserManager Object
120
121     std::string                 m_login;           ///< Login User Name
122     std::vector<CicoSCUser*>    m_userList;        ///< User List
123     std::vector<std::string>    m_homescreenList;  ///< HomeScreen List
124     std::string                 m_parentDir;       ///  login-user use directory
125     const CicoSCUserConf*       m_uConfig;
126     std::string                 m_flagPath;        ///  history save control flag file
127     std::vector<pairPidAppid>   m_vppa;            ///  app dead watcher
128     bool                        m_wait;            ///  app dead wait flag
129     std::string                 m_waitName;        ///  wait backup login name
130     std::string                 m_waitHS;          ///  wait backup homescreen appid
131 };
132 #endif  // __CICO_SC_USER_MANAGER_H__
133 // vim:set expandtab ts=4 sw=4: