Convert song information module into CSongInfo class.
[profile/tv/apps/native/musicplayer.git] / include / music-controller.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __MUSIC_CONTROLLER_H__
18 #define __MUSIC_CONTROLLER_H__
19
20
21 #include <Eina.h>
22 #include <UsbConnectionListener.h>
23
24 struct SSongInfo;
25 struct album_info;
26
27
28 class IMusicControllerListener {
29 private:
30         static void sm_CbComplete(void *cookie);
31         static void sm_CbError(void *cookie);
32         static void sm_CbUsbConnected(void *cookie);
33         static void sm_CbUpdateContent(void *cookie);
34
35 protected:
36         virtual void t_OnComplete(void) = 0;
37         virtual void t_OnError(void) = 0;
38         virtual void t_OnUsbConnected(void) = 0;
39         virtual void t_OnUpdateContent(void) = 0;
40 };
41
42
43 class CMusicController : public CUsbConnectionListener {
44 private:
45         static CMusicController *instance;
46         static int refCnt;
47         struct SMusicController *m;
48
49 private:
50
51         enum EDirectionType {
52                 DIR_PREVIOUS,
53                 DIR_NEXT
54         };
55
56         enum ENextType {
57                 E_ON_COMPLETE,
58                 E_BUTTON_CLICK
59         };
60 private:
61         CMusicController() {}
62         virtual ~CMusicController() {}
63
64 private:
65         static void sm_CbPlaybackCompletion(void *data);
66         void m_OnPlaybackCompletion(void);
67
68 protected:
69         bool t_PlayNext(int direction, int playnext_type);
70         SMusicController* t_Create(void);
71         void t_Destroy(void);
72
73 public:
74         static bool Initialize(void);
75         static void Finalize(void);
76
77         static CMusicController* GetInstance(void);
78
79         bool Start(void);
80         bool Stop(void);
81         bool Resume(void);
82         bool Pause(void);
83
84         bool AddListener(IMusicControllerListener *listener);
85         bool RemoveListener(IMusicControllerListener *listener);
86
87         bool GetCurrentSongIndex(int *ind);
88         bool SetCurrentSongIndex(int ind);
89         bool GetTotalSongs(int *ts);
90         bool GetSonginfoFromIndex(int index, CSongInfo **const csinfo);
91
92         int PlayState(void);
93         bool SetPlayState(int state);
94
95         int ShuffleState(void);
96         bool SetShuffleState(int state);
97
98         int RepeatState(void);
99         bool SetRepeatState(int state);
100
101         int SourceType(void);
102         int SortType(void);
103
104         bool SetSourceType(int type);
105         bool SetSortType(int type);
106         bool SetPosition(int milsec);
107         bool GetPosition(int *const milseconds);
108
109         bool SetCurrentSong(char *mediaid);
110
111         bool GetCurrentSong(CSongInfo **const sinfo);
112         bool SetCurrentAlbum(album_info *alinfo);
113
114         struct album_info *CurrentAlbum(void);
115
116         bool UpdatePlaylist(Eina_List *slist, int addmode);
117         bool EmptyPlaylist(void);
118         bool PlaylistUpdateShuffle(void);
119         bool PlayPreviousSong(void);
120         bool PlayNextSong(void);
121         bool PlayIndexSong(int index);
122         bool RemoveSong(CSongInfo *sinfo, int index);
123         bool CheckUsb(void);
124
125         bool MediaGetList(int EListType, void *info, Eina_List **list);
126         bool MediaInsertPlaylist(const char *name, Eina_List *idlist);
127         bool MediaExistPlaylist(const char *name);
128         bool MediaDeletePlaylist(int id);
129         bool MediaRenamePlaylist(int id, const char *name);
130         bool MediaAddmediaPlaylist(int id, Eina_List *idlist);
131         bool MediaRemovemediaPlaylist(int id, Eina_List *idlist);
132         bool MediaAddsongsPlaylist(int lid, Eina_List *list);
133         CSongInfo *MediaSongByUri(char *uri);
134
135 public:
136         virtual void OnConnect(void);
137 };
138
139
140
141 #endif /*__MUSIC_CONTROLLER_H__*/