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.
9 #include <MessageRunner.h>
12 #include "BluetoothMain.h"
13 #include "BluetoothWindow.h"
17 #undef B_TRANSLATION_CONTEXT
18 #define B_TRANSLATION_CONTEXT "main"
20 BluetoothApplication::BluetoothApplication(void)
21 : BApplication(BLUETOOTH_APP_SIGNATURE
)
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
,
36 alert
->SetShortcut(2, B_ESCAPE
);
37 int32 choice
= alert
->Go();
42 PostMessage(B_QUIT_REQUESTED
);
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);
62 PostMessage(new BMessage('Xtmp'));
67 BluetoothApplication::MessageReceived(BMessage
* message
)
69 switch (message
->what
) {
70 case kMsgAddToRemoteList
:
71 fWindow
->PostMessage(message
);
75 if (!be_roster
->IsRunning(BLUETOOTH_SIGNATURE
)) {
76 // Give another chance
77 BMessageRunner::StartSending(be_app_messenger
,
78 new BMessage('Xtmp'), 2 * 1000000, 1);
80 fWindow
= new BluetoothWindow(BRect(100, 100, 750, 420));
86 BApplication::MessageReceived(message
);
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"
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"
108 " - Pieter Panman\n\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"
116 " - Michael Weirauch\n"
117 " - Fredrik Ekdahl\n"
118 " - Raynald Lesieur\n"
119 " - Andreas Färber\n"
122 " - Petter H. Juliussen\n"
123 "Who gave me all the knowledge:\n"
124 " - the yellowTAB team"),
126 alert
->SetFlags(alert
->Flags() | B_CLOSE_ON_ESCAPE
);
134 BluetoothApplication myApplication
;