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