Go to the documentation of this file.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 org.codehaus.jackson.JsonNode;
00027 import org.codehaus.jackson.node.ArrayNode;
00028 import org.codehaus.jackson.node.ObjectNode;
00029 import org.xbmc.android.jsonrpc.api.AbstractCall;
00030 import org.xbmc.android.jsonrpc.api.model.ListModel;
00031 import org.xbmc.android.jsonrpc.api.model.ProfilesModel;
00032
00033 public final class Profiles {
00034
00042 public static class GetCurrentProfile extends AbstractCall<ProfilesModel.ProfileDetail> {
00043 public final static String API_TYPE = "Profiles.GetCurrentProfile";
00044
00045 @Override
00046 public void writeToParcel(Parcel parcel, int flags) {
00047 super.writeToParcel(parcel, flags);
00048 parcel.writeParcelable(mResult, flags);
00049 }
00050
00054 protected GetCurrentProfile(Parcel parcel) {
00055 super(parcel);
00056 }
00057
00061 public static final Parcelable.Creator<GetCurrentProfile> CREATOR = new Parcelable.Creator<GetCurrentProfile>() {
00062 @Override
00063 public GetCurrentProfile createFromParcel(Parcel parcel) {
00064 return new GetCurrentProfile(parcel);
00065 }
00066 @Override
00067 public GetCurrentProfile[] newArray(int n) {
00068 return new GetCurrentProfile[n];
00069 }
00070 };
00071
00076 public GetCurrentProfile(String... properties) {
00077 super();
00078 addParameter("properties", properties);
00079 }
00080
00081 @Override
00082 protected ProfilesModel.ProfileDetail parseOne(JsonNode node) {
00083 return new ProfilesModel.ProfileDetail(node);
00084 }
00085
00086 @Override
00087 public String getName() {
00088 return API_TYPE;
00089 }
00090
00091 @Override
00092 protected boolean returnsList() {
00093 return false;
00094 }
00095 }
00096
00104 public static class GetProfiles extends AbstractCall<ProfilesModel.ProfileDetail> {
00105 public final static String API_TYPE = "Profiles.GetProfiles";
00106
00107 @Override
00108 public void writeToParcel(Parcel parcel, int flags) {
00109 super.writeToParcel(parcel, flags);
00110 parcel.writeParcelable(mResult, flags);
00111 }
00112
00116 protected GetProfiles(Parcel parcel) {
00117 super(parcel);
00118 }
00119
00123 public static final Parcelable.Creator<GetProfiles> CREATOR = new Parcelable.Creator<GetProfiles>() {
00124 @Override
00125 public GetProfiles createFromParcel(Parcel parcel) {
00126 return new GetProfiles(parcel);
00127 }
00128 @Override
00129 public GetProfiles[] newArray(int n) {
00130 return new GetProfiles[n];
00131 }
00132 };
00133 public final static String RESULT = "profiles";
00134
00141 public GetProfiles(ListModel.Limits limits, ListModel.Sort sort, String... properties) {
00142 super();
00143 addParameter("limits", limits);
00144 addParameter("sort", sort);
00145 addParameter("properties", properties);
00146 }
00147
00152 public GetProfiles(String... properties) {
00153 super();
00154 addParameter("properties", properties);
00155 }
00156
00162 public GetProfiles(ListModel.Limits limits, String... properties) {
00163 super();
00164 addParameter("limits", limits);
00165 addParameter("properties", properties);
00166 }
00167
00168 @Override
00169 protected ArrayList<ProfilesModel.ProfileDetail> parseMany(JsonNode node) {
00170 final ArrayNode profiles = parseResults(node, RESULT);
00171 if (profiles != null) {
00172 final ArrayList<ProfilesModel.ProfileDetail> ret = new ArrayList<ProfilesModel.ProfileDetail>(profiles.size());
00173 for (int i = 0; i < profiles.size(); i++) {
00174 final ObjectNode item = (ObjectNode)profiles.get(i);
00175 ret.add(new ProfilesModel.ProfileDetail(item));
00176 }
00177 return ret;
00178 } else {
00179 return new ArrayList<ProfilesModel.ProfileDetail>(0);
00180 }
00181 }
00182
00183 @Override
00184 public String getName() {
00185 return API_TYPE;
00186 }
00187
00188 @Override
00189 protected boolean returnsList() {
00190 return true;
00191 }
00192 }
00193
00201 public static class LoadProfile extends AbstractCall<String> {
00202 public final static String API_TYPE = "Profiles.LoadProfile";
00203
00204 @Override
00205 public void writeToParcel(Parcel parcel, int flags) {
00206 super.writeToParcel(parcel, flags);
00207 parcel.writeValue(mResult);
00208 }
00209
00213 protected LoadProfile(Parcel parcel) {
00214 super(parcel);
00215 }
00216
00220 public static final Parcelable.Creator<LoadProfile> CREATOR = new Parcelable.Creator<LoadProfile>() {
00221 @Override
00222 public LoadProfile createFromParcel(Parcel parcel) {
00223 return new LoadProfile(parcel);
00224 }
00225 @Override
00226 public LoadProfile[] newArray(int n) {
00227 return new LoadProfile[n];
00228 }
00229 };
00230
00237 public LoadProfile(String profile, Boolean prompt, ProfilesModel.Password password) {
00238 super();
00239 addParameter("profile", profile);
00240 addParameter("prompt", prompt);
00241 addParameter("password", password);
00242 }
00243
00248 public LoadProfile(String profile) {
00249 super();
00250 addParameter("profile", profile);
00251 }
00252
00258 public LoadProfile(String profile, Boolean prompt) {
00259 super();
00260 addParameter("profile", profile);
00261 addParameter("prompt", prompt);
00262 }
00263
00269 public LoadProfile(String profile, ProfilesModel.Password password) {
00270 super();
00271 addParameter("profile", profile);
00272 addParameter("password", password);
00273 }
00274
00275 @Override
00276 protected String parseOne(JsonNode node) {
00277 return node.getTextValue();
00278 }
00279
00280 @Override
00281 public String getName() {
00282 return API_TYPE;
00283 }
00284
00285 @Override
00286 protected boolean returnsList() {
00287 return false;
00288 }
00289 }
00290 }