Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 1 | package org.sflphone.account; |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.HashMap; |
| 5 | |
Alexandre Lision | 064e1e0 | 2013-10-01 16:18:42 -0400 | [diff] [blame] | 6 | import org.sflphone.service.ServiceConstants; |
| 7 | import org.sflphone.service.StringMap; |
| 8 | import org.sflphone.service.VectMap; |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 9 | |
| 10 | public class HistoryHandler { |
Alexandre Lision | 6e8931e | 2013-09-19 16:49:34 -0400 | [diff] [blame] | 11 | // private static final String TAG = HistoryHandler.class.getSimpleName(); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 12 | |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 13 | private static String tryToGet(StringMap smap, String key) { |
| 14 | if (smap.has_key(key)) { |
| 15 | return smap.get(key); |
| 16 | } else { |
| 17 | return ""; |
| 18 | } |
| 19 | } |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 20 | |
| 21 | public static ArrayList<HashMap<String, String>> convertSwigToNative(VectMap swigmap) { |
| 22 | |
| 23 | ArrayList<HashMap<String, String>> nativemap = new ArrayList<HashMap<String, String>>(); |
| 24 | |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame] | 25 | // Log.w(TAG, "size history " + swigmap.size()); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 26 | |
| 27 | for (int i = 0; i < swigmap.size(); ++i) { |
| 28 | HashMap<String, String> entry = new HashMap<String, String>(); |
| 29 | |
Alexandre Lision | 6711ab2 | 2013-09-16 15:15:38 -0400 | [diff] [blame] | 30 | entry.put(ServiceConstants.history.ACCOUNT_ID_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.ACCOUNT_ID_KEY)); |
| 31 | entry.put(ServiceConstants.history.CALLID_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.CALLID_KEY)); |
| 32 | entry.put(ServiceConstants.history.CONFID_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.CONFID_KEY)); |
| 33 | entry.put(ServiceConstants.history.DISPLAY_NAME_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.DISPLAY_NAME_KEY)); |
| 34 | entry.put(ServiceConstants.history.PEER_NUMBER_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.PEER_NUMBER_KEY)); |
| 35 | entry.put(ServiceConstants.history.RECORDING_PATH_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.RECORDING_PATH_KEY)); |
| 36 | entry.put(ServiceConstants.history.STATE_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.STATE_KEY)); |
| 37 | entry.put(ServiceConstants.history.TIMESTAMP_START_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.TIMESTAMP_START_KEY)); |
| 38 | entry.put(ServiceConstants.history.TIMESTAMP_STOP_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.TIMESTAMP_STOP_KEY)); |
| 39 | entry.put(ServiceConstants.history.AUDIO_CODEC_KEY, tryToGet(swigmap.get(i), ServiceConstants.history.AUDIO_CODEC_KEY)); |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 40 | |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 41 | nativemap.add(entry); |
| 42 | } |
| 43 | |
| 44 | return nativemap; |
| 45 | } |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 46 | } |