Permalink
Browse files

removed some old code

  • Loading branch information...
bjyoungblood committed Nov 15, 2011
1 parent ee5e002 commit 3c2db6d949702732ab37f5ae64cac9424b2940f6
Showing with 0 additions and 172 deletions.
  1. +0 −172 lib/models/sms.js
View
@@ -1,172 +0,0 @@
-/**
- * This file is part of Shorty.
- *
- * Shorty is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 3 of the License.
- *
- * Shorty is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Shorty. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category shorty
- * @license http://www.gnu.org/licenses/gpl-3.0.txt GPL
- * @copyright Copyright 2010 Evan Coury (http://www.Evan.pro/)
- * @package models
- */
-
-var smpp = require('../smpp'),
- pdu = require('./pdu'),
- pack = require('./utils/pack');
-
-var sms = function(sender, recipient, message, sequence_number, options) {
- var self = this;
- self.sender = sender;
- self.recipient = recipient;
- self.message = message;
- if (sequence_number === undefined) {
- self.sequence_number = 0;
- } else {
- self.sequence_number = sequence_number;
- }
-
- if (options === undefined) {
- self.options = {};
- } else {
- self.options = options;
- }
-
- self.confirmation = false;
- self.failureTimeout = null;
-
- self.toPdu = function(command) {
- var payload,
- source_addr_ton = 0x00,
- source_addr_npi = 0x00,
- dest_addr_ton = 0x00,
- dest_addr_npi = 0x00,
- esm_class = 0x00,
- protocol_id = 0x00,
- priority_flag = 0x00;
-
- if (self.options.source_addr_ton !== undefined) {
- source_addr_ton = self.options.source_addr_ton;
- }
-
- if (self.options.source_addr_npi !== undefined) {
- source_addr_npi = self.options.source_addr_npi;
- }
-
- if (self.options.dest_addr_ton !== undefined) {
- dest_addr_ton = self.options.dest_addr_ton;
- }
-
- if (self.options.dest_addr_npi !== undefined) {
- dest_addr_npi = self.options.dest_addr_npi;
- }
-
- if (self.options.esm_class !== undefined) {
- esm_class = self.options.esm_class;
- }
-
- if (self.options.protocol_id !== undefined) {
- protocol_id = self.options.protocol_id;
- }
-
- if (self.options.priority_flag !== undefined) {
- priority_flag = self.options.priority_flag;
- }
-
- payload = pack.pack(
- 'a1cca' + (self.sender.length + 1) + 'cca' + (self.recipient.length + 1) + 'ccca1a1cccccU' + (Buffer.byteLength(self.message, 'utf8')),
- "", //service_type
- source_addr_ton, //source_addr_ton
- source_addr_npi, //source_addr_npi
- self.sender, //source_addr
- dest_addr_ton, //dest_addr_ton
- dest_addr_npi, //dest_addr_npi
- self.recipient, //destination_addr
- esm_class, //esm_class
- protocol_id, //protocol_id
- priority_flag, //priority_flag
- "", //schedule_delivery_time
- "", //validity_period
- 0x00, //a couple fields,
- 0x00,
- 0x03,
- 0x00,
- Buffer.byteLength(self.message), //message length
- self.message); //message
-
- return pdu.createPdu(command, self.sequence_number, payload);
- };
-
-};
-
-exports.fromPdu = function(myPdu) {
-
- var i, from, to, length, message, sequence_number, start, end;
-
- // not really sure whether we'll run into encoding issues by using ascii encoding
- // over utf8, but it works for the moment
-
- for (i = 0; i < 6; i++) {
- if (myPdu.pdu_body[i] === 0x0) {
- break;
- }
- }
-
- i += 3;
-
- start = i;
- for (i; i <= start + 21; i++) {
- if (myPdu.pdu_body[i] === 0x0) {
- end = i; break;
- }
- }
-
- from = myPdu.pdu_body.toString('ascii', start, end);
-
- i += 3;
-
- start = i;
- for (i; i <= start + 21; i++) {
- if (myPdu.pdu_body[i] === 0x0) {
- end = i; break;
- }
- }
-
- to = myPdu.pdu_body.toString('ascii', start, end);
-
- i += 4;
-
- if (myPdu.pdu_body[i] === 0x0) {
- i++;
- } else {
- i += 17;
- }
-
- if (myPdu.pdu_body[i] === 0x0) {
- i++;
- } else {
- i += 17;
- }
-
- i += 4;
- length = myPdu.pdu_body[i];
-
- i++;
- message = myPdu.pdu_body.toString('utf8', i, i + length);
-
- sequence_number = myPdu.sequence_number;
-
- return new sms(from, to, message, sequence_number);
-};
-
-exports.create = function(sender, recipient, message, sequence_number, options) {
- return new sms(sender, recipient, message, sequence_number, options);
-};

0 comments on commit 3c2db6d

Please sign in to comment.