void CTestMenu::testCPINInput() { std::string value; CPINInput * pinInput = new CPINInput("CPINInput", (char *)value.c_str()); pinInput->exec(NULL, ""); pinInput->hide(); delete pinInput; value.clear(); }
int CCAMMenuHandler::handleCamMsg (const neutrino_msg_t msg, neutrino_msg_data_t data, bool from_menu) { int ret = 0; char str[255]; char cnt[5]; int i; MMI_MENU_LIST_INFO Menu; MMI_ENGUIRY_INFO MmiEnquiry; int curslot; MMI_MENU_LIST_INFO * pMenu = &Menu; MMI_ENGUIRY_INFO * pMmiEnquiry = &MmiEnquiry; if(msg == NeutrinoMessages::EVT_CI_INSERTED) { if(hintBox != NULL) { hintBox->hide(); delete hintBox; hintBox = NULL; } sprintf(str, "%s %d", g_Locale->getText(LOCACE_CAM_INSERTED), (int) data+1); dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str); hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str); hintBox->paint(); sleep(CI_MSG_TIME); hintBox->hide(); delete hintBox; hintBox = NULL; } else if (msg == NeutrinoMessages::EVT_CI_REMOVED) { if(hintBox != NULL) { hintBox->hide(); delete hintBox; hintBox = NULL; } sprintf(str, "%s %d", g_Locale->getText(LOCALE_CAM_REMOVED), (int) data+1); dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str); hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str); hintBox->paint(); sleep(CI_MSG_TIME); hintBox->hide(); delete hintBox; hintBox = NULL; } else if(msg == NeutrinoMessages::EVT_CI_INIT_OK) { if(hintBox != NULL) { hintBox->hide(); delete hintBox; hintBox = NULL; } char name[255] = "Unknown"; ci->GetName((int) data, name); sprintf(str, "%s %d: %s", g_Locale->getText(LOCALE_CAM_INIT_OK), (int) data+1, name); dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleMsg: %s\n", str); hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, str); hintBox->paint(); sleep(CI_MSG_TIME); hintBox->hide(); delete hintBox; hintBox = NULL; } else if(msg == NeutrinoMessages::EVT_CI_MMI_MENU || msg == NeutrinoMessages::EVT_CI_MMI_LIST) { bool sublevel = false; if(msg != NeutrinoMessages::EVT_CI_MMI_MENU) sublevel = true; /* if(msg != NeutrinoMessages::EVT_CI_MMI_MENU) dprintf(DEBUG_NORMAL, "NeutrinoMessages::EVT_CI_MMI_MENU \n"); else dprintf(DEBUG_NORMAL, "NeutrinoMessages::EVT_CI_MMI_LIST \n"); */ memcpy(pMenu, (MMI_MENU_LIST_INFO*) data, sizeof(MMI_MENU_LIST_INFO)); free((void *)data); curslot = pMenu->slot; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: slot %d menu ready, title %s choices %d\n", curslot, convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), pMenu->choice_nb); if(hintBox) { hintBox->hide(); } int selected = -1; if(pMenu->choice_nb) { CMenuWidget* menu = new CMenuWidget(convertDVBUTF8(pMenu->title, strlen(pMenu->title), 0).c_str(), NEUTRINO_ICON_SETTINGS); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&selected); int slen = strlen(pMenu->subtitle); if(slen) { char * sptr = pMenu->subtitle; char * tptr = sptr; int bpos = 0; for(int i1 = 0; i1 < slen; i1++) { if((tptr[i1] == 0x8A) || ((bpos >= 38) && (tptr[i1] == 0x20)) ) { bpos = 0; tptr[i1] = 0; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); sptr = &tptr[i1+1]; } bpos++; } if(strlen(sptr)) { dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: subtitle: %s\n", sptr); menu->addItem(new CMenuForwarder(convertDVBUTF8(sptr, strlen(sptr), 0).c_str(), false)); } } for(i = 0; i < pMenu->choice_nb; i++) { sprintf(cnt, "%d", i); if(sublevel) menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt)); else menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->choice_item[i], strlen(pMenu->choice_item[i]), 0).c_str(), true, NULL, selector, cnt, CRCInput::convertDigitToKey(i+1))); } slen = strlen(pMenu->bottom); if(slen) { dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: bottom: %s\n", pMenu->bottom); menu->addItem(new CMenuForwarder(convertDVBUTF8(pMenu->bottom, slen, 0).c_str(), false)); } menu->exec(NULL, ""); delete menu; delete selector; } else { char _str[255]; snprintf(_str, 255, "%s\n%s\n%s", pMenu->title, pMenu->subtitle, pMenu->bottom); if(hintBox) { delete hintBox; hintBox = NULL; } hintBox = new CHintBox(LOCALE_MESSAGEBOX_INFO, convertDVBUTF8(_str, strlen(_str), 0).c_str()); hintBox->paint(); sleep(4);//FIXME if(!from_menu) { delete hintBox; hintBox = NULL; } return 1; } if(sublevel) return 0; if(selected >= 0) { dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: selected %d:%s sublevel %s\n", selected, pMenu->choice_item[i], sublevel ? "yes" : "no"); ci->CI_MenuAnswer(curslot, selected+1); timeoutEnd = CRCInput::calcTimeoutEnd(10); return 1; } else { return 2; } } else if(msg == NeutrinoMessages::EVT_CI_MMI_REQUEST_INPUT) { memcpy(pMmiEnquiry, (MMI_ENGUIRY_INFO*) data, sizeof(MMI_ENGUIRY_INFO)); free((void *)data); curslot = pMmiEnquiry->slot; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: slot %d input request, text %s\n", curslot, convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str()); if(hintBox) hintBox->hide(); char cPIN[pMmiEnquiry->answerlen+1]; cPIN[0] = 0; CPINInput *PINInput = new CPINInput((char *) convertDVBUTF8(pMmiEnquiry->enguiryText, strlen(pMmiEnquiry->enguiryText), 0).c_str(), cPIN, 4, NONEXISTANT_LOCALE); PINInput->exec(NULL, ""); delete PINInput; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: input=[%s]\n", cPIN); if((int) strlen(cPIN) != pMmiEnquiry->answerlen) { dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: wrong input len\n"); ci->CI_Answer(curslot, (unsigned char *) cPIN, 0); return 0; } else { ci->CI_Answer(curslot, (unsigned char *) cPIN, pMmiEnquiry->answerlen); return 1; } } else if(msg == NeutrinoMessages::EVT_CI_MMI_CLOSE) { curslot = (int) data; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: close request slot: %d\n", curslot); ci->CI_CloseMMI(curslot); return 0; } else if(msg == NeutrinoMessages::EVT_CI_MMI_TEXT) { curslot = (int) data; dprintf(DEBUG_NORMAL, "CCAMMenuHandler::handleCamMsg: text\n"); } else ret = -1; return ret; }