Permalink
Browse files

Starting streaming https

  • Loading branch information...
1 parent d166f66 commit 16fb87ab5dd7192096a2971437fe71770a8b9079 @sileht committed Apr 20, 2011
View
@@ -7,8 +7,11 @@
<meta-data android:name="android.app.default_searchable"
android:value=".SongsActivity" />
- <activity android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar"
- android:name="MainActivity">
+ <activity android:label="@string/app_name"
+ android:theme="@android:style/Theme.NoTitleBar"
+ android:name="MainActivity"
+
+ >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
@@ -36,5 +39,5 @@
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
- <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="12"></uses-sdk>
+ <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="14"></uses-sdk>
</manifest>
View
@@ -10,4 +10,4 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
-target=android-10
+target=android-8
@@ -19,7 +19,6 @@
* | Boston, MA 02111-1307, USA. |
* +------------------------------------------------------------------------+
*/
-import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
@@ -1,36 +1,41 @@
package net.sileht.lullaby;
+
/* Copyright (c) 20010 ABAAKOUK Mehdi <theli48@gmail.com>
-*
-* +------------------------------------------------------------------------+
-* | This program is free software; you can redistribute it and/or |
-* | modify it under the terms of the GNU General Public License |
-* | as published by the Free Software Foundation; either version 2 |
-* | of the License, or (at your option) any later version. |
-* | |
-* | This program is distributed in the hope that it will be useful, |
-* | but WITHOUT ANY WARRANTY; without even the implied warranty of |
-* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
-* | GNU General Public License for more details. |
-* | |
-* | You should have received a copy of the GNU General Public License |
-* | along with this program; if not, write to the Free Software |
-* | Foundation, Inc., 59 Temple Place - Suite 330, |
-* | Boston, MA 02111-1307, USA. |
-* +------------------------------------------------------------------------+
-*/
+ *
+ * +------------------------------------------------------------------------+
+ * | This program is free software; you can redistribute it and/or |
+ * | modify it under the terms of the GNU General Public License |
+ * | as published by the Free Software Foundation; either version 2 |
+ * | of the License, or (at your option) any later version. |
+ * | |
+ * | This program is distributed in the hope that it will be useful, |
+ * | but WITHOUT ANY WARRANTY; without even the implied warranty of |
+ * | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+ * | GNU General Public License for more details. |
+ * | |
+ * | You should have received a copy of the GNU General Public License |
+ * | along with this program; if not, write to the Free Software |
+ * | Foundation, Inc., 59 Temple Place - Suite 330, |
+ * | Boston, MA 02111-1307, USA. |
+ * +------------------------------------------------------------------------+
+ */
+
import net.sileht.lullaby.backend.AmpacheBackend;
import android.app.Application;
+import android.content.SharedPreferences;
+
public final class Lullaby extends Application {
public static AmpacheBackend comm;
+ protected SharedPreferences mPrefs;
public void onCreate() {
+
try {
comm = new AmpacheBackend(this);
} catch (Exception poo) {
System.out.println("Failed launch Backend....");
}
-
}
}
@@ -57,7 +57,7 @@
static final String TAG = "LullabyMainActivity";
- private static String PREFS_NAME = "LullabyPrefs";
+ //private static String PREFS_NAME = "LullabyPrefs";
// private static final int SWIPE_MAX_OFF_PATH = 250; // initial value
private static final int SWIPE_MAX_OFF_PATH = 300;
@@ -20,10 +20,8 @@
* +------------------------------------------------------------------------+
*/
-import net.sileht.lullaby.R;
import net.sileht.lullaby.objects.Song;
import net.sileht.lullaby.player.PlayerService;
-
import android.app.ListActivity;
import android.content.ComponentName;
import android.content.Context;
@@ -21,7 +21,6 @@
*/
import java.util.ArrayList;
-import net.sileht.lullaby.R;
import net.sileht.lullaby.SongsActivity.ViewHolder;
import net.sileht.lullaby.objects.Playlist;
import android.app.Activity;
@@ -18,7 +18,7 @@
* | Boston, MA 02111-1307, USA. |
* +------------------------------------------------------------------------+
*/
-import net.sileht.lullaby.R;
+
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.util.Log;
@@ -31,6 +31,8 @@ protected void onCreate(Bundle savedInstanceState) {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
+
+
}
protected void onStop() {
@@ -39,4 +41,5 @@ protected void onStop() {
/* we want to tell other activities that we need to reload */
super.onStop();
}
+
}
@@ -21,9 +21,7 @@
*/
import java.util.ArrayList;
-import net.sileht.lullaby.R;
import net.sileht.lullaby.objects.Song;
-
import android.app.Activity;
import android.app.SearchManager;
import android.content.Context;
@@ -17,7 +17,6 @@
package net.sileht.lullaby;
-import net.sileht.lullaby.R;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
@@ -21,33 +21,44 @@
* +------------------------------------------------------------------------+
*/
-import java.net.*;
-import java.io.*;
-
-import org.xml.sax.*;
-import org.xml.sax.helpers.*;
-
+import java.io.CharArrayWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
+import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
+import javax.net.ssl.HttpsURLConnection;
+
import net.sileht.lullaby.Lullaby;
-import net.sileht.lullaby.objects.*;
+import net.sileht.lullaby.objects.Album;
+import net.sileht.lullaby.objects.Artist;
+import net.sileht.lullaby.objects.Playlist;
+import net.sileht.lullaby.objects.Song;
+import net.sileht.lullaby.objects.Tag;
+import net.sileht.lullaby.objects.ampacheObject;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+import org.xml.sax.helpers.XMLReaderFactory;
+
import android.content.Context;
import android.content.SharedPreferences;
+import android.net.SSLCertificateSocketFactory;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;
-import java.lang.Integer;
-import java.lang.Long;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.util.Date;
-
public class AmpacheBackend extends HandlerThread {
public String authToken = "";
@@ -288,6 +299,7 @@ private AmpacheHandler makeRequest(String url, String action) {
hasSettingsIncorrect = true;
return null;
} catch (IOException e) {
+ e.printStackTrace();
authToken = "";
return null;
}
@@ -307,6 +319,14 @@ private AmpacheHandler makeRequest(String url, String action) {
private Boolean makeAuthentification() {
//Log.d(TAG, "Ampache handshake request.");
+ if (prefs.getBoolean("InsecureSSL", true)){
+ HttpsURLConnection.setDefaultSSLSocketFactory(SSLCertificateSocketFactory.getInsecure(-1,null));
+ HttpsURLConnection.setDefaultHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+ } else {
+ HttpsURLConnection.setDefaultSSLSocketFactory(SSLCertificateSocketFactory.getDefault(-1,null));
+ HttpsURLConnection.setDefaultHostnameVerifier(org.apache.http.conn.ssl.SSLSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
authToken = "";
String url = getUrlFor("handshake", "", 0);
AmpacheHandler hand = makeRequest(url, "handshake");
@@ -25,8 +25,8 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Parcelable;
public class Album extends ampacheObject {
public String artist = "";
@@ -25,8 +25,8 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Parcelable;
public class Artist extends ampacheObject {
public int albums = 0;
@@ -25,8 +25,8 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Parcelable;
public class Playlist extends ampacheObject {
public String owner = "";
@@ -21,14 +21,12 @@
* +------------------------------------------------------------------------+
*/
-import android.os.Parcelable;
-import android.os.Parcel;
+import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import java.io.IOException;
-import java.lang.ClassNotFoundException;
-import net.sileht.lullaby.Lullaby;
+import android.os.Parcel;
+import android.os.Parcelable;
public class Song extends ampacheObject {
public String artist = "";
@@ -55,11 +53,6 @@ public String childString() {
return "";
}
- /* Replace the old session id with our current one */
- public String liveUrl() {
- return url.replaceAll("sid=[^&]+", "sid=" + Lullaby.comm.authToken);
- }
-
public boolean hasChildren() {
return false;
}
@@ -25,8 +25,8 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import android.os.Parcelable;
import android.os.Parcel;
+import android.os.Parcelable;
public class Tag extends ampacheObject {
public String artists = "";
@@ -22,8 +22,9 @@
*/
import java.io.Externalizable;
-import android.os.Parcelable;
+
import android.os.Parcel;
+import android.os.Parcelable;
public abstract class ampacheObject implements Parcelable, Externalizable {
Oops, something went wrong.

0 comments on commit 16fb87a

Please sign in to comment.