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.call;
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.Set;
00029 import org.codehaus.jackson.JsonNode;
00030 import org.codehaus.jackson.node.ArrayNode;
00031 import org.codehaus.jackson.node.ObjectNode;
00032 import org.xbmc.android.jsonrpc.api.AbstractCall;
00033 import org.xbmc.android.jsonrpc.api.AbstractModel;
00034 import org.xbmc.android.jsonrpc.api.model.GlobalModel;
00035 import org.xbmc.android.jsonrpc.api.model.ListModel;
00036 import org.xbmc.android.jsonrpc.api.model.PVRModel;
00037
00038 public final class PVR {
00039
00047 public static class GetChannelDetails extends AbstractCall<PVRModel.ChannelDetail> {
00048 public final static String API_TYPE = "PVR.GetChannelDetails";
00049
00050 @Override
00051 public void writeToParcel(Parcel parcel, int flags) {
00052 super.writeToParcel(parcel, flags);
00053 parcel.writeParcelable(mResult, flags);
00054 }
00055
00059 protected GetChannelDetails(Parcel parcel) {
00060 super(parcel);
00061 }
00062
00066 public static final Parcelable.Creator<GetChannelDetails> CREATOR = new Parcelable.Creator<GetChannelDetails>() {
00067 @Override
00068 public GetChannelDetails createFromParcel(Parcel parcel) {
00069 return new GetChannelDetails(parcel);
00070 }
00071 @Override
00072 public GetChannelDetails[] newArray(int n) {
00073 return new GetChannelDetails[n];
00074 }
00075 };
00076 public final static String RESULT = "channeldetails";
00077
00083 public GetChannelDetails(Integer channelid, String... properties) {
00084 super();
00085 addParameter("channelid", channelid);
00086 addParameter("properties", properties);
00087 }
00088
00089 @Override
00090 protected PVRModel.ChannelDetail parseOne(JsonNode node) {
00091 return new PVRModel.ChannelDetail((ObjectNode)node.get(RESULT));
00092 }
00093
00094 @Override
00095 public String getName() {
00096 return API_TYPE;
00097 }
00098
00099 @Override
00100 protected boolean returnsList() {
00101 return false;
00102 }
00103 }
00104
00112 public static class GetChannelGroupDetails extends AbstractCall<PVRModel.ChannelGroupExtendedDetail> {
00113 public final static String API_TYPE = "PVR.GetChannelGroupDetails";
00114
00115 @Override
00116 public void writeToParcel(Parcel parcel, int flags) {
00117 super.writeToParcel(parcel, flags);
00118 parcel.writeParcelable(mResult, flags);
00119 }
00120
00124 protected GetChannelGroupDetails(Parcel parcel) {
00125 super(parcel);
00126 }
00127
00131 public static final Parcelable.Creator<GetChannelGroupDetails> CREATOR = new Parcelable.Creator<GetChannelGroupDetails>() {
00132 @Override
00133 public GetChannelGroupDetails createFromParcel(Parcel parcel) {
00134 return new GetChannelGroupDetails(parcel);
00135 }
00136 @Override
00137 public GetChannelGroupDetails[] newArray(int n) {
00138 return new GetChannelGroupDetails[n];
00139 }
00140 };
00141 public final static String RESULT = "channelgroupdetails";
00142
00148 public GetChannelGroupDetails(PVRModel.ChannelGroupId channelgroupid, Channel channels) {
00149 super();
00150 addParameter("channelgroupid", channelgroupid);
00151 addParameter("channels", channels);
00152 }
00153
00158 public GetChannelGroupDetails(PVRModel.ChannelGroupId channelgroupid) {
00159 super();
00160 addParameter("channelgroupid", channelgroupid);
00161 }
00162
00163 @Override
00164 protected PVRModel.ChannelGroupExtendedDetail parseOne(JsonNode node) {
00165 return new PVRModel.ChannelGroupExtendedDetail((ObjectNode)node.get(RESULT));
00166 }
00167
00168 @Override
00169 public String getName() {
00170 return API_TYPE;
00171 }
00172
00173 @Override
00174 protected boolean returnsList() {
00175 return false;
00176 }
00177
00182 public static class Channel extends AbstractModel {
00183
00184
00185 public static final String LIMITS = "limits";
00186 public static final String PROPERTIES = "properties";
00187
00188
00189 public final ListModel.Limits limits;
00190 public final String properties;
00191
00196 public Channel(ListModel.Limits limits, String properties) {
00197 this.limits = limits;
00198 this.properties = properties;
00199 }
00200
00201 @Override
00202 public JsonNode toJsonNode() {
00203 final ObjectNode node = OM.createObjectNode();
00204 node.put(LIMITS, limits.toJsonNode());
00205 node.put(PROPERTIES, properties);
00206 return node;
00207 }
00208
00214 @Override
00215 public void writeToParcel(Parcel parcel, int flags) {
00216 parcel.writeValue(limits);
00217 parcel.writeValue(properties);
00218 }
00219
00223 protected Channel(Parcel parcel) {
00224 limits = parcel.<ListModel.Limits>readParcelable(ListModel.Limits.class.getClassLoader());
00225 properties = parcel.readString();
00226 }
00227
00231 public static final Parcelable.Creator<Channel> CREATOR = new Parcelable.Creator<Channel>() {
00232 @Override
00233 public Channel createFromParcel(Parcel parcel) {
00234 return new Channel(parcel);
00235 }
00236 @Override
00237 public Channel[] newArray(int n) {
00238 return new Channel[n];
00239 }
00240 };
00241
00242 @Override
00243 public int describeContents() {
00244 return 0;
00245 }
00246
00250 public interface Property {
00251
00252 public final String THUMBNAIL = "thumbnail";
00253 public final String CHANNELTYPE = "channeltype";
00254 public final String HIDDEN = "hidden";
00255 public final String LOCKED = "locked";
00256 public final String CHANNEL = "channel";
00257 public final String LASTPLAYED = "lastplayed";
00258
00259 public final static Set<String> values = new HashSet<String>(Arrays.asList(THUMBNAIL, CHANNELTYPE, HIDDEN, LOCKED, CHANNEL, LASTPLAYED));
00260 }
00261 }
00262 }
00263
00271 public static class GetChannelGroups extends AbstractCall<PVRModel.ChannelGroupDetail> {
00272 public final static String API_TYPE = "PVR.GetChannelGroups";
00273
00274 @Override
00275 public void writeToParcel(Parcel parcel, int flags) {
00276 super.writeToParcel(parcel, flags);
00277 parcel.writeParcelable(mResult, flags);
00278 }
00279
00283 protected GetChannelGroups(Parcel parcel) {
00284 super(parcel);
00285 }
00286
00290 public static final Parcelable.Creator<GetChannelGroups> CREATOR = new Parcelable.Creator<GetChannelGroups>() {
00291 @Override
00292 public GetChannelGroups createFromParcel(Parcel parcel) {
00293 return new GetChannelGroups(parcel);
00294 }
00295 @Override
00296 public GetChannelGroups[] newArray(int n) {
00297 return new GetChannelGroups[n];
00298 }
00299 };
00300 public final static String RESULT = "channelgroups";
00301
00307 public GetChannelGroups(String channeltype, ListModel.Limits limits) {
00308 super();
00309 addParameter("channeltype", channeltype);
00310 addParameter("limits", limits);
00311 }
00312
00317 public GetChannelGroups(String channeltype) {
00318 super();
00319 addParameter("channeltype", channeltype);
00320 }
00321
00322 @Override
00323 protected ArrayList<PVRModel.ChannelGroupDetail> parseMany(JsonNode node) {
00324 final ArrayNode channelgroups = parseResults(node, RESULT);
00325 if (channelgroups != null) {
00326 final ArrayList<PVRModel.ChannelGroupDetail> ret = new ArrayList<PVRModel.ChannelGroupDetail>(channelgroups.size());
00327 for (int i = 0; i < channelgroups.size(); i++) {
00328 final ObjectNode item = (ObjectNode)channelgroups.get(i);
00329 ret.add(new PVRModel.ChannelGroupDetail(item));
00330 }
00331 return ret;
00332 } else {
00333 return new ArrayList<PVRModel.ChannelGroupDetail>(0);
00334 }
00335 }
00336
00337 @Override
00338 public String getName() {
00339 return API_TYPE;
00340 }
00341
00342 @Override
00343 protected boolean returnsList() {
00344 return true;
00345 }
00346 }
00347
00355 public static class GetChannels extends AbstractCall<PVRModel.ChannelDetail> {
00356 public final static String API_TYPE = "PVR.GetChannels";
00357
00358 @Override
00359 public void writeToParcel(Parcel parcel, int flags) {
00360 super.writeToParcel(parcel, flags);
00361 parcel.writeParcelable(mResult, flags);
00362 }
00363
00367 protected GetChannels(Parcel parcel) {
00368 super(parcel);
00369 }
00370
00374 public static final Parcelable.Creator<GetChannels> CREATOR = new Parcelable.Creator<GetChannels>() {
00375 @Override
00376 public GetChannels createFromParcel(Parcel parcel) {
00377 return new GetChannels(parcel);
00378 }
00379 @Override
00380 public GetChannels[] newArray(int n) {
00381 return new GetChannels[n];
00382 }
00383 };
00384 public final static String RESULT = "channels";
00385
00392 public GetChannels(PVRModel.ChannelGroupId channelgroupid, ListModel.Limits limits, String... properties) {
00393 super();
00394 addParameter("channelgroupid", channelgroupid);
00395 addParameter("limits", limits);
00396 addParameter("properties", properties);
00397 }
00398
00404 public GetChannels(PVRModel.ChannelGroupId channelgroupid, String... properties) {
00405 super();
00406 addParameter("channelgroupid", channelgroupid);
00407 addParameter("properties", properties);
00408 }
00409
00410 @Override
00411 protected ArrayList<PVRModel.ChannelDetail> parseMany(JsonNode node) {
00412 final ArrayNode channels = parseResults(node, RESULT);
00413 if (channels != null) {
00414 final ArrayList<PVRModel.ChannelDetail> ret = new ArrayList<PVRModel.ChannelDetail>(channels.size());
00415 for (int i = 0; i < channels.size(); i++) {
00416 final ObjectNode item = (ObjectNode)channels.get(i);
00417 ret.add(new PVRModel.ChannelDetail(item));
00418 }
00419 return ret;
00420 } else {
00421 return new ArrayList<PVRModel.ChannelDetail>(0);
00422 }
00423 }
00424
00425 @Override
00426 public String getName() {
00427 return API_TYPE;
00428 }
00429
00430 @Override
00431 protected boolean returnsList() {
00432 return true;
00433 }
00434 }
00435
00443 public static class GetProperties extends AbstractCall<PVRModel.PropertyValue> {
00444 public final static String API_TYPE = "PVR.GetProperties";
00445
00446 @Override
00447 public void writeToParcel(Parcel parcel, int flags) {
00448 super.writeToParcel(parcel, flags);
00449 parcel.writeParcelable(mResult, flags);
00450 }
00451
00455 protected GetProperties(Parcel parcel) {
00456 super(parcel);
00457 }
00458
00462 public static final Parcelable.Creator<GetProperties> CREATOR = new Parcelable.Creator<GetProperties>() {
00463 @Override
00464 public GetProperties createFromParcel(Parcel parcel) {
00465 return new GetProperties(parcel);
00466 }
00467 @Override
00468 public GetProperties[] newArray(int n) {
00469 return new GetProperties[n];
00470 }
00471 };
00472
00477 public GetProperties(String... properties) {
00478 super();
00479 addParameter("properties", properties);
00480 }
00481
00482 @Override
00483 protected PVRModel.PropertyValue parseOne(JsonNode node) {
00484 return new PVRModel.PropertyValue(node);
00485 }
00486
00487 @Override
00488 public String getName() {
00489 return API_TYPE;
00490 }
00491
00492 @Override
00493 protected boolean returnsList() {
00494 return false;
00495 }
00496 }
00497
00505 public static class Record extends AbstractCall<String> {
00506 public final static String API_TYPE = "PVR.Record";
00507
00508 @Override
00509 public void writeToParcel(Parcel parcel, int flags) {
00510 super.writeToParcel(parcel, flags);
00511 parcel.writeValue(mResult);
00512 }
00513
00517 protected Record(Parcel parcel) {
00518 super(parcel);
00519 }
00520
00524 public static final Parcelable.Creator<Record> CREATOR = new Parcelable.Creator<Record>() {
00525 @Override
00526 public Record createFromParcel(Parcel parcel) {
00527 return new Record(parcel);
00528 }
00529 @Override
00530 public Record[] newArray(int n) {
00531 return new Record[n];
00532 }
00533 };
00534
00540 public Record(GlobalModel.Toggle record, String channel) {
00541 super();
00542 addParameter("record", record);
00543 addParameter("channel", channel);
00544 }
00545
00551 public Record(GlobalModel.Toggle record, Integer channel) {
00552 super();
00553 addParameter("record", record);
00554 addParameter("channel", channel);
00555 }
00556
00560 public Record() {
00561 super();
00562 }
00563
00568 public Record(GlobalModel.Toggle record) {
00569 super();
00570 addParameter("record", record);
00571 }
00572
00573 @Override
00574 protected String parseOne(JsonNode node) {
00575 return node.getTextValue();
00576 }
00577
00578 @Override
00579 public String getName() {
00580 return API_TYPE;
00581 }
00582
00583 @Override
00584 protected boolean returnsList() {
00585 return false;
00586 }
00587
00591 public interface Channel {
00592
00593 public final String CURRENT = "current";
00594
00595 public final static Set<String> values = new HashSet<String>(Arrays.asList(CURRENT));
00596 }
00597 }
00598
00606 public static class Scan extends AbstractCall<String> {
00607 public final static String API_TYPE = "PVR.Scan";
00608
00609 @Override
00610 public void writeToParcel(Parcel parcel, int flags) {
00611 super.writeToParcel(parcel, flags);
00612 parcel.writeValue(mResult);
00613 }
00614
00618 protected Scan(Parcel parcel) {
00619 super(parcel);
00620 }
00621
00625 public static final Parcelable.Creator<Scan> CREATOR = new Parcelable.Creator<Scan>() {
00626 @Override
00627 public Scan createFromParcel(Parcel parcel) {
00628 return new Scan(parcel);
00629 }
00630 @Override
00631 public Scan[] newArray(int n) {
00632 return new Scan[n];
00633 }
00634 };
00635
00639 public Scan() {
00640 super();
00641 }
00642
00643 @Override
00644 protected String parseOne(JsonNode node) {
00645 return node.getTextValue();
00646 }
00647
00648 @Override
00649 public String getName() {
00650 return API_TYPE;
00651 }
00652
00653 @Override
00654 protected boolean returnsList() {
00655 return false;
00656 }
00657 }
00658 }