94f3d8f8eb7650104e6c94a1cf4bf6e5d53befc4
[apps/mediaplayer.git] / binding / mediaplayer-manager.h
1 /*
2  *  Copyright 2017 Konsulko Group
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 MEDIAPLAYER_MANAGER_H
18 #define MEDIAPLAYER_MANAGER_H
19
20 #include <glib.h>
21 #include <gio/gio.h>
22 #include <glib-object.h>
23
24 #include "lightmediascanner_interface.h"
25 #include "udisks_interface.h"
26
27     /* Debug Trace Level */
28 #define DT_LEVEL_ERROR          (1 << 1)
29 #define DT_LEVEL_WARNING        (1 << 2)
30 #define DT_LEVEL_NOTICE         (1 << 3)
31 #define DT_LEVEL_INFO           (1 << 4)
32 #define DT_LEVEL_DEBUG          (1 << 5)
33 //#define _DEBUG
34
35 #define LOGE(fmt, args...)   \
36     DebugTraceSendMsg(DT_LEVEL_ERROR, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
37 #define LOGW(fmt, args...)   \
38     DebugTraceSendMsg(DT_LEVEL_WARNING, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
39 #define LOGN(fmt, args...)   \
40     DebugTraceSendMsg(DT_LEVEL_NOTICE,  g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
41 #define LOGI(fmt, args...)   \
42     DebugTraceSendMsg(DT_LEVEL_INFO, g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
43 #define LOGD(fmt, args...)   \
44     DebugTraceSendMsg(DT_LEVEL_DEBUG,  g_strdup_printf("[%d:%s]" fmt, __LINE__, __FUNCTION__, ## args))
45
46 #ifdef _DEBUG
47  #define _DEBUG_PRINT_DBUS
48  #define LOCAL_PRINT_DEBUG
49 #endif
50
51 #ifdef LOCAL_PRINT_DEBUG
52 #define D_PRINTF(fmt, args...) \
53         g_print("[DEBUG][%d:%s]"fmt,  __LINE__, __FUNCTION__, ## args)
54 #define D_PRINTF_RAW(fmt, args...) \
55         g_print(""fmt, ## args)
56 #else
57 #define D_PRINTF(fmt, args...)
58 #define D_PRINTF_RAW(fmt, args...)
59 #endif  /* ifdef _DEBUG */
60
61 void DebugTraceSendMsg(int level, gchar* message);
62
63 //service
64 #define AGENT_SERVICE               "org.agent"
65
66 //remote service
67 #define LIGHTMEDIASCANNER_SERVICE   "org.lightmediascanner"
68 #define UDISKS_SERVICE              "org.freedesktop.UDisks"
69
70 //object path
71 #define LIGHTMEDIASCANNER_PATH      "/org/lightmediascanner/Scanner1"
72 #define UDISKS_PATH                 "/org/freedesktop/UDisks"
73
74 //interface
75 #define LIGHTMEDIASCANNER_INTERFACE "org.lightmediascanner.Scanner1"
76 #define UDISKS_INTERFACE            "org.freedesktop.UDisks"
77 #define FREEDESKTOP_PROPERTIES      "org.freedesktop.DBus.Properties"
78
79 //sqlite
80 #define SQL_QUERY "SELECT files.path FROM files LEFT JOIN audios " \
81                   "WHERE audios.id = files.id ORDER BY " \
82                   "audios.artist_id, audios.album_id, audios.trackno"
83
84 typedef struct {
85     GList *list;
86     GMutex m;
87     Scanner1 *lms_proxy;
88     OrgFreedesktopUDisks *udisks_proxy;
89 } stMediaPlayerManage;
90
91 typedef struct tagBinding_RegisterCallback
92 {
93     void (*binding_device_added)(GList *list);
94     void (*binding_device_removed)(const char *obj_path);
95 } Binding_RegisterCallback_t;
96
97 /* ------ PUBLIC PLUGIN FUNCTIONS --------- */
98 void BindingAPIRegister(const Binding_RegisterCallback_t* pstRegisterCallback);
99 int MediaPlayerManagerInit(void);
100
101 void ListLock();
102 void ListUnlock();
103
104 GList* media_lightmediascanner_scan(void);
105
106 #endif