service working. need foreground. sms broken.
[andGMXsms.git] / src / de / ub0r / android / websms / connector / gmx / CommandReceiverGMX.java
blob0e6d164c42ea8c118f38e708c018ff50b4ba2871
1 /*
2 * Copyright (C) 2010 Felix Bechstein
3 *
4 * This file is part of WebSMS.
5 *
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU General Public License as published by the Free Software
8 * Foundation; either version 3 of the License, or (at your option) any later
9 * version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 * details.
16 * You should have received a copy of the GNU General Public License along with
17 * this program; If not, see <http://www.gnu.org/licenses/>.
19 package de.ub0r.android.websms.connector.gmx;
21 import android.content.Context;
22 import android.content.Intent;
23 import android.content.SharedPreferences;
24 import android.preference.PreferenceManager;
25 import android.util.Log;
26 import de.ub0r.android.andGMXsms.R;
27 import de.ub0r.android.websms.connector.common.CommandReceiver;
28 import de.ub0r.android.websms.connector.common.ConnectorSpec;
29 import de.ub0r.android.websms.connector.common.WebSMSException;
30 import de.ub0r.android.websms.connector.common.ConnectorSpec.SubConnectorSpec;
32 /**
33 * Receives commands coming as broadcast from WebSMS.
35 * @author flx
37 public class CommandReceiverGMX extends CommandReceiver {
38 /** Tag for debug output. */
39 private static final String TAG = "WebSMS.GMX";
41 /** Preferences intent action. */
42 private static final String PREFS_INTENT_ACTION = "de.ub0r.android."
43 + "websms.connectors.gmx.PREFS";
45 /**
46 * {@inheritDoc}
48 @Override
49 public final ConnectorSpec initSpec(final Context context) {
50 final String name = context.getString(R.string.connector_gmx_name);
51 ConnectorSpec c = new ConnectorSpec(TAG, name);
52 c.setAuthor(// .
53 context.getString(R.string.connector_gmx_author));
54 c.setBalance(null);
55 c.setPrefsIntent(PREFS_INTENT_ACTION);
56 c.setPrefsTitle(context.getString(R.string.connector_gmx_preferences));
57 c.setCapabilities(ConnectorSpec.CAPABILITIES_BOOSTRAP
58 | ConnectorSpec.CAPABILITIES_UPDATE
59 | ConnectorSpec.CAPABILITIES_SEND);
60 c.addSubConnector(TAG, c.getName(),
61 SubConnectorSpec.FEATURE_MULTIRECIPIENTS
62 | SubConnectorSpec.FEATURE_CUSTOMSENDER
63 | SubConnectorSpec.FEATURE_SENDLATER);
64 return c;
67 /**
68 * {@inheritDoc}
70 @Override
71 public final ConnectorSpec updateSpec(final Context context,
72 final ConnectorSpec connectorSpec) {
73 final SharedPreferences p = PreferenceManager
74 .getDefaultSharedPreferences(context);
75 if (p.getBoolean(Preferences.PREFS_ENABLED, false)) {
76 if (p.getString(Preferences.PREFS_MAIL, "").length() > 0
77 && p.getString(Preferences.PREFS_PASSWORD, "") // .
78 .length() > 0) {
79 connectorSpec.setReady();
80 } else {
81 connectorSpec.setStatus(ConnectorSpec.STATUS_ENABLED);
83 } else {
84 connectorSpec.setStatus(ConnectorSpec.STATUS_INACTIVE);
86 return connectorSpec;
89 /**
90 * {@inheritDoc}
92 @Override
93 protected final void doBootstrap(final Intent intent)
94 throws WebSMSException {
95 // do nothing by default
96 Log.d(TAG, "bootstrap");
99 /**
100 * {@inheritDoc}
102 @Override
103 protected final void doUpdate(final Intent intent) throws WebSMSException {
104 // do nothing by default
105 Log.d(TAG, "update");
109 * {@inheritDoc}
111 @Override
112 protected final void doSend(final Intent intent) throws WebSMSException {
113 // do nothing by default
114 Log.d(TAG, "send");