| 1 | #include "DST_Window.h" |
|---|
| 2 | #include "DST_WinManager.h" |
|---|
| 3 | #include "DST_DataStrings.h" |
|---|
| 4 | #include "DST_CommonAPI.h" |
|---|
| 5 | #include "DST_EEPROM.h" |
|---|
| 6 | #include "DST_ChannelTune.h" |
|---|
| 7 | #include "DST_UserInterface.h" |
|---|
| 8 | #include "DST_Updates.h" |
|---|
| 9 | #include "DST_ISDBT_ChannelTask.h" |
|---|
| 10 | //#include "DST_OTC_Main.h" |
|---|
| 11 | #include "DST_OSDImage.h" |
|---|
| 12 | |
|---|
| 13 | #if 0 |
|---|
| 14 | ____CMessageWin___() |
|---|
| 15 | #endif |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | char* DST_GetAppShortVersion(); |
|---|
| 19 | |
|---|
| 20 | |
|---|
| 21 | class COTCDownLoadingWin : public CWindow |
|---|
| 22 | { |
|---|
| 23 | private: |
|---|
| 24 | bool bDone; |
|---|
| 25 | bool bNeedLine; |
|---|
| 26 | int progress; |
|---|
| 27 | int center_pos; |
|---|
| 28 | int line_spacing; |
|---|
| 29 | |
|---|
| 30 | int nBlock; |
|---|
| 31 | int nErr; |
|---|
| 32 | int ErrCategory; |
|---|
| 33 | int category; |
|---|
| 34 | public: |
|---|
| 35 | COTCDownLoadingWin(SWinEventMsg event):CWindow(event) |
|---|
| 36 | { |
|---|
| 37 | |
|---|
| 38 | DST_g_RFUpdateState = 0; |
|---|
| 39 | rect.w = 382; |
|---|
| 40 | rect.h = 241; |
|---|
| 41 | rect.x = (DST_GetScreenWidth() - rect.w) / 2; |
|---|
| 42 | rect.y = (DST_GetScreenHeight()- rect.h) / 2; |
|---|
| 43 | |
|---|
| 44 | DST_Printf("\n\n--------------------------WIN_OTC_DOWNLOADING----------------------------------\n\n"); |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | center_pos = rect.h / 2; |
|---|
| 48 | line_spacing = DST_GetFontHeight(fontItemSize) * 125 / 100; |
|---|
| 49 | |
|---|
| 50 | nErr = 0; |
|---|
| 51 | ErrCategory = 0; |
|---|
| 52 | category = 0; |
|---|
| 53 | bNeedLine = false; |
|---|
| 54 | SetTimeOut(0); |
|---|
| 55 | bDone = false; |
|---|
| 56 | progress = 0; |
|---|
| 57 | |
|---|
| 58 | SetTimeOut(0); |
|---|
| 59 | SetTimer(1, 5*60*DST_OS_GetTicksPerSecond()); |
|---|
| 60 | |
|---|
| 61 | // DHL_POWER_SetMode(nSleepState ? 2 : 0); |
|---|
| 62 | } |
|---|
| 63 | virtual void KeyInput(DS_U8 key, bool /*bRepeat*/) |
|---|
| 64 | { |
|---|
| 65 | switch (key) |
|---|
| 66 | { |
|---|
| 67 | case VK_PWR: |
|---|
| 68 | if (DST_g_PowerOn) // ÄÑÁø»óÅÂ |
|---|
| 69 | { |
|---|
| 70 | DST_g_PowerOn = false; |
|---|
| 71 | } |
|---|
| 72 | else // ²¨Áø»óÅ |
|---|
| 73 | { |
|---|
| 74 | DST_g_PowerOn = true; |
|---|
| 75 | } |
|---|
| 76 | DHL_POWER_Display(DST_g_PowerOn); |
|---|
| 77 | break; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | void DrawProgressBar(DS_U32 nPos, DS_U32 nTotal, int x, int y, DS_U32 width) |
|---|
| 81 | { |
|---|
| 82 | // DST_Printf("nPos:%d, x:%d, y:%d, width:%d, p:%d, nTotal:%d\n",nPos,x/10,y,width,(nPos*width)/nTotal, nTotal); |
|---|
| 83 | |
|---|
| 84 | DrawBox32(x, y, width, 10, CONV32_16(0xffe5e5ff)); |
|---|
| 85 | if(nPos == nTotal) |
|---|
| 86 | DrawBox32(x, y, width, 10, CONV32_16(0xff65a5cc)); |
|---|
| 87 | else |
|---|
| 88 | DrawBox32(x, y, (nPos*width)/nTotal, 10, CONV32_16(0xff65a5cc)); |
|---|
| 89 | |
|---|
| 90 | setFontStyle(15,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER); |
|---|
| 91 | |
|---|
| 92 | int line = DST_GetFontHeight(15); |
|---|
| 93 | int y_str = y+10; |
|---|
| 94 | char tmpProgStr[50] = {0,}; |
|---|
| 95 | |
|---|
| 96 | sprintf(tmpProgStr,"(%d%%)",(nPos == nTotal)?(100):(int)((nPos*100)/nTotal)); |
|---|
| 97 | DrawBox32(x, y_str, width, line, CONV32_16(0xff24435e)); |
|---|
| 98 | DrawTextUTF8(x, y_str, width, line, (DS_U8*)tmpProgStr, &font); |
|---|
| 99 | |
|---|
| 100 | // DST_Printf("rect.x:%d,rect.y:%d,rect.w:%d,rect.h:%d\n",rect.x,rect.y,rect.w,rect.h); |
|---|
| 101 | // DST_Printf("x:%d,y:%d,w:%d,h:%d\n",x,y,width,y_str-y+line); |
|---|
| 102 | |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | virtual void OnMessage(SWinEventMsg event) |
|---|
| 106 | { |
|---|
| 107 | static int old_count = -1; |
|---|
| 108 | switch (event.cmd) |
|---|
| 109 | { |
|---|
| 110 | case WM_RF_UPDATE: |
|---|
| 111 | switch(event.data32[0]) |
|---|
| 112 | { |
|---|
| 113 | case DATA_RECEIVING: // DATA RECEIVING |
|---|
| 114 | KillTimer(1); |
|---|
| 115 | DrawProgressBar(event.data32[1], 100,rect.w/10,center_pos+2*line_spacing-10,rect.w*8/10); |
|---|
| 116 | if(old_count != (int)event.data32[1]) |
|---|
| 117 | { |
|---|
| 118 | old_count = event.data32[1]; |
|---|
| 119 | KillTimer(2); |
|---|
| 120 | SetTimer(2, 15*60*DST_OS_GetTicksPerSecond()); |
|---|
| 121 | } |
|---|
| 122 | break; |
|---|
| 123 | } |
|---|
| 124 | break; |
|---|
| 125 | } |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | virtual void OnTimer(char nID) |
|---|
| 129 | { |
|---|
| 130 | switch(nID) |
|---|
| 131 | { |
|---|
| 132 | case 1: |
|---|
| 133 | DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,(DST_g_Lock == true)?(OTC_WAIT_TIMEOUT_FAIL):(TUNING_FAIL)); |
|---|
| 134 | Close(); |
|---|
| 135 | break; |
|---|
| 136 | case 2: |
|---|
| 137 | DST_CreateWin(WIN_OTC_DOWNLOAD_FAIL,WIN_NULL,OTC_COMPLETE_TIMEOUT_FAIL); |
|---|
| 138 | Close(); |
|---|
| 139 | break; |
|---|
| 140 | #if 0 //test code |
|---|
| 141 | case 3: |
|---|
| 142 | { |
|---|
| 143 | static int count = 0; |
|---|
| 144 | KillTimer(3); |
|---|
| 145 | |
|---|
| 146 | DrawProgressBar(count, 100,rect.w/10,center_pos+2*line_spacing-10,rect.w*8/10); |
|---|
| 147 | count++; |
|---|
| 148 | if(count == 100) count = 0; |
|---|
| 149 | |
|---|
| 150 | SetTimer(3,300); |
|---|
| 151 | } |
|---|
| 152 | break; |
|---|
| 153 | #endif |
|---|
| 154 | case 4: |
|---|
| 155 | { |
|---|
| 156 | static int loading = 0; |
|---|
| 157 | |
|---|
| 158 | loading = loading%6; |
|---|
| 159 | switch(loading) |
|---|
| 160 | { |
|---|
| 161 | case 0: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait1,true); break; |
|---|
| 162 | case 1: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait2,true); break; |
|---|
| 163 | case 2: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait3,true); break; |
|---|
| 164 | case 3: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait4,true); break; |
|---|
| 165 | case 4: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait5,true); break; |
|---|
| 166 | case 5: DrawImage((rect.w-34)/2, 30, newcon2_gui_downaload_Wait6,true); break; |
|---|
| 167 | } |
|---|
| 168 | loading ++; |
|---|
| 169 | |
|---|
| 170 | } |
|---|
| 171 | break; |
|---|
| 172 | } |
|---|
| 173 | } |
|---|
| 174 | |
|---|
| 175 | virtual void Show(void) |
|---|
| 176 | { |
|---|
| 177 | Draw(); |
|---|
| 178 | |
|---|
| 179 | RegisterAllKey(); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | void Draw() |
|---|
| 183 | { |
|---|
| 184 | DrawBox32(0, 0, rect.w, rect.h, CONV32_16(0xff24435e)); |
|---|
| 185 | |
|---|
| 186 | setFontStyle(fontItemSize,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER); |
|---|
| 187 | |
|---|
| 188 | DrawTextUni(0, center_pos-60+25, rect.w, line_spacing, pz_OTC_Download1[OSD_Lang], &font); |
|---|
| 189 | DrawTextUni(0, center_pos+line_spacing-50+25, rect.w, line_spacing, pz_OTC_Download2[OSD_Lang], &font); |
|---|
| 190 | // SetTimer(3,500); |
|---|
| 191 | SetTimer(4,300); |
|---|
| 192 | |
|---|
| 193 | } |
|---|
| 194 | }; |
|---|
| 195 | |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | class COTCDownloadFailResetWin : public CWindow |
|---|
| 199 | { |
|---|
| 200 | private: |
|---|
| 201 | DS_U8 winParentID; |
|---|
| 202 | DS_U8 msg; |
|---|
| 203 | int nErr; |
|---|
| 204 | public: |
|---|
| 205 | COTCDownloadFailResetWin(SWinEventMsg event):CWindow(event) |
|---|
| 206 | { |
|---|
| 207 | rect.w = 382; |
|---|
| 208 | rect.h = 241; |
|---|
| 209 | rect.x = (DST_GetScreenWidth() - rect.w) / 2; |
|---|
| 210 | rect.y = (DST_GetScreenHeight()- rect.h) / 2; |
|---|
| 211 | RegisterAllKey(); |
|---|
| 212 | SetTimeOut(0); |
|---|
| 213 | DST_g_bOTCMode = false; |
|---|
| 214 | |
|---|
| 215 | DST_g_LED_PowerState = 1; |
|---|
| 216 | nErr = event.data[2];; |
|---|
| 217 | |
|---|
| 218 | } |
|---|
| 219 | ~COTCDownloadFailResetWin() |
|---|
| 220 | { |
|---|
| 221 | DST_Reset(__func__); // âÀÌ ´ÝÈ÷¸é¼ ÀçºÎÆÃ |
|---|
| 222 | } |
|---|
| 223 | virtual void OnTimer(char nID) |
|---|
| 224 | { |
|---|
| 225 | switch(nID) |
|---|
| 226 | { |
|---|
| 227 | case 1: |
|---|
| 228 | KillTimer(1); |
|---|
| 229 | SetTimer(2, 1000); |
|---|
| 230 | Show(); |
|---|
| 231 | break; |
|---|
| 232 | case 2: |
|---|
| 233 | KillTimer(2); |
|---|
| 234 | Close(); |
|---|
| 235 | break; |
|---|
| 236 | default: |
|---|
| 237 | break; |
|---|
| 238 | } |
|---|
| 239 | } |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | virtual void Show(void) |
|---|
| 243 | { |
|---|
| 244 | DrawBox32(0, 0, rect.w, rect.h, CONV32_16(0xff24435e)); |
|---|
| 245 | setFontStyle(22,0xFFE1E1E1,ALIGN_MIDDLE,ALIGN_CENTER); |
|---|
| 246 | int center_pos = rect.h / 2; |
|---|
| 247 | int line_spacing = DST_GetFontHeight(fontItemSize) * 150 / 100; |
|---|
| 248 | |
|---|
| 249 | switch(nErr) |
|---|
| 250 | { |
|---|
| 251 | case TUNING_FAIL: |
|---|
| 252 | DST_Printf("OTCDownloadFail : ERROR %d TUNING_FAIL\n",nErr); |
|---|
| 253 | DrawTextUni(0, center_pos-2*line_spacing, rect.w, line_spacing, pz_Update_Err_101[OSD_Lang], &font); |
|---|
| 254 | break; |
|---|
| 255 | case OTC_WAIT_TIMEOUT_FAIL: |
|---|
| 256 | DST_Printf("OTCDownloadFail : ERROR %d OTC_WAIT_TIMEOUT_FAIL\n",nErr); |
|---|
| 257 | DrawTextUni(0, center_pos-2*line_spacing, rect.w, line_spacing, pz_Update_Err_201[OSD_Lang], &font); |
|---|
| 258 | break; |
|---|
| 259 | case OTC_COMPLETE_TIMEOUT_FAIL: |
|---|
| 260 | DST_Printf("OTCDownloadFail : ERROR %d OTC_COMPLETE_TIMEOUT_FAIL\n",nErr); |
|---|
| 261 | DrawTextUni(0, center_pos-2*line_spacing, rect.w, line_spacing, pz_Update_Err_202[OSD_Lang], &font); |
|---|
| 262 | break; |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | DrawTextUni(0, center_pos-line_spacing, rect.w, line_spacing, pz_OTC_Download_Fail1[OSD_Lang], &font); |
|---|
| 266 | DrawTextUni(0, center_pos, rect.w, line_spacing, pz_OTC_Download_Fail2[OSD_Lang], &font); |
|---|
| 267 | DrawTextUni(0, center_pos+line_spacing, rect.w, line_spacing, pz_OTC_Download_Fail3[OSD_Lang], &font); |
|---|
| 268 | |
|---|
| 269 | UpdateScreen(); |
|---|
| 270 | |
|---|
| 271 | RegisterAllKey(); |
|---|
| 272 | SetTimer(2, 5000); |
|---|
| 273 | } |
|---|
| 274 | }; |
|---|
| 275 | void DST_CreateOTCDownloadFailResetWin(SWinEventMsg event) |
|---|
| 276 | { |
|---|
| 277 | DST_RemoveAllWindowExceptBasicWin(); |
|---|
| 278 | DST_AddWin((WinID)(event.data[0]), new COTCDownloadFailResetWin(event)); |
|---|
| 279 | } |
|---|
| 280 | |
|---|
| 281 | |
|---|
| 282 | void DST_CreateOTCDownLoadingWin(SWinEventMsg event) |
|---|
| 283 | { |
|---|
| 284 | if (DST_GetWin(WIN_UPDATE)) return; |
|---|
| 285 | DST_RemoveAllWindowExceptBasicWin(); |
|---|
| 286 | DST_AddWin((WinID)(event.data[0]), new COTCDownLoadingWin(event)); |
|---|
| 287 | } |
|---|
| 288 | |
|---|
| 289 | |
|---|
| 290 | |
|---|