Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 1 | /* |
Alexandre Lision | c1024c0 | 2014-01-06 11:12:53 -0500 | [diff] [blame] | 2 | * Copyright (C) 2004-2014 Savoir-Faire Linux Inc. |
Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 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 Lision | 72e3732 | 2013-11-04 17:14:11 -0500 | [diff] [blame] | 32 | package org.sflphone.client; |
| 33 | |
Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 34 | import org.sflphone.R; |
| 35 | import org.sflphone.fragments.DetailsHistoryEntryFragment; |
| 36 | import org.sflphone.fragments.HistoryFragment; |
Alexandre Lision | ddbb46f | 2013-12-12 12:18:58 -0500 | [diff] [blame] | 37 | import org.sflphone.model.Conference; |
| 38 | import org.sflphone.model.SipCall; |
Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 39 | import org.sflphone.service.ISipService; |
| 40 | import org.sflphone.service.SipService; |
Alexandre Lision | 72e3732 | 2013-11-04 17:14:11 -0500 | [diff] [blame] | 41 | |
Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 42 | import android.app.Activity; |
| 43 | import android.app.Fragment; |
| 44 | import android.app.FragmentTransaction; |
| 45 | import android.content.ComponentName; |
| 46 | import android.content.Context; |
| 47 | import android.content.Intent; |
| 48 | import android.content.ServiceConnection; |
| 49 | import android.os.Bundle; |
| 50 | import android.os.IBinder; |
| 51 | import android.util.Log; |
| 52 | import android.view.MenuItem; |
| 53 | |
| 54 | public class DetailHistoryActivity extends Activity implements DetailsHistoryEntryFragment.Callbacks { |
| 55 | |
| 56 | private boolean mBound = false; |
| 57 | private ISipService service; |
| 58 | private String TAG = DetailHistoryActivity.class.getSimpleName(); |
| 59 | |
| 60 | @Override |
| 61 | protected void onCreate(Bundle savedInstanceState) { |
| 62 | super.onCreate(savedInstanceState); |
| 63 | setContentView(R.layout.activity_holder); |
| 64 | |
| 65 | Intent intent = new Intent(this, SipService.class); |
| 66 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
| 67 | getActionBar().setDisplayHomeAsUpEnabled(true); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public boolean onOptionsItemSelected(MenuItem item) { |
| 72 | switch (item.getItemId()) { |
| 73 | case android.R.id.home: |
| 74 | finish(); |
| 75 | return true; |
| 76 | default: |
| 77 | return true; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public ISipService getService() { |
| 83 | return service; |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | protected void onPause() { |
| 88 | super.onPause(); |
| 89 | if (mBound) { |
| 90 | unbindService(mConnection); |
| 91 | mBound = false; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /** Defines callbacks for service binding, passed to bindService() */ |
| 96 | private ServiceConnection mConnection = new ServiceConnection() { |
| 97 | |
| 98 | @Override |
| 99 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 100 | service = ISipService.Stub.asInterface(binder); |
| 101 | |
| 102 | FragmentTransaction ft = getFragmentManager().beginTransaction(); |
| 103 | |
| 104 | Fragment fr = new DetailsHistoryEntryFragment(); |
| 105 | fr.setArguments(getIntent().getBundleExtra(HistoryFragment.ARGS)); |
| 106 | ft.replace(R.id.frag_container, fr); |
| 107 | |
| 108 | ft.commit(); |
| 109 | |
| 110 | mBound = true; |
| 111 | Log.d(TAG, "Service connected service=" + service); |
| 112 | |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public void onServiceDisconnected(ComponentName arg0) { |
| 117 | |
| 118 | mBound = false; |
| 119 | Log.d(TAG, "Service disconnected service=" + service); |
| 120 | } |
| 121 | }; |
| 122 | |
Alexandre Lision | 6da3bb9 | 2013-12-10 17:32:46 -0500 | [diff] [blame] | 123 | @Override |
Alexandre Lision | ddbb46f | 2013-12-12 12:18:58 -0500 | [diff] [blame] | 124 | public void onCall(SipCall call) { |
| 125 | Bundle bundle = new Bundle(); |
Alexandre Lision | 67c70b4 | 2014-01-16 13:57:15 -0500 | [diff] [blame] | 126 | Conference tmp = new Conference(Conference.DEFAULT_ID); |
Alexandre Lision | 6da3bb9 | 2013-12-10 17:32:46 -0500 | [diff] [blame] | 127 | |
Alexandre Lision | ddbb46f | 2013-12-12 12:18:58 -0500 | [diff] [blame] | 128 | tmp.getParticipants().add(call); |
| 129 | |
| 130 | bundle.putParcelable("conference", tmp); |
| 131 | Intent intent = new Intent().setClass(this, CallActivity.class); |
| 132 | intent.putExtra("resuming", false); |
| 133 | intent.putExtras(bundle); |
| 134 | startActivity(intent); |
| 135 | } |
Alexandre Lision | 2e52d39 | 2013-11-06 15:14:31 -0500 | [diff] [blame] | 136 | } |