// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: braces fieldsfirst space lnc package com.philips.lighting.hue.sdk.clip; import com.philips.lighting.model.PHBridgeConfiguration; import com.philips.lighting.model.PHGroup; import com.philips.lighting.model.PHLight; import com.philips.lighting.model.PHLightState; import com.philips.lighting.model.PHSchedule; import com.philips.lighting.model.PHSoftwareUpdateStatus; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.List; import java.util.Locale; import java.util.TimeZone; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; // Referenced classes of package com.philips.lighting.hue.sdk.clip: // PHCLIPBuilder public class PHCLIPBuilder1_0 implements PHCLIPBuilder { public static final int LOCAL_KEY = 4626; public static final int PORTAL_KEY = 13364; public PHCLIPBuilder1_0() { } public static PHCLIPBuilder1_0 getInstance(int i) { if (i == 4626 || i == 13364) { return new PHCLIPBuilder1_0(); } else { return null; } } public String createActivateScenePacket(String s) throws JSONException { return null; } public String createFindLightSerialsPacket(List list) throws JSONException { return null; } public String createGroupPacket(String s, String as[]) throws JSONException { JSONObject jsonobject = new JSONObject(); JSONArray jsonarray = new JSONArray(); int i = 0; do { if (i >= as.length) { jsonobject.putOpt("name", s); jsonobject.putOpt("lights", jsonarray); return jsonobject.toString(); } jsonarray.put(i, as[i]); i++; } while (true); } public String createScenePacket(String s, String as[]) throws JSONException { return null; } public String createSchedulePacket(PHSchedule phschedule, String s, String s1) throws JSONException { return createSchedulePacket(phschedule, s, s1, "UTC"); } public String createSchedulePacket(PHSchedule phschedule, String s, String s1, String s2) throws JSONException { label0: { Object obj; label1: { obj = new JSONObject(); if (s != null) { ((JSONObject) (obj)).putOpt("address", s); } if (s1 != null) { ((JSONObject) (obj)).putOpt("method", s1); } if (phschedule.getLightState() != null) { ((JSONObject) (obj)).putOpt("body", lightStateForIdPacket(phschedule.getLightState())); } s = new JSONObject(); if (phschedule.getName() != null) { s.putOpt("name", phschedule.getName()); } if (phschedule.getDescription() != null && phschedule.getDescription().length() != 0) { s.putOpt("description", phschedule.getDescription()); } if (obj != null) { s.putOpt("command", obj); } s1 = phschedule.getDate(); if (s1 == null) { break label0; } obj = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", new Locale("nl_NL")); if (s2 != null) { phschedule = s2; if (s2.length() != 0) { break label1; } } phschedule = "UTC"; } ((DateFormat) (obj)).setTimeZone(TimeZone.getTimeZone(phschedule)); s.putOpt("time", ((DateFormat) (obj)).format(s1)); } return s.toString(); } public String createUpdateBridge(PHBridgeConfiguration phbridgeconfiguration) throws JSONException { JSONObject jsonobject = new JSONObject(); if (phbridgeconfiguration.getName() != null && phbridgeconfiguration.getName().length() > 0) { jsonobject.putOpt("name", phbridgeconfiguration.getName()); } if (phbridgeconfiguration.getTime() != null && phbridgeconfiguration.getTime().length() > 0) { jsonobject.putOpt("UTC", phbridgeconfiguration.getTime()); } if (phbridgeconfiguration.getProxy() != null && phbridgeconfiguration.getProxy().length() > 0) { jsonobject.putOpt("proxyaddress", phbridgeconfiguration.getProxy()); } if (phbridgeconfiguration.getProxyPort() != -55) { jsonobject.putOpt("proxyport", Integer.valueOf(phbridgeconfiguration.getProxyPort())); } if (phbridgeconfiguration.getDhcpEnabled() != null) { jsonobject.putOpt("dhcp", phbridgeconfiguration.getDhcpEnabled()); } if (phbridgeconfiguration.getIpAddress() != null && phbridgeconfiguration.getIpAddress().length() > 0) { jsonobject.putOpt("ipaddress", phbridgeconfiguration.getIpAddress()); } if (phbridgeconfiguration.getNetmask() != null && phbridgeconfiguration.getNetmask().length() > 0) { jsonobject.putOpt("netmask", phbridgeconfiguration.getNetmask()); } if (phbridgeconfiguration.getGateway() != null && phbridgeconfiguration.getGateway().length() > 0) { jsonobject.putOpt("gateway", phbridgeconfiguration.getGateway()); } if (phbridgeconfiguration.getPortalServicesEnabled() != null) { jsonobject.putOpt("portalservices", phbridgeconfiguration.getPortalServicesEnabled()); } Object obj = phbridgeconfiguration.getSoftwareStatus(); if (obj != null) { phbridgeconfiguration = new JSONObject(); obj = ((PHSoftwareUpdateStatus) (obj)).getState(); if (obj != null) { if (obj == com.philips.lighting.model.PHSoftwareUpdateStatus.PHStateType.NO_UPDATE) { phbridgeconfiguration.putOpt("notify", Boolean.valueOf(false)); } else { phbridgeconfiguration.putOpt("updatestate", Integer.valueOf(((com.philips.lighting.model.PHSoftwareUpdateStatus.PHStateType) (obj)).ordinal())); } } jsonobject.putOpt("swupdate", phbridgeconfiguration); } return jsonobject.toString(); } public String createUpdateGroup(PHGroup phgroup) throws JSONException { JSONObject jsonobject; jsonobject = new JSONObject(); jsonobject.put("name", phgroup.getName()); if (phgroup.getLightIdentifiers() == null) goto _L2; else goto _L1 _L1: JSONArray jsonarray; int i; jsonarray = new JSONArray(); i = 0; _L6: if (i < phgroup.getLightIdentifiers().length) goto _L4; else goto _L3 _L3: jsonobject.putOpt("lights", jsonarray); _L2: return jsonobject.toString(); _L4: jsonarray.put(i, phgroup.getLightIdentifiers()[i]); i++; if (true) goto _L6; else goto _L5 _L5: } public String createUpdateLightPacket(PHLight phlight) throws JSONException { JSONObject jsonobject = new JSONObject(); jsonobject.putOpt("name", phlight.getName()); return jsonobject.toString(); } public JSONObject lightStateForIdPacket(PHLightState phlightstate) throws JSONException { JSONObject jsonobject = new JSONObject(); if (phlightstate.getHue() != -55) { jsonobject.putOpt("hue", Integer.valueOf(phlightstate.getHue())); } if (phlightstate.isOn() != null) { jsonobject.putOpt("on", phlightstate.isOn()); } if (phlightstate.getBrightness() != -55) { jsonobject.putOpt("bri", Integer.valueOf(phlightstate.getBrightness())); } if (phlightstate.getSaturation() != -55) { jsonobject.putOpt("sat", Integer.valueOf(phlightstate.getSaturation())); } if (phlightstate.getTransitionTime() != -55) { jsonobject.putOpt("transitiontime", Integer.valueOf(phlightstate.getTransitionTime())); } if (phlightstate.getCt() != -55) { jsonobject.putOpt("ct", Integer.valueOf(phlightstate.getCt())); } if (phlightstate.getX() != -55F && phlightstate.getY() != -55F) { JSONArray jsonarray = new JSONArray(); JSONObject jsonobject1 = new JSONObject(String.format(Locale.ENGLISH, "{\"tempX\": %.4f}", new Object[] { Float.valueOf(phlightstate.getX()) })); JSONObject jsonobject2 = new JSONObject(String.format(Locale.ENGLISH, "{\"tempY\": %.4f}", new Object[] { Float.valueOf(phlightstate.getY()) })); jsonarray.put(jsonobject1.get("tempX")); jsonarray.put(jsonobject2.get("tempY")); jsonobject.putOpt("xy", jsonarray); } String s; if (phlightstate.getAlertMode() != null) { s = null; if (phlightstate.getAlertMode() == com.philips.lighting.model.PHLight.PHLightAlertMode.ALERT_NONE) { s = "none"; } else if (phlightstate.getAlertMode() == com.philips.lighting.model.PHLight.PHLightAlertMode.ALERT_LSELECT) { s = "lselect"; } else if (phlightstate.getAlertMode() == com.philips.lighting.model.PHLight.PHLightAlertMode.ALERT_SELECT) { s = "select"; } if (s != null) { jsonobject.putOpt("alert", s); } } if (phlightstate.getEffectMode() != null) { s = null; if (phlightstate.getEffectMode() == com.philips.lighting.model.PHLight.PHLightEffectMode.EFFECT_COLORLOOP) { s = "colorloop"; } else if (phlightstate.getEffectMode() == com.philips.lighting.model.PHLight.PHLightEffectMode.EFFECT_NONE) { s = "none"; } if (s != null) { jsonobject.putOpt("effect", s); } } return jsonobject; } public String updateLightStateForIdPacket(PHLightState phlightstate) throws JSONException { phlightstate = lightStateForIdPacket(phlightstate); if (phlightstate != null) { return phlightstate.toString(); } else { return null; } } public String updateSchedulePacket(PHSchedule phschedule, String s, String s1) throws JSONException { return null; } public String updateSchedulePacket(PHSchedule phschedule, String s, String s1, String s2) throws JSONException { return null; } }