JSONRPC.java
Go to the documentation of this file.
00001 /*
00002  *      Copyright (C) 2005-2013 Team XBMC
00003  *      http://xbmc.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with XBMC Remote; see the file license.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00018  *  http://www.gnu.org/copyleft/gpl.html
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.List;
00027 import org.codehaus.jackson.JsonNode;
00028 import org.codehaus.jackson.node.ArrayNode;
00029 import org.codehaus.jackson.node.ObjectNode;
00030 import org.xbmc.android.jsonrpc.api.AbstractCall;
00031 import org.xbmc.android.jsonrpc.api.AbstractModel;
00032 
00033 public final class JSONRPC {
00034 
00042         public static class NotifyAll extends AbstractCall<String> {
00043                 public final static String API_TYPE = "JSONRPC.NotifyAll";
00044 
00045                 @Override
00046                 public void writeToParcel(Parcel parcel, int flags) {
00047                         super.writeToParcel(parcel, flags);
00048                         parcel.writeValue(mResult);
00049                 }
00050 
00054                 protected NotifyAll(Parcel parcel) {
00055                         super(parcel);
00056                 }
00057 
00061                 public static final Parcelable.Creator<NotifyAll> CREATOR = new Parcelable.Creator<NotifyAll>() {
00062                         @Override
00063                         public NotifyAll createFromParcel(Parcel parcel) {
00064                                 return new NotifyAll(parcel);
00065                         }
00066                         @Override
00067                         public NotifyAll[] newArray(int n) {
00068                                 return new NotifyAll[n];
00069                         }
00070                 };
00071 
00078                 public NotifyAll(String sender, String message, String data) {
00079                         super();
00080                         addParameter("sender", sender);
00081                         addParameter("message", message);
00082                         addParameter("data", data);
00083                 }
00084 
00090                 public NotifyAll(String sender, String message) {
00091                         super();
00092                         addParameter("sender", sender);
00093                         addParameter("message", message);
00094                 }
00095 
00096                 @Override
00097                 protected String parseOne(JsonNode node) {
00098                         return node.getTextValue();
00099                 }
00100 
00101                 @Override
00102                 public String getName() {
00103                         return API_TYPE;
00104                 }
00105 
00106                 @Override
00107                 protected boolean returnsList() {
00108                         return false;
00109                 }
00110         }
00111 
00119         public static class Permission extends AbstractCall<Permission.PermissionResult> {
00120                 public final static String API_TYPE = "JSONRPC.Permission";
00121 
00122                 @Override
00123                 public void writeToParcel(Parcel parcel, int flags) {
00124                         super.writeToParcel(parcel, flags);
00125                         parcel.writeParcelable(mResult, flags);
00126                 }
00127 
00131                 protected Permission(Parcel parcel) {
00132                         super(parcel);
00133                 }
00134 
00138                 public static final Parcelable.Creator<Permission> CREATOR = new Parcelable.Creator<Permission>() {
00139                         @Override
00140                         public Permission createFromParcel(Parcel parcel) {
00141                                 return new Permission(parcel);
00142                         }
00143                         @Override
00144                         public Permission[] newArray(int n) {
00145                                 return new Permission[n];
00146                         }
00147                 };
00148 
00152                 public Permission() {
00153                         super();
00154                 }
00155 
00156                 @Override
00157                 protected PermissionResult parseOne(JsonNode node) {
00158                         return new PermissionResult(node);
00159                 }
00160 
00161                 @Override
00162                 public String getName() {
00163                         return API_TYPE;
00164                 }
00165 
00166                 @Override
00167                 protected boolean returnsList() {
00168                         return false;
00169                 }
00170 
00175                 public static class PermissionResult extends AbstractModel {
00176 
00177                         // field names
00178                         public static final String CONTROLGUI = "controlgui";
00179                         public static final String CONTROLNOTIFY = "controlnotify";
00180                         public static final String CONTROLPLAYBACK = "controlplayback";
00181                         public static final String CONTROLPOWER = "controlpower";
00182                         public static final String CONTROLPVR = "controlpvr";
00183                         public static final String CONTROLSYSTEM = "controlsystem";
00184                         public static final String EXECUTEADDON = "executeaddon";
00185                         public static final String MANAGEADDON = "manageaddon";
00186                         public static final String NAVIGATE = "navigate";
00187                         public static final String READDATA = "readdata";
00188                         public static final String REMOVEDATA = "removedata";
00189                         public static final String UPDATEDATA = "updatedata";
00190                         public static final String WRITEFILE = "writefile";
00191 
00192                         // class members
00193                         public final Boolean controlgui;
00194                         public final Boolean controlnotify;
00195                         public final Boolean controlplayback;
00196                         public final Boolean controlpower;
00197                         public final Boolean controlpvr;
00198                         public final Boolean controlsystem;
00199                         public final Boolean executeaddon;
00200                         public final Boolean manageaddon;
00201                         public final Boolean navigate;
00202                         public final Boolean readdata;
00203                         public final Boolean removedata;
00204                         public final Boolean updatedata;
00205                         public final Boolean writefile;
00206 
00222                         public PermissionResult(Boolean controlgui, Boolean controlnotify, Boolean controlplayback, Boolean controlpower, Boolean controlpvr, Boolean controlsystem, Boolean executeaddon, Boolean manageaddon, Boolean navigate, Boolean readdata, Boolean removedata, Boolean updatedata, Boolean writefile) {
00223                                 this.controlgui = controlgui;
00224                                 this.controlnotify = controlnotify;
00225                                 this.controlplayback = controlplayback;
00226                                 this.controlpower = controlpower;
00227                                 this.controlpvr = controlpvr;
00228                                 this.controlsystem = controlsystem;
00229                                 this.executeaddon = executeaddon;
00230                                 this.manageaddon = manageaddon;
00231                                 this.navigate = navigate;
00232                                 this.readdata = readdata;
00233                                 this.removedata = removedata;
00234                                 this.updatedata = updatedata;
00235                                 this.writefile = writefile;
00236                         }
00237 
00242                         public PermissionResult(JsonNode node) {
00243                                 controlgui = node.get(CONTROLGUI).getBooleanValue(); // required value
00244                                 controlnotify = node.get(CONTROLNOTIFY).getBooleanValue(); // required value
00245                                 controlplayback = node.get(CONTROLPLAYBACK).getBooleanValue(); // required value
00246                                 controlpower = node.get(CONTROLPOWER).getBooleanValue(); // required value
00247                                 controlpvr = node.get(CONTROLPVR).getBooleanValue(); // required value
00248                                 controlsystem = node.get(CONTROLSYSTEM).getBooleanValue(); // required value
00249                                 executeaddon = node.get(EXECUTEADDON).getBooleanValue(); // required value
00250                                 manageaddon = node.get(MANAGEADDON).getBooleanValue(); // required value
00251                                 navigate = node.get(NAVIGATE).getBooleanValue(); // required value
00252                                 readdata = node.get(READDATA).getBooleanValue(); // required value
00253                                 removedata = node.get(REMOVEDATA).getBooleanValue(); // required value
00254                                 updatedata = node.get(UPDATEDATA).getBooleanValue(); // required value
00255                                 writefile = node.get(WRITEFILE).getBooleanValue(); // required value
00256                         }
00257 
00258                         @Override
00259                         public JsonNode toJsonNode() {
00260                                 final ObjectNode node = OM.createObjectNode();
00261                                 node.put(CONTROLGUI, controlgui);
00262                                 node.put(CONTROLNOTIFY, controlnotify);
00263                                 node.put(CONTROLPLAYBACK, controlplayback);
00264                                 node.put(CONTROLPOWER, controlpower);
00265                                 node.put(CONTROLPVR, controlpvr);
00266                                 node.put(CONTROLSYSTEM, controlsystem);
00267                                 node.put(EXECUTEADDON, executeaddon);
00268                                 node.put(MANAGEADDON, manageaddon);
00269                                 node.put(NAVIGATE, navigate);
00270                                 node.put(READDATA, readdata);
00271                                 node.put(REMOVEDATA, removedata);
00272                                 node.put(UPDATEDATA, updatedata);
00273                                 node.put(WRITEFILE, writefile);
00274                                 return node;
00275                         }
00276 
00282                         static List<PermissionResult> getJSONRPCPermissionResultList(JsonNode node, String key) {
00283                                 if (node.has(key)) {
00284                                         final ArrayNode a = (ArrayNode)node.get(key);
00285                                         final List<PermissionResult> l = new ArrayList<PermissionResult>(a.size());
00286                                         for (int i = 0; i < a.size(); i++) {
00287                                                 l.add(new PermissionResult((JsonNode)a.get(i)));
00288                                         }
00289                                         return l;
00290                                 }
00291                                 return new ArrayList<PermissionResult>(0);
00292                         }
00293 
00299                         @Override
00300                         public void writeToParcel(Parcel parcel, int flags) {
00301                                 parcel.writeInt(controlgui ? 1 : 0);
00302                                 parcel.writeInt(controlnotify ? 1 : 0);
00303                                 parcel.writeInt(controlplayback ? 1 : 0);
00304                                 parcel.writeInt(controlpower ? 1 : 0);
00305                                 parcel.writeInt(controlpvr ? 1 : 0);
00306                                 parcel.writeInt(controlsystem ? 1 : 0);
00307                                 parcel.writeInt(executeaddon ? 1 : 0);
00308                                 parcel.writeInt(manageaddon ? 1 : 0);
00309                                 parcel.writeInt(navigate ? 1 : 0);
00310                                 parcel.writeInt(readdata ? 1 : 0);
00311                                 parcel.writeInt(removedata ? 1 : 0);
00312                                 parcel.writeInt(updatedata ? 1 : 0);
00313                                 parcel.writeInt(writefile ? 1 : 0);
00314                         }
00315 
00319                         protected PermissionResult(Parcel parcel) {
00320                                 controlgui = parcel.readInt() == 1;
00321                                 controlnotify = parcel.readInt() == 1;
00322                                 controlplayback = parcel.readInt() == 1;
00323                                 controlpower = parcel.readInt() == 1;
00324                                 controlpvr = parcel.readInt() == 1;
00325                                 controlsystem = parcel.readInt() == 1;
00326                                 executeaddon = parcel.readInt() == 1;
00327                                 manageaddon = parcel.readInt() == 1;
00328                                 navigate = parcel.readInt() == 1;
00329                                 readdata = parcel.readInt() == 1;
00330                                 removedata = parcel.readInt() == 1;
00331                                 updatedata = parcel.readInt() == 1;
00332                                 writefile = parcel.readInt() == 1;
00333                         }
00334 
00338                         public static final Parcelable.Creator<PermissionResult> CREATOR = new Parcelable.Creator<PermissionResult>() {
00339                                 @Override
00340                                 public PermissionResult createFromParcel(Parcel parcel) {
00341                                         return new PermissionResult(parcel);
00342                                 }
00343                                 @Override
00344                                 public PermissionResult[] newArray(int n) {
00345                                         return new PermissionResult[n];
00346                                 }
00347                         };
00348 
00349                         @Override
00350                         public int describeContents() {
00351                                 return 0;
00352                         }
00353                 }
00354         }
00355 
00363         public static class Ping extends AbstractCall<String> {
00364                 public final static String API_TYPE = "JSONRPC.Ping";
00365 
00366                 @Override
00367                 public void writeToParcel(Parcel parcel, int flags) {
00368                         super.writeToParcel(parcel, flags);
00369                         parcel.writeValue(mResult);
00370                 }
00371 
00375                 protected Ping(Parcel parcel) {
00376                         super(parcel);
00377                 }
00378 
00382                 public static final Parcelable.Creator<Ping> CREATOR = new Parcelable.Creator<Ping>() {
00383                         @Override
00384                         public Ping createFromParcel(Parcel parcel) {
00385                                 return new Ping(parcel);
00386                         }
00387                         @Override
00388                         public Ping[] newArray(int n) {
00389                                 return new Ping[n];
00390                         }
00391                 };
00392 
00396                 public Ping() {
00397                         super();
00398                 }
00399 
00400                 @Override
00401                 protected String parseOne(JsonNode node) {
00402                         return node.getTextValue();
00403                 }
00404 
00405                 @Override
00406                 public String getName() {
00407                         return API_TYPE;
00408                 }
00409 
00410                 @Override
00411                 protected boolean returnsList() {
00412                         return false;
00413                 }
00414         }
00415 
00423         public static class Version extends AbstractCall<Version.VersionResult> {
00424                 public final static String API_TYPE = "JSONRPC.Version";
00425 
00426                 @Override
00427                 public void writeToParcel(Parcel parcel, int flags) {
00428                         super.writeToParcel(parcel, flags);
00429                         parcel.writeParcelable(mResult, flags);
00430                 }
00431 
00435                 protected Version(Parcel parcel) {
00436                         super(parcel);
00437                 }
00438 
00442                 public static final Parcelable.Creator<Version> CREATOR = new Parcelable.Creator<Version>() {
00443                         @Override
00444                         public Version createFromParcel(Parcel parcel) {
00445                                 return new Version(parcel);
00446                         }
00447                         @Override
00448                         public Version[] newArray(int n) {
00449                                 return new Version[n];
00450                         }
00451                 };
00452 
00456                 public Version() {
00457                         super();
00458                 }
00459 
00460                 @Override
00461                 protected VersionResult parseOne(JsonNode node) {
00462                         return new VersionResult(node.get("version"));
00463                 }
00464 
00465                 @Override
00466                 public String getName() {
00467                         return API_TYPE;
00468                 }
00469 
00470                 @Override
00471                 protected boolean returnsList() {
00472                         return false;
00473                 }
00474 
00479                 public static class VersionResult extends AbstractModel {
00480 
00481                         // field names
00482                         public static final String MAJOR = "major";
00483                         public static final String MINOR = "minor";
00484                         public static final String PATCH = "patch";
00485 
00486                         // class members
00487                         public final Integer major;
00488                         public final Integer minor;
00489                         public final Integer patch;
00490 
00496                         public VersionResult(Integer major, Integer minor, Integer patch) {
00497                                 this.major = major;
00498                                 this.minor = minor;
00499                                 this.patch = patch;
00500                         }
00501 
00502                         @Override
00503                         public String toString() {
00504                                 return major + "." + minor + "." + patch;
00505                         }
00506 
00514                         public int toInt() {
00515                                 return patch + minor * 10000 + major * 10000000;
00516                         }
00517 
00522                         public VersionResult(JsonNode node) {
00523                                 major = node.get(MAJOR).getIntValue(); // required value
00524                                 minor = node.get(MINOR).getIntValue(); // required value
00525                                 patch = node.get(PATCH).getIntValue(); // required value
00526                         }
00527 
00528                         @Override
00529                         public JsonNode toJsonNode() {
00530                                 final ObjectNode node = OM.createObjectNode();
00531                                 node.put(MAJOR, major);
00532                                 node.put(MINOR, minor);
00533                                 node.put(PATCH, patch);
00534                                 return node;
00535                         }
00536 
00542                         static List<VersionResult> getJSONRPCVersionResultList(JsonNode node, String key) {
00543                                 if (node.has(key)) {
00544                                         final ArrayNode a = (ArrayNode)node.get(key);
00545                                         final List<VersionResult> l = new ArrayList<VersionResult>(a.size());
00546                                         for (int i = 0; i < a.size(); i++) {
00547                                                 l.add(new VersionResult((JsonNode)a.get(i)));
00548                                         }
00549                                         return l;
00550                                 }
00551                                 return new ArrayList<VersionResult>(0);
00552                         }
00553 
00559                         @Override
00560                         public void writeToParcel(Parcel parcel, int flags) {
00561                                 parcel.writeValue(major);
00562                                 parcel.writeValue(minor);
00563                                 parcel.writeValue(patch);
00564                         }
00565 
00569                         protected VersionResult(Parcel parcel) {
00570                                 major = parcel.readInt();
00571                                 minor = parcel.readInt();
00572                                 patch = parcel.readInt();
00573                         }
00574 
00578                         public static final Parcelable.Creator<VersionResult> CREATOR = new Parcelable.Creator<VersionResult>() {
00579                                 @Override
00580                                 public VersionResult createFromParcel(Parcel parcel) {
00581                                         return new VersionResult(parcel);
00582                                 }
00583                                 @Override
00584                                 public VersionResult[] newArray(int n) {
00585                                         return new VersionResult[n];
00586                                 }
00587                         };
00588 
00589                         @Override
00590                         public int describeContents() {
00591                                 return 0;
00592                         }
00593                 }
00594         }
00595 }


smarthome_media_kodi_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 21:03:49