/* 
 * Copyright 2014 OpenMarket Ltd
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.matrix.androidsdk.rest.model;

import java.util.HashMap;
import java.util.Map;

public class PowerLevels implements java.io.Serializable {
    public int ban;
    public int kick;
    public int invite;
    public int redact;

    public int eventsDefault;
    public Map<String, Integer> events = new HashMap<String, Integer>();

    public int usersDefault;
    public Map<String, Integer> users = new HashMap<String, Integer>();

    public int stateDefault;

    public PowerLevels deepCopy() {
        PowerLevels copy = new PowerLevels();
        copy.ban = ban;
        copy.kick = kick;
        copy.invite = invite;
        copy.redact = redact;

        copy.eventsDefault = eventsDefault;
        copy.events = new HashMap<String, Integer>();
        copy.events.putAll(events);

        copy.usersDefault = usersDefault;
        copy.users = new HashMap<String, Integer>();
        copy.users.putAll(users);

        copy.stateDefault = stateDefault;

        return copy;
    }

    public int getUserPowerLevel(String userId) {
        Integer powerLevel = users.get(userId);
        return (powerLevel != null) ? powerLevel : usersDefault;
    }

    public void setUserPowerLevel(String userId, int powerLevel) {
        if (null != userId) {
            users.put(userId, Integer.valueOf(powerLevel));
        }
    }
}
@@ -760,24 +760,29 @@
 blic int ban
+ = 50
 ;%0A    public
@@ -786,24 +786,29 @@
 lic int kick
+ = 50
 ;%0A    public
@@ -814,24 +814,29 @@
 c int invite
+ = 50
 ;%0A    public
@@ -842,24 +842,29 @@
 c int redact
+ = 50
 ;%0A%0A    publi
@@ -874,32 +874,37 @@
 nt eventsDefault
+ = 50
 ;%0A    public Map
@@ -986,24 +986,28 @@
 usersDefault
+ = 0
 ;%0A    public
@@ -1092,24 +1092,29 @@
 stateDefault
+ = 50
 ;%0A%0A    publi
@@ -1975,10 +1975,1199 @@
  %7D%0A    %7D
+%0A%0A    /**%0A     *  Helper to get the minimum power level the user must have to send an event of the given type%0A     as a message.%0A     * @param eventTypeString the type of event (in Event.EVENT_TYPE_XXX values)%0A     * @return the required minimum power level.%0A     */%0A    public int minimumPowerLevelForSendingEventAsMessage(String eventTypeString) %7B%0A        int minimumPowerLevel = eventsDefault;%0A%0A        if ((null != eventTypeString) && events.containsKey(eventTypeString)) %7B%0A            minimumPowerLevel = events.get(eventTypeString);%0A        %7D%0A%0A        return minimumPowerLevel;%0A    %7D%0A%0A    /**%0A     * Helper to get the minimum power level the user must have to send an event of the given type%0A     * as a state event.%0A     * @param eventTypeString the type of event (in Event.EVENT_TYPE_STATE_ values).%0A     * @return the required minimum power level.%0A     */%0A    public int minimumPowerLevelForSendingEventAsStateEvent(String eventTypeString) %7B%0A        int minimumPowerLevel = stateDefault;%0A%0A        if ((null != eventTypeString) && events.containsKey(eventTypeString)) %7B%0A            minimumPowerLevel = events.get(eventTypeString);%0A        %7D%0A%0A        return minimumPowerLevel;%0A    %7D
 %0A%7D

Add some new method to detect if an user can perform some room state updates.