Пример #1
0
void ApplicationUI::onCreateChannelCompleted(const bb::network::PushStatus &status, const QString &token)
{
    qDebug()<< "creatChannelComplete status: " << status.code();
    qDebug()<< "createChannelComplete token: " << token;


    // Typically in your own application you wouldn't want to display this error to your users
    QString message = QString("Create channel failed with error code: %0").arg(status.code());

    switch(status.code()){
        case  PushErrorCode::NoError:
            settings->saveValueFor("pim",token);
            break;
        case  PushErrorCode::TransportFailure:
            message = tr("Create channel failed as the push transport is unavailable. "
                    "Verify your mobile network and/or Wi-Fi are turned on. "
                    "If they are on, you will be notified when the push transport is available again.");
            qDebug()<< message;
            break;
        case PushErrorCode::SubscriptionContentNotAvailable:
            message = tr("Create channel failed as the PPG is currently returning a server error. "
                    "You will be notified when the PPG is available again.");
            qDebug()<< message;
            break;
    }
}
Пример #2
0
void App::onCreateChannelCompleted(const bb::network::PushStatus &status, const QString &token)
{
    qDebug()<< "creatChannelComplete status: " << status.code();
    qDebug()<< "createChannelComplete token: " << token;

    emit closeActivityDialog();

    if (status.code() == PushErrorCode::NoError) {
        if (!m_configuration.pushInitiatorUrl().isEmpty()) {
            // Now, attempt to subscribe to the Push Initiator
            openActivityDialog(tr("Register"), tr("Subscribing to Push Initiator..."));

            // This is very important: the token returned in the create channel success event is what
            // the Push Initiator should use when initiating a push to the BlackBerry Push Service.
            // This token must be communicated back to the Push Initiator's server-side application.
            m_pushNotificationService.subscribeToPushInitiator(m_user, token);
        } else {
            showDialog(tr("Register"), tr("Register succeeded."));
        }
    } else {
        // Typically in your own application you wouldn't want to display this error to your users
        showDialog(tr("Register"), tr("Create channel failed with error code: %0").arg(status.code()));
    }

}
Пример #3
0
void App::onUnregisterFromLaunchCompleted(const bb::network::PushStatus &status)
{
    if (status.code() != PushErrorCode::NoError) {
        // Typically in your own application you wouldn't want to display this error to your users
        showDialog(tr("Configuration"), m_notificationBody + tr("Unregister from launch failed with error code: %0.").arg(status.code()));
    }
}
Пример #4
0
void App::onCreateSessionCompleted(const bb::network::PushStatus &status)
{
    emit closeActivityDialog();

    if (status.code() == PushErrorCode::NoError) {
        if (m_shouldRegisterToLaunch) {
            m_pushNotificationService.registerToLaunch();
        } else if (m_shouldUnregisterFromLaunch) {
            m_pushNotificationService.unregisterFromLaunch();
        }

        if (m_configSaveAction){
            showDialog(tr("Configuration"),tr("Configuration was saved."));
        }
    } else{
        if (m_configSaveAction) {
            showDialog(tr("Configuration"), m_notificationBody + tr("Configuration was saved, but was unable to create push session. (Error code: %0)").arg(status.code()));
        } else {
            // Typically in your own application you wouldn't want to display this error to your users
            showDialog(tr("Push Collector"), m_notificationBody + tr("Error: unable to create push session. (Error code: %0)").arg(status.code()));
        }
    }

    m_configSaveAction = false;
}
Пример #5
0
void App::onDestroyChannelCompleted(const bb::network::PushStatus &status)
{
    qDebug() << "onDestroyChannelCompleted: " << status.code();

    emit closeActivityDialog();
    if (status.code() == PushErrorCode::NoError) {
        if (!m_configuration.pushInitiatorUrl().isEmpty()) {
            // The Push Service SDK will be used to unsubscribe to the Push Initiator's server-side application since a
            // Push Initiator URL was specified

            openActivityDialog(tr("Unregister"), tr("Unsubscribing from Push Initiator..."));
            // Now, attempt to unsubscribe from the Push Initiator
            m_pushNotificationService.unsubscribeFromPushInitiator(m_user);
        } else {
            showDialog(tr("Unregister"), tr("Unregister succeeded."));
        }
    } else {
        // Typically in your own application you wouldn't want to display this error to your users
        showDialog(tr("Unregister"), tr("Destroy channel failed with error code: %0").arg(status.code()));
    }
}
Пример #6
0
void App::onCreateChannelCompleted(const bb::network::PushStatus &status, const QString &token)
{
    qDebug()<< "creatChannelComplete status: " << status.code();
    qDebug()<< "createChannelComplete token: " << token;

    emit closeActivityDialog();

    // Typically in your own application you wouldn't want to display this error to your users
    QString message = QString("Create channel failed with error code: %0").arg(status.code());

    switch(status.code()){
    case  PushErrorCode::NoError:
         if (!m_configuration.pushInitiatorUrl().isEmpty()) {
            // Now, attempt to subscribe to the Push Initiator
            openActivityDialog(tr("Register"), tr("Subscribing to Push Initiator..."));

            // This is very important: the token returned in the create channel success event is what
            // the Push Initiator should use when initiating a push to the BlackBerry Push Service.
            // This token must be communicated back to the Push Initiator's server-side application.
            m_pushNotificationService.subscribeToPushInitiator(m_user, token);
            return;
        } else {
            message = tr("Register succeeded.");
        }
        break;
    case  PushErrorCode::TransportFailure:
        message = tr("Create channel failed as the push transport is unavailable. "
                  "Verify your mobile network and/or Wi-Fi are turned on. "
                  "If they are on, you will be notified when the push transport is available again.");
        break;
    case PushErrorCode::SubscriptionContentNotAvailable:
        message = tr("Create channel failed as the PPG is currently returning a server error. "
                  "You will be notified when the PPG is available again.");
        break;
    }

    showDialog(tr("Register"), message);
}
Пример #7
0
void App::onDestroyChannelCompleted(const bb::network::PushStatus &status)
{
    qDebug() << "onDestroyChannelCompleted: " << status.code();

    emit closeActivityDialog();

    // Typically in your own application you wouldn't want to display this error to your users
    QString message = QString("Destroy channel failed with error code: %0").arg(status.code());

    switch(status.code()){
    case  PushErrorCode::NoError:
         if (!m_configuration.pushInitiatorUrl().isEmpty()) {
             // The Push Service SDK will be used to unsubscribe to the Push Initiator's server-side application since a
             // Push Initiator URL was specified

             openActivityDialog(tr("Unregister"), tr("Unsubscribing from Push Initiator..."));
             // Now, attempt to unsubscribe from the Push Initiator
             m_pushNotificationService.unsubscribeFromPushInitiator(m_user);
            return;
        } else {
            message = tr("Unregister succeeded.");
        }
        break;
    case  PushErrorCode::TransportFailure:
        message = tr("Destroy channel failed as the push transport is unavailable. "
                  "Verify your mobile network and/or Wi-Fi are turned on. "
                  "If they are on, you will be notified when the push transport is available again.");
        break;
    case PushErrorCode::SubscriptionContentNotAvailable:
        message = tr("Destroy channel failed as the PPG is currently returning a server error. "
                  "You will be notified when the PPG is available again.");
        break;
    }

    showDialog(tr("Unregister"), message);
}