Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,14 @@ set(client_SRCS
tooltipupdater.cpp
urischemehandler.h
urischemehandler.cpp
notificationconfirmjob.h
notificationconfirmjob.cpp
notifications/notificationconfirmjob.h
notifications/notificationconfirmjob.cpp
notifications/notificationmanager.h
notifications/notificationmanager.cpp
notifications/servernotificationhandler.h
notifications/servernotificationhandler.cpp
notifications/talkreply.h
notifications/talkreply.cpp
guiutility.h
guiutility.cpp
elidedlabel.h
Expand Down Expand Up @@ -247,12 +253,9 @@ set(client_SRCS
search/unifiedsearchresultslistmodel.cpp
tray/usermodel.h
tray/usermodel.cpp
tray/notificationhandler.h
tray/notificationhandler.cpp
tray/sortedactivitylistmodel.h
tray/sortedactivitylistmodel.cpp
creds/credentialsfactory.h
tray/talkreply.cpp
creds/credentialsfactory.cpp
creds/httpcredentialsgui.h
creds/httpcredentialsgui.cpp
Expand Down Expand Up @@ -332,7 +335,12 @@ IF( APPLE )
macOS/trayaccountpopup/trayaccountpopup_mac.mm)
list(APPEND client_SRCS macOS/singleinstancemanager_mac.mm)

list(APPEND client_SRCS systray_mac_usernotifications.mm)
list(APPEND client_SRCS
notifications/macnotificationcenter.h
notifications/macnotificationcenter_p.h
notifications/macnotificationcenter.mm
notifications/ncnotificationcenterdelegate.h
notifications/ncnotificationcenterdelegate.mm)

# FinderSync XPC is independent of File Provider — always built on macOS
list(APPEND client_SRCS
Expand Down
10 changes: 8 additions & 2 deletions src/gui/macOS/trayaccountpopup/ncnotificationactionspopup.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "trayaccountpopupmetrics.h"
#import "trayaccountpopupviewutils.h"

#include "notifications/notificationmanager.h"
#include "tray/usermodel.h"

#include <QVariantMap>
Expand Down Expand Up @@ -61,8 +62,13 @@ - (void)populateForUserIndex:(int)userIndex activityIndex:(int)activityIndex act
width:kNotificationActionsPopupWidth
enabled:YES
action:^{
const auto user = OCC::UserModel::instance()->user(userIndex);
const auto notificationManager = user ? user->notificationManager() : nullptr;
if (!notificationManager) {
return;
}
if (dismisses) {
OCC::UserModel::instance()->dismissNotification(userIndex, activityIndex);
notificationManager->dismissNotification(activityIndex);
[weakSelf orderOut:nil];
return;
}
Expand All @@ -72,7 +78,7 @@ - (void)populateForUserIndex:(int)userIndex activityIndex:(int)activityIndex act
}

[weakOwner closeAllPopups];
OCC::UserModel::instance()->triggerNotificationAction(userIndex, activityIndex, actionIndex);
notificationManager->triggerNotificationAction(activityIndex, actionIndex);
}]);
}
addOwnedArrangedSubview(_stack, [[NCSpacerView alloc] initWithHeight:kActionVerticalPadding width:kNotificationActionsPopupWidth]);
Expand Down
41 changes: 41 additions & 0 deletions src/gui/notifications/macnotificationcenter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: GPL-2.0-or-later
*/

#pragma once

#include "accountfwd.h"
#include "tray/activitydata.h"

#include <QSet>
#include <QString>
#include <QUrl>

namespace OCC::MacNotificationCenter {

/** @brief Configure the macOS notification center delegate, permissions and base categories. */
void initialize(const QString &localizedDownloadString);

/** @brief Return whether the macOS notification center is available. */
[[nodiscard]] bool canSendNotification();

/** @brief Send a basic macOS notification. */
void sendNotification(const QString &title, const QString &message);

/** @brief Send an update notification that opens a download URL. */
void sendUpdateNotification(const QString &title, const QString &message, const QUrl &webUrl);

/**
* @brief Send a server notification with its server-provided actions.
* @param playSound Whether the notification should play the default sound.
*/
void sendServerNotification(const Activity &activity, const AccountStatePtr &accountState, bool playSound);

/** @brief Remove a pending and delivered server notification. */
void removeServerNotification(const QString &accountId, qint64 notificationId);

/** @brief Remove native server notifications absent from the latest server list. */
void reconcileServerNotifications(const QString &accountId, const QSet<qint64> &activeNotificationIds);

}
Loading