Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

nsIMsgCloudFileProvider

nsIMsgCloudFileProvider is the interface that must be implemented by new Filelink providers. 

web.html($0) is defined in wiki.template('tbsource', mediawiki.args([$1])). It is wiki.template(mediawiki.path('InterfaceStatus:Scriptable_' + $4, "en")) and wiki.template(mediawiki.path('InterfaceStatus:' + $2, "en"), mediawiki.args([$3])).

Inherits from: nsISupports

Method overview

void init(in string aAccountKey);
void uploadFile(in nsILocalFile aFile, in nsIRequestObserver aCallback);
ACString urlForFile(in nsILocalFile aFile);
void cancelFileUpload(in nsILocalFile aFile);
void refreshUserInfo(in boolean aWithUI, in nsIRequestObserver aCallback);
void deleteFile(in nsILocalFile aFile, in nsIRequestObserver aCallback);
void createNewAccount(in ACString aEmailAddress, in ACString aPassword,
                      in ACString aFirstName, in ACString aLastName,
                      in nsIRequestObserver aCallback);
void createExistingAccount(in nsIRequestObserver aCallback);
ACString providerUrlForError(in unsigned long aError);

Attributes

Attribute Type Description
type ACString Readonly: The type is a unique string identifier which can be used by interface elements for styling. As such, the type should be an alphanumpheric string with no spaces.
displayName ACString Readonly: Used for displaying the service name in the user interface.
serviceURL ACString Readonly: A link to the homepage of the service, if applicable.
iconClass ACString Readonly: A chrome URL for an icon to be used for representing the service.
accountKey ACString Readonly: The unique identifier for the account associated with an instance of an nsIMsgCloudFileProvider.
settingsURL ACString Readonly: A chrome URL for an XHTML page displayed in the account setup dialog window, used for displaying and setting provider-specific settings. This URL should not point to external web content.
managementURL ACString Readonly: A chrome URL for an XHTML page displayed within the Filelink preferences dialog, used for displaying and setting provider-specific settings once the account has already been set up. This URL should not point to external web content.
fileUploadSizeLimit long Readonly: The upper size limit in bytes for a file to be uploaded. If this value is not known, returns -1.
remainingFileSpace long long Readonly: The remaining storage space available for this account in bytes. If this value is not known, returns -1.
fileSpaceUsed long long Readonly: The total amount of space used by this account. If this value is not known, returns -1.
lastError ACString Readonly: The last error message received from the server.

Constants

The following constants are used for the status codes passed to the onStopRequest functions of the nsIRequestObserver's used by the asynchronous methods of nsIMsgCloudFileProvider.

Constant Value Description
offlineErr 0x80550014 Returned when it appears that there is no active network connection.
authErr 0x8055001e Returned when authorizing has failed.
uploadErr 0x8055311a Returned when uploading has failed for an unknown reason.
uploadWouldExceedQuota 0x8055311b Returned when uploading has failed because the user has exceeded their storage quota.
uploadExceedsFileLimit 0x8055311c Returned when uploading has failed because the file being uploaded is larger than the file size limit.
uploadCanceled 0x8055311d Returned when uploading has stopped because it was cancelled by the user.

Methods

init()

Initializes an nsIMsgCloudFileProvider to be associated with a particular account.  This should probably be called immediately after instantiation.

void init(in string aAccountKey);
Parameters

uploadFile()

Starts a file upload for this account.

aAccountKey
The account key that this instance of the nsIMsgCloudFileProvider should be associated with.
void uploadFile(in nsILocalFile aFile,
                in nsIRequestObserver aCallback);
Parameters
aFile
The file to be uploaded.
aCallback
The nsIRequestObserver callback to receive request start and stop notices.

urlForFile()

Returns the URL for a file that has been uploaded.

ACString urlForFile(in nsILocalFile aFile);
Parameters
aFile
The previously uploaded file to get the URL for.
Return value

The string representation of the URL for the uploaded file. If the file was not uploaded with this instance of the nsIMsgCloudFileProvider, returns undefined.

cancelFileUpload()

Cancels an upload currently in progress for some nsILocalFile.

void cancelFileUpload(in nsILocalFile aFile);
Parameters
aFile
The nsILocalFile that is currently being uploaded to cancel.

refreshUserInfo()

Refreshes the data for this user account - for example, the storage quota, or the amount of storage being used.

void refreshUserInfo(in boolean aWithUI,
                     in nsIRequestObserver aCallback);
Parameters
aWithUI
Whether or not the provider should prompt the user for credentails in the event that the stored credentials have gone stale.  If aWithUI is false, and the credentials are stale, the onStopRequest of the aCallback nsIRequestListener will get the authErr status code passed to it.
aCallback
The nsIRequestObserver for monitoring the start and stop states of the refresh operation.

deleteFile()

Attempts to delete a file that had previously been uploaded using this instance.

void deleteFile(in nsILocalFile aFile,
                in nsIRequestObserver aCallback);
Parameters
aFile
The file that was previously uploaded using this nsIMsgCloudFileProvider instance that should be deleted.
aCallback
The nsIRequestObserver for monitoring the start and stop states of the delete operation.

createNewAccount()

Creates a new user account for the storage provider represented by the nsIMsgCloudFileProvider.

Note: This function is not directly called by the Filelink UI. This might change in the future, but as it stands, this function can simply return NS_ERROR_NOT_IMPLEMENTED unless there are plans to call createNewAccount from the management or settings XHTML files.

void createNewAccount(in ACString aEmailAddress, in ACString aPassword,
                      in ACString aFirstName, in ACString aLastName,
                      in nsIRequestObserver aCallback);
Parameters
aEmailAddress
The new user account email address.
aPassword
The desired password for the new account.
aFirstName
The new account holder's first name.
aLastName
The new account holder's last name.
aCallback
The nsIRequestObserver for monitoring the start and stop states of the new account creation operation.

createExistingAccount()

For an init'ed nsIMsgCloudFileProvider, attempts to communicate with the service provider in order to get the proper credentials for starting uploads.

void createExistingAccount(in nsIRequestObserver aCallback);
Parameters
aCallback
The nsIRequestObserver for monitoring the start and stop states of the creation operation.

providerUrlForError()

For an error code, for example uploadWouldExceedQuota, a provider might have a URL with information on how to deal with that error. This function translates those error codes into those URLs.  If the provider has no appropriate URL for the error, the method returns the empty string.

void providerUrlForError(in unsigned long aError);
Parameters
aError
An error code to be translated into a URL.

Document Tags and Contributors

 Contributors to this page: chrisdavidmills, mconley
 Last updated by: chrisdavidmills,