-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRadioApp.cpp
75 lines (67 loc) · 1.48 KB
/
RadioApp.cpp
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
#include "StationFinder.h"
#include "StationFinderRadioNetwork.h"
#include "StationFinderListenLive.h"
#include "RadioApp.h"
#include "About.h"
RadioApp::RadioApp()
: BApplication(appSignature),
fArgvMessage(NULL)
{
}
RadioApp::~RadioApp() {
}
void
RadioApp::ReadyToRun() {
mainWindow = new MainWindow();
mainWindow->Show();
if (fArgvMessage)
mainWindow->PostMessage(fArgvMessage);
}
void
RadioApp::RefsReceived(BMessage* message) {
mainWindow->PostMessage(message);
}
void
RadioApp::ArgvReceived(int32 argc, char** argv) {
fArgvMessage = new BMessage(B_REFS_RECEIVED);
int32 count = 0;
for (int32 i = 1; i < argc; i++) {
char* arg = argv[i];
if (!strncmp(arg, "--help", 7)) {
printf("Usage: Radio <filename>\n"
"<filename> should be a Shoutcast playlist file.\n"
"If the station already exists, it is made to play otherwise it is added.\n");
continue;
}
BEntry entry(arg);
if (entry.Exists()) {
entry_ref entryRef;
entry.GetRef(&entryRef);
fArgvMessage->AddRef("refs", &entryRef);
count++;
}
}
if (count) {
if (mainWindow)
mainWindow->PostMessage(fArgvMessage);
} else {
delete fArgvMessage;
fArgvMessage = NULL;
}
}
void
RadioApp::AboutRequested() {
About* about = new About();
about->Show();
}
/**
* Application entry point
*/
int
main(int argc, char * argv[]) {
StationFinderRadioNetwork::RegisterSelf();
StationFinderListenLive::RegisterSelf();
new RadioApp();
be_app->Run();
delete be_app;
}