Merge lp:~trb143/openlp/android-2 into lp:openlp/android

Proposed by Tim Bentley
Status: Merged
Merged at revision: 49
Proposed branch: lp:~trb143/openlp/android-2
Merge into: lp:openlp/android
Diff against target: 1238 lines (+447/-324)
26 files modified
AndroidManifest.xml (+2/-2)
res/values/defaultValues.xml (+2/-0)
res/values/keyStrings.xml (+2/-0)
res/values/strings.xml (+9/-0)
src/org/openlp/android/OpenLP.java (+2/-2)
src/org/openlp/android/activity/DefaultActivity.java (+2/-2)
src/org/openlp/android/activity/OpenLPNavigate.java (+2/-2)
src/org/openlp/android/activity/PagerActivity.java (+2/-2)
src/org/openlp/android/activity/Search.java (+2/-2)
src/org/openlp/android/activity/SearchService.java (+2/-2)
src/org/openlp/android/activity/SearchableActivity.java (+2/-2)
src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java (+49/-12)
src/org/openlp/android/activity/preference/Preferences.java (+2/-2)
src/org/openlp/android/api/Api.java (+2/-2)
src/org/openlp/android/data/HttpReturn.java (+53/-0)
src/org/openlp/android/data/Poll.java (+2/-2)
src/org/openlp/android/data/SlideItem.java (+2/-2)
src/org/openlp/android/service/ApiCallIntent.java (+247/-263)
src/org/openlp/android/service/PingIntent.java (+2/-2)
src/org/openlp/android/utility/GroupExpandableListAdapter.java (+2/-2)
src/org/openlp/android/utility/JSONHandler.java (+2/-2)
src/org/openlp/android/utility/OpenLPController.java (+14/-3)
src/org/openlp/android/utility/OpenLPHttpClient.java (+35/-10)
src/org/openlp/android/utility/SlideAdapter.java (+2/-2)
src/org/openlp/android/utility/StringHelper.java (+2/-2)
src/org/openlp/android/utility/WebCallReturningAsyncTask.java (+2/-2)
To merge this branch: bzr merge lp:~trb143/openlp/android-2
Reviewer Review Type Date Requested Status
Johan Mynhardt Approve
Review via email: mp+157543@code.launchpad.net

Description of the change

Fix up the SSL code to work with CherryPy
Add Userid and Password to config and HTTPCLient
Fix up error handling to work better
Move display strings to translatables.

To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote :

Userid and password are saveed in config but cannot be read in client.
Not sure why this is happning any clues Johan

Revision history for this message
Johan Mynhardt (johanmynhardt) wrote :

Ok, got my stuff up and running.

@trb143: it appears to be working for me:

* if I activate user Authentication and set the username and password to something different (matching between remote and openlp) it works.
* if I set the wrong credentials on the remote, it does not authenticate correctly.

I'm not sure I understood your question 100%. Did I maybe troubleshoot the wrong scenario?

Revision history for this message
Johan Mynhardt (johanmynhardt) wrote :

Looks good to me! Although it appears that in several places the indents have been replaced with spaces. I'm not 100% sure of the convention, but most places I looked, it seems that the indents are achieved by means of tabs.

review: Needs Fixing
Revision history for this message
Tim Bentley (trb143) wrote :

No you were right.
I changed the userid and forgot to press "Activate" to enable it.
Retested and works fine.

The code layout has always been an issue as we use different editors. I use plain intelij now and it looks fine!

Revision history for this message
Johan Mynhardt (johanmynhardt) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

My guess is that somewhere tabs are used and somewhere spaces are used. Can you try to decide which you want to use, and then set the entire code base to use those?

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'AndroidManifest.xml'
--- AndroidManifest.xml 2013-03-12 19:45:46 +0000
+++ AndroidManifest.xml 2013-04-07 12:27:25 +0000
@@ -3,8 +3,8 @@
3 xmlns:android="http://schemas.android.com/apk/res/android"3 xmlns:android="http://schemas.android.com/apk/res/android"
4 android:installLocation="auto"4 android:installLocation="auto"
5 package="org.openlp.android"5 package="org.openlp.android"
6 android:versionCode="1"6 android:versionCode="7"
7 android:versionName="1.0"7 android:versionName="1.1"
8 >8 >
9 <uses-sdk android:minSdkVersion="8"/>9 <uses-sdk android:minSdkVersion="8"/>
10 <uses-permission android:name="android.permission.INTERNET"/>10 <uses-permission android:name="android.permission.INTERNET"/>
1111
=== modified file 'res/values/defaultValues.xml'
--- res/values/defaultValues.xml 2012-05-23 21:37:47 +0000
+++ res/values/defaultValues.xml 2013-04-07 12:27:25 +0000
@@ -4,6 +4,8 @@
4 <string name="portDefaultValue">4316</string>4 <string name="portDefaultValue">4316</string>
5 <string name="ssl.port.default">4317</string>5 <string name="ssl.port.default">4317</string>
6 <string name="displayTypeValue">@string/displayScreen</string>6 <string name="displayTypeValue">@string/displayScreen</string>
7 <string name="useridDefaultValue">openlp</string>
8 <string name="passwordDefaultValue">password</string>
79
8 <!-- INTEGER -->10 <!-- INTEGER -->
9 <integer name="socketTimeoutDefaultValue">3000</integer>11 <integer name="socketTimeoutDefaultValue">3000</integer>
1012
=== modified file 'res/values/keyStrings.xml'
--- res/values/keyStrings.xml 2012-05-27 21:42:19 +0000
+++ res/values/keyStrings.xml 2013-04-07 12:27:25 +0000
@@ -7,6 +7,8 @@
7 <string name="keySocketTimeout">socketTimeout</string>7 <string name="keySocketTimeout">socketTimeout</string>
8 <string name="keyHost">keyHost</string>8 <string name="keyHost">keyHost</string>
9 <string name="keyPort">keyPort</string>9 <string name="keyPort">keyPort</string>
10 <string name="key.userid">key.userid</string>
11 <string name="key.password">key.password</string>
10 <string name="keySharedPreferences">keySharedPreferences</string>12 <string name="keySharedPreferences">keySharedPreferences</string>
11 <string name="key.ssl.use">ssl.use</string>13 <string name="key.ssl.use">ssl.use</string>
12 <string name="key.profile.selected.title">key.profile.selected.title</string>14 <string name="key.profile.selected.title">key.profile.selected.title</string>
1315
=== modified file 'res/values/strings.xml'
--- res/values/strings.xml 2012-06-02 14:43:23 +0000
+++ res/values/strings.xml 2013-04-07 12:27:25 +0000
@@ -89,4 +89,13 @@
89 <string name="connection.profile.ssl.summary">Specify whether SSL should be used</string>89 <string name="connection.profile.ssl.summary">Specify whether SSL should be used</string>
90 <string name="connection.available.configurations">List of available profiles</string>90 <string name="connection.available.configurations">List of available profiles</string>
91 <string name="connection.add.by.menu">Tap to add a new profile</string>91 <string name="connection.add.by.menu">Tap to add a new profile</string>
92 <string name="connection.userid">Userid</string>
93 <string name="connection.password">Password</string>
94 <string name="httpreturn.unauthorised">Unauthorised Access, please enter valid userid and password</string>
95 <string name="apiCallIntent.search">Unexpected invalid result during Search Call.</string>
96 <string name="apiCallIntent.alert">Unexpected invalid result during Alert call.</string>
97 <string name="apiCallIntent.navigation">Unexpected invalid result during Navigation.</string>
98 <string name="apiCallIntent.list_data">Unexpected invalid result while setting list data.</string>
99 <string name="apiCallIntent.poll">Unexpected invalid result during status Poll.</string>
100 <string name="apiCallIntent.fetch">Unexpected invalid result while fetching items.</string>
92</resources>101</resources>
93102
=== modified file 'src/org/openlp/android/OpenLP.java'
--- src/org/openlp/android/OpenLP.java 2012-05-24 21:06:55 +0000
+++ src/org/openlp/android/OpenLP.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/DefaultActivity.java'
--- src/org/openlp/android/activity/DefaultActivity.java 2012-05-24 21:06:55 +0000
+++ src/org/openlp/android/activity/DefaultActivity.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/OpenLPNavigate.java'
--- src/org/openlp/android/activity/OpenLPNavigate.java 2012-05-01 18:49:58 +0000
+++ src/org/openlp/android/activity/OpenLPNavigate.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/PagerActivity.java'
--- src/org/openlp/android/activity/PagerActivity.java 2012-05-01 20:43:27 +0000
+++ src/org/openlp/android/activity/PagerActivity.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/Search.java'
--- src/org/openlp/android/activity/Search.java 2012-05-05 14:12:12 +0000
+++ src/org/openlp/android/activity/Search.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/SearchService.java'
--- src/org/openlp/android/activity/SearchService.java 2012-05-05 14:12:12 +0000
+++ src/org/openlp/android/activity/SearchService.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/SearchableActivity.java'
--- src/org/openlp/android/activity/SearchableActivity.java 2012-05-05 17:34:31 +0000
+++ src/org/openlp/android/activity/SearchableActivity.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java'
--- src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2012-07-02 05:09:23 +0000
+++ src/org/openlp/android/activity/preference/ConnectionPreferenceActivity.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
@@ -39,9 +39,6 @@
39import android.preference.PreferenceScreen;39import android.preference.PreferenceScreen;
40import android.text.InputType;40import android.text.InputType;
41import android.util.Log;41import android.util.Log;
42import android.view.Menu;
43import android.view.MenuInflater;
44import android.view.MenuItem;
45import android.widget.Toast;42import android.widget.Toast;
46import org.openlp.android.R;43import org.openlp.android.R;
4744
@@ -51,7 +48,6 @@
51 private final String PREFERENCE_DISPLAY_SERVER = "displayServer";48 private final String PREFERENCE_DISPLAY_SERVER = "displayServer";
52 private final String LOG_TAG = ConnectionPreferenceActivity.class.getName();49 private final String LOG_TAG = ConnectionPreferenceActivity.class.getName();
5350
54
55 private PreferenceScreen preferenceScreen = null;51 private PreferenceScreen preferenceScreen = null;
56 private boolean resume = true;52 private boolean resume = true;
5753
@@ -197,11 +193,24 @@
197 ? getString(R.string.hostDefaultValue) : hostValueObject.toString();193 ? getString(R.string.hostDefaultValue) : hostValueObject.toString();
198 hostConfig.hostAddress.setText(hostValue);194 hostConfig.hostAddress.setText(hostValue);
199 hostConfig.hostAddress.setSummary(hostValue);195 hostConfig.hostAddress.setSummary(hostValue);
196
200 Object portValueObject = preferences.get(hostConfig.hostPort.getKey());197 Object portValueObject = preferences.get(hostConfig.hostPort.getKey());
201 String portValue = portValueObject == null198 String portValue = portValueObject == null
202 ? getString(R.string.portDefaultValue) : portValueObject.toString();199 ? getString(R.string.portDefaultValue) : portValueObject.toString();
203 hostConfig.hostPort.setText(portValue);200 hostConfig.hostPort.setText(portValue);
204 hostConfig.hostPort.setSummary(portValue);201 hostConfig.hostPort.setSummary(portValue);
202
203 Object useridValueObject = preferences.get(hostConfig.userid.getKey());
204 String useridValue = useridValueObject == null
205 ? getString(R.string.useridDefaultValue) : useridValueObject.toString();
206 hostConfig.userid.setText(useridValue);
207 hostConfig.userid.setSummary(useridValue);
208
209 Object passwordValueObject = preferences.get(hostConfig.password.getKey());
210 String passwordValue = passwordValueObject == null
211 ? getString(R.string.passwordDefaultValue) : passwordValueObject.toString();
212 hostConfig.password.setText(passwordValue);
213 hostConfig.password.setSummary(passwordValue);
205 return hostConfig;214 return hostConfig;
206 }215 }
207216
@@ -234,6 +243,8 @@
234 preferenceCategory.addPreference(hostConfig.hostAddress);243 preferenceCategory.addPreference(hostConfig.hostAddress);
235 preferenceCategory.addPreference(hostConfig.hostPort);244 preferenceCategory.addPreference(hostConfig.hostPort);
236 preferenceCategory.addPreference(hostConfig.useSsl);245 preferenceCategory.addPreference(hostConfig.useSsl);
246 preferenceCategory.addPreference(hostConfig.userid);
247 preferenceCategory.addPreference(hostConfig.password);
237 preferenceCategory.addPreference(hostConfig.remove);248 preferenceCategory.addPreference(hostConfig.remove);
238 preferenceCategory.addPreference(hostConfig.activate);249 preferenceCategory.addPreference(hostConfig.activate);
239 return true;250 return true;
@@ -261,6 +272,8 @@
261 final EditTextPreference hostAddress;272 final EditTextPreference hostAddress;
262 final EditTextPreference hostPort;273 final EditTextPreference hostPort;
263 final CheckBoxPreference useSsl;274 final CheckBoxPreference useSsl;
275 final EditTextPreference userid;
276 final EditTextPreference password;
264 final Preference remove;277 final Preference remove;
265 final Preference activate;278 final Preference activate;
266279
@@ -282,10 +295,9 @@
282 hostAddress.getEditText().setHint(R.string.urlHint);295 hostAddress.getEditText().setHint(R.string.urlHint);
283 hostAddress.setSummary(getString(R.string.urlHint));296 hostAddress.setSummary(getString(R.string.urlHint));
284 hostAddress.setDialogTitle(getString(R.string.urlHint));297 hostAddress.setDialogTitle(getString(R.string.urlHint));
285 hostAddress.getEditText().setInputType(298 hostAddress.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_URI);
286 InputType.TYPE_TEXT_VARIATION_URI);299 hostAddress.setOnPreferenceChangeListener(onPreferenceChangeListener);
287 hostAddress.setOnPreferenceChangeListener(300
288 onPreferenceChangeListener);
289 hostPort = new EditTextPreference(ConnectionPreferenceActivity.this);301 hostPort = new EditTextPreference(ConnectionPreferenceActivity.this);
290 hostPort.setTitle(getString(R.string.port));302 hostPort.setTitle(getString(R.string.port));
291 hostPort.setKey(KEY_PREFIX + id + ".port");303 hostPort.setKey(KEY_PREFIX + id + ".port");
@@ -299,8 +311,26 @@
299 useSsl.setTitle(getString(R.string.connection_profile_ssl_use));311 useSsl.setTitle(getString(R.string.connection_profile_ssl_use));
300 useSsl.setSummary(getString(R.string.connection_profile_ssl_summary));312 useSsl.setSummary(getString(R.string.connection_profile_ssl_summary));
301 useSsl.setKey(KEY_PREFIX + id + ".usessl");313 useSsl.setKey(KEY_PREFIX + id + ".usessl");
302 // Only till SSL is added to core314
303 useSsl.setEnabled(false);315 userid = new EditTextPreference(ConnectionPreferenceActivity.this);
316 userid.setSummary(getString(R.string.connection_userid));
317 userid.getEditText().setHint(getString(R.string.connection_userid));
318 userid.setTitle(getString(R.string.connection_userid));
319 userid.setKey(KEY_PREFIX + id + ".userid");
320 userid.setDefaultValue(getString(R.string.useridDefaultValue));
321 userid.setSummary(getString(R.string.useridDefaultValue));
322 userid.setDialogTitle(getString(R.string.connection_userid));
323 userid.setOnPreferenceChangeListener(onPreferenceChangeListener);
324
325 password = new EditTextPreference(ConnectionPreferenceActivity.this);
326 password.setSummary(getString(R.string.connection_password));
327 password.getEditText().setHint(getString(R.string.connection_password));
328 password.setTitle(getString(R.string.connection_password));
329 password.setKey(KEY_PREFIX + id + ".password");
330 password.setDefaultValue(getString(R.string.passwordDefaultValue));
331 password.setSummary(getString(R.string.passwordDefaultValue));
332 password.setDialogTitle(getString(R.string.connection_password));
333 password.setOnPreferenceChangeListener(onPreferenceChangeListener);
304334
305 remove = new Preference(ConnectionPreferenceActivity.this);335 remove = new Preference(ConnectionPreferenceActivity.this);
306 remove.setTitle(getString(R.string.connection_profile_remove));336 remove.setTitle(getString(R.string.connection_profile_remove));
@@ -314,6 +344,8 @@
314 editor.remove(hostPort.getKey());344 editor.remove(hostPort.getKey());
315 editor.remove(title.getKey());345 editor.remove(title.getKey());
316 editor.remove(useSsl.getKey());346 editor.remove(useSsl.getKey());
347 editor.remove(userid.getKey());
348 editor.remove(password.getKey());
317 editor.commit();349 editor.commit();
318 ConnectionPreferenceActivity.this.onBackPressed();350 ConnectionPreferenceActivity.this.onBackPressed();
319 return false;351 return false;
@@ -336,6 +368,11 @@
336 editor.putString(getString(R.string.keyPort), port);368 editor.putString(getString(R.string.keyPort), port);
337 Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false);369 Boolean bUseSsl = preferences.getBoolean(useSsl.getKey(), false);
338 editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl);370 editor.putBoolean(getString(R.string.key_ssl_use), bUseSsl);
371 String suserid = preferences.getString(userid.getKey(), getString(R.string.useridDefaultValue));
372 editor.putString(getString(R.string.key_userid), suserid);
373 String spassword = preferences.getString(password.getKey(),
374 getString(R.string.passwordDefaultValue));
375 editor.putString(getString(R.string.key_password), spassword);
339376
340 editor.putString(377 editor.putString(
341 getString(R.string.key_profile_selected_title),378 getString(R.string.key_profile_selected_title),
342379
=== modified file 'src/org/openlp/android/activity/preference/Preferences.java'
--- src/org/openlp/android/activity/preference/Preferences.java 2012-05-31 20:07:41 +0000
+++ src/org/openlp/android/activity/preference/Preferences.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/api/Api.java'
--- src/org/openlp/android/api/Api.java 2012-05-01 18:49:58 +0000
+++ src/org/openlp/android/api/Api.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== added file 'src/org/openlp/android/data/HttpReturn.java'
--- src/org/openlp/android/data/HttpReturn.java 1970-01-01 00:00:00 +0000
+++ src/org/openlp/android/data/HttpReturn.java 2013-04-07 12:27:25 +0000
@@ -0,0 +1,53 @@
1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *
9 * under the terms of the GNU General Public License as published by the Free *
10 * Software Foundation; version 2 of the License. *
11 * *
12 * This program is distributed in the hope that it will be useful, but WITHOUT *
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
15 * more details. *
16 * *
17 * You should have received a copy of the GNU General Public License along *
18 * with this program; if not, write to the Free Software Foundation, Inc., 59 *
19 * Temple Place, Suite 330, Boston, MA 02111-1307 USA *
20 *******************************************************************************/
21package org.openlp.android.data;
22
23import android.content.Context;
24import org.openlp.android.R;
25
26public class HttpReturn {
27 private int return_code = 0;
28 private String data = null;
29 private Context context;
30
31 public HttpReturn(int return_code, String data, Context context) {
32 this.return_code = return_code;
33 this.data = data;
34 this.context = context;
35 }
36
37 public String getData() {
38 return this.data;
39 }
40
41 public boolean isError() {
42 return return_code != 0;
43 }
44
45 public String getErrorMessage(String message) {
46 return return_code == 401 ? this.context.getString(R.string.httpreturn_unauthorised) : message;
47 }
48
49 @Override
50 public String toString() {
51 return "HttpReturn{" + "data='" + data + '\'' + ", return code=" + return_code + '}';
52 }
53}
054
=== modified file 'src/org/openlp/android/data/Poll.java'
--- src/org/openlp/android/data/Poll.java 2012-05-05 17:29:57 +0000
+++ src/org/openlp/android/data/Poll.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/data/SlideItem.java'
--- src/org/openlp/android/data/SlideItem.java 2012-03-04 17:20:44 +0000
+++ src/org/openlp/android/data/SlideItem.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/service/ApiCallIntent.java'
--- src/org/openlp/android/service/ApiCallIntent.java 2012-05-12 19:40:12 +0000
+++ src/org/openlp/android/service/ApiCallIntent.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
@@ -23,9 +23,11 @@
23import android.app.IntentService;23import android.app.IntentService;
24import android.content.Intent;24import android.content.Intent;
25import android.util.Log;25import android.util.Log;
26import org.openlp.android.R;
26import org.openlp.android.activity.Search;27import org.openlp.android.activity.Search;
27import org.openlp.android.activity.SearchService;28import org.openlp.android.activity.SearchService;
28import org.openlp.android.api.Api;29import org.openlp.android.api.Api;
30import org.openlp.android.data.HttpReturn;
29import org.openlp.android.utility.JSONHandler;31import org.openlp.android.utility.JSONHandler;
30import org.openlp.android.utility.OpenLPHttpClient;32import org.openlp.android.utility.OpenLPHttpClient;
3133
@@ -38,265 +40,247 @@
38 * from an OpenLP server.40 * from an OpenLP server.
39 */41 */
40public class ApiCallIntent extends IntentService implements SearchService {42public class ApiCallIntent extends IntentService implements SearchService {
41 public static final String API_CALL_RECEIVE =43 public static final String API_CALL_RECEIVE =
42 ApiCallIntent.class.getName().concat(".Receive");44 ApiCallIntent.class.getName().concat(".Receive");
4345
44 public ApiCallIntent() {46 public ApiCallIntent() {
45 super(ApiCallIntent.class.getName());47 super(ApiCallIntent.class.getName());
46 }48 }
4749
48 /**50 /**
49 * apiPart is one of the strings set in {@link org.openlp.android.api.Api}51 * apiPart is one of the strings set in {@link org.openlp.android.api.Api}
50 * apiCall is when the requested apiPart takes input52 * apiCall is when the requested apiPart takes input
51 *53 *
52 * @param intent The intent requesting data54 * @param intent The intent requesting data
53 */55 */
54 @Override56 @Override
55 protected void onHandleIntent(Intent intent) {57 protected void onHandleIntent(Intent intent) {
56 Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent);58 Log.v(LOG_TAG, "Executing WebCallIntent from: " + intent);
57 Intent apiCallReceiverIntent = null;59 Intent apiCallReceiverIntent = null;
5860
59 try {61 try {
60 if (intent.hasExtra(Api.ALERT)) {62 if (intent.hasExtra(Api.ALERT)) {
61 String alertData = JSONHandler.createRequestJSON("text",63 String alertData = JSONHandler.createRequestJSON("text",
62 intent.getStringExtra(Api.ALERT));64 intent.getStringExtra(Api.ALERT));
63 apiCallReceiverIntent = executeAlert(alertData);65 apiCallReceiverIntent = executeAlert(alertData);
64 }66 } else if (intent.hasExtra(Api.SERVICE_BASE)) {
65 else if (intent.hasExtra(Api.SERVICE_BASE)) {67 apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE,
66 apiCallReceiverIntent = executeNavigation(Api.SERVICE_BASE,68 intent.getStringExtra(Api.SERVICE_BASE));
67 intent.getStringExtra(Api.SERVICE_BASE));69 } else if (intent.hasExtra(Api.LIVE_BASE)) {
68 }70 apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE,
69 else if (intent.hasExtra(Api.LIVE_BASE)) {71 intent.getStringExtra(Api.LIVE_BASE));
70 apiCallReceiverIntent = executeNavigation(Api.LIVE_BASE,72 } else if (intent.hasExtra(Api.DISPLAY_BASE)) {
71 intent.getStringExtra(Api.LIVE_BASE));73 apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE,
72 }74 intent.getStringExtra(Api.DISPLAY_BASE));
73 else if (intent.hasExtra(Api.DISPLAY_BASE)) {75 } else if (intent.hasExtra(Api.POLL_STATUS)) {
74 apiCallReceiverIntent = executeNavigation(Api.DISPLAY_BASE,76 apiCallReceiverIntent = executePoll();
75 intent.getStringExtra(Api.DISPLAY_BASE));77 } else if (intent.hasExtra(Api.LIVE_TEXT)) {
76 }78 apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT);
77 else if (intent.hasExtra(Api.POLL_STATUS)) {79 } else if (intent.hasExtra(Api.SERVICE_LIST)) {
78 apiCallReceiverIntent = executePoll();80 apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST);
79 }81 } else if (intent.hasExtra(Api.LIVE_SET)) {
80 else if (intent.hasExtra(Api.LIVE_TEXT)) {82 apiCallReceiverIntent = executeSetData(Api.LIVE_SET,
81 apiCallReceiverIntent = executeItemFetch(Api.LIVE_TEXT);83 intent.getIntExtra(Api.LIVE_SET, 0));
82 }84 } else if (intent.hasExtra(Api.SERVICE_SET)) {
83 else if (intent.hasExtra(Api.SERVICE_LIST)) {85 apiCallReceiverIntent = executeSetData(Api.SERVICE_SET,
84 apiCallReceiverIntent = executeItemFetch(Api.SERVICE_LIST);86 intent.getIntExtra(Api.SERVICE_SET, 0));
85 }87 }
86 else if (intent.hasExtra(Api.LIVE_SET)) {88
87 apiCallReceiverIntent = executeSetData(Api.LIVE_SET,89 if (apiCallReceiverIntent == null) {
88 intent.getIntExtra(Api.LIVE_SET, 0));90
89 }91 // match wildcard intent keys
90 else if (intent.hasExtra(Api.SERVICE_SET)) {92 for (String key : intent.getExtras().keySet()) {
91 apiCallReceiverIntent = executeSetData(Api.SERVICE_SET,93 if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") ||
92 intent.getIntExtra(Api.SERVICE_SET, 0));94 key.matches("/api/\\w+\\W?\\w+/add\\?data=")) {
93 }95 apiCallReceiverIntent = getSearchPluginIntent(key,
9496 intent.getStringExtra(key));
95 if (apiCallReceiverIntent == null) {97 break;
9698 }
97 // match wildcard intent keys99 }
98 for (String key : intent.getExtras().keySet()) {100
99 if (key.matches("/api/\\w+\\W?\\w+/live\\?data=") ||101 if (apiCallReceiverIntent == null) {
100 key.matches("/api/\\w+\\W?\\w+/add\\?data=")) {102 String nyiMessage =
101 apiCallReceiverIntent = getSearchPluginIntent(key,103 "Not yet Implemented for calls with these extras: " +
102 intent.getStringExtra(key));104 intent.getExtras();
103 break;105 Log.w(LOG_TAG, nyiMessage);
104 }106 apiCallReceiverIntent = new WebCallReceiverIntent(
105 }107 new WebCallReceiverIntentError(nyiMessage));
106108 }
107 if (apiCallReceiverIntent == null) {109 }
108 String nyiMessage =110 } catch (Exception e) {
109 "Not yet Implemented for calls with these extras: " +111 Log.e(LOG_TAG, e.toString());
110 intent.getExtras();112 apiCallReceiverIntent = new WebCallReceiverIntent(
111 Log.w(LOG_TAG, nyiMessage);113 new WebCallReceiverIntentError(String
112 apiCallReceiverIntent = new WebCallReceiverIntent(114 .format("%s: %s", e.getClass().getSimpleName(),
113 new WebCallReceiverIntentError(nyiMessage));115 e.getMessage())));
114 }116 Log.w(LOG_TAG,
115 }117 "Sending Broadcast with error: " + apiCallReceiverIntent);
116 }118 }
117 catch (Exception e) {119 sendBroadcast(apiCallReceiverIntent);
118 Log.e(LOG_TAG, e.toString());120 }
119 apiCallReceiverIntent = new WebCallReceiverIntent(121
120 new WebCallReceiverIntentError(String122 @Override
121 .format("%s: %s", e.getClass().getSimpleName(),123 public Intent getSearchPluginIntent(String apiBase, String apiData)
122 e.getMessage())));124 throws JSONHandler.JSONHandlerException, IOException,
123 Log.w(LOG_TAG,125 URISyntaxException {
124 "Sending Broadcast with error: " + apiCallReceiverIntent);126 Intent apiCallSearchReceiverIntent =
125 }127 new WebCallReceiverIntent(apiBase, apiData);
126 sendBroadcast(apiCallReceiverIntent);128 apiCallSearchReceiverIntent
127 }129 .setAction(Search.ACTION); //override default receiver action
128130 String jsonRequest = JSONHandler.createRequestJSON("id", apiData);
129 @Override131
130 public Intent getSearchPluginIntent(String apiBase, String apiData)132 OpenLPHttpClient httpClient =
131 throws JSONHandler.JSONHandlerException, IOException,133 getApiConfiguredClient(apiBase, jsonRequest);
132 URISyntaxException {134 HttpReturn result = httpClient.handleExecute();
133 Intent apiCallSearchReceiverIntent =135
134 new WebCallReceiverIntent(apiBase, apiData);136 if (result.isError()) {
135 apiCallSearchReceiverIntent137 apiCallSearchReceiverIntent = new WebCallReceiverIntent(
136 .setAction(Search.ACTION); //override default receiver action138 new WebCallReceiverIntentError(result.getErrorMessage(
137 String jsonRequest = JSONHandler.createRequestJSON("id", apiData);139 String.valueOf(R.string.apiCallIntent_search))));
138140 apiCallSearchReceiverIntent.setAction(Search.ACTION);
139 OpenLPHttpClient httpClient =141 } else {
140 getApiConfiguredClient(apiBase, jsonRequest);142 Log.d(LOG_TAG, "searchPluginCall result: " + result.getData());
141 String result = httpClient.handleExecute();143 }
142144
143 if (result == null) {145 return apiCallSearchReceiverIntent;
144 apiCallSearchReceiverIntent = new WebCallReceiverIntent(146 }
145 new WebCallReceiverIntentError(147
146 "Unexpected null result during searchPluginCall."));148 private Intent executeAlert(String alertData)
147 apiCallSearchReceiverIntent.setAction(Search.ACTION);149 throws IOException, URISyntaxException {
148 }150 Intent apiCallReceiverIntent =
149 else {151 new WebCallReceiverIntent(Api.ALERT, alertData);
150 Log.d(LOG_TAG, "searchPluginCall result: " + result);152 OpenLPHttpClient httpClient =
151 }153 getApiConfiguredClient(Api.ALERT, alertData);
152154
153 return apiCallSearchReceiverIntent;155 HttpReturn result = httpClient.handleExecute();
154 }156 if (result.isError()) {
155157 apiCallReceiverIntent = new WebCallReceiverIntent(
156 private Intent executeAlert(String alertData)158 new WebCallReceiverIntentError(result.getErrorMessage(
157 throws IOException, URISyntaxException {159 String.valueOf(R.string.apiCallIntent_alert))));
158 Intent apiCallReceiverIntent =160 } else {
159 new WebCallReceiverIntent(Api.ALERT, alertData);161 Log.d(LOG_TAG, "Alert result: " + result.getData());
160 OpenLPHttpClient httpClient =162 }
161 getApiConfiguredClient(Api.ALERT, alertData);163
162164 return apiCallReceiverIntent;
163 String result = httpClient.handleExecute();165 }
164 if (result == null) {166
165 apiCallReceiverIntent = new WebCallReceiverIntent(167 private Intent executeNavigation(final String apiBase, final String apiData)
166 new WebCallReceiverIntentError(168 throws IOException, URISyntaxException {
167 "Unexpected null result during alert call."));169 Intent apiCallReceiverIntent =
168 }170 new WebCallReceiverIntent(apiBase, apiData);
169 else {171 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData);
170 Log.d(LOG_TAG, "Alert result: " + result);172
171 }173 HttpReturn result = httpClient.handleExecute();
172174 if (result.isError()) {
173 return apiCallReceiverIntent;175 apiCallReceiverIntent = new WebCallReceiverIntent(
174 }176 new WebCallReceiverIntentError(result.getErrorMessage(
175177 String.valueOf(R.string.apiCallIntent_navigation))));
176 private Intent executeNavigation(final String apiBase, final String apiData)178 } else {
177 throws IOException, URISyntaxException {179 Log.d(LOG_TAG, "Navigation result: " + result.getData());
178 Intent apiCallReceiverIntent =180 }
179 new WebCallReceiverIntent(apiBase, apiData);181
180 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, apiData);182 return apiCallReceiverIntent;
181183 }
182 String result = httpClient.handleExecute();184
183 if (result == null) {185 private Intent executeSetData(String apiBase, int position)
184 apiCallReceiverIntent = new WebCallReceiverIntent(186 throws JSONHandler.JSONHandlerException, IOException,
185 new WebCallReceiverIntentError(187 URISyntaxException {
186 "Unexpected null result during navigation."));188 String request = JSONHandler.createRequestJSON("id", Integer.toString(position));
187 }189 Intent apiCallreceiverIntent = new WebCallReceiverIntent(apiBase, request);
188 else {190 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request);
189 Log.d(LOG_TAG, "Navigation result: " + result);191
190 }192 HttpReturn result = httpClient.handleExecute();
191193 if (result.isError()) {
192 return apiCallReceiverIntent;194 String message = String.format(
193 }195 "Unexpected null result while setting list data. apiBase(%s), position(%s)",
194196 apiBase, position);
195 private Intent executeSetData(String apiBase, int position)197 Log.e(LOG_TAG, message);
196 throws JSONHandler.JSONHandlerException, IOException,198 apiCallreceiverIntent = new WebCallReceiverIntent(
197 URISyntaxException {199 new WebCallReceiverIntentError(result.getErrorMessage(
198 String request =200 String.valueOf(R.string.apiCallIntent_list_data))));
199 JSONHandler.createRequestJSON("id", Integer.toString(position));201 } else {
200 Intent apiCallreceiverIntent =202 Log.d(LOG_TAG, "setData result: " + result.getData());
201 new WebCallReceiverIntent(apiBase, request);203 }
202 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase, request);204
203205 return apiCallreceiverIntent;
204 String result = httpClient.handleExecute();206 }
205 if (result == null) {207
206 String message = String.format(208 private Intent executePoll() throws IOException, URISyntaxException,
207 "Unexpected null result while setting list data. apiBase(%s), position(%s)",209 JSONHandler.JSONHandlerException {
208 apiBase, position);210 Intent apiCallReceiverIntent = new WebCallReceiverIntent(Api.POLL_STATUS, "");
209 Log.e(LOG_TAG, message);211 OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS);
210 apiCallreceiverIntent = new WebCallReceiverIntent(212
211 new WebCallReceiverIntentError(213 HttpReturn pollJson = httpClient.handleExecute();
212 "Unexpected null result while setting list data."));214 if (pollJson.isError()) {
213 }215 apiCallReceiverIntent = new WebCallReceiverIntent(
214 else {216 new WebCallReceiverIntentError(pollJson.getErrorMessage(
215 Log.d(LOG_TAG, "setData result: " + result);217 String.valueOf(R.string.apiCallIntent_poll))));
216 }218 } else {
217219 Log.d(LOG_TAG, "Poll result: " + pollJson);
218 return apiCallreceiverIntent;220 apiCallReceiverIntent.putExtra("pollJson", pollJson.getData());
219 }221 }
220222 return apiCallReceiverIntent;
221 private Intent executePoll() throws IOException, URISyntaxException,223 }
222 JSONHandler.JSONHandlerException {224
223 Intent apiCallReceiverIntent =225 private Intent executeItemFetch(final String apiBase)
224 new WebCallReceiverIntent(Api.POLL_STATUS, "");226 throws IOException, URISyntaxException {
225 OpenLPHttpClient httpClient = getApiConfiguredClient(Api.POLL_STATUS);227 Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, "");
226228 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase);
227 String pollJson = httpClient.handleExecute();229
228 if (pollJson == null) {230 HttpReturn itemsJson = httpClient.handleExecute();
229 apiCallReceiverIntent = new WebCallReceiverIntent(231 if (itemsJson.isError()) {
230 new WebCallReceiverIntentError(232 apiCallReceiverIntent = new WebCallReceiverIntent(
231 "Unexpected null result during status poll."));233 new WebCallReceiverIntentError(
232 }234 itemsJson.getErrorMessage(String.valueOf(R.string.apiCallIntent_fetch))));
233 else {235 } else {
234 Log.d(LOG_TAG, "Poll result: " + pollJson);236 Log.d(LOG_TAG, "Items JSON: " + itemsJson);
235 apiCallReceiverIntent.putExtra("pollJson", pollJson);237 apiCallReceiverIntent.putExtra("itemsJson", itemsJson.getData());
236 }238 }
237 return apiCallReceiverIntent;239 return apiCallReceiverIntent;
238 }240 }
239241
240 private Intent executeItemFetch(final String apiBase)242 private OpenLPHttpClient getApiConfiguredClient(String apiBase,
241 throws IOException, URISyntaxException {243 String partData) throws MalformedURLException, URISyntaxException {
242 Intent apiCallReceiverIntent = new WebCallReceiverIntent(apiBase, "");244 OpenLPHttpClient httpClient =
243 OpenLPHttpClient httpClient = getApiConfiguredClient(apiBase);245 new OpenLPHttpClient(getApplicationContext());
244246 httpClient.setUrl(String.format("%s%s", apiBase, partData));
245 String itemsJson = httpClient.handleExecute();247 return httpClient;
246 if (itemsJson == null) {248 }
247 apiCallReceiverIntent = new WebCallReceiverIntent(249
248 new WebCallReceiverIntentError(250 private OpenLPHttpClient getApiConfiguredClient(String apiBase)
249 "Unexpected null result while fetching itmes."));251 throws MalformedURLException, URISyntaxException {
250 }252 return getApiConfiguredClient(apiBase, "");
251 else {253 }
252 Log.d(LOG_TAG, "Items JSON: " + itemsJson);254
253 apiCallReceiverIntent.putExtra("itemsJson", itemsJson);255 private final String LOG_TAG = ApiCallIntent.class.getName();
254 }256
255 return apiCallReceiverIntent;257 class WebCallReceiverIntent extends Intent {
256 }258 WebCallReceiverIntent() {
257259 setDefaults();
258 private OpenLPHttpClient getApiConfiguredClient(String apiBase,260 }
259 String partData) throws MalformedURLException, URISyntaxException {261
260 OpenLPHttpClient httpClient =262 WebCallReceiverIntent(WebCallReceiverIntentError error) {
261 new OpenLPHttpClient(getApplicationContext());263 setDefaults();
262 httpClient.setUrl(String.format("%s%s", apiBase, partData));264 WebCallReceiverIntent.this.putExtra("error", error.message);
263 return httpClient;265 }
264 }266
265267 WebCallReceiverIntent(String apiBase, String apiData) {
266 private OpenLPHttpClient getApiConfiguredClient(String apiBase)268 setDefaults();
267 throws MalformedURLException, URISyntaxException {269 WebCallReceiverIntent.this.putExtra("apiBase", apiBase);
268 return getApiConfiguredClient(apiBase, "");270 WebCallReceiverIntent.this.putExtra("apiData", apiData);
269 }271 }
270272
271 private final String LOG_TAG = ApiCallIntent.class.getName();273 private void setDefaults() {
272274 WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE);
273 class WebCallReceiverIntent extends Intent {275 WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT);
274 WebCallReceiverIntent() {276 }
275 setDefaults();277 }
276 }278
277279 class WebCallReceiverIntentError {
278 WebCallReceiverIntent(WebCallReceiverIntentError error) {280 final String message;
279 setDefaults();281
280 WebCallReceiverIntent.this.putExtra("error", error.message);282 WebCallReceiverIntentError(String error) {
281 }283 this.message = error;
282284 }
283 WebCallReceiverIntent(String apiBase, String apiData) {285 }
284 setDefaults();
285 WebCallReceiverIntent.this.putExtra("apiBase", apiBase);
286 WebCallReceiverIntent.this.putExtra("apiData", apiData);
287 }
288
289 private void setDefaults() {
290 WebCallReceiverIntent.this.setAction(API_CALL_RECEIVE);
291 WebCallReceiverIntent.this.addCategory(Intent.CATEGORY_DEFAULT);
292 }
293 }
294
295 class WebCallReceiverIntentError {
296 final String message;
297
298 WebCallReceiverIntentError(String error) {
299 this.message = error;
300 }
301 }
302}286}
303287
=== modified file 'src/org/openlp/android/service/PingIntent.java'
--- src/org/openlp/android/service/PingIntent.java 2012-05-06 15:53:56 +0000
+++ src/org/openlp/android/service/PingIntent.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/utility/GroupExpandableListAdapter.java'
--- src/org/openlp/android/utility/GroupExpandableListAdapter.java 2012-03-04 17:20:44 +0000
+++ src/org/openlp/android/utility/GroupExpandableListAdapter.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/utility/JSONHandler.java'
--- src/org/openlp/android/utility/JSONHandler.java 2012-05-05 17:34:31 +0000
+++ src/org/openlp/android/utility/JSONHandler.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/utility/OpenLPController.java'
--- src/org/openlp/android/utility/OpenLPController.java 2012-07-31 17:13:08 +0000
+++ src/org/openlp/android/utility/OpenLPController.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
@@ -26,14 +26,17 @@
26import android.content.Intent;26import android.content.Intent;
27import android.content.IntentFilter;27import android.content.IntentFilter;
28import android.content.SharedPreferences;28import android.content.SharedPreferences;
29import android.net.http.SslError;
29import android.support.v4.view.PagerAdapter;30import android.support.v4.view.PagerAdapter;
30import android.support.v4.view.ViewPager;31import android.support.v4.view.ViewPager;
31import android.util.Log;32import android.util.Log;
32import android.view.LayoutInflater;33import android.view.LayoutInflater;
33import android.view.View;34import android.view.View;
34import android.view.ViewGroup;35import android.view.ViewGroup;
36import android.webkit.SslErrorHandler;
35import android.webkit.WebSettings;37import android.webkit.WebSettings;
36import android.webkit.WebView;38import android.webkit.WebView;
39import android.webkit.WebViewClient;
37import android.widget.AdapterView;40import android.widget.AdapterView;
38import android.widget.Button;41import android.widget.Button;
39import android.widget.EditText;42import android.widget.EditText;
@@ -360,6 +363,15 @@
360363
361 private WebView getWebViewFromView(View view) {364 private WebView getWebViewFromView(View view) {
362 WebView myWebView = (WebView) view.findViewById(R.id.stageview);365 WebView myWebView = (WebView) view.findViewById(R.id.stageview);
366 /*
367 * Handle SSL self signed certificates and refresh the screen if the certificate
368 * page appears.
369 */
370 myWebView.setWebViewClient(new WebViewClient() {
371 public void onReceivedSslError (WebView view, SslErrorHandler handler, SslError error) {
372 handler.proceed() ;
373 }
374 } );
363 WebSettings webSettings = myWebView.getSettings();375 WebSettings webSettings = myWebView.getSettings();
364 webSettings.setJavaScriptEnabled(true);376 webSettings.setJavaScriptEnabled(true);
365 webSettings.setBuiltInZoomControls(true);377 webSettings.setBuiltInZoomControls(true);
@@ -369,7 +381,6 @@
369 myWebView.setScrollbarFadingEnabled(true);381 myWebView.setScrollbarFadingEnabled(true);
370382
371 myWebView.loadUrl(getUrlBase());383 myWebView.loadUrl(getUrlBase());
372
373 return myWebView;384 return myWebView;
374 }385 }
375386
376387
=== modified file 'src/org/openlp/android/utility/OpenLPHttpClient.java'
--- src/org/openlp/android/utility/OpenLPHttpClient.java 2012-05-23 21:37:47 +0000
+++ src/org/openlp/android/utility/OpenLPHttpClient.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
@@ -47,6 +47,9 @@
47import android.util.Log;47import android.util.Log;
48import org.apache.http.HttpEntity;48import org.apache.http.HttpEntity;
49import org.apache.http.HttpResponse;49import org.apache.http.HttpResponse;
50import org.apache.http.auth.AuthScope;
51import org.apache.http.auth.Credentials;
52import org.apache.http.auth.UsernamePasswordCredentials;
50import org.apache.http.client.methods.HttpGet;53import org.apache.http.client.methods.HttpGet;
51import org.apache.http.conn.scheme.PlainSocketFactory;54import org.apache.http.conn.scheme.PlainSocketFactory;
52import org.apache.http.conn.scheme.Scheme;55import org.apache.http.conn.scheme.Scheme;
@@ -57,11 +60,11 @@
57import org.apache.http.params.HttpConnectionParams;60import org.apache.http.params.HttpConnectionParams;
58import org.apache.http.params.HttpParams;61import org.apache.http.params.HttpParams;
59import org.openlp.android.R;62import org.openlp.android.R;
63import org.openlp.android.data.HttpReturn;
6064
61/**65/**
62 * Personalised HttpClient to be used throughout OpenLP with customisable66 * Personalised HttpClient to be used throughout OpenLP with customisable
63 * parameters.67 * parameters.
64 * todo: accomodate https
65 */68 */
66public class OpenLPHttpClient extends DefaultHttpClient {69public class OpenLPHttpClient extends DefaultHttpClient {
6770
@@ -69,6 +72,7 @@
69 private URL url;72 private URL url;
70 private final String urlBase;73 private final String urlBase;
71 private SSLSocketFactory sslSocketFactory;74 private SSLSocketFactory sslSocketFactory;
75 private Context context;
7276
73 public OpenLPHttpClient(Context context) {77 public OpenLPHttpClient(Context context) {
74 SharedPreferences preferences = context.getSharedPreferences(78 SharedPreferences preferences = context.getSharedPreferences(
@@ -76,6 +80,8 @@
76 Context.MODE_PRIVATE);80 Context.MODE_PRIVATE);
77 HttpParams httpParams = new BasicHttpParams();81 HttpParams httpParams = new BasicHttpParams();
7882
83 this.context = context;
84
79 Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false);85 Boolean useSsl = preferences.getBoolean(context.getString(R.string.key_ssl_use), false);
8086
81 String port = preferences.getString(87 String port = preferences.getString(
@@ -83,7 +89,6 @@
83 context.getString(R.string.portDefaultValue)89 context.getString(R.string.portDefaultValue)
84 );90 );
8591
86
87 SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry();92 SchemeRegistry schemeRegistry = getConnectionManager().getSchemeRegistry();
88 if (!useSsl) {93 if (!useSsl) {
89 schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port)));94 schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), Integer.valueOf(port)));
@@ -107,7 +112,23 @@
107112
108 }113 }
109114
110 urlBase = String.format("http%s://%s:%s",115 String userid = preferences.getString(
116 context.getString(R.string.key_userid),
117 context.getString(R.string.useridDefaultValue)
118 );
119
120
121 String password = preferences.getString(
122 context.getString(R.string.key_password),
123 context.getString(R.string.passwordDefaultValue)
124 );
125
126 Log.d(LOG_TAG, "Credentials set to " + userid + " : " + password);
127
128 Credentials creds = new UsernamePasswordCredentials(userid, password);
129 getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), creds);
130
131 urlBase = String.format("http%s://%s:%s",
111 useSsl ? "s" : "",132 useSsl ? "s" : "",
112 preferences.getString(133 preferences.getString(
113 context.getString(R.string.keyHost),134 context.getString(R.string.keyHost),
@@ -158,9 +179,11 @@
158 return super.execute(httpGet);179 return super.execute(httpGet);
159 }180 }
160181
161 public String handleExecute() throws IOException {182 public HttpReturn handleExecute() throws IOException {
162 HttpResponse response = this.execute();183 HttpResponse response = this.execute();
163184
185 Log.d(LOG_TAG, "Http response code " + String.valueOf(response.getStatusLine().getStatusCode()));
186
164 if (response.getStatusLine().getStatusCode() == 200) {187 if (response.getStatusLine().getStatusCode() == 200) {
165 BufferedReader bufferedReader;188 BufferedReader bufferedReader;
166 HttpEntity entity = response.getEntity();189 HttpEntity entity = response.getEntity();
@@ -175,10 +198,10 @@
175 line = bufferedReader.readLine();198 line = bufferedReader.readLine();
176 }199 }
177 bufferedReader.close();200 bufferedReader.close();
178 return stringBuilder.toString();201 return new HttpReturn(0, stringBuilder.toString(), this.context);
179 }202 }
180 }203 }
181 return null;204 return new HttpReturn(response.getStatusLine().getStatusCode() , null, this.context);
182 }205 }
183206
184 public HttpEntity handleAndReturnEntity() throws IOException {207 public HttpEntity handleAndReturnEntity() throws IOException {
@@ -190,7 +213,8 @@
190 return null;213 return null;
191 }214 }
192215
193 private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException, IOException, CertificateException {216 private void initSsl() throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException,
217 UnrecoverableKeyException, IOException, CertificateException {
194 final SSLContext sslContext = SSLContext.getInstance("TLS");218 final SSLContext sslContext = SSLContext.getInstance("TLS");
195 X509TrustManager trustManager = new X509TrustManager() {219 X509TrustManager trustManager = new X509TrustManager() {
196 @Override220 @Override
@@ -217,7 +241,8 @@
217 }241 }
218242
219 @Override243 @Override
220 public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException, UnknownHostException {244 public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException,
245 UnknownHostException {
221 return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);246 return sslContext.getSocketFactory().createSocket(socket, host, port, autoClose);
222 }247 }
223 };248 };
224249
=== modified file 'src/org/openlp/android/utility/SlideAdapter.java'
--- src/org/openlp/android/utility/SlideAdapter.java 2012-05-05 17:34:31 +0000
+++ src/org/openlp/android/utility/SlideAdapter.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/utility/StringHelper.java'
--- src/org/openlp/android/utility/StringHelper.java 2012-03-04 10:56:34 +0000
+++ src/org/openlp/android/utility/StringHelper.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *
99
=== modified file 'src/org/openlp/android/utility/WebCallReturningAsyncTask.java'
--- src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2012-05-24 21:06:55 +0000
+++ src/org/openlp/android/utility/WebCallReturningAsyncTask.java 2013-04-07 12:27:25 +0000
@@ -1,8 +1,8 @@
1/******************************************************************************1/******************************************************************************
2 * OpenLP - Open Source Lyrics Projection *2 * OpenLP - Open Source Lyrics Projection *
3 * --------------------------------------------------------------------------- *3 * --------------------------------------------------------------------------- *
4 * Copyright (c) 2011-2012 Raoul Snyman *4 * Copyright (c) 2011-2013 Raoul Snyman *
5 * Portions copyright (c) 2011-2012 Tim Bentley, Johan Mynhardt, Samuel *5 * Portions copyright (c) 2011-2013 Tim Bentley, Johan Mynhardt, Samuel *
6 * Sjöbergsson *6 * Sjöbergsson *
7 * --------------------------------------------------------------------------- *7 * --------------------------------------------------------------------------- *
8 * This program is free software; you can redistribute it and/or modify it *8 * This program is free software; you can redistribute it and/or modify it *

Subscribers

People subscribed via source and target branches