*/\r
public boolean removeIUPendingFile(String localPath, String accountName) {\r
return mDB.delete(TABLE_INSTANT_UPLOAD,\r
- "path = ? and account = ?",\r
- new String[]{ localPath, accountName }) != 0;\r
+ "path = ?",\r
+ new String[]{ localPath }) != 0;\r
\r
}\r
\r
@Override
public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "Received: " + intent.getAction());
if (intent.getAction().equals(android.net.ConnectivityManager.CONNECTIVITY_ACTION)) {
handleConnectivityAction(context, intent);
} else if (intent.getAction().equals(NEW_PHOTO_ACTION)) {
return;
}
- Cursor c = context.getContentResolver().query(intent.getData(), CONTENT_PROJECTION, null, null, null);
+ Cursor c = context.getContentResolver().query(intent.getData(),
+ CONTENT_PROJECTION,
+ null, null, null);
if (!c.moveToFirst()) {
Log.e(TAG, "Couldn't resolve given uri: " + intent.getDataString());
String mime_type = c.getString(c.getColumnIndex(Media.MIME_TYPE));
c.close();
+ Log.e(TAG, file_path+"");
if (!isOnline(context) ||
(instantUploadViaWiFiOnly(context) && !isConnectedViaWiFi(context))) {
// On the other hand this might be only for dynamicly registered
// broadcast receivers, needs investigation.
IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
- context.registerReceiver(this, filter);
+ context.getApplicationContext().registerReceiver(this, filter);
Intent i = new Intent(context, FileUploader.class);
i.putExtra(FileUploader.KEY_ACCOUNT, account);
DbHandler db = new DbHandler(context);
Cursor c = db.getAwaitingFiles();
if (c.moveToFirst()) {
+ IntentFilter filter = new IntentFilter(FileUploader.UPLOAD_FINISH_MESSAGE);
+ context.getApplicationContext().registerReceiver(this, filter);
do {
String account_name = c.getString(c.getColumnIndex("account"));
String file_path = c.getString(c.getColumnIndex("path"));
import org.apache.jackrabbit.webdav.DavException;\r
import org.apache.jackrabbit.webdav.MultiStatus;\r
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;\r
+import org.json.JSONObject;\r
\r
+import com.owncloud.android.AccountUtils;\r
import com.owncloud.android.R;\r
+import com.owncloud.android.authenticator.AccountAuthenticator;\r
import com.owncloud.android.datamodel.FileDataStorageManager;\r
import com.owncloud.android.datamodel.OCFile;\r
import com.owncloud.android.files.services.FileDownloader;\r
+import com.owncloud.android.utils.OwnCloudVersion;\r
\r
import android.accounts.Account;\r
import android.app.Notification;\r
mDelaysIndex = 0;\r
mDelaysCount = 0;\r
*/\r
- \r
- \r
+\r
Log.d(TAG, "syncing owncloud account " + account.name);\r
\r
sendStickyBroadcast(true, null); // message to signal the start to the UI\r
+ \r
+ updateOCVersion();\r
\r
String uri = getUri().toString();\r
PropFindMethod query = null;\r
fetchData(uri, syncResult, file.getFileId());\r
}\r
}\r
- \r
+\r
} else {\r
syncResult.stats.numAuthExceptions++;\r
}\r
}\r
}\r
\r
- \r
+ private void updateOCVersion() {\r
+ String statUrl = getAccountManager().getUserData(getAccount(), AccountAuthenticator.KEY_OC_BASE_URL);\r
+ statUrl += AccountUtils.STATUS_PATH;\r
+ \r
+ try {\r
+ String result = getClient().getResultAsString(statUrl);\r
+ if (result != null) {\r
+ try {\r
+ JSONObject json = new JSONObject(result);\r
+ if (json != null && json.getString("version") != null) {\r
+ OwnCloudVersion ocver = new OwnCloudVersion(json.getString("version"));\r
+ if (ocver.isVersionValid()) {\r
+ getAccountManager().setUserData(getAccount(), AccountAuthenticator.KEY_OC_VERSION, ocver.toString());\r
+ Log.d(TAG, "Got new OC version " + ocver.toString());\r
+ } else {\r
+ Log.w(TAG, "Invalid version number received from server: " + json.getString("version"));\r
+ }\r
+ }\r
+ } catch (Throwable e) {\r
+ Log.w(TAG, "Couldn't parse version response", e);\r
+ }\r
+ } else {\r
+ Log.w(TAG, "Problem while getting ocversion from server");\r
+ }\r
+ } catch (Exception e) {\r
+ Log.e(TAG, "Problem getting response from server", e);\r
+ }\r
+ }\r
}\r
return;\r
}\r
// a new chance to get the mDownloadBinder through getFileDownloadBinder() - THIS IS A MESS\r
- mFileList.listDirectory();\r
+ if (mFileList != null)\r
+ mFileList.listDirectory();\r
if (mDualPane) {\r
FileDetailFragment fragment = (FileDetailFragment) getSupportFragmentManager().findFragmentByTag(FileDetailFragment.FTAG);\r
if (fragment != null)\r
fragment.updateFileDetails();\r
}\r
- \r
}\r
\r
@Override\r
*/
public void listDirectory(OCFile directory) {
DataStorageManager storageManager = mContainerActivity.getStorageManager();
+ if (storageManager != null) {
- // Check input parameters for null
- if(directory == null){
- if(mFile != null){
- directory = mFile;
- } else {
- directory = storageManager.getFileByPath("/");
- if (directory == null) return; // no files, wait for sync
+ // Check input parameters for null
+ if(directory == null){
+ if(mFile != null){
+ directory = mFile;
+ } else {
+ directory = storageManager.getFileByPath("/");
+ if (directory == null) return; // no files, wait for sync
+ }
}
- }
- // If that's not a directory -> List its parent
- if(!directory.isDirectory()){
- Log.w(TAG, "You see, that is not a directory -> " + directory.toString());
- directory = storageManager.getFileById(directory.getParentId());
- }
+ // If that's not a directory -> List its parent
+ if(!directory.isDirectory()){
+ Log.w(TAG, "You see, that is not a directory -> " + directory.toString());
+ directory = storageManager.getFileById(directory.getParentId());
+ }
- mFile = directory;
- mAdapter.swapDirectory(mFile);
- mList.setSelectionFromTop(0, 0);
- mList.invalidate();
+ mFile = directory;
+ mAdapter.swapDirectory(mFile);
+ mList.setSelectionFromTop(0, 0);
+ mList.invalidate();
+ }
}
public Uri getBaseUri() {\r
return mUri;\r
}\r
+\r
+ public String getResultAsString(String targetUrl) {\r
+ String getResult = null;\r
+ try {\r
+ GetMethod get = new GetMethod(targetUrl);\r
+ int status = executeMethod(get);\r
+ if (status == HttpStatus.SC_OK) {\r
+ getResult = get.getResponseBodyAsString();\r
+ }\r
+ } catch (Exception e) {\r
+ Log.e(TAG, "Error while getting requested file: " + targetUrl, e);\r
+ getResult = null;\r
+ }\r
+ return getResult;\r
+ }\r
\r
}\r