92e65884d2ab3f4ac7a86bf5d4b05e86fc8409cd
[vuplus_xbmc] / xbmc / interfaces / legacy / ModuleXbmcplugin.h
1 /*
2  *      Copyright (C) 2005-2012 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 "Tuple.h"
23
24 #include "AddonString.h"
25 #include "ListItem.h"
26
27 #include "utils/log.h"
28
29 #include "SortFileItem.h"
30 #include "swighelper.h"
31
32 namespace XBMCAddon
33 {
34   namespace xbmcplugin
35   {
36     /**
37      * addDirectoryItem(handle, url, listitem [,isFolder, totalItems]) -- Callback function to pass directory contents back to XBMC.
38      *  - Returns a bool for successful completion.
39      * 
40      * handle      : integer - handle the plugin was started with.
41      * url         : string - url of the entry. would be plugin:// for another virtual directory
42      * listitem    : ListItem - item to add.
43      * isFolder    : [opt] bool - True=folder / False=not a folder(default).
44      * totalItems  : [opt] integer - total number of items that will be passed.(used for progressbar)
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      * example:
50      *   - if not xbmcplugin.addDirectoryItem(int(sys.argv[1]), 'F:\\\\Trailers\\\\300.mov', listitem, totalItems=50): break
51      */
52     bool addDirectoryItem(int handle, const String& url, const XBMCAddon::xbmcgui::ListItem* listitem,
53                           bool isFolder = false, int totalItems = 0);
54
55     /**
56      * addDirectoryItems(handle, items [,totalItems]) -- Callback function to pass directory contents back to XBMC as a list.
57      *  - Returns a bool for successful completion.
58      * 
59      * handle      : integer - handle the plugin was started with.
60      * items       : List - list of (url, listitem[, isFolder]) as a tuple to add.
61      * totalItems  : [opt] integer - total number of items that will be passed.(used for progressbar)
62      * 
63      *        Large lists benefit over using the standard addDirectoryItem()
64      *        You may call this more than once to add items in chunks
65      * 
66      * example:
67      *   - if not xbmcplugin.addDirectoryItems(int(sys.argv[1]), [(url, listitem, False,)]: raise
68      */
69     bool addDirectoryItems(int handle, 
70                            const std::vector<Tuple<String,const XBMCAddon::xbmcgui::ListItem*,bool> >& items, 
71                            int totalItems = 0);
72
73     /**
74      * endOfDirectory(handle[, succeeded, updateListing, cacheToDisc]) -- Callback function to tell XBMC that the end of the directory listing in a virtualPythonFolder module is reached.
75      * 
76      * handle           : integer - handle the plugin was started with.
77      * succeeded        : [opt] bool - True=script completed successfully(Default)/False=Script did not.
78      * updateListing    : [opt] bool - True=this folder should update the current listing/False=Folder is a subfolder(Default).
79      * cacheToDisc      : [opt] bool - True=Folder will cache if extended time(default)/False=this folder will never cache to disc.
80      * 
81      * example:
82      *   - xbmcplugin.endOfDirectory(int(sys.argv[1]), cacheToDisc=False)
83      */
84     void endOfDirectory(int handle, bool succeeded = true, bool updateListing = false, 
85                         bool cacheToDisc = true);
86
87     /**
88      * setResolvedUrl(handle, succeeded, listitem) -- Callback function to tell XBMC that the file plugin has been resolved to a url
89      * 
90      * handle           : integer - handle the plugin was started with.
91      * succeeded        : bool - True=script completed successfully/False=Script did not.
92      * listitem         : ListItem - item the file plugin resolved to for playback.
93      * 
94      * example:
95      *   - xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
96      */
97     void setResolvedUrl(int handle, bool succeeded, const XBMCAddon::xbmcgui::ListItem* listitem);
98
99     /**
100      * addSortMethod(handle, sortMethod, label2) -- Adds a sorting method for the media list.
101      * 
102      * handle      : integer - handle the plugin was started with.
103      * sortMethod  : integer - number for sortmethod see FileItem.h.
104      * label2Mask  : [opt] string - the label mask to use for the second label.  Defaults to '%D'
105      *               applies to: SORT_METHOD_NONE, SORT_METHOD_UNSORTED, SORT_METHOD_VIDEO_TITLE,
106      *                           SORT_METHOD_TRACKNUM, SORT_METHOD_FILE, SORT_METHOD_TITLE,
107      *                           SORT_METHOD_TITLE_IGNORE_THE, SORT_METHOD_LABEL,
108      *                           SORT_METHOD_LABEL_IGNORE_THE, SORT_METHOD_VIDEO_SORT_TITLE,
109      *                           SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE
110      * 
111      * example:
112      *   - xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE)
113      */
114     void addSortMethod(int handle, int sortMethod, const String& label2Mask = emptyString);
115
116     /**
117      * getSetting(handle, id) -- Returns the value of a setting as a string.
118      * 
119      * handle    : integer - handle the plugin was started with.
120      * id        : string - id of the setting that the module needs to access.
121      * 
122      * *Note, You can use the above as a keyword.
123      * 
124      * example:
125      *   - apikey = xbmcplugin.getSetting(int(sys.argv[1]), 'apikey')
126      */
127     String getSetting(int handle, const char* id);
128
129     /**
130      * setSetting(handle, id, value) -- Sets a plugin setting for the current running plugin.
131      * 
132      * handle    : integer - handle the plugin was started with.
133      * id        : string - id of the setting that the module needs to access.
134      * value     : string or unicode - value of the setting.
135      * 
136      * example:
137      *   - xbmcplugin.setSetting(int(sys.argv[1]), id='username', value='teamxbmc')
138      */
139     void setSetting(int handle, const String& id, const String& value);
140
141     /**
142      * setContent(handle, content) -- Sets the plugins content.
143      * 
144      * handle      : integer - handle the plugin was started with.
145      * content     : string - content type (eg. movies)
146      * 
147      *  *Note:  content: files, songs, artists, albums, movies, tvshows, episodes, musicvideos
148      * 
149      * example:
150      *   - xbmcplugin.setContent(int(sys.argv[1]), 'movies')
151      */
152     void setContent(int handle, const char* content);
153
154     /**
155      * setPluginCategory(handle, category) -- Sets the plugins name for skins to display.
156      * 
157      * handle      : integer - handle the plugin was started with.
158      * category    : string or unicode - plugins sub category.
159      * 
160      * example:
161      *   - xbmcplugin.setPluginCategory(int(sys.argv[1]), 'Comedy')
162      */
163     void setPluginCategory(int handle, const String& category);
164
165     /**
166      * setPluginFanart(handle, image, color1, color2, color3) -- Sets the plugins fanart and color for skins to display.
167      * 
168      * handle      : integer - handle the plugin was started with.
169      * image       : [opt] string - path to fanart image.
170      * color1      : [opt] hexstring - color1. (e.g. '0xFFFFFFFF')
171      * color2      : [opt] hexstring - color2. (e.g. '0xFFFF3300')
172      * color3      : [opt] hexstring - color3. (e.g. '0xFF000000')
173      * 
174      * example:
175      *   - xbmcplugin.setPluginFanart(int(sys.argv[1]), 'special://home/addons/plugins/video/Apple movie trailers II/fanart.png', color2='0xFFFF3300')\n
176      */
177     void setPluginFanart(int handle, const char* image = NULL, 
178                          const char* color1 = NULL,
179                          const char* color2 = NULL,
180                          const char* color3 = NULL);
181
182     /**
183      * setProperty(handle, key, value) -- Sets a container property for this plugin.
184      * 
185      * handle      : integer - handle the plugin was started with.
186      * key         : string - property name.
187      * value       : string or unicode - value of property.
188      * 
189      * *Note, Key is NOT case sensitive.
190      * 
191      * example:
192      *   - xbmcplugin.setProperty(int(sys.argv[1]), 'Emulator', 'M.A.M.E.')\n
193      */
194     void setProperty(int handle, const char* key, const String& value);
195
196     SWIG_CONSTANT(int,SORT_METHOD_NONE);
197     SWIG_CONSTANT(int,SORT_METHOD_LABEL);
198     SWIG_CONSTANT(int,SORT_METHOD_LABEL_IGNORE_THE);
199     SWIG_CONSTANT(int,SORT_METHOD_DATE);
200     SWIG_CONSTANT(int,SORT_METHOD_SIZE);
201     SWIG_CONSTANT(int,SORT_METHOD_FILE);
202     SWIG_CONSTANT(int,SORT_METHOD_DRIVE_TYPE);
203     SWIG_CONSTANT(int,SORT_METHOD_TRACKNUM);
204     SWIG_CONSTANT(int,SORT_METHOD_DURATION);
205     SWIG_CONSTANT(int,SORT_METHOD_TITLE);
206     SWIG_CONSTANT(int,SORT_METHOD_TITLE_IGNORE_THE);
207     SWIG_CONSTANT(int,SORT_METHOD_ARTIST);
208     SWIG_CONSTANT(int,SORT_METHOD_ARTIST_IGNORE_THE);
209     SWIG_CONSTANT(int,SORT_METHOD_ALBUM);
210     SWIG_CONSTANT(int,SORT_METHOD_ALBUM_IGNORE_THE);
211     SWIG_CONSTANT(int,SORT_METHOD_GENRE);
212     SWIG_CONSTANT2(int,SORT_METHOD_VIDEO_YEAR,SORT_METHOD_YEAR);
213     SWIG_CONSTANT(int,SORT_METHOD_VIDEO_RATING);
214     SWIG_CONSTANT(int,SORT_METHOD_PROGRAM_COUNT);
215     SWIG_CONSTANT(int,SORT_METHOD_PLAYLIST_ORDER);
216     SWIG_CONSTANT(int,SORT_METHOD_EPISODE);
217     SWIG_CONSTANT(int,SORT_METHOD_VIDEO_TITLE);
218     SWIG_CONSTANT(int,SORT_METHOD_VIDEO_SORT_TITLE);
219     SWIG_CONSTANT(int,SORT_METHOD_VIDEO_SORT_TITLE_IGNORE_THE);
220     SWIG_CONSTANT(int,SORT_METHOD_PRODUCTIONCODE);
221     SWIG_CONSTANT(int,SORT_METHOD_SONG_RATING);
222     SWIG_CONSTANT(int,SORT_METHOD_MPAA_RATING);
223     SWIG_CONSTANT(int,SORT_METHOD_VIDEO_RUNTIME);
224     SWIG_CONSTANT(int,SORT_METHOD_STUDIO);
225     SWIG_CONSTANT(int,SORT_METHOD_STUDIO_IGNORE_THE);
226     SWIG_CONSTANT(int,SORT_METHOD_UNSORTED);
227     SWIG_CONSTANT(int,SORT_METHOD_BITRATE);
228     SWIG_CONSTANT(int,SORT_METHOD_LISTENERS);
229   }
230 }