smsRuby 1.0.0-x86-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +20 -0
- data/ext/Makefile +157 -0
- data/ext/RecieveSMS.o +0 -0
- data/ext/SendSMS.o +0 -0
- data/ext/extconf.rb +6 -0
- data/ext/sms.i +8 -0
- data/ext/sms.o +0 -0
- data/ext/sms.so +0 -0
- data/ext/sms_wrap.c +3606 -0
- data/ext/sms_wrap.o +0 -0
- data/lib/sms.so +0 -0
- data/lib/smsruby.rb +199 -0
- data/lib/smsruby.rb~ +199 -0
- data/lib/smsruby/adm_connection.rb +539 -0
- data/lib/smsruby/adm_connection.rb~ +539 -0
- data/lib/smsruby/connection.rb +141 -0
- data/lib/smsruby/connection.rb~ +141 -0
- data/lib/smsruby/error.rb +40 -0
- data/lib/smsruby/receive.rb +97 -0
- data/lib/smsruby/receive.rb~ +97 -0
- data/lib/smsruby/send.rb +182 -0
- data/lib/smsruby/send.rb~ +182 -0
- metadata +84 -0
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'sms'
|
2
|
+
require 'smsruby/error'
|
3
|
+
|
4
|
+
#
|
5
|
+
# The Connection class represent the connection layer. Contains all values that
|
6
|
+
# describe an available connection that is associated with an attach phone.
|
7
|
+
# Implements methods for comunicating with the phone for send/receive messages
|
8
|
+
# and for obtain information about associated phone
|
9
|
+
#
|
10
|
+
class Connection
|
11
|
+
|
12
|
+
include Sms
|
13
|
+
|
14
|
+
# Reference the status of the current connection
|
15
|
+
attr_accessor :status
|
16
|
+
# Reference if the current connection it's allow to send, receive or both
|
17
|
+
attr_accessor :typec
|
18
|
+
# Reference the associated port for the current connection
|
19
|
+
attr_reader :port
|
20
|
+
# Represent the unique id of the current connection
|
21
|
+
attr_reader :id_connection
|
22
|
+
# Reference model of the phone attached to the current connection
|
23
|
+
attr_reader :phone_model
|
24
|
+
# Reference manufacter of the phone attached to the current connection
|
25
|
+
attr_reader :phone_manufacter
|
26
|
+
# Reference the installed software revition in the phone attached to the current connection
|
27
|
+
attr_reader :phone_revsoft
|
28
|
+
# Reference imei of the phone attached to the current connection
|
29
|
+
attr_reader :phone_imei
|
30
|
+
|
31
|
+
|
32
|
+
#
|
33
|
+
# Initialize the connection reprensented by name through businit function provided
|
34
|
+
# by the sms shared object. In the same way initialize all class attributes.
|
35
|
+
#
|
36
|
+
def initialize(name,port)
|
37
|
+
begin
|
38
|
+
if RUBY_PLATFORM =~ /(win|w)32$/
|
39
|
+
path = ENV['userprofile']+'/_gnokiirc'
|
40
|
+
elsif RUBY_PLATFORM =~ /linux/
|
41
|
+
path = ENV['HOME']+'/.gnokiirc'
|
42
|
+
end
|
43
|
+
error=businit(name, path)
|
44
|
+
error <= 0 ? (error==-500 ? (raise "The maximum number of connection has been open") : @id_connection=error.to_i*-1) : exception(error)
|
45
|
+
@port = port
|
46
|
+
@phone_model=phoneModel(@id_connection)
|
47
|
+
@phone_manufacter=phoneManufacter(@id_connection)
|
48
|
+
@phone_revsoft=phoneRevSoft(@id_connection)
|
49
|
+
@phone_imei=(phoneImei(@id_connection)).gsub(/[\s\D]/, "")
|
50
|
+
@typec='none'
|
51
|
+
@status='available'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Allow to test and existing connection to verify if is still available. Return
|
57
|
+
# 0 if is still available, diferent from 0 otherwise.
|
58
|
+
#
|
59
|
+
def test
|
60
|
+
return testconn(@id_connection)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Return the signal level of the phone asociatted with the current connection
|
65
|
+
#
|
66
|
+
def signallevel
|
67
|
+
return rf_level(@id_connection)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Return the battery level of the phone asociatted with the current connection
|
72
|
+
#
|
73
|
+
def batterylevel
|
74
|
+
return bat_level(@id_connection)
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Terminate the current connection
|
79
|
+
#
|
80
|
+
def close
|
81
|
+
busterminate(@id_connection)
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Execute a specific function from the shared object depending of type option value
|
86
|
+
# specified in hsh. If an error occurs an exception will be thrown
|
87
|
+
#
|
88
|
+
def execute(hsh)
|
89
|
+
cmd = hsh[:type]
|
90
|
+
|
91
|
+
case cmd
|
92
|
+
when /send/
|
93
|
+
@status = 'sending'
|
94
|
+
error = 0
|
95
|
+
puts ":: Manufacter sending the message: "+@phone_manufacter.to_s+' in port: '+@port.to_s+' with id: '+@id_connection.to_s+"\n"
|
96
|
+
error= send_sms(hsh[:dst], hsh[:msj], hsh[:smsc], hsh[:report], hsh[:validity], @id_connection)
|
97
|
+
#puts ':: The return error in execute send function is: '+error.to_s+"\n"
|
98
|
+
sleep(7)
|
99
|
+
when /receive/
|
100
|
+
@status = 'receiving'
|
101
|
+
msj=[]
|
102
|
+
nmsj=0
|
103
|
+
error = get_sms(@id_connection)
|
104
|
+
error <= 0 ? number=error.to_i*-1 : exception(error)
|
105
|
+
number.times { |i|
|
106
|
+
m = get_msj(i,@id_connection)
|
107
|
+
if(m.type_sms.eql?("Inbox Message"))
|
108
|
+
msj[nmsj] = m if (m.error == 0)
|
109
|
+
nmsj+=1 if m.error ==0
|
110
|
+
end
|
111
|
+
}
|
112
|
+
return msj
|
113
|
+
end
|
114
|
+
exception(error) unless error==0
|
115
|
+
end
|
116
|
+
|
117
|
+
def type(status)
|
118
|
+
case status
|
119
|
+
when 0 then return "unread"
|
120
|
+
when 1 then return "read"
|
121
|
+
when 2 then return "sent"
|
122
|
+
when 3 then return "unsent"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Throws a diferent exception depending of specified error code
|
128
|
+
#
|
129
|
+
def exception (error)
|
130
|
+
case error
|
131
|
+
when 1..9 then raise ErrorHandler::GeneralError.new(error)
|
132
|
+
when 10..15 then raise ErrorHandler::StatemachineError.new(error)
|
133
|
+
when 16..18 then raise ErrorHandler::LocationError.new(error)
|
134
|
+
when 19..21 then raise ErrorHandler::FormatError.new(error)
|
135
|
+
when 22..25 then raise ErrorHandler::CallError.new(error)
|
136
|
+
when 26..29 then raise ErrorHandler::OtherError.new(error)
|
137
|
+
when 30..35 then raise ErrorHandler::ConfigError.new(error)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'sms'
|
2
|
+
require 'smsruby/error'
|
3
|
+
|
4
|
+
#
|
5
|
+
# The Connection class represent the connection layer. Contains all values that
|
6
|
+
# describe an available connection that is associated with an attach phone.
|
7
|
+
# Implements methods for comunicating with the phone for send/receive messages
|
8
|
+
# and for obtain information about associated phone
|
9
|
+
#
|
10
|
+
class Connection
|
11
|
+
|
12
|
+
include Sms
|
13
|
+
|
14
|
+
# Reference the status of the current connection
|
15
|
+
attr_accessor :status
|
16
|
+
# Reference if the current connection it's allow to send, receive or both
|
17
|
+
attr_accessor :typec
|
18
|
+
# Reference the associated port for the current connection
|
19
|
+
attr_reader :port
|
20
|
+
# Represent the unique id of the current connection
|
21
|
+
attr_reader :id_connection
|
22
|
+
# Reference model of the phone attached to the current connection
|
23
|
+
attr_reader :phone_model
|
24
|
+
# Reference manufacter of the phone attached to the current connection
|
25
|
+
attr_reader :phone_manufacter
|
26
|
+
# Reference the installed software revition in the phone attached to the current connection
|
27
|
+
attr_reader :phone_revsoft
|
28
|
+
# Reference imei of the phone attached to the current connection
|
29
|
+
attr_reader :phone_imei
|
30
|
+
|
31
|
+
|
32
|
+
#
|
33
|
+
# Initialize the connection reprensented by name through businit function provided
|
34
|
+
# by the sms shared object. In the same way initialize all class attributes.
|
35
|
+
#
|
36
|
+
def initialize(name,port)
|
37
|
+
begin
|
38
|
+
if RUBY_PLATFORM =~ /(win|w)32$/
|
39
|
+
path = ENV['userprofile']+'/_gnokiirc'
|
40
|
+
elsif RUBY_PLATFORM =~ /linux/
|
41
|
+
path = ENV['HOME']+'/.gnokiirc'
|
42
|
+
end
|
43
|
+
error=businit(name, path)
|
44
|
+
error <= 0 ? (error==-10 ? (raise "The maximum number of connection has been open") : @id_connection=error.to_i*-1) : exception(error)
|
45
|
+
@port = port
|
46
|
+
@phone_model=phoneModel(@id_connection)
|
47
|
+
@phone_manufacter=phoneManufacter(@id_connection)
|
48
|
+
@phone_revsoft=phoneRevSoft(@id_connection)
|
49
|
+
@phone_imei=(phoneImei(@id_connection)).gsub(/[\s\D]/, "")
|
50
|
+
@typec='none'
|
51
|
+
@status='available'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Allow to test and existing connection to verify if is still available. Return
|
57
|
+
# 0 if is still available, diferent from 0 otherwise.
|
58
|
+
#
|
59
|
+
def test
|
60
|
+
return testconn(@id_connection)
|
61
|
+
end
|
62
|
+
|
63
|
+
#
|
64
|
+
# Return the signal level of the phone asociatted with the current connection
|
65
|
+
#
|
66
|
+
def signallevel
|
67
|
+
return rf_level(@id_connection)
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Return the battery level of the phone asociatted with the current connection
|
72
|
+
#
|
73
|
+
def batterylevel
|
74
|
+
return bat_level(@id_connection)
|
75
|
+
end
|
76
|
+
|
77
|
+
#
|
78
|
+
# Terminate the current connection
|
79
|
+
#
|
80
|
+
def close
|
81
|
+
busterminate(@id_connection)
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Execute a specific function from the shared object depending of type option value
|
86
|
+
# specified in hsh. If an error occurs an exception will be thrown
|
87
|
+
#
|
88
|
+
def execute(hsh)
|
89
|
+
cmd = hsh[:type]
|
90
|
+
|
91
|
+
case cmd
|
92
|
+
when /send/
|
93
|
+
@status = 'sending'
|
94
|
+
error = 0
|
95
|
+
puts ":: Manufacter sending the message: "+@phone_manufacter.to_s+' in port: '+@port.to_s+' with id: '+@id_connection.to_s+"\n"
|
96
|
+
error= send_sms(hsh[:dst], hsh[:msj], hsh[:smsc], hsh[:report], hsh[:validity], @id_connection)
|
97
|
+
#puts ':: The return error in execute send function is: '+error.to_s+"\n"
|
98
|
+
sleep(7)
|
99
|
+
when /receive/
|
100
|
+
@status = 'receiving'
|
101
|
+
msj=[]
|
102
|
+
nmsj=0
|
103
|
+
error = get_sms(@id_connection)
|
104
|
+
error <= 0 ? number=error.to_i*-1 : exception(error)
|
105
|
+
number.times { |i|
|
106
|
+
m = get_msj(i,@id_connection)
|
107
|
+
if(m.type_sms.eql?("Inbox Message"))
|
108
|
+
msj[nmsj] = m if (m.error == 0)
|
109
|
+
nmsj+=1 if m.error ==0
|
110
|
+
end
|
111
|
+
}
|
112
|
+
return msj
|
113
|
+
end
|
114
|
+
exception(error) unless error==0
|
115
|
+
end
|
116
|
+
|
117
|
+
def type(status)
|
118
|
+
case status
|
119
|
+
when 0 then return "unread"
|
120
|
+
when 1 then return "read"
|
121
|
+
when 2 then return "sent"
|
122
|
+
when 3 then return "unsent"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
#
|
127
|
+
# Throws a diferent exception depending of specified error code
|
128
|
+
#
|
129
|
+
def exception (error)
|
130
|
+
case error
|
131
|
+
when 1..9 then raise ErrorHandler::GeneralError.new(error)
|
132
|
+
when 10..15 then raise ErrorHandler::StatemachineError.new(error)
|
133
|
+
when 16..18 then raise ErrorHandler::LocationError.new(error)
|
134
|
+
when 19..21 then raise ErrorHandler::FormatError.new(error)
|
135
|
+
when 22..25 then raise ErrorHandler::CallError.new(error)
|
136
|
+
when 26..29 then raise ErrorHandler::OtherError.new(error)
|
137
|
+
when 30..35 then raise ErrorHandler::ConfigError.new(error)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'sms'
|
2
|
+
module ErrorHandler
|
3
|
+
|
4
|
+
#
|
5
|
+
# The Error class represent the error layer. Inherit from standard error class
|
6
|
+
# of ruby and allows to give a more specific description about produced errors
|
7
|
+
#
|
8
|
+
class Error < StandardError
|
9
|
+
include Sms
|
10
|
+
|
11
|
+
# Reference the id of the current error
|
12
|
+
attr_reader :id
|
13
|
+
# Reference a string message description of the current error
|
14
|
+
attr_reader :message
|
15
|
+
|
16
|
+
#
|
17
|
+
# Initialize all attributes for error class receiving the id error. The
|
18
|
+
# printError function of the shared object is used to obtain the string
|
19
|
+
# message of the current error
|
20
|
+
#
|
21
|
+
def initialize(id)
|
22
|
+
@id = id
|
23
|
+
@message = printError(id)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Represent the diferent classes for particular given errors. All the classes
|
30
|
+
# inherits from Error class defined above.
|
31
|
+
#
|
32
|
+
class GeneralError < Error; end
|
33
|
+
class ConfigError < Error; end
|
34
|
+
class StatemachineError < Error; end
|
35
|
+
class CallError < Error; end
|
36
|
+
class OtherError < Error; end
|
37
|
+
class FormatError < Error; end
|
38
|
+
class LocationError < Error; end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'smsruby/adm_connection'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'sqlite3'
|
4
|
+
|
5
|
+
#
|
6
|
+
# The Receive class represent the receive layer. Handles the reception of messages
|
7
|
+
# and the initialization of multiples threads to allow multiples connections to receive
|
8
|
+
# messages simultaniously
|
9
|
+
#
|
10
|
+
class Receive
|
11
|
+
|
12
|
+
# Reference an instance for the Connection Administrator
|
13
|
+
attr_reader :adm
|
14
|
+
# Reference the list of messages
|
15
|
+
attr_reader :list
|
16
|
+
# Reference the type of receive that will be used (0: receive for a defined period of time, 1: receive messages ones )
|
17
|
+
attr_accessor :receivetype
|
18
|
+
# Represent the time in seconds that a particular connection will be receiving messages (for receivetype==0)
|
19
|
+
attr_accessor :time
|
20
|
+
|
21
|
+
|
22
|
+
#
|
23
|
+
# Obtains and instance of the Connection Administrator to control all existing
|
24
|
+
# connections. Due to the use of a singleton in the administrator, the same
|
25
|
+
# created instance will be obtain, or will be created if an instance doesn't
|
26
|
+
# exist. The type of receive and the period of time that will be used are passed
|
27
|
+
# to initialize method. An Exception is thrown if the instance of Admconnection fail
|
28
|
+
#
|
29
|
+
def initialize(type,time)
|
30
|
+
begin
|
31
|
+
@receivetype=type
|
32
|
+
@time =time
|
33
|
+
@adm = AdmConnection.instance
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Represent the receive method of the Receive class. Will create the reception threads
|
39
|
+
# acording with the imeis values passed as an argument. if imeis passed are nil will be
|
40
|
+
# created as many threads as connections configured to receive are found
|
41
|
+
#
|
42
|
+
def receive(imeis)
|
43
|
+
begin
|
44
|
+
if @adm.avlconn
|
45
|
+
if imeis
|
46
|
+
imeis.each do |i|
|
47
|
+
if @adm.get_connections.inject(false){|res,act| (act[1].phone_imei==i.to_s and act[1].status=='available' and (act[1].typec=='r' or act[1].typec=='sr')) || res}
|
48
|
+
t=Thread.new{receive_internal(i.to_s){|x,y| yield x,y if block_given? }}
|
49
|
+
t[:type]='r'
|
50
|
+
else
|
51
|
+
@adm.log.warn "Can't receive message in connection with imei: #{i}." unless @adm.log.nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
@adm.get_connections.select{ |n,act| (act.typec=='r' or act.typec=='sr') and act.status=='available'}.each do |i|
|
56
|
+
t=Thread.new{receive_internal(i[1].phone_imei){|x,y| yield x,y if block_given? }}
|
57
|
+
t[:type]='r'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise "There are no active connections"
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
@adm.log.error "Error receiving messages #{e.message}. Detail: #{e.message}" unless @adm.log.nil?
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Represent the method associated to the receive threads. Will handle the BD writting
|
71
|
+
# of the received messages and will make the call of recieve method in the Connection
|
72
|
+
# Administrator
|
73
|
+
#
|
74
|
+
def receive_internal(imei)
|
75
|
+
begin
|
76
|
+
db = SQLite3::Database.new('prueba.s3db')
|
77
|
+
@adm.receive(to_hash(imei)){ |x,y|
|
78
|
+
yield x,y if block_given?
|
79
|
+
db.execute("INSERT INTO inbox (smsdate,phone_number,text) VALUES " + "('#{x.date}', '#{x.source_number}','#{x.text}');")
|
80
|
+
}
|
81
|
+
rescue Exception => e
|
82
|
+
puts e.message
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Combine all option values into a hash to relate them
|
88
|
+
#
|
89
|
+
def to_hash(imei)
|
90
|
+
{ :type => 'receive',
|
91
|
+
:imei => imei.gsub(/[\s\D]/, ""),
|
92
|
+
:receivetype => self.receivetype,
|
93
|
+
:time => self.time
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'adm_connection'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'sqlite3'
|
4
|
+
|
5
|
+
#
|
6
|
+
# The Receive class represent the receive layer. Handles the reception of messages
|
7
|
+
# and the initialization of multiples threads to allow multiples connections to receive
|
8
|
+
# messages simultaniously
|
9
|
+
#
|
10
|
+
class Receive
|
11
|
+
|
12
|
+
# Reference an instance for the Connection Administrator
|
13
|
+
attr_reader :adm
|
14
|
+
# Reference the list of messages
|
15
|
+
attr_reader :list
|
16
|
+
# Reference the type of receive that will be used (0: receive for a defined period of time, 1: receive messages ones )
|
17
|
+
attr_accessor :receivetype
|
18
|
+
# Represent the time in seconds that a particular connection will be receiving messages (for receivetype==0)
|
19
|
+
attr_accessor :time
|
20
|
+
|
21
|
+
|
22
|
+
#
|
23
|
+
# Obtains and instance of the Connection Administrator to control all existing
|
24
|
+
# connections. Due to the use of a singleton in the administrator, the same
|
25
|
+
# created instance will be obtain, or will be created if an instance doesn't
|
26
|
+
# exist. The type of receive and the period of time that will be used are passed
|
27
|
+
# to initialize method. An Exception is thrown if the instance of Admconnection fail
|
28
|
+
#
|
29
|
+
def initialize(type,time)
|
30
|
+
begin
|
31
|
+
@receivetype=type
|
32
|
+
@time =time
|
33
|
+
@adm = AdmConnection.instance
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# Represent the receive method of the Receive class. Will create the reception threads
|
39
|
+
# acording with the imeis values passed as an argument. if imeis passed are nil will be
|
40
|
+
# created as many threads as connections configured to receive are found
|
41
|
+
#
|
42
|
+
def receive(imeis)
|
43
|
+
begin
|
44
|
+
if @adm.avlconn
|
45
|
+
if imeis
|
46
|
+
imeis.each do |i|
|
47
|
+
if @adm.get_connections.inject(false){|res,act| (act[1].phone_imei==i.to_s and act[1].status=='available' and (act[1].typec=='r' or act[1].typec=='sr')) || res}
|
48
|
+
t=Thread.new{receive_internal(i.to_s){|x,y| yield x,y if block_given? }}
|
49
|
+
t[:type]='r'
|
50
|
+
else
|
51
|
+
@adm.log.warn "Can't receive message in connection with imei: #{i}." unless @adm.log.nil?
|
52
|
+
end
|
53
|
+
end
|
54
|
+
else
|
55
|
+
@adm.get_connections.select{ |n,act| (act.typec=='r' or act.typec=='sr') and act.status=='available'}.each do |i|
|
56
|
+
t=Thread.new{receive_internal(i[1].phone_imei){|x,y| yield x,y if block_given? }}
|
57
|
+
t[:type]='r'
|
58
|
+
end
|
59
|
+
end
|
60
|
+
else
|
61
|
+
raise "There are no active connections"
|
62
|
+
end
|
63
|
+
rescue Exception => e
|
64
|
+
@adm.log.error "Error receiving messages #{e.message}. Detail: #{e.message}" unless @adm.log.nil?
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#
|
70
|
+
# Represent the method associated to the receive threads. Will handle the BD writting
|
71
|
+
# of the received messages and will make the call of recieve method in the Connection
|
72
|
+
# Administrator
|
73
|
+
#
|
74
|
+
def receive_internal(imei)
|
75
|
+
begin
|
76
|
+
db = SQLite3::Database.new('prueba.s3db')
|
77
|
+
@adm.receive(to_hash(imei)){ |x,y|
|
78
|
+
yield x,y if block_given?
|
79
|
+
db.execute("INSERT INTO inbox (smsdate,phone_number,text) VALUES " + "('#{x.date}', '#{x.source_number}','#{x.text}');")
|
80
|
+
}
|
81
|
+
rescue Exception => e
|
82
|
+
puts e.message
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
#
|
87
|
+
# Combine all option values into a hash to relate them
|
88
|
+
#
|
89
|
+
def to_hash(imei)
|
90
|
+
{ :type => 'receive',
|
91
|
+
:imei => imei.gsub(/[\s\D]/, ""),
|
92
|
+
:receivetype => self.receivetype,
|
93
|
+
:time => self.time
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|