app.hpp Example File
pushCollector/10.0/pushCollector/src/app.hpp
#ifndef APP_HPP
#define APP_HPP
#include "service/ConfigurationService.hpp"
#include "service/PushNotificationService.hpp"
#include <bb/cascades/GroupDataModel>
#include <bb/system/InvokeManager>
#include <bb/system/SystemCredentialsPrompt>
class PushContentController;
class App : public QObject
{
Q_OBJECT
Q_PROPERTY(bb::cascades::GroupDataModel* model READ model CONSTANT)
Q_PROPERTY(bool modelIsEmpty READ modelIsEmpty NOTIFY modelIsEmptyChanged)
Q_PROPERTY(QString notificationTitle READ notificationTitle NOTIFY notificationChanged)
Q_PROPERTY(QString notificationBody READ notificationBody NOTIFY notificationChanged)
Q_PROPERTY(QString activityDialogTitle READ activityDialogTitle NOTIFY activityDialogChanged)
Q_PROPERTY(QString activityDialogBody READ activityDialogBody NOTIFY activityDialogChanged)
Q_PROPERTY(PushContentController* currentPushContent READ currentPushContent CONSTANT)
Q_PROPERTY(QString appId READ appId WRITE setAppId NOTIFY appIdChanged)
Q_PROPERTY(QString ppgUrl READ ppgUrl WRITE setPpgUrl NOTIFY ppgUrlChanged)
Q_PROPERTY(QString pushInitiatorUrl READ pushInitiatorUrl WRITE setPushInitiatorUrl NOTIFY pushInitiatorUrlChanged)
Q_PROPERTY(bool useSdk READ useSdk WRITE setUseSdk NOTIFY useSdkChanged)
Q_PROPERTY(bool launchApplicationOnPush READ launchApplicationOnPush WRITE setLaunchApplicationOnPush NOTIFY launchApplicationOnPushChanged)
Q_PROPERTY(bool usePublicPpg READ usePublicPpg WRITE setUsePublicPpg NOTIFY usePublicPpgChanged)
public:
App();
Q_INVOKABLE void saveConfiguration();
Q_INVOKABLE void loadConfiguration();
Q_INVOKABLE bool validateConfiguration();
Q_INVOKABLE void createChannel();
Q_INVOKABLE void destroyChannel();
Q_INVOKABLE void deletePush(const QVariantMap &item);
Q_INVOKABLE void deleteAllPushes();
Q_INVOKABLE void markAllPushesAsRead();
Q_INVOKABLE void selectPush(const QVariantList &indexPath);
Q_INVOKABLE QString convertToUtf8String(const QVariant &pushContent);
public Q_SLOTS:
void onCreateSessionCompleted(const bb::network::PushStatus &status);
void onCreateChannelCompleted(const bb::network::PushStatus &status, const QString &token);
void onDestroyChannelCompleted(const bb::network::PushStatus &status);
void onRegisterToLaunchCompleted(const bb::network::PushStatus &status);
void onUnregisterFromLaunchCompleted(const bb::network::PushStatus &status);
void onRegisterPromptFinished(bb::system::SystemUiResult::Type value);
void onUnregisterPromptFinished(bb::system::SystemUiResult::Type value);
void onPIRegistrationCompleted(int code, const QString &description);
void onPIDeregistrationCompleted(int code, const QString &description);
void onInvoked(const bb::system::InvokeRequest &request);
void onSimChanged();
void onPushTransportReady(bb::network::PushCommand::Type command);
void onNoPushServiceConnection();
void onFullscreen();
void onAllPushesRemoved();
Q_SIGNALS:
void modelIsEmptyChanged();
void notificationChanged();
void activityDialogChanged();
void appIdChanged();
void ppgUrlChanged();
void pushInitiatorUrlChanged();
void useSdkChanged();
void launchApplicationOnPushChanged();
void usePublicPpgChanged();
void openActivityDialog();
void closeActivityDialog();
private:
void initializePushSession();
bool validateUser(const QString &dialogTitle, const QString &username, const QString &password);
void loadUser();
void setPromptDefaultText(bb::system::SystemCredentialsPrompt* prompt,const QString &username, const QString &password);
void pushNotificationHandler(bb::network::PushPayload &pushPayload);
void showDialog(const QString &title, const QString &message);
void openActivityDialog(const QString &title, const QString &message);
void openPush(int pushSeqNum);
void updatePushContent(Push &push, const QVariantList &indexPath);
bb::cascades::GroupDataModel* model() const;
bool modelIsEmpty() const;
QString notificationTitle() const;
QString notificationBody() const;
QString activityDialogTitle() const;
QString activityDialogBody() const;
PushContentController* currentPushContent() const;
QString appId() const;
void setAppId(const QString &appId);
QString ppgUrl() const;
void setPpgUrl(const QString &ppgUrl);
QString pushInitiatorUrl() const;
void setPushInitiatorUrl(const QString &pushInitiatorUrl);
bool useSdk() const;
void setUseSdk(bool value);
bool launchApplicationOnPush() const;
void setLaunchApplicationOnPush(bool launchAppOnPush);
bool usePublicPpg() const;
void setUsePublicPpg(bool usingPublicPpg);
bb::system::InvokeManager *m_invokeManager;
bb::system::SystemCredentialsPrompt *m_registerPrompt;
bb::system::SystemCredentialsPrompt *m_unregisterPrompt;
ConfigurationService m_configurationService;
Configuration m_configuration;
User m_user;
PushNotificationService m_pushNotificationService;
bool m_shouldRegisterToLaunch;
bool m_shouldUnregisterFromLaunch;
bool m_hasBeenInForeground;
bool m_configSaveAction;
PushContentController* m_pushContentController;
bb::cascades::GroupDataModel *m_model;
QString m_notificationTitle;
QString m_notificationBody;
QString m_activityDialogTitle;
QString m_activityDialogBody;
QString m_appId;
QString m_ppgUrl;
QString m_pushInitiatorUrl;
bool m_useSdk;
bool m_launchApplicationOnPush;
bool m_usePublicPpg;
};
#endif