last sync field for oc file
authorBartek Przybylski <bart.p.pl@gmail.com>
Sat, 19 May 2012 16:30:03 +0000 (18:30 +0200)
committerBartek Przybylski <bart.p.pl@gmail.com>
Sat, 19 May 2012 16:30:03 +0000 (18:30 +0200)
src/eu/alefzero/owncloud/datamodel/DataStorageManager.java
src/eu/alefzero/owncloud/datamodel/FileDataStorageManager.java
src/eu/alefzero/owncloud/datamodel/OCFile.java
src/eu/alefzero/owncloud/db/ProviderMeta.java
src/eu/alefzero/owncloud/providers/FileContentProvider.java

index 8d7d2ee..e4c385f 100644 (file)
@@ -33,4 +33,6 @@ public interface DataStorageManager {
     public boolean saveFile(OCFile file);
 
     public Vector<OCFile> getDirectoryContent(OCFile f);
+    
+    public void removeFile(OCFile file);
 }
index 80072bb..4ec5798 100644 (file)
@@ -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);
+        }
+    }
 
 }
index e2cebcf..7e8f428 100644 (file)
@@ -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);
     }
 
 }
index aa67109..79f285a 100644 (file)
@@ -57,6 +57,7 @@ public class ProviderMeta {
         public static final String FILE_STORAGE_PATH = "media_path";\r
         public static final String FILE_PATH = "path";\r
         public static final String FILE_ACCOUNT_OWNER = "file_owner";\r
+        public static final String FILE_LAST_SYNC_DATE = "last_sync_date";\r
 \r
         public static final String DEFAULT_SORT_ORDER = FILE_NAME\r
                 + " collate nocase asc";\r
index c1ecef3..06338df 100644 (file)
@@ -66,6 +66,8 @@ public class FileContentProvider extends ContentProvider {
                 ProviderTableMeta.FILE_CONTENT_TYPE);\r
         mProjectionMap.put(ProviderTableMeta.FILE_STORAGE_PATH,\r
                 ProviderTableMeta.FILE_STORAGE_PATH);\r
+        mProjectionMap.put(ProviderTableMeta.FILE_LAST_SYNC_DATE,\r
+                ProviderTableMeta.FILE_LAST_SYNC_DATE);\r
     }\r
 \r
     private static final int SINGLE_FILE = 1;\r
@@ -207,7 +209,8 @@ public class FileContentProvider extends ContentProvider {
                     + ProviderTableMeta.FILE_CONTENT_TYPE + " TEXT, "\r
                     + ProviderTableMeta.FILE_CONTENT_LENGTH + " INTEGER, "\r
                     + ProviderTableMeta.FILE_STORAGE_PATH + " TEXT, "\r
-                    + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT);");\r
+                    + ProviderTableMeta.FILE_ACCOUNT_OWNER + " TEXT, "\r
+                    + ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER );");\r
         }\r
 \r
         @Override\r