Assorted whitespace cleanup and typo fixes.
[haiku.git] / src / preferences / bluetooth / BluetoothMain.cpp
blob3451ecb65608849136dcaf4a6d99270da73e7ea0
1 /*
2 * Copyright 2008-10, Oliver Ruiz Dorantes, <oliver.ruiz.dorantes_at_gmail.com>
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5 #include <stdio.h>
7 #include <Alert.h>
8 #include <Catalog.h>
9 #include <MessageRunner.h>
10 #include <Roster.h>
12 #include "BluetoothMain.h"
13 #include "BluetoothWindow.h"
14 #include "defs.h"
17 #undef B_TRANSLATION_CONTEXT
18 #define B_TRANSLATION_CONTEXT "main"
20 BluetoothApplication::BluetoothApplication(void)
21 : BApplication(BLUETOOTH_APP_SIGNATURE)
26 void
27 BluetoothApplication::ReadyToRun()
29 if (!be_roster->IsRunning(BLUETOOTH_SIGNATURE)) {
30 BAlert* alert = new BAlert("bluetooth_server not running",
31 B_TRANSLATE("bluetooth_server has not been found running on the "
32 "system. Should be started, or stay offline"),
33 B_TRANSLATE("Work offline"), B_TRANSLATE("Quit"),
34 B_TRANSLATE("Start please"), B_WIDTH_AS_USUAL,
35 B_WARNING_ALERT);
36 alert->SetShortcut(2, B_ESCAPE);
37 int32 choice = alert->Go();
40 switch (choice) {
41 case 1:
42 PostMessage(B_QUIT_REQUESTED);
43 case 2:
45 status_t error;
46 error = be_roster->Launch(BLUETOOTH_SIGNATURE);
47 printf("kMsgStartServices: %s\n", strerror(error));
48 // TODO: This is temporal
49 // BMessage handcheck: use the version of Launch()
50 // that includes a BMessage in that message include
51 // a BMessenger to yourself and the BT server could
52 // use that messenger to send back a reply indicating
53 // when it's ready and you could just create window
54 BMessageRunner::StartSending(be_app_messenger,
55 new BMessage('Xtmp'), 2 * 1000000, 1);
59 return;
62 PostMessage(new BMessage('Xtmp'));
66 void
67 BluetoothApplication::MessageReceived(BMessage* message)
69 switch (message->what) {
70 case kMsgAddToRemoteList:
71 fWindow->PostMessage(message);
72 break;
74 case 'Xtmp':
75 if (!be_roster->IsRunning(BLUETOOTH_SIGNATURE)) {
76 // Give another chance
77 BMessageRunner::StartSending(be_app_messenger,
78 new BMessage('Xtmp'), 2 * 1000000, 1);
79 } else {
80 fWindow = new BluetoothWindow(BRect(100, 100, 750, 420));
81 fWindow->Show();
83 break;
85 default:
86 BApplication::MessageReceived(message);
91 void
92 BluetoothApplication::AboutRequested()
94 BAlert* alert = new BAlert("about", B_TRANSLATE(
95 "Haiku Bluetooth system, (ARCE)\n\n"
96 "Created by Oliver Ruiz Dorantes\n\n"
97 "With support of:\n"
98 " - Mika Lindqvist\n"
99 " - Adrien Destugues\n"
100 " - Maksym Yevmenkin\n\n"
101 "Thanks to the individuals who helped...\n\n"
102 "Shipping/donating hardware:\n"
103 " - Henry Jair Abril Florez (el Colombian)\n"
104 " & Stefanie Bartolich\n"
105 " - Edwin Erik Amsler\n"
106 " - Dennis d'Entremont\n"
107 " - Luroh\n"
108 " - Pieter Panman\n\n"
109 "Economically:\n"
110 " - Karl vom Dorff, Andrea Bernardi (OSDrawer),\n"
111 " - Matt M, Doug F, Hubert H,\n"
112 " - Sebastian B, Andrew M, Jared E,\n"
113 " - Frederik H, Tom S, Ferry B,\n"
114 " - Greg G, David F, Richard S, Martin W:\n\n"
115 "With patches:\n"
116 " - Michael Weirauch\n"
117 " - Fredrik Ekdahl\n"
118 " - Raynald Lesieur\n"
119 " - Andreas Färber\n"
120 " - Joerg Meyer\n"
121 "Testing:\n"
122 " - Petter H. Juliussen\n"
123 "Who gave me all the knowledge:\n"
124 " - the yellowTAB team"),
125 B_TRANSLATE("OK"));
126 alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
127 alert->Go();
132 main(int, char**)
134 BluetoothApplication myApplication;
135 myApplication.Run();
137 return 0;