blob: ab9fbbfe91574c586f72e27d36c6a2560c8a85bd [file] [log] [blame]
Alexandre Savardfccd1dc2012-10-17 17:31:38 -04001/**
2 * Copyright (C) 2010-2012 Regis Montoya (aka r3gis - www.r3gis.fr)
3 * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
4 *
5 * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 * If you own a pjsip commercial license you can also redistribute it
12 * and/or modify it under the terms of the GNU Lesser General Public License
13 * as an android library.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 */
23package com.savoirfairelinux.sflphone.service;
24
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040025import android.content.Context;
26import android.content.Intent;
27import android.support.v4.content.LocalBroadcastManager;
Alexandre Savardfccd1dc2012-10-17 17:31:38 -040028import android.util.Log;
29
30public class ConfigurationManagerCallback extends ConfigurationCallback {
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040031 private static final String TAG = "ConfigurationManagerCallback";
Alexandre Savard74c1cad2012-10-24 16:39:00 -040032 private Context mContext;
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040033
Alexandre Savardbb6f1872012-11-01 17:25:55 -040034 static public final String SIGNAL_NAME = "signal-name";
35 static public final String ACCOUNTS_CHANGED = "accounts-changed";
36 static public final String ACCOUNT_STATE_CHANGED = "account-state-changed";
37
Alexandre Savard74c1cad2012-10-24 16:39:00 -040038 public ConfigurationManagerCallback(Context context) {
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040039 mContext = context;
40 }
Alexandre Savardfccd1dc2012-10-17 17:31:38 -040041
42 @Override
43 public void on_account_state_changed() {
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040044 sendAccountsChangedMessage();
45 }
46
47 private void sendAccountsChangedMessage() {
Alexandre Savardbb6f1872012-11-01 17:25:55 -040048 Log.d(TAG, "Broadcast Accounts Changed signal");
49 Intent intent = new Intent(ACCOUNTS_CHANGED);
50 intent.putExtra(SIGNAL_NAME, ACCOUNTS_CHANGED);
Alexandre Savard4f11d7a2012-10-18 13:15:36 -040051 intent.putExtra("message", "Accounts Changed");
52 LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
Alexandre Savardfccd1dc2012-10-17 17:31:38 -040053 }
Alexandre Savardbb6f1872012-11-01 17:25:55 -040054
55 private void sendAccountStateChangedMessage() {
56 Log.d(TAG, "Broadcast Account State Changed signal");
57 Intent intent = new Intent(ACCOUNT_STATE_CHANGED);
58 intent.putExtra(SIGNAL_NAME, ACCOUNTS_CHANGED);
59 intent.putExtra("message", "Account State Changed");
60 LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
61 }
Alexandre Savardfccd1dc2012-10-17 17:31:38 -040062}