alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 1 | package com.savoirfairelinux.sflphone.account; |
| 2 | |
| 3 | import java.util.ArrayList; |
| 4 | import java.util.HashMap; |
| 5 | |
| 6 | import android.util.Log; |
| 7 | |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 8 | import com.savoirfairelinux.sflphone.service.ServiceConstants; |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 9 | import com.savoirfairelinux.sflphone.service.VectMap; |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 10 | import com.savoirfairelinux.sflphone.service.StringMap; |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 11 | |
| 12 | public class HistoryHandler { |
| 13 | private static final String TAG = HistoryHandler.class.getSimpleName(); |
| 14 | |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 15 | private static String tryToGet(StringMap smap, String key) { |
| 16 | if (smap.has_key(key)) { |
| 17 | return smap.get(key); |
| 18 | } else { |
| 19 | return ""; |
| 20 | } |
| 21 | } |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 22 | |
| 23 | public static ArrayList<HashMap<String, String>> convertSwigToNative(VectMap swigmap) { |
| 24 | |
| 25 | ArrayList<HashMap<String, String>> nativemap = new ArrayList<HashMap<String, String>>(); |
| 26 | |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame^] | 27 | // Log.w(TAG, "size history " + swigmap.size()); |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 28 | |
| 29 | for (int i = 0; i < swigmap.size(); ++i) { |
| 30 | HashMap<String, String> entry = new HashMap<String, String>(); |
| 31 | |
Alexandre Lision | c51ccb1 | 2013-09-11 16:00:30 -0400 | [diff] [blame^] | 32 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_ACCOUNT_ID_KEY)); |
| 33 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CALLID_KEY)); |
| 34 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CONFID_KEY)); |
| 35 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_DISPLAY_NAME_KEY)); |
| 36 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_PEER_NUMBER_KEY)); |
| 37 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_RECORDING_PATH_KEY)); |
| 38 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_STATE_KEY)); |
| 39 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_START_KEY)); |
| 40 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_STOP_KEY)); |
| 41 | // Log.i(TAG, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_AUDIO_CODEC_KEY)); |
alision | 907bde7 | 2013-06-20 14:40:37 -0400 | [diff] [blame] | 42 | |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 43 | |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 44 | entry.put(ServiceConstants.HISTORY_ACCOUNT_ID_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_ACCOUNT_ID_KEY)); |
| 45 | entry.put(ServiceConstants.HISTORY_CALLID_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CALLID_KEY)); |
| 46 | entry.put(ServiceConstants.HISTORY_CONFID_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_CONFID_KEY)); |
| 47 | entry.put(ServiceConstants.HISTORY_DISPLAY_NAME_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_DISPLAY_NAME_KEY)); |
| 48 | entry.put(ServiceConstants.HISTORY_PEER_NUMBER_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_PEER_NUMBER_KEY)); |
| 49 | entry.put(ServiceConstants.HISTORY_RECORDING_PATH_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_RECORDING_PATH_KEY)); |
| 50 | entry.put(ServiceConstants.HISTORY_STATE_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_STATE_KEY)); |
| 51 | entry.put(ServiceConstants.HISTORY_TIMESTAMP_START_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_START_KEY)); |
| 52 | entry.put(ServiceConstants.HISTORY_TIMESTAMP_STOP_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_TIMESTAMP_STOP_KEY)); |
| 53 | entry.put(ServiceConstants.HISTORY_AUDIO_CODEC_KEY, tryToGet(swigmap.get(i), ServiceConstants.HISTORY_AUDIO_CODEC_KEY)); |
| 54 | |
alision | e2a38e1 | 2013-04-25 14:20:20 -0400 | [diff] [blame] | 55 | nativemap.add(entry); |
| 56 | } |
| 57 | |
| 58 | return nativemap; |
| 59 | } |
Tristan Matthews | 39910d5 | 2013-07-18 17:04:15 -0400 | [diff] [blame] | 60 | } |