|
@@ -26,7 +26,7 @@ import java.util.concurrent.ConcurrentMap;
|
|
import com.owncloud.android.MainApp;
|
|
import com.owncloud.android.MainApp;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.R;
|
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
|
import com.owncloud.android.datamodel.FileDataStorageManager;
|
|
-import com.owncloud.android.datamodel.OCFile;
|
|
|
|
|
|
+import com.owncloud.android.files.services.FileDownloader;
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
import com.owncloud.android.lib.common.OwnCloudAccount;
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
import com.owncloud.android.lib.common.OwnCloudClient;
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
import com.owncloud.android.lib.common.OwnCloudClientManagerFactory;
|
|
@@ -51,6 +51,7 @@ import com.owncloud.android.operations.RenameFileOperation;
|
|
import com.owncloud.android.operations.SynchronizeFileOperation;
|
|
import com.owncloud.android.operations.SynchronizeFileOperation;
|
|
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
|
import com.owncloud.android.operations.SynchronizeFolderOperation;
|
|
import com.owncloud.android.operations.UnshareLinkOperation;
|
|
import com.owncloud.android.operations.UnshareLinkOperation;
|
|
|
|
+import com.owncloud.android.utils.FileStorageUtils;
|
|
|
|
|
|
import android.accounts.Account;
|
|
import android.accounts.Account;
|
|
import android.accounts.AccountsException;
|
|
import android.accounts.AccountsException;
|
|
@@ -179,6 +180,7 @@ public class OperationsService extends Service {
|
|
Pair<Target, RemoteOperation> itemToQueue = newOperation(intent);
|
|
Pair<Target, RemoteOperation> itemToQueue = newOperation(intent);
|
|
if (itemToQueue != null) {
|
|
if (itemToQueue != null) {
|
|
mSyncFolderHandler.add(account, remotePath, (SynchronizeFolderOperation)itemToQueue.second);
|
|
mSyncFolderHandler.add(account, remotePath, (SynchronizeFolderOperation)itemToQueue.second);
|
|
|
|
+ sendBroadcastNewSyncFolder(account, remotePath);
|
|
Message msg = mSyncFolderHandler.obtainMessage();
|
|
Message msg = mSyncFolderHandler.obtainMessage();
|
|
msg.arg1 = startId;
|
|
msg.arg1 = startId;
|
|
msg.obj = itemSyncKey;
|
|
msg.obj = itemSyncKey;
|
|
@@ -203,6 +205,19 @@ public class OperationsService extends Service {
|
|
return START_NOT_STICKY;
|
|
return START_NOT_STICKY;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * TODO remove this method when "folder synchronization" replaces "folder download"; this is a fast and ugly
|
|
|
|
+ * patch.
|
|
|
|
+ */
|
|
|
|
+ private void sendBroadcastNewSyncFolder(Account account, String remotePath) {
|
|
|
|
+ Intent added = new Intent(FileDownloader.getDownloadAddedMessage());
|
|
|
|
+ added.putExtra(FileDownloader.ACCOUNT_NAME, account.name);
|
|
|
|
+ added.putExtra(FileDownloader.EXTRA_REMOTE_PATH, remotePath);
|
|
|
|
+ added.putExtra(FileDownloader.EXTRA_FILE_PATH, FileStorageUtils.getSavePath(account.name) + remotePath);
|
|
|
|
+ sendStickyBroadcast(added);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onDestroy() {
|
|
public void onDestroy() {
|
|
//Log_OC.wtf(TAG, "onDestroy init" );
|
|
//Log_OC.wtf(TAG, "onDestroy init" );
|
|
@@ -359,6 +374,19 @@ public class OperationsService extends Service {
|
|
//Log_OC.wtf(TAG, "Not finished yet");
|
|
//Log_OC.wtf(TAG, "Not finished yet");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns True when the file described by 'file' in the ownCloud account 'account' is downloading or waiting to download.
|
|
|
|
+ *
|
|
|
|
+ * If 'file' is a directory, returns 'true' if some of its descendant files is downloading or waiting to download.
|
|
|
|
+ *
|
|
|
|
+ * @param account ownCloud account where the remote file is stored.
|
|
|
|
+ * @param file A file that could be affected
|
|
|
|
+ */
|
|
|
|
+ public boolean isSynchronizing(Account account, String remotePath) {
|
|
|
|
+ return mSyncFolderHandler.isSynchronizing(account, remotePath);
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -389,6 +417,16 @@ public class OperationsService extends Service {
|
|
mService = service;
|
|
mService = service;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ public boolean isSynchronizing(Account account, String remotePath) {
|
|
|
|
+ if (account == null || remotePath == null) return false;
|
|
|
|
+ String targetKey = buildRemoteName(account, remotePath);
|
|
|
|
+ synchronized (mPendingOperations) {
|
|
|
|
+ return (mPendingOperations.containsKey(targetKey));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void handleMessage(Message msg) {
|
|
public void handleMessage(Message msg) {
|
|
Pair<Account, String> itemSyncKey = (Pair<Account, String>) msg.obj;
|
|
Pair<Account, String> itemSyncKey = (Pair<Account, String>) msg.obj;
|