- * 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.
+ * it under the terms of the GNU General Public License version 2,
+ * as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
import com.owncloud.android.files.OwnCloudFileObserver;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.utils.FileStorageUtils;
import com.owncloud.android.files.OwnCloudFileObserver;
import com.owncloud.android.operations.SynchronizeFileOperation;
import com.owncloud.android.utils.FileStorageUtils;
import android.database.Cursor;
import android.os.Binder;
import android.os.IBinder;
import android.database.Cursor;
import android.os.Binder;
import android.os.IBinder;
private static Map<String, OwnCloudFileObserver> mObserversMap;
private static DownloadCompletedReceiverBis mDownloadReceiver;
private IBinder mBinder = new LocalBinder();
private static Map<String, OwnCloudFileObserver> mObserversMap;
private static DownloadCompletedReceiverBis mDownloadReceiver;
private IBinder mBinder = new LocalBinder();
public class LocalBinder extends Binder {
FileObserverService getService() {
return FileObserverService.this;
public class LocalBinder extends Binder {
FileObserverService getService() {
return FileObserverService.this;
- filter.addAction(FileDownloader.DOWNLOAD_ADDED_MESSAGE);
- filter.addAction(FileDownloader.DOWNLOAD_FINISH_MESSAGE);
+ filter.addAction(FileDownloader.getDownloadAddedMessage());
+ filter.addAction(FileDownloader.getDownloadFinishMessage());
registerReceiver(mDownloadReceiver, filter);
mObserversMap = new HashMap<String, OwnCloudFileObserver>();
registerReceiver(mDownloadReceiver, filter);
mObserversMap = new HashMap<String, OwnCloudFileObserver>();
super.onDestroy();
unregisterReceiver(mDownloadReceiver);
mObserversMap = null; // TODO study carefully the life cycle of Services to grant the best possible observance
super.onDestroy();
unregisterReceiver(mDownloadReceiver);
mObserversMap = null; // TODO study carefully the life cycle of Services to grant the best possible observance
ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?",
new String[] {String.valueOf(1)},
null);
ProviderTableMeta.FILE_KEEP_IN_SYNC + " = ?",
new String[] {String.valueOf(1)},
null);
OwnCloudFileObserver observer =
new OwnCloudFileObserver( path,
OwnCloudFileObserver observer =
new OwnCloudFileObserver( path,
account,
getApplicationContext(),
OwnCloudFileObserver.CHANGES_ONLY);
mObserversMap.put(path, observer);
if (new File(path).exists()) {
observer.startWatching();
account,
getApplicationContext(),
OwnCloudFileObserver.CHANGES_ONLY);
mObserversMap.put(path, observer);
if (new File(path).exists()) {
observer.startWatching();
OwnCloudFileObserver observer = mObserversMap.get(localPath);
if (observer == null) {
/// the local file was never registered to observe before
OwnCloudFileObserver observer = mObserversMap.get(localPath);
if (observer == null) {
/// the local file was never registered to observe before
account,
getApplicationContext(),
OwnCloudFileObserver.CHANGES_ONLY);
mObserversMap.put(localPath, observer);
account,
getApplicationContext(),
OwnCloudFileObserver.CHANGES_ONLY);
mObserversMap.put(localPath, observer);
String downloadPath = intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH);
OwnCloudFileObserver observer = mObserversMap.get(downloadPath);
if (observer != null) {
String downloadPath = intent.getStringExtra(FileDownloader.EXTRA_FILE_PATH);
OwnCloudFileObserver observer = mObserversMap.get(downloadPath);
if (observer != null) {
- if (intent.getAction().equals(FileDownloader.DOWNLOAD_FINISH_MESSAGE) &&
- new File(downloadPath).exists()) { // the download could be successful, or not; in both cases, the file could be down, due to a former download or upload
+ if (intent.getAction().equals(FileDownloader.getDownloadFinishMessage()) &&
+ new File(downloadPath).exists()) { // the download could be successful. not; in both cases, the file could be down, due to a former download or upload