2 * Copyright 2004-2010, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
10 #include "AddOnMonitor.h"
11 #include "AddOnMonitorHandler.h"
13 #include <MessageRunner.h>
14 #include <Messenger.h>
18 AddOnMonitor::AddOnMonitor()
20 BLooper("AddOnMonitor"),
21 fInitCheck(B_NO_INIT
),
27 AddOnMonitor::AddOnMonitor(AddOnMonitorHandler
* handler
)
29 BLooper("AddOnMonitor"),
30 fInitCheck(B_NO_INIT
),
37 fInitCheck
= (status_t
)id
;
38 fprintf(stderr
, "AddOnMonitor() : bad id returned by Run()\n");
44 AddOnMonitor::~AddOnMonitor()
51 AddOnMonitor::InitCheck()
58 AddOnMonitor::SetHandler(AddOnMonitorHandler
* handler
)
64 SetPreferredHandler(handler
);
70 BMessenger
messenger(handler
, this, &status
);
76 BMessage
pulseMessage(B_PULSE
);
77 fPulseRunner
= new(std::nothrow
) BMessageRunner(messenger
, &pulseMessage
,
79 if (fPulseRunner
== NULL
) {
80 fInitCheck
= B_NO_MEMORY
;
84 status
= fPulseRunner
->InitCheck();
87 fprintf(stderr
, "AddOnMonitor() : bad status returned by "
88 "fPulseRunner->InitCheck()\n");
92 // Send an initial message to process added directories immediately
93 messenger
.SendMessage(&pulseMessage
);