xref: /haiku/src/apps/mediaplayer/playlist/PlaylistObserver.cpp (revision ed6250c95736c0b55da79d6e9dd01369532260c0)
1 /*
2  * Copyright 2007, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  * Authors:
6  *		Stephan Aßmus <superstippi@gmx.de>
7  */
8 
9 #include "PlaylistObserver.h"
10 
11 #include <Message.h>
12 
13 
14 PlaylistObserver::PlaylistObserver(BHandler* target)
15 	: Playlist::Listener()
16 	, AbstractLOAdapter(target)
17 {
18 }
19 
20 
21 PlaylistObserver::~PlaylistObserver()
22 {
23 }
24 
25 
26 void
27 PlaylistObserver::RefAdded(const entry_ref& ref, int32 index)
28 {
29 	BMessage message(MSG_PLAYLIST_REF_ADDED);
30 	message.AddRef("refs", &ref);
31 	message.AddInt32("index", index);
32 
33 	DeliverMessage(message);
34 }
35 
36 
37 void
38 PlaylistObserver::RefRemoved(int32 index)
39 {
40 	BMessage message(MSG_PLAYLIST_REF_REMOVED);
41 	message.AddInt32("index", index);
42 
43 	DeliverMessage(message);
44 }
45 
46 
47 void
48 PlaylistObserver::RefsSorted()
49 {
50 	BMessage message(MSG_PLAYLIST_REFS_SORTED);
51 
52 	DeliverMessage(message);
53 }
54 
55 
56 void
57 PlaylistObserver::CurrentRefChanged(int32 newIndex)
58 {
59 	BMessage message(MSG_PLAYLIST_CURRENT_REF_CHANGED);
60 	message.AddInt32("index", newIndex);
61 
62 	DeliverMessage(message);
63 }
64 
65