-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
-
21
-
22
-
23
-
24
-
25
-
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
-
47
-
48
-
49
-
50
-
51
-
52
-
53
-
54
-
55
-
56
-
57
-
58
-
59
-
60
-
61
-
62
-
63
-
64
-
65
-
66
-
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
-
75
-
76
-
77
-
78
-
79
-
80
-
81
-
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
-
97
-
98
-
99
-
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
-
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
-
191
-
192
-
193
-
194
-
195
-
196
-
197
-
198
-
199
-
200
-
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
-
236
-
237
-
238
-
239
-
240
-
241
-
242
-
243
-
244
-
245
-
246
-
247
-
248
-
249
-
250
-
251
-
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
-
264
-
265
-
266
-
267
-
268
-
269
-
270
-
271
-
272
-
273
-
274
-
275
-
276
-
277
-
278
-
279
-
280
-
281
-
282
-
283
-
284
-
285
-
286
-
287
-
288
-
289
-
290
-
291
-
292
-
293
-
294
-
295
-
296
-
297
-
298
-
299
-
300
-
301
-
302
-
303
-
304
-
305
-
306
-
307
-
308
-
309
-
310
-
311
-
312
-
313
-
314
-
315
-
316
-
317
-
318
-
319
-
320
-
321
-
322
-
323
-
324
-
325
-
326
-
327
-
328
-
329
-
330
-
331
-
332
-
333
-
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
-
342
-
343
-
344
-
345
-
346
-
347
-
348
-
349
-
350
-
351
-
352
-
353
-
354
-
355
-
356
-
357
-
358
-
359
-
360
-
361
-
362
-
363
-
364
-
365
-
366
-
367
-
368
-
369
-
370
-
371
-
372
-
373
-
374
-
375
-
376
-
377
-
378
-
379
-
380
-
381
-
382
-
383
-
384
// Copyright 2025 Shota FUJI
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
const std = @import("std");
const rc = @import("../rc.zig");
const json = @import("../json.zig");
const allocator = std.heap.c_allocator;
pub const Hierarchy = enum(c_int) {
pub const cname = "roon_browse_Hierarchy";
browse = 0,
playlists = 1,
settings = 2,
internet_radio = 3,
albums = 4,
artists = 5,
genres = 6,
composers = 7,
search = 8,
};
pub const ItemHint = enum(c_int) {
pub const cname = "roon_browse_ItemHint";
unknown = 0,
action = 1,
action_list = 2,
list = 3,
header = 4,
pub fn jsonParseFromValue(
_: std.mem.Allocator,
value: std.json.Value,
_: std.json.ParseOptions,
) std.json.ParseFromValueError!@This() {
return switch (value) {
.string => |v| {
inline for (@typeInfo(@This()).@"enum".fields) |field| {
if (std.mem.eql(u8, field.name, "unknown")) {
continue;
}
if (std.mem.eql(u8, field.name, v)) {
return @enumFromInt(field.value);
}
}
return .unknown;
},
else => .unknown,
};
}
};
pub const ItemInputPrompt = rc.RefCounted(extern struct {
pub const cname = "roon_browse_ItemInputPrompt";
prompt: [*:0]const u8,
action: [*:0]const u8,
value: ?[*:0]const u8,
is_password: bool,
pub fn init(raw: Raw) !@This() {
return .{
.prompt = (try allocator.dupeZ(u8, raw.prompt)).ptr,
.action = (try allocator.dupeZ(u8, raw.action)).ptr,
.value = if (raw.value) |value| (try allocator.dupeZ(u8, value)).ptr else null,
.is_password = raw.is_password,
};
}
pub const Raw = struct {
prompt: [:0]const u8,
action: [:0]const u8,
value: ?[:0]const u8 = null,
is_password: bool = false,
};
pub fn deinit(self: *const @This()) void {
allocator.free(std.mem.span(self.prompt));
allocator.free(std.mem.span(self.action));
if (self.value) |value| {
allocator.free(std.mem.span(value));
}
}
});
pub const Item = rc.RefCounted(extern struct {
pub const cname = "roon_browse_Item";
title: [*:0]const u8,
subtitle: ?[*:0]const u8,
image_key: ?[*:0]const u8,
item_key: ?[*:0]const u8,
hint: ItemHint,
input_prompt: ?*ItemInputPrompt,
pub fn init(raw: Raw) !@This() {
return .{
.title = (try allocator.dupeZ(u8, raw.title)).ptr,
.subtitle = if (raw.subtitle) |subtitle| (try allocator.dupeZ(u8, subtitle)).ptr else null,
.image_key = if (raw.image_key) |image_key| (try allocator.dupeZ(u8, image_key)).ptr else null,
.item_key = if (raw.item_key) |item_key| (try allocator.dupeZ(u8, item_key)).ptr else null,
.hint = raw.hint,
.input_prompt = if (raw.input_prompt) |input_prompt| try ItemInputPrompt.new(try .init(input_prompt)) else null,
};
}
pub const Raw = struct {
title: [:0]const u8,
subtitle: ?[:0]const u8 = null,
image_key: ?[:0]const u8 = null,
item_key: ?[:0]const u8 = null,
hint: ItemHint = .unknown,
input_prompt: ?ItemInputPrompt.Data.Raw = null,
};
pub fn deinit(self: *const @This()) void {
allocator.free(std.mem.span(self.title));
if (self.subtitle) |subtitle| {
allocator.free(std.mem.span(subtitle));
}
if (self.image_key) |image_key| {
allocator.free(std.mem.span(image_key));
}
if (self.item_key) |item_key| {
allocator.free(std.mem.span(item_key));
}
if (self.input_prompt) |input_prompt| {
input_prompt.release();
}
}
});
pub const ListHint = enum(c_int) {
pub const cname = "roon_browse_ListHint";
unknown = 0,
action_list = 1,
pub fn jsonParseFromValue(
_: std.mem.Allocator,
value: std.json.Value,
_: std.json.ParseOptions,
) std.json.ParseFromValueError!@This() {
return switch (value) {
.string => |v| {
inline for (@typeInfo(@This()).@"enum".fields) |field| {
if (std.mem.eql(u8, field.name, "unknown")) {
continue;
}
if (std.mem.eql(u8, field.name, v)) {
return @enumFromInt(field.value);
}
}
return .unknown;
},
else => .unknown,
};
}
};
pub const List = rc.RefCounted(extern struct {
pub const cname = "roon_browse_List";
title: [*:0]const u8,
count: usize,
subtitle: ?[*:0]const u8,
image_key: ?[*:0]const u8,
level: usize,
display_offset: i64,
has_display_offset: bool,
hint: ListHint,
pub fn init(raw: Raw) !@This() {
return .{
.title = (try allocator.dupeZ(u8, raw.title)).ptr,
.count = raw.count,
.subtitle = if (raw.subtitle) |subtitle| (try allocator.dupeZ(u8, subtitle)).ptr else null,
.image_key = if (raw.image_key) |image_key| (try allocator.dupeZ(u8, image_key)).ptr else null,
.level = raw.level,
.display_offset = raw.display_offset orelse 0,
.has_display_offset = raw.display_offset != null,
.hint = raw.hint,
};
}
pub const Raw = struct {
title: []const u8,
count: usize = 0,
subtitle: ?[]const u8 = null,
image_key: ?[]const u8 = null,
level: usize = 0,
display_offset: ?i64 = null,
hint: ListHint = .unknown,
};
pub fn deinit(self: *const @This()) void {
allocator.free(std.mem.span(self.title));
if (self.subtitle) |subtitle| {
allocator.free(std.mem.span(subtitle));
}
if (self.image_key) |image_key| {
allocator.free(std.mem.span(image_key));
}
}
});
pub const BrowseAction = enum(c_int) {
pub const cname = "roon_browse_BrowseAction";
message = 0,
none = 1,
list = 2,
replace_item = 3,
remove_item = 4,
};
pub const browse = struct {
pub const Request = json.Serializable(rc.RefCounted(struct {
pub const cname = "roon_browse_browse_Request";
hierarchy: Hierarchy,
item_key: ?[]const u8 = null,
input: ?[]const u8 = null,
zone_or_output_id: ?[]const u8 = null,
pop_all: ?bool = null,
pop_levels: ?usize = null,
refresh_list: ?bool = null,
pub fn init(hierarchy: Hierarchy) @This() {
return .{ .hierarchy = hierarchy };
}
pub fn deinit(self: *const @This()) void {
if (self.item_key) |item_key| {
allocator.free(item_key);
}
if (self.input) |input| {
allocator.free(input);
}
if (self.zone_or_output_id) |zone_or_output_id| {
allocator.free(zone_or_output_id);
}
}
}), .{});
export fn roon_browse_browse_Request_new(hierarchy: Hierarchy) callconv(.C) ?*Request {
return Request.new(.init(hierarchy)) catch return null;
}
pub const Response = json.Deserializable(rc.RefCounted(extern struct {
pub const cname = "roon_browse_browse_Response";
pub const deserializable = true;
action: BrowseAction,
item: ?*Item,
list: ?*List,
message: ?[*:0]const u8,
is_error: bool,
pub fn init(raw: Raw) !@This() {
return .{
.action = raw.action,
.item = if (raw.item) |item| try Item.new(try .init(item)) else null,
.list = if (raw.list) |list| try List.new(try .init(list)) else null,
.message = if (raw.message) |message| (try allocator.dupeZ(u8, message)).ptr else null,
.is_error = raw.is_error orelse false,
};
}
pub const Raw = struct {
action: BrowseAction,
item: ?Item.Data.Raw = null,
list: ?List.Data.Raw = null,
message: ?[]const u8 = null,
is_error: ?bool = null,
};
pub fn deinit(self: *const @This()) void {
if (self.item) |item| {
item.release();
}
if (self.list) |list| {
list.release();
}
if (self.message) |message| {
allocator.free(std.mem.span(message));
}
}
}), .{});
};
pub const load = struct {
pub const Request = json.Serializable(rc.RefCounted(struct {
pub const cname = "roon_browse_load_Request";
set_display_offset: ?i64 = null,
level: ?usize = 0,
offset: ?i64 = 0,
count: ?usize = 0,
hierarchy: Hierarchy,
multi_session_key: ?[]const u8 = null,
pub fn init(hierarchy: Hierarchy) @This() {
return .{ .hierarchy = hierarchy };
}
pub fn deinit(self: *const @This()) void {
if (self.multi_session_key) |multi_session_key| {
allocator.free(multi_session_key);
}
}
}), .{});
export fn roon_browse_load_Request_new(hierarchy: Hierarchy) callconv(.C) ?*Request {
return Request.new(.init(hierarchy)) catch return null;
}
pub const Response = json.Deserializable(rc.RefCounted(extern struct {
pub const cname = "roon_browse_load_Response";
pub const deserializable = true;
items_ptr: [*]const *Item,
items_len: usize,
offset: i64,
list: *List,
pub fn init(raw: Raw) !@This() {
const items = try allocator.alloc(*Item, raw.items.len);
errdefer allocator.free(items);
var i: usize = 0;
errdefer {
for (0..i) |_| {
items[i].release();
}
}
for (raw.items) |item| {
items[i] = try Item.new(try .init(item));
i += 1;
}
return .{
.items_ptr = items.ptr,
.items_len = items.len,
.offset = raw.offset,
.list = try List.new(try .init(raw.list)),
};
}
pub fn deinit(_: *const @This()) void {}
pub const Raw = struct {
items: []const Item.Data.Raw,
offset: i64 = 0,
list: List.Data.Raw,
};
}), .{});
};