blob: a950ea2d00854b5f4b0b409d07059062b9518cdb [file] [log] [blame]
Alexandre Lision3c6b7102013-09-16 16:56:46 -04001/*
2 * Copyright (C) 2004-2013 Savoir-Faire Linux Inc.
3 *
4 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Additional permission under GNU GPL version 3 section 7:
21 *
22 * If you modify this program, or any covered work, by linking or
23 * combining it with the OpenSSL project's OpenSSL library (or a
24 * modified version of that library), containing parts covered by the
25 * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26 * grants you additional permission to convey the resulting work.
27 * Corresponding Source for a non-source form of such a combination
28 * shall include the source code for the parts of OpenSSL used as well
29 * as that of the covered work.
30 */
31
Alexandre Lision064e1e02013-10-01 16:18:42 -040032package org.sflphone.account;
Alexandre Lision6711ab22013-09-16 15:15:38 -040033
34import java.util.HashMap;
35
Alexandre Lision064e1e02013-10-01 16:18:42 -040036import org.sflphone.service.ServiceConstants;
37import org.sflphone.service.StringMap;
Alexandre Lision3c6b7102013-09-16 16:56:46 -040038
Alexandre Lision064e1e02013-10-01 16:18:42 -040039import android.util.Log;
Alexandre Lision6711ab22013-09-16 15:15:38 -040040
41public class CallDetailsHandler {
Alexandre Lision3c6b7102013-09-16 16:56:46 -040042
43 private static String TAG = CallDetailsHandler.class.getSimpleName();
Alexandre Lision6711ab22013-09-16 15:15:38 -040044
45 public static HashMap<String, String> convertSwigToNative(StringMap swigmap) {
46
47 HashMap<String, String> entry = new HashMap<String, String>();
48
Alexandre Lisionfd7a88f2013-09-18 10:03:17 -040049 Log.i(TAG, "CALL_TYPE: " + tryToGet(swigmap, ServiceConstants.call.CALL_TYPE));
50 Log.i(TAG, "PEER_NUMBER: " + tryToGet(swigmap, ServiceConstants.call.PEER_NUMBER));
51 Log.i(TAG, "DISPLAY_NAME: " + tryToGet(swigmap, ServiceConstants.call.DISPLAY_NAME));
52 Log.i(TAG, "CALL_STATE: " + tryToGet(swigmap, ServiceConstants.call.CALL_STATE));
53 Log.i(TAG, "CONF_ID" + tryToGet(swigmap, ServiceConstants.call.CONF_ID));
54 Log.i(TAG, "TIMESTAMP_START: " + tryToGet(swigmap, ServiceConstants.call.TIMESTAMP_START));
55 Log.i(TAG, "ACCOUNTID: " + tryToGet(swigmap, ServiceConstants.call.ACCOUNTID));
Alexandre Lision3c6b7102013-09-16 16:56:46 -040056
Alexandre Lisionfd7a88f2013-09-18 10:03:17 -040057 entry.put(ServiceConstants.call.CALL_TYPE, tryToGet(swigmap, ServiceConstants.call.CALL_TYPE));
58 entry.put(ServiceConstants.call.PEER_NUMBER, tryToGet(swigmap, ServiceConstants.call.PEER_NUMBER));
59 entry.put(ServiceConstants.call.DISPLAY_NAME, tryToGet(swigmap, ServiceConstants.call.DISPLAY_NAME));
60 entry.put(ServiceConstants.call.CALL_STATE, tryToGet(swigmap, ServiceConstants.call.CALL_STATE));
61 entry.put(ServiceConstants.call.CONF_ID, tryToGet(swigmap, ServiceConstants.call.CONF_ID));
62 entry.put(ServiceConstants.call.TIMESTAMP_START, tryToGet(swigmap, ServiceConstants.call.TIMESTAMP_START));
63 entry.put(ServiceConstants.call.ACCOUNTID, tryToGet(swigmap, ServiceConstants.call.ACCOUNTID));
Alexandre Lision6711ab22013-09-16 15:15:38 -040064
65 return entry;
66 }
Alexandre Lisionfd7a88f2013-09-18 10:03:17 -040067
68 private static String tryToGet(StringMap smap, String key) {
69 if (smap.has_key(key)) {
70 return smap.get(key);
71 } else {
Alexandre Lision6e8931e2013-09-19 16:49:34 -040072 if(key.contentEquals(ServiceConstants.call.TIMESTAMP_START))
73 return ""+System.currentTimeMillis() / 1000;
Alexandre Lisionfd7a88f2013-09-18 10:03:17 -040074 return "";
75 }
76 }
Alexandre Lision6711ab22013-09-16 15:15:38 -040077
78}