mms2r 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,13 @@
1
+ == 1.1.8 / 2007-09-08 (James Grishnack - Head of Behemoth Productions, producer
2
+ of Blood Ocean)
3
+
4
+ * Added support for Orange of France, Orange orange.fr (Julian Biard)
5
+ * purge in the process block removed, purge must be called explicitly
6
+ after processing to clean up extracted temporary media files.
7
+
1
8
  == 1.1.7 / 2007-08-25 (Adam Nergal, friend of Skwisgaar, but not Pickles)
2
9
 
3
- * Added suport for Orange of Poland Orange mmsemail.orange.pl (Zbigniew
10
+ * Added suport for Orange of Poland, Orange mmsemail.orange.pl (Zbigniew
4
11
  Sobiecki)
5
12
  * Cleaned up documentation modifiers
6
13
  * Cleaned out non-Ruby code idioms
data/Manifest.txt CHANGED
@@ -11,6 +11,7 @@ conf/mms2r_media_ignore.yml
11
11
  conf/mms2r_media_subject.yml
12
12
  conf/mms2r_my_cingular_media_subject.yml
13
13
  conf/mms2r_nextel_media_ignore.yml
14
+ conf/mms2r_orange_france_media_ignore.yml
14
15
  conf/mms2r_orange_poland_media_subject.yml
15
16
  conf/mms2r_sprint_media_ignore.yml
16
17
  conf/mms2r_sprint_media_subject.yml
@@ -27,6 +28,7 @@ lib/mms2r/m_mode_media.rb
27
28
  lib/mms2r/media.rb
28
29
  lib/mms2r/my_cingular_media.rb
29
30
  lib/mms2r/nextel_media.rb
31
+ lib/mms2r/orange_france_media.rb
30
32
  lib/mms2r/orange_poland_media.rb
31
33
  lib/mms2r/sprint_media.rb
32
34
  lib/mms2r/sprint_pcs_media.rb
@@ -74,6 +76,7 @@ test/fixtures/nextel-image-01.mail
74
76
  test/fixtures/nextel-image-02.mail
75
77
  test/fixtures/nextel-image-03.mail
76
78
  test/fixtures/nextel-image-04.mail
79
+ test/fixtures/orangefrance-text-and-image.mail
77
80
  test/fixtures/orangepoland-text-01.mail
78
81
  test/fixtures/orangepoland-text-02.mail
79
82
  test/fixtures/simple-with-two-images-two-texts.mail
@@ -102,6 +105,7 @@ test/test_mms2r_m_mode_media.rb
102
105
  test/test_mms2r_media.rb
103
106
  test/test_mms2r_my_cingular_media.rb
104
107
  test/test_mms2r_nextel_media.rb
108
+ test/test_mms2r_orange_france_media.rb
105
109
  test/test_mms2r_orange_poland_media.rb
106
110
  test/test_mms2r_sprint_media.rb
107
111
  test/test_mms2r_sprint_pcs_media.rb
data/README.txt CHANGED
@@ -26,6 +26,7 @@ Corpus of carriers currently processed by MMS2R:
26
26
  * Helio => mms.myhelio.com
27
27
  * Nextel => messaging.nextel.com
28
28
  * Orange (Poland) => mmsemail.orange.pl
29
+ * Orange (France) => orange.fr
29
30
  * Sprint => pm.sprint.com
30
31
  * Sprint => messaging.sprintpcs.com
31
32
  * T-Mobile => tmomail.net
@@ -0,0 +1,6 @@
1
+ ---
2
+ application/smil:
3
+ - !ruby/regexp /^<smil><head><layout><root-layout height=/
4
+ text/plain:
5
+ - banniere.txt
6
+
data/lib/mms2r.rb CHANGED
@@ -13,6 +13,7 @@ require 'mms2r/helio_media'
13
13
  require 'mms2r/m_mode_media'
14
14
  require 'mms2r/my_cingular_media'
15
15
  require 'mms2r/nextel_media'
16
+ require 'mms2r/orange_france_media'
16
17
  require 'mms2r/orange_poland_media'
17
18
  require 'mms2r/sprint_media'
18
19
  require 'mms2r/sprint_pcs_media'
@@ -37,6 +38,7 @@ module MMS2R
37
38
  'mmode.com' => MMS2R::MModeMedia,
38
39
  'mms.mycingular.com' => MMS2R::MyCingularMedia,
39
40
  'messaging.nextel.com' => MMS2R::NextelMedia,
41
+ 'orange.fr' => MMS2R::OrangeFranceMedia,
40
42
  'mmsemail.orange.pl' => MMS2R::OrangePolandMedia,
41
43
  'pm.sprint.com' => MMS2R::SprintMedia,
42
44
  'messaging.sprintpcs.com' => MMS2R::SprintPcsMedia,
@@ -63,7 +65,7 @@ module MMS2R
63
65
  ##
64
66
  # MMS2R Library version
65
67
 
66
- VERSION = '1.1.7'
68
+ VERSION = '1.1.8'
67
69
 
68
70
  end
69
71
 
data/lib/mms2r/media.rb CHANGED
@@ -54,6 +54,11 @@ module MMS2R
54
54
 
55
55
  attr_reader :media_dir
56
56
 
57
+ ##
58
+ # Various multi-parts that are bundled into mail
59
+
60
+ MULTIPARTS_TO_SPLIT = [ 'multipart/related', 'multipart/alternative', 'multipart/mixed' ]
61
+
57
62
  ##
58
63
  # Factory method that creates MMS2R::Media products.
59
64
  #
@@ -180,22 +185,21 @@ module MMS2R
180
185
  # overridden unless there is an extreme special case in processing the
181
186
  # media of a MMS (like Sprint)
182
187
  #
183
- # Helpers methods for the process template:
188
+ # Helper methods for the process template:
184
189
  # * ignore_media? -- true if the media contained in a part should be ignored.
185
190
  # * process_media -- retrieves media to temporary file, returns path to file.
186
191
  # * transform_text -- called by process_media, strips out advertising.
187
192
  # * temp_file -- creates a temporary filepath based on information from the part.
188
193
  #
189
194
  # Block support:
190
- # Calling process() with a block to automatically iterate through media
191
- # and *purge* after the block yields. For example, to process and receive
192
- # all media types of video, you can do:
195
+ # Calling process() with a block to automatically iterate through media.
196
+ # For example, to process and receive all media types of video, you can do:
193
197
  # mms.process do |media_type, file|
194
198
  # results << file if media_type =~ /video/
195
199
  # end
196
200
  #
197
- # note: auto-purging is a feature of calling process() with a block, purge
198
- # must be explicitly called otherwise
201
+ # note: purge must be explicitly called to remove the media files
202
+ # mms2r extracts from an mms message.
199
203
 
200
204
  def process() # :yields: media_type, file
201
205
  @logger.info("#{self.class} processing") unless @logger.nil?
@@ -210,7 +214,7 @@ module MMS2R
210
214
  # double check for multipart/related, if it exists
211
215
  # replace it with its children parts
212
216
  parts.each do |p|
213
- if self.class.part_type?(p).eql?('multipart/related')
217
+ if MULTIPARTS_TO_SPLIT.include?(self.class.part_type?(p))
214
218
  part = parts.delete(p)
215
219
  part.parts.each { |mp| parts << mp }
216
220
  end
@@ -238,7 +242,6 @@ module MMS2R
238
242
  if block_given?
239
243
  media.each do |k, v|
240
244
  yield(k, v)
241
- purge
242
245
  end
243
246
  end
244
247
 
@@ -289,9 +292,8 @@ module MMS2R
289
292
  if m.eql?('text') || type.eql?('application/smil')
290
293
  s = part.body.gsub(/\s+/m," ").strip
291
294
  break(i) if i.match(s)
292
- else
293
- break(i) if filename?(part).eql?(i)
294
295
  end
296
+ break(i) if filename?(part).eql?(i)
295
297
  end
296
298
  return ignore.eql?(a) ? false : true # when ignore is equal to 'a' that
297
299
  # means none of the breaks fired in
@@ -0,0 +1,10 @@
1
+ module MMS2R
2
+
3
+ ##
4
+ # Orange-France version of MMS2R::Media
5
+ #
6
+ # Orange uses multipart/mixed
7
+
8
+ class MMS2R::OrangeFranceMedia < MMS2R::Media
9
+ end
10
+ end
@@ -0,0 +1,68 @@
1
+ Message-ID: <803565.1188978142556.JavaMail.root@tn-03>
2
+ Date: Wed, 5 Sep 2007 09:42:22 +0200 (CEST)
3
+ From: <0688675309@orange.fr>
4
+ To: example@example.com
5
+ Mime-Version: 1.0
6
+ X-Mms-Delivery-Report: no
7
+ X-Mms-Delivery-Time: Wed, 05 Sep 2007 09:42:22 CEST
8
+ X-Mms-MMS-Version: 1.0
9
+ X-Mms-Message-Class: Personal
10
+ X-Mms-Message-Type: m-send-req
11
+ X-Mms-Message-Size: 56110
12
+ Original_Msg_Size: 56110
13
+ X-Mms-Read-Reply: no
14
+ X-Mms-Sender-Visibility: Show
15
+ X-Mms-Transaction-ID: 4660@
16
+ X-Mms-Message-ID: 5181920103@ericsson.mms.orange.fr
17
+ X-Priority: 3
18
+ X-MMS-OPERATOR: ORANGE
19
+ Content-Type: multipart/mixed; boundary="------------755776262782926"
20
+ X-Ovh-Remote: 80.12.242.30 (smtp59.orange.fr)
21
+ X-Ovh-Local: 213.186.33.73 (mx3.ovh.net)
22
+ X-Spam-Check: DONE|H 0.5/N
23
+
24
+ --------------755776262782926
25
+ Content-Type: multipart/mixed;
26
+ boundary="----=_Part_3197436_24584554.1188978142551"
27
+
28
+
29
+ ------=_Part_3197436_24584554.1188978142551
30
+ Content-Type: application/smil; charset=utf-8
31
+ Content-Transfer-Encoding: 7bit
32
+ Content-ID: <AAAA>
33
+
34
+
35
+ <smil><head><layout><root-layout height="1200px" width="1600px"/><region fit="hidden" height="1170px" id="Image" left="0px" top="0px" width="1600px"/><region fit="hidden" height="30px" id="Text" left="0px" top="1171px" width="1600px"/></layout></head><body><par dur="5000ms"><img region="Image" src="IMAGE.jpeg"/><text region="Text" src="Ar1.txt"/></par></body></smil>
36
+ ------=_Part_3197436_24584554.1188978142551
37
+ Content-Type: image/jpeg; name=IMAGE.jpeg
38
+ Content-Transfer-Encoding: base64
39
+ Content-ID: <IMAGE.jpeg>
40
+ Content-Location: IMAGE.jpeg
41
+
42
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
43
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
44
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
45
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
46
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
47
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
48
+ EQMRAD8AlgA6WW//2Q==
49
+ ------=_Part_3197436_24584554.1188978142551
50
+ Content-Type: text/plain; name=Ar1.txt; charset=utf-8
51
+ Content-Transfer-Encoding: 7bit
52
+ Content-ID: <Ar1.txt>
53
+ Content-Location: Ar1.txt
54
+
55
+ Test ma poule
56
+ ------=_Part_3197436_24584554.1188978142551--
57
+
58
+
59
+
60
+ --------------755776262782926
61
+ Content-Type: text/plain; name=banniere.txt; charset=iso-8859-1
62
+ Content-Transfer-Encoding: 8bit
63
+
64
+ Un abonn� Orange vous a envoy� ce message directement depuis son t�l�phone mobile. Vous aussi, communiquez en images avec MMS, les Messages Multim�dia. Rendez-vous sur www.orange.fr.
65
+
66
+ --------------755776262782926--
67
+
68
+
@@ -16,22 +16,6 @@ class MMS2R::MediaTest < Test::Unit::TestCase
16
16
  JENNYSNUMER = '2068675309'
17
17
  GENERIC_CARRIER = 'mms.example.com'
18
18
 
19
- CARRIER_TO_CLASS = {
20
- 'mms2r.media' => MMS2R::Media,
21
- 'mms.att.net' => MMS2R::ATTMedia,
22
- 'cingularme.com' => MMS2R::CingularMeMedia,
23
- 'mms.dobson.net' => MMS2R::DobsonMedia,
24
- 'mms.myhelio.com' => MMS2R::HelioMedia,
25
- 'mmode.com' => MMS2R::MModeMedia,
26
- 'mms.mycingular.com' => MMS2R::MyCingularMedia,
27
- 'messaging.nextel.com' => MMS2R::NextelMedia,
28
- 'pm.sprint.com' => MMS2R::SprintMedia,
29
- 'messaging.sprintpcs.com' => MMS2R::SprintPcsMedia,
30
- 'tmomail.net' => MMS2R::TMobileMedia,
31
- 'vzwpix.com' => MMS2R::VerizonMedia,
32
- 'vtext.com' => MMS2R::VtextMedia
33
- }
34
-
35
19
  def use_temp_dirs
36
20
  MMS2R::Media.tmp_dir = @tmpdir
37
21
  MMS2R::Media.conf_dir = @confdir
@@ -103,7 +87,8 @@ class MMS2R::MediaTest < Test::Unit::TestCase
103
87
  assert(File::exist?(file), "file #{file} does not exist")
104
88
  assert(File.basename(file) =~ /spacer\.gif/, "file #{file} does not exist")
105
89
  end
106
- assert !File.exist?(file_array.first)
90
+ # mms.purge has to be called manually
91
+ assert File.exist?(file_array.first)
107
92
  end
108
93
 
109
94
  def test_collect_text_plain
@@ -159,7 +144,7 @@ class MMS2R::MediaTest < Test::Unit::TestCase
159
144
  end
160
145
 
161
146
  def test_create
162
- CARRIER_TO_CLASS.each {|car, cls|
147
+ MMS2R::CARRIER_CLASSES.each do |car, cls|
163
148
  mail = TMail::Mail.new
164
149
  mail.from = ["#{JENNYSNUMER}@#{car}"]
165
150
  mms = MMS2R::Media.create(mail)
@@ -167,16 +152,16 @@ class MMS2R::MediaTest < Test::Unit::TestCase
167
152
  mms = MMS2R::Media.create(mail)
168
153
  assert_equal cls, mms.class, "expected a #{cls} and received a #{mms.class}"
169
154
  assert_equal car, mms.carrier, "expected a #{car} and received a #{mms.carrier}"
170
- }
155
+ end
171
156
  end
172
157
 
173
158
  def test_logging
174
- CARRIER_TO_CLASS.each {|car, cls|
159
+ MMS2R::CARRIER_CLASSES.each do |car, cls|
175
160
  mail = TMail::Mail.new
176
161
  mail.from = ["#{JENNYSNUMER}@#{car}"]
177
162
  mms = MMS2R::Media.create(mail,@log)
178
163
  assert_equal cls, mms.class, "expected a #{cls} and received a #{mms.class}"
179
- }
164
+ end
180
165
  end
181
166
 
182
167
  def test_tmp_dir
@@ -366,13 +351,13 @@ class MMS2R::MediaTest < Test::Unit::TestCase
366
351
  subjects = [nil, '', '(no subject)']
367
352
 
368
353
  mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
369
- subjects.each{|s|
354
+ subjects.each do |s|
370
355
  mail.subject = s
371
356
  mms = MMS2R::Media.create(mail)
372
357
  mms.process
373
358
  assert_equal nil, mms.get_subject, "Default subject not scrubbed."
374
359
  mms.purge
375
- }
360
+ end
376
361
 
377
362
  mail = TMail::Mail.parse(load_mail('hello_world_mail_plain_no_content_type.mail').join)
378
363
  mms = MMS2R::Media.create(mail)
@@ -0,0 +1,53 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), "..", "lib")
2
+ require File.dirname(__FILE__) + "/test_helper"
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mms2r'
6
+ require 'mms2r/media'
7
+ require 'tmail/mail'
8
+ require 'logger'
9
+
10
+ class MMS2R::OrangeFranceMediaTest < Test::Unit::TestCase
11
+ include MMS2R::TestHelper
12
+
13
+ def test_create_should_return_orange_france
14
+ mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
15
+ mms = MMS2R::Media.create(mail)
16
+ assert_equal MMS2R::OrangeFranceMedia, mms.class, "expected a #{MMS2R::OrangeFranceMedia} and received a #{mms.class}"
17
+ end
18
+
19
+ def test_empty_subject
20
+ mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
21
+ mms = MMS2R::Media.create(mail)
22
+ mms.process
23
+ assert_nil mms.get_subject
24
+ end
25
+
26
+ def test_processed_content
27
+ mail = TMail::Mail.parse(load_mail('orangefrance-text-and-image.mail').join)
28
+ mms = MMS2R::Media.create(mail)
29
+ mms.process
30
+
31
+ # there should be one text and one image
32
+ assert_equal 2, mms.media.size
33
+
34
+ #text
35
+ # there is a text banner that Orange attaches but
36
+ # that should be ignored
37
+ assert_not_nil mms.media['text/plain']
38
+ assert_equal 1, mms.media['text/plain'].size
39
+ file = mms.media['text/plain'].first
40
+ assert File::exist?(file), "file #{file} does not exist"
41
+ text = IO.readlines("#{file}").join
42
+ assert_match /Test ma poule/, text
43
+
44
+ # image
45
+ assert_not_nil mms.media['image/jpeg']
46
+ assert_equal 1, mms.media['image/jpeg'].size
47
+ assert_match /IMAGE.jpeg$/, mms.media['image/jpeg'].first
48
+ assert_file_size mms.media['image/jpeg'].first, 337
49
+
50
+ mms.purge
51
+ end
52
+
53
+ end
metadata CHANGED
@@ -3,15 +3,15 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: mms2r
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.7
7
- date: 2007-08-27 00:00:00 -07:00
6
+ version: 1.1.8
7
+ date: 2007-09-08 00:00:00 -07:00
8
8
  summary: Extract user media from MMS (and not carrier cruft)
9
9
  require_paths:
10
10
  - lib
11
11
  email: mikemondragon@gmail.com
12
12
  homepage: http://mms2r.rubyforge.org/
13
13
  rubyforge_project: mms2r
14
- description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * AT&T => mms.att.net * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Dobson/Cellular One => mms.dobson.net * Helio => mms.myhelio.com * Nextel => messaging.nextel.com * Orange (Poland) => mmsemail.orange.pl * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
14
+ description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the cellphone carriers. MMS messages are multipart email and the carriers often inject branding into these messages. Use MMS2R if you want to get at the real user generated content from a MMS without having to deal with the cruft from the carriers. If MMS2R is not aware of a particular carrier no extra processing is done to the MMS other than decoding and consolidating its media. Contact the author to add additional carriers to be processed by the library. Suggestions and patches appreciated and welcomed! Corpus of carriers currently processed by MMS2R: * AT&T => mms.att.net * AT&T/Cingular => mmode.com * Cingular => mms.mycingular.com * Cingular => cingularme.com * Dobson/Cellular One => mms.dobson.net * Helio => mms.myhelio.com * Nextel => messaging.nextel.com * Orange (Poland) => mmsemail.orange.pl * Orange (France) => orange.fr * Sprint => pm.sprint.com * Sprint => messaging.sprintpcs.com * T-Mobile => tmomail.net * Verizon => vzwpix.com * Verizon => vtext.com"
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -42,6 +42,7 @@ files:
42
42
  - conf/mms2r_media_subject.yml
43
43
  - conf/mms2r_my_cingular_media_subject.yml
44
44
  - conf/mms2r_nextel_media_ignore.yml
45
+ - conf/mms2r_orange_france_media_ignore.yml
45
46
  - conf/mms2r_orange_poland_media_subject.yml
46
47
  - conf/mms2r_sprint_media_ignore.yml
47
48
  - conf/mms2r_sprint_media_subject.yml
@@ -58,6 +59,7 @@ files:
58
59
  - lib/mms2r/media.rb
59
60
  - lib/mms2r/my_cingular_media.rb
60
61
  - lib/mms2r/nextel_media.rb
62
+ - lib/mms2r/orange_france_media.rb
61
63
  - lib/mms2r/orange_poland_media.rb
62
64
  - lib/mms2r/sprint_media.rb
63
65
  - lib/mms2r/sprint_pcs_media.rb
@@ -105,6 +107,7 @@ files:
105
107
  - test/fixtures/nextel-image-02.mail
106
108
  - test/fixtures/nextel-image-03.mail
107
109
  - test/fixtures/nextel-image-04.mail
110
+ - test/fixtures/orangefrance-text-and-image.mail
108
111
  - test/fixtures/orangepoland-text-01.mail
109
112
  - test/fixtures/orangepoland-text-02.mail
110
113
  - test/fixtures/simple-with-two-images-two-texts.mail
@@ -133,6 +136,7 @@ files:
133
136
  - test/test_mms2r_media.rb
134
137
  - test/test_mms2r_my_cingular_media.rb
135
138
  - test/test_mms2r_nextel_media.rb
139
+ - test/test_mms2r_orange_france_media.rb
136
140
  - test/test_mms2r_orange_poland_media.rb
137
141
  - test/test_mms2r_sprint_media.rb
138
142
  - test/test_mms2r_sprint_pcs_media.rb
@@ -152,6 +156,7 @@ test_files:
152
156
  - test/test_mms2r_sprint_media.rb
153
157
  - test/test_mms2r_vtext_media.rb
154
158
  - test/test_mms2r_dobson_media.rb
159
+ - test/test_mms2r_orange_france_media.rb
155
160
  - test/test_mms2r_m_mode_media.rb
156
161
  - test/test_mms2r_verizon_media.rb
157
162
  - test/test_helper.rb
@@ -196,5 +201,5 @@ dependencies:
196
201
  requirements:
197
202
  - - ">="
198
203
  - !ruby/object:Gem::Version
199
- version: 1.3.0
204
+ version: 1.2.1
200
205
  version: