Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2012 Savoir-Faire Linux Inc. |
| 3 | * |
| 4 | * Author: Alexandre Savard <alexandre.savard@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 | |
| 32 | package com.savoirfairelinux.sflphone.client; |
| 33 | |
| 34 | import android.app.Activity; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 35 | import android.content.Context; |
| 36 | import android.content.ComponentName; |
| 37 | import android.content.Intent; |
| 38 | import android.content.ServiceConnection; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 39 | import android.os.Bundle; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 40 | import android.os.IBinder; |
| 41 | import android.os.RemoteException; |
| 42 | import android.util.Log; |
| 43 | import android.view.View; |
| 44 | import android.view.View.OnClickListener; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 45 | |
| 46 | import com.savoirfairelinux.sflphone.R; |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 47 | import com.savoirfairelinux.sflphone.client.SipCall; |
| 48 | import com.savoirfairelinux.sflphone.service.ISipService; |
| 49 | import com.savoirfairelinux.sflphone.service.SipService; |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 50 | |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 51 | public class CallActivity extends Activity implements OnClickListener |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 52 | { |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 53 | static final String TAG = "CallActivity"; |
| 54 | private ISipService service; |
| 55 | private SipCall mCall; |
| 56 | |
| 57 | public void CallActivity(SipCall call) { |
| 58 | mCall = call; |
| 59 | } |
| 60 | |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 61 | @Override |
| 62 | protected void onCreate(Bundle savedInstanceState) |
| 63 | { |
| 64 | super.onCreate(savedInstanceState); |
| 65 | setContentView(R.layout.call_activity_layout); |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 66 | |
| 67 | Intent intent = new Intent(this, SipService.class); |
| 68 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
| 69 | |
| 70 | |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | protected void onDestroy() { |
| 75 | stopService(new Intent(this, SipService.class)); |
| 76 | super.onDestroy(); |
| 77 | } |
| 78 | |
| 79 | /** Defines callbacks for service binding, passed to bindService() */ |
| 80 | private ServiceConnection mConnection = new ServiceConnection() { |
| 81 | @Override |
| 82 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 83 | service = ISipService.Stub.asInterface(binder); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void onServiceDisconnected(ComponentName arg0) { |
| 88 | } |
| 89 | }; |
| 90 | |
| 91 | @Override |
| 92 | public void onClick(View view) |
| 93 | { |
| 94 | if(view.getId() == R.id.buttonhangup) { |
| 95 | try { |
| 96 | service.hangUp(mCall.mCallInfo.mCallID); |
| 97 | } catch (RemoteException e) { |
| 98 | Log.e(TAG, "Cannot call service method", e); |
| 99 | } |
| 100 | } |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 101 | } |
| 102 | } |