Showing posts with label PirateBox. Show all posts
Showing posts with label PirateBox. Show all posts

Tuesday, August 26, 2014

PirateBox for Android - Android Wear

Starting with version 0.53 PirateBox for Android supports Android Wear notifications for uploads and shout messages.

Android Wear support is disabled by default but can be enabled inside the PirateBox preferences. There is a new Android Wear section which currently only has one Wear Notification check-box preference.
As soon as this option is ticked upload and shout notifications will be sent to a connect Wear device.

Android Wear Preference

Whenever a new upload or shout has been processed and sent to the Wear device a notification is displayed on the Android device (the phone) to indicate that new notifications have been transferred to the Wear device. If that notification gets dismissed, all notifications on the smart-watch will also be deleted.

Wear Notification on Phone

On the smart-watch notifications are summarized and presented in chronological order (newer first). The following image describes the flow on the Wear device.

Flow on Wear Device

After the messages have been expanded options are available to open the PirateBox app on the phone and in the case of a file upload to open that file on your phone for display.

Thursday, August 7, 2014

PirateBox for Android - I18N

The latest PirateBox for Android version 0.5.2 adds i18n support to the web interface. It is now possible to change the language of the web interface independent of the phone's langue settings.
This post will show how to add your own translations in a few easy steps ...

The language files are stored inside the piratebox/html/i18n* folder. The file names have the following format: i18n_ISO.properties
The ISO part specified the ISO 639-1 code which defines the language. Here is a list of available ISO language codes: Language Codes according to ISO 639-1

To add your own translation copy the English translation i18n_en.properties file and rename it to your desired language. To take French as an example, the file would be named i18n_fr.properties.

It is important to note that the file encoding has to be ISO-8859-1, otherwise you might have issues displaying the characters correctly inside the web interface.

Now you can start editing the file. The file contains key value pairs separated by an equals (=) sign. All you have to do is to translate the right hand side of the euqation.
Here is an example, the original in English on the left and the French translation on the right:
button.thanks=Thanks                                button.thanks=Merci

If all lines have been translated, copy the  new file to the piratebox/html/i18n folder and you are almost done.

To select the new language simply go to the preferences of the PirateBox app and select Web Interface Language. If everything worked well the language should be available for selection.



After a restart of the server the web interface should show the new translation.
Besides English the web interface is already translation into German. If you have made your own translation, you can send it to me** and I'll include it in the next release***.

Have fun and I hope everything is working as it should ...


Base directory: /data/data/de.fun2code.android.piratebox/files/
** Mail: jochen[at]fun2code.de
*** If there are multiple for the same language, I'll pick one...

Saturday, July 19, 2014

PirateBox for Android - Modding

Here are the workshop slides I prepared for the PirateBox Camp #2 in Lille. Because they were not used at the camp I'll post them here, so they are not lost.
The slides show the range of possible modifications to the PirateBox for Android, ranging form simple preference changes to the more advanced use of the Android API.

Here are the slides, more details and download links are available below the presentation.
 
The first slide shows the Basic Settings that can be changed inside the preferences of the PirateBox app.
These basic settings allow to change things like the SSID name, storage directory etc. without deeper knowledge of the PirateBox.

The next slide Content Modifications shows the settings needed to make basic changes to the HTML, CSS and JavaScript files. After ticking the Content to SD option, the app has to be restarted for the change to take effect. After the restart you should find a folder named piratebox on your SD card (or wherever your external storage file system is located).

Inside the piratebox folder you'll find a directory named html which contains all the HTML, CSS and JavaScript files. If you are making changes to files located inside the html directory, make sure that the option Enable Updates is not ticked to prevent the next update of the app to overwrite your changes.
You will also notice that the html directory contains files with the extension xhtml. These files are html files that, in addition to standard HTML, include dynamic content. Dynamic content is covered in the slides that follow.

The next five slide (Dynamic Pages, Using BeanShell, XHTML Example, XHTML Errors and BeanShell DIY) cover the use of dynamic pages by using BeanShell. The slide named BeanShell DIY contains a download link (available below) that offers you the possibility to execute BeanShell code directly on your device.

The last two slides (Using the Android API and Android API DIY) are targeted at developers that already know the Android API. The Adroid API DIY links to a ZIP file (download below) that contains an example that shows the use of the Android API to access the music stored on the Android device. After unzipping the files to the html directory you should have an additional menu entry named Media inside the menu of your PirateBox start page.

If you are interested in how that works you can inspect the xhtml files included inside the ZIP file. But event if you are not into development the sample might be a nice addition to your PirateBox.

Downloads

The files referred to inside the presentation are available on Google Drive:
camp#2/beanshell.zip
camp#2/android_media.zip

Tuesday, July 15, 2014

PirateShare

PirateShare is an app that tries to simplify file upload to a PirateBox by using Android's share functionality.
On the PirateBox Camp #2 we tried the app and it seems to work quite well.
Android Share Dialog (image by #BiblioBox)

PirateShare was inspired by the PirateFox a PirateBox file sharing app for FireFox OS:

http://ruk.ca/content/piratebox-firefox-os-piratefox
https://github.com/reinvented/piratefox

The  PirateShare app is available for download on Google Drive:
http://t.co/j7oiLJdZuT


The app works like this:

  1. Select one or multiple photos from the Gallery or select file(s) inside a file management app
  2. Select PirateShare from share menu
  3. PirateShare checks if connected to a PirateBox by requesting the ncsi.txt file
  4. If connected PirateShare will upload the file(s)
Upload Dialog

Wednesday, May 21, 2014

PirateBox at Google Play

After quite some testing PirateBox for Android is now available at Google Play.
Thanks a lot to all of you for testing. Special thanks goes to Skyworth S8 for testing and sending in lots of screen shots (see gallery below).

The APKs will also be published to Google Drive, so installation will be possible for devices without Goggle Apps.

In case of errors or if you would like to provide feedback, please send a mail to piratebox[at]fun2code.de or leave a comment below.




Links

PirateBox at Google Play
APKs on Google Drive

Saturday, May 17, 2014

PirateBox Reloaded - Episode III

Version 0.4.4 of PirateBox for Android is now available. This post is about the new and noteworthy features of that version.

If tests go well and I have enough feedback I will make PirateBox for Android available at Google Play. So please fill out the questionnaire ... feedback has been very sparse lately.

Droopy Support

The original PirateBox uses Droopy for file upload. PirateBox for Android uses his own mechanism for file uploads. To be compatible Droopy emulation has been introduced. If the Emulate Droopy option is enabled (which it is by default) files can be uploaded by using port 8080.

PirateBox and PirateFox

This makes it possible to use existing file upload tools. For testing the FireFox OS app PirateFox has been used (see image).

In addition to the file upload feature, a number is added to the uploaded file name if the file already exists. In earlier versions files with the same name were silently overwritten.


Info Widget

Info Widget
To make it easier to see if files were uploaded or new messages are available the new version contains a new widget which displays this information.

The counters should update automatically. If that does not work, you can force an update by tapping the widget.

Tasker/Locale Plugin

To make automation easier the latest version contains a Tasker/Locale plugin.
With this plugin it is possible to define tasks to switch the PirateBox on/off automatically.

Tasker
It has to be noted, that there are problems when using WiFi on/off as trigger. This is likely to not work as expected. I hope I'll be able to fix that in upcoming versions.





Status Broadcasts

This might only be interesting for developers but it is now possible to request the status of the PirateBox externally via broadcast. The new Info Widget uses this functionality and might serve as example.

The broadcast action used for the status request is de.fun2code.android.piratebox.broadcast.intent.STATUS_REQUEST and the PirateBox app will respond with a de.fun2code.android.piratebox.broadcast.intent.STATUS_RESULT broadcast which contains the following extras:

SERVER_STATE
  boolean value: true if the server is running, otherwise false

UPLOAD_NUMBER
  int value: number of uploaded files

SHOUT_NUMBER
  int value: number of shout/chat messages

UPLOAD_DIR
  String value: upload directory location

SHOUT_DIR
  String value: shout/chat directory location


That's it for the new version ... looking forward to receiving more feedback :)

Friday, May 9, 2014

PirateBox Reloaded - Episode II

First of all thanks to all of you who gave feedback regarding the PirateBox for Android. The feedback was very useful and showed that there are problems when running the app on Android 4.x.
Meanwhile I've rooted my Galaxy Nexus (still on stock ROM) running 4.3, so I had the change for in depth testing. The result is version 0.4.0 of the app which includes a different handling of the dnsmasq process. I'll go a little into detail to describe the changes that have been made.

Those of  you not interested can jump directly to the end of this post where the download link is located. I've also added the questionnaire again. It would be really nice if you could provide feedback, it's  really useful.

Wrapping Dnsmasq

In previous version of the app the dnsmasq process was killed and restarted with the --address=/#/. This worked fine on Android 2.x devices but lead to a continuous restart of the AP (Access Point) on Android 4.x devices.
The new approach is different in the way that it does not kill the dnsmasq process but installs a wrapper script that is created before the AP stars and removed afterwards.
For this to work the app saves a copy of the file /system/bin/dnsmasq to /system/bin/dansmasq.pb.real. On start of the PirateBox service the wrapper script is created which overwrites the /system/bin/dnsmasq command. After the AP is started the original dnsmasq binary is restored.
The wrapper script looks like this:

#!/system/bin/sh
exec /system/bin/dnsmasq.pb.real --address=/#/192.168.43.1 $*

The wrapper calls the original dnsmasq binary which is now located at /system/bin/dnsmasq.pb.real with the --address and all other other parameters ($*) the system used to start dnsmasq.

If you look at the process list after starting the AP you should see that the backed up dnsmasq.pb.real is running instead of the real one (dnsmasq).
Here is the result of the ps | grep dnsmasq command:

shell@maguro:/ $ ps | grep dnsmasq
nobody    5088  121   928    496   ffffffff 00000000 S /system/bin/dnsmasq.pb.backup

New Preferences

The preference screen has two new additions. One is the IP address of the AP and the other is the option to restore the original dnsmasq binary.

New Preference Options
In previous versions the IP of the AP could determined after the AP was started and used to restart dnsmasq. This is no longer possible, because the wrapper script has to be created before the AP starts.

On Android most of the devices have the IP address 192.168.43.1 hard coded and I don't believe that there are a lot ROMs with different addresses. Should your AP start with a different IP address, you can still change this by using the new preference setting AP IP Number.

The second new preferences option is called Restore "dnsmasq" Binary. This will, as the name implies, try to restore the original dnsmasq binary. This should not be necessary to used, because the wrapper is removed and replaced by the original binary after the AP has been started. But in case thing do not work as desired when the device is used for standard tethering, this is the option to restore the binary.

Simple Widget

The new version also comes with a simple widget. It is not pretty ... but hey, I'm a developer not an artist ;)
Meanwhile I've updated the widget images in version 0.4.1, hope the widget is looking a bit better.

Below are the links to the app, the questionnaire and to the source code located at GitHub.
So I hope the new version is working better as the previous version and I'm looking forward for your feedback.



Source Code

The source code is now available on GitHub.

Download Links

Google Drive: PirateBox APKs

Questionnaire

The results can be viewed here, so you know on which configurations PirateBox is running.

Thursday, October 10, 2013

PirateBox Reloaded

It's been a while since the last PirateBox update. The last version was based on a PAW server plug-in  that didn't work well for all users.
Meanwhile I developed a stand alone PirateBox Android app that hopefully will work better.

The new app is based on CyanogenMod 7 and was tested on a Nexus One.
I have no other devices running CyanogenMod but I hope that the app will run too on different versions of that ROM.

CyanogenMod 7 and Nexus One


This post will describe the app in some detail. Technical details about the networking part will not be covered, because these were described in the earlier post. The techniques are the same, so there is no need to go through all of that again.
For those of you not interested, don't worry, here is the download link to the app straight away. Just download the APK and install it. A rooted device is necessary and it has only be tested with CyanogenMod 7.

So here is the Google Drive download link: PirateBox APKs


Running the App

For those still reading here is the more detailed part...
When you start the app you will  see the (not so spectacular) main screen which basically consists of an image and a start button. If your device is not rooted or the device is missing some prerequisites there will be a message telling so and you will not be able to proceed.

PirateBox - Switched off


After pressing the start button the app will start to setup the network. There is no need to start the hotspot beforehand, that will be done automatically. The app also take care to create an open hotspot and to name it appropriately.
After all is set up, you should see three icons underneath the start button and a notification in form of a scull.



PirateBox - Running


The icons show the active components that are configured during start up. These are, from left to right, the web server, the access point and the network configuration.

 Connecting via Browser

The PirateBox should show up as access point with the default SSID named  PirateBox - Share Freely. The name can be changed inside the setting, but we'll come to that in the next section.

PirateBox - Wi-Fi Access Point


After connecting to the access point you should be able to enter any HTTP URL inside your browser's address bar to get to the index page of the PirateBox.

PirateBox - Index page


App Settings

The app has a few settings. We will discuss them briefly.

PirateBox - Settings


Start On Boot: If you check that option, the PirateBox will start up after the device has been booted and the SD card is ready.

SSID Name: You can change the SSID name here. The app will try to change the name immediately. A restart should not be necessary. The default name is PirateBox - Share Freely as mentioned above.

Storage Directory: The directory which contains the uploaded files and the messages inside the shoutbox. You can locate the directory wherever you like. The directory /sdcard/pb_store is the default.

Enable Updates: On default the configuration and HTML files are updated with each new version of the app. If you don not want to do that, because you want to use your own configuration, un-check that option and no updates will be done.

iOS WISPr Support: iOS devices use WISPr request to detect if the device is indeed online. If not the device will not permanently connect to the hotspot. If that option is enabled the iOS device assumes it's online.

WP NCSI Support: Basically the same as for iOS devices. Windows Phone request a NCSI file to check if it's online.

App Broadcasts

This is a more advances topic and directed to developers which would like to interface with the app.
You do not need to read this section to use the app.
The app broadcast Intents to make indications  about the state of the PirateBox , of file uploads and shout messages.
Here are the broadcasts and the extra values provided.

Intent: de.fun2code.android.piratebox.broadcast.intent.server
Extras: state (boolean)
Description: Indicates the state of the web server.

Intent: de.fun2code.android.piratebox.broadcast.intent.ap
Extras: state (boolean)
Description: Indicates if the access point is running or not.

Intent: de.fun2code.android.piratebox.broadcast.intent.network
Extras: state (boolean)
Description: If the state is true, the networking (dnsmasq and iptables) are configured.

Intent: de.fun2code.android.piratebox.broadcast.intent.shout
Extras: name (String), text (String)
Description: If a message is entered into the shoutbox, the name and text will be included inside the extras of this Intent.

Intent: de.fun2code.android.piratebox.broadcast.intent.upload
Extras: file (String)
Description: Upon file upload the extra will contain the FQN of the file.


Current State

The app is in an very early state. I've tested as good as I could. There are surely bugs and  in some cases the app might not work at all.

New updates of the APK will show up in the Google Drive folder linked below.
So if you are interested, check the folder from time to time.

Feedback is always welcome!

Source Code

The source code is now available on GitHub.

In Case of Errors

If the PirateBox does not work as expected, please send me a mail describing your setup and include the LogCat output ... thanks

Mail address: jochen [at] fun2code.de

Download Links

Google Drive: PirateBox APKs

Questionnaire

If you tried the app, please provide feedback by filling out the following questionnaire ... thanks!
The results can be viewed here, so you know on which configurations PirateBox is running.

Thursday, January 26, 2012

Changing the PirateBox Location

This post gives a quick overview what has to be done to move the PirateBox installation to a different directory.

By default the PirateBox HTML files are located in the directory /sdcard/paw/html/app/plugins/piratebox_plugin/html and uploaded files are stored in the folder uploads inside the HTML directory.

I'll demonstrate what to do to move the PirateBox to a different directory (in my example /sdcard/piratebox_ext). You can of course also use a directory on an external SD card.

Copying the HTML Directory
First thing to do ist to create the new folder /sdcard/pireatebox_ext.
Now copy the directory /sdcard/paw/html/app/plugins/piratebox_plugin/html to the new location /sdcard/pireatebox_ext.

As a next step we will edit the PAW server configuration.

Changing the PAW Configuration

The configuration file used for PirateBox is named handlers.xml and it's located inside the /sdcard/paw/html/app/plugins/piratebox_plugin/conf directory.
Edit this file and replace each occurence of /sdcard/paw/html/app/plugins/piratebox_plugin with /sdcard/piraebox_ext.

Changing the Web Pages
Last step to do is to edit the files list.xhtml and pb.xhtml inside the /sdcard/piratebox_ext/html directory.
In each file there is one line that defines the upload directory.
Again, change each occurence of /sdcard/paw/html/app/plugins/piratebox_plugin to /sdcard/piraebox_ext.


That's it ... on next startup the new PirateBox location should be used.

Thursday, December 1, 2011

PirateBox on Android

A while ago psundegroud created the thread [TUT]Roll Your Own PirateBox! PirateBoxMobile. At that time my only rooted device was an old Samsung Galaxy I7500 running Android 1.6. We managed to get this working. The two main issues were that WiFi Tether was needed, which didn't run on all Android devices and that only Ad-Hoc mode was available. The missing Infrastructure mode prevented most Androids from seeing the PirateBox hotspot.

Note: This post is somewhat outdated. The current state of the PirateBox can be found here: PirateBox Reloaded

Meanwhile I have a rooted Notion Ink Adam running AdamComb v0.3. So I tried to get PirateBox running by using the built in tether app. Built in tethering uses Infrastructure mode, which solves above mentioned problem.

On my Adam this is really working fine and I hope that it will also run on other Android units.
I'll divide the post in two parts. The first part describes the technical details, so if someone has problems in getting this to work this might be helpful for further testing.

Along with setting up the scripts I have also written a plugin for PAW which should make setup really easy.
If you are not interested in the technical details you can right jump to the Installing the Plugin section.

Techical Details

Setting up the PirateBox during boot is done by PAW startup scripts.

The main tasks of these scripts are:
  • Killing dnsmasq and restarting it with changed parameters, so that DNS requests always respond with the IP of the Android device.
  • Configuring iptables so that requests to port 80 are redirected to the port PAW is listening on, because PAW can not operate on privileged ports.
  • Change the PAW configuration to use the PirateBox Handler, which ensures that all unknown request are forwarded to the base URL (piratebox.org/).

The startup scripts are located in the subfolders 0 and 1 of the directory /sdcard/paw/etc/init. These folders represent PAW runlevels. Runlevel 0 is before the server starts and after server shutdown and 1 is after server start and before the server shuts down. Scripts beginning with S_ will be called on startup and scripts starting with K_ will be run at shutdown.

So here is a short summary what these scripts are doing.

0/S_PirateBox.bsh:
  • Checks if tethering is running. If not none of the steps below will be performed.
  • Kills the "original" dnsmasq process and starts a new one.
  • Executes iptables commands to get port redirection working.
  • Replaces the original PAW configuration with the PirateBox configuration.

1/S_SpirateBox.bsh:
  • Checks if tethering is running. If not none of the steps below will be performed.
  • Restores the original PAW configuration.
  • Displays a PirateBox notification.
  • Sets the max upload limit to 200MB.

1/K_S_SpirateBox.bsh:
  • Clears the PirateBox notification.
  • Kills dnsmasq process.
  • Stops tetherig and restarts WiFi.

0/K_S_SpirateBox.bsh:
  • Removes iptables rules for port redirection.

If you run into problems have a look at these scripts and try to run the commands inside the scripts individually.


Installing the Plugin

PAW Plug-in Menu
Installing the plugin is easy. I've put it on the PAW plugin page, so you'll find it within the PAW web application or you can direct download it from the PAW Plugin Page.
After download extract the ZIP file to the /sdcard/paw/html/app/plugins directory of your Android device.
Now after re-entering the PAW web application, the PirateBox plugin should be visible in the Plugins menu.

If the plugin setup screen shows a warning in red, the installation is likely to fail, because some prerequisites are missing.
If no warnings are displayed, press the Install button. You can also try to setup a PirateBox Access Point (AP) automatically. I'm not sure, if this is working on all devices. If it's not working, please create an AP manually.
To uninstall the plugin, press the Uninstall button.

PirateBox Plugin

It is important to note, that PirateBox will only be started if tethering is active before PAW starts up.
Otherwise the normal PAW configuration will be applied. So you can choose between these two configurations.

I hope that's not just working on my Adam but on many other devices as well.

Screenshost
Here are some screenshots from my setup...

PirateBox Startup

Connected to PirateBox

PirateBox on Nexus One
PirateBox in Chromium

Video

Here is a video that shows the PirateBox in action...



Update

Since version 0.3 of the plugin, PirateBox is also working on rooted Galaxy Nexus devices running Ice Cream Sandwich.
Here is a video...