2 * Copyright (C) 2005-2013 Team XBMC
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)
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.
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
22 #include "AddonString.h"
24 //#include "Monitor.h"
26 #include "utils/log.h"
27 #include "utils/StdString.h"
29 #include "swighelper.h"
37 // This is a bit of a hack to get around a SWIG problem
38 extern const int lLOGNOTICE;
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)
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.
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.
56 * - xbmc.output(msg='This is a test string.', level=xbmc.LOGDEBUG));
58 void log(const char* msg, int level = lLOGNOTICE);
61 * Shutdown() -- Shutdown the xbox.
69 * restart() -- Restart the xbox.
76 * executescript(script) -- Execute a python script.
78 * script : string - script filename to execute.
81 * - xbmc.executescript('special://home/scripts/update.py')
83 void executescript(const char* script);
86 * executebuiltin(function) -- Execute a built in XBMC function.
88 * function : string - builtin function to execute.
90 * List of functions - http://wiki.xbmc.org/?title=List_of_Built_In_Functions
93 * - xbmc.executebuiltin('XBMC.RunXBE(c:\\\\avalaunch.xbe)')
95 void executebuiltin(const char* function, bool wait = false);
98 * executehttpapi(httpcommand) -- Not implemented anymore.
100 String executehttpapi(const char* httpcommand);
103 * executeJSONRPC(jsonrpccommand) -- Execute an JSONRPC command.
105 * jsonrpccommand : string - jsonrpc command to execute.
110 * - response = xbmc.executeJSONRPC('{ \"jsonrpc\": \"2.0\", \"method\": \"JSONRPC.Introspect\", \"id\": 1 }')
112 String executeJSONRPC(const char* jsonrpccommand);
115 * sleep(time) -- Sleeps for 'time' msec.
117 * time : integer - number of msec to sleep.
119 * *Note, This is useful if you have for example a Player class that is waiting
120 * for onPlayBackEnded() calls.
122 * Throws: PyExc_TypeError, if time is not an integer.
125 * - xbmc.sleep(2000) # sleeps for 2 seconds
127 void sleep(long timemillis);
130 * getLocalizedString(id) -- Returns a localized 'unicode string'.
132 * id : integer - id# for string you want to localize.
134 * *Note, See strings.xml in \\language\\{yourlanguage}\\ for which id
135 * you need for a string.
138 * - locstr = xbmc.getLocalizedString(6)
140 String getLocalizedString(int id);
143 * getSkinDir() -- Returns the active skin directory as a string.
145 * *Note, This is not the full path like 'special://home/addons/MediaCenter', but only 'MediaCenter'.
148 * - skindir = xbmc.getSkinDir()
153 * getLanguage() -- Returns the active language as a string.
156 * - language = xbmc.getLanguage()
158 String getLanguage();
161 * getIPAddress() -- Returns the current ip address as a string.
164 * - ip = xbmc.getIPAddress()
166 String getIPAddress();
169 * getDVDState() -- Returns the dvd state as an integer.
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
178 * - dvdstate = xbmc.getDVDState()
183 * getFreeMem() -- Returns the amount of free memory in MB as an integer.
186 * - freemem = xbmc.getFreeMem()
191 * getInfoLabel(infotag) -- Returns an InfoLabel as a string.
193 * infotag : string - infoTag for value you want returned.
195 * List of InfoTags - http://wiki.xbmc.org/?title=InfoLabels
198 * - label = xbmc.getInfoLabel('Weather.Conditions')
200 String getInfoLabel(const char* cLine);
203 * getInfoImage(infotag) -- Returns a filename including path to the InfoImage's
204 * thumbnail as a string.
206 * infotag : string - infotag for value you want returned.
208 * List of InfoTags - http://wiki.xbmc.org/?title=InfoLabels
211 * - filename = xbmc.getInfoImage('Weather.Conditions')
213 String getInfoImage(const char * infotag);
216 * playSFX(filename) -- Plays a wav file by filename
218 * filename : string - filename of the wav file to play.
221 * - xbmc.playSFX('special://xbmc/scripts/dingdong.wav')
223 void playSFX(const char* filename);
226 * enableNavSounds(yesNo) -- Enables/Disables nav sounds
228 * yesNo : integer - enable (True) or disable (False) nav sounds
231 * - xbmc.enableNavSounds(True)
233 void enableNavSounds(bool yesNo);
236 * getCondVisibility(condition) -- Returns True (1) or False (0) as a bool.
238 * condition : string - condition to check.
240 * List of Conditions - http://wiki.xbmc.org/?title=List_of_Boolean_Conditions
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.
246 * - visible = xbmc.getCondVisibility('[Control.IsVisible(41) + !Control.IsVisible(12)]')
248 bool getCondVisibility(const char *condition);
251 * getGlobalIdleTime() -- Returns the elapsed idle time in seconds as an integer.
254 * - t = xbmc.getGlobalIdleTime()
256 int getGlobalIdleTime();
259 * getCacheThumbName(path) -- Returns a thumb cache filename.
261 * path : string or unicode - path to file
264 * - thumb = xbmc.getCacheThumbName('f:\\\\videos\\\\movie.avi')
266 String getCacheThumbName(const String& path);
269 * makeLegalFilename(filename[, fatX]) -- Returns a legal filename or path as a string.
271 * filename : string or unicode - filename/path to make legal
272 * fatX : [opt] bool - True=Xbox file system(Default)
274 * *Note, If fatX is true you should pass a full path. If fatX is false only pass
275 * the basename of the path.
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.
281 * - filename = xbmc.makeLegalFilename('F:\\Trailers\\Ice Age: The Meltdown.avi')
283 String makeLegalFilename(const String& filename,bool fatX = true);
286 * translatePath(path) -- Returns the translated path.
288 * path : string or unicode - Path to format
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.
295 * - fpath = xbmc.translatePath('special://masterprofile/script_data')
297 String translatePath(const String& path);
300 * getCleanMovieTitle(path[, usefoldername]) -- Returns a clean movie title and year string if available.
302 * path : string or unicode - String to clean
303 * bool : [opt] bool - use folder names (defaults to false)
306 * - title, year = xbmc.getCleanMovieTitle('/path/to/moviefolder/test.avi', True)
308 Tuple<String,String> getCleanMovieTitle(const String& path, bool usefoldername = false);
311 * validatePath(path) -- Returns the validated path.
313 * path : string or unicode - Path to format
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'
319 * - fpath = xbmc.validatePath(somepath)
321 String validatePath(const String& path);
324 * getRegion(id) -- Returns your regions setting as a string for the specified id.
326 * id : string - id of setting to return
328 * *Note, choices are (dateshort, datelong, time, meridiem, tempunit, speedunit)
330 * You can use the above as keywords for arguments.
333 * - date_long_format = xbmc.getRegion('datelong')
335 String getRegion(const char* id);
338 * getSupportedMedia(media) -- Returns the supported file types for the specific media as a string.
340 * media : string - media type
342 * *Note, media type can be (video, music, picture).
344 * The return value is a pipe separated string of filetypes (eg. '.mov|.avi').
346 * You can use the above as keywords for arguments.
349 * - mTypes = xbmc.getSupportedMedia('video')
351 String getSupportedMedia(const char* mediaType);
354 * skinHasImage(image) -- Returns True if the image file exists in the skin.
356 * image : string - image filename
358 * *Note, If the media resides in a subfolder include it. (eg. home-myfiles\\\\home-myfiles2.png)
360 * You can use the above as keywords for arguments.
363 * - exists = xbmc.skinHasImage('ButtonFocusedTexture.png')
365 bool skinHasImage(const char* image);
368 * startServer(typ, bStart, bWait) -- start or stop a server.
370 * typ : integer - use SERVER_* constants
372 * bStart : bool - start (True) or stop (False) a server
374 * bWait : [opt] bool - wait on stop before returning (not supported by all servers)
376 * returnValue : bool - True or False
378 * - xbmc.startServer(xbmc.SERVER_AIRPLAYSERVER, False)
380 bool startServer(int iTyp, bool bStart, bool bWait = false);
383 * audioSuspend() -- Suspend Audio engine.
386 * xbmc.audioSuspend()
391 * audioResume() -- Resume Audio engine.
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);
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);
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);
430 SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_FLAG_CONTINUOUS);
431 SWIG_CONSTANT_FROM_GETTER(int,CAPTURE_FLAG_IMMEDIATELY);
433 void registerMonitor(Monitor* monitor);
434 void unregisterMonitor(Monitor* monitor);