Subversion Repositories linshare

[/] [trunk/] [plugins/] [thunderbird/] [content/] [server/] [linshareServerAPIv3.js] - Diff between revs 1647 and 1648

Show entire file | Details | Blame | View Log

Rev 1647 Rev 1648
Line 14... Line 14...
 
 
    You should have received a copy of the GNU Affero General Public License
    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
*/
 
 
if ( typeof(LinshareServerAPIv2) == "undefined" ) {
if ( typeof(LinshareServerAPIBase) == "undefined" ) {
    var scriptLoader = Components
    var scriptLoader = Components
                            .classes["@mozilla.org/moz/jssubscript-loader;1"]
                            .classes["@mozilla.org/moz/jssubscript-loader;1"]
                            .createInstance(Components.interfaces.mozIJSSubScriptLoader);
                            .createInstance(Components.interfaces.mozIJSSubScriptLoader);
 
 
    scriptLoader.loadSubScript("chrome://linshare/content/server/LinshareServerAPIv2.js");
    scriptLoader.loadSubScript("chrome://linshare/content/server/linshareServerAPIBase.js");
 
 
    var msg = Components
 
                        .classes["@mozilla.org/moz/jssubscript-loader;1"]
 
                        .createInstance(Components.interfaces.mozIJSSubScriptLoader);
 
 
 
//    nsIMsgCompFields: Components.classes["@mozilla.org/messengercompose/composefields;1"]
//    nsIMsgCompFields: Components.classes["@mozilla.org/messengercompose/composefields;1"]
//                               .getService(Components.interfaces.nsIMsgCompFields);
//                               .getService(Components.interfaces.nsIMsgCompFields);
 
 
}
}
Line 35... Line 31...
function LinshareServerAPIv3() {
function LinshareServerAPIv3() {
        this.logInfo("using api : linshareServerAPIv3");
        this.logInfo("using api : linshareServerAPIv3");
}
}
 
 
LinshareServerAPIv3.prototype = {
LinshareServerAPIv3.prototype = {
    __proto__: new LinshareServerAPIv2(),
    __proto__: new LinshareServerAPIBase(),
 
 
 
    uploadFileUrl: function (url) {
 
        return url + "/webservice/rest/document/upload";
 
    },
 
 
 
    multipleShareDocumentsUrl: function (url) {
 
        return url + "/webservice/rest/share/multiplesharedocuments";
 
    },
 
 
 
    pluginInfoUrl: function (url) {
 
        return url + "/webservice/rest/plugin/information";
 
    },
 
 
 
    uploadFile: function (serverInfo, attachment, callback) {
 
        var file = this.openFile(attachment.url);
 
        this.logInfo("uploading file : " + attachment.name);
 
        var request = this.newFileUploadRequest(file, attachment.name, this.uploadFileUrl(serverInfo.url), true, serverInfo.username, serverInfo.password);
 
 
 
        request.setRequestHeader("Accept", "application/json");
 
        request.onreadystatechange = function (e) {
 
            if (request.readyState == 4) {
 
                this.logInfo("upload request status : " + request.status)
 
                if (request.status == 200) {
 
                    try {
 
                        var doc = JSON.parse(request.responseText);
 
                        callback.success(doc.uuid, file);
 
                    } catch(e) {
 
                        Components.utils.reportError("error : " + request.status + " : " + e);
 
                        callback.error(request.status, e);
 
                    }
 
                } else {
 
                    Components.utils.reportError("request error code : " + request.status);
 
                    callback.error(request.status);
 
                }
 
            }
 
        };
 
 
 
        try {
 
            request.sendFile();
 
        } catch(e) {
 
            callback.error(-1, e);
 
        }
 
 
 
        return request;
 
    },
 
 
    shareMultipleFiles: function (serverInfo, fileIds, recipient) {
    shareMultipleFiles: function (serverInfo, fileIds, recipient) {
        var fileParams = "";
        var fileParams = "";
 
 
        for (var i=0; i < fileIds.length; i++) {
        for (var i=0; i < fileIds.length; i++) {