MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / registerCommands

Method registerCommands

app/src/API/Handlers/NotificationsHandler.cpp:74–148  ·  view source on GitHub ↗

* @brief Register all notifications.* commands with the command registry. */

Source from the content-addressed store, hash-verified

72 * @brief Register all notifications.* commands with the command registry.
73 */
74void API::Handlers::NotificationsHandler::registerCommands()
75{
76 auto& registry = CommandRegistry::instance();
77
78 QJsonObject emptySchema;
79 emptySchema[QStringLiteral("type")] = QStringLiteral("object");
80 emptySchema[QStringLiteral("properties")] = QJsonObject();
81
82 QJsonObject eventProps;
83 eventProps[QStringLiteral("channel")] = stringProp(QStringLiteral("Channel ID (free-form)"));
84 eventProps[QStringLiteral("title")] = stringProp(QStringLiteral("Event title"));
85 eventProps[QStringLiteral("subtitle")] = stringProp(QStringLiteral("Event detail (optional)"));
86
87 {
88 QJsonObject props = eventProps;
89 props[QStringLiteral("level")] = QJsonObject{
90 { QStringLiteral("type"), QStringLiteral("integer")},
91 {QStringLiteral("description"), QStringLiteral("0 = Info, 1 = Warning, 2 = Critical")}
92 };
93 registry.registerCommand(QStringLiteral("notifications.post"),
94 QStringLiteral("Post a notification (params: level, channel, title, "
95 "subtitle)"),
96 makeSchema(props, QJsonArray{QStringLiteral("level")}),
97 &post);
98 }
99
100 registry.registerCommand(QStringLiteral("notifications.resolve"),
101 QStringLiteral("Emit a companion 'Resolved' Info event"),
102 makeSchema(eventProps, QJsonArray()),
103 &resolve);
104
105 {
106 QJsonObject props;
107 props[QStringLiteral("channel")] = stringProp(QStringLiteral("Filter by channel (optional)"));
108 props[QStringLiteral("limit")] = QJsonObject{
109 { QStringLiteral("type"),QStringLiteral("integer") },
110 {QStringLiteral("description"),
111 QStringLiteral("Max entries to return (0 = all, default 0)")}
112 };
113 registry.registerCommand(
114 QStringLiteral("notifications.list"),
115 QStringLiteral("List historical events, newest first (params: channel?, limit?)"),
116 makeSchema(props, QJsonArray()),
117 &list);
118 }
119
120 registry.registerCommand(QStringLiteral("notifications.listChannels"),
121 QStringLiteral("List channel IDs currently present in history"),
122 emptySchema,
123 &channels);
124
125 registry.registerCommand(QStringLiteral("notifications.getUnreadCount"),
126 QStringLiteral("Return the number of unread Warning/Critical events"),
127 emptySchema,
128 &unreadCount);
129
130 {
131 QJsonObject props;

Callers

nothing calls this directly

Calls 4

QJsonObjectClass · 0.85
registerCommandMethod · 0.80
stringPropFunction · 0.70
makeSchemaFunction · 0.70

Tested by

no test coverage detected