blob: 6613a61e81401d5389dc3cee2c5a19c31285af1a [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
57 public void CallActivity(SipCall call) {
58 mCall = call;
59 }
60
Alexandre Savard14323be2012-10-24 10:02:13 -040061 @Override
62 protected void onCreate(Bundle savedInstanceState)
63 {
64 super.onCreate(savedInstanceState);
65 setContentView(R.layout.call_activity_layout);
Alexandre Savard6d54bbc2012-10-24 11:04:23 -040066
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 Savard14323be2012-10-24 10:02:13 -0400101 }
102}