Browse Source

Upload improvements: better control of errors, updated use of status notifications, removed toast notifications, new isUploading(...) mehtod

David A. Velasco 12 years ago
parent
commit
f3ba107585

+ 1 - 1
AndroidManifest.xml

@@ -18,7 +18,7 @@
  -->
 <manifest package="eu.alefzero.owncloud"
     android:versionCode="1"
-    android:versionName="0.1.185B" xmlns:android="http://schemas.android.com/apk/res/android">
+    android:versionName="0.1.186B" xmlns:android="http://schemas.android.com/apk/res/android">
 
     <uses-permission android:name="android.permission.GET_ACCOUNTS" />
     <uses-permission android:name="android.permission.USE_CREDENTIALS" />

+ 10 - 4
res/values/strings.xml

@@ -70,12 +70,18 @@
     <string name="common_save_exit">Save &amp; Exit</string>
     <string name="common_error">Error</string>
     <string name="uploader_info_dirname">Directory name</string>
-    <string name="uploader_upload_succeed">Upload was successful</string>
-    <string name="uploader_upload_failed">Upload failed: %1$d/%2$d files uploaded</string>
+	<string name="uploader_upload_in_progress_ticker">Uploading &#8230;</string>    
+	<string name="uploader_upload_in_progress_content">%1$d%% Uploading %2$s</string>    
+	<string name="uploader_upload_succeeded_ticker">Upload succeeded</string>
+    <string name="uploader_upload_succeeded_content_single">%1$s was successfully upload</string>
+    <string name="uploader_upload_succeeded_content_multiple">%1$d files were successfully upload</string>
+    <string name="uploader_upload_failed_ticker">Upload failed</string>
+    <string name="uploader_upload_failed_content_single">Upload of %1$s could not be completed</string>
+    <string name="uploader_upload_failed_content_multiple">Upload failed: %1$d/%2$d files were upload</string>
     <string name="downloader_download_in_progress_ticker">Downloading &#8230;</string>
     <string name="downloader_download_in_progress_content">%1$d%% Downloading %2$s</string>
-    <string name="downloader_download_succeed_ticker">Download suceeded</string>
-    <string name="downloader_download_succeed_content">%1$s was successfully download</string>
+    <string name="downloader_download_succeeded_ticker">Download suceeded</string>
+    <string name="downloader_download_succeeded_content">%1$s was successfully download</string>
     <string name="downloader_download_failed_ticker">Download failed</string>
     <string name="downloader_download_failed_content">Download of %1$s could not be completed</string>
     <string name="common_choose_account">Choose account</string>

+ 12 - 16
src/eu/alefzero/owncloud/files/services/FileDownloader.java

@@ -1,15 +1,12 @@
 package eu.alefzero.owncloud.files.services;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
 import android.accounts.Account;
 import android.accounts.AccountManager;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -24,14 +21,11 @@ import android.os.Looper;
 import android.os.Message;
 import android.os.Process;
 import android.util.Log;
-import android.util.LogPrinter;
 import android.widget.RemoteViews;
-import android.widget.Toast;
 import eu.alefzero.owncloud.R;
 import eu.alefzero.owncloud.authenticator.AccountAuthenticator;
 import eu.alefzero.owncloud.db.ProviderMeta.ProviderTableMeta;
 import eu.alefzero.owncloud.files.interfaces.OnDatatransferProgressListener;
-import eu.alefzero.owncloud.syncadapter.FileSyncService;
 import eu.alefzero.webdav.WebdavClient;
 
 public class FileDownloader extends Service implements OnDatatransferProgressListener {
@@ -120,7 +114,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                 !intent.hasExtra(EXTRA_REMOTE_PATH)
            ) {
             Log.e(TAG, "Not enough information provided in intent");
-            return START_STICKY;
+            return START_NOT_STICKY;
         }
         mAccount = intent.getParcelableExtra(EXTRA_ACCOUNT);
         mFilePath = intent.getStringExtra(EXTRA_FILE_PATH);
@@ -135,7 +129,10 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         return START_NOT_STICKY;
     }
 
-    void downloadFile() {
+    /**
+     * Core download method: requests the file to download and stores it.
+     */
+    private void downloadFile() {
         boolean downloadResult = false;
 
         /// prepare client object to send the request to the ownCloud server
@@ -148,7 +145,6 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
                     AccountAuthenticator.AUTH_TOKEN_TYPE, true);
         } catch (Exception e) {
             Log.e(TAG, "Access to account credentials failed", e);
-            // TODO - check if that log prints the stack trace
             sendFinalBroadcast(downloadResult, null);
             return;
         }
@@ -167,8 +163,7 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, mTotalDownloadSize == -1);
         mNotification.contentView.setTextViewText(R.id.status_text, String.format(getString(R.string.downloader_download_in_progress_content), 0, tmpFile.getName()));
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
-        // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;
-        //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on a download in the notification bar
+        // TODO put something smart in the contentIntent below
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
         mNotificationMngr.notify(R.string.downloader_download_in_progress_ticker, mNotification);
         
@@ -201,12 +196,11 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         
         /// notify result
         mNotificationMngr.cancel(R.string.downloader_download_in_progress_ticker);
-        int tickerId = (downloadResult) ? R.string.downloader_download_succeed_ticker : R.string.downloader_download_failed_ticker;
-        int contentId = (downloadResult) ? R.string.downloader_download_succeed_content : R.string.downloader_download_failed_content;
+        int tickerId = (downloadResult) ? R.string.downloader_download_succeeded_ticker : R.string.downloader_download_failed_ticker;
+        int contentId = (downloadResult) ? R.string.downloader_download_succeeded_content : R.string.downloader_download_failed_content;
         Notification finalNotification = new Notification(R.drawable.icon, getString(tickerId), System.currentTimeMillis());
         finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
-        // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;
-        //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on a download in the notification bar
+        // TODO put something smart in the contentIntent below
         finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
         finalNotification.setLatestEventInfo(getApplicationContext(), getString(tickerId), String.format(getString(contentId), tmpFile.getName()), finalNotification.contentIntent);
         mNotificationMngr.notify(tickerId, finalNotification);
@@ -214,7 +208,9 @@ public class FileDownloader extends Service implements OnDatatransferProgressLis
         sendFinalBroadcast(downloadResult, (downloadResult)?newFile.getAbsolutePath():null);
     }
 
-    
+    /**
+     * Callback method to update the progress bar in the status notification.
+     */
     @Override
     public void transferProgress(long progressRate) {
         mCurrentDownloadSize += progressRate;

+ 107 - 47
src/eu/alefzero/owncloud/files/services/FileUploader.java

@@ -1,12 +1,11 @@
 package eu.alefzero.owncloud.files.services;
 
 import java.io.File;
-
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
 
 import android.accounts.Account;
-import android.accounts.AccountManager;
 import android.app.Notification;
 import android.app.NotificationManager;
 import android.app.PendingIntent;
@@ -21,7 +20,6 @@ import android.os.Process;
 import android.util.Log;
 import android.webkit.MimeTypeMap;
 import android.widget.RemoteViews;
-import android.widget.Toast;
 import eu.alefzero.owncloud.R;
 import eu.alefzero.owncloud.datamodel.FileDataStorageManager;
 import eu.alefzero.owncloud.datamodel.OCFile;
@@ -43,6 +41,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     public static final int UPLOAD_MULTIPLE_FILES = 1;
 
     private static final String TAG = "FileUploader";
+    
     private NotificationManager mNotificationManager;
     private Looper mServiceLooper;
     private ServiceHandler mServiceHandler;
@@ -50,9 +49,31 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     private String[] mLocalPaths, mRemotePaths;
     private int mUploadType;
     private Notification mNotification;
-    private int mTotalDataToSend, mSendData;
+    private long mTotalDataToSend, mSendData;
     private int mCurrentIndexUpload, mPreviousPercent;
     private int mSuccessCounter;
+    
+    /**
+     * Static map with the files being download and the path to the temporal file were are download
+     */
+    private static Map<String, String> mUploadsInProgress = Collections.synchronizedMap(new HashMap<String, String>());
+    
+    /**
+     * Returns True when the file referred by 'remotePath' in the ownCloud account 'account' is downloading
+     */
+    public static boolean isUploading(Account account, String remotePath) {
+        return (mUploadsInProgress.get(buildRemoteName(account.name, remotePath)) != null);
+    }
+    
+    /**
+     * Builds a key for mUplaodsInProgress from the accountName and remotePath
+     */
+    private static String buildRemoteName(String accountName, String remotePath) {
+        return accountName + remotePath;
+    }
+
+    
+    
 
     @Override
     public IBinder onBind(Intent arg0) {
@@ -85,7 +106,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
     @Override
     public int onStartCommand(Intent intent, int flags, int startId) {
         if (!intent.hasExtra(KEY_ACCOUNT) && !intent.hasExtra(KEY_UPLOAD_TYPE)) {
-            Log.e(TAG, "Not enought data in intent provided");
+            Log.e(TAG, "Not enough information provided in intent");
             return Service.START_NOT_STICKY;
         }
         mAccount = intent.getParcelableExtra(KEY_ACCOUNT);
@@ -104,7 +125,7 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         }
 
         if (mLocalPaths.length != mRemotePaths.length) {
-            Log.e(TAG, "Remote paths and local paths are not equal!");
+            Log.e(TAG, "Different number of remote paths and local paths!");
             return Service.START_NOT_STICKY;
         }
 
@@ -115,49 +136,42 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
         return Service.START_NOT_STICKY;
     }
 
-    public void run() {
-        String message;
-        if (mSuccessCounter == mLocalPaths.length) {
-            message = getString(R.string.uploader_upload_succeed); 
-        } else {
-            message = String.format(getString(R.string.uploader_upload_failed), mSuccessCounter, mLocalPaths.length); 
-        }
-        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
-    }
-
+    
+    /**
+     * Core upload method: sends the file(s) to upload
+     */
     public void uploadFile() {
         FileDataStorageManager storageManager = new FileDataStorageManager(mAccount, getContentResolver());
-        
+
         mTotalDataToSend = mSendData = mPreviousPercent = 0;
         
-        mNotification = new Notification(
-                eu.alefzero.owncloud.R.drawable.icon, "Uploading...",
-                System.currentTimeMillis());
+        /// prepare client object to send the request to the ownCloud server
+        WebdavClient wc = new WebdavClient(mAccount, getApplicationContext());
+        wc.allowSelfsignedCertificates();
+        wc.setDataTransferProgressListener(this);
+
+        /// create status notification to show the upload progress
+        mNotification = new Notification(eu.alefzero.owncloud.R.drawable.icon, getString(R.string.uploader_upload_in_progress_ticker), System.currentTimeMillis());
         mNotification.flags |= Notification.FLAG_ONGOING_EVENT;
+        RemoteViews oldContentView = mNotification.contentView;
         mNotification.contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.progressbar_layout);
         mNotification.contentView.setProgressBar(R.id.status_progress, 100, 0, false);
         mNotification.contentView.setImageViewResource(R.id.status_icon, R.drawable.icon);
         // dvelasco ; contentIntent MUST be assigned to avoid app crashes in versions previous to Android 4.x ;
         //              BUT an empty Intent is not a very elegant solution; something smart should happen when a user 'clicks' on an upload in the notification bar
         mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
-        
-        mNotificationManager.notify(42, mNotification);
-
-        WebdavClient wc = new WebdavClient(mAccount, getApplicationContext());
-        wc.allowSelfsignedCertificates();
-        wc.setDataTransferProgressListener(this);
+        mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification);
 
+        
+        /// perform the upload
+        File [] localFiles = new File[mLocalPaths.length];
         for (int i = 0; i < mLocalPaths.length; ++i) {
-            File f = new File(mLocalPaths[i]);
-            mTotalDataToSend += f.length();
+            localFiles[i] = new File(mLocalPaths[i]);
+            mTotalDataToSend += localFiles[i].length();
         }
-        
         Log.d(TAG, "Will upload " + mTotalDataToSend + " bytes, with " + mLocalPaths.length + " files");
-        
         mSuccessCounter = 0;
-        
         for (int i = 0; i < mLocalPaths.length; ++i) {
-            
             String mimeType = null;
             try {
                 mimeType = MimeTypeMap.getSingleton()
@@ -169,31 +183,73 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             }
             if (mimeType == null)
                 mimeType = "application/octet-stream";
-            
             mCurrentIndexUpload = i;
             mRemotePaths[i] = getAvailableRemotePath(wc, mRemotePaths[i]);
+            mUploadsInProgress.put(buildRemoteName(mAccount.name, mRemotePaths[i]), mLocalPaths[i]);
+            long parentDirId = -1;
             if (mRemotePaths[i] != null && wc.putFile(mLocalPaths[i], mRemotePaths[i], mimeType)) {
                 mSuccessCounter++;
                 OCFile new_file = new OCFile(mRemotePaths[i]);
                 new_file.setMimetype(mimeType);
-                new_file.setFileLength(new File(mLocalPaths[i]).length());
+                new_file.setFileLength(localFiles[i].length());
                 new_file.setModificationTimestamp(System.currentTimeMillis());
                 new_file.setLastSyncDate(0);
                 new_file.setStoragePath(mLocalPaths[i]);         
                 File f = new File(mRemotePaths[i]);
-                long parentDirId = storageManager.getFileByPath(f.getParent().endsWith("/")?f.getParent():f.getParent()+"/").getFileId();
+                parentDirId = storageManager.getFileByPath(f.getParent().endsWith("/")?f.getParent():f.getParent()+"/").getFileId();
                 new_file.setParentId(parentDirId);
                 storageManager.saveFile(new_file);
-                
-                Intent end = new Intent(UPLOAD_FINISH_MESSAGE);
-                end.putExtra(EXTRA_PARENT_DIR_ID, parentDirId);
-                end.putExtra(ACCOUNT_NAME, mAccount.name);
-                sendBroadcast(end);
             }
+            mUploadsInProgress.remove(buildRemoteName(mAccount.name, mRemotePaths[i]));
+            
+            /// notify upload of EACH file to activities interested
+            Intent end = new Intent(UPLOAD_FINISH_MESSAGE);
+            end.putExtra(EXTRA_PARENT_DIR_ID, parentDirId);
+            end.putExtra(ACCOUNT_NAME, mAccount.name);
+            sendBroadcast(end);
+        }
+        
+        /// notify final result
+        if (mSuccessCounter == mLocalPaths.length) {    // success
+            //Notification finalNotification = new Notification(R.drawable.icon, getString(R.string.uploader_upload_succeeded_ticker), System.currentTimeMillis());
+            mNotification.flags ^= Notification.FLAG_ONGOING_EVENT; // remove the ongoing flag
+            mNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+            mNotification.contentView = oldContentView;
+            // TODO put something smart in the contentIntent below
+            mNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
+            if (mLocalPaths.length == 1) {
+                mNotification.setLatestEventInfo(   getApplicationContext(), 
+                                                    getString(R.string.uploader_upload_succeeded_ticker), 
+                                                    String.format(getString(R.string.uploader_upload_succeeded_content_single), localFiles[0].getName()), 
+                                                    mNotification.contentIntent);
+            } else {
+                mNotification.setLatestEventInfo(   getApplicationContext(), 
+                                                    getString(R.string.uploader_upload_succeeded_ticker), 
+                                                    String.format(getString(R.string.uploader_upload_succeeded_content_multiple), mSuccessCounter), 
+                                                    mNotification.contentIntent);
+            }                
+            mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification);    // NOT AN ERROR; uploader_upload_in_progress_ticker is the target, not a new notification
             
+        } else {
+            mNotificationManager.cancel(R.string.uploader_upload_in_progress_ticker);
+            Notification finalNotification = new Notification(R.drawable.icon, getString(R.string.uploader_upload_failed_ticker), System.currentTimeMillis());
+            finalNotification.flags |= Notification.FLAG_AUTO_CANCEL;
+            // TODO put something smart in the contentIntent below
+            finalNotification.contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), PendingIntent.FLAG_UPDATE_CURRENT);
+            if (mLocalPaths.length == 1) {
+                finalNotification.setLatestEventInfo(   getApplicationContext(), 
+                                                        getString(R.string.uploader_upload_failed_ticker), 
+                                                        String.format(getString(R.string.uploader_upload_failed_content_single), localFiles[0].getName()), 
+                                                        finalNotification.contentIntent);
+            } else {
+                finalNotification.setLatestEventInfo(   getApplicationContext(), 
+                                                        getString(R.string.uploader_upload_failed_ticker), 
+                                                        String.format(getString(R.string.uploader_upload_failed_content_multiple), mSuccessCounter, mLocalPaths.length), 
+                                                        finalNotification.contentIntent);
+            }                
+            mNotificationManager.notify(R.string.uploader_upload_failed_ticker, finalNotification);
         }
-        mNotificationManager.cancel(42);
-        run();
+        
     }
 
     /**
@@ -235,16 +291,20 @@ public class FileUploader extends Service implements OnDatatransferProgressListe
             return remotePath + suffix;
         }
     }
-
+    
+    
+    /**
+     * Callback method to update the progress bar in the status notification.
+     */
     @Override
     public void transferProgress(long progressRate) {
         mSendData += progressRate;
         int percent = (int)(100*((double)mSendData)/((double)mTotalDataToSend));
         if (percent != mPreviousPercent) {
-            String text = String.format("%d%% Uploading %s file", percent, new File(mLocalPaths[mCurrentIndexUpload]).getName());
+            String text = String.format(getString(R.string.uploader_upload_in_progress_content), percent, new File(mLocalPaths[mCurrentIndexUpload]).getName());
             mNotification.contentView.setProgressBar(R.id.status_progress, 100, percent, false);
             mNotification.contentView.setTextViewText(R.id.status_text, text);
-            mNotificationManager.notify(42, mNotification);
+            mNotificationManager.notify(R.string.uploader_upload_in_progress_ticker, mNotification);
         }
         mPreviousPercent = percent;
     }

+ 1 - 2
src/eu/alefzero/owncloud/syncadapter/FileSyncAdapter.java

@@ -186,8 +186,7 @@ public class FileSyncAdapter extends AbstractOwnCloudSyncAdapter {
                 if (getStorageManager().getFileByPath(file.getRemotePath()) != null)
                     file.setKeepInSync(getStorageManager().getFileByPath(file.getRemotePath()).keepInSync());
                 
-                //getStorageManager().saveFile(file);
-                Log.v(TAG, "adding file: " + file);
+                //Log.v(TAG, "adding file: " + file);
                 updatedFiles.add(file);
                 if (parentId == 0)
                     parentId = file.getFileId();

+ 6 - 0
src/eu/alefzero/webdav/FileRequestEntity.java

@@ -8,6 +8,8 @@ import java.io.OutputStream;
 
 import org.apache.commons.httpclient.methods.RequestEntity;
 
+import android.util.Log;
+
 import eu.alefzero.owncloud.files.interfaces.OnDatatransferProgressListener;
 
 /**
@@ -55,6 +57,10 @@ public class FileRequestEntity implements RequestEntity {
                 if (listener != null) 
                     listener.transferProgress(i);
             }
+        } catch (IOException io) {
+            Log.e("FileRequestException", io.getMessage());
+            throw new RuntimeException("Ugly solution to workaround the default policy of retries when the server falls while uploading ; temporal fix; really", io);   
+            
         } finally {
             instream.close();
         }

+ 22 - 19
src/eu/alefzero/webdav/WebdavClient.java

@@ -145,9 +145,6 @@ public class WebdavClient extends HttpClient {
         boolean caughtException = false;
         GetMethod get = new GetMethod(mUri.toString() + WebdavUtils.encodePath(remoteFilepath));
 
-        // get.setHeader("Host", mUri.getHost());
-        // get.setHeader("User-Agent", "Android-ownCloud");
-
         int status = -1;
         try {
             status = executeMethod(get);
@@ -221,32 +218,38 @@ public class WebdavClient extends HttpClient {
      * @param contentType       MIME type of the file.
      * @return                  'True' then the upload was successfully completed
      */
-    public boolean putFile(String localFile, String remoteTarget,
-            String contentType) {
+    public boolean putFile(String localFile, String remoteTarget, String contentType) {
         boolean result = false;
+        boolean caughtException = false;
+        int status = 0;
 
         try {
-            Log.e("ASD", contentType + "");
             File f = new File(localFile);
             FileRequestEntity entity = new FileRequestEntity(f, contentType);
             entity.setOnDatatransferProgressListener(mDataTransferListener);
-            Log.e("ASD", f.exists() + " " + entity.getContentLength());
             PutMethod put = new PutMethod(mUri.toString() + WebdavUtils.encodePath(remoteTarget));
             put.setRequestEntity(entity);
-            Log.d(TAG, "" + put.getURI().toString());
-            int status = executeMethod(put, 0);
-            Log.d(TAG, "PUT method return with status " + status);
-
-            if (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT) {
-                result = true;
-                Log.i(TAG, "Uploading, done");
-            }
+            status = executeMethod(put);
             
-        } catch (final Exception e) {
-            Log.i(TAG, "" + e.getMessage());
-            result = false;
-        }
+            result = (status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED || status == HttpStatus.SC_NO_CONTENT);
+            
+            Log.d(TAG, "PUT response for " + remoteTarget + " finished with HTTP status " + status);
+            
+        } catch (HttpException e) {
+            Log.e(TAG, "HTTP exception uploading " + localFile + " to " + remoteTarget, e);
+            caughtException = true;
 
+        } catch (IOException e) {
+            Log.e(TAG, "I/O exception uploading " + localFile + " to " + remoteTarget, e);
+            caughtException = true;
+
+        } catch (Exception e) {
+            Log.e(TAG, "Unexpected exception uploading " + localFile + " to " + remoteTarget, e);
+            caughtException = true;
+        }
+        
+        if (!result && !caughtException) Log.e(TAG, "Upload of " + localFile + " to " + remoteTarget + " FAILED with HTTP status " + status);
+        
         return result;
     }