//
// Autogenerated by Thrift Compiler (0.5.0-en-exported)
//
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
//


  // Define types and services

  var Thrift = require('thrift');
  var exports = exports || {};


  exports.NwResource = Thrift.Struct.define('NwResource',  {
    1: { alias: 'id', type: Thrift.Type.STRING },
    2: { alias: 'mimeType', type: Thrift.Type.STRING },
    3: { alias: 'filename', type: Thrift.Type.STRING },
    4: { alias: 'data', type: Thrift.Type.BINARY }
  });

  exports.NwResourceBase64 = Thrift.Struct.define('NwResourceBase64',  {
    1: { alias: 'id', type: Thrift.Type.STRING },
    2: { alias: 'mimeType', type: Thrift.Type.STRING },
    3: { alias: 'filename', type: Thrift.Type.STRING },
    4: { alias: 'base64', type: Thrift.Type.STRING }
  });

  exports.NwNote = Thrift.Struct.define('NwNote',  {
    1: { alias: 'id', type: Thrift.Type.I32 },
    2: { alias: 'title', type: Thrift.Type.STRING },
    3: { alias: 'source', type: Thrift.Type.STRING },
    4: { alias: 'html', type: Thrift.Type.STRING },
    5: { alias: 'contentClass', type: Thrift.Type.STRING },
    6: { alias: 'sourceURL', type: Thrift.Type.STRING },
    7: { alias: 'author', type: Thrift.Type.STRING }
  });

  var DesktopService = exports.DesktopService = {};

  DesktopService.serverStarted = Thrift.Method.define({
    alias: 'serverStarted',
    args: Thrift.Struct.define('serverStartedArgs', {
      1: { alias: 'serverName', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('serverStartedResult')
  });

  DesktopService.logMessage = Thrift.Method.define({
    alias: 'logMessage',
    args: Thrift.Struct.define('logMessageArgs', {
      1: { alias: 'message', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('logMessageResult')
  });

  DesktopService.getCurrentUserInfo = Thrift.Method.define({
    alias: 'getCurrentUserInfo',
    args: Thrift.Struct.define('getCurrentUserInfoArgs'),
    result: Thrift.Struct.define('getCurrentUserInfoResult', {
      0: { alias: 'returnValue',type: Thrift.Type.MAP, def: Thrift.Map.define(Thrift.Type.STRING, Thrift.Type.STRING )  }
    })
  });

  DesktopService.getAnalyticsInfo = Thrift.Method.define({
    alias: 'getAnalyticsInfo',
    args: Thrift.Struct.define('getAnalyticsInfoArgs'),
    result: Thrift.Struct.define('getAnalyticsInfoResult', {
      0: { alias: 'returnValue',type: Thrift.Type.MAP, def: Thrift.Map.define(Thrift.Type.STRING, Thrift.Type.STRING )  }
    })
  });

  DesktopService.getResource = Thrift.Method.define({
    alias: 'getResource',
    args: Thrift.Struct.define('getResourceArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('getResourceResult', {
      0: { alias: 'returnValue',type: Thrift.Type.STRUCT, def: exports.NwResource }
    })
  });

  DesktopService.getResources = Thrift.Method.define({
    alias: 'getResources',
    args: Thrift.Struct.define('getResourcesArgs', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('getResourcesResult', {
      0: { alias: 'returnValue',type: Thrift.Type.LIST, def: Thrift.List.define(Thrift.Type.STRUCT, exports.NwResource)  }
    })
  });

  DesktopService.getResourceAsBase64 = Thrift.Method.define({
    alias: 'getResourceAsBase64',
    args: Thrift.Struct.define('getResourceAsBase64Args', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('getResourceAsBase64Result', {
      0: { alias: 'returnValue',type: Thrift.Type.STRUCT, def: exports.NwResourceBase64 }
    })
  });

  DesktopService.getResourcesAsBase64 = Thrift.Method.define({
    alias: 'getResourcesAsBase64',
    args: Thrift.Struct.define('getResourcesAsBase64Args', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('getResourcesAsBase64Result', {
      0: { alias: 'returnValue',type: Thrift.Type.LIST, def: Thrift.List.define(Thrift.Type.STRUCT, exports.NwResourceBase64)  }
    })
  });

  DesktopService.openResource = Thrift.Method.define({
    alias: 'openResource',
    args: Thrift.Struct.define('openResourceArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('openResourceResult')
  });

  DesktopService.updateResource = Thrift.Method.define({
    alias: 'updateResource',
    args: Thrift.Struct.define('updateResourceArgs', {
      1: { alias: 'resource', type: Thrift.Type.STRUCT, def: exports.NwResource, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 }
    }),
    result: Thrift.Struct.define('updateResourceResult')
  });

  DesktopService.updateResourceAsBase64 = Thrift.Method.define({
    alias: 'updateResourceAsBase64',
    args: Thrift.Struct.define('updateResourceAsBase64Args', {
      1: { alias: 'resource', type: Thrift.Type.STRUCT, def: exports.NwResourceBase64, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 }
    }),
    result: Thrift.Struct.define('updateResourceAsBase64Result')
  });

  DesktopService.createNoteFromResource = Thrift.Method.define({
    alias: 'createNoteFromResource',
    args: Thrift.Struct.define('createNoteFromResourceArgs', {
      1: { alias: 'resource', type: Thrift.Type.STRUCT, def: exports.NwResource, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 }
    }),
    result: Thrift.Struct.define('createNoteFromResourceResult')
  });

  DesktopService.createNoteFromResourceAsBase64 = Thrift.Method.define({
    alias: 'createNoteFromResourceAsBase64',
    args: Thrift.Struct.define('createNoteFromResourceAsBase64Args', {
      1: { alias: 'resource', type: Thrift.Type.STRUCT, def: exports.NwResourceBase64, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 }
    }),
    result: Thrift.Struct.define('createNoteFromResourceAsBase64Result')
  });

  DesktopService.renderPage = Thrift.Method.define({
    alias: 'renderPage',
    args: Thrift.Struct.define('renderPageArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 },
      3: { alias: 'width', type: Thrift.Type.I32, index: 2 },
      4: { alias: 'height', type: Thrift.Type.I32, index: 3 },
      5: { alias: 'pageNum', type: Thrift.Type.I32, index: 4 }
    }),
    result: Thrift.Struct.define('renderPageResult', {
      0: { alias: 'returnValue',type: Thrift.Type.BINARY }
    })
  });

  DesktopService.renderPages = Thrift.Method.define({
    alias: 'renderPages',
    args: Thrift.Struct.define('renderPagesArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 },
      2: { alias: 'offset', type: Thrift.Type.I32, index: 1 },
      3: { alias: 'width', type: Thrift.Type.I32, index: 2 },
      4: { alias: 'height', type: Thrift.Type.I32, index: 3 },
      5: { alias: 'pageNums', type: Thrift.Type.LIST, def: Thrift.List.define(Thrift.Type.I32) , index: 4 }
    }),
    result: Thrift.Struct.define('renderPagesResult', {
      0: { alias: 'returnValue',type: Thrift.Type.LIST, def: Thrift.List.define(Thrift.Type.BINARY)  }
    })
  });

  DesktopService.getNoteId = Thrift.Method.define({
    alias: 'getNoteId',
    args: Thrift.Struct.define('getNoteIdArgs', {
      1: { alias: 'noteLink', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('getNoteIdResult', {
      0: { alias: 'returnValue',type: Thrift.Type.I32 }
    })
  });

  DesktopService.getNoteTitle = Thrift.Method.define({
    alias: 'getNoteTitle',
    args: Thrift.Struct.define('getNoteTitleArgs', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('getNoteTitleResult', {
      0: { alias: 'returnValue',type: Thrift.Type.STRING }
    })
  });

  DesktopService.isNoteLocked = Thrift.Method.define({
    alias: 'isNoteLocked',
    args: Thrift.Struct.define('isNoteLockedArgs', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('isNoteLockedResult', {
      0: { alias: 'returnValue',type: Thrift.Type.BOOL }
    })
  });

  DesktopService.requestNoteLock = Thrift.Method.define({
    alias: 'requestNoteLock',
    args: Thrift.Struct.define('requestNoteLockArgs', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('requestNoteLockResult', {
      0: { alias: 'returnValue',type: Thrift.Type.BOOL }
    })
  });

  DesktopService.getNote = Thrift.Method.define({
    alias: 'getNote',
    args: Thrift.Struct.define('getNoteArgs', {
      1: { alias: 'noteId', type: Thrift.Type.I32, index: 0 }
    }),
    result: Thrift.Struct.define('getNoteResult', {
      0: { alias: 'returnValue',type: Thrift.Type.STRUCT, def: exports.NwNote }
    })
  });

  DesktopService.updateNote = Thrift.Method.define({
    alias: 'updateNote',
    args: Thrift.Struct.define('updateNoteArgs', {
      1: { alias: 'note', type: Thrift.Type.STRUCT, def: exports.NwNote, index: 0 }
    }),
    result: Thrift.Struct.define('updateNoteResult')
  });

  DesktopService.markupWindowClosed = Thrift.Method.define({
    alias: 'markupWindowClosed',
    args: Thrift.Struct.define('markupWindowClosedArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('markupWindowClosedResult')
  });

  DesktopService.markupWindowFocused = Thrift.Method.define({
    alias: 'markupWindowFocused',
    args: Thrift.Struct.define('markupWindowFocusedArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('markupWindowFocusedResult')
  });

  DesktopService.markupWindowActive = Thrift.Method.define({
    alias: 'markupWindowActive',
    args: Thrift.Struct.define('markupWindowActiveArgs', {
      1: { alias: 'resourceUrl', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('markupWindowActiveResult')
  });

  DesktopService.presentationWindowClosed = Thrift.Method.define({
    alias: 'presentationWindowClosed',
    args: Thrift.Struct.define('presentationWindowClosedArgs'),
    result: Thrift.Struct.define('presentationWindowClosedResult')
  });

  DesktopService.pdfTrialStarted = Thrift.Method.define({
    alias: 'pdfTrialStarted',
    args: Thrift.Struct.define('pdfTrialStartedArgs'),
    result: Thrift.Struct.define('pdfTrialStartedResult')
  });

  DesktopService.presTrialStarted = Thrift.Method.define({
    alias: 'presTrialStarted',
    args: Thrift.Struct.define('presTrialStartedArgs'),
    result: Thrift.Struct.define('presTrialStartedResult')
  });

  DesktopService.showPremiumPage = Thrift.Method.define({
    alias: 'showPremiumPage',
    args: Thrift.Struct.define('showPremiumPageArgs', {
      1: { alias: 'offercode', type: Thrift.Type.STRING, index: 0 }
    }),
    result: Thrift.Struct.define('showPremiumPageResult')
  });

  // Define DesktopService Client

  function DesktopServiceClient(output) {
    this.output = output;
    this.seqid = 0;
  }

  DesktopServiceClient.prototype.serverStarted = function(serverName, callback) {
    var mdef = DesktopService.serverStarted;
    var args = new mdef.args();
    args.serverName = serverName;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.logMessage = function(message, callback) {
    var mdef = DesktopService.logMessage;
    var args = new mdef.args();
    args.message = message;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getCurrentUserInfo = function(callback) {
    var mdef = DesktopService.getCurrentUserInfo;
    var args = new mdef.args();
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getAnalyticsInfo = function(callback) {
    var mdef = DesktopService.getAnalyticsInfo;
    var args = new mdef.args();
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getResource = function(resourceUrl, callback) {
    var mdef = DesktopService.getResource;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getResources = function(noteId, callback) {
    var mdef = DesktopService.getResources;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getResourceAsBase64 = function(resourceUrl, callback) {
    var mdef = DesktopService.getResourceAsBase64;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getResourcesAsBase64 = function(noteId, callback) {
    var mdef = DesktopService.getResourcesAsBase64;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.openResource = function(resourceUrl, callback) {
    var mdef = DesktopService.openResource;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.updateResource = function(resource, offset, callback) {
    var mdef = DesktopService.updateResource;
    var args = new mdef.args();
    args.resource = resource;
    args.offset = offset;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.updateResourceAsBase64 = function(resource, offset, callback) {
    var mdef = DesktopService.updateResourceAsBase64;
    var args = new mdef.args();
    args.resource = resource;
    args.offset = offset;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.createNoteFromResource = function(resource, offset, callback) {
    var mdef = DesktopService.createNoteFromResource;
    var args = new mdef.args();
    args.resource = resource;
    args.offset = offset;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.createNoteFromResourceAsBase64 = function(resource, offset, callback) {
    var mdef = DesktopService.createNoteFromResourceAsBase64;
    var args = new mdef.args();
    args.resource = resource;
    args.offset = offset;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.renderPage = function(resourceUrl, offset, width, height, pageNum, callback) {
    var mdef = DesktopService.renderPage;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    args.offset = offset;
    args.width = width;
    args.height = height;
    args.pageNum = pageNum;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.renderPages = function(resourceUrl, offset, width, height, pageNums, callback) {
    var mdef = DesktopService.renderPages;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    args.offset = offset;
    args.width = width;
    args.height = height;
    args.pageNums = pageNums;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getNoteId = function(noteLink, callback) {
    var mdef = DesktopService.getNoteId;
    var args = new mdef.args();
    args.noteLink = noteLink;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getNoteTitle = function(noteId, callback) {
    var mdef = DesktopService.getNoteTitle;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.isNoteLocked = function(noteId, callback) {
    var mdef = DesktopService.isNoteLocked;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.requestNoteLock = function(noteId, callback) {
    var mdef = DesktopService.requestNoteLock;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.getNote = function(noteId, callback) {
    var mdef = DesktopService.getNote;
    var args = new mdef.args();
    args.noteId = noteId;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.updateNote = function(note, callback) {
    var mdef = DesktopService.updateNote;
    var args = new mdef.args();
    args.note = note;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.markupWindowClosed = function(resourceUrl, callback) {
    var mdef = DesktopService.markupWindowClosed;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.markupWindowFocused = function(resourceUrl, callback) {
    var mdef = DesktopService.markupWindowFocused;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.markupWindowActive = function(resourceUrl, callback) {
    var mdef = DesktopService.markupWindowActive;
    var args = new mdef.args();
    args.resourceUrl = resourceUrl;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.presentationWindowClosed = function(callback) {
    var mdef = DesktopService.presentationWindowClosed;
    var args = new mdef.args();
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.pdfTrialStarted = function(callback) {
    var mdef = DesktopService.pdfTrialStarted;
    var args = new mdef.args();
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.presTrialStarted = function(callback) {
    var mdef = DesktopService.presTrialStarted;
    var args = new mdef.args();
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  DesktopServiceClient.prototype.showPremiumPage = function(offercode, callback) {
    // console.log('DesktopServiceClient.showPremiumPage offercode: ' + offercode);
    var mdef = DesktopService.showPremiumPage;
    var args = new mdef.args();
    args.offercode = offercode;
    mdef.sendRequest(this.output, this.seqid++, args, callback);
  };

  exports.DesktopService.Client = DesktopServiceClient;

  // Define DesktopService Server

  function DesktopServiceServer(service, stransport, Protocol) {
    var methodName;
      this.service = service;
      this.stransport = stransport;
      this.processor = new Thrift.Processor();
      for (methodName in DesktopService) {
        if (service[methodName]) {
          this.processor.addMethod(DesktopService[methodName], service[methodName].bind(service));
        }
      }
      this.stransport.process = function (input, output, noop) {
      var inprot = new Protocol(input);
      var outprot = new Protocol(output);
      this.processor.process(inprot, outprot, noop);
    }.bind(this);
  }

  DesktopServiceServer.prototype.start = function () {
    this.stransport.listen();
  };
  DesktopServiceServer.prototype.stop = function () {
    this.stransport.close();
  };

  exports.DesktopService.Server = DesktopServiceServer;

  return exports;

