blob: 3427c74f75812f4609afd77b4627d3c7a03cced3 [file] [log] [blame]
Alexandre Lision064e1e02013-10-01 16:18:42 -04001package org.sflphone.account;
alisione2a38e12013-04-25 14:20:20 -04002
3import java.util.ArrayList;
4import java.util.HashMap;
5
Alexandre Lision064e1e02013-10-01 16:18:42 -04006import org.sflphone.service.ServiceConstants;
7import org.sflphone.service.StringMap;
8import org.sflphone.service.VectMap;
alisione2a38e12013-04-25 14:20:20 -04009
10public class HistoryHandler {
Alexandre Lision6e8931e2013-09-19 16:49:34 -040011// private static final String TAG = HistoryHandler.class.getSimpleName();
alisione2a38e12013-04-25 14:20:20 -040012
Tristan Matthews39910d52013-07-18 17:04:15 -040013 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 }
alisione2a38e12013-04-25 14:20:20 -040020
21 public static ArrayList<HashMap<String, String>> convertSwigToNative(VectMap swigmap) {
22
23 ArrayList<HashMap<String, String>> nativemap = new ArrayList<HashMap<String, String>>();
24
Alexandre Lisionc51ccb12013-09-11 16:00:30 -040025// Log.w(TAG, "size history " + swigmap.size());
alisione2a38e12013-04-25 14:20:20 -040026
27 for (int i = 0; i < swigmap.size(); ++i) {
28 HashMap<String, String> entry = new HashMap<String, String>();
29
Alexandre Lision6711ab22013-09-16 15:15:38 -040030 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 Matthews39910d52013-07-18 17:04:15 -040040
alisione2a38e12013-04-25 14:20:20 -040041 nativemap.add(entry);
42 }
43
44 return nativemap;
45 }
Tristan Matthews39910d52013-07-18 17:04:15 -040046}