blob: 69c9727a1d7351cc027f15278c7a58d4aefe49f8 [file] [log] [blame]
Alexandre Lision2e52d392013-11-06 15:14:31 -05001/*
Alexandre Lisionc1024c02014-01-06 11:12:53 -05002 * Copyright (C) 2004-2014 Savoir-Faire Linux Inc.
Alexandre Lision2e52d392013-11-06 15:14:31 -05003 *
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 Lision72e37322013-11-04 17:14:11 -050032package org.sflphone.client;
33
Alexandre Lision2e52d392013-11-06 15:14:31 -050034import org.sflphone.R;
35import org.sflphone.fragments.DetailsHistoryEntryFragment;
36import org.sflphone.fragments.HistoryFragment;
Alexandre Lisionddbb46f2013-12-12 12:18:58 -050037import org.sflphone.model.Conference;
38import org.sflphone.model.SipCall;
Alexandre Lision2e52d392013-11-06 15:14:31 -050039import org.sflphone.service.ISipService;
40import org.sflphone.service.SipService;
Alexandre Lision72e37322013-11-04 17:14:11 -050041
Alexandre Lision2e52d392013-11-06 15:14:31 -050042import android.app.Activity;
43import android.app.Fragment;
44import android.app.FragmentTransaction;
45import android.content.ComponentName;
46import android.content.Context;
47import android.content.Intent;
48import android.content.ServiceConnection;
49import android.os.Bundle;
50import android.os.IBinder;
51import android.util.Log;
52import android.view.MenuItem;
53
54public 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 Lision6da3bb92013-12-10 17:32:46 -0500123 @Override
Alexandre Lisionddbb46f2013-12-12 12:18:58 -0500124 public void onCall(SipCall call) {
125 Bundle bundle = new Bundle();
126 Conference tmp = new Conference("-1");
Alexandre Lision6da3bb92013-12-10 17:32:46 -0500127
Alexandre Lisionddbb46f2013-12-12 12:18:58 -0500128 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 Lision2e52d392013-11-06 15:14:31 -0500136}