Browse Source

Added option to force recheck of data with rTorrent, uTorrent and Deluge. Fixes #16. Also fixes a UI glitch to propage torrent changes back to the torrents list screen.

pull/82/head
Eric Kok 11 years ago
parent
commit
7776eb2ef5
  1. 1
      core/.classpath
  2. BIN
      core/libs/transdroid-connect.jar
  3. BIN
      core/res/drawable-hdpi/ic_action_forcerecheck_dark.png
  4. BIN
      core/res/drawable-hdpi/ic_action_forcerecheck_light.png
  5. BIN
      core/res/drawable-mdpi/ic_action_forcerecheck_dark.png
  6. BIN
      core/res/drawable-mdpi/ic_action_forcerecheck_light.png
  7. BIN
      core/res/drawable-xhdpi/ic_action_forcerecheck_dark.png
  8. BIN
      core/res/drawable-xhdpi/ic_action_forcerecheck_light.png
  9. BIN
      core/res/drawable-xxhdpi/ic_action_forcerecheck_dark.png
  10. BIN
      core/res/drawable-xxhdpi/ic_action_forcerecheck_light.png
  11. 10
      core/res/menu/fragment_details.xml
  12. 2
      core/res/values-nl/strings.xml
  13. 1
      core/res/values/attrs.xml
  14. 2
      core/res/values/strings.xml
  15. 2
      core/res/values/styles.xml
  16. 39
      core/src/org/transdroid/core/gui/DetailsActivity.java
  17. 5
      core/src/org/transdroid/core/gui/DetailsFragment.java
  18. 1
      core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
  19. 78
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  20. 27
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  21. 6
      lib/src/org/transdroid/daemon/Daemon.java
  22. 3
      lib/src/org/transdroid/daemon/DaemonMethod.java
  23. 8
      lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java
  24. 12
      lib/src/org/transdroid/daemon/DummyAdapter.java
  25. 6
      lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java
  26. 4
      lib/src/org/transdroid/daemon/Torrent.java
  27. 10
      lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java
  28. 31
      lib/src/org/transdroid/daemon/task/ForceRecheckTask.java

1
core/.classpath

@ -10,5 +10,6 @@
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/> <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/Transdroid Torrent Connect"/>
<classpathentry kind="output" path="bin/classes"/> <classpathentry kind="output" path="bin/classes"/>
</classpath> </classpath>

BIN
core/libs/transdroid-connect.jar

Binary file not shown.

BIN
core/res/drawable-hdpi/ic_action_forcerecheck_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

BIN
core/res/drawable-hdpi/ic_action_forcerecheck_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

BIN
core/res/drawable-mdpi/ic_action_forcerecheck_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

BIN
core/res/drawable-mdpi/ic_action_forcerecheck_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 511 B

BIN
core/res/drawable-xhdpi/ic_action_forcerecheck_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 698 B

BIN
core/res/drawable-xhdpi/ic_action_forcerecheck_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 783 B

BIN
core/res/drawable-xxhdpi/ic_action_forcerecheck_dark.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
core/res/drawable-xxhdpi/ic_action_forcerecheck_light.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

10
core/res/menu/fragment_details.xml

@ -62,17 +62,23 @@
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_setlabel" android:title="@string/action_setlabel"
android:orderInCategory="205" /> android:orderInCategory="205" />
<item
android:id="@+id/action_forcerecheck"
android:icon="?attr/ic_action_forcerecheck"
android:showAsAction="ifRoom"
android:title="@string/action_forcerecheck"
android:orderInCategory="206" />
<item <item
android:id="@+id/action_updatetrackers" android:id="@+id/action_updatetrackers"
android:icon="?attr/ic_action_trackers" android:icon="?attr/ic_action_trackers"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_updatetrackers" android:title="@string/action_updatetrackers"
android:orderInCategory="206" /> android:orderInCategory="207" />
<item <item
android:id="@+id/action_changelocation" android:id="@+id/action_changelocation"
android:icon="?attr/ic_action_save" android:icon="?attr/ic_action_save"
android:showAsAction="ifRoom" android:showAsAction="ifRoom"
android:title="@string/action_changelocation" android:title="@string/action_changelocation"
android:orderInCategory="207" /> android:orderInCategory="208" />
</menu> </menu>

2
core/res/values-nl/strings.xml

@ -49,6 +49,7 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="action_setlabel">Label toewijzen</string> <string name="action_setlabel">Label toewijzen</string>
<string name="action_updatetrackers">Trackers updaten</string> <string name="action_updatetrackers">Trackers updaten</string>
<string name="action_changelocation">Opslaglocatie wijzigen</string> <string name="action_changelocation">Opslaglocatie wijzigen</string>
<string name="action_forcerecheck">Forceer dataintegriteitscontrole</string>
<string name="action_priority_off">Uit</string> <string name="action_priority_off">Uit</string>
<string name="action_priority_low">Laag</string> <string name="action_priority_low">Laag</string>
<string name="action_priority_normal">Normaal</string> <string name="action_priority_normal">Normaal</string>
@ -151,6 +152,7 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="result_trackersupdated">Trackers geüpdatet</string> <string name="result_trackersupdated">Trackers geüpdatet</string>
<string name="result_labelset">Label \'%1$s\' toegewezen</string> <string name="result_labelset">Label \'%1$s\' toegewezen</string>
<string name="result_labelremoved">Label verwijderd</string> <string name="result_labelremoved">Label verwijderd</string>
<string name="result_recheckedstarted">%1$s wordt gecontroleerd</string>
<string name="result_locationset">Torrent verplaatst naar \'%1$s\'</string> <string name="result_locationset">Torrent verplaatst naar \'%1$s\'</string>
<string name="result_priotitiesset">Bestandsprioriteiten geüpdatet</string> <string name="result_priotitiesset">Bestandsprioriteiten geüpdatet</string>
<string name="result_maxspeedsset">Maximale snelheden ingesteld</string> <string name="result_maxspeedsset">Maximale snelheden ingesteld</string>

1
core/res/values/attrs.xml

@ -36,6 +36,7 @@
<attr name="ic_action_resume" format="reference"/> <attr name="ic_action_resume" format="reference"/>
<attr name="ic_action_rss" format="reference"/> <attr name="ic_action_rss" format="reference"/>
<attr name="ic_action_save" format="reference"/> <attr name="ic_action_save" format="reference"/>
<attr name="ic_action_forcerecheck" format="reference"/>
<attr name="ic_action_search" format="reference"/> <attr name="ic_action_search" format="reference"/>
<attr name="ic_action_sort_by_size" format="reference"/> <attr name="ic_action_sort_by_size" format="reference"/>
<attr name="ic_action_start" format="reference"/> <attr name="ic_action_start" format="reference"/>

2
core/res/values/strings.xml

@ -49,6 +49,7 @@
<string name="action_setlabel">Set label</string> <string name="action_setlabel">Set label</string>
<string name="action_updatetrackers">Update trackers</string> <string name="action_updatetrackers">Update trackers</string>
<string name="action_changelocation">Change storage location</string> <string name="action_changelocation">Change storage location</string>
<string name="action_forcerecheck">Force data recheck</string>
<string name="action_priority_off">Off</string> <string name="action_priority_off">Off</string>
<string name="action_priority_low">Low</string> <string name="action_priority_low">Low</string>
<string name="action_priority_normal">Normal</string> <string name="action_priority_normal">Normal</string>
@ -154,6 +155,7 @@
<string name="result_trackersupdated">Trackers updated</string> <string name="result_trackersupdated">Trackers updated</string>
<string name="result_labelset">Label set to \'%1$s\'</string> <string name="result_labelset">Label set to \'%1$s\'</string>
<string name="result_labelremoved">Label removed</string> <string name="result_labelremoved">Label removed</string>
<string name="result_recheckedstarted">Checking %1$s data</string>
<string name="result_locationset">Torrent moved to \'%1$s\'</string> <string name="result_locationset">Torrent moved to \'%1$s\'</string>
<string name="result_priotitiesset">File priorities updated</string> <string name="result_priotitiesset">File priorities updated</string>
<string name="result_maxspeedsset">Maximum transfer speeds set</string> <string name="result_maxspeedsset">Maximum transfer speeds set</string>

2
core/res/values/styles.xml

@ -36,6 +36,7 @@
<item name="ic_action_resume">@drawable/ic_action_resume_light</item> <item name="ic_action_resume">@drawable/ic_action_resume_light</item>
<item name="ic_action_rss">@drawable/ic_action_rss_light</item> <item name="ic_action_rss">@drawable/ic_action_rss_light</item>
<item name="ic_action_save">@drawable/ic_action_save_light</item> <item name="ic_action_save">@drawable/ic_action_save_light</item>
<item name="ic_action_forcerecheck">@drawable/ic_action_forcerecheck_light</item>
<item name="ic_action_search">@drawable/ic_action_search_light</item> <item name="ic_action_search">@drawable/ic_action_search_light</item>
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_light</item>
<item name="ic_action_start">@drawable/ic_action_start_light</item> <item name="ic_action_start">@drawable/ic_action_start_light</item>
@ -69,6 +70,7 @@
<item name="ic_action_resume">@drawable/ic_action_resume_dark</item> <item name="ic_action_resume">@drawable/ic_action_resume_dark</item>
<item name="ic_action_rss">@drawable/ic_action_rss_dark</item> <item name="ic_action_rss">@drawable/ic_action_rss_dark</item>
<item name="ic_action_save">@drawable/ic_action_save_dark</item> <item name="ic_action_save">@drawable/ic_action_save_dark</item>
<item name="ic_action_forcerecheck">@drawable/ic_action_forcerecheck_dark</item>
<item name="ic_action_search">@drawable/ic_action_search_dark</item> <item name="ic_action_search">@drawable/ic_action_search_dark</item>
<item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item> <item name="ic_action_sort_by_size">@drawable/ic_action_sort_by_size_dark</item>
<item name="ic_action_start">@drawable/ic_action_start_dark</item> <item name="ic_action_start">@drawable/ic_action_start_dark</item>

39
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -47,6 +47,7 @@ import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.task.DaemonTaskFailureResult; import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult; import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult; import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask; import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult; import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetTorrentDetailsTask; import org.transdroid.daemon.task.GetTorrentDetailsTask;
@ -225,7 +226,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void resumeTorrent(Torrent torrent) { public void resumeTorrent(Torrent torrent) {
torrent.mimicResume(); torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -237,7 +238,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void pauseTorrent(Torrent torrent) { public void pauseTorrent(Torrent torrent) {
torrent.mimicPause(); torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -249,7 +250,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void startTorrent(Torrent torrent, boolean forced) { public void startTorrent(Torrent torrent, boolean forced) {
torrent.mimicStart(); torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute(); DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -261,7 +262,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void stopTorrent(Torrent torrent) { public void stopTorrent(Torrent torrent) {
torrent.mimicStop(); torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -272,7 +273,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Override @Override
public void removeTorrent(Torrent torrent, boolean withData) { public void removeTorrent(Torrent torrent, boolean withData) {
DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute(); DaemonTaskResult result = RemoveTask.create(currentConnection, torrent, withData).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
// Close the details activity (as the torrent is now removed) // Close the details activity (as the torrent is now removed)
closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed, closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed,
torrent.getName())); torrent.getName()));
@ -283,8 +284,8 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread @UiThread
protected void closeActivity(String closeText) { protected void closeActivity(String closeText) {
// The activity result RESULT_CANCELED means that the torrent no longer exists setResult(RESULT_OK,
setResult(RESULT_OK, new Intent().putExtra("torrent_removed", true)); new Intent().putExtra("torrent_removed", true).putExtra("affected_torrent", torrent));
finish(); finish();
if (closeText != null) if (closeText != null)
Toast.makeText(this, closeText, Toast.LENGTH_LONG).show(); Toast.makeText(this, closeText, Toast.LENGTH_LONG).show();
@ -296,18 +297,31 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
torrent.mimicNewLabel(newLabel); torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel) DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel)
.execute(); .execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@Background
@Override
public void forceRecheckTorrent(Torrent torrent) {
torrent.mimicCheckingStatus();
DaemonTaskResult result = ForceRecheckTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result,
getString(R.string.result_recheckedstarted, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background @Background
@Override @Override
public void updateTrackers(Torrent torrent, List<String> newTrackers) { public void updateTrackers(Torrent torrent, List<String> newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute(); DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -318,7 +332,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@Override @Override
public void updateLocation(Torrent torrent, String newLocation) { public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute(); DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -330,7 +344,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) { public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) {
DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority, DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority,
new ArrayList<TorrentFile>(files)).execute(); new ArrayList<TorrentFile>(files)).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -339,6 +353,9 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread @UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) { protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// Set the activity result so the calling activity knows it needs to update its view
setResult(RESULT_OK,
new Intent().putExtra("torrent_updated", true).putExtra("affected_torrent", torrent));
// Refresh the screen as well // Refresh the screen as well
refreshTorrent(); refreshTorrent();
refreshTorrentDetails(torrent); refreshTorrentDetails(torrent);

5
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -318,6 +318,11 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
.show(getFragmentManager(), "SetLabelDialog"); .show(getFragmentManager(), "SetLabelDialog");
} }
@OptionsItem(resName = "action_forcerecheck")
protected void setForceRecheck() {
getTasksExecutor().forceRecheckTorrent(torrent);
}
@OptionsItem(resName = "action_updatetrackers") @OptionsItem(resName = "action_updatetrackers")
protected void updateTrackers() { protected void updateTrackers() {
if (torrentDetails == null) { if (torrentDetails == null) {

1
core/src/org/transdroid/core/gui/TorrentTasksExecutor.java

@ -33,6 +33,7 @@ public interface TorrentTasksExecutor {
void startTorrent(Torrent torrent, boolean forced); void startTorrent(Torrent torrent, boolean forced);
void stopTorrent(Torrent torrent); void stopTorrent(Torrent torrent);
void removeTorrent(Torrent torrent, boolean withData); void removeTorrent(Torrent torrent, boolean withData);
void forceRecheckTorrent(Torrent torrent);
void updateLabel(Torrent torrent, String newLabel); void updateLabel(Torrent torrent, String newLabel);
void updateTrackers(Torrent torrent, List<String> newTrackers); void updateTrackers(Torrent torrent, List<String> newTrackers);
void updateLocation(Torrent torrent, String newLocation); void updateLocation(Torrent torrent, String newLocation);

78
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -45,18 +45,28 @@ import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.cookie.BasicClientCookie; import org.apache.http.impl.cookie.BasicClientCookie;
import org.transdroid.core.R; import org.transdroid.core.R;
import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.*; import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.app.settings.WebsearchSetting; import org.transdroid.core.app.settings.WebsearchSetting;
import org.transdroid.core.gui.lists.LocalTorrent; import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.lists.NoProgressHeaderTransformer; import org.transdroid.core.gui.lists.NoProgressHeaderTransformer;
import org.transdroid.core.gui.lists.SimpleListItem; import org.transdroid.core.gui.lists.SimpleListItem;
import org.transdroid.core.gui.log.*; import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.*; import org.transdroid.core.gui.log.Log_;
import org.transdroid.core.gui.rss.*; import org.transdroid.core.gui.navigation.FilterListAdapter;
import org.transdroid.core.gui.navigation.FilterListAdapter_;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter;
import org.transdroid.core.gui.navigation.FilterListDropDownAdapter_;
import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.StatusType;
import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.core.gui.search.BarcodeHelper; import org.transdroid.core.gui.search.BarcodeHelper;
import org.transdroid.core.gui.search.FilePickerHelper; import org.transdroid.core.gui.search.FilePickerHelper;
import org.transdroid.core.gui.search.UrlEntryDialog; import org.transdroid.core.gui.search.UrlEntryDialog;
import org.transdroid.core.gui.settings.*; import org.transdroid.core.gui.settings.MainSettingsActivity_;
import org.transdroid.core.service.BootReceiver; import org.transdroid.core.service.BootReceiver;
import org.transdroid.core.service.ConnectivityHelper; import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.core.widget.WidgetProvider; import org.transdroid.core.widget.WidgetProvider;
@ -73,6 +83,7 @@ import org.transdroid.daemon.task.AddByUrlTask;
import org.transdroid.daemon.task.DaemonTaskFailureResult; import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult; import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult; import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask; import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult; import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetStatsTask; import org.transdroid.daemon.task.GetStatsTask;
@ -132,7 +143,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
RefreshableActivity { RefreshableActivity {
private static final int RESULT_DETAILS = 0; private static final int RESULT_DETAILS = 0;
// Navigation components // Navigation components
@Bean @Bean
protected NavigationHelper navigationHelper; protected NavigationHelper navigationHelper;
@ -279,8 +290,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
updateFragmentVisibility(false); updateFragmentVisibility(false);
return; return;
} }
// If we had no connection before, establish it now; otherwise jsut reload the settings // If we had no connection before, establish it now; otherwise just reload the settings
if (currentConnection == null) if (currentConnection == null)
filterSelected(lastUsed, true); filterSelected(lastUsed, true);
else else
@ -289,11 +300,14 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@OnActivityResult(RESULT_DETAILS) @OnActivityResult(RESULT_DETAILS)
protected void onDetailsScreenResult(Intent result) { protected void onDetailsScreenResult(Intent result) {
// If the details activity returns whether the torrent was removed, refresh the screen // If the details activity returns whether the torrent was removed or updated, update the torrents list as well
if (result != null && result.getBooleanExtra("torrent_removed", false)) // (the details fragment is the source, so no need to update that)
refreshScreen(); if (result != null && result.hasExtra("affected_torrent")) {
Torrent affected = result.getParcelableExtra("affected_torrent");
fragmentTorrents.quickUpdateTorrent(affected, result.getBooleanExtra("torrent_removed", false));
}
} }
@Override @Override
protected void onDestroy() { protected void onDestroy() {
Crouton.cancelAllCroutons(); Crouton.cancelAllCroutons();
@ -457,7 +471,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
} }
supportInvalidateOptionsMenu(); supportInvalidateOptionsMenu();
} }
@Override @Override
protected void onNewIntent(Intent intent) { protected void onNewIntent(Intent intent) {
setIntent(intent); setIntent(intent);
@ -549,7 +563,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
searchMenu.collapseActionView(); searchMenu.collapseActionView();
super.onPause(); super.onPause();
} }
@Override @Override
public boolean onSearchRequested() { public boolean onSearchRequested() {
if (searchMenu != null) { if (searchMenu != null) {
@ -615,7 +629,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
} }
}); });
} }
@OptionsItem(resName = "action_refresh") @OptionsItem(resName = "action_refresh")
public void refreshScreen() { public void refreshScreen() {
fragmentTorrents.updateIsLoading(true); fragmentTorrents.updateIsLoading(true);
@ -701,7 +715,8 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
if (fragmentDetails != null) { if (fragmentDetails != null) {
fragmentDetails.updateTorrent(torrent); fragmentDetails.updateTorrent(torrent);
} else { } else {
DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels).startForResult(RESULT_DETAILS); DetailsActivity_.intent(this).torrent(torrent).currentLabels(lastNavigationLabels)
.startForResult(RESULT_DETAILS);
} }
} }
@ -882,7 +897,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void resumeTorrent(Torrent torrent) { public void resumeTorrent(Torrent torrent) {
torrent.mimicResume(); torrent.mimicResume();
DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = ResumeTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -894,7 +909,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void pauseTorrent(Torrent torrent) { public void pauseTorrent(Torrent torrent) {
torrent.mimicPause(); torrent.mimicPause();
DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = PauseTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -906,7 +921,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void startTorrent(Torrent torrent, boolean forced) { public void startTorrent(Torrent torrent, boolean forced) {
torrent.mimicStart(); torrent.mimicStart();
DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute(); DaemonTaskResult result = StartTask.create(currentConnection, torrent, forced).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -918,7 +933,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void stopTorrent(Torrent torrent) { public void stopTorrent(Torrent torrent) {
torrent.mimicStop(); torrent.mimicStop();
DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute(); DaemonTaskResult result = StopTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -944,7 +959,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
torrent.mimicNewLabel(newLabel); torrent.mimicNewLabel(newLabel);
DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel) DaemonTaskResult result = SetLabelTask.create(currentConnection, torrent, newLabel == null ? "" : newLabel)
.execute(); .execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded( onTaskSucceeded(
(DaemonTaskSuccessResult) result, (DaemonTaskSuccessResult) result,
newLabel == null ? getString(R.string.result_labelremoved) : getString(R.string.result_labelset, newLabel == null ? getString(R.string.result_labelremoved) : getString(R.string.result_labelset,
@ -954,11 +969,24 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
} }
} }
@Background
@Override
public void forceRecheckTorrent(Torrent torrent) {
torrent.mimicCheckingStatus();
DaemonTaskResult result = ForceRecheckTask.create(currentConnection, torrent).execute();
if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result,
getString(R.string.result_recheckedstarted, torrent.getName()));
} else {
onCommunicationError((DaemonTaskFailureResult) result, false);
}
}
@Background @Background
@Override @Override
public void updateTrackers(Torrent torrent, List<String> newTrackers) { public void updateTrackers(Torrent torrent, List<String> newTrackers) {
DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute(); DaemonTaskResult result = SetTrackersTask.create(currentConnection, torrent, newTrackers).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -969,7 +997,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
@Override @Override
public void updateLocation(Torrent torrent, String newLocation) { public void updateLocation(Torrent torrent, String newLocation) {
DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute(); DaemonTaskResult result = SetDownloadLocationTask.create(currentConnection, torrent, newLocation).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -981,7 +1009,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) { public void updatePriority(Torrent torrent, List<TorrentFile> files, Priority priority) {
DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority, DaemonTaskResult result = SetFilePriorityTask.create(currentConnection, torrent, priority,
new ArrayList<TorrentFile>(files)).execute(); new ArrayList<TorrentFile>(files)).execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);
@ -992,7 +1020,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
public void updateMaxSpeeds(Integer maxDownloadSpeed, Integer maxUploadSpeed) { public void updateMaxSpeeds(Integer maxDownloadSpeed, Integer maxUploadSpeed) {
DaemonTaskResult result = SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed) DaemonTaskResult result = SetTransferRatesTask.create(currentConnection, maxUploadSpeed, maxDownloadSpeed)
.execute(); .execute();
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskSuccessResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_maxspeedsset)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_maxspeedsset));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result, false); onCommunicationError((DaemonTaskFailureResult) result, false);

27
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -132,6 +132,28 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
applyAllFilters(); applyAllFilters();
} }
/**
* Just look for a specific torrent in the currently shown list (by its unique id) and update only this
* @param affected The affected torrent to update
* @param wasRemoved Whether the affected torrent was indeed removed; otherwise it was updated somehow
*/
public void quickUpdateTorrent(Torrent affected, boolean wasRemoved) {
// Remove the old torrent object first
Iterator<Torrent> iter = this.torrents.iterator();
while (iter.hasNext()) {
Torrent torrent = iter.next();
if (torrent.getUniqueID().equals(affected.getUniqueID())) {
iter.remove();
break;
}
}
// In case it was an update, add the updated torrent object
if (!wasRemoved)
this.torrents.add(affected);
// Now refresh the screen
applyAllFilters();
}
/** /**
* Clears the currently visible list of torrents. * Clears the currently visible list of torrents.
* @param b * @param b
@ -187,9 +209,6 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
return; return;
} }
// Get the server daemon type directly form the local list of torrents, if it's not empty
Daemon serverType = (this.torrents.size() > 0 ? this.torrents.get(0).getDaemon() : Daemon.Transmission);
// Filter the list of torrents to show according to navigation and text filters // Filter the list of torrents to show according to navigation and text filters
ArrayList<Torrent> filteredTorrents = new ArrayList<Torrent>(torrents); ArrayList<Torrent> filteredTorrents = new ArrayList<Torrent>(torrents);
if (filteredTorrents != null && currentNavigationFilter != null) { if (filteredTorrents != null && currentNavigationFilter != null) {
@ -209,7 +228,7 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
} }
// Sort the list of filtered torrents // Sort the list of filtered torrents
Collections.sort(filteredTorrents, new TorrentsComparator(serverType, this.currentSortOrder, Collections.sort(filteredTorrents, new TorrentsComparator(daemonType, this.currentSortOrder,
this.currentSortDescending)); this.currentSortDescending));
((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents); ((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents);

6
lib/src/org/transdroid/daemon/Daemon.java

@ -314,7 +314,7 @@ public enum Daemon {
} }
public static boolean supportsLabels(Daemon type) { public static boolean supportsLabels(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == Dummy; // || type == Vuze return type == uTorrent || type == BitTorrent || type == Deluge || type == BitComet || type == rTorrent || type == Dummy;
} }
public static boolean supportsSetLabel(Daemon type) { public static boolean supportsSetLabel(Daemon type) {
@ -333,6 +333,10 @@ public enum Daemon {
return type == uTorrent || type == BitTorrent || type == Deluge || type == Dummy; return type == uTorrent || type == BitTorrent || type == Deluge || type == Dummy;
} }
public static boolean supportsForceRecheck(Daemon type) {
return type == uTorrent || type == BitTorrent || type == Deluge || type == rTorrent || type == Dummy;
}
public static boolean supportsExtraPassword(Daemon type) { public static boolean supportsExtraPassword(Daemon type) {
return type == Deluge; return type == Deluge;
} }

3
lib/src/org/transdroid/daemon/DaemonMethod.java

@ -43,7 +43,8 @@ public enum DaemonMethod {
GetTorrentDetails (18), GetTorrentDetails (18),
SetTrackers (19), SetTrackers (19),
SetAlternativeMode (20), SetAlternativeMode (20),
GetStats (21); GetStats (21),
ForceRecheck (22);
private int code; private int code;
private static final Map<Integer,DaemonMethod> lookup = new HashMap<Integer,DaemonMethod>(); private static final Map<Integer,DaemonMethod> lookup = new HashMap<Integer,DaemonMethod>();

8
lib/src/org/transdroid/daemon/Deluge/DelugeAdapter.java

@ -112,6 +112,7 @@ public class DelugeAdapter implements IDaemonAdapter {
//private static final String RPC_METHOD_SETOPTIONS = "core.set_torrent_options"; //private static final String RPC_METHOD_SETOPTIONS = "core.set_torrent_options";
private static final String RPC_METHOD_MOVESTORAGE = "core.move_storage"; private static final String RPC_METHOD_MOVESTORAGE = "core.move_storage";
private static final String RPC_METHOD_SETTRACKERS = "core.set_torrent_trackers"; private static final String RPC_METHOD_SETTRACKERS = "core.set_torrent_trackers";
private static final String RPC_METHOD_FORCERECHECK = "core.force_recheck";
private static final String RPC_NAME = "name"; private static final String RPC_NAME = "name";
private static final String RPC_STATUS = "state"; private static final String RPC_STATUS = "state";
@ -397,6 +398,13 @@ public class DelugeAdapter implements IDaemonAdapter {
params.put(trackers); params.put(trackers);
makeRequest(buildRequest(RPC_METHOD_SETTRACKERS, params)); makeRequest(buildRequest(RPC_METHOD_SETTRACKERS, params));
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case ForceRecheck:
// Pause a torrent
makeRequest(buildRequest(RPC_METHOD_FORCERECHECK,
((new JSONArray()).put((new JSONArray()).put(task.getTargetTorrent().getUniqueID())))));
return new DaemonTaskSuccessResult(task);
default: default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType())); return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));

12
lib/src/org/transdroid/daemon/DummyAdapter.java

@ -33,6 +33,7 @@ import org.transdroid.daemon.task.DaemonTask;
import org.transdroid.daemon.task.DaemonTaskFailureResult; import org.transdroid.daemon.task.DaemonTaskFailureResult;
import org.transdroid.daemon.task.DaemonTaskResult; import org.transdroid.daemon.task.DaemonTaskResult;
import org.transdroid.daemon.task.DaemonTaskSuccessResult; import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import org.transdroid.daemon.task.ForceRecheckTask;
import org.transdroid.daemon.task.GetFileListTask; import org.transdroid.daemon.task.GetFileListTask;
import org.transdroid.daemon.task.GetFileListTaskSuccessResult; import org.transdroid.daemon.task.GetFileListTaskSuccessResult;
import org.transdroid.daemon.task.GetStatsTask; import org.transdroid.daemon.task.GetStatsTask;
@ -269,6 +270,17 @@ public class DummyAdapter implements IDaemonAdapter {
trackersList = new ArrayList<String>(((SetTrackersTask)task).getNewTrackers()); trackersList = new ArrayList<String>(((SetTrackersTask)task).getNewTrackers());
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case ForceRecheck:
ForceRecheckTask recheckTask = (ForceRecheckTask) task;
// Pretend we rechecked this task by pausing it (or stopping, if it is paused) so we can see the result
if (recheckTask.getTargetTorrent().getStatusCode() == TorrentStatus.Paused) {
recheckTask.getTargetTorrent().mimicStop();
} else {
recheckTask.getTargetTorrent().mimicPause();
}
return new DaemonTaskSuccessResult(task);
case SetDownloadLocation: case SetDownloadLocation:
task.getTargetTorrent().mimicNewLocation(((SetDownloadLocationTask) task).getNewLocation()); task.getTargetTorrent().mimicNewLocation(((SetDownloadLocationTask) task).getNewLocation());

6
lib/src/org/transdroid/daemon/Rtorrent/RtorrentAdapter.java

@ -225,6 +225,12 @@ public class RtorrentAdapter implements IDaemonAdapter {
makeRtorrentCall("d.set_custom1", new String[] { task.getTargetTorrent().getUniqueID(), labelTask.getNewLabel() }); makeRtorrentCall("d.set_custom1", new String[] { task.getTargetTorrent().getUniqueID(), labelTask.getNewLabel() });
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case ForceRecheck:
// Force re-check of data of a torrent
makeRtorrentCall("d.check_hash", new String[] { task.getTargetTorrent().getUniqueID() });
return new DaemonTaskSuccessResult(task);
default: default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType())); return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));
} }

4
lib/src/org/transdroid/daemon/Torrent.java

@ -250,6 +250,10 @@ public final class Torrent implements Parcelable, Comparable<Torrent> {
public void mimicNewLabel(String newLabel) { public void mimicNewLabel(String newLabel) {
label = newLabel; label = newLabel;
} }
public void mimicCheckingStatus() {
statusCode = TorrentStatus.Checking;
}
public void mimicNewLocation(String newLocation) { public void mimicNewLocation(String newLocation) {
locationDir = newLocation; locationDir = newLocation;

10
lib/src/org/transdroid/daemon/Utorrent/UtorrentAdapter.java

@ -41,12 +41,12 @@ import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.DaemonException.ExceptionType; import org.transdroid.daemon.DaemonException.ExceptionType;
import org.transdroid.daemon.DaemonSettings; import org.transdroid.daemon.DaemonSettings;
import org.transdroid.daemon.IDaemonAdapter; import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Label;
import org.transdroid.daemon.Priority; import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent; import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentDetails; import org.transdroid.daemon.TorrentDetails;
import org.transdroid.daemon.TorrentFile; import org.transdroid.daemon.TorrentFile;
import org.transdroid.daemon.TorrentStatus; import org.transdroid.daemon.TorrentStatus;
import org.transdroid.daemon.Label;
import org.transdroid.daemon.task.AddByFileTask; import org.transdroid.daemon.task.AddByFileTask;
import org.transdroid.daemon.task.AddByMagnetUrlTask; import org.transdroid.daemon.task.AddByMagnetUrlTask;
import org.transdroid.daemon.task.AddByUrlTask; import org.transdroid.daemon.task.AddByUrlTask;
@ -248,7 +248,13 @@ public class UtorrentAdapter implements IDaemonAdapter {
makeUtorrentRequest("&action=setprops" + RPC_URL_HASH + trackersTask.getTargetTorrent().getUniqueID() + makeUtorrentRequest("&action=setprops" + RPC_URL_HASH + trackersTask.getTargetTorrent().getUniqueID() +
"&s=trackers&v=" + URLEncoder.encode(newTrackersText, "UTF-8")); "&s=trackers&v=" + URLEncoder.encode(newTrackersText, "UTF-8"));
return new DaemonTaskSuccessResult(task); return new DaemonTaskSuccessResult(task);
case ForceRecheck:
// Force re-check of data on a torrent
makeUtorrentRequest("&action=recheck" + RPC_URL_HASH + task.getTargetTorrent().getUniqueID());
return new DaemonTaskSuccessResult(task);
default: default:
return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType())); return new DaemonTaskFailureResult(task, new DaemonException(ExceptionType.MethodUnsupported, task.getMethod() + " is not supported by " + getType()));
} }

31
lib/src/org/transdroid/daemon/task/ForceRecheckTask.java

@ -0,0 +1,31 @@
/*
* This file is part of Transdroid <http://www.transdroid.org>
*
* Transdroid 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 3 of the License, or
* (at your option) any later version.
*
* Transdroid 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 Transdroid. If not, see <http://www.gnu.org/licenses/>.
*
*/
package org.transdroid.daemon.task;
import org.transdroid.daemon.DaemonMethod;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.Torrent;
public class ForceRecheckTask extends DaemonTask {
protected ForceRecheckTask(IDaemonAdapter adapter, Torrent targetTorrent) {
super(adapter, DaemonMethod.ForceRecheck, targetTorrent, null);
}
public static ForceRecheckTask create(IDaemonAdapter adapter, Torrent targetTorrent) {
return new ForceRecheckTask(adapter, targetTorrent);
}
}
Loading…
Cancel
Save