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(); } }
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; } }