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