Browse Source

last sync field for oc file

Bartek Przybylski 13 năm trước cách đây
mục cha
commit
65523409c7

+ 2 - 0
src/eu/alefzero/owncloud/datamodel/DataStorageManager.java

@@ -33,4 +33,6 @@ public interface DataStorageManager {
     public boolean saveFile(OCFile file);
 
     public Vector<OCFile> getDirectoryContent(OCFile f);
+    
+    public void removeFile(OCFile file);
 }

+ 13 - 0
src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java

@@ -286,5 +286,18 @@ public class FileDataStorageManager implements DataStorageManager {
         }
         return file;
     }
+    
+    public void removeFile(OCFile file) {
+        Uri file_uri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI, ""+file.getFileId());
+        if (getContentProvider() != null) {
+            try {
+                getContentProvider().delete(file_uri, null, null);
+            } catch (RemoteException e) {
+                e.printStackTrace();
+            }
+        } else {
+            getContentResolver().delete(file_uri, null, null);
+        }
+    }
 
 }

+ 12 - 2
src/eu/alefzero/owncloud/datamodel/OCFile.java

@@ -46,6 +46,7 @@ public class OCFile implements Parcelable {
     private String mLocalPath;
     private String mMimeType;
     private boolean mNeedsUpdating;
+    private long mLastSyncDate;
 
     /**
      * Create new {@link OCFile} with given path
@@ -227,6 +228,7 @@ public class OCFile implements Parcelable {
         mLength = 0;
         mCreationTimestamp = 0;
         mModifiedTimestamp = 0;
+        mLastSyncDate = 0;
     }
 
     /**
@@ -291,6 +293,14 @@ public class OCFile implements Parcelable {
     public boolean needsUpdatingWhileSaving() {
         return mNeedsUpdating;
     }
+    
+    public long getLastSyncDate() {
+        return mLastSyncDate;
+    }
+    
+    public void setLastSyncDate(long lastSyncDate) {
+        mLastSyncDate = lastSyncDate;
+    }
 
     @Override
     public int describeContents() {
@@ -307,8 +317,8 @@ public class OCFile implements Parcelable {
         dest.writeString(mRemotePath);
         dest.writeString(mLocalPath);
         dest.writeString(mMimeType);
-        dest.writeInt(mNeedsUpdating ? 0 : 1); // No writeBoolean method exists
-                                               // - yay :D
+        dest.writeInt(mNeedsUpdating ? 1 : 0);
+        dest.writeLong(mLastSyncDate);
     }
 
 }

+ 1 - 0
src/eu/alefzero/owncloud/db/ProviderMeta.java

@@ -57,6 +57,7 @@ public class ProviderMeta {
         public static final String FILE_STORAGE_PATH = "media_path";
         public static final String FILE_PATH = "path";
         public static final String FILE_ACCOUNT_OWNER = "file_owner";
+        public static final String FILE_LAST_SYNC_DATE = "last_sync_date";
 
         public static final String DEFAULT_SORT_ORDER = FILE_NAME
                 + " collate nocase asc";

+ 4 - 1
src/eu/alefzero/owncloud/providers/FileContentProvider.java

@@ -66,6 +66,8 @@ public class FileContentProvider extends ContentProvider {
                 ProviderTableMeta.FILE_CONTENT_TYPE);
         mProjectionMap.put(ProviderTableMeta.FILE_STORAGE_PATH,
                 ProviderTableMeta.FILE_STORAGE_PATH);
+        mProjectionMap.put(ProviderTableMeta.FILE_LAST_SYNC_DATE,
+                ProviderTableMeta.FILE_LAST_SYNC_DATE);
     }
 
     private static final int SINGLE_FILE = 1;
@@ -207,7 +209,8 @@ public class FileContentProvider extends ContentProvider {
                     + ProviderTableMeta.FILE_CONTENT_TYPE + " TEXT, "
                     + ProviderTableMeta.FILE_CONTENT_LENGTH + " INTEGER, "
                     + ProviderTableMeta.FILE_STORAGE_PATH + " TEXT, "
-                    + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT);");
+                    + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT, "
+                    + ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER );");
         }
 
         @Override