[cosmetics] update date in GPL header
[vuplus_xbmc] / xbmc / interfaces / legacy / ModuleXbmc.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program 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
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, write to
17  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18  *  http://www.gnu.org/copyleft/gpl.html
19  *
20  */
21
22 #include "AddonString.h"
23 #include "Tuple.h"
24 //#include "Monitor.h"
25
26 #include "utils/log.h"
27 #include "utils/StdString.h"
28
29 #include "swighelper.h"
30 #include <vector>
31
32 namespace XBMCAddon
33 {
34   namespace xbmc
35   {
36 #ifndef SWIG
37     // This is a bit of a hack to get around a SWIG problem
38     extern const int lLOGNOTICE;
39 #endif
40
41     /**
42      * log(msg[, level]) -- Write a string to XBMC's log file and the debug window.
43      *     msg            : string - text to output.
44      *     level          : [opt] integer - log level to ouput at. (default=LOGNOTICE)
45      *     
46      * *Note, You can use the above as keywords for arguments and skip certain optional arguments.
47      *        Once you use a keyword, all following arguments require the keyword.
48      * 
49      * Text is written to the log for the following conditions.
50      *           XBMC loglevel == -1 (NONE, nothing at all is logged)
51      *           XBMC loglevel == 0 (NORMAL, shows LOGNOTICE, LOGERROR, LOGSEVERE and LOGFATAL)\
52      *           XBMC loglevel == 1 (DEBUG, shows all)
53      *           See pydocs for valid values for level.
54      *           
55      *           example:
56      *             - xbmc.output(msg='This is a test string.', level=xbmc.LOGDEBUG));
57      */
58     void log(const char* msg, int level = lLOGNOTICE);
59
60     /**
61      * Shutdown() -- Shutdown the xbox.
62      *
63      * example:
64      *  - xbmc.shutdown()
65      */
66     void shutdown();
67
68     /**
69      * restart() -- Restart the xbox.
70      * example:
71      *  - xbmc.restart()
72      */
73     void restart();
74
75     /**
76      * executescript(script) -- Execute a python script.
77      * 
78      * script         : string - script filename to execute.
79      * 
80      * example:
81      *   - xbmc.executescript('special://home/scripts/update.py')
82      */
83     void executescript(const char* script);
84
85     /**
86      * executebuiltin(function) -- Execute a built in XBMC function.
87      * 
88      * function       : string - builtin function to execute.
89      * 
90      * List of functions - http://wiki.xbmc.org/?title=List_of_Built_In_Functions 
91      * 
92      * example:
93      *   - xbmc.executebuiltin('XBMC.RunXBE(c:\\\\avalaunch.xbe)')
94      */
95     void executebuiltin(const char* function, bool wait = false);
96
97     /**
98      * executehttpapi(httpcommand) -- Not implemented anymore.
99      */
100     String executehttpapi(const char* httpcommand);
101
102     /**
103      * executeJSONRPC(jsonrpccommand) -- Execute an JSONRPC command.
104      * 
105      * jsonrpccommand    : string - jsonrpc command to execute.
106      * 
107      * List of commands - 
108      * 
109      * example:
110      *   - response = xbmc.executeJSONRPC('{ \"jsonrpc\": \"2.0\", \"method\": \"JSONRPC.Introspect\", \"id\": 1 }')
111      */
112     String executeJSONRPC(const char* jsonrpccommand);
113
114     /**
115      * sleep(time) -- Sleeps for 'time' msec.
116      * 
117      * time           : integer - number of msec to sleep.
118      * 
119      * *Note, This is useful if you have for example a Player class that is waiting
120      *        for onPlayBackEnded() calls.
121      * 
122      * Throws: PyExc_TypeError, if time is not an integer.
123      * 
124      * example:
125      *   - xbmc.sleep(2000) # sleeps for 2 seconds
126      */
127     void sleep(long timemillis);
128
129     /**
130      * getLocalizedString(id) -- Returns a localized 'unicode string'.
131      * 
132      * id             : integer - id# for string you want to localize.
133      * 
134      * *Note, See strings.xml in \\language\\{yourlanguage}\\ for which id
135      *        you need for a string.
136      * 
137      * example:
138      *   - locstr = xbmc.getLocalizedString(6)
139      */
140     String getLocalizedString(int id);
141
142     /**
143      * getSkinDir() -- Returns the active skin directory as a string.
144      * 
145      * *Note, This is not the full path like 'special://home/addons/MediaCenter', but only 'MediaCenter'.
146      * 
147      * example:
148      *   - skindir = xbmc.getSkinDir()
149      */
150     String getSkinDir();
151
152     /**
153      * getLanguage() -- Returns the active language as a string.
154      * 
155      * example:
156      *   - language = xbmc.getLanguage()
157      */
158     String getLanguage();
159
160     /**
161      * getIPAddress() -- Returns the current ip address as a string.
162      * 
163      * example:
164      *   - ip = xbmc.getIPAddress()
165      */
166     String getIPAddress();
167
168     /**
169      * getDVDState() -- Returns the dvd state as an integer.
170      * 
171      * return values are:
172      *    1 : xbmc.DRIVE_NOT_READY
173      *   16 : xbmc.TRAY_OPEN
174      *   64 : xbmc.TRAY_CLOSED_NO_MEDIA
175      *   96 : xbmc.TRAY_CLOSED_MEDIA_PRESENT
176      * 
177      * example:
178      *   - dvdstate = xbmc.getDVDState()
179      */
180     long getDVDState();
181
182     /**
183      * getFreeMem() -- Returns the amount of free memory in MB as an integer.
184      * 
185      * example:
186      *   - freemem = xbmc.getFreeMem()
187      */
188     long getFreeMem();
189
190     /**
191      * getInfoLabel(infotag) -- Returns an InfoLabel as a string.
192      * 
193      * infotag        : string - infoTag for value you want returned.
194      * 
195      * List of InfoTags - http://wiki.xbmc.org/?title=InfoLabels 
196      * 
197      * example:
198      *   - label = xbmc.getInfoLabel('Weather.Conditions')
199      */
200     String getInfoLabel(const char* cLine);
201
202     /**
203      * getInfoImage(infotag) -- Returns a filename including path to the InfoImage's
204      *                          thumbnail as a string.
205      * 
206      * infotag        : string - infotag for value you want returned.
207      * 
208      * List of InfoTags - http://wiki.xbmc.org/?title=InfoLabels 
209      * 
210      * example:
211      *   - filename = xbmc.getInfoImage('Weather.Conditions')
212      */
213     String getInfoImage(const char * infotag);
214
215     /**
216      * playSFX(filename) -- Plays a wav file by filename
217      * 
218      * filename       : string - filename of the wav file to play.
219      * 
220      * example:
221      *   - xbmc.playSFX('special://xbmc/scripts/dingdong.wav')
222      */
223     void playSFX(const char* filename);
224
225     /**
226      * enableNavSounds(yesNo) -- Enables/Disables nav sounds
227      * 
228      * yesNo          : integer - enable (True) or disable (False) nav sounds
229      * 
230      * example:
231      *   - xbmc.enableNavSounds(True)
232      */
233     void enableNavSounds(bool yesNo);
234
235     /**
236      * getCondVisibility(condition) -- Returns True (1) or False (0) as a bool.
237      * 
238      * condition      : string - condition to check.
239      * 
240      * List of Conditions - http://wiki.xbmc.org/?title=List_of_Boolean_Conditions 
241      * 
242      * *Note, You can combine two (or more) of the above settings by using \"+\" as an AND operator,
243      * \"|\" as an OR operator, \"!\" as a NOT operator, and \"[\" and \"]\" to bracket expressions.
244      * 
245      * example:
246      *   - visible = xbmc.getCondVisibility('[Control.IsVisible(41) + !Control.IsVisible(12)]')
247      */
248     bool getCondVisibility(const char *condition);
249
250     /**
251      * getGlobalIdleTime() -- Returns the elapsed idle time in seconds as an integer.
252      * 
253      * example:
254      *   - t = xbmc.getGlobalIdleTime()
255      */
256     int getGlobalIdleTime();
257
258     /**
259      * getCacheThumbName(path) -- Returns a thumb cache filename.
260      * 
261      * path           : string or unicode - path to file
262      * 
263      * example:
264      *   - thumb = xbmc.getCacheThumbName('f:\\\\videos\\\\movie.avi')
265      */
266     String getCacheThumbName(const String& path);
267
268     /**
269      * makeLegalFilename(filename[, fatX]) -- Returns a legal filename or path as a string.
270      * 
271      * filename       : string or unicode - filename/path to make legal
272      * fatX           : [opt] bool - True=Xbox file system(Default)
273      * 
274      * *Note, If fatX is true you should pass a full path. If fatX is false only pass
275      *        the basename of the path.
276      * 
277      *        You can use the above as keywords for arguments and skip certain optional arguments.
278      *        Once you use a keyword, all following arguments require the keyword.
279      * 
280      * example:
281      *   - filename = xbmc.makeLegalFilename('F:\\Trailers\\Ice Age: The Meltdown.avi')
282      */
283     String makeLegalFilename(const String& filename,bool fatX = true);
284
285     /**
286      * translatePath(path) -- Returns the translated path.
287      * 
288      * path           : string or unicode - Path to format
289      * 
290      * *Note, Only useful if you are coding for both Linux and Windows/Xbox.
291      *        e.g. Converts 'special://masterprofile/script_data' -> '/home/user/XBMC/UserData/script_data'
292      *        on Linux. Would return 'special://masterprofile/script_data' on the Xbox.
293      * 
294      * example:
295      *   - fpath = xbmc.translatePath('special://masterprofile/script_data')
296      */
297     String translatePath(const String& path);
298
299     /**
300      * getCleanMovieTitle(path[, usefoldername]) -- Returns a clean movie title and year string if available.
301      * 
302      * path           : string or unicode - String to clean
303      * bool           : [opt] bool - use folder names (defaults to false)
304      * 
305      * example:
306      *   - title, year = xbmc.getCleanMovieTitle('/path/to/moviefolder/test.avi', True)
307      */
308     Tuple<String,String> getCleanMovieTitle(const String& path, bool usefoldername = false);
309
310     /**
311      * validatePath(path) -- Returns the validated path.
312      * 
313      * path           : string or unicode - Path to format
314      * 
315      * *Note, Only useful if you are coding for both Linux and Windows/Xbox for fixing slash problems.
316      *        e.g. Corrects 'Z://something' -> 'Z:\\something'
317      * 
318      * example:
319      *   - fpath = xbmc.validatePath(somepath)
320      */
321     String validatePath(const String& path);
322
323     /**
324      * getRegion(id) -- Returns your regions setting as a string for the specified id.
325      * 
326      * id             : string - id of setting to return
327      * 
328      * *Note, choices are (dateshort, datelong, time, meridiem, tempunit, speedunit)
329      * 
330      *        You can use the above as keywords for arguments.
331      * 
332      * example:
333      *   - date_long_format = xbmc.getRegion('datelong')
334      */
335     String getRegion(const char* id);
336
337     /**
338      * getSupportedMedia(media) -- Returns the supported file types for the specific media as a string.
339      * 
340      * media          : string - media type
341      * 
342      * *Note, media type can be (video, music, picture).
343      * 
344      *        The return value is a pipe separated string of filetypes (eg. '.mov|.avi').
345      * 
346      *        You can use the above as keywords for arguments.
347      * 
348      * example:
349      *   - mTypes = xbmc.getSupportedMedia('video')
350      */
351     String getSupportedMedia(const char* mediaType);
352
353     /**
354      * skinHasImage(image) -- Returns True if the image file exists in the skin.
355      * 
356      * image          : string - image filename
357      * 
358      * *Note, If the media resides in a subfolder include it. (eg. home-myfiles\\\\home-myfiles2.png)
359      * 
360      *        You can use the above as keywords for arguments.
361      * 
362      * example:
363      *   - exists = xbmc.skinHasImage('ButtonFocusedTexture.png')
364      */
365     bool skinHasImage(const char* image);
366
367     /**
368      * startServer(typ, bStart, bWait) -- start or stop a server.
369      * 
370      * typ          : integer - use SERVER_* constants
371      * 
372      * bStart       : bool - start (True) or stop (False) a server
373      * 
374      * bWait        : [opt] bool - wait on stop before returning (not supported by all servers)
375      * 
376      * returnValue  : bool - True or False
377      * example:
378      *   - xbmc.startServer(xbmc.SERVER_AIRPLAYSERVER, False)
379      */
380     bool startServer(int iTyp, bool bStart, bool bWait = false);
381
382     /**
383      * audioSuspend() -- Suspend Audio engine.
384      * 
385      * example:
386      *   xbmc.audioSuspend()
387      */
388     void audioSuspend();
389
390     /**
391      * audioResume() -- Resume Audio engine.
392      * 
393      * example:
394      *   xbmc.audioResume()
395      */  
396     void audioResume();
397
398     SWIG_CONSTANT_FROM_GETTER(int,SERVER_WEBSERVER);
399     SWIG_CONSTANT_FROM_GETTER(int,SERVER_AIRPLAYSERVER);
400     SWIG_CONSTANT_FROM_GETTER(int,SERVER_UPNPSERVER);
401     SWIG_CONSTANT_FROM_GETTER(int,SERVER_UPNPRENDERER);
402     SWIG_CONSTANT_FROM_GETTER(int,SERVER_EVENTSERVER);
403     SWIG_CONSTANT_FROM_GETTER(int,SERVER_JSONRPCSERVER);
404     SWIG_CONSTANT_FROM_GETTER(int,SERVER_ZEROCONF);
405
406     SWIG_CONSTANT_FROM_GETTER(int,PLAYLIST_MUSIC);
407     SWIG_CONSTANT_FROM_GETTER(int,PLAYLIST_VIDEO);
408     SWIG_CONSTANT_FROM_GETTER(int,PLAYER_CORE_AUTO);
409     SWIG_CONSTANT_FROM_GETTER(int,PLAYER_CORE_DVDPLAYER);
410     SWIG_CONSTANT_FROM_GETTER(int,PLAYER_CORE_MPLAYER);
411     SWIG_CONSTANT_FROM_GETTER(int,PLAYER_CORE_PAPLAYER);
412     SWIG_CONSTANT_FROM_GETTER(int,TRAY_OPEN);
413     SWIG_CONSTANT_FROM_GETTER(int,DRIVE_NOT_READY);
414     SWIG_CONSTANT_FROM_GETTER(int,TRAY_CLOSED_NO_MEDIA);
415     SWIG_CONSTANT_FROM_GETTER(int,TRAY_CLOSED_MEDIA_PRESENT);
416     SWIG_CONSTANT_FROM_GETTER(int,LOGDEBUG);
417     SWIG_CONSTANT_FROM_GETTER(int,LOGINFO);
418     SWIG_CONSTANT_FROM_GETTER(int,LOGNOTICE);
419     SWIG_CONSTANT_FROM_GETTER(int,LOGWARNING);
420     SWIG_CONSTANT_FROM_GETTER(int,LOGERROR);
421     SWIG_CONSTANT_FROM_GETTER(int,LOGSEVERE);
422     SWIG_CONSTANT_FROM_GETTER(int,LOGFATAL);
423     SWIG_CONSTANT_FROM_GETTER(int,LOGNONE);
424
425
426     SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_STATE_WORKING);
427     SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_STATE_DONE);
428     SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_STATE_FAILED);
429
430     SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_FLAG_CONTINUOUS);
431     SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_FLAG_IMMEDIATELY);
432 #if 0
433     void registerMonitor(Monitor* monitor);
434     void unregisterMonitor(Monitor* monitor);
435 #endif
436   }
437 }