00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 package org.xbmc.android.jsonrpc.api.model;
00022
00023 import android.os.Parcel;
00024 import android.os.Parcelable;
00025 import java.util.ArrayList;
00026 import java.util.Arrays;
00027 import java.util.HashSet;
00028 import java.util.List;
00029 import java.util.Set;
00030 import org.codehaus.jackson.JsonNode;
00031 import org.codehaus.jackson.node.ArrayNode;
00032 import org.codehaus.jackson.node.ObjectNode;
00033 import org.xbmc.android.jsonrpc.api.AbstractModel;
00034
00035 public final class GUIModel {
00036
00043 public static class PropertyValue extends AbstractModel {
00044 public final static String API_TYPE = "GUI.Property.Value";
00045
00046
00047 public static final String CURRENTCONTROL = "currentcontrol";
00048 public static final String CURRENTWINDOW = "currentwindow";
00049 public static final String FULLSCREEN = "fullscreen";
00050 public static final String SKIN = "skin";
00051
00052
00053 public final Currentcontrol currentcontrol;
00054 public final Currentwindow currentwindow;
00055 public final Boolean fullscreen;
00056 public final Skin skin;
00057
00064 public PropertyValue(Currentcontrol currentcontrol, Currentwindow currentwindow, Boolean fullscreen, Skin skin) {
00065 this.currentcontrol = currentcontrol;
00066 this.currentwindow = currentwindow;
00067 this.fullscreen = fullscreen;
00068 this.skin = skin;
00069 }
00070
00075 public PropertyValue(JsonNode node) {
00076 currentcontrol = node.has(CURRENTCONTROL) ? new Currentcontrol(node.get(CURRENTCONTROL)) : null;
00077 currentwindow = node.has(CURRENTWINDOW) ? new Currentwindow(node.get(CURRENTWINDOW)) : null;
00078 fullscreen = parseBoolean(node, FULLSCREEN);
00079 skin = node.has(SKIN) ? new Skin(node.get(SKIN)) : null;
00080 }
00081
00082 @Override
00083 public JsonNode toJsonNode() {
00084 final ObjectNode node = OM.createObjectNode();
00085 node.put(CURRENTCONTROL, currentcontrol.toJsonNode());
00086 node.put(CURRENTWINDOW, currentwindow.toJsonNode());
00087 node.put(FULLSCREEN, fullscreen);
00088 node.put(SKIN, skin.toJsonNode());
00089 return node;
00090 }
00091
00097 static List<PropertyValue> getGUIModelPropertyValueList(JsonNode node, String key) {
00098 if (node.has(key)) {
00099 final ArrayNode a = (ArrayNode)node.get(key);
00100 final List<PropertyValue> l = new ArrayList<PropertyValue>(a.size());
00101 for (int i = 0; i < a.size(); i++) {
00102 l.add(new PropertyValue((JsonNode)a.get(i)));
00103 }
00104 return l;
00105 }
00106 return new ArrayList<PropertyValue>(0);
00107 }
00108
00114 @Override
00115 public void writeToParcel(Parcel parcel, int flags) {
00116 parcel.writeValue(currentcontrol);
00117 parcel.writeValue(currentwindow);
00118 parcel.writeInt(fullscreen ? 1 : 0);
00119 parcel.writeValue(skin);
00120 }
00121
00125 protected PropertyValue(Parcel parcel) {
00126 currentcontrol = parcel.<Currentcontrol>readParcelable(Currentcontrol.class.getClassLoader());
00127 currentwindow = parcel.<Currentwindow>readParcelable(Currentwindow.class.getClassLoader());
00128 fullscreen = parcel.readInt() == 1;
00129 skin = parcel.<Skin>readParcelable(Skin.class.getClassLoader());
00130 }
00131
00135 public static final Parcelable.Creator<PropertyValue> CREATOR = new Parcelable.Creator<PropertyValue>() {
00136 @Override
00137 public PropertyValue createFromParcel(Parcel parcel) {
00138 return new PropertyValue(parcel);
00139 }
00140 @Override
00141 public PropertyValue[] newArray(int n) {
00142 return new PropertyValue[n];
00143 }
00144 };
00145
00146 @Override
00147 public int describeContents() {
00148 return 0;
00149 }
00150
00155 public static class Skin extends AbstractModel {
00156
00157
00158 public static final String ID = "id";
00159 public static final String NAME = "name";
00160
00161
00162 public final String id;
00163 public final String name;
00164
00169 public Skin(String id, String name) {
00170 this.id = id;
00171 this.name = name;
00172 }
00173
00178 public Skin(JsonNode node) {
00179 id = node.get(ID).getTextValue();
00180 name = parseString(node, NAME);
00181 }
00182
00183 @Override
00184 public JsonNode toJsonNode() {
00185 final ObjectNode node = OM.createObjectNode();
00186 node.put(ID, id);
00187 node.put(NAME, name);
00188 return node;
00189 }
00190
00196 static List<Skin> getGUIModelSkinList(JsonNode node, String key) {
00197 if (node.has(key)) {
00198 final ArrayNode a = (ArrayNode)node.get(key);
00199 final List<Skin> l = new ArrayList<Skin>(a.size());
00200 for (int i = 0; i < a.size(); i++) {
00201 l.add(new Skin((JsonNode)a.get(i)));
00202 }
00203 return l;
00204 }
00205 return new ArrayList<Skin>(0);
00206 }
00207
00213 @Override
00214 public void writeToParcel(Parcel parcel, int flags) {
00215 parcel.writeValue(id);
00216 parcel.writeValue(name);
00217 }
00218
00222 protected Skin(Parcel parcel) {
00223 id = parcel.readString();
00224 name = parcel.readString();
00225 }
00226
00230 public static final Parcelable.Creator<Skin> CREATOR = new Parcelable.Creator<Skin>() {
00231 @Override
00232 public Skin createFromParcel(Parcel parcel) {
00233 return new Skin(parcel);
00234 }
00235 @Override
00236 public Skin[] newArray(int n) {
00237 return new Skin[n];
00238 }
00239 };
00240
00241 @Override
00242 public int describeContents() {
00243 return 0;
00244 }
00245 }
00246
00251 public static class Currentwindow extends AbstractModel {
00252
00253
00254 public static final String ID = "id";
00255 public static final String LABEL = "label";
00256
00257
00258 public final Integer id;
00259 public final String label;
00260
00265 public Currentwindow(Integer id, String label) {
00266 this.id = id;
00267 this.label = label;
00268 }
00269
00274 public Currentwindow(JsonNode node) {
00275 id = node.get(ID).getIntValue();
00276 label = node.get(LABEL).getTextValue();
00277 }
00278
00279 @Override
00280 public JsonNode toJsonNode() {
00281 final ObjectNode node = OM.createObjectNode();
00282 node.put(ID, id);
00283 node.put(LABEL, label);
00284 return node;
00285 }
00286
00292 static List<Currentwindow> getGUIModelCurrentwindowList(JsonNode node, String key) {
00293 if (node.has(key)) {
00294 final ArrayNode a = (ArrayNode)node.get(key);
00295 final List<Currentwindow> l = new ArrayList<Currentwindow>(a.size());
00296 for (int i = 0; i < a.size(); i++) {
00297 l.add(new Currentwindow((JsonNode)a.get(i)));
00298 }
00299 return l;
00300 }
00301 return new ArrayList<Currentwindow>(0);
00302 }
00303
00309 @Override
00310 public void writeToParcel(Parcel parcel, int flags) {
00311 parcel.writeValue(id);
00312 parcel.writeValue(label);
00313 }
00314
00318 protected Currentwindow(Parcel parcel) {
00319 id = parcel.readInt();
00320 label = parcel.readString();
00321 }
00322
00326 public static final Parcelable.Creator<Currentwindow> CREATOR = new Parcelable.Creator<Currentwindow>() {
00327 @Override
00328 public Currentwindow createFromParcel(Parcel parcel) {
00329 return new Currentwindow(parcel);
00330 }
00331 @Override
00332 public Currentwindow[] newArray(int n) {
00333 return new Currentwindow[n];
00334 }
00335 };
00336
00337 @Override
00338 public int describeContents() {
00339 return 0;
00340 }
00341 }
00342
00347 public static class Currentcontrol extends AbstractModel {
00348
00349
00350 public static final String LABEL = "label";
00351
00352
00353 public final String label;
00354
00358 public Currentcontrol(String label) {
00359 this.label = label;
00360 }
00361
00366 public Currentcontrol(JsonNode node) {
00367 label = node.get(LABEL).getTextValue();
00368 }
00369
00370 @Override
00371 public JsonNode toJsonNode() {
00372 final ObjectNode node = OM.createObjectNode();
00373 node.put(LABEL, label);
00374 return node;
00375 }
00376
00382 static List<Currentcontrol> getGUIModelCurrentcontrolList(JsonNode node, String key) {
00383 if (node.has(key)) {
00384 final ArrayNode a = (ArrayNode)node.get(key);
00385 final List<Currentcontrol> l = new ArrayList<Currentcontrol>(a.size());
00386 for (int i = 0; i < a.size(); i++) {
00387 l.add(new Currentcontrol((JsonNode)a.get(i)));
00388 }
00389 return l;
00390 }
00391 return new ArrayList<Currentcontrol>(0);
00392 }
00393
00399 @Override
00400 public void writeToParcel(Parcel parcel, int flags) {
00401 parcel.writeValue(label);
00402 }
00403
00407 protected Currentcontrol(Parcel parcel) {
00408 label = parcel.readString();
00409 }
00410
00414 public static final Parcelable.Creator<Currentcontrol> CREATOR = new Parcelable.Creator<Currentcontrol>() {
00415 @Override
00416 public Currentcontrol createFromParcel(Parcel parcel) {
00417 return new Currentcontrol(parcel);
00418 }
00419 @Override
00420 public Currentcontrol[] newArray(int n) {
00421 return new Currentcontrol[n];
00422 }
00423 };
00424
00425 @Override
00426 public int describeContents() {
00427 return 0;
00428 }
00429 }
00430 }
00431
00435 public interface PropertyName {
00436
00437 public final String CURRENTWINDOW = "currentwindow";
00438 public final String CURRENTCONTROL = "currentcontrol";
00439 public final String SKIN = "skin";
00440 public final String FULLSCREEN = "fullscreen";
00441
00442 public final static Set<String> values = new HashSet<String>(Arrays.asList(CURRENTWINDOW, CURRENTCONTROL, SKIN, FULLSCREEN));
00443 }
00444
00448 public interface Window {
00449
00450 public final String HOME = "home";
00451 public final String PROGRAMS = "programs";
00452 public final String PICTURES = "pictures";
00453 public final String FILEMANAGER = "filemanager";
00454 public final String FILES = "files";
00455 public final String SETTINGS = "settings";
00456 public final String MUSIC = "music";
00457 public final String VIDEO = "video";
00458 public final String VIDEOS = "videos";
00459 public final String TV = "tv";
00460 public final String PVR = "pvr";
00461 public final String PVRGUIDEINFO = "pvrguideinfo";
00462 public final String PVRRECORDINGINFO = "pvrrecordinginfo";
00463 public final String PVRTIMERSETTING = "pvrtimersetting";
00464 public final String PVRGROUPMANAGER = "pvrgroupmanager";
00465 public final String PVRCHANNELMANAGER = "pvrchannelmanager";
00466 public final String PVRGUIDESEARCH = "pvrguidesearch";
00467 public final String PVRCHANNELSCAN = "pvrchannelscan";
00468 public final String PVRUPDATEPROGRESS = "pvrupdateprogress";
00469 public final String PVROSDCHANNELS = "pvrosdchannels";
00470 public final String PVROSDGUIDE = "pvrosdguide";
00471 public final String PVROSDDIRECTOR = "pvrosddirector";
00472 public final String PVROSDCUTTER = "pvrosdcutter";
00473 public final String PVROSDTELETEXT = "pvrosdteletext";
00474 public final String SYSTEMINFO = "systeminfo";
00475 public final String TESTPATTERN = "testpattern";
00476 public final String SCREENCALIBRATION = "screencalibration";
00477 public final String GUICALIBRATION = "guicalibration";
00478 public final String PICTURESSETTINGS = "picturessettings";
00479 public final String PROGRAMSSETTINGS = "programssettings";
00480 public final String WEATHERSETTINGS = "weathersettings";
00481 public final String MUSICSETTINGS = "musicsettings";
00482 public final String SYSTEMSETTINGS = "systemsettings";
00483 public final String VIDEOSSETTINGS = "videossettings";
00484 public final String NETWORKSETTINGS = "networksettings";
00485 public final String SERVICESETTINGS = "servicesettings";
00486 public final String APPEARANCESETTINGS = "appearancesettings";
00487 public final String PVRSETTINGS = "pvrsettings";
00488 public final String TVSETTINGS = "tvsettings";
00489 public final String SCRIPTS = "scripts";
00490 public final String VIDEOFILES = "videofiles";
00491 public final String VIDEOLIBRARY = "videolibrary";
00492 public final String VIDEOPLAYLIST = "videoplaylist";
00493 public final String LOGINSCREEN = "loginscreen";
00494 public final String PROFILES = "profiles";
00495 public final String SKINSETTINGS = "skinsettings";
00496 public final String ADDONBROWSER = "addonbrowser";
00497 public final String YESNODIALOG = "yesnodialog";
00498 public final String PROGRESSDIALOG = "progressdialog";
00499 public final String VIRTUALKEYBOARD = "virtualkeyboard";
00500 public final String VOLUMEBAR = "volumebar";
00501 public final String SUBMENU = "submenu";
00502 public final String FAVOURITES = "favourites";
00503 public final String CONTEXTMENU = "contextmenu";
00504 public final String INFODIALOG = "infodialog";
00505 public final String NUMERICINPUT = "numericinput";
00506 public final String GAMEPADINPUT = "gamepadinput";
00507 public final String SHUTDOWNMENU = "shutdownmenu";
00508 public final String MUTEBUG = "mutebug";
00509 public final String PLAYERCONTROLS = "playercontrols";
00510 public final String SEEKBAR = "seekbar";
00511 public final String MUSICOSD = "musicosd";
00512 public final String ADDONSETTINGS = "addonsettings";
00513 public final String VISUALISATIONSETTINGS = "visualisationsettings";
00514 public final String VISUALISATIONPRESETLIST = "visualisationpresetlist";
00515 public final String OSDVIDEOSETTINGS = "osdvideosettings";
00516 public final String OSDAUDIOSETTINGS = "osdaudiosettings";
00517 public final String VIDEOBOOKMARKS = "videobookmarks";
00518 public final String FILEBROWSER = "filebrowser";
00519 public final String NETWORKSETUP = "networksetup";
00520 public final String MEDIASOURCE = "mediasource";
00521 public final String PROFILESETTINGS = "profilesettings";
00522 public final String LOCKSETTINGS = "locksettings";
00523 public final String CONTENTSETTINGS = "contentsettings";
00524 public final String SONGINFORMATION = "songinformation";
00525 public final String SMARTPLAYLISTEDITOR = "smartplaylisteditor";
00526 public final String SMARTPLAYLISTRULE = "smartplaylistrule";
00527 public final String BUSYDIALOG = "busydialog";
00528 public final String PICTUREINFO = "pictureinfo";
00529 public final String ACCESSPOINTS = "accesspoints";
00530 public final String FULLSCREENINFO = "fullscreeninfo";
00531 public final String KARAOKESELECTOR = "karaokeselector";
00532 public final String KARAOKELARGESELECTOR = "karaokelargeselector";
00533 public final String SLIDERDIALOG = "sliderdialog";
00534 public final String ADDONINFORMATION = "addoninformation";
00535 public final String MUSICPLAYLIST = "musicplaylist";
00536 public final String MUSICFILES = "musicfiles";
00537 public final String MUSICLIBRARY = "musiclibrary";
00538 public final String MUSICPLAYLISTEDITOR = "musicplaylisteditor";
00539 public final String TELETEXT = "teletext";
00540 public final String SELECTDIALOG = "selectdialog";
00541 public final String MUSICINFORMATION = "musicinformation";
00542 public final String OKDIALOG = "okdialog";
00543 public final String MOVIEINFORMATION = "movieinformation";
00544 public final String TEXTVIEWER = "textviewer";
00545 public final String FULLSCREENVIDEO = "fullscreenvideo";
00546 public final String FULLSCREENLIVETV = "fullscreenlivetv";
00547 public final String VISUALISATION = "visualisation";
00548 public final String SLIDESHOW = "slideshow";
00549 public final String FILESTACKINGDIALOG = "filestackingdialog";
00550 public final String KARAOKE = "karaoke";
00551 public final String WEATHER = "weather";
00552 public final String SCREENSAVER = "screensaver";
00553 public final String VIDEOOSD = "videoosd";
00554 public final String VIDEOMENU = "videomenu";
00555 public final String VIDEOTIMESEEK = "videotimeseek";
00556 public final String MUSICOVERLAY = "musicoverlay";
00557 public final String VIDEOOVERLAY = "videooverlay";
00558 public final String STARTWINDOW = "startwindow";
00559 public final String STARTUP = "startup";
00560 public final String PERIPHERALS = "peripherals";
00561 public final String PERIPHERALSETTINGS = "peripheralsettings";
00562 public final String EXTENDEDPROGRESSDIALOG = "extendedprogressdialog";
00563 public final String MEDIAFILTER = "mediafilter";
00564 public final String ADDON = "addon";
00565
00566 public final static Set<String> values = new HashSet<String>(Arrays.asList(HOME, PROGRAMS, PICTURES, FILEMANAGER, FILES, SETTINGS, MUSIC, VIDEO, VIDEOS, TV, PVR, PVRGUIDEINFO, PVRRECORDINGINFO, PVRTIMERSETTING, PVRGROUPMANAGER, PVRCHANNELMANAGER, PVRGUIDESEARCH, PVRCHANNELSCAN, PVRUPDATEPROGRESS, PVROSDCHANNELS, PVROSDGUIDE, PVROSDDIRECTOR, PVROSDCUTTER, PVROSDTELETEXT, SYSTEMINFO, TESTPATTERN, SCREENCALIBRATION, GUICALIBRATION, PICTURESSETTINGS, PROGRAMSSETTINGS, WEATHERSETTINGS, MUSICSETTINGS, SYSTEMSETTINGS, VIDEOSSETTINGS, NETWORKSETTINGS, SERVICESETTINGS, APPEARANCESETTINGS, PVRSETTINGS, TVSETTINGS, SCRIPTS, VIDEOFILES, VIDEOLIBRARY, VIDEOPLAYLIST, LOGINSCREEN, PROFILES, SKINSETTINGS, ADDONBROWSER, YESNODIALOG, PROGRESSDIALOG, VIRTUALKEYBOARD, VOLUMEBAR, SUBMENU, FAVOURITES, CONTEXTMENU, INFODIALOG, NUMERICINPUT, GAMEPADINPUT, SHUTDOWNMENU, MUTEBUG, PLAYERCONTROLS, SEEKBAR, MUSICOSD, ADDONSETTINGS, VISUALISATIONSETTINGS, VISUALISATIONPRESETLIST, OSDVIDEOSETTINGS, OSDAUDIOSETTINGS, VIDEOBOOKMARKS, FILEBROWSER, NETWORKSETUP, MEDIASOURCE, PROFILESETTINGS, LOCKSETTINGS, CONTENTSETTINGS, SONGINFORMATION, SMARTPLAYLISTEDITOR, SMARTPLAYLISTRULE, BUSYDIALOG, PICTUREINFO, ACCESSPOINTS, FULLSCREENINFO, KARAOKESELECTOR, KARAOKELARGESELECTOR, SLIDERDIALOG, ADDONINFORMATION, MUSICPLAYLIST, MUSICFILES, MUSICLIBRARY, MUSICPLAYLISTEDITOR, TELETEXT, SELECTDIALOG, MUSICINFORMATION, OKDIALOG, MOVIEINFORMATION, TEXTVIEWER, FULLSCREENVIDEO, FULLSCREENLIVETV, VISUALISATION, SLIDESHOW, FILESTACKINGDIALOG, KARAOKE, WEATHER, SCREENSAVER, VIDEOOSD, VIDEOMENU, VIDEOTIMESEEK, MUSICOVERLAY, VIDEOOVERLAY, STARTWINDOW, STARTUP, PERIPHERALS, PERIPHERALSETTINGS, EXTENDEDPROGRESSDIALOG, MEDIAFILTER, ADDON));
00567 }
00568 }