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 | |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 57 | @Override |
| 58 | protected void onCreate(Bundle savedInstanceState) |
| 59 | { |
| 60 | super.onCreate(savedInstanceState); |
| 61 | setContentView(R.layout.call_activity_layout); |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 62 | |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 63 | Bundle b = getIntent().getExtras(); |
| 64 | // Parcelable value = b.getParcelable("CallInfo"); |
| 65 | SipCall.CallInfo info = b.getParcelable("CallInfo"); // new SipCall.CallInfo.CREATOR.createFromParcel |
| 66 | Log.i(TAG, "Starting activity for call " + info.mCallID); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame^] | 67 | mCall = new SipCall(info); |
Alexandre Savard | 557a574 | 2012-10-24 13:54:53 -0400 | [diff] [blame] | 68 | |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 69 | Intent intent = new Intent(this, SipService.class); |
| 70 | bindService(intent, mConnection, Context.BIND_AUTO_CREATE); |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame^] | 71 | |
| 72 | findViewById(R.id.buttonhangup).setOnClickListener(this); |
| 73 | |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | @Override |
| 77 | protected void onDestroy() { |
| 78 | stopService(new Intent(this, SipService.class)); |
| 79 | super.onDestroy(); |
| 80 | } |
| 81 | |
| 82 | /** Defines callbacks for service binding, passed to bindService() */ |
| 83 | private ServiceConnection mConnection = new ServiceConnection() { |
| 84 | @Override |
| 85 | public void onServiceConnected(ComponentName className, IBinder binder) { |
| 86 | service = ISipService.Stub.asInterface(binder); |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | public void onServiceDisconnected(ComponentName arg0) { |
| 91 | } |
| 92 | }; |
| 93 | |
| 94 | @Override |
| 95 | public void onClick(View view) |
| 96 | { |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame^] | 97 | Log.i(TAG, "On click action"); |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 98 | if(view.getId() == R.id.buttonhangup) { |
Alexandre Savard | 74c1cad | 2012-10-24 16:39:00 -0400 | [diff] [blame^] | 99 | mCall.hangup(service); |
| 100 | // terminate this activity |
| 101 | finish(); |
Alexandre Savard | 6d54bbc | 2012-10-24 11:04:23 -0400 | [diff] [blame] | 102 | } |
Alexandre Savard | 14323be | 2012-10-24 10:02:13 -0400 | [diff] [blame] | 103 | } |
| 104 | } |