Skip to content

Commit

Permalink
complete first version of Intent based Rhizome API
Browse files Browse the repository at this point in the history
  • Loading branch information
techxplorer committed Feb 21, 2012
1 parent 70ad56a commit 0abb18c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
8 changes: 7 additions & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright (C) 2011 The Serval Project
* Copyright (C) 2011,2012 The Serval Project
*
* This file is part of Serval Software (http://www.servalproject.org)
*
Expand Down Expand Up @@ -30,6 +30,12 @@
android:description="@string/rhizome_share_file_permission_description"
android:name="org.servalproject.rhizome.ADD_FILE">
</permission>
<permission
android:label="@string/rhizome_receive_file_permission_label"
android:protectionLevel="dangerous"
android:description="@string/rhizome_receive_file_permission_description"
android:name="org.servalproject.rhizome.RECIEVE_FILE">
</permission>

<!-- Uses permissions -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
Expand Down
3 changes: 3 additions & 0 deletions res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@
<string name="rhizome_share_file_intent_action">org.servalproject.rhizome.ADD_FILE</string>
<string name="rhizome_share_file_permission_label">Add files to Rhizome</string>
<string name="rhizome_share_file_permission_description">Add files via the Serval Mesh using Rhizome</string>
<string name="rhizome_receive_file_intent_action">org.servalproject.rhizome.RECEIVE_FILE</string>
<string name="rhizome_receive_file_permission_label">Receive files from Rhizome</string>
<string name="rhizome_receive_file_permission_description">Receive files via the Serval Mesh using Rhizome</string>


<!-- Serval General -->
Expand Down
40 changes: 29 additions & 11 deletions src/org/servalproject/rhizome/StuffDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,23 +140,41 @@ private void dlFile(String manifest) {
handler.sendMessage(updateMessage);
}

// send the broadcast
if (downloadedFileName.toLowerCase().endsWith(".rpml") == false
&& downloadedFileName.toLowerCase().endsWith(".apk") == false) {

Intent mBroadcastIntent = new Intent(
"org.servalproject.rhizome.RECIEVE_FILE");
mBroadcastIntent.putExtra("path", downloadedFileName);
mBroadcastIntent.putExtra("name", name);
mBroadcastIntent.putExtra("version",
Long.parseLong(version));

ServalBatPhoneApplication.context.sendBroadcast(
mBroadcastIntent,
"org.servalproject.rhizome.RECIEVE_FILE");

}

if (downloadedFileName.toLowerCase().endsWith(".rpml"))
{
// File is a public message log - so we should tell batphone to
// look for messages in the file.
MessageLogExaminer.examineLog(downloadedFileName);
}
if (downloadedFileName.toLowerCase().endsWith(".map")) {
// File is a map.
// copy into place and notify user to restart mapping
RhizomeUtils.dirServalMapping.mkdir();
RhizomeUtils.CopyFileToDir(new File(downloadedFileName),
RhizomeUtils.dirServalMapping);

// TODO: Create a notification or otherwise tell the mapping
// application that the
// map is available.
}
// let Serval Maps deal with the map files itself
// if (downloadedFileName.toLowerCase().endsWith(".map")) {
// // File is a map.
// // copy into place and notify user to restart mapping
// RhizomeUtils.dirServalMapping.mkdir();
// RhizomeUtils.CopyFileToDir(new File(downloadedFileName),
// RhizomeUtils.dirServalMapping);
//
// // TODO: Create a notification or otherwise tell the mapping
// // application that the
// // map is available.
// }
if (downloadedFileName.toLowerCase().endsWith(".apk")) {
PackageManager pm = ServalBatPhoneApplication.context
.getPackageManager();
Expand Down

0 comments on commit 0abb18c

Please sign in to comment.