bug fix: TC-1152
[profile/ivi/ico-uxf-homescreen.git] / src / homescreen / CicoHomeScreen.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  * @brief   Home Screen
11  *
12  * @date    Aug-08-2013
13  */
14 #ifndef __CICO_HOME_SCREEN_H__
15 #define __CICO_HOME_SCREEN_H__
16 #include <stdio.h>
17 #include <pthread.h>
18 #include <libwebsockets.h>
19 #include <vector>
20 #include <string>
21
22 #include "ico_syc_common.h"
23 #include "ico_syc_winctl.h"
24 #include "ico_syc_private.h"
25
26 #include <unistd.h>
27
28 #include "CicoHomeScreenCommon.h"
29
30 #include "CicoGKeyFileConfig.h"
31 #include "CicoHSMenuWindow.h"
32 #include "CicoHSBackWindow.h"
33 #include "CicoHSControlBarWindow.h"
34 #include "CicoHSSwipeTouch.h"
35 #include "CicoHSWindowController.h"
36 #include "CicoHSAppInfo.h"
37
38 #include "CicoSystemConfig.h"
39 #include "CicoHSLifeCycleController.h"
40 #include "CicoHSAppHistory.h"
41 #include "CicoHSAppHistoryExt.h"
42
43 /* display position and size */
44 #define ICO_HS_WINDOW_POS_X 0
45 #define ICO_HS_WINDOW_POS_Y 0
46 #define ICO_HS_STATUSBAR_WINDOW_HEIGHT 64
47 #define ICO_HS_MENU_WINDOW_POS_X ICO_HS_WINDOW_POS_X
48 #define ICO_HS_MENU_WINDOW_POS_Y ICO_HS_STATUSBAR_WINDOW_HEIGHT
49 #define ICO_HS_CONTROLBAR_WINDOW_POS_X ICO_HS_WINDOW_POS_X
50 #define ICO_HS_CONTROLBAR_WINDOW_HEIGHT 128
51
52 /*mode*/
53 #define ICO_HS_MODE_MENU 0
54 #define ICO_HS_MODE_APPLICATION 1
55
56 /*hide pattern*/
57 #define ICO_HS_SHOW_HIDE_PATTERN_SLIDE 0
58 #define ICO_HS_SHOW_HIDE_PATTERN_FADE 1
59
60 #define ICO_HS_CONFIG_HOMESCREEN    "homescreen"
61 #define ICO_HS_CONFIG_ONSCREEN      "onscreen"
62 #define ICO_HS_CONFIG_SOUND         "sound"
63 #define ICO_HS_CONFIG_SB            "statusbar"
64 #define ICO_HS_CONFIG_ONS           "onscreen"
65 #define ICO_HS_APPID_DEFAULT_SB     ICO_SYC_PACKAGE_STATUSBAR   /* default statusbar appid */
66 #define ICO_HS_APPID_DEFAULT_ONS    ICO_SYC_PACKAGE_ONSCREEN    /* default on screen appid */
67
68 #define ICO_HS_GROUP_SPECIAL        "menu"
69
70 #define ICO_HS_APP_STATUS_ERR -1
71
72 #define ICO_HS_CHANGE_ZONE_MAX  10
73
74 class CicoHomeScreen
75 {
76   public:
77     CicoHomeScreen(void);
78     ~CicoHomeScreen(void);
79     static CicoHomeScreen* getInstance(void);
80     int Initialize(int orientation,CicoGKeyFileConfig *config);
81     void InitializeAppHistory(void);
82     void Finalize(void);
83     int StartRelations();
84     void CreateMenuWindow(void);
85     void DeleteMenuWindow(void);
86     void UpDateMenuWindow(void);
87     void CreateBackWindow(void);
88     void DeleteBackWindow(void);
89     void UpDateBackWindow(void);
90     void CreateControlBarWindow(void);
91     void DeleteControlBarWindow(void);
92     void CreateSwipeInputWindow(void);
93     void DeleteSwipeInputWindow(void);
94     char *GetHsPackageName(void);
95     char *GetSbPackageName(void);
96     char *GetOsPackageName(void);
97     void ShowHomeScreenLayer(void);
98     void ShowHomeScreenWindow(ico_syc_win_info_t *win_info);
99     void ShowStatusBarWindow(ico_syc_win_info_t *win_info);
100     void ShowApplicationWindow(ico_syc_win_info_t *win_info);
101     void RaiseApplicationWindow(const char *appid,int surface);
102     static void ChangeMode(int pattern);
103     static void ExecuteApp(const char *appid);
104     static void TerminateApp(const char *appid);
105     static bool GetAppStatus(const char *appid);
106     void ChangeActive(const char *appid, int surface);
107     static void ChangeZone(void);
108     void requestChangeZone(CicoHSAppInfo* appinfo);
109     static CicoHSAppInfo *GetAppInfo(const char *appid);
110     void SetMode(int mode);
111     int GetMode(void);
112     int StartHomeScreen(int orientation);
113     void UpdateTile(const char *appid);
114     static void RenewAppInfoList(void);
115
116     void setActiveApp(const char* appid);
117     // update current active application information
118     void SetActiveAppInfo(const char *appid);
119     CicoHSAppInfo* GetActiveAppInfo(void);
120
121     // update current sub displaye applicatin information
122     void SetSubDisplayAppInfo(const char *appid);
123     CicoHSAppInfo* GetSubDisplayAppInfo(void);
124     const char* GetSubDisplayAppid(void);
125     // order of the start-up window
126     void startupCheckAdd(int pid, const std::string& appid,
127                          bool bSubDisp = false);
128     void startupCheck(const char* appid);
129     void finishStartup(void);
130     void readStartupApp(std::vector<pairAppidSubd>& apps);
131     void requestHideAppid(const std::string& app);
132     void requestShowAppid(const std::string& app);
133     void requestActivationAppid(const std::string& app);
134     void controlRegulation(bool regStt=true);
135     static bool ActivationUpdate(void);
136     bool ActivationUpdate_i(void);
137     static void ShowApp(const std::string& app);
138     static void HideApp(const std::string& app);
139     static void MoveApp(const std::string& app, const std::string& zone);
140   private:
141     int GetProcessWindow(const char *appid);
142     static void EventCallBack(ico_syc_ev_e event,const void* detail,void* user_data);
143     void ExecuteApp_i(const char *appid);
144     void TerminateApp_i(const char *appid);
145     void CreateAppInfoList(void);
146     ico_hs_window_info *GetWindowInfo(CicoHSAppInfo* appinfo,const char *window);
147     ico_hs_window_info *GetWindowInfo(CicoHSAppInfo* appinfo,int surface);
148
149     static void SetNightMode(void* data);
150     static void SetRegulation(void* data);
151
152     void ShowApp_i(const std::string& app);
153     void RenewAppInfoList_i(void);
154
155     /*application control(do not use now)*/
156     int application_num;
157     CicoHSAppInfo *apps_info[ICO_HS_MAX_APP_NUM];
158     // current active application information
159     CicoHSAppInfo *active_appinfo;
160     /*application info*/
161     CicoHSAppInfo *hs_app_info;
162     CicoHSAppInfo *sb_app_info;
163     CicoHSAppInfo *os_app_info;
164     /*sizes*/
165     int full_width,full_height;
166     int menu_width,menu_height;
167     int bg_width,bg_height;
168     int ctl_bar_width,ctl_bar_height;
169     /*package names*/
170     char hs_package_name[ICO_HS_MAX_PROCESS_NAME];
171     char sb_package_name[ICO_HS_MAX_PROCESS_NAME];
172     char os_package_name[ICO_HS_MAX_PROCESS_NAME];
173     /*Window Instances*/
174     CicoHSMenuWindow* menu_window;
175     CicoHSBackWindow* back_window;
176     CicoHSControlBarWindow* ctl_bar_window;
177     int num_swipe_input_windows;
178     CicoHSSwipeInputWindow* swipe_input_windows[ICO_HS_MAX_SWIPEWINDOWS];
179     /*mode*/
180     int mode;
181     /*configuration*/
182     CicoGKeyFileConfig *config;
183     /*my instance for callback*/
184     static CicoHomeScreen *hs_instance;
185
186     CicoHSLifeCycleController* life_cycle_controller;
187     CicoHSAppHistoryExt* m_appHis;
188
189     // current sub display appinfo
190     CicoHSAppInfo *sub_display_appinfo;
191
192   public:
193     // swith trigger zone rotation list
194     const char* moveZoneName;
195
196     // move zone animation information
197     ico_syc_animation_t moveZoneAnimation;
198
199
200   protected:
201     CicoHomeScreen operator=(const CicoHomeScreen&);
202     CicoHomeScreen(const CicoHomeScreen&);
203 };
204 #endif
205 // vim:set expandtab ts=4 sw=4: