Skip to content

Commit

Permalink
Move to single quotes everywhere and remove some TODO comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
ibc committed Oct 20, 2014
1 parent a7b61b7 commit dab6463
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 116 deletions.
200 changes: 100 additions & 100 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,74 @@
*
* grunt min: Generate builds/jssip-X.Y.Z.min.js.
*
* grunt watch: Watch for changes in the src/ directory and run "grunt dist".
* grunt watch: Watch for changes in the src/ directory and run 'grunt dist'.
*
* grunt: Alias for "grunt dist".
* grunt: Alias for 'grunt dist'.
*/


module.exports = function(grunt) {
// JavaScript files defining the JsSIP namespace.
var jsFiles = [
"src/JsSIP.js",
"src/Logger.js",
"src/LoggerFactory.js",
"src/EventEmitter.js",
"src/Constants.js",
"src/Exceptions.js",
"src/Timers.js",
"src/Transport.js",
"src/Parser.js",
"src/SIPMessage.js",
"src/URI.js",
"src/NameAddrHeader.js",
"src/Transactions.js",
"src/Dialog.js",
"src/Dialog/RequestSender.js",
"src/RequestSender.js",
"src/Registrator.js",
"src/RTCSession.js",
"src/RTCSession/RTCMediaHandler.js",
"src/RTCSession/Request.js",
"src/RTCSession/DTMF.js",
"src/Message.js",
"src/UA.js",
"src/Utils.js",
"src/SanityCheck.js",
"src/DigestAuthentication.js",
"src/WebRTC.js"
'src/JsSIP.js',
'src/Logger.js',
'src/LoggerFactory.js',
'src/EventEmitter.js',
'src/Constants.js',
'src/Exceptions.js',
'src/Timers.js',
'src/Transport.js',
'src/Parser.js',
'src/SIPMessage.js',
'src/URI.js',
'src/NameAddrHeader.js',
'src/Transactions.js',
'src/Dialog.js',
'src/Dialog/RequestSender.js',
'src/RequestSender.js',
'src/Registrator.js',
'src/RTCSession.js',
'src/RTCSession/RTCMediaHandler.js',
'src/RTCSession/Request.js',
'src/RTCSession/DTMF.js',
'src/Message.js',
'src/UA.js',
'src/Utils.js',
'src/SanityCheck.js',
'src/DigestAuthentication.js',
'src/WebRTC.js'
];

// JavaScript files to concatenate.
var concatFiles = (function() {
var files = [];

files.push("src/_head.js");
files.push('src/_head.js');
files = files.concat(jsFiles);
files.push("src/_tail.js");
files.push('src/_tail.js');

return files;
}());

// Files for documentation.
var docFiles = [
"README.md"
'README.md'
].concat(jsFiles);

// Banner.
var banner = require("fs").readFileSync("src/banner.txt").toString();
var banner = require('fs').readFileSync('src/banner.txt').toString();

// Generated builds.
var builds = {
dist: "builds/<%= pkg.name %>-<%= pkg.version %>.js",
last: "builds/<%= pkg.name %>-last.js",
dist: 'builds/<%= pkg.name %>-<%= pkg.version %>.js',
last: 'builds/<%= pkg.name %>-last.js',
};


// Project configuration.
grunt.initConfig({

pkg: grunt.file.readJSON("package.json"),
pkg: grunt.file.readJSON('package.json'),

meta: {
banner: banner
Expand All @@ -89,21 +89,21 @@ module.exports = function(grunt) {
src: concatFiles,
dest: builds.dist,
options: {
banner: "<%= meta.banner %>",
separator: "\n\n",
banner: '<%= meta.banner %>',
separator: '\n\n',
process: true
},
nonull: true
},
post_dist: {
src: [
builds.dist,
"src/Grammar/dist/Grammar.js",
"src/SDP/dist/SDP.js"
'src/Grammar/dist/Grammar.js',
'src/SDP/dist/SDP.js'
],
dest: builds.dist,
options: {
separator: "\n\n",
separator: '\n\n',
process: true
},
nonull: true
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = function(grunt) {
jquery: true,
worker: true,
globals: {
module: false, // false means that "module" is defined elsewhere and cannot override it.
module: false, // false means that 'module' is defined elsewhere and cannot override it.
define: false
}
},
Expand All @@ -149,7 +149,7 @@ module.exports = function(grunt) {
ignores: [],
globals: {
// target: false, // TODO: Add it when 'target' is given instead of 'window'.
JsSIP: true // true means that "JsSIP" is defined here.
JsSIP: true // true means that 'JsSIP' is defined here.
}
}
}
Expand All @@ -158,30 +158,30 @@ module.exports = function(grunt) {
uglify: {
dist: {
files: {
"builds/<%= pkg.name %>-<%= pkg.version %>.min.js": [ builds.dist ]
'builds/<%= pkg.name %>-<%= pkg.version %>.min.js': [ builds.dist ]
}
},
options: {
banner: "<%= meta.banner %>"
banner: '<%= meta.banner %>'
}
},

browserify: {
sdp: {
files: {
"src/SDP/dist/SDP.js": [ "src/SDP/main.js" ]
'src/SDP/dist/SDP.js': [ 'src/SDP/main.js' ]
}
}
},

qunit: {
noWebRTC: [ "test/run-TestNoWebRTC.html" ]
noWebRTC: [ 'test/run-TestNoWebRTC.html' ]
},

watch: {
dist: {
files: jsFiles,
tasks: [ "dist" ],
tasks: [ 'dist' ],
options: {
nospawn: true
}
Expand All @@ -202,102 +202,102 @@ module.exports = function(grunt) {
basic: {
src: docFiles,
options: {
destination: "doc/basic/",
destination: 'doc/basic/',
private: false
}
},
docstrap: {
src: docFiles,
options: {
destination: "doc/docstrap/",
destination: 'doc/docstrap/',
private: false,
template: "node_modules/grunt-jsdoc/node_modules/ink-docstrap/template",
configure: "jsdoc.conf.json"
template: 'node_modules/grunt-jsdoc/node_modules/ink-docstrap/template',
configure: 'jsdoc.conf.json'
}
}
}
});


// Load Grunt plugins.
grunt.loadNpmTasks("grunt-contrib-concat");
grunt.loadNpmTasks("grunt-contrib-jshint");
grunt.loadNpmTasks("grunt-contrib-uglify");
grunt.loadNpmTasks("grunt-browserify");
grunt.loadNpmTasks("grunt-contrib-qunit");
grunt.loadNpmTasks("grunt-contrib-watch");
grunt.loadNpmTasks("grunt-contrib-symlink");
grunt.loadNpmTasks("grunt-jsdoc");
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-symlink');
grunt.loadNpmTasks('grunt-jsdoc');


// Task for building src/Grammar/dist/Grammar.js.
// NOTE: This task is not included in "grunt dist".
grunt.registerTask("grammar", function() {
// NOTE: This task is not included in 'grunt dist'.
grunt.registerTask('grammar', function() {
var done = this.async(); // This is an async task.
var sys = require("sys");
var exec = require("child_process").exec;
var sys = require('sys');
var exec = require('child_process').exec;
var child;

// First compile JsSIP grammar with PEGjs.
console.log("'grammar' task: compiling JsSIP PEGjs grammar into Grammar.js...");
child = exec("" +
"if [ -x './node_modules/pegjs/bin/pegjs' ] ; then\n" +
"PEGJS_BIN='./node_modules/pegjs/bin/pegjs';\n" +
"else\n" +
"PEGJS_BIN='pegjs';\n" +
"fi &&\n" +
"mkdir -p src/Grammar/dist\n" +
"$PEGJS_BIN -e JsSIP.Grammar src/Grammar/src/Grammar.pegjs src/Grammar/dist/Grammar.js",
console.log('grammar task: compiling JsSIP PEGjs grammar into Grammar.js...');
child = exec('' +
'if [ -x "./node_modules/pegjs/bin/pegjs" ] ; then\n' +
'PEGJS_BIN="./node_modules/.bin/pegjs";\n' +
'else\n' +
'PEGJS_BIN="pegjs";\n' +
'fi &&\n' +
'mkdir -p src/Grammar/dist\n' +
'$PEGJS_BIN -e JsSIP.Grammar src/Grammar/src/Grammar.pegjs src/Grammar/dist/Grammar.js',
function(error, stdout, stderr) {
if (error) {
sys.print("ERROR: " + stderr);
sys.print('ERROR: ' + stderr);
done(false); // Tell grunt that async task has failed.
}
console.log("OK");
console.log('OK');

// Then modify the generated Grammar.js file with custom changes.
console.log("'grammar' task: applying custom changes to Grammar.js...");
var fs = require("fs");
var grammar = fs.readFileSync("src/Grammar/dist/Grammar.js").toString();
var modified_grammar = grammar.replace(/throw new this\.SyntaxError\(([\s\S]*?)\);([\s\S]*?)}([\s\S]*?)return result;/, "new this.SyntaxError($1);\n return -1;$2}$3return data;");
fs.writeFileSync("src/Grammar/dist/Grammar.js", modified_grammar);
console.log("OK");
console.log('grammar task: applying custom changes to Grammar.js...');
var fs = require('fs');
var grammar = fs.readFileSync('src/Grammar/dist/Grammar.js').toString();
var modified_grammar = grammar.replace(/throw new this\.SyntaxError\(([\s\S]*?)\);([\s\S]*?)}([\s\S]*?)return result;/, 'new this.SyntaxError($1);\n return -1;$2}$3return data;');
fs.writeFileSync('src/Grammar/dist/Grammar.js', modified_grammar);
console.log('OK');
done(); // Tell grunt that async task has succeeded.
});
});

// Generate src/SDP/dist/SDP.js.
// NOTE: This task is not included in "grunt dist".
grunt.registerTask("sdp", [ "browserify:sdp" ]);
// NOTE: This task is not included in 'grunt dist'.
grunt.registerTask('sdp', [ 'browserify:sdp' ]);

// Build both JsSIP Grammar and SDP components.
grunt.registerTask("devel", [ "grammar", "sdp" ]);
grunt.registerTask('devel', [ 'grammar', 'sdp' ]);

// Taks for building builds/jssip-X.Y.Z.js and builds/jssip-last.js symlink.
// NOTE: This task assumes that "devel" task has been already executed.
grunt.registerTask("dist", [
"jshint:each_file",
"concat:dist",
"jshint:dist",
"concat:post_dist",
"symlink:last"
// NOTE: This task assumes that 'devel' task has been already executed.
grunt.registerTask('dist', [
'jshint:each_file',
'concat:dist',
'jshint:dist',
'concat:post_dist',
'symlink:last'
]);

// Taks for building builds/jssip-X.Y.Z.min.js (minified).
// NOTE: This task assumes that "devel" and "dist" tasks have been already executed.
grunt.registerTask("min", [ "uglify:dist"]);
// NOTE: This task assumes that 'devel' and 'dist' tasks have been already executed.
grunt.registerTask('min', [ 'uglify:dist']);

// Test tasks.
// NOTE: This task assumes that "devel" and "dist" tasks have been already executed.
grunt.registerTask("testNoWebRTC", [ "qunit:noWebRTC" ]);
grunt.registerTask("test", [ "testNoWebRTC" ]);
// NOTE: This task assumes that 'devel' and 'dist' tasks have been already executed.
grunt.registerTask('testNoWebRTC', [ 'qunit:noWebRTC' ]);
grunt.registerTask('test', [ 'testNoWebRTC' ]);

// Build builds nice documentation using JsDoc3.
grunt.registerTask("doc", [ "jsdoc:docstrap" ]);
grunt.registerTask('doc', [ 'jsdoc:docstrap' ]);

// Task for Travis CI.
grunt.registerTask("travis", [ "test" ]);
grunt.registerTask('travis', [ 'test' ]);

// Default task points to "dist" task.
grunt.registerTask("default", [ "dist" ]);
// Default task points to 'dist' task.
grunt.registerTask('default', [ 'dist' ]);
};
23 changes: 11 additions & 12 deletions src/RTCSession.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ var RTCSession,

RTCSession = function(ua) {
var events = [
'connecting',
'progress',
'failed',
'accepted',
'confirmed',
'ended',
'newDTMF',
'hold',
'unhold',
'muted',
'unmuted'
'connecting',
'progress',
'failed',
'accepted',
'confirmed',
'ended',
'newDTMF',
'hold',
'unhold',
'muted',
'unmuted'
];

this.ua = ua;
Expand Down Expand Up @@ -1375,7 +1375,6 @@ RTCSession.prototype.receiveRequest = function(request) {
request.reply(403, 'Wrong Status');
}
break;
// TODO
case JsSIP.C.UPDATE:
if(this.status === C.STATUS_CONFIRMED) {
this.logger.debug('UPDATE received');
Expand Down
Loading

0 comments on commit dab6463

Please sign in to comment.