1/* 2 * Copyright (C) 2008 Esmertec AG. 3 * Copyright (C) 2008 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17package com.android.im.imps; 18 19import java.util.Map; 20 21import android.os.RemoteException; 22 23import com.android.im.engine.ImException; 24import com.android.im.plugin.ImPluginConstants; 25import com.android.im.plugin.PresenceMapping; 26 27import dalvik.system.PathClassLoader; 28 29public class CustomPresenceMapping implements PresenceMapping { 30 private PresenceMapping mPresenceMapping; 31 32 public CustomPresenceMapping(String pluginPath, String implClass) throws ImException { 33 PathClassLoader classLoader = new PathClassLoader(pluginPath, 34 getClass().getClassLoader()); 35 try { 36 Class<?> cls = classLoader.loadClass(implClass); 37 mPresenceMapping = (PresenceMapping)cls.newInstance(); 38 } catch (ClassNotFoundException e) { 39 throw new ImException(e); 40 } catch (IllegalAccessException e) { 41 throw new ImException(e); 42 } catch (InstantiationException e) { 43 throw new ImException(e); 44 } 45 } 46 47 public Map<String, Object> getExtra(int status) { 48 return mPresenceMapping.getExtra(status); 49 } 50 51 public boolean getOnlineStatus(int status) { 52 return mPresenceMapping.getOnlineStatus(status); 53 } 54 55 public int getPresenceStatus(boolean onlineStatus, String userAvailability, 56 Map<String, Object> allValues) { 57 return mPresenceMapping.getPresenceStatus(onlineStatus, userAvailability, allValues); 58 } 59 60 public int[] getSupportedPresenceStatus() { 61 return mPresenceMapping.getSupportedPresenceStatus(); 62 } 63 64 public String getUserAvaibility(int status) { 65 return mPresenceMapping.getUserAvaibility(status); 66 } 67 68 public boolean requireAllPresenceValues() { 69 return mPresenceMapping.requireAllPresenceValues(); 70 } 71 72} 73