projects
/
pub
/
Android
/
ownCloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into refresh_folder_contents_when_browsed_into
[pub/Android/ownCloud.git]
/
src
/
com
/
owncloud
/
android
/
files
/
services
/
FileUploader.java
diff --git
a/src/com/owncloud/android/files/services/FileUploader.java
b/src/com/owncloud/android/files/services/FileUploader.java
index
c606b68
..
4d2df0f
100644
(file)
--- a/
src/com/owncloud/android/files/services/FileUploader.java
+++ b/
src/com/owncloud/android/files/services/FileUploader.java
@@
-29,6
+29,7
@@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.http.HttpStatus;
import java.util.concurrent.ConcurrentMap;
import org.apache.http.HttpStatus;
+import org.apache.jackrabbit.webdav.DavConstants;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
@@
-70,6
+71,7
@@
import android.webkit.MimeTypeMap;
import android.widget.RemoteViews;
import com.owncloud.android.Log_OC;
import android.widget.RemoteViews;
import com.owncloud.android.Log_OC;
+import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.db.DbHandler;
import com.owncloud.android.ui.activity.FailedUploadActivity;
import com.owncloud.android.R;
import com.owncloud.android.db.DbHandler;
import com.owncloud.android.ui.activity.FailedUploadActivity;
@@
-83,7
+85,7
@@
import eu.alefzero.webdav.WebdavClient;
public class FileUploader extends Service implements OnDatatransferProgressListener {
public class FileUploader extends Service implements OnDatatransferProgressListener {
- p
ublic
static final String UPLOAD_FINISH_MESSAGE = "UPLOAD_FINISH";
+ p
rivate
static final String UPLOAD_FINISH_MESSAGE = "UPLOAD_FINISH";
public static final String EXTRA_UPLOAD_RESULT = "RESULT";
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
public static final String EXTRA_OLD_REMOTE_PATH = "OLD_REMOTE_PATH";
public static final String EXTRA_UPLOAD_RESULT = "RESULT";
public static final String EXTRA_REMOTE_PATH = "REMOTE_PATH";
public static final String EXTRA_OLD_REMOTE_PATH = "OLD_REMOTE_PATH";
@@
-126,6
+128,11
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
private int mLastPercent;
private RemoteViews mDefaultNotificationContentView;
private int mLastPercent;
private RemoteViews mDefaultNotificationContentView;
+
+ public static String getUploadFinishMessage() {
+ return FileUploader.class.getName().toString() + UPLOAD_FINISH_MESSAGE;
+ }
+
/**
* Builds a key for mPendingUploads from the account and file to upload
*
/**
* Builds a key for mPendingUploads from the account and file to upload
*
@@
-376,7
+383,7
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
return false;
String targetKey = buildRemoteName(account, file);
synchronized (mPendingUploads) {
return false;
String targetKey = buildRemoteName(account, file);
synchronized (mPendingUploads) {
- if (file.is
Directory
()) {
+ if (file.is
Folder
()) {
// this can be slow if there are many uploads :(
Iterator<String> it = mPendingUploads.keySet().iterator();
boolean found = false;
// this can be slow if there are many uploads :(
Iterator<String> it = mPendingUploads.keySet().iterator();
boolean found = false;
@@
-529,6
+536,11
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
mPendingUploads.remove(uploadKey);
Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map.");
}
mPendingUploads.remove(uploadKey);
Log_OC.i(TAG, "Remove CurrentUploadItem from pending upload Item Map.");
}
+ if (uploadResult.isException()) {
+ // enforce the creation of a new client object for next uploads; this grant that a new socket will
+ // be created in the future if the current exception is due to an abrupt lose of network connection
+ mUploadClient = null;
+ }
}
/// notify result
}
/// notify result
@@
-611,8
+623,9
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
PropFindMethod propfind = null;
RemoteOperationResult result = null;
try {
PropFindMethod propfind = null;
RemoteOperationResult result = null;
try {
- propfind = new PropFindMethod(mUploadClient.getBaseUri()
- + WebdavUtils.encodePath(mCurrentUpload.getRemotePath()));
+ propfind = new PropFindMethod(mUploadClient.getBaseUri() + WebdavUtils.encodePath(mCurrentUpload.getRemotePath()),
+ DavConstants.PROPFIND_ALL_PROP,
+ DavConstants.DEPTH_0);
int status = mUploadClient.executeMethod(propfind);
boolean isMultiStatus = (status == HttpStatus.SC_MULTI_STATUS);
if (isMultiStatus) {
int status = mUploadClient.executeMethod(propfind);
boolean isMultiStatus = (status == HttpStatus.SC_MULTI_STATUS);
if (isMultiStatus) {
@@
-717,12
+730,7
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
/// includes a pending intent in the notification showing the details view of the file
mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
/// includes a pending intent in the notification showing the details view of the file
- Intent showDetailsIntent = null;
- if (PreviewImageFragment.canBePreviewed(upload.getFile())) {
- showDetailsIntent = new Intent(this, PreviewImageActivity.class);
- } else {
- showDetailsIntent = new Intent(this, FileDisplayActivity.class);
- }
+ Intent showDetailsIntent = new Intent(this, FileDisplayActivity.class);
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
showDetailsIntent.putExtra(FileActivity.EXTRA_FILE, upload.getFile());
showDetailsIntent.putExtra(FileActivity.EXTRA_ACCOUNT, upload.getAccount());
showDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
@@
-814,7
+822,7
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
//(uploadResult.isTemporalRedirection() && uploadResult.isIdPRedirection() &&
(uploadResult.isIdPRedirection() &&
boolean needsToUpdateCredentials = (uploadResult.getCode() == ResultCode.UNAUTHORIZED ||
//(uploadResult.isTemporalRedirection() && uploadResult.isIdPRedirection() &&
(uploadResult.isIdPRedirection() &&
-
AccountAuthenticator.AUTH_TOKEN_TYPE_SAML_WEB_SSO_SESSION_COOKIE
.equals(mUploadClient.getAuthTokenType())));
+
MainApp.getAuthTokenTypeSamlSessionCookie()
.equals(mUploadClient.getAuthTokenType())));
if (needsToUpdateCredentials) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
if (needsToUpdateCredentials) {
// let the user update credentials with one click
Intent updateAccountCredentials = new Intent(this, AuthenticatorActivity.class);
@@
-897,7
+905,7
@@
public class FileUploader extends Service implements OnDatatransferProgressListe
* @param uploadResult Result of the upload operation
*/
private void sendFinalBroadcast(UploadFileOperation upload, RemoteOperationResult uploadResult) {
* @param uploadResult Result of the upload operation
*/
private void sendFinalBroadcast(UploadFileOperation upload, RemoteOperationResult uploadResult) {
- Intent end = new Intent(
UPLOAD_FINISH_MESSAGE
);
+ Intent end = new Intent(
getUploadFinishMessage()
);
end.putExtra(EXTRA_REMOTE_PATH, upload.getRemotePath()); // real remote
// path, after
// possible
end.putExtra(EXTRA_REMOTE_PATH, upload.getRemotePath()); // real remote
// path, after
// possible