summaryrefslogtreecommitdiffstats
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/library.xbmc.addon/dlfcn-win32.cpp263
-rw-r--r--addons/library.xbmc.addon/dlfcn-win32.h46
-rw-r--r--addons/library.xbmc.addon/libXBMC_addon.h600
-rw-r--r--addons/library.xbmc.codec/libXBMC_codec.h124
-rw-r--r--addons/library.xbmc.gui/libXBMC_gui.h845
-rw-r--r--addons/library.xbmc.pvr/libXBMC_pvr.h332
6 files changed, 2210 insertions, 0 deletions
diff --git a/addons/library.xbmc.addon/dlfcn-win32.cpp b/addons/library.xbmc.addon/dlfcn-win32.cpp
new file mode 100644
index 0000000..5839921
--- /dev/null
+++ b/addons/library.xbmc.addon/dlfcn-win32.cpp
@@ -0,0 +1,263 @@
1/*
2 * dlfcn-win32
3 * Copyright (c) 2007 Ramiro Polla
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <windows.h>
21#include <stdio.h>
22
23#include "dlfcn-win32.h"
24
25/* Note:
26 * MSDN says these functions are not thread-safe. We make no efforts to have
27 * any kind of thread safety.
28 */
29
30/* I have no special reason to have set MAX_GLOBAL_OBJECTS to this value. Any
31 * comments are welcome.
32 */
33#define MAX_OBJECTS 255
34
35static HMODULE global_objects[MAX_OBJECTS];
36
37/* This function adds an object to the list of global objects.
38 * The implementation is very simple and slow.
39 * TODO: should failing this function be enough to fail the call to dlopen( )?
40 */
41static void global_object_add( HMODULE hModule )
42{
43 int i;
44
45 for( i = 0 ; i < MAX_OBJECTS ; i++ )
46 {
47 if( !global_objects[i] )
48 {
49 global_objects[i] = hModule;
50 break;
51 }
52 }
53}
54
55static void global_object_rem( HMODULE hModule )
56{
57 int i;
58
59 for( i = 0 ; i < MAX_OBJECTS ; i++ )
60 {
61 if( global_objects[i] == hModule )
62 {
63 global_objects[i] = 0;
64 break;
65 }
66 }
67}
68
69/* Argument to last function. Used in dlerror( ) */
70static char last_name[MAX_PATH];
71
72static int copy_string( char *dest, int dest_size, const char *src )
73{
74 int i = 0;
75
76 if( src && dest )
77 {
78 for( i = 0 ; i < dest_size-1 ; i++ )
79 {
80 if( !src[i] )
81 break;
82 else
83 dest[i] = src[i];
84 }
85 }
86 dest[i] = '\0';
87
88 return i;
89}
90
91void *dlopen( const char *file, int mode )
92{
93 HMODULE hModule;
94 UINT uMode;
95
96 /* Do not let Windows display the critical-error-handler message box */
97 uMode = SetErrorMode( SEM_FAILCRITICALERRORS );
98
99 if( file == 0 )
100 {
101 /* Save NULL pointer for error message */
102 _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", file );
103
104 /* POSIX says that if the value of file is 0, a handle on a global
105 * symbol object must be provided. That object must be able to access
106 * all symbols from the original program file, and any objects loaded
107 * with the RTLD_GLOBAL flag.
108 * The return value from GetModuleHandle( ) allows us to retrieve
109 * symbols only from the original program file. For objects loaded with
110 * the RTLD_GLOBAL flag, we create our own list later on.
111 */
112 hModule = GetModuleHandle( NULL );
113 }
114 else
115 {
116 char lpFileName[MAX_PATH];
117 int i;
118
119 /* MSDN says backslashes *must* be used instead of forward slashes. */
120 for( i = 0 ; i < sizeof(lpFileName)-1 ; i++ )
121 {
122 if( !file[i] )
123 break;
124 else if( file[i] == '/' )
125 lpFileName[i] = '\\';
126 else
127 lpFileName[i] = file[i];
128 }
129 lpFileName[i] = '\0';
130
131 /* Save file name for error message */
132 copy_string( last_name, sizeof(last_name), lpFileName );
133
134 /* POSIX says the search path is implementation-defined.
135 * LOAD_WITH_ALTERED_SEARCH_PATH is used to make it behave more closely
136 * to UNIX's search paths (start with system folders instead of current
137 * folder).
138 */
139 hModule = LoadLibraryEx( (LPSTR) lpFileName, NULL,
140 LOAD_WITH_ALTERED_SEARCH_PATH );
141 /* If the object was loaded with RTLD_GLOBAL, add it to list of global
142 * objects, so that its symbols may be retrieved even if the handle for
143 * the original program file is passed. POSIX says that if the same
144 * file is specified in multiple invocations, and any of them are
145 * RTLD_GLOBAL, even if any further invocations use RTLD_LOCAL, the
146 * symbols will remain global.
147 */
148
149 if( hModule && (mode & RTLD_GLOBAL) )
150 global_object_add( hModule );
151 }
152
153 /* Return to previous state of the error-mode bit flags. */
154 SetErrorMode( uMode );
155
156 return (void *) hModule;
157}
158
159int dlclose( void *handle )
160{
161 HMODULE hModule = (HMODULE) handle;
162 BOOL ret;
163
164 /* Save handle for error message */
165 _snprintf_s( last_name, MAX_PATH, MAX_PATH, "0x%p", handle );
166
167 ret = FreeLibrary( hModule );
168
169 /* If the object was loaded with RTLD_GLOBAL, remove it from list of global
170 * objects.
171 */
172 if( ret )
173 global_object_rem( hModule );
174
175 /* dlclose's return value in inverted in relation to FreeLibrary's. */
176 ret = !ret;
177
178 return (int) ret;
179}
180
181void *dlsym( void *handle, const char *name )
182{
183 FARPROC symbol;
184 HMODULE myhandle = (HMODULE) handle;
185
186 /* Save symbol name for error message */
187 copy_string( last_name, sizeof(last_name), name );
188
189 symbol = GetProcAddress( myhandle, name );
190#if 0
191 if( symbol == NULL )
192 {
193 HMODULE hModule;
194
195 /* If the handle for the original program file is passed, also search
196 * in all globally loaded objects.
197 */
198
199 hModule = GetModuleHandle( NULL );
200
201 if( hModule == handle )
202 {
203 int i;
204
205 for( i = 0 ; i < MAX_OBJECTS ; i++ )
206 {
207 if( global_objects[i] != 0 )
208 {
209 symbol = GetProcAddress( global_objects[i], name );
210 if( symbol != NULL )
211 break;
212 }
213 }
214 }
215
216
217 CloseHandle( hModule );
218 }
219#endif
220 return (void*) symbol;
221}
222
223char *dlerror( void )
224{
225 DWORD dwMessageId;
226 /* POSIX says this function doesn't have to be thread-safe, so we use one
227 * static buffer.
228 * MSDN says the buffer cannot be larger than 64K bytes, so we set it to
229 * the limit.
230 */
231 static char lpBuffer[65535];
232 DWORD ret;
233
234 dwMessageId = GetLastError( );
235
236 if( dwMessageId == 0 )
237 return NULL;
238
239 /* Format error message to:
240 * "<argument to function that failed>": <Windows localized error message>
241 */
242 ret = copy_string( lpBuffer, sizeof(lpBuffer), "\"" );
243 ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, last_name );
244 ret += copy_string( lpBuffer+ret, sizeof(lpBuffer)-ret, "\": " );
245 ret += FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMessageId,
246 MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ),
247 lpBuffer+ret, sizeof(lpBuffer)-ret, NULL );
248
249 if( ret > 1 )
250 {
251 /* POSIX says the string must not have trailing <newline> */
252 if( lpBuffer[ret-2] == '\r' && lpBuffer[ret-1] == '\n' )
253 lpBuffer[ret-2] = '\0';
254 }
255
256 /* POSIX says that invoking dlerror( ) a second time, immediately following
257 * a prior invocation, shall result in NULL being returned.
258 */
259 SetLastError(0);
260
261 return lpBuffer;
262}
263
diff --git a/addons/library.xbmc.addon/dlfcn-win32.h b/addons/library.xbmc.addon/dlfcn-win32.h
new file mode 100644
index 0000000..b93a029
--- /dev/null
+++ b/addons/library.xbmc.addon/dlfcn-win32.h
@@ -0,0 +1,46 @@
1#pragma once
2/*
3 * dlfcn-win32
4 * Copyright (c) 2007 Ramiro Polla
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#ifndef DLFCN_H
22#define DLFCN_H
23
24/* POSIX says these are implementation-defined.
25 * To simplify use with Windows API, we treat them the same way.
26 */
27
28#define RTLD_LAZY 0
29#define RTLD_NOW 0
30
31#define RTLD_GLOBAL (1 << 1)
32#define RTLD_LOCAL (1 << 2)
33
34/* These two were added in The Open Group Base Specifications Issue 6.
35 * Note: All other RTLD_* flags in any dlfcn.h are not standard compliant.
36 */
37
38#define RTLD_DEFAULT 0
39#define RTLD_NEXT 0
40
41void *dlopen ( const char *file, int mode );
42int dlclose( void *handle );
43void *dlsym ( void *handle, const char *name );
44char *dlerror( void );
45
46#endif /* DLFCN-WIN32_H */
diff --git a/addons/library.xbmc.addon/libXBMC_addon.h b/addons/library.xbmc.addon/libXBMC_addon.h
new file mode 100644
index 0000000..c3ed54f
--- /dev/null
+++ b/addons/library.xbmc.addon/libXBMC_addon.h
@@ -0,0 +1,600 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <string>
23#include <vector>
24#include <string.h>
25#include <stdlib.h>
26#include <stdio.h>
27#include <stdint.h>
28#include <stdarg.h>
29
30#ifdef _WIN32 // windows
31#ifndef _SSIZE_T_DEFINED
32typedef intptr_t ssize_t;
33#define _SSIZE_T_DEFINED
34#endif // !_SSIZE_T_DEFINED
35#include "dlfcn-win32.h"
36#define ADDON_DLL "\\library.xbmc.addon\\libXBMC_addon" ADDON_HELPER_EXT
37#define ADDON_HELPER_EXT ".dll"
38#else
39#if defined(__APPLE__) // osx
40#if defined(__POWERPC__)
41#define ADDON_HELPER_ARCH "powerpc-osx"
42#elif defined(__arm__)
43#define ADDON_HELPER_ARCH "arm-osx"
44#elif defined(__x86_64__)
45#define ADDON_HELPER_ARCH "x86-osx"
46#else
47#define ADDON_HELPER_ARCH "x86-osx"
48#endif
49#else // linux
50#if defined(__x86_64__)
51#define ADDON_HELPER_ARCH "x86_64-linux"
52#elif defined(_POWERPC)
53#define ADDON_HELPER_ARCH "powerpc-linux"
54#elif defined(_POWERPC64)
55#define ADDON_HELPER_ARCH "powerpc64-linux"
56#elif defined(__ARMEL__)
57#define ADDON_HELPER_ARCH "arm"
58#elif defined(__mips__)
59#define ADDON_HELPER_ARCH "mips"
60#else
61#define ADDON_HELPER_ARCH "i486-linux"
62#endif
63#endif
64#include <dlfcn.h> // linux+osx
65#define ADDON_HELPER_EXT ".so"
66#define ADDON_DLL_NAME "libXBMC_addon-" ADDON_HELPER_ARCH ADDON_HELPER_EXT
67#define ADDON_DLL "/library.xbmc.addon/" ADDON_DLL_NAME
68#endif
69#if defined(ANDROID)
70#include <sys/stat.h>
71#endif
72
73#ifdef LOG_DEBUG
74#undef LOG_DEBUG
75#endif
76#ifdef LOG_INFO
77#undef LOG_INFO
78#endif
79#ifdef LOG_NOTICE
80#undef LOG_NOTICE
81#endif
82#ifdef LOG_ERROR
83#undef LOG_ERROR
84#endif
85
86namespace ADDON
87{
88 typedef enum addon_log
89 {
90 LOG_DEBUG,
91 LOG_INFO,
92 LOG_NOTICE,
93 LOG_ERROR
94 } addon_log_t;
95
96 typedef enum queue_msg
97 {
98 QUEUE_INFO,
99 QUEUE_WARNING,
100 QUEUE_ERROR
101 } queue_msg_t;
102
103 class CHelper_libXBMC_addon
104 {
105 public:
106 CHelper_libXBMC_addon()
107 {
108 m_libXBMC_addon = NULL;
109 m_Handle = NULL;
110 }
111
112 ~CHelper_libXBMC_addon()
113 {
114 if (m_libXBMC_addon)
115 {
116 XBMC_unregister_me(m_Handle, m_Callbacks);
117 dlclose(m_libXBMC_addon);
118 }
119 }
120
121 bool RegisterMe(void *Handle)
122 {
123 m_Handle = Handle;
124
125 std::string libBasePath;
126 libBasePath = ((cb_array*)m_Handle)->libPath;
127 libBasePath += ADDON_DLL;
128
129#if defined(ANDROID)
130 struct stat st;
131 if(stat(libBasePath.c_str(),&st) != 0)
132 {
133 std::string tempbin = getenv("XBMC_ANDROID_LIBS");
134 libBasePath = tempbin + "/" + ADDON_DLL_NAME;
135 }
136#endif
137
138 m_libXBMC_addon = dlopen(libBasePath.c_str(), RTLD_LAZY);
139 if (m_libXBMC_addon == NULL)
140 {
141 fprintf(stderr, "Unable to load %s\n", dlerror());
142 return false;
143 }
144
145 XBMC_register_me = (void* (*)(void *HANDLE))
146 dlsym(m_libXBMC_addon, "XBMC_register_me");
147 if (XBMC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
148
149 XBMC_unregister_me = (void (*)(void* HANDLE, void* CB))
150 dlsym(m_libXBMC_addon, "XBMC_unregister_me");
151 if (XBMC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
152
153 XBMC_log = (void (*)(void* HANDLE, void* CB, const addon_log_t loglevel, const char *msg))
154 dlsym(m_libXBMC_addon, "XBMC_log");
155 if (XBMC_log == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
156
157 XBMC_get_setting = (bool (*)(void* HANDLE, void* CB, const char* settingName, void *settingValue))
158 dlsym(m_libXBMC_addon, "XBMC_get_setting");
159 if (XBMC_get_setting == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
160
161 XBMC_queue_notification = (void (*)(void* HANDLE, void* CB, const queue_msg_t loglevel, const char *msg))
162 dlsym(m_libXBMC_addon, "XBMC_queue_notification");
163 if (XBMC_queue_notification == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
164
165 XBMC_wake_on_lan = (bool (*)(void* HANDLE, void *CB, const char *mac))
166 dlsym(m_libXBMC_addon, "XBMC_wake_on_lan");
167 if (XBMC_wake_on_lan == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
168
169 XBMC_unknown_to_utf8 = (char* (*)(void* HANDLE, void* CB, const char* str))
170 dlsym(m_libXBMC_addon, "XBMC_unknown_to_utf8");
171 if (XBMC_unknown_to_utf8 == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
172
173 XBMC_get_localized_string = (char* (*)(void* HANDLE, void* CB, int dwCode))
174 dlsym(m_libXBMC_addon, "XBMC_get_localized_string");
175 if (XBMC_get_localized_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
176
177 XBMC_free_string = (void (*)(void* HANDLE, void* CB, char* str))
178 dlsym(m_libXBMC_addon, "XBMC_free_string");
179 if (XBMC_free_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
180
181 XBMC_get_dvd_menu_language = (char* (*)(void* HANDLE, void* CB))
182 dlsym(m_libXBMC_addon, "XBMC_get_dvd_menu_language");
183 if (XBMC_get_dvd_menu_language == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
184
185 XBMC_open_file = (void* (*)(void* HANDLE, void* CB, const char* strFileName, unsigned int flags))
186 dlsym(m_libXBMC_addon, "XBMC_open_file");
187 if (XBMC_open_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
188
189 XBMC_open_file_for_write = (void* (*)(void* HANDLE, void* CB, const char* strFileName, bool bOverWrite))
190 dlsym(m_libXBMC_addon, "XBMC_open_file_for_write");
191 if (XBMC_open_file_for_write == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
192
193 XBMC_read_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize))
194 dlsym(m_libXBMC_addon, "XBMC_read_file");
195 if (XBMC_read_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
196
197 XBMC_read_file_string = (bool (*)(void* HANDLE, void* CB, void* file, char *szLine, int iLineLength))
198 dlsym(m_libXBMC_addon, "XBMC_read_file_string");
199 if (XBMC_read_file_string == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
200
201 XBMC_write_file = (ssize_t (*)(void* HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize))
202 dlsym(m_libXBMC_addon, "XBMC_write_file");
203 if (XBMC_write_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
204
205 XBMC_flush_file = (void (*)(void* HANDLE, void* CB, void* file))
206 dlsym(m_libXBMC_addon, "XBMC_flush_file");
207 if (XBMC_flush_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
208
209 XBMC_seek_file = (int64_t (*)(void* HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence))
210 dlsym(m_libXBMC_addon, "XBMC_seek_file");
211 if (XBMC_seek_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
212
213 XBMC_truncate_file = (int (*)(void* HANDLE, void* CB, void* file, int64_t iSize))
214 dlsym(m_libXBMC_addon, "XBMC_truncate_file");
215 if (XBMC_truncate_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
216
217 XBMC_get_file_position = (int64_t (*)(void* HANDLE, void* CB, void* file))
218 dlsym(m_libXBMC_addon, "XBMC_get_file_position");
219 if (XBMC_get_file_position == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
220
221 XBMC_get_file_length = (int64_t (*)(void* HANDLE, void* CB, void* file))
222 dlsym(m_libXBMC_addon, "XBMC_get_file_length");
223 if (XBMC_get_file_length == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
224
225 XBMC_close_file = (void (*)(void* HANDLE, void* CB, void* file))
226 dlsym(m_libXBMC_addon, "XBMC_close_file");
227 if (XBMC_close_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
228
229 XBMC_get_file_chunk_size = (int (*)(void* HANDLE, void* CB, void* file))
230 dlsym(m_libXBMC_addon, "XBMC_get_file_chunk_size");
231 if (XBMC_get_file_chunk_size == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
232
233 XBMC_file_exists = (bool (*)(void* HANDLE, void* CB, const char *strFileName, bool bUseCache))
234 dlsym(m_libXBMC_addon, "XBMC_file_exists");
235 if (XBMC_file_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
236
237 XBMC_stat_file = (int (*)(void* HANDLE, void* CB, const char *strFileName, struct __stat64* buffer))
238 dlsym(m_libXBMC_addon, "XBMC_stat_file");
239 if (XBMC_stat_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
240
241 XBMC_delete_file = (bool (*)(void* HANDLE, void* CB, const char *strFileName))
242 dlsym(m_libXBMC_addon, "XBMC_delete_file");
243 if (XBMC_delete_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
244
245 XBMC_can_open_directory = (bool (*)(void* HANDLE, void* CB, const char* strURL))
246 dlsym(m_libXBMC_addon, "XBMC_can_open_directory");
247 if (XBMC_can_open_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
248
249 XBMC_create_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath))
250 dlsym(m_libXBMC_addon, "XBMC_create_directory");
251 if (XBMC_create_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
252
253 XBMC_directory_exists = (bool (*)(void* HANDLE, void* CB, const char* strPath))
254 dlsym(m_libXBMC_addon, "XBMC_directory_exists");
255 if (XBMC_directory_exists == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
256
257 XBMC_remove_directory = (bool (*)(void* HANDLE, void* CB, const char* strPath))
258 dlsym(m_libXBMC_addon, "XBMC_remove_directory");
259 if (XBMC_remove_directory == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
260
261 m_Callbacks = XBMC_register_me(m_Handle);
262 return m_Callbacks != NULL;
263 }
264
265 /*!
266 * @brief Add a message to XBMC's log.
267 * @param loglevel The log level of the message.
268 * @param format The format of the message to pass to XBMC.
269 */
270 void Log(const addon_log_t loglevel, const char *format, ... )
271 {
272 char buffer[16384];
273 va_list args;
274 va_start (args, format);
275 vsprintf (buffer, format, args);
276 va_end (args);
277 return XBMC_log(m_Handle, m_Callbacks, loglevel, buffer);
278 }
279
280 /*!
281 * @brief Get a settings value for this add-on.
282 * @param settingName The name of the setting to get.
283 * @param settingValue The value.
284 * @return True if the settings was fetched successfully, false otherwise.
285 */
286 bool GetSetting(const char* settingName, void *settingValue)
287 {
288 return XBMC_get_setting(m_Handle, m_Callbacks, settingName, settingValue);
289 }
290
291 /*!
292 * @brief Queue a notification in the GUI.
293 * @param type The message type.
294 * @param format The format of the message to pass to display in XBMC.
295 */
296 void QueueNotification(const queue_msg_t type, const char *format, ... )
297 {
298 char buffer[16384];
299 va_list args;
300 va_start (args, format);
301 vsprintf (buffer, format, args);
302 va_end (args);
303 return XBMC_queue_notification(m_Handle, m_Callbacks, type, buffer);
304 }
305
306 /*!
307 * @brief Send WakeOnLan magic packet.
308 * @param mac Network address of the host to wake.
309 * @return True if the magic packet was successfully sent, false otherwise.
310 */
311 bool WakeOnLan(const char* mac)
312 {
313 return XBMC_wake_on_lan(m_Handle, m_Callbacks, mac);
314 }
315
316 /*!
317 * @brief Translate a string with an unknown encoding to UTF8.
318 * @param str The string to translate.
319 * @return The string translated to UTF8. Must be freed by calling FreeString() when done.
320 */
321 char* UnknownToUTF8(const char* str)
322 {
323 return XBMC_unknown_to_utf8(m_Handle, m_Callbacks, str);
324 }
325
326 /*!
327 * @brief Get a localised message.
328 * @param dwCode The code of the message to get.
329 * @return The message. Must be freed by calling FreeString() when done.
330 */
331 char* GetLocalizedString(int dwCode)
332 {
333 return XBMC_get_localized_string(m_Handle, m_Callbacks, dwCode);
334 }
335
336
337 /*!
338 * @brief Get the DVD menu language.
339 * @return The language. Must be freed by calling FreeString() when done.
340 */
341 char* GetDVDMenuLanguage()
342 {
343 return XBMC_get_dvd_menu_language(m_Handle, m_Callbacks);
344 }
345
346 /*!
347 * @brief Free the memory used by str
348 * @param str The string to free
349 */
350 void FreeString(char* str)
351 {
352 return XBMC_free_string(m_Handle, m_Callbacks, str);
353 }
354
355 /*!
356 * @brief Open the file with filename via XBMC's CFile. Needs to be closed by calling CloseFile() when done.
357 * @param strFileName The filename to open.
358 * @param flags The flags to pass. Documented in XBMC's File.h
359 * @return A handle for the file, or NULL if it couldn't be opened.
360 */
361 void* OpenFile(const char* strFileName, unsigned int flags)
362 {
363 return XBMC_open_file(m_Handle, m_Callbacks, strFileName, flags);
364 }
365
366 /*!
367 * @brief Open the file with filename via XBMC's CFile in write mode. Needs to be closed by calling CloseFile() when done.
368 * @param strFileName The filename to open.
369 * @param bOverWrite True to overwrite, false otherwise.
370 * @return A handle for the file, or NULL if it couldn't be opened.
371 */
372 void* OpenFileForWrite(const char* strFileName, bool bOverWrite)
373 {
374 return XBMC_open_file_for_write(m_Handle, m_Callbacks, strFileName, bOverWrite);
375 }
376
377 /*!
378 * @brief Read from an open file.
379 * @param file The file handle to read from.
380 * @param lpBuf The buffer to store the data in.
381 * @param uiBufSize The size of the buffer.
382 * @return number of successfully read bytes if any bytes were read and stored in
383 * buffer, zero if no bytes are available to read (end of file was reached)
384 * or undetectable error occur, -1 in case of any explicit error
385 */
386 ssize_t ReadFile(void* file, void* lpBuf, size_t uiBufSize)
387 {
388 return XBMC_read_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize);
389 }
390
391 /*!
392 * @brief Read a string from an open file.
393 * @param file The file handle to read from.
394 * @param szLine The buffer to store the data in.
395 * @param iLineLength The size of the buffer.
396 * @return True when a line was read, false otherwise.
397 */
398 bool ReadFileString(void* file, char *szLine, int iLineLength)
399 {
400 return XBMC_read_file_string(m_Handle, m_Callbacks, file, szLine, iLineLength);
401 }
402
403 /*!
404 * @brief Write to a file opened in write mode.
405 * @param file The file handle to write to.
406 * @param lpBuf The data to write.
407 * @param uiBufSize Size of the data to write.
408 * @return number of successfully written bytes if any bytes were written,
409 * zero if no bytes were written and no detectable error occur,
410 * -1 in case of any explicit error
411 */
412 ssize_t WriteFile(void* file, const void* lpBuf, size_t uiBufSize)
413 {
414 return XBMC_write_file(m_Handle, m_Callbacks, file, lpBuf, uiBufSize);
415 }
416
417 /*!
418 * @brief Flush buffered data.
419 * @param file The file handle to flush the data for.
420 */
421 void FlushFile(void* file)
422 {
423 return XBMC_flush_file(m_Handle, m_Callbacks, file);
424 }
425
426 /*!
427 * @brief Seek in an open file.
428 * @param file The file handle to see in.
429 * @param iFilePosition The new position.
430 * @param iWhence Seek argument. See stdio.h for possible values.
431 * @return The new position.
432 */
433 int64_t SeekFile(void* file, int64_t iFilePosition, int iWhence)
434 {
435 return XBMC_seek_file(m_Handle, m_Callbacks, file, iFilePosition, iWhence);
436 }
437
438 /*!
439 * @brief Truncate a file to the requested size.
440 * @param file The file handle to truncate.
441 * @param iSize The new max size.
442 * @return New size?
443 */
444 int TruncateFile(void* file, int64_t iSize)
445 {
446 return XBMC_truncate_file(m_Handle, m_Callbacks, file, iSize);
447 }
448
449 /*!
450 * @brief The current position in an open file.
451 * @param file The file handle to get the position for.
452 * @return The requested position.
453 */
454 int64_t GetFilePosition(void* file)
455 {
456 return XBMC_get_file_position(m_Handle, m_Callbacks, file);
457 }
458
459 /*!
460 * @brief Get the file size of an open file.
461 * @param file The file to get the size for.
462 * @return The requested size.
463 */
464 int64_t GetFileLength(void* file)
465 {
466 return XBMC_get_file_length(m_Handle, m_Callbacks, file);
467 }
468
469 /*!
470 * @brief Close an open file.
471 * @param file The file handle to close.
472 */
473 void CloseFile(void* file)
474 {
475 return XBMC_close_file(m_Handle, m_Callbacks, file);
476 }
477
478 /*!
479 * @brief Get the chunk size for an open file.
480 * @param file the file handle to get the size for.
481 * @return The requested size.
482 */
483 int GetFileChunkSize(void* file)
484 {
485 return XBMC_get_file_chunk_size(m_Handle, m_Callbacks, file);
486 }
487
488 /*!
489 * @brief Check if a file exists.
490 * @param strFileName The filename to check.
491 * @param bUseCache Check in file cache.
492 * @return true if the file exists false otherwise.
493 */
494 bool FileExists(const char *strFileName, bool bUseCache)
495 {
496 return XBMC_file_exists(m_Handle, m_Callbacks, strFileName, bUseCache);
497 }
498
499 /*!
500 * @brief Reads file status.
501 * @param strFileName The filename to read the status from.
502 * @param buffer The file status is written into this buffer.
503 * @return The file status was successfully read.
504 */
505 int StatFile(const char *strFileName, struct __stat64* buffer)
506 {
507 return XBMC_stat_file(m_Handle, m_Callbacks, strFileName, buffer);
508 }
509
510 /*!
511 * @brief Deletes a file.
512 * @param strFileName The filename to delete.
513 * @return The file was successfully deleted.
514 */
515 bool DeleteFile(const char *strFileName)
516 {
517 return XBMC_delete_file(m_Handle, m_Callbacks, strFileName);
518 }
519
520 /*!
521 * @brief Checks whether a directory can be opened.
522 * @param strUrl The URL of the directory to check.
523 * @return True when it can be opened, false otherwise.
524 */
525 bool CanOpenDirectory(const char* strUrl)
526 {
527 return XBMC_can_open_directory(m_Handle, m_Callbacks, strUrl);
528 }
529
530 /*!
531 * @brief Creates a directory.
532 * @param strPath Path to the directory.
533 * @return True when it was created, false otherwise.
534 */
535 bool CreateDirectory(const char *strPath)
536 {
537 return XBMC_create_directory(m_Handle, m_Callbacks, strPath);
538 }
539
540 /*!
541 * @brief Checks if a directory exists.
542 * @param strPath Path to the directory.
543 * @return True when it exists, false otherwise.
544 */
545 bool DirectoryExists(const char *strPath)
546 {
547 return XBMC_directory_exists(m_Handle, m_Callbacks, strPath);
548 }
549
550 /*!
551 * @brief Removes a directory.
552 * @param strPath Path to the directory.
553 * @return True when it was removed, false otherwise.
554 */
555 bool RemoveDirectory(const char *strPath)
556 {
557 return XBMC_remove_directory(m_Handle, m_Callbacks, strPath);
558 }
559
560 protected:
561 void* (*XBMC_register_me)(void *HANDLE);
562 void (*XBMC_unregister_me)(void *HANDLE, void* CB);
563 void (*XBMC_log)(void *HANDLE, void* CB, const addon_log_t loglevel, const char *msg);
564 bool (*XBMC_get_setting)(void *HANDLE, void* CB, const char* settingName, void *settingValue);
565 void (*XBMC_queue_notification)(void *HANDLE, void* CB, const queue_msg_t type, const char *msg);
566 bool (*XBMC_wake_on_lan)(void *HANDLE, void* CB, const char* mac);
567 char* (*XBMC_unknown_to_utf8)(void *HANDLE, void* CB, const char* str);
568 char* (*XBMC_get_localized_string)(void *HANDLE, void* CB, int dwCode);
569 char* (*XBMC_get_dvd_menu_language)(void *HANDLE, void* CB);
570 void (*XBMC_free_string)(void *HANDLE, void* CB, char* str);
571 void* (*XBMC_open_file)(void *HANDLE, void* CB, const char* strFileName, unsigned int flags);
572 void* (*XBMC_open_file_for_write)(void *HANDLE, void* CB, const char* strFileName, bool bOverWrite);
573 ssize_t (*XBMC_read_file)(void *HANDLE, void* CB, void* file, void* lpBuf, size_t uiBufSize);
574 bool (*XBMC_read_file_string)(void *HANDLE, void* CB, void* file, char *szLine, int iLineLength);
575 ssize_t(*XBMC_write_file)(void *HANDLE, void* CB, void* file, const void* lpBuf, size_t uiBufSize);
576 void (*XBMC_flush_file)(void *HANDLE, void* CB, void* file);
577 int64_t (*XBMC_seek_file)(void *HANDLE, void* CB, void* file, int64_t iFilePosition, int iWhence);
578 int (*XBMC_truncate_file)(void *HANDLE, void* CB, void* file, int64_t iSize);
579 int64_t (*XBMC_get_file_position)(void *HANDLE, void* CB, void* file);
580 int64_t (*XBMC_get_file_length)(void *HANDLE, void* CB, void* file);
581 void (*XBMC_close_file)(void *HANDLE, void* CB, void* file);
582 int (*XBMC_get_file_chunk_size)(void *HANDLE, void* CB, void* file);
583 bool (*XBMC_file_exists)(void *HANDLE, void* CB, const char *strFileName, bool bUseCache);
584 int (*XBMC_stat_file)(void *HANDLE, void* CB, const char *strFileName, struct __stat64* buffer);
585 bool (*XBMC_delete_file)(void *HANDLE, void* CB, const char *strFileName);
586 bool (*XBMC_can_open_directory)(void *HANDLE, void* CB, const char* strURL);
587 bool (*XBMC_create_directory)(void *HANDLE, void* CB, const char* strPath);
588 bool (*XBMC_directory_exists)(void *HANDLE, void* CB, const char* strPath);
589 bool (*XBMC_remove_directory)(void *HANDLE, void* CB, const char* strPath);
590
591 private:
592 void *m_libXBMC_addon;
593 void *m_Handle;
594 void *m_Callbacks;
595 struct cb_array
596 {
597 const char* libPath;
598 };
599 };
600};
diff --git a/addons/library.xbmc.codec/libXBMC_codec.h b/addons/library.xbmc.codec/libXBMC_codec.h
new file mode 100644
index 0000000..3853f08
--- /dev/null
+++ b/addons/library.xbmc.codec/libXBMC_codec.h
@@ -0,0 +1,124 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <string>
23#include <vector>
24#include <string.h>
25#include <stdlib.h>
26#include <stdio.h>
27#include "xbmc_codec_types.h"
28#include "libXBMC_addon.h"
29
30#ifdef _WIN32
31#define CODEC_HELPER_DLL "\\library.xbmc.codec\\libXBMC_codec" ADDON_HELPER_EXT
32#else
33#define CODEC_HELPER_DLL_NAME "libXBMC_codec-" ADDON_HELPER_ARCH ADDON_HELPER_EXT
34#define CODEC_HELPER_DLL "/library.xbmc.codec/" CODEC_HELPER_DLL_NAME
35#endif
36
37class CHelper_libXBMC_codec
38{
39public:
40 CHelper_libXBMC_codec(void)
41 {
42 m_libXBMC_codec = NULL;
43 m_Handle = NULL;
44 }
45
46 ~CHelper_libXBMC_codec(void)
47 {
48 if (m_libXBMC_codec)
49 {
50 CODEC_unregister_me(m_Handle, m_Callbacks);
51 dlclose(m_libXBMC_codec);
52 }
53 }
54
55 /*!
56 * @brief Resolve all callback methods
57 * @param handle Pointer to the add-on
58 * @return True when all methods were resolved, false otherwise.
59 */
60 bool RegisterMe(void* handle)
61 {
62 m_Handle = handle;
63
64 std::string libBasePath;
65 libBasePath = ((cb_array*)m_Handle)->libPath;
66 libBasePath += CODEC_HELPER_DLL;
67
68#if defined(ANDROID)
69 struct stat st;
70 if(stat(libBasePath.c_str(),&st) != 0)
71 {
72 std::string tempbin = getenv("XBMC_ANDROID_LIBS");
73 libBasePath = tempbin + "/" + CODEC_HELPER_DLL_NAME;
74 }
75#endif
76
77 m_libXBMC_codec = dlopen(libBasePath.c_str(), RTLD_LAZY);
78 if (m_libXBMC_codec == NULL)
79 {
80 fprintf(stderr, "Unable to load %s\n", dlerror());
81 return false;
82 }
83
84 CODEC_register_me = (void* (*)(void *HANDLE))
85 dlsym(m_libXBMC_codec, "CODEC_register_me");
86 if (CODEC_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
87
88 CODEC_unregister_me = (void (*)(void* HANDLE, void* CB))
89 dlsym(m_libXBMC_codec, "CODEC_unregister_me");
90 if (CODEC_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
91
92 CODEC_get_codec_by_name = (xbmc_codec_t (*)(void* HANDLE, void* CB, const char* strCodecName))
93 dlsym(m_libXBMC_codec, "CODEC_get_codec_by_name");
94 if (CODEC_get_codec_by_name == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
95
96 m_Callbacks = CODEC_register_me(m_Handle);
97 return m_Callbacks != NULL;
98 }
99
100 /*!
101 * @brief Get the codec id used by XBMC
102 * @param strCodecName The name of the codec
103 * @return The codec_id, or a codec_id with 0 values when not supported
104 */
105 xbmc_codec_t GetCodecByName(const char* strCodecName)
106 {
107 return CODEC_get_codec_by_name(m_Handle, m_Callbacks, strCodecName);
108 }
109
110protected:
111 void* (*CODEC_register_me)(void*);
112 void (*CODEC_unregister_me)(void*, void*);
113 xbmc_codec_t (*CODEC_get_codec_by_name)(void *HANDLE, void* CB, const char* strCodecName);
114
115private:
116 void* m_libXBMC_codec;
117 void* m_Handle;
118 void* m_Callbacks;
119 struct cb_array
120 {
121 const char* libPath;
122 };
123};
124
diff --git a/addons/library.xbmc.gui/libXBMC_gui.h b/addons/library.xbmc.gui/libXBMC_gui.h
new file mode 100644
index 0000000..8dbc38b
--- /dev/null
+++ b/addons/library.xbmc.gui/libXBMC_gui.h
@@ -0,0 +1,845 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <string>
23#include <vector>
24#include <string.h>
25#include <stdlib.h>
26#include <stdio.h>
27#include "libXBMC_addon.h"
28
29typedef void* GUIHANDLE;
30
31#ifdef _WIN32
32#define GUI_HELPER_DLL "\\library.xbmc.gui\\libXBMC_gui" ADDON_HELPER_EXT
33#else
34#define GUI_HELPER_DLL_NAME "libXBMC_gui-" ADDON_HELPER_ARCH ADDON_HELPER_EXT
35#define GUI_HELPER_DLL "/library.xbmc.gui/" GUI_HELPER_DLL_NAME
36#endif
37
38/* current ADDONGUI API version */
39#define XBMC_GUI_API_VERSION "5.8.0"
40
41/* min. ADDONGUI API version */
42#define XBMC_GUI_MIN_API_VERSION "5.8.0"
43
44#define ADDON_ACTION_PREVIOUS_MENU 10
45#define ADDON_ACTION_CLOSE_DIALOG 51
46#define ADDON_ACTION_NAV_BACK 92
47
48class CAddonGUIWindow;
49class CAddonGUISpinControl;
50class CAddonGUIRadioButton;
51class CAddonGUIProgressControl;
52class CAddonListItem;
53class CAddonGUIRenderingControl;
54class CAddonGUISliderControl;
55class CAddonGUISettingsSliderControl;
56
57class CHelper_libXBMC_gui
58{
59public:
60 CHelper_libXBMC_gui()
61 {
62 m_libXBMC_gui = NULL;
63 m_Handle = NULL;
64 }
65
66 ~CHelper_libXBMC_gui()
67 {
68 if (m_libXBMC_gui)
69 {
70 GUI_unregister_me(m_Handle, m_Callbacks);
71 dlclose(m_libXBMC_gui);
72 }
73 }
74
75 bool RegisterMe(void *Handle)
76 {
77 m_Handle = Handle;
78
79 std::string libBasePath;
80 libBasePath = ((cb_array*)m_Handle)->libPath;
81 libBasePath += GUI_HELPER_DLL;
82
83#if defined(ANDROID)
84 struct stat st;
85 if(stat(libBasePath.c_str(),&st) != 0)
86 {
87 std::string tempbin = getenv("XBMC_ANDROID_LIBS");
88 libBasePath = tempbin + "/" + GUI_HELPER_DLL_NAME;
89 }
90#endif
91
92 m_libXBMC_gui = dlopen(libBasePath.c_str(), RTLD_LAZY);
93 if (m_libXBMC_gui == NULL)
94 {
95 fprintf(stderr, "Unable to load %s\n", dlerror());
96 return false;
97 }
98
99 GUI_register_me = (void* (*)(void *HANDLE))
100 dlsym(m_libXBMC_gui, "GUI_register_me");
101 if (GUI_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
102
103 GUI_unregister_me = (void (*)(void *HANDLE, void *CB))
104 dlsym(m_libXBMC_gui, "GUI_unregister_me");
105 if (GUI_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
106
107 GUI_lock = (void (*)(void *HANDLE, void *CB))
108 dlsym(m_libXBMC_gui, "GUI_lock");
109 if (GUI_lock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
110
111 GUI_unlock = (void (*)(void *HANDLE, void *CB))
112 dlsym(m_libXBMC_gui, "GUI_unlock");
113 if (GUI_unlock == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
114
115 GUI_get_screen_height = (int (*)(void *HANDLE, void *CB))
116 dlsym(m_libXBMC_gui, "GUI_get_screen_height");
117 if (GUI_get_screen_height == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
118
119 GUI_get_screen_width = (int (*)(void *HANDLE, void *CB))
120 dlsym(m_libXBMC_gui, "GUI_get_screen_width");
121 if (GUI_get_screen_width == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
122
123 GUI_get_video_resolution = (int (*)(void *HANDLE, void *CB))
124 dlsym(m_libXBMC_gui, "GUI_get_video_resolution");
125 if (GUI_get_video_resolution == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
126
127 GUI_Window_create = (CAddonGUIWindow* (*)(void *HANDLE, void *CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog))
128 dlsym(m_libXBMC_gui, "GUI_Window_create");
129 if (GUI_Window_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
130
131 GUI_Window_destroy = (void (*)(CAddonGUIWindow* p))
132 dlsym(m_libXBMC_gui, "GUI_Window_destroy");
133 if (GUI_Window_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
134
135 GUI_control_get_spin = (CAddonGUISpinControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
136 dlsym(m_libXBMC_gui, "GUI_control_get_spin");
137 if (GUI_control_get_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
138
139 GUI_control_release_spin = (void (*)(CAddonGUISpinControl* p))
140 dlsym(m_libXBMC_gui, "GUI_control_release_spin");
141 if (GUI_control_release_spin == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
142
143 GUI_control_get_radiobutton = (CAddonGUIRadioButton* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
144 dlsym(m_libXBMC_gui, "GUI_control_get_radiobutton");
145 if (GUI_control_get_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
146
147 GUI_control_release_radiobutton = (void (*)(CAddonGUIRadioButton* p))
148 dlsym(m_libXBMC_gui, "GUI_control_release_radiobutton");
149 if (GUI_control_release_radiobutton == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
150
151 GUI_control_get_progress = (CAddonGUIProgressControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
152 dlsym(m_libXBMC_gui, "GUI_control_get_progress");
153 if (GUI_control_get_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
154
155 GUI_control_release_progress = (void (*)(CAddonGUIProgressControl* p))
156 dlsym(m_libXBMC_gui, "GUI_control_release_progress");
157 if (GUI_control_release_progress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
158
159 GUI_ListItem_create = (CAddonListItem* (*)(void *HANDLE, void *CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path))
160 dlsym(m_libXBMC_gui, "GUI_ListItem_create");
161 if (GUI_ListItem_create == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
162
163 GUI_ListItem_destroy = (void (*)(CAddonListItem* p))
164 dlsym(m_libXBMC_gui, "GUI_ListItem_destroy");
165 if (GUI_ListItem_destroy == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
166
167 GUI_control_get_rendering = (CAddonGUIRenderingControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
168 dlsym(m_libXBMC_gui, "GUI_control_get_rendering");
169 if (GUI_control_get_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
170
171 GUI_control_release_rendering = (void (*)(CAddonGUIRenderingControl* p))
172 dlsym(m_libXBMC_gui, "GUI_control_release_rendering");
173 if (GUI_control_release_rendering == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
174
175 GUI_control_get_slider = (CAddonGUISliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
176 dlsym(m_libXBMC_gui, "GUI_control_get_slider");
177 if (GUI_control_get_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
178
179 GUI_control_release_slider = (void (*)(CAddonGUISliderControl* p))
180 dlsym(m_libXBMC_gui, "GUI_control_release_slider");
181 if (GUI_control_release_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
182
183 GUI_control_get_settings_slider = (CAddonGUISettingsSliderControl* (*)(void *HANDLE, void *CB, CAddonGUIWindow *window, int controlId))
184 dlsym(m_libXBMC_gui, "GUI_control_get_settings_slider");
185 if (GUI_control_get_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
186
187 GUI_control_release_settings_slider = (void (*)(CAddonGUISettingsSliderControl* p))
188 dlsym(m_libXBMC_gui, "GUI_control_release_settings_slider");
189 if (GUI_control_release_settings_slider == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
190
191 GUI_dialog_keyboard_show_and_get_input_with_head = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs))
192 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_get_input_with_head");
193 if (GUI_dialog_keyboard_show_and_get_input_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
194
195 GUI_dialog_keyboard_show_and_get_input = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs))
196 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_get_input");
197 if (GUI_dialog_keyboard_show_and_get_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
198
199 GUI_dialog_keyboard_show_and_get_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs))
200 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_get_new_password_with_head");
201 if (GUI_dialog_keyboard_show_and_get_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
202
203 GUI_dialog_keyboard_show_and_get_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs))
204 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_get_new_password");
205 if (GUI_dialog_keyboard_show_and_get_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
206
207 GUI_dialog_keyboard_show_and_verify_new_password_with_head = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs))
208 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_verify_new_password_with_head");
209 if (GUI_dialog_keyboard_show_and_verify_new_password_with_head == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
210
211 GUI_dialog_keyboard_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs))
212 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_verify_new_password");
213 if (GUI_dialog_keyboard_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
214
215 GUI_dialog_keyboard_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs))
216 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_verify_password");
217 if (GUI_dialog_keyboard_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
218
219 GUI_dialog_keyboard_show_and_get_filter = (bool (*)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs))
220 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_show_and_get_filter");
221 if (GUI_dialog_keyboard_show_and_get_filter == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
222
223 GUI_dialog_keyboard_send_text_to_active_keyboard = (bool (*)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard))
224 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_send_text_to_active_keyboard");
225 if (GUI_dialog_keyboard_send_text_to_active_keyboard == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
226
227 GUI_dialog_keyboard_is_activated = (bool (*)(void *HANDLE, void *CB))
228 dlsym(m_libXBMC_gui, "GUI_dialog_keyboard_is_activated");
229 if (GUI_dialog_keyboard_is_activated == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
230
231 GUI_dialog_numeric_show_and_verify_new_password = (bool (*)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize))
232 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_verify_new_password");
233 if (GUI_dialog_numeric_show_and_verify_new_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
234
235 GUI_dialog_numeric_show_and_verify_password = (int (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries))
236 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_verify_password");
237 if (GUI_dialog_numeric_show_and_verify_password == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
238
239 GUI_dialog_numeric_show_and_verify_input = (bool (*)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput))
240 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_verify_input");
241 if (GUI_dialog_numeric_show_and_verify_input == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
242
243 GUI_dialog_numeric_show_and_get_time = (bool (*)(void *HANDLE, void *CB, tm &time, const char *strHeading))
244 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_get_time");
245 if (GUI_dialog_numeric_show_and_get_time == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
246
247 GUI_dialog_numeric_show_and_get_date = (bool (*)(void *HANDLE, void *CB, tm &date, const char *strHeading))
248 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_get_date");
249 if (GUI_dialog_numeric_show_and_get_date == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
250
251 GUI_dialog_numeric_show_and_get_ipaddress = (bool (*)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading))
252 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_get_ipaddress");
253 if (GUI_dialog_numeric_show_and_get_ipaddress == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
254
255 GUI_dialog_numeric_show_and_get_number = (bool (*)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs))
256 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_get_number");
257 if (GUI_dialog_numeric_show_and_get_number == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
258
259 GUI_dialog_numeric_show_and_get_seconds = (bool (*)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading))
260 dlsym(m_libXBMC_gui, "GUI_dialog_numeric_show_and_get_seconds");
261 if (GUI_dialog_numeric_show_and_get_seconds == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
262
263 GUI_dialog_filebrowser_show_and_get_file = (bool (*)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList))
264 dlsym(m_libXBMC_gui, "GUI_dialog_filebrowser_show_and_get_file");
265 if (GUI_dialog_filebrowser_show_and_get_file == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
266
267 GUI_dialog_ok_show_and_get_input_single_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *text))
268 dlsym(m_libXBMC_gui, "GUI_dialog_ok_show_and_get_input_single_text");
269 if (GUI_dialog_ok_show_and_get_input_single_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
270
271 GUI_dialog_ok_show_and_get_input_line_text = (void (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2))
272 dlsym(m_libXBMC_gui, "GUI_dialog_ok_show_and_get_input_line_text");
273 if (GUI_dialog_ok_show_and_get_input_line_text == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
274
275 GUI_dialog_yesno_show_and_get_input_singletext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel))
276 dlsym(m_libXBMC_gui, "GUI_dialog_yesno_show_and_get_input_singletext");
277 if (GUI_dialog_yesno_show_and_get_input_singletext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
278
279 GUI_dialog_yesno_show_and_get_input_linetext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel))
280 dlsym(m_libXBMC_gui, "GUI_dialog_yesno_show_and_get_input_linetext");
281 if (GUI_dialog_yesno_show_and_get_input_linetext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
282
283 GUI_dialog_yesno_show_and_get_input_linebuttontext = (bool (*)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel))
284 dlsym(m_libXBMC_gui, "GUI_dialog_yesno_show_and_get_input_linebuttontext");
285 if (GUI_dialog_yesno_show_and_get_input_linebuttontext == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
286
287 GUI_dialog_text_viewer = (void (*)(void *hdl, void *cb, const char *heading, const char *text))
288 dlsym(m_libXBMC_gui, "GUI_dialog_text_viewer");
289 if (GUI_dialog_text_viewer == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
290
291 GUI_dialog_select = (int (*)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected))
292 dlsym(m_libXBMC_gui, "GUI_dialog_select");
293 if (GUI_dialog_select == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
294
295 m_Callbacks = GUI_register_me(m_Handle);
296 return m_Callbacks != NULL;
297 }
298
299 void Lock()
300 {
301 return GUI_lock(m_Handle, m_Callbacks);
302 }
303
304 void Unlock()
305 {
306 return GUI_unlock(m_Handle, m_Callbacks);
307 }
308
309 int GetScreenHeight()
310 {
311 return GUI_get_screen_height(m_Handle, m_Callbacks);
312 }
313
314 int GetScreenWidth()
315 {
316 return GUI_get_screen_width(m_Handle, m_Callbacks);
317 }
318
319 int GetVideoResolution()
320 {
321 return GUI_get_video_resolution(m_Handle, m_Callbacks);
322 }
323
324 CAddonGUIWindow* Window_create(const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog)
325 {
326 return GUI_Window_create(m_Handle, m_Callbacks, xmlFilename, defaultSkin, forceFallback, asDialog);
327 }
328
329 void Window_destroy(CAddonGUIWindow* p)
330 {
331 return GUI_Window_destroy(p);
332 }
333
334 CAddonGUISpinControl* Control_getSpin(CAddonGUIWindow *window, int controlId)
335 {
336 return GUI_control_get_spin(m_Handle, m_Callbacks, window, controlId);
337 }
338
339 void Control_releaseSpin(CAddonGUISpinControl* p)
340 {
341 return GUI_control_release_spin(p);
342 }
343
344 CAddonGUIRadioButton* Control_getRadioButton(CAddonGUIWindow *window, int controlId)
345 {
346 return GUI_control_get_radiobutton(m_Handle, m_Callbacks, window, controlId);
347 }
348
349 void Control_releaseRadioButton(CAddonGUIRadioButton* p)
350 {
351 return GUI_control_release_radiobutton(p);
352 }
353
354 CAddonGUIProgressControl* Control_getProgress(CAddonGUIWindow *window, int controlId)
355 {
356 return GUI_control_get_progress(m_Handle, m_Callbacks, window, controlId);
357 }
358
359 void Control_releaseProgress(CAddonGUIProgressControl* p)
360 {
361 return GUI_control_release_progress(p);
362 }
363
364 CAddonListItem* ListItem_create(const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path)
365 {
366 return GUI_ListItem_create(m_Handle, m_Callbacks, label, label2, iconImage, thumbnailImage, path);
367 }
368
369 void ListItem_destroy(CAddonListItem* p)
370 {
371 return GUI_ListItem_destroy(p);
372 }
373
374 CAddonGUIRenderingControl* Control_getRendering(CAddonGUIWindow *window, int controlId)
375 {
376 return GUI_control_get_rendering(m_Handle, m_Callbacks, window, controlId);
377 }
378
379 void Control_releaseRendering(CAddonGUIRenderingControl* p)
380 {
381 return GUI_control_release_rendering(p);
382 }
383
384 CAddonGUISliderControl* Control_getSlider(CAddonGUIWindow *window, int controlId)
385 {
386 return GUI_control_get_slider(m_Handle, m_Callbacks, window, controlId);
387 }
388
389 void Control_releaseSlider(CAddonGUISliderControl* p)
390 {
391 return GUI_control_release_slider(p);
392 }
393
394 CAddonGUISettingsSliderControl* Control_getSettingsSlider(CAddonGUIWindow *window, int controlId)
395 {
396 return GUI_control_get_settings_slider(m_Handle, m_Callbacks, window, controlId);
397 }
398
399 void Control_releaseSettingsSlider(CAddonGUISettingsSliderControl* p)
400 {
401 return GUI_control_release_settings_slider(p);
402 }
403
404 /*! @name GUI Keyboard functions */
405 //@{
406 bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs = 0)
407 {
408 return GUI_dialog_keyboard_show_and_get_input_with_head(m_Handle, m_Callbacks, strText, iMaxStringSize, strHeading, allowEmptyResult, hiddenInput, autoCloseMs);
409 }
410
411 bool Dialog_Keyboard_ShowAndGetInput(char &strText, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs = 0)
412 {
413 return GUI_dialog_keyboard_show_and_get_input(m_Handle, m_Callbacks, strText, iMaxStringSize, allowEmptyResult, autoCloseMs);
414 }
415
416 bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0)
417 {
418 return GUI_dialog_keyboard_show_and_get_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs);
419 }
420
421 bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0)
422 {
423 return GUI_dialog_keyboard_show_and_get_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs);
424 }
425
426 bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs = 0)
427 {
428 return GUI_dialog_keyboard_show_and_verify_new_password_with_head(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, strHeading, allowEmptyResult, autoCloseMs);
429 }
430
431 bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs = 0)
432 {
433 return GUI_dialog_keyboard_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize, autoCloseMs);
434 }
435
436 int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs = 0)
437 {
438 return GUI_dialog_keyboard_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries, autoCloseMs);
439 }
440
441 bool Dialog_Keyboard_ShowAndGetFilter(char &strText, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs = 0)
442 {
443 return GUI_dialog_keyboard_show_and_get_filter(m_Handle, m_Callbacks, strText, iMaxStringSize, searching, autoCloseMs);
444 }
445
446 bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard = false)
447 {
448 return GUI_dialog_keyboard_send_text_to_active_keyboard(m_Handle, m_Callbacks, aTextString, closeKeyboard);
449 }
450
451 bool Dialog_Keyboard_isKeyboardActivated()
452 {
453 return GUI_dialog_keyboard_is_activated(m_Handle, m_Callbacks);
454 }
455 //@}
456
457 /*! @name GUI Numeric functions */
458 //@{
459 bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize)
460 {
461 return GUI_dialog_numeric_show_and_verify_new_password(m_Handle, m_Callbacks, strNewPassword, iMaxStringSize);
462 }
463
464 int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries)
465 {
466 return GUI_dialog_numeric_show_and_verify_password(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, iRetries);
467 }
468
469 bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput)
470 {
471 return GUI_dialog_numeric_show_and_verify_input(m_Handle, m_Callbacks, strPassword, iMaxStringSize, strHeading, bGetUserInput);
472 }
473
474 bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading)
475 {
476 return GUI_dialog_numeric_show_and_get_time(m_Handle, m_Callbacks, time, strHeading);
477 }
478
479 bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading)
480 {
481 return GUI_dialog_numeric_show_and_get_date(m_Handle, m_Callbacks, date, strHeading);
482 }
483
484 bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading)
485 {
486 return GUI_dialog_numeric_show_and_get_ipaddress(m_Handle, m_Callbacks, strIPAddress, iMaxStringSize, strHeading);
487 }
488
489 bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs = 0)
490 {
491 return GUI_dialog_numeric_show_and_get_number(m_Handle, m_Callbacks, strInput, iMaxStringSize, strHeading, iAutoCloseTimeoutMs = 0);
492 }
493
494 bool Dialog_Numeric_ShowAndGetSeconds(char &strTime, unsigned int iMaxStringSize, const char *strHeading)
495 {
496 return GUI_dialog_numeric_show_and_get_seconds(m_Handle, m_Callbacks, strTime, iMaxStringSize, strHeading);
497 }
498 //@}
499
500 /*! @name GUI File browser functions */
501 //@{
502 bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &strPath, unsigned int iMaxStringSize, bool useThumbs = false, bool useFileDirectories = false, bool singleList = false)
503 {
504 return GUI_dialog_filebrowser_show_and_get_file(m_Handle, m_Callbacks, directory, mask, heading, strPath, iMaxStringSize, useThumbs, useFileDirectories, singleList);
505 }
506 //@}
507
508 /*! @name GUI OK Dialog functions */
509 //@{
510 void Dialog_OK_ShowAndGetInput(const char *heading, const char *text)
511 {
512 GUI_dialog_ok_show_and_get_input_single_text(m_Handle, m_Callbacks, heading, text);
513 }
514
515 void Dialog_OK_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2)
516 {
517 GUI_dialog_ok_show_and_get_input_line_text(m_Handle, m_Callbacks, heading, line0, line1, line2);
518 }
519 //@}
520
521 /*! @name GUI Yes No Dialog functions */
522 //@{
523 bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *text, bool& bCanceled, const char *noLabel = "", const char *yesLabel = "")
524 {
525 return GUI_dialog_yesno_show_and_get_input_singletext(m_Handle, m_Callbacks, heading, text, bCanceled, noLabel, yesLabel);
526 }
527
528 bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel = "", const char *yesLabel = "")
529 {
530 return GUI_dialog_yesno_show_and_get_input_linetext(m_Handle, m_Callbacks, heading, line0, line1, line2, noLabel, yesLabel);
531 }
532
533 bool Dialog_YesNo_ShowAndGetInput(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel = "", const char *yesLabel = "")
534 {
535 return GUI_dialog_yesno_show_and_get_input_linebuttontext(m_Handle, m_Callbacks, heading, line0, line1, line2, bCanceled, noLabel, yesLabel);
536 }
537 //@}
538
539 /*! @name GUI Text viewer Dialog */
540 //@{
541 void Dialog_TextViewer(const char *heading, const char *text)
542 {
543 return GUI_dialog_text_viewer(m_Handle, m_Callbacks, heading, text);
544 }
545 //@}
546
547 /*! @name GUI select Dialog */
548 //@{
549 int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected = -1)
550 {
551 return GUI_dialog_select(m_Handle, m_Callbacks, heading, entries, size, selected);
552 }
553 //@}
554
555protected:
556 void* (*GUI_register_me)(void *HANDLE);
557 void (*GUI_unregister_me)(void *HANDLE, void* CB);
558 void (*GUI_lock)(void *HANDLE, void* CB);
559 void (*GUI_unlock)(void *HANDLE, void* CB);
560 int (*GUI_get_screen_height)(void *HANDLE, void* CB);
561 int (*GUI_get_screen_width)(void *HANDLE, void* CB);
562 int (*GUI_get_video_resolution)(void *HANDLE, void* CB);
563 CAddonGUIWindow* (*GUI_Window_create)(void *HANDLE, void* CB, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog);
564 void (*GUI_Window_destroy)(CAddonGUIWindow* p);
565 CAddonGUISpinControl* (*GUI_control_get_spin)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
566 void (*GUI_control_release_spin)(CAddonGUISpinControl* p);
567 CAddonGUIRadioButton* (*GUI_control_get_radiobutton)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
568 void (*GUI_control_release_radiobutton)(CAddonGUIRadioButton* p);
569 CAddonGUIProgressControl* (*GUI_control_get_progress)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
570 void (*GUI_control_release_progress)(CAddonGUIProgressControl* p);
571 CAddonListItem* (*GUI_ListItem_create)(void *HANDLE, void* CB, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path);
572 void (*GUI_ListItem_destroy)(CAddonListItem* p);
573 CAddonGUIRenderingControl* (*GUI_control_get_rendering)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
574 void (*GUI_control_release_rendering)(CAddonGUIRenderingControl* p);
575 CAddonGUISliderControl* (*GUI_control_get_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
576 void (*GUI_control_release_slider)(CAddonGUISliderControl* p);
577 CAddonGUISettingsSliderControl* (*GUI_control_get_settings_slider)(void *HANDLE, void* CB, CAddonGUIWindow *window, int controlId);
578 void (*GUI_control_release_settings_slider)(CAddonGUISettingsSliderControl* p);
579 bool (*GUI_dialog_keyboard_show_and_get_input_with_head)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs);
580 bool (*GUI_dialog_keyboard_show_and_get_input)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs);
581 bool (*GUI_dialog_keyboard_show_and_get_new_password_with_head)(void *HANDLE, void *CB, char &newPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs);
582 bool (*GUI_dialog_keyboard_show_and_get_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs);
583 bool (*GUI_dialog_keyboard_show_and_verify_new_password_with_head)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, unsigned int autoCloseMs);
584 bool (*GUI_dialog_keyboard_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs);
585 int (*GUI_dialog_keyboard_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs);
586 bool (*GUI_dialog_keyboard_show_and_get_filter)(void *HANDLE, void *CB, char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs);
587 bool (*GUI_dialog_keyboard_send_text_to_active_keyboard)(void *HANDLE, void *CB, const char *aTextString, bool closeKeyboard);
588 bool (*GUI_dialog_keyboard_is_activated)(void *HANDLE, void *CB);
589 bool (*GUI_dialog_numeric_show_and_verify_new_password)(void *HANDLE, void *CB, char &strNewPassword, unsigned int iMaxStringSize);
590 int (*GUI_dialog_numeric_show_and_verify_password)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries);
591 bool (*GUI_dialog_numeric_show_and_verify_input)(void *HANDLE, void *CB, char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput);
592 bool (*GUI_dialog_numeric_show_and_get_time)(void *HANDLE, void *CB, tm &time, const char *strHeading);
593 bool (*GUI_dialog_numeric_show_and_get_date)(void *HANDLE, void *CB, tm &date, const char *strHeading);
594 bool (*GUI_dialog_numeric_show_and_get_ipaddress)(void *HANDLE, void *CB, char &IPAddress, unsigned int iMaxStringSize, const char *strHeading);
595 bool (*GUI_dialog_numeric_show_and_get_number)(void *HANDLE, void *CB, char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs);
596 bool (*GUI_dialog_numeric_show_and_get_seconds)(void *HANDLE, void *CB, char &strTime, unsigned int iMaxStringSize, const char *strHeading);
597 bool (*GUI_dialog_filebrowser_show_and_get_file)(void *HANDLE, void *CB, const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList);
598 void (*GUI_dialog_ok_show_and_get_input_single_text)(void *HANDLE, void *CB, const char *heading, const char *text);
599 void (*GUI_dialog_ok_show_and_get_input_line_text)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2);
600 bool (*GUI_dialog_yesno_show_and_get_input_singletext)(void *HANDLE, void *CB, const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel);
601 bool (*GUI_dialog_yesno_show_and_get_input_linetext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel);
602 bool (*GUI_dialog_yesno_show_and_get_input_linebuttontext)(void *HANDLE, void *CB, const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel);
603 void (*GUI_dialog_text_viewer)(void *hdl, void *cb, const char *heading, const char *text);
604 int (*GUI_dialog_select)(void *hdl, void *cb, const char *heading, const char *entries[], unsigned int size, int selected);
605
606private:
607 void *m_libXBMC_gui;
608 void *m_Handle;
609 void *m_Callbacks;
610 struct cb_array
611 {
612 const char* libPath;
613 };
614};
615
616class CAddonGUISpinControl
617{
618public:
619 CAddonGUISpinControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
620 virtual ~CAddonGUISpinControl(void) {}
621
622 virtual void SetVisible(bool yesNo);
623 virtual void SetText(const char *label);
624 virtual void Clear();
625 virtual void AddLabel(const char *label, int iValue);
626 virtual int GetValue();
627 virtual void SetValue(int iValue);
628
629private:
630 CAddonGUIWindow *m_Window;
631 int m_ControlId;
632 GUIHANDLE m_SpinHandle;
633 void *m_Handle;
634 void *m_cb;
635};
636
637class CAddonGUIRadioButton
638{
639public:
640 CAddonGUIRadioButton(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
641 virtual ~CAddonGUIRadioButton() {}
642
643 virtual void SetVisible(bool yesNo);
644 virtual void SetText(const char *label);
645 virtual void SetSelected(bool yesNo);
646 virtual bool IsSelected();
647
648private:
649 CAddonGUIWindow *m_Window;
650 int m_ControlId;
651 GUIHANDLE m_ButtonHandle;
652 void *m_Handle;
653 void *m_cb;
654};
655
656class CAddonGUIProgressControl
657{
658public:
659 CAddonGUIProgressControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
660 virtual ~CAddonGUIProgressControl(void) {}
661
662 virtual void SetPercentage(float fPercent);
663 virtual float GetPercentage() const;
664 virtual void SetInfo(int iInfo);
665 virtual int GetInfo() const;
666 virtual std::string GetDescription() const;
667
668private:
669 CAddonGUIWindow *m_Window;
670 int m_ControlId;
671 GUIHANDLE m_ProgressHandle;
672 void *m_Handle;
673 void *m_cb;
674};
675
676class CAddonGUISliderControl
677{
678public:
679 CAddonGUISliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
680 virtual ~CAddonGUISliderControl(void) {}
681
682 virtual void SetVisible(bool yesNo);
683 virtual std::string GetDescription() const;
684
685 virtual void SetIntRange(int iStart, int iEnd);
686 virtual void SetIntValue(int iValue);
687 virtual int GetIntValue() const;
688 virtual void SetIntInterval(int iInterval);
689
690 virtual void SetPercentage(float fPercent);
691 virtual float GetPercentage() const;
692
693 virtual void SetFloatRange(float fStart, float fEnd);
694 virtual void SetFloatValue(float fValue);
695 virtual float GetFloatValue() const;
696 virtual void SetFloatInterval(float fInterval);
697
698private:
699 CAddonGUIWindow *m_Window;
700 int m_ControlId;
701 GUIHANDLE m_SliderHandle;
702 void *m_Handle;
703 void *m_cb;
704};
705
706class CAddonGUISettingsSliderControl
707{
708public:
709 CAddonGUISettingsSliderControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
710 virtual ~CAddonGUISettingsSliderControl(void) {}
711
712 virtual void SetVisible(bool yesNo);
713 virtual void SetText(const char *label);
714 virtual std::string GetDescription() const;
715
716 virtual void SetIntRange(int iStart, int iEnd);
717 virtual void SetIntValue(int iValue);
718 virtual int GetIntValue() const;
719 virtual void SetIntInterval(int iInterval);
720
721 virtual void SetPercentage(float fPercent);
722 virtual float GetPercentage() const;
723
724 virtual void SetFloatRange(float fStart, float fEnd);
725 virtual void SetFloatValue(float fValue);
726 virtual float GetFloatValue() const;
727 virtual void SetFloatInterval(float fInterval);
728
729private:
730 CAddonGUIWindow *m_Window;
731 int m_ControlId;
732 GUIHANDLE m_SettingsSliderHandle;
733 void *m_Handle;
734 void *m_cb;
735};
736
737class CAddonListItem
738{
739friend class CAddonGUIWindow;
740
741public:
742 CAddonListItem(void *hdl, void *cb, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path);
743 virtual ~CAddonListItem(void) {}
744
745 virtual const char *GetLabel();
746 virtual void SetLabel(const char *label);
747 virtual const char *GetLabel2();
748 virtual void SetLabel2(const char *label);
749 virtual void SetIconImage(const char *image);
750 virtual void SetThumbnailImage(const char *image);
751 virtual void SetInfo(const char *Info);
752 virtual void SetProperty(const char *key, const char *value);
753 virtual const char *GetProperty(const char *key) const;
754 virtual void SetPath(const char *Path);
755
756// {(char*)"select();
757// {(char*)"isSelected();
758protected:
759 GUIHANDLE m_ListItemHandle;
760 void *m_Handle;
761 void *m_cb;
762};
763
764class CAddonGUIWindow
765{
766friend class CAddonGUISpinControl;
767friend class CAddonGUIRadioButton;
768friend class CAddonGUIProgressControl;
769friend class CAddonGUIRenderingControl;
770friend class CAddonGUISliderControl;
771friend class CAddonGUISettingsSliderControl;
772
773public:
774 CAddonGUIWindow(void *hdl, void *cb, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog);
775 virtual ~CAddonGUIWindow();
776
777 virtual bool Show();
778 virtual void Close();
779 virtual void DoModal();
780 virtual bool SetFocusId(int iControlId);
781 virtual int GetFocusId();
782 virtual bool SetCoordinateResolution(int res);
783 virtual void SetProperty(const char *key, const char *value);
784 virtual void SetPropertyInt(const char *key, int value);
785 virtual void SetPropertyBool(const char *key, bool value);
786 virtual void SetPropertyDouble(const char *key, double value);
787 virtual const char *GetProperty(const char *key) const;
788 virtual int GetPropertyInt(const char *key) const;
789 virtual bool GetPropertyBool(const char *key) const;
790 virtual double GetPropertyDouble(const char *key) const;
791 virtual void ClearProperties();
792 virtual int GetListSize();
793 virtual void ClearList();
794 virtual GUIHANDLE AddStringItem(const char *name, int itemPosition = -1);
795 virtual void AddItem(GUIHANDLE item, int itemPosition = -1);
796 virtual void AddItem(CAddonListItem *item, int itemPosition = -1);
797 virtual void RemoveItem(int itemPosition);
798 virtual GUIHANDLE GetListItem(int listPos);
799 virtual void SetCurrentListPosition(int listPos);
800 virtual int GetCurrentListPosition();
801 virtual void SetControlLabel(int controlId, const char *label);
802 virtual void MarkDirtyRegion();
803
804 virtual bool OnClick(int controlId);
805 virtual bool OnFocus(int controlId);
806 virtual bool OnInit();
807 virtual bool OnAction(int actionId);
808
809 GUIHANDLE m_cbhdl;
810 bool (*CBOnInit)(GUIHANDLE cbhdl);
811 bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId);
812 bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId);
813 bool (*CBOnAction)(GUIHANDLE cbhdl, int actionId);
814
815protected:
816 GUIHANDLE m_WindowHandle;
817 void *m_Handle;
818 void *m_cb;
819};
820
821class CAddonGUIRenderingControl
822{
823public:
824 CAddonGUIRenderingControl(void *hdl, void *cb, CAddonGUIWindow *window, int controlId);
825 virtual ~CAddonGUIRenderingControl();
826 virtual void Init();
827
828 virtual bool Create(int x, int y, int w, int h, void *device);
829 virtual void Render();
830 virtual void Stop();
831 virtual bool Dirty();
832
833 GUIHANDLE m_cbhdl;
834 bool (*CBCreate)(GUIHANDLE cbhdl, int x, int y, int w, int h, void *device);
835 void (*CBRender)(GUIHANDLE cbhdl);
836 void (*CBStop)(GUIHANDLE cbhdl);
837 bool (*CBDirty)(GUIHANDLE cbhdl);
838
839private:
840 CAddonGUIWindow *m_Window;
841 int m_ControlId;
842 GUIHANDLE m_RenderingHandle;
843 void *m_Handle;
844 void *m_cb;
845};
diff --git a/addons/library.xbmc.pvr/libXBMC_pvr.h b/addons/library.xbmc.pvr/libXBMC_pvr.h
new file mode 100644
index 0000000..3116514
--- /dev/null
+++ b/addons/library.xbmc.pvr/libXBMC_pvr.h
@@ -0,0 +1,332 @@
1#pragma once
2/*
3 * Copyright (C) 2005-2013 Team XBMC
4 * http://xbmc.org
5 *
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include <string>
23#include <vector>
24#include <string.h>
25#include <stdlib.h>
26#include <stdio.h>
27#include "xbmc_pvr_types.h"
28#include "libXBMC_addon.h"
29
30#ifdef _WIN32
31#define PVR_HELPER_DLL "\\library.xbmc.pvr\\libXBMC_pvr" ADDON_HELPER_EXT
32#else
33#define PVR_HELPER_DLL_NAME "libXBMC_pvr-" ADDON_HELPER_ARCH ADDON_HELPER_EXT
34#define PVR_HELPER_DLL "/library.xbmc.pvr/" PVR_HELPER_DLL_NAME
35#endif
36
37#define DVD_TIME_BASE 1000000
38#define DVD_NOPTS_VALUE (-1LL<<52) // should be possible to represent in both double and __int64
39
40class CHelper_libXBMC_pvr
41{
42public:
43 CHelper_libXBMC_pvr(void)
44 {
45 m_libXBMC_pvr = NULL;
46 m_Handle = NULL;
47 }
48
49 ~CHelper_libXBMC_pvr(void)
50 {
51 if (m_libXBMC_pvr)
52 {
53 PVR_unregister_me(m_Handle, m_Callbacks);
54 dlclose(m_libXBMC_pvr);
55 }
56 }
57
58 /*!
59 * @brief Resolve all callback methods
60 * @param handle Pointer to the add-on
61 * @return True when all methods were resolved, false otherwise.
62 */
63 bool RegisterMe(void* handle)
64 {
65 m_Handle = handle;
66
67 std::string libBasePath;
68 libBasePath = ((cb_array*)m_Handle)->libPath;
69 libBasePath += PVR_HELPER_DLL;
70
71#if defined(ANDROID)
72 struct stat st;
73 if(stat(libBasePath.c_str(),&st) != 0)
74 {
75 std::string tempbin = getenv("XBMC_ANDROID_LIBS");
76 libBasePath = tempbin + "/" + PVR_HELPER_DLL_NAME;
77 }
78#endif
79
80 m_libXBMC_pvr = dlopen(libBasePath.c_str(), RTLD_LAZY);
81 if (m_libXBMC_pvr == NULL)
82 {
83 fprintf(stderr, "Unable to load %s\n", dlerror());
84 return false;
85 }
86
87 PVR_register_me = (void* (*)(void *HANDLE))
88 dlsym(m_libXBMC_pvr, "PVR_register_me");
89 if (PVR_register_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
90
91 PVR_unregister_me = (void (*)(void* HANDLE, void* CB))
92 dlsym(m_libXBMC_pvr, "PVR_unregister_me");
93 if (PVR_unregister_me == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
94
95 PVR_transfer_epg_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const EPG_TAG *epgentry))
96 dlsym(m_libXBMC_pvr, "PVR_transfer_epg_entry");
97 if (PVR_transfer_epg_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
98
99 PVR_transfer_channel_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL *chan))
100 dlsym(m_libXBMC_pvr, "PVR_transfer_channel_entry");
101 if (PVR_transfer_channel_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
102
103 PVR_transfer_timer_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_TIMER *timer))
104 dlsym(m_libXBMC_pvr, "PVR_transfer_timer_entry");
105 if (PVR_transfer_timer_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
106
107 PVR_transfer_recording_entry = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_RECORDING *recording))
108 dlsym(m_libXBMC_pvr, "PVR_transfer_recording_entry");
109 if (PVR_transfer_recording_entry == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
110
111 PVR_add_menu_hook = (void (*)(void* HANDLE, void* CB, PVR_MENUHOOK *hook))
112 dlsym(m_libXBMC_pvr, "PVR_add_menu_hook");
113 if (PVR_add_menu_hook == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
114
115 PVR_recording = (void (*)(void* HANDLE, void* CB, const char *Name, const char *FileName, bool On))
116 dlsym(m_libXBMC_pvr, "PVR_recording");
117 if (PVR_recording == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
118
119 PVR_trigger_timer_update = (void (*)(void* HANDLE, void* CB))
120 dlsym(m_libXBMC_pvr, "PVR_trigger_timer_update");
121 if (PVR_trigger_timer_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
122
123 PVR_trigger_recording_update = (void (*)(void* HANDLE, void* CB))
124 dlsym(m_libXBMC_pvr, "PVR_trigger_recording_update");
125 if (PVR_trigger_recording_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
126
127 PVR_trigger_channel_update = (void (*)(void* HANDLE, void* CB))
128 dlsym(m_libXBMC_pvr, "PVR_trigger_channel_update");
129 if (PVR_trigger_channel_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
130
131 PVR_trigger_channel_groups_update = (void (*)(void* HANDLE, void* CB))
132 dlsym(m_libXBMC_pvr, "PVR_trigger_channel_groups_update");
133 if (PVR_trigger_channel_groups_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
134
135 PVR_trigger_epg_update = (void (*)(void* HANDLE, void* CB, unsigned int iChannelUid))
136 dlsym(m_libXBMC_pvr, "PVR_trigger_epg_update");
137 if (PVR_trigger_epg_update == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
138
139 PVR_transfer_channel_group = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP *group))
140 dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group");
141 if (PVR_transfer_channel_group == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
142
143 PVR_transfer_channel_group_member = (void (*)(void* HANDLE, void* CB, const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER *member))
144 dlsym(m_libXBMC_pvr, "PVR_transfer_channel_group_member");
145 if (PVR_transfer_channel_group_member == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
146
147#ifdef USE_DEMUX
148 PVR_free_demux_packet = (void (*)(void* HANDLE, void* CB, DemuxPacket* pPacket))
149 dlsym(m_libXBMC_pvr, "PVR_free_demux_packet");
150 if (PVR_free_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
151
152 PVR_allocate_demux_packet = (DemuxPacket* (*)(void* HANDLE, void* CB, int iDataSize))
153 dlsym(m_libXBMC_pvr, "PVR_allocate_demux_packet");
154 if (PVR_allocate_demux_packet == NULL) { fprintf(stderr, "Unable to assign function %s\n", dlerror()); return false; }
155#endif
156
157 m_Callbacks = PVR_register_me(m_Handle);
158 return m_Callbacks != NULL;
159 }
160
161 /*!
162 * @brief Transfer an EPG tag from the add-on to XBMC
163 * @param handle The handle parameter that XBMC used when requesting the EPG data
164 * @param entry The entry to transfer to XBMC
165 */
166 void TransferEpgEntry(const ADDON_HANDLE handle, const EPG_TAG* entry)
167 {
168 return PVR_transfer_epg_entry(m_Handle, m_Callbacks, handle, entry);
169 }
170
171 /*!
172 * @brief Transfer a channel entry from the add-on to XBMC
173 * @param handle The handle parameter that XBMC used when requesting the channel list
174 * @param entry The entry to transfer to XBMC
175 */
176 void TransferChannelEntry(const ADDON_HANDLE handle, const PVR_CHANNEL* entry)
177 {
178 return PVR_transfer_channel_entry(m_Handle, m_Callbacks, handle, entry);
179 }
180
181 /*!
182 * @brief Transfer a timer entry from the add-on to XBMC
183 * @param handle The handle parameter that XBMC used when requesting the timers list
184 * @param entry The entry to transfer to XBMC
185 */
186 void TransferTimerEntry(const ADDON_HANDLE handle, const PVR_TIMER* entry)
187 {
188 return PVR_transfer_timer_entry(m_Handle, m_Callbacks, handle, entry);
189 }
190
191 /*!
192 * @brief Transfer a recording entry from the add-on to XBMC
193 * @param handle The handle parameter that XBMC used when requesting the recordings list
194 * @param entry The entry to transfer to XBMC
195 */
196 void TransferRecordingEntry(const ADDON_HANDLE handle, const PVR_RECORDING* entry)
197 {
198 return PVR_transfer_recording_entry(m_Handle, m_Callbacks, handle, entry);
199 }
200
201 /*!
202 * @brief Transfer a channel group from the add-on to XBMC. The group will be created if it doesn't exist.
203 * @param handle The handle parameter that XBMC used when requesting the channel groups list
204 * @param entry The entry to transfer to XBMC
205 */
206 void TransferChannelGroup(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP* entry)
207 {
208 return PVR_transfer_channel_group(m_Handle, m_Callbacks, handle, entry);
209 }
210
211 /*!
212 * @brief Transfer a channel group member entry from the add-on to XBMC. The channel will be added to the group if the group can be found.
213 * @param handle The handle parameter that XBMC used when requesting the channel group members list
214 * @param entry The entry to transfer to XBMC
215 */
216 void TransferChannelGroupMember(const ADDON_HANDLE handle, const PVR_CHANNEL_GROUP_MEMBER* entry)
217 {
218 return PVR_transfer_channel_group_member(m_Handle, m_Callbacks, handle, entry);
219 }
220
221 /*!
222 * @brief Add or replace a menu hook for the context menu for this add-on
223 * @param hook The hook to add
224 */
225 void AddMenuHook(PVR_MENUHOOK* hook)
226 {
227 return PVR_add_menu_hook(m_Handle, m_Callbacks, hook);
228 }
229
230 /*!
231 * @brief Display a notification in XBMC that a recording started or stopped on the server
232 * @param strRecordingName The name of the recording to display
233 * @param strFileName The filename of the recording
234 * @param bOn True when recording started, false when it stopped
235 */
236 void Recording(const char* strRecordingName, const char* strFileName, bool bOn)
237 {
238 return PVR_recording(m_Handle, m_Callbacks, strRecordingName, strFileName, bOn);
239 }
240
241 /*!
242 * @brief Request XBMC to update it's list of timers
243 */
244 void TriggerTimerUpdate(void)
245 {
246 return PVR_trigger_timer_update(m_Handle, m_Callbacks);
247 }
248
249 /*!
250 * @brief Request XBMC to update it's list of recordings
251 */
252 void TriggerRecordingUpdate(void)
253 {
254 return PVR_trigger_recording_update(m_Handle, m_Callbacks);
255 }
256
257 /*!
258 * @brief Request XBMC to update it's list of channels
259 */
260 void TriggerChannelUpdate(void)
261 {
262 return PVR_trigger_channel_update(m_Handle, m_Callbacks);
263 }
264
265 /*!
266 * @brief Schedule an EPG update for the given channel channel
267 * @param iChannelUid The unique id of the channel for this add-on
268 */
269 void TriggerEpgUpdate(unsigned int iChannelUid)
270 {
271 return PVR_trigger_epg_update(m_Handle, m_Callbacks, iChannelUid);
272 }
273
274 /*!
275 * @brief Request XBMC to update it's list of channel groups
276 */
277 void TriggerChannelGroupsUpdate(void)
278 {
279 return PVR_trigger_channel_groups_update(m_Handle, m_Callbacks);
280 }
281
282#ifdef USE_DEMUX
283 /*!
284 * @brief Free a packet that was allocated with AllocateDemuxPacket
285 * @param pPacket The packet to free
286 */
287 void FreeDemuxPacket(DemuxPacket* pPacket)
288 {
289 return PVR_free_demux_packet(m_Handle, m_Callbacks, pPacket);
290 }
291
292 /*!
293 * @brief Allocate a demux packet. Free with FreeDemuxPacket
294 * @param iDataSize The size of the data that will go into the packet
295 * @return The allocated packet
296 */
297 DemuxPacket* AllocateDemuxPacket(int iDataSize)
298 {
299 return PVR_allocate_demux_packet(m_Handle, m_Callbacks, iDataSize);
300 }
301#endif
302
303protected:
304 void* (*PVR_register_me)(void*);
305 void (*PVR_unregister_me)(void*, void*);
306 void (*PVR_transfer_epg_entry)(void*, void*, const ADDON_HANDLE, const EPG_TAG*);
307 void (*PVR_transfer_channel_entry)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL*);
308 void (*PVR_transfer_timer_entry)(void*, void*, const ADDON_HANDLE, const PVR_TIMER*);
309 void (*PVR_transfer_recording_entry)(void*, void*, const ADDON_HANDLE, const PVR_RECORDING*);
310 void (*PVR_add_menu_hook)(void*, void*, PVR_MENUHOOK*);
311 void (*PVR_recording)(void*, void*, const char*, const char*, bool);
312 void (*PVR_trigger_channel_update)(void*, void*);
313 void (*PVR_trigger_channel_groups_update)(void*, void*);
314 void (*PVR_trigger_timer_update)(void*, void*);
315 void (*PVR_trigger_recording_update)(void* , void*);
316 void (*PVR_trigger_epg_update)(void*, void*, unsigned int);
317 void (*PVR_transfer_channel_group)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP*);
318 void (*PVR_transfer_channel_group_member)(void*, void*, const ADDON_HANDLE, const PVR_CHANNEL_GROUP_MEMBER*);
319#ifdef USE_DEMUX
320 void (*PVR_free_demux_packet)(void*, void*, DemuxPacket*);
321 DemuxPacket* (*PVR_allocate_demux_packet)(void*, void*, int);
322#endif
323
324private:
325 void* m_libXBMC_pvr;
326 void* m_Handle;
327 void* m_Callbacks;
328 struct cb_array
329 {
330 const char* libPath;
331 };
332};