1 #include "AddOnMonitor.h" 2 #include "AddOnMonitorHandler.h" 3 #include <Message.h> 4 #include <MessageRunner.h> 5 #include <Messenger.h> 6 #include <stdio.h> 7 8 AddOnMonitor::AddOnMonitor(AddOnMonitorHandler * handler) 9 : BLooper("AddOnMonitor") 10 { 11 fInitCheck = B_NO_INIT; 12 AddHandler(handler); 13 SetPreferredHandler(handler); 14 status_t status; 15 BMessenger messenger(handler, this, &status); 16 if (status != B_OK) { 17 fInitCheck = status; 18 return; 19 } 20 if (!messenger.IsValid()) { 21 fInitCheck = B_ERROR; 22 return; 23 } 24 fPulseMessage = new BMessage(B_PULSE); 25 fPulseRunner = new BMessageRunner(messenger, fPulseMessage, 1000000); 26 status = fPulseRunner->InitCheck(); 27 if (status != B_OK) { 28 fInitCheck = status; 29 return; 30 } 31 thread_id id = Run(); 32 if (id < 0) { 33 fInitCheck = (status_t)id; 34 return; 35 } 36 fInitCheck = B_OK; 37 return; 38 } 39 40 41 /* virtual */ 42 AddOnMonitor::~AddOnMonitor() 43 { 44 delete fPulseMessage; 45 delete fPulseRunner; 46 } 47 48 49 /* virtual */ status_t 50 AddOnMonitor::InitCheck() 51 { 52 return fInitCheck; 53 } 54