FileDocCategorySizeDatePackage
DemoPresenceMapping.javaAPI DocAndroid 1.5 API3470Wed May 06 22:42:46 BST 2009com.android.im.plugin.demo

DemoPresenceMapping

public class DemoPresenceMapping extends IPresenceMapping.Stub
A simple implementation of PresenceMaping for the provider.

Fields Summary
Constructors Summary
Methods Summary
public java.util.MapgetExtra(int status)

        // We don't have extra values except OnlineStatus and UserAvaibility
        // need to be sent to the server. If we do need other values to the server,
        // return a map the values structured the same as they are defined in the spec.
        //
        // e.g.
        // Map<String, Object> extra = new HashMap<String, Object>();
        //
        // HashMap<String, Object> commCap = new HashMap<String, Object>();
        //
        // HashMap<String, Object> commC = new HashMap<String, Object>();
        // commC.put("Qualifier", "T");
        // commC.put("Cap", "IM");
        // commC.put("Status", "Open");
        //
        // commCap.put("Qualifier", "T");
        // commCap.put("CommC", commC);
        //
        // extra.put("CommCap", commCap);
        // return extra;
        return null;
    
public booleangetOnlineStatus(int status)

        return status != ImPluginConstants.PRESENCE_OFFLINE;
    
public intgetPresenceStatus(boolean onlineStatus, java.lang.String userAvailability, java.util.Map allValues)

        if (!onlineStatus) {
            return ImPluginConstants.PRESENCE_OFFLINE;
        }
        if (ImPluginConstants.PA_NOT_AVAILABLE.equals(userAvailability)) {
            return ImPluginConstants.PRESENCE_AWAY;
        } else if (ImPluginConstants.PA_DISCREET.equals(userAvailability)) {
            return ImPluginConstants.PRESENCE_DO_NOT_DISTURB;
        } else {
            return ImPluginConstants.PRESENCE_AVAILABLE;
        }
    
public int[]getSupportedPresenceStatus()

        return new int[] {
                ImPluginConstants.PRESENCE_AVAILABLE,
                ImPluginConstants.PRESENCE_DO_NOT_DISTURB,
                ImPluginConstants.PRESENCE_OFFLINE
        };
    
public java.lang.StringgetUserAvaibility(int status)

        switch (status) {
            case ImPluginConstants.PRESENCE_AVAILABLE:
                return ImPluginConstants.PA_AVAILABLE;

            case ImPluginConstants.PRESENCE_DO_NOT_DISTURB:
                return ImPluginConstants.PA_DISCREET;

            case ImPluginConstants.PRESENCE_OFFLINE:
                return ImPluginConstants.PA_NOT_AVAILABLE;

            default:
                return null;
        }
    
public booleanrequireAllPresenceValues()

        // Return false since we don't need all values received from the server
        // when map it to the predefined presence status.
        return false;