1 /*
2 * Copyright 2007-2010 Stephan Aßmus <superstippi@gmx.de>.
3 * All rights reserved. Distributed under the terms of the MIT License.
4 */
5
6 #include "PlaylistObserver.h"
7
8 #include <stdio.h>
9
10 #include <Message.h>
11
12
PlaylistObserver(BHandler * target)13 PlaylistObserver::PlaylistObserver(BHandler* target)
14 : Playlist::Listener()
15 , AbstractLOAdapter(target)
16 {
17 }
18
19
~PlaylistObserver()20 PlaylistObserver::~PlaylistObserver()
21 {
22 }
23
24
25 void
ItemAdded(PlaylistItem * item,int32 index)26 PlaylistObserver::ItemAdded(PlaylistItem* item, int32 index)
27 {
28 BMessage message(MSG_PLAYLIST_ITEM_ADDED);
29 message.AddPointer("item", item);
30 message.AddInt32("index", index);
31
32 DeliverMessage(message);
33 }
34
35
36 void
ItemRemoved(int32 index)37 PlaylistObserver::ItemRemoved(int32 index)
38 {
39 BMessage message(MSG_PLAYLIST_ITEM_REMOVED);
40 message.AddInt32("index", index);
41
42 DeliverMessage(message);
43 }
44
45
46 void
ItemsSorted()47 PlaylistObserver::ItemsSorted()
48 {
49 BMessage message(MSG_PLAYLIST_ITEMS_SORTED);
50
51 DeliverMessage(message);
52 }
53
54
55 void
CurrentItemChanged(int32 newIndex,bool play)56 PlaylistObserver::CurrentItemChanged(int32 newIndex, bool play)
57 {
58 BMessage message(MSG_PLAYLIST_CURRENT_ITEM_CHANGED);
59 message.AddInt32("index", newIndex);
60 message.AddBool("play", play);
61
62 DeliverMessage(message);
63 }
64
65
66 void
ImportFailed()67 PlaylistObserver::ImportFailed()
68 {
69 BMessage message(MSG_PLAYLIST_IMPORT_FAILED);
70
71 DeliverMessage(message);
72 }
73
74
75