2 * Copyright 2013-2014, Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
7 #include "MessagePackageListener.h"
12 #include "PackageInfo.h"
15 // #pragma mark - MessagePackageListener
18 MessagePackageListener::MessagePackageListener(BHandler
* target
)
21 fChangesMask(0xffffffff)
26 MessagePackageListener::~MessagePackageListener()
32 MessagePackageListener::PackageChanged(const PackageInfoEvent
& event
)
34 if ((event
.Changes() & fChangesMask
) == 0)
37 BMessenger
messenger(fTarget
);
38 if (!messenger
.IsValid())
41 BMessage
message(MSG_UPDATE_PACKAGE
);
42 message
.AddString("name", event
.Package()->Name());
43 message
.AddUInt32("changes", event
.Changes());
45 messenger
.SendMessage(&message
);
50 MessagePackageListener::SetChangesMask(uint32 mask
)
56 // #pragma mark - OnePackageMessagePackageListener
59 OnePackageMessagePackageListener::OnePackageMessagePackageListener(BHandler
* target
)
61 MessagePackageListener(target
)
66 OnePackageMessagePackageListener::~OnePackageMessagePackageListener()
72 OnePackageMessagePackageListener::SetPackage(const PackageInfoRef
& package
)
74 if (fPackage
== package
)
77 PackageInfoListenerRef
listener(this);
79 if (fPackage
.Get() != NULL
)
80 fPackage
->RemoveListener(listener
);
84 if (fPackage
.Get() != NULL
)
85 fPackage
->AddListener(listener
);
90 OnePackageMessagePackageListener::Package() const