2 * Copyright 2011, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Clemens Zeidler <haiku@clemens-zeidler.de>
10 #include "QueryMonitor.h"
13 QueryHandler::QueryHandler(EntryViewInterface
* listener
)
22 QueryHandler::MessageReceived(BMessage
* message
)
25 if (message
->what
== B_QUERY_UPDATE
26 && message
->FindInt32("opcode", &opcode
) == B_OK
) {
30 message
->what
= B_NODE_MONITOR
;
35 FileMonitor::MessageReceived(message
);
39 QueryReader::QueryReader(QueryHandler
* handler
)
47 QueryReader::~QueryReader()
54 QueryReader::AddQuery(BQuery
* query
)
56 query
->SetTarget(fTarget
);
58 return fQueries
.AddItem(query
);
68 for (int32 i
= 0; i
< fLiveQueries
.CountItems(); i
++)
69 delete fLiveQueries
.ItemAt(i
);
70 fLiveQueries
.MakeEmpty();
72 for (int32 i
= 0; i
< fQueries
.CountItems(); i
++)
73 delete fQueries
.ItemAt(i
);
79 QueryReader::ReadNextEntry(entry_ref
& entry
)
81 BQuery
* query
= fQueries
.ItemAt(0);
84 if (query
->GetNextRef(&entry
) != B_OK
) {
85 fQueries
.RemoveItemAt(0);
86 fLiveQueries
.AddItem(query
);
87 return ReadNextEntry(entry
);