コード例 #1
0
  private List<Add> appendAddConfiguration(Operation operation) throws WindowsOperationException {

    List<Add> addList = new ArrayList<Add>();
    Gson gson = new Gson();

    if (SyncmlCommandType.WIFI.getValue().equals(operation.getCode())) {

      Add add = new Add();

      String operationCode = operation.getCode();

      Wifi wifiObject = gson.fromJson((String) operation.getPayLoad(), Wifi.class);

      String data =
          "&lt;?xml version=&quot;1.0&quot;?&gt;&lt;WLANProfile"
              + "xmlns=&quot;http://www.microsoft.com/networking/WLAN/profile/v1&quot;&gt;&lt;name&gt;"
              + wifiObject.getNetworkName()
              + "&lt;/name&gt;&lt;SSIDConfig&gt;&lt;SSID&gt;&lt;name&gt;"
              + wifiObject.getSsid()
              + "&lt;/name&gt;&lt;/SSID&gt;&lt;/SSIDConfig&gt;&lt;connectionType&gt;"
              + wifiObject.getConnectionType()
              + "&lt;/connectionType&gt;&lt;connectionMode&gt;"
              + wifiObject.getConnectionMode()
              + "&lt;/connectionMode&gt;&lt;MSM&gt;&lt;security&gt;&lt;"
              + "authEncryption&gt;&lt;authentication&gt;"
              + wifiObject.getAuthentication()
              + "&lt;/authentication&gt;&lt;encryption&gt;"
              + wifiObject.getEncryption()
              + "&lt;/encryption&gt;&lt;/authEncryption&gt;&lt;sharedKey&gt;&lt;keyType&gt;"
              + wifiObject.getKeyType()
              + "&lt;/keyType&gt;&lt;protected&gt;"
              + wifiObject.getProtection()
              + "&lt;/protected&gt;&lt;keyMaterial&gt;"
              + wifiObject.getKeyMaterial()
              + "&lt;/keyMaterial&gt;&lt;/sharedKey&gt;&lt;/security&gt;&lt;/MSM&gt;&lt;/WLANProfile&gt;";

      Meta meta = new Meta();
      meta.setFormat("chr");
      List<Item> items = new ArrayList<Item>();

      for (Configure configure : Configure.values()) {
        if (operationCode != null && operationCode.equals(configure.name())) {
          Target target = new Target();
          target.setLocURI(configure.getCode());
          items.get(0).setTarget(target);
        }
      }
      items.get(0).setMeta(meta);
      items.get(0).setData(data);

      add.setCommandId(301);
      add.setItems(items);
      addList.add(add);
      return addList;
    }
    return null;
  }