//KeyListener virtual void keyPressEvent(int keyCode) { if(keyCode == MAK_FIRE) { maVibrate(0); on = false; printf("did you turn off the vibration?\n"); } }
void pointerPressEvent(MAPoint2d p) { if(on) { maVibrate(0); on = false; printf("did you turn off the vibration?\n"); } else { KeyBaseCase::pointerReleaseEvent(p); } }
//TestCase virtual void start() { if(!assert("maVibrate available?",maVibrate(100000)!=0)) { suite->runNextCase(); return; } clearScreen(); printf(VIB_MSG); on = true; }
void Login::keyPressEvent(int keyCode) { error = false; Widget *currentSoftKeys = mainLayout->getChildren()[mainLayout->getChildren().size() - 1]; int index = kinListBox->getSelectedIndex(); switch(keyCode) { case MAK_FIRE: if(currentSoftKeys->getChildren()[0]->isSelected()){ keyPressEvent(MAK_SOFTLEFT); }else if(currentSoftKeys->getChildren()[2]->isSelected()){ keyPressEvent(MAK_SOFTRIGHT); } break; case MAK_SOFTLEFT: if (!isBusy) { switch (screen) { case S_LOGIN: if (editBoxLogin->getText()!="" & editBoxPass->getText()!="") { isBusy = true; notice->setCaption("Please wait, logging in..."); conCatenation = editBoxPass->getText().c_str(); value = Util::base64_encode(reinterpret_cast<const unsigned char*>(conCatenation.c_str()),conCatenation.length()); feed->setEncrypt(value.c_str()); feed->setUsername(editBoxLogin->getText().c_str()); feed->setUnsuccessful("true"); mHttp = HttpConnection(this); int urlLength = 71 + URLSIZE; char *url = new char[urlLength+1]; memset(url,'\0',urlLength+1); sprintf(url, "%s?userdetails=1", URL); lprintfln("%s", url); int res = mHttp.create(url, HTTP_GET); if(res < 0) { notice->setCaption("Unable to connect, try again later..."); } else { mHttp.setRequestHeader("AUTH_USER", feed->getUsername().c_str()); mHttp.setRequestHeader("AUTH_PW", feed->getEncrypt().c_str()); feed->addHttp(); mHttp.finish(); } delete url; url = NULL; conCatenation = ""; value = ""; } else { maVibrate(1000); notice->setCaption("Ensure that you have entered your username and password."); } break; case S_REGISTER: notice->setCaption(""); if ((strcmp(feed->getRegistered().c_str(), "1") == 0)) { notice->setCaption("Already registered for an account with this device."); maVibrate(1000); } else if (editBoxLogin->getText().length() < 6) { notice->setCaption("Your username needs to be at least 6 characters long"); maVibrate(1000); } else if (editBoxPass->getText().length() < 6) { notice->setCaption("Your password needs to be at least 6 characters long"); maVibrate(1000); } else if (editBoxEmail->getText().length() == 0) { notice->setCaption("You need to enter an email address"); maVibrate(1000); } else if (!Util::validateEmailAddress(editBoxEmail->getText())) { notice->setCaption("Please enter a valid email address"); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxLogin->getText())) { notice->setCaption("Please enter a username without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxPass->getText())) { notice->setCaption("Please enter a password without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxEmail->getText())) { notice->setCaption("Please enter a email address without spaces."); maVibrate(1000); } else if (!Util::validateNoWhiteSpaces(editBoxRefer->getText())) { notice->setCaption("Please enter a referer name."); maVibrate(1000); } else { result = ""; isBusy = true; notice->setCaption("Attempting to register user..."); conCatenation = editBoxPass->getText().c_str(); value = Util::base64_encode(reinterpret_cast<const unsigned char*>(conCatenation.c_str()),conCatenation.length()); feed->setEncrypt(value.c_str()); feed->setUsername(editBoxLogin->getText().c_str()); feed->setUnsuccessful("true"); char *url = NULL; //work out how long the url will be, the 2 is for the & and = symbols int urlLength = 89 + URLSIZE + editBoxLogin->getText().length() + editBoxPass->getText().length() + editBoxEmail->getText().length() + editBoxRefer->getText().length(); url = new char[urlLength+1]; memset(url,'\0',urlLength+1); sprintf(url, "%s?registeruser=1&username=%s&password=%s&email=%s&referer=%s", URL, editBoxLogin->getText().c_str(), editBoxPass->getText().c_str(), editBoxEmail->getText().c_str(), editBoxRefer->getText().c_str()); lprintfln("%s", url); mHttp = HttpConnection(this); int res = mHttp.create(url, HTTP_GET); if(res < 0) { notice->setCaption("Unable to connect, try again later..."); } else { mHttp.setRequestHeader("AUTH_USER", feed->getUsername().c_str()); mHttp.setRequestHeader("AUTH_PW", feed->getEncrypt().c_str()); feed->addHttp(); mHttp.finish(); } delete url; url = NULL; } break; } } break; case MAK_BACK: case MAK_SOFTRIGHT: if ((strcmp(feed->getRegistered().c_str(), "1") == 0)) { maExit(1); } else { previous->show(); } break; case MAK_UP: if(currentSelectedKey!=NULL){ currentSelectedKey->setSelected(false); currentSelectedKey = NULL; currentKeyPosition = -1; kinListBox->getChildren()[kinListBox->getChildren().size()-1]->setSelected(true); } else if (index-2 > 0) { kinListBox->setSelectedIndex(index-2); } break; case MAK_DOWN: if (index+2 < kinListBox->getChildren().size()) { kinListBox->setSelectedIndex(index+2); } else { kinListBox->getChildren()[index]->setSelected(false); for(int i = 0; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } break; case MAK_LEFT: if(currentSelectedKey!=NULL){ if(currentKeyPosition > 0){ currentKeyPosition = currentKeyPosition - 1; for(int i = currentKeyPosition; i >= 0;i--){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; case MAK_RIGHT: if(currentSelectedKey!=NULL){ if(currentKeyPosition+1 < currentSelectedKey->getParent()->getChildren().size()){ currentKeyPosition = currentKeyPosition + 1; for(int i = currentKeyPosition; i < currentSoftKeys->getChildren().size();i++){ if(((Button *)currentSoftKeys->getChildren()[i])->isSelectable()){ currentSelectedKey->setSelected(false); currentKeyPosition=i; currentSelectedKey= currentSoftKeys->getChildren()[i]; currentSelectedKey->setSelected(true); break; } } } } break; } }