Skip to content

Commit a5f9fd7

Browse files
author
dsward2
committed
In AppDelegate and HTTPWebServerConnection, the user now has the option to continue using the LocalRadio app if an RTL-SDR device is not found. An informative message will be displayed if the device is not found.
1 parent 8a296c0 commit a5f9fd7

29 files changed

Lines changed: 151 additions & 106 deletions

β€ŽLocalRadio/LocalRadio-Source/AppDelegate.hβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,7 @@
177177

178178
- (void)restartStreamingServerIfNeeded;
179179

180+
- (void)checkForRTLSDRUSBDevice;
181+
180182
@end
181183

β€ŽLocalRadio/LocalRadio-Source/AppDelegate.mβ€Ž

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -130,30 +130,35 @@ - (void)configureServices
130130
BOOL conflictsFound = NO;
131131

132132
[self checkForRTLSDRUSBDevice];
133-
133+
134+
if (self.rtlsdrDeviceFound == NO)
135+
{
136+
[self performSelectorOnMainThread:@selector(poseRTLSDRNotFoundAlert) withObject:NULL waitUntilDone:YES];
137+
}
138+
134139
if (self.rtlsdrDeviceFound == YES)
135140
{
136141
conflictsFound = [self checkForProcessConflicts];
137-
138-
if (conflictsFound == NO)
139-
{
140-
[self.sqliteController startSQLiteConnection];
142+
}
143+
else
144+
{
145+
// app termination could be in progress due RTL-SDR device not found
146+
}
141147

142-
[self.localRadioAppSettings registerDefaultSettings];
148+
if (conflictsFound == NO)
149+
{
150+
[self.sqliteController startSQLiteConnection];
143151

144-
NSString * bonjourName = [self localHostString];
145-
[self.localRadioAppSettings setValue:bonjourName forKey:@"StreamingServerHost"];
146-
147-
[self performSelectorOnMainThread:@selector(finishConfigureServices) withObject:NULL waitUntilDone:YES];
148-
}
149-
else
150-
{
151-
// app termination in progress due to process confict
152-
}
152+
[self.localRadioAppSettings registerDefaultSettings];
153+
154+
NSString * bonjourName = [self localHostString];
155+
[self.localRadioAppSettings setValue:bonjourName forKey:@"StreamingServerHost"];
156+
157+
[self performSelectorOnMainThread:@selector(finishConfigureServices) withObject:NULL waitUntilDone:YES];
153158
}
154159
else
155160
{
156-
// app termination in progress due RTL-SDR device not found
161+
// app termination in progress due to process confict
157162
}
158163
}
159164

@@ -806,11 +811,6 @@ - (void)checkForRTLSDRUSBDevice
806811
}
807812
IOObjectRelease(iter);
808813
}
809-
810-
if (self.rtlsdrDeviceFound == NO)
811-
{
812-
[self performSelectorOnMainThread:@selector(poseRTLSDRNotFoundAlert) withObject:NULL waitUntilDone:YES];
813-
}
814814
}
815815

816816
//==================================================================================
@@ -823,25 +823,31 @@ - (void)poseRTLSDRNotFoundAlert
823823

824824
[alert addButtonWithTitle:@"Quit"];
825825
[alert addButtonWithTitle:@"More Info"];
826-
826+
[alert addButtonWithTitle:@"Continue"];
827+
827828
[alert setMessageText:@"RTL-SDR USB Device Not Found"];
828829

829-
NSString * informativeText = @"LocalRadio requires an RTL-SDR device plugged into this Mac's USB port. Please check the USB connection and try again. For additional information, click the \"More Info\" button to open the LocalRadio project web page.";
830+
NSString * informativeText = @"LocalRadio requires an RTL-SDR device plugged into this Mac's USB port. Please check the USB connection and try again.\n\nFor additional information, click the \"More Info\" button to open the LocalRadio project web page.\n\nClick the \"Continue\" button to proceed without an RTL-SDR device.";
830831

831832
[alert setInformativeText:informativeText];
832833

833-
[alert setAlertStyle:NSWarningAlertStyle];
834+
[alert setAlertStyle:NSAlertStyleWarning];
834835

835836
[alert beginSheetModalForWindow:self.window completionHandler:^(NSModalResponse returnCode) {
837+
if (returnCode == NSAlertFirstButtonReturn) {
838+
// Quit LocalRadio.app
839+
840+
exit(0);
841+
}
836842
if (returnCode == NSAlertSecondButtonReturn) {
837843
// Show LocalRadio Clean-Up Workflow button
838844
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/dsward2/LocalRadio"]];
839845

840846
exit(0);
841847
}
842-
848+
843849
// Quit button clicked
844-
exit(0);
850+
//exit(0);
845851
}];
846852
}
847853

β€ŽLocalRadio/LocalRadio-Source/HTTPWebServerConnection.mβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,6 +1507,17 @@ - (BOOL)expectsRequestBodyFromMethod:(NSString *)method atPath:(NSString *)path
15071507
}
15081508
}
15091509

1510+
[self.appDelegate checkForRTLSDRUSBDevice];
1511+
1512+
if (self.appDelegate.rtlsdrDeviceFound == NO)
1513+
{
1514+
[replacementDict setObject:@"<div style='text-align: center; color: red; font-weight: bold;'>RTL-SDR device not found</div>" forKey:@"ERROR_MESSAGE"];
1515+
}
1516+
else
1517+
{
1518+
[replacementDict setObject:@"" forKey:@"ERROR_MESSAGE"];
1519+
}
1520+
15101521
return [[HTTPDynamicFileResponse alloc] initWithFilePath:[self filePathForURI:path]
15111522
forConnection:self
15121523
separator:@"%%"

β€ŽLocalRadio/Web/addcategoryform.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<!-- Primary Page Layout
33
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
4+
%%ERROR_MESSAGE%%
45

56
<div class="container">
67
<section class="header">

β€ŽLocalRadio/Web/categories.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<!-- Primary Page Layout
44
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
5+
%%ERROR_MESSAGE%%
56

67
<div class="container">
78
<section class="header">

β€ŽLocalRadio/Web/category.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<!-- Primary Page Layout
33
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
4+
%%ERROR_MESSAGE%%
45

56
<div class="container">
67
<section class="header">

β€ŽLocalRadio/Web/devices.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<!-- Primary Page Layout
33
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
4+
%%ERROR_MESSAGE%%
45

56
<div class="container">
67
<section class="header">

β€ŽLocalRadio/Web/editcategory.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<!-- Primary Page Layout
33
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
4+
%%ERROR_MESSAGE%%
45

56
<div class="container">
67
<section class="header">

β€ŽLocalRadio/Web/editcategorysettings.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
<!-- Primary Page Layout
33
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
4+
%%ERROR_MESSAGE%%
45

56
<div class="container">
67
<section class="header">

β€ŽLocalRadio/Web/editfavorite.htmlβ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<!-- Primary Page Layout
44
–––––––––––––––––––––––––––––––––––––––––––––––––– -->
5+
%%ERROR_MESSAGE%%
56

67
<div class="container">
78
<section class="header">

0 commit comments

Comments
Β (0)