blob: d032e8d4025d8e3523d0e4f21a22873f08e80e34 [file] [log] [blame]
Alexandre Savard14323be2012-10-24 10:02:13 -04001/*
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
32package com.savoirfairelinux.sflphone.client;
33
34import android.app.Activity;
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040035import android.content.Context;
36import android.content.ComponentName;
37import android.content.Intent;
38import android.content.ServiceConnection;
Alexandre Savard14323be2012-10-24 10:02:13 -040039import android.os.Bundle;
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040040import android.os.IBinder;
41import android.os.RemoteException;
42import android.util.Log;
43import android.view.View;
44import android.view.View.OnClickListener;
Alexandre Savard14323be2012-10-24 10:02:13 -040045
46import com.savoirfairelinux.sflphone.R;
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040047import com.savoirfairelinux.sflphone.client.SipCall;
48import com.savoirfairelinux.sflphone.service.ISipService;
49import com.savoirfairelinux.sflphone.service.SipService;
Alexandre Savard14323be2012-10-24 10:02:13 -040050
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040051public class CallActivity extends Activity implements OnClickListener
Alexandre Savard14323be2012-10-24 10:02:13 -040052{
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040053 static final String TAG = "CallActivity";
54 private ISipService service;
55 private SipCall mCall;
56
Alexandre Savard14323be2012-10-24 10:02:13 -040057 @Override
58 protected void onCreate(Bundle savedInstanceState)
59 {
60 super.onCreate(savedInstanceState);
61 setContentView(R.layout.call_activity_layout);
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040062
Alexandre Savard557a5742012-10-24 13:54:53 -040063 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 Savard74c1cad2012-10-24 16:39:00 -040067 mCall = new SipCall(info);
Alexandre Savard557a5742012-10-24 13:54:53 -040068
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040069 Intent intent = new Intent(this, SipService.class);
70 bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
Alexandre Savard74c1cad2012-10-24 16:39:00 -040071
72 findViewById(R.id.buttonhangup).setOnClickListener(this);
73
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040074 }
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 Savard74c1cad2012-10-24 16:39:00 -040097 Log.i(TAG, "On click action");
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040098 if(view.getId() == R.id.buttonhangup) {
Alexandre Savard74c1cad2012-10-24 16:39:00 -040099 mCall.hangup(service);
100 // terminate this activity
101 finish();
Alexandre Savard6d54bbc2012-10-24 11:04:23 -0400102 }
Alexandre Savard14323be2012-10-24 10:02:13 -0400103 }
104}