mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-17 23:56:56 +00:00
feat(BRIDGE-37): Remote notification support
This commit is contained in:
@ -729,4 +729,23 @@ SPStreamEvent newGenericErrorEvent(grpc::ErrorCode errorCode) {
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] userID The user ID that received the notification.
|
||||
/// \param[in] title The title of the notification.
|
||||
/// \param[in] subtitle The subtitle of the notification.
|
||||
/// \param[in] body The body of the notification.
|
||||
/// \return The event.
|
||||
//****************************************************************************************************************************************************
|
||||
SPStreamEvent newUserNotificationEvent(QString const &userID, QString const title, QString const subtitle, QString const body) {
|
||||
auto event = new grpc::UserNotificationEvent;
|
||||
event->set_userid(userID.toStdString());
|
||||
event->set_body(body.toStdString());
|
||||
event->set_subtitle(subtitle.toStdString());
|
||||
event->set_title(title.toStdString());
|
||||
auto appEvent = new grpc::AppEvent;
|
||||
appEvent->set_allocated_usernotification(event);
|
||||
return wrapAppEvent(appEvent);
|
||||
}
|
||||
|
||||
|
||||
} // namespace bridgepp
|
||||
|
||||
@ -94,6 +94,9 @@ SPStreamEvent newSyncProgressEvent(QString const &userID, double progress, qint6
|
||||
// Generic error event
|
||||
SPStreamEvent newGenericErrorEvent(grpc::ErrorCode errorCode); ///< Create a new GenericErrrorEvent event.
|
||||
|
||||
// User notification event
|
||||
SPStreamEvent newUserNotificationEvent(QString const &userID, QString const title, QString const subtitle, QString const body);
|
||||
|
||||
} // namespace bridgepp
|
||||
|
||||
|
||||
|
||||
@ -1206,6 +1206,17 @@ void GRPCClient::processAppEvent(AppEvent const &event) {
|
||||
this->logTrace("App event received: AllUsersLoaded");
|
||||
emit allUsersLoaded();
|
||||
break;
|
||||
case AppEvent::kUserNotification: {
|
||||
this->logTrace("App event received: UserNotification");
|
||||
UserNotification notification{
|
||||
.title = QString::fromStdString(event.usernotification().title()),
|
||||
.subtitle = QString::fromStdString(event.usernotification().subtitle()),
|
||||
.body = QString::fromStdString(event.usernotification().body()),
|
||||
.userID = QString::fromStdString(event.usernotification().userid()),
|
||||
};
|
||||
emit userNotificationReceived(notification);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this->logError("Unknown App event received.");
|
||||
}
|
||||
|
||||
@ -56,6 +56,24 @@ public:
|
||||
};
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief A struct for user notitifications.
|
||||
//****************************************************************************************************************************************************
|
||||
struct UserNotification {
|
||||
// The following lines make the type transmissible to QML (but not instanciable there)
|
||||
Q_GADGET
|
||||
Q_PROPERTY(QString title MEMBER title)
|
||||
Q_PROPERTY(QString subtitle MEMBER subtitle)
|
||||
Q_PROPERTY(QString body MEMBER body)
|
||||
Q_PROPERTY(QString userID MEMBER userID)
|
||||
public:
|
||||
QString title; ///< The title of the notification.
|
||||
QString subtitle; ///< The subtitle of the notification.
|
||||
QString body; ///< The body of the notification.
|
||||
QString userID; ///< The userID that received the notification.
|
||||
};
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \brief gRPC client class. This class encapsulate the gRPC service, abstracting all data type conversions.
|
||||
//****************************************************************************************************************************************************
|
||||
@ -125,6 +143,7 @@ signals: // app related signals
|
||||
void knowledgeBasSuggestionsReceived(QList<KnowledgeBaseSuggestion> const& suggestions);
|
||||
void repairStarted();
|
||||
void allUsersLoaded();
|
||||
void userNotificationReceived(UserNotification const& notification);
|
||||
|
||||
|
||||
public: // cache related calls
|
||||
|
||||
Reference in New Issue
Block a user