41
41
42
42
NS_ASSUME_NONNULL_BEGIN
43
43
44
- @interface Download : NSObject
44
+ @interface MTRDownload : NSObject
45
45
@property (nonatomic ) NSString * fileDesignator;
46
46
@property (nonatomic ) NSNumber * fabricIndex;
47
47
@property (nonatomic ) NSNumber * nodeID;
@@ -55,7 +55,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
55
55
nodeID : (NSNumber *)nodeID
56
56
queue : (dispatch_queue_t )queue
57
57
completion : (void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
58
- done : (void (^)(Download * finishedDownload))done ;
58
+ done : (void (^)(MTRDownload * finishedDownload))done ;
59
59
60
60
- (void )writeToFile : (NSData *)data error : (out NSError **)error ;
61
61
@@ -69,24 +69,24 @@ - (void)success;
69
69
- (void )failure : (NSError * _Nullable)error ;
70
70
@end
71
71
72
- @interface Downloads : NSObject
73
- @property (nonatomic , strong ) NSMutableArray <Download *> * downloads;
72
+ @interface MTRDownloads : NSObject
73
+ @property (nonatomic , strong ) NSMutableArray <MTRDownload *> * downloads;
74
74
75
- - (Download * _Nullable)get : (NSString *)fileDesignator
75
+ - (MTRDownload * _Nullable)get : (NSString *)fileDesignator
76
76
fabricIndex : (NSNumber *)fabricIndex
77
77
nodeID : (NSNumber *)nodeID ;
78
78
79
- - (Download * _Nullable)add : (MTRDiagnosticLogType)type
79
+ - (MTRDownload * _Nullable)add : (MTRDiagnosticLogType)type
80
80
fabricIndex : (NSNumber *)fabricIndex
81
81
nodeID : (NSNumber *)nodeID
82
82
queue : (dispatch_queue_t )queue
83
83
completion : (void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
84
- done : (void (^)(Download * finishedDownload))done ;
84
+ done : (void (^)(MTRDownload * finishedDownload))done ;
85
85
@end
86
86
87
87
@interface MTRDiagnosticLogsDownloader ()
88
88
@property (readonly ) DiagnosticLogsDownloaderBridge * bridge;
89
- @property (nonatomic , strong ) Downloads * downloads;
89
+ @property (nonatomic , strong ) MTRDownloads * downloads;
90
90
91
91
/* *
92
92
* Notify the delegate when a BDX Session starts for some logs.
@@ -134,21 +134,21 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
134
134
CHIP_ERROR OnTransferEnd (chip::bdx::BDXTransferProxy * transfer, CHIP_ERROR error) override ;
135
135
CHIP_ERROR OnTransferData (chip::bdx::BDXTransferProxy * transfer, const chip::ByteSpan & data) override ;
136
136
137
- CHIP_ERROR StartBDXTransferTimeout (Download * download, uint16_t timeoutInSeconds);
138
- void CancelBDXTransferTimeout (Download * download);
137
+ CHIP_ERROR StartBDXTransferTimeout (MTRDownload * download, uint16_t timeoutInSeconds);
138
+ void CancelBDXTransferTimeout (MTRDownload * download);
139
139
140
140
private:
141
141
static void OnTransferTimeout (chip::System::Layer * layer, void * context);
142
142
MTRDiagnosticLogsDownloader * __weak mDelegate ;
143
143
};
144
144
145
- @implementation Download
145
+ @implementation MTRDownload
146
146
- (instancetype )initWithType : (MTRDiagnosticLogType)type
147
147
fabricIndex : (NSNumber *)fabricIndex
148
148
nodeID : (NSNumber *)nodeID
149
149
queue : (dispatch_queue_t )queue
150
150
completion : (void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
151
- done : (void (^)(Download * finishedDownload))done ;
151
+ done : (void (^)(MTRDownload * finishedDownload))done ;
152
152
{
153
153
self = [super init ];
154
154
if (self) {
@@ -158,7 +158,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
158
158
__weak typeof (self) weakSelf = self;
159
159
auto bdxTransferDone = ^(NSError * bdxError) {
160
160
dispatch_async (queue, ^{
161
- Download * strongSelf = weakSelf;
161
+ MTRDownload * strongSelf = weakSelf;
162
162
if (strongSelf) {
163
163
// If a fileHandle exists, it means that the BDX session has been initiated and a file has
164
164
// been created to host the data of the session. So even if there is an error there may be some
@@ -303,7 +303,7 @@ - (NSString *)_toTypeString:(MTRDiagnosticLogType)type
303
303
304
304
@end
305
305
306
- @implementation Downloads
306
+ @implementation MTRDownloads
307
307
- (instancetype )init
308
308
{
309
309
if (self = [super init ]) {
@@ -315,15 +315,15 @@ - (instancetype)init
315
315
- (void )dealloc
316
316
{
317
317
auto error = [MTRError errorForCHIPErrorCode: CHIP_ERROR_INTERNAL];
318
- for (Download * download in _downloads) {
318
+ for (MTRDownload * download in _downloads) {
319
319
[download failure: error];
320
320
}
321
321
_downloads = nil ;
322
322
}
323
323
324
- - (Download * _Nullable)get : (NSString *)fileDesignator fabricIndex : (NSNumber *)fabricIndex nodeID : (NSNumber *)nodeID
324
+ - (MTRDownload * _Nullable)get : (NSString *)fileDesignator fabricIndex : (NSNumber *)fabricIndex nodeID : (NSNumber *)nodeID
325
325
{
326
- for (Download * download in _downloads) {
326
+ for (MTRDownload * download in _downloads) {
327
327
if ([download matches: fileDesignator fabricIndex: fabricIndex nodeID: nodeID]) {
328
328
return download;
329
329
}
@@ -332,23 +332,23 @@ - (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)f
332
332
return nil ;
333
333
}
334
334
335
- - (Download * _Nullable)add : (MTRDiagnosticLogType)type
335
+ - (MTRDownload * _Nullable)add : (MTRDiagnosticLogType)type
336
336
fabricIndex : (NSNumber *)fabricIndex
337
337
nodeID : (NSNumber *)nodeID
338
338
queue : (dispatch_queue_t )queue
339
339
completion : (void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
340
- done : (void (^)(Download * finishedDownload))done
340
+ done : (void (^)(MTRDownload * finishedDownload))done
341
341
{
342
342
assertChipStackLockedByCurrentThread ();
343
343
344
- auto download = [[Download alloc ] initWithType: type fabricIndex: fabricIndex nodeID: nodeID queue: queue completion: completion done: done];
344
+ auto download = [[MTRDownload alloc ] initWithType: type fabricIndex: fabricIndex nodeID: nodeID queue: queue completion: completion done: done];
345
345
VerifyOrReturnValue (nil != download, nil );
346
346
347
347
[_downloads addObject: download];
348
348
return download;
349
349
}
350
350
351
- - (void )remove : (Download *)download
351
+ - (void )remove : (MTRDownload *)download
352
352
{
353
353
assertChipStackLockedByCurrentThread ();
354
354
@@ -362,7 +362,7 @@ - (instancetype)init
362
362
assertChipStackLockedByCurrentThread ();
363
363
364
364
if (self = [super init ]) {
365
- _downloads = [[Downloads alloc ] init ];
365
+ _downloads = [[MTRDownloads alloc ] init ];
366
366
_bridge = new DiagnosticLogsDownloaderBridge (self);
367
367
if (_bridge == nullptr ) {
368
368
MTR_LOG_ERROR (" Error: %@" , kErrorInitDiagnosticLogsDownloader );
@@ -406,7 +406,7 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
406
406
}
407
407
408
408
// This block is always called when a download is finished.
409
- auto done = ^(Download * finishedDownload) {
409
+ auto done = ^(MTRDownload * finishedDownload) {
410
410
[controller asyncDispatchToMatterQueue: ^() {
411
411
[self ->_downloads remove :finishedDownload];
412
412
@@ -593,13 +593,13 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
593
593
return CHIP_NO_ERROR;
594
594
}
595
595
596
- CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout (Download * download, uint16_t timeoutInSeconds)
596
+ CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout (MTRDownload * download, uint16_t timeoutInSeconds)
597
597
{
598
598
assertChipStackLockedByCurrentThread ();
599
599
return chip::DeviceLayer::SystemLayer ().StartTimer (chip::System::Clock::Seconds16 (timeoutInSeconds), OnTransferTimeout, (__bridge void *) download);
600
600
}
601
601
602
- void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout (Download * download)
602
+ void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout (MTRDownload * download)
603
603
{
604
604
assertChipStackLockedByCurrentThread ();
605
605
chip::DeviceLayer::SystemLayer ().CancelTimer (OnTransferTimeout, (__bridge void *) download);
@@ -609,7 +609,7 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
609
609
{
610
610
assertChipStackLockedByCurrentThread ();
611
611
612
- auto * download = (__bridge Download *) context;
612
+ auto * download = (__bridge MTRDownload *) context;
613
613
VerifyOrReturn (nil != download);
614
614
615
615
// If there is no abortHandler, it means that the BDX transfer has not started.
0 commit comments