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 */ 17 package com.android.im.imps; 18 19 import java.util.Map; 20 21 import android.os.RemoteException; 22 23 import com.android.im.engine.ImException; 24 import com.android.im.plugin.ImPluginConstants; 25 import com.android.im.plugin.PresenceMapping; 26 27 import dalvik.system.PathClassLoader; 28 29 public class CustomPresenceMapping implements PresenceMapping { 30 private PresenceMapping mPresenceMapping; 31 CustomPresenceMapping(String pluginPath, String implClass)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 getExtra(int status)47 public Map<String, Object> getExtra(int status) { 48 return mPresenceMapping.getExtra(status); 49 } 50 getOnlineStatus(int status)51 public boolean getOnlineStatus(int status) { 52 return mPresenceMapping.getOnlineStatus(status); 53 } 54 getPresenceStatus(boolean onlineStatus, String userAvailability, Map<String, Object> allValues)55 public int getPresenceStatus(boolean onlineStatus, String userAvailability, 56 Map<String, Object> allValues) { 57 return mPresenceMapping.getPresenceStatus(onlineStatus, userAvailability, allValues); 58 } 59 getSupportedPresenceStatus()60 public int[] getSupportedPresenceStatus() { 61 return mPresenceMapping.getSupportedPresenceStatus(); 62 } 63 getUserAvaibility(int status)64 public String getUserAvaibility(int status) { 65 return mPresenceMapping.getUserAvaibility(status); 66 } 67 requireAllPresenceValues()68 public boolean requireAllPresenceValues() { 69 return mPresenceMapping.requireAllPresenceValues(); 70 } 71 72 } 73