RegistrationHandler::RegistrationHandler(const QUuid &uuid, QObject *parent) : QObject(parent) , m_context(uuid) , m_isAllowed(false) , m_progress(BbmRegistrationProgress::NotStarted) , m_temporaryError(false) , m_statusMessage(tr("Please wait while the application connects to BBM.")) { QmlDocument* qml = QmlDocument::create("asset:///registration.qml") .parent(this); qml->setContextProperty("_registrationHandler", this); AbstractPane *root = qml->createRootObject<AbstractPane>(); if (uuid.isNull()) { SystemDialog *uuidDialog = new SystemDialog("OK"); uuidDialog->setTitle("UUID Error"); uuidDialog->setBody("Invalid/Empty UUID, please set correctly in main.cpp"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); return; } connect(&m_context, SIGNAL(registrationStateUpdated( bb::platform::bbm::RegistrationState::Type)), this, SLOT(processRegistrationStatus( bb::platform::bbm::RegistrationState::Type))); if (m_context.isAccessAllowed()){ // jika sudah teregister langsung ke main app qDebug() << "access allowed"; finishRegistration(); }else{ // jika belum, tampilkan halaman registrasi ini. Application::instance()->setScene(root); } }
void NetImageManager::onSslErrors(QNetworkReply * reply, const QList<QSslError> & errors) { foreach (QSslError e, errors) qDebug() << "SSL error: " << e; SystemDialog *dialog = new SystemDialog("OK"); dialog->setTitle(tr("SSL errors received")); dialog->setBody(tr("We have received information about a security breach in the protocol. Press \"OK\" to terminate the application")); // Connect your functions to handle the predefined signals for the buttons. // The slot will check the SystemUiResult to see which button was clicked. bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onDialogFinished(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI dialog->show(); } else { // Failed to connect to signal. dialog->deleteLater(); } }
void BugReportController::insertComment(const QString &body, int issueNumber) { // get the list of issues m_TmpBody = body; m_TmpLabel = issueNumber; if(body.isEmpty()) { bb::system::SystemToast *toast = new bb::system::SystemToast(this); toast->setBody(tr("A comment should not be empty.")); toast->setPosition(bb::system::SystemUiPosition::MiddleCenter); toast->show(); return; } using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle(tr("Create a new comment")); dialog->setBody(tr("Do you want to submit this comment? Please make sure that the content of the message is anonymous.")); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedCreateComment(bb::system::SystemUiResult::Type))); if (success) { dialog->show(); } else { dialog->deleteLater(); } }
RegistrationHandler::RegistrationHandler(const QUuid &uuid, QObject *parent) : QObject(parent) , m_context(uuid) , m_isAllowed(false) , m_progress(BbmRegistrationProgress::NotStarted) , m_temporaryError(false) , m_statusMessage(tr("")) // In the class provided by BlackBerry a message is displayed, but I think it is cleaner not to display anything here. // While connecting, an overlay toast will give feedback to the user. // If there is a problem, then the error message will also be displayed. //, m_statusMessage(tr("Please wait while the application connects to BBM.")) { QmlDocument* qml = QmlDocument::create("asset:///registration.qml") .parent(this); qml->setContextProperty("_registrationHandler", this); AbstractPane *root = qml->createRootObject<AbstractPane>(); Application::instance()->setScene(root); if (uuid.isNull()) { SystemDialog *uuidDialog = new SystemDialog("OK"); uuidDialog->setTitle("UUID Error"); uuidDialog->setBody("Invalid/Empty UUID, please set correctly in main.cpp"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); return; } connect(&m_context, SIGNAL(registrationStateUpdated( bb::platform::bbm::RegistrationState::Type)), this, SLOT(processRegistrationStatus( bb::platform::bbm::RegistrationState::Type))); }
void BalanceController::deleteRecord(int id) { using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle(tr("Delete record")); dialog->setBody(tr("Are you sure you want to delete this record? ")); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedDeleteRecord(bb::system::SystemUiResult::Type))); if (success) { m_tmp_id = id; // Signal was successfully connected. // Now show the dialog box in your UI. dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } }
void App::deleteAllPushes() { SystemDialog deleteAllDialog; deleteAllDialog.setTitle("Delete ALL"); deleteAllDialog.setBody("Delete All Items?"); deleteAllDialog.confirmButton()->setLabel("Delete"); if (deleteAllDialog.exec() == SystemUiResult::ConfirmButtonSelection) { m_pushNotificationService.removeAllPushes(); } }
// Alert Dialog Box Functions void TripMaster::alert(const QString &message) { SystemDialog *dialog; // SystemDialog uses the BB10 native dialog. dialog = new SystemDialog(tr("OK"), 0); // New dialog with on 'Ok' button, no 'Cancel' button dialog->setTitle(tr("Alert")); // set a title for the message dialog->setBody(message); // set the message itself dialog->setDismissAutomatically(true); // Hides the dialog when a button is pressed. // Setup slot to mark the dialog for deletion in the next event loop after the dialog has been accepted. connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), dialog, SLOT(deleteLater())); dialog->show(); }
void App::deletePush(const QVariantMap &item) { SystemDialog deleteDialog; deleteDialog.setTitle("Delete"); deleteDialog.setBody("Delete Item?"); deleteDialog.confirmButton()->setLabel("Delete"); if (deleteDialog.exec() == SystemUiResult::ConfirmButtonSelection) { Push push(item); m_pushNotificationService.removePush(push.seqNum()); m_model->remove(item); } }
void DriveController::openForSharing(const QString &id, const QString &type) { // ---------------------------------------------------------------------------------------------- // get the dataModel of the listview if not already available using namespace bb::cascades; if(m_ListView == NULL) { qWarning() << "did not received the listview. quit."; return; } GroupDataModel* dataModel = dynamic_cast<GroupDataModel*>(m_ListView->dataModel()); if(type == "application/vnd.google-apps.folder") { if(dataModel != NULL) dataModel->clear(); m_Google->getFileList(id); } else { using namespace bb::cascades; using namespace bb::system; SystemDialog *dialog = new SystemDialog("Yes", "No"); dialog->setTitle("Share"); dialog->setBody("Do you want to share this document?"); bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onPromptFinishedShareFile(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI. m_SelectedItemForSharing = id; dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } } }
void App::deletePush(const QVariantMap &item) { SystemDialog deleteDialog; deleteDialog.setTitle("Delete"); deleteDialog.setBody("Delete Item?"); deleteDialog.confirmButton()->setLabel("Delete"); if (deleteDialog.exec() == SystemUiResult::ConfirmButtonSelection) { Push push(item); m_pushHandler->remove(push.seqNum()); m_model->remove(item); // The push has been deleted, so delete the notification Notification::deleteFromInbox(NOTIFICATION_PREFIX + QString::number(push.seqNum())); } }
void App::onSimChanged() { // Remove the currently registered user (if there is one) // and unsubscribe the user from the Push Initiator since // switching SIMs might indicate we are dealing with // a different user m_pushNotificationService.handleSimChange(); SystemDialog simChangeDialog; simChangeDialog.setTitle("Push Collector"); simChangeDialog.setBody("The SIM card was changed and, as a result, the current user has been unregistered. Would you like to re-register?"); simChangeDialog.confirmButton()->setLabel("Yes"); simChangeDialog.cancelButton()->setLabel("No"); if (simChangeDialog.exec() == SystemUiResult::ConfirmButtonSelection) { createChannel(); } }
// A public function to display a SystemDialog in your UI void ApplicationUI::showDialog() { // Set up the SystemDialog with a title and some body text. // Label the two standard buttons with specific text. // Add a custom button as well. SystemDialog *dialog = new SystemDialog("Save as", "Discard changes", "Cancel"); dialog->setTitle("Save changes"); dialog->setBody("Save your changes and close the document?"); dialog->setEmoticonsEnabled(true); // Connect the finished() signal to the onDialogFinished() slot. // The slot will check the SystemUiResult to see which // button was tapped. bool success = connect(dialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(onDialogFinished(bb::system::SystemUiResult::Type))); if (success) { // Signal was successfully connected. // Now show the dialog box in your UI. dialog->show(); } else { // Failed to connect to signal. // This is not normal in most cases and can be a critical // situation for your app! Make sure you know exactly why // this has happened. Add some code to recover from the // lost connection below this line. dialog->deleteLater(); } }
//! [0] RegistrationHandler::RegistrationHandler(const QUuid &uuid, QObject *parent) : QObject(parent) , m_context(uuid) , m_isAllowed(false) , m_progress(BbmRegistrationProgress::NotStarted) , m_temporaryError(false) , m_statusMessage(tr("Please wait while the application connects to BBM.")) { if (uuid.isNull()) { SystemDialog *uuidDialog = new SystemDialog("OK"); uuidDialog->setTitle("UUID Error"); uuidDialog->setBody("Invalid/Empty UUID, please set correctly in main.cpp"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); return; } connect(&m_context, SIGNAL(registrationStateUpdated(bb::platform::bbm::RegistrationState::Type)), this, SLOT(processRegistrationStatus(bb::platform::bbm::RegistrationState::Type))); RegistrationHandler::registerApplication(); }
//! [3] void RegistrationHandler::registrationFinished() { // Finish registration and use the state to decide which message to show // the user. m_progress = BbmRegistrationProgress::Finished; SystemDialog *uuidDialog = new SystemDialog("OK"); //FriendTracker101 mainScreen1(&m_context, this); switch (m_context.registrationState()) { case RegistrationState::Allowed: m_statusMessage = tr("Application connected to BBM. Press Continue."); m_temporaryError = false; //mainScreen1.show(); break; // This error code is not yet available in the NDK. // case RegistrationState::BbmDisabled: // m_statusMessage = tr("Cannot connect to BBM. BBM is not setup. " // "Open BBM to set it up and try again."); // m_temporaryError = false; // break; case RegistrationState::BlockedByRIM: m_statusMessage = tr("Disconnected by RIM. RIM is preventing this " "application from connecting to BBM."); m_temporaryError = false; uuidDialog->setTitle("Disconnected"); uuidDialog->setBody("RIM is preventing this application from connecting to BBM"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::BlockedByUser: m_statusMessage = tr("Disconnected. Go to Settings -> Security and " "Privacy -> Application Permissions and " "connect this application to BBM."); m_temporaryError = false; uuidDialog->setTitle("Disconnected"); uuidDialog->setBody("App does not have enough permissions to contact BBM service."); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::InvalidUuid: // You should be resolving this error at development time. m_statusMessage = tr("Invalid UUID. Report this error to the " "vendor."); m_temporaryError = true; uuidDialog->setTitle("Disconnected"); uuidDialog->setBody("Invalid UUID. Report this error to the vendor"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::MaxAppsReached: m_statusMessage = tr("Too many applications are connected to BBM. " "Uninstall one or more applications and try " "again."); m_temporaryError = false; uuidDialog->setTitle("Disconnected"); uuidDialog->setBody("Too many applications are connected to BBM"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::Expired: case RegistrationState::MaxDownloadsReached: m_statusMessage = tr("Cannot connect to BBM. Download this " "application from AppWorld to keep using it."); m_temporaryError = false; break; case RegistrationState::NoDataConnection: m_statusMessage = tr("Check your Internet connection and try again."); m_temporaryError = true; uuidDialog->setTitle("Registration Finished"); uuidDialog->setBody("no data"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::Pending: // The user will never see this. The BBM Social Platform already // displays a "Connecting" dialog. m_statusMessage = tr("Connecting to BBM. Please wait."); m_temporaryError = false; uuidDialog->setTitle("Registration Finished"); uuidDialog->setBody("5"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::Unknown: m_statusMessage = tr("Determining the status. Please wait."); m_temporaryError = false; uuidDialog->setTitle("Registration Finished"); uuidDialog->setBody("4"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; case RegistrationState::Unregistered: case RegistrationState::UnexpectedError: case RegistrationState::TemporaryError: case RegistrationState::CancelledByUser: default: // If new error codes are added, treat them as temporary errors. m_statusMessage = tr("Would you like to connect the application to " "BBM?"); m_temporaryError = true; uuidDialog->setTitle("Registration Finished"); uuidDialog->setBody("3"); connect(uuidDialog, SIGNAL(finished(bb::system::SystemUiResult::Type)), this, SLOT(dialogFinished(bb::system::SystemUiResult::Type))); uuidDialog->show(); break; } if (m_context.isAccessAllowed()) { m_isAllowed = true; } else { m_isAllowed = false; } qDebug() << "Finished BBM Social Platform registration, success=" << m_isAllowed << "temporaryError=" << m_temporaryError; emit stateChanged(); }
void App::onMessageReceived(const StatusMessage &statusMsg) { // remove message m_messageReader->remove(); // Determine the appropriate action to take by checking the status of the message if(QString::compare(PUSH_COLLECTOR_LAUNCH_CONFIG, statusMsg.status()) == 0){ Sheet* configSheet = Application::instance()->findChild<Sheet*>("configurationSheet"); if (configSheet) { configSheet->open(); } showDialog(tr("Push Collector"), tr("No configuration settings were found. Please fill them in.")); } else if(QString::compare(PUSH_COLLECTOR_CREATE_SESSION_COMPLETE, statusMsg.status()) == 0){ emit closeProgressDialog(); if (statusMsg.code() == PushErrorCode::NoError) { if (m_configSaveAction){ showDialog(tr("Configuration"),tr("Configuration was saved. Please register now.")); } } else{ if (m_configSaveAction) { showDialog(tr("Configuration"), tr("Configuration was saved, but was unable to create push session. (Error code: %0)").arg(statusMsg.code())); } else { // Typically in your own application you wouldn't want to display this error to your users showToast(tr("Error: unable to create push session. (Error code: %0)").arg(statusMsg.code())); } } m_configSaveAction = false; } else if(QString::compare(PUSH_COLLECTOR_CREATE_CHANNEL_COMPLETE, statusMsg.status()) == 0){ emit closeProgressDialog(); showDialog(tr("Register"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_REGISTER_WITH_PUSH_INITIATOR, statusMsg.status()) == 0){ openProgressDialog(tr("Register"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_REGISTER_WITH_PUSH_INITIATOR_COMPLETE, statusMsg.status()) == 0){ emit closeProgressDialog(); showDialog(tr("Register"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_DESTROY_CHANNEL_COMPLETE, statusMsg.status()) == 0){ emit closeProgressDialog(); showDialog(tr("Unregister"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_DEREGISTER_WITH_PUSH_INITIATOR, statusMsg.status()) == 0){ openProgressDialog(tr("Unregister"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_DEREGISTER_WITH_PUSH_INITIATOR_COMPLETE, statusMsg.status()) == 0){ emit closeProgressDialog(); showDialog(tr("Unregister"), statusMsg.message()); } else if(QString::compare(PUSH_COLLECTOR_SIM_CHANGE, statusMsg.status()) == 0) { SystemDialog simChangeDialog; simChangeDialog.setTitle("Push Collector"); simChangeDialog.setBody("The SIM card was changed and, as a result, the current user has been unregistered. Would you like to re-register?"); simChangeDialog.confirmButton()->setLabel("Yes"); simChangeDialog.cancelButton()->setLabel("No"); if (simChangeDialog.exec() == SystemUiResult::ConfirmButtonSelection) { createChannel(); } } else if(QString::compare(PUSH_COLLECTOR_REFRESH_MODEL, statusMsg.status()) == 0){ loadModelData(); } else if(QString::compare(PUSH_COLLECTOR_NO_PUSH_SERVICE_CONNECTION, statusMsg.status()) == 0){ QString message; if (m_configSaveAction) { message = tr("Configuration was saved, but lost connection to the Push Agent. Trying to reconnect..."); } else { message = tr("Lost connection to the Push Agent. Trying to reconnect..."); } showToast(message); m_configSaveAction = false; } else if(QString::compare(PUSH_COLLECTOR_SHOW_DIALOG, statusMsg.status()) == 0){ emit closeProgressDialog(); showDialog(tr("Push Collector"), statusMsg.message()); } else { emit closeProgressDialog(); showToast(statusMsg.message()); m_configSaveAction = false; } }