From b34c09a785319063a291314ed581eef98c035c73 Mon Sep 17 00:00:00 2001 From: Olivier Poitrey Date: Thu, 29 Mar 2012 16:26:07 +0200 Subject: [PATCH] Unify to space indentation --- lib/c2dm.js | 118 ++++++++++++++++++++++++++-------------------------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/lib/c2dm.js b/lib/c2dm.js index 8b91d28..908c9ae 100644 --- a/lib/c2dm.js +++ b/lib/c2dm.js @@ -4,31 +4,31 @@ var querystring = require('querystring'); var emitter = require('events').EventEmitter; function C2DM(config) { - if (config) { - if ('user' in config) - this.user = config.user; - if ('password' in config) - this.password = config.password; - this.source = 'source' in config ? config.source : 'node-c2dm-client'; - this.token = 'token' in config ? config.token : null; - this.keepAlive = 'keepAlive' in config ? config.keepAlive : false; - } else { - throw Error('No config given.'); - } - this.loginOptions = { - host: 'www.google.com', - port: 443, - path: '/accounts/ClientLogin', - method: 'POST', - headers: {'Content-Type': 'application/x-www-form-urlencoded'} - }; - this.c2dmOptions = { - host: 'android.apis.google.com', - port: 443, - path: '/c2dm/send', - method: 'POST', - headers: {} - }; + if (config) { + if ('user' in config) + this.user = config.user; + if ('password' in config) + this.password = config.password; + this.source = 'source' in config ? config.source : 'node-c2dm-client'; + this.token = 'token' in config ? config.token : null; + this.keepAlive = 'keepAlive' in config ? config.keepAlive : false; + } else { + throw Error('No config given.'); + } + this.loginOptions = { + host: 'www.google.com', + port: 443, + path: '/accounts/ClientLogin', + method: 'POST', + headers: {'Content-Type': 'application/x-www-form-urlencoded'} + }; + this.c2dmOptions = { + host: 'android.apis.google.com', + port: 443, + path: '/c2dm/send', + method: 'POST', + headers: {} + }; } util.inherits(C2DM, emitter); @@ -36,27 +36,27 @@ util.inherits(C2DM, emitter); exports.C2DM = C2DM; C2DM.prototype.captureToken = function(err, token) { - this.token = token; + this.token = token; }; C2DM.prototype.login = function(cb) { - var self = this; - this.once('token', this.captureToken); + var self = this; + this.once('token', this.captureToken); - if (cb) this.once('token', cb); + if (cb) this.once('token', cb); - var postData = { - Email: this.user, - Passwd: this.password, - accountType: 'HOSTED_OR_GOOGLE', - source: this.source, - service: 'ac2dm' - }; + var postData = { + Email: this.user, + Passwd: this.password, + accountType: 'HOSTED_OR_GOOGLE', + source: this.source, + service: 'ac2dm' + }; - var request = https.request(this.loginOptions, function(res) { - var data = ''; + var request = https.request(this.loginOptions, function(res) { + var data = ''; function respond() { - var idx = data.indexOf('Auth='); + var idx = data.indexOf('Auth='); if (idx < 0) { self.emit('token', data, null); } else { @@ -68,30 +68,30 @@ C2DM.prototype.login = function(cb) { }); res.on('end', respond); res.on('close', respond); - }); - request.end(querystring.stringify(postData)); + }); + request.end(querystring.stringify(postData)); }; C2DM.prototype.send = function(packet, cb) { - var self = this; - if (cb) this.once('sent', cb); + var self = this; + if (cb) this.once('sent', cb); - var postData = querystring.stringify(packet); - var headers = { - //'Connection': 'keep-alive', - 'Host': 'android.apis.google.com', - 'Authorization': 'GoogleLogin ' + this.token, - 'Content-Type': 'application/x-www-form-urlencoded', - 'Content-length': postData.length - }; - this.c2dmOptions.headers = headers; - if (this.keepAlive) - headers.Connection = 'keep-alive'; + var postData = querystring.stringify(packet); + var headers = { + //'Connection': 'keep-alive', + 'Host': 'android.apis.google.com', + 'Authorization': 'GoogleLogin ' + this.token, + 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-length': postData.length + }; + this.c2dmOptions.headers = headers; + if (this.keepAlive) + headers.Connection = 'keep-alive'; - var request = https.request(this.c2dmOptions, function(res) { - var data = ''; + var request = https.request(this.c2dmOptions, function(res) { + var data = ''; function respond() { - var idx = data.indexOf('id='); + var idx = data.indexOf('id='); if (idx < 0) { self.emit('sent', data, null); } else { @@ -103,6 +103,6 @@ C2DM.prototype.send = function(packet, cb) { }); res.on('end', respond); res.on('close', respond); - }); - request.end(postData); + }); + request.end(postData); };