mms2r 2.0.5 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,20 @@
1
- == 2.0.5 / 2008-07-17 (Dr. Ralphus Galkensmelter - Psychological death expert)
1
+ ### 2.1.0 / 2008-07-30 (Dr. Gibbons Birthday expert and Murderface expert)
2
+
3
+ * 1 major enhancement:
4
+
5
+ * opens up TMail for improved query method patterned code in MMS2R
6
+
7
+ * 2 minor enhancements:
8
+
9
+ * UK O2 support mediamessaging.o2.co.uk - Jeremy Wilkins
10
+ * Write non text files with binary bit set on Windows - Nobody
11
+ * source hosted on github: git clone git://github.com/monde/mms2r.git
12
+
13
+ ### 2.0.5 / 2008-07-17 (Dr. Ralphus Galkensmelter - Psychological death expert)
2
14
 
3
15
  * Deal with Apple Mail multipart/appledouble - jesse dp
4
16
 
5
- == 2.0.4 / 2008-04-28 (Mr. Selatcia - elder member of The Tribunal)
17
+ ### 2.0.4 / 2008-04-28 (Mr. Selatcia - elder member of The Tribunal)
6
18
 
7
19
  * updated mms.vodacom4me.co.za Vodacom South Africa - Vijay Yellapragada
8
20
  * 1nbox.net / Idea cellular 1nbox.net - Vijay Yellapragada
@@ -14,7 +26,7 @@
14
26
  * mmsreply.t-mobile.co.uk / T-Mobile UK - Vijay Yellapragada
15
27
  * waw.plspictures.com / PLSPICTURES.COM mms hosting service
16
28
 
17
- == 2.0.3 / 2008-04-15 (Enter Taxman - The 1040 MMS Form)
29
+ ### 2.0.3 / 2008-04-15 (Enter Taxman - The 1040 MMS Form)
18
30
 
19
31
  * fix case when part is image/jpeg declared 'application/octet-stream'
20
32
  * trim dangling image/jpeg text from blackberry messages
@@ -23,7 +35,7 @@
23
35
  * T-Mobile update - jesse dp
24
36
  * AT&T/T-Mobile Blackberrry update - Dave Myron
25
37
 
26
- == 2.0.2 / 2008-02-22 (The Jomfru Brothers - proprietors of diefordethklok.com)
38
+ ### 2.0.2 / 2008-02-22 (The Jomfru Brothers - proprietors of diefordethklok.com)
27
39
 
28
40
  * added support for mms.vodacom4me.co.za Vodacom South Africa - Jason Haruska
29
41
  * added support for bellsouth.net - Jason Haruska
@@ -35,14 +47,14 @@
35
47
  * return sender's phone number for mms.luxgsm.lu
36
48
  * return sender's phone number for mms.vodacom4me.co.za
37
49
 
38
- == 2.0.1 / 2008-02-08 (Professor Jerry Gustav Munndig - Child control expert)
50
+ ### 2.0.1 / 2008-02-08 (Professor Jerry Gustav Munndig - Child control expert)
39
51
 
40
52
  * strip out common blackberry and iPhone signatures
41
53
  * handle carriers that use external mail services such as Yahoo! as the From address
42
54
  * Add support for mobile.indosat.net.id (and yahoo.co.id) - Jason Haruska
43
55
  * Add support for sms.sasktel.com - Jason Haruska
44
56
 
45
- == 2.0.0 / 2008-01-23 (Skwisgaar Skwigelf - fastest guitarist alive)
57
+ ### 2.0.0 / 2008-01-23 (Skwisgaar Skwigelf - fastest guitarist alive)
46
58
 
47
59
  * added support for pxt.vodafone.net.nz PXT New Zealand
48
60
  * added support for mms.o2online.de O2 Germany
@@ -67,13 +79,13 @@
67
79
  * fixed typo in name of method #attachement to #attachment
68
80
  * fixed broken downloading of Sprint videos
69
81
 
70
- == 1.1.12 / 2007-10-21 (Dr. Ronald von Moldenberg - Endorsement specialist)
82
+ ### 1.1.12 / 2007-10-21 (Dr. Ronald von Moldenberg - Endorsement specialist)
71
83
 
72
84
  * fetch original images from Sprint content server (Layton Wedgeworth)
73
85
  * ignore Sprint messages when requested content has been purged from their
74
86
  content server
75
87
 
76
- == 1.1.11 / 2007-10-20 (Dr. Armand Skagerakk Frederickshaven - Mythology expert)
88
+ ### 1.1.11 / 2007-10-20 (Dr. Armand Skagerakk Frederickshaven - Mythology expert)
77
89
 
78
90
  * minor fix for attachment_fu where it might call #path on the cgi temp file
79
91
  that is returned by get_attachment
@@ -89,62 +101,62 @@
89
101
  * #get_attachment marked deprecated, use #attachment instead
90
102
  * #get_media marked deprecated, use #default_media instead
91
103
 
92
- == 1.1.10 / 2007-09-30 (Face Bones)
104
+ ### 1.1.10 / 2007-09-30 (Face Bones)
93
105
 
94
106
  * fixed a case for a nil match on From in the create method (Luke Francl)
95
107
  * added support for Alltel message.alltel.com (Ben Wood)
96
108
 
97
- == 1.1.9 / 2007-09-08 (Rebecca Nightrod - controlling girlfriend of Nathan
109
+ ### 1.1.9 / 2007-09-08 (Rebecca Nightrod - controlling girlfriend of Nathan
98
110
  Explosion)
99
111
 
100
112
  * fixed broken support for act_as_attachment and attachment_fu
101
113
 
102
- == 1.1.8 / 2007-09-08 (James Grishnack - Head of Behemoth Productions, producer
114
+ ### 1.1.8 / 2007-09-08 (James Grishnack - Head of Behemoth Productions, producer
103
115
  of Blood Ocean)
104
116
 
105
117
  * Added support for Orange of France, Orange orange.fr (Julian Biard)
106
118
  * purge in the process block removed, purge must be called explicitly
107
119
  after processing to clean up extracted temporary media files.
108
120
 
109
- == 1.1.7 / 2007-08-25 (Adam Nergal, friend of Skwisgaar, but not Pickles)
121
+ ### 1.1.7 / 2007-08-25 (Adam Nergal, friend of Skwisgaar, but not Pickles)
110
122
 
111
123
  * Added support for Orange of Poland, Orange mmsemail.orange.pl (Zbigniew
112
124
  Sobiecki)
113
125
  * Cleaned up documentation modifiers
114
126
  * Cleaned out non-Ruby code idioms
115
127
 
116
- == 1.1.6 / 2007-08-11 (Mustakrakish, the Lake Troll part 2)
128
+ ### 1.1.6 / 2007-08-11 (Mustakrakish, the Lake Troll part 2)
117
129
 
118
130
  * Redo of release mistake of 1.1.5
119
131
 
120
- == 1.1.5 / 2007-08-11 (Mustakrakish, the Lake Troll)
132
+ ### 1.1.5 / 2007-08-11 (Mustakrakish, the Lake Troll)
121
133
 
122
134
  * AT&T => mms.att.net not clearing out default "multimedia message"
123
135
  subject to nil (Will Jessup)
124
136
  * Ignore case on default subject for all carriers in
125
137
  corresponding conf/mms2r_XXX_media_subject.yml
126
138
 
127
- == 1.1.4 / 2007-08-07 (Dr. Rockso)
139
+ ### 1.1.4 / 2007-08-07 (Dr. Rockso)
128
140
 
129
141
  * AT&T => mms.att.net support (thanks Mike Chen and Dave Myron)
130
142
  * get_body returns nil when there is not user text (sorry Will!)
131
143
 
132
- == 1.1.3 / 2007-07-10 (Charles Foster Ofdensen)
144
+ ### 1.1.3 / 2007-07-10 (Charles Foster Ofdensen)
133
145
 
134
146
  * Helio support by Will Jessup
135
147
  * get_subject returns nil on default carrier subjects
136
148
 
137
- == 1.1.2 / 2007-06-13 (Dethklok roadie #2)
149
+ ### 1.1.2 / 2007-06-13 (Dethklok roadie #2)
138
150
 
139
151
  * placed versioned hpricot dependency in Hoe's extra_deps (an attempt to
140
152
  appease firebrigade gods or not cause Gem::RemoteInstallationCancelled
141
153
  whichever you prefer)
142
154
 
143
- == 1.1.1 / 2007-06-11 (Dethklok roadie)
155
+ ### 1.1.1 / 2007-06-11 (Dethklok roadie)
144
156
 
145
157
  * rescue rcov non-dependency in Rakefile to make firebrigade happy
146
158
 
147
- == 1.1.0 / 2007-06-08 (Toki Wartooth)
159
+ ### 1.1.0 / 2007-06-08 (Toki Wartooth)
148
160
 
149
161
  * get_body to return body text (Luke Francl)
150
162
  * get_subject returns "" for default subjects now
@@ -163,7 +175,7 @@ Explosion)
163
175
  of that type if the more than one exits in the media (Luke Francl)
164
176
  * added block support to process() method (Shane Vitarana)
165
177
 
166
- == 1.0.7 / 2007-04-27 (Senator Stampingston)
178
+ ### 1.0.7 / 2007-04-27 (Senator Stampingston)
167
179
 
168
180
  * patch submitted by Luke Francl
169
181
  * added a get_subject method that returns nil when any MMS has a default
@@ -171,7 +183,7 @@ Explosion)
171
183
  * get_subject returns nil for '', 'Multimedia message', '(no subject)', 'You
172
184
  have new Picture Mail!'
173
185
 
174
- == 1.0.6 / 2007-04-24 (Pickles the Drummer)
186
+ ### 1.0.6 / 2007-04-24 (Pickles the Drummer)
175
187
 
176
188
  * patch submitted by Luke Francl
177
189
  * added support for mms.dobson.net (Dobson aka Cellular One) (Luke)
@@ -182,7 +194,7 @@ Explosion)
182
194
  * added get_text instance method that returns first non advertising text
183
195
  * File from get_text can be used by/with attachment_fu
184
196
 
185
- == 1.0.5 / 2007-04-10 (William Murderface)
197
+ ### 1.0.5 / 2007-04-10 (William Murderface)
186
198
 
187
199
  * patch submitted by Luke Francl
188
200
  * made ignore_media? start its text check from the start of the file (Luke)
@@ -196,7 +208,7 @@ Explosion)
196
208
  * added tests for 4 three samples of unique variants of Sprint/Nextel text
197
209
  * 100% test coverage!
198
210
 
199
- == 1.0.4 / 2007-04-09 (Metalocalypse)
211
+ ### 1.0.4 / 2007-04-09 (Metalocalypse)
200
212
 
201
213
  * fix teardown in test_mms2r_sprint.rb (shanesbrain.net)
202
214
  * clean up Net::HTTP in MMS2R::SprintMedia (shanesbrain.net)
@@ -204,12 +216,12 @@ Explosion)
204
216
  * fixed a nil issue with underlying tmp working dir
205
217
  * added exception handling around Net::HTTP in MMS2R::SprintMedia
206
218
 
207
- == 1.0.3 / 2007-04-05 (Paper Cut)
219
+ ### 1.0.3 / 2007-04-05 (Paper Cut)
208
220
 
209
221
  * Cleaned up packaging and errors in example found by Shane V.
210
222
  http://shanesbrain.net/
211
223
 
212
- == 1.0.2 / 2007-03-07
224
+ ### 1.0.2 / 2007-03-07
213
225
 
214
226
  * Reorganized tests and fixtures
215
227
  * Added carriers:
@@ -217,11 +229,11 @@ Explosion)
217
229
  * Nextel => messaging.nextel.com
218
230
  * Verizon => vtext.com
219
231
 
220
- == 1.0.1 / 2007-03-07
232
+ ### 1.0.1 / 2007-03-07
221
233
 
222
234
  * Flubbed RubyForge release ... do not use this.
223
235
 
224
- == 1.0.0 / 2007-03-06
236
+ ### 1.0.0 / 2007-03-06
225
237
 
226
238
  * Birthday!
227
239
  * AT&T/Cingular => mmode.com
@@ -5,6 +5,7 @@ Rakefile
5
5
  conf/1nbox.net.yml
6
6
  conf/aliases.yml
7
7
  conf/bellsouth.net.yml
8
+ conf/mediamessaging.o2.co.uk.yml
8
9
  conf/messaging.nextel.com.yml
9
10
  conf/mms.3ireland.ie.yml
10
11
  conf/mms.alltel.com.yml
@@ -34,6 +35,7 @@ dev_tools/debug_sprint_hpricot_parsing.rb
34
35
  lib/mms2r.rb
35
36
  lib/mms2r/media.rb
36
37
  lib/mms2r/media/sprint.rb
38
+ lib/tmail_ext.rb
37
39
  test/fixtures/1nbox-2images-01.mail
38
40
  test/fixtures/1nbox-2images-02.mail
39
41
  test/fixtures/1nbox-2images-03.mail
@@ -61,6 +63,7 @@ test/fixtures/indosat-image-01.mail
61
63
  test/fixtures/indosat-image-02.mail
62
64
  test/fixtures/luxgsm-image-01.mail
63
65
  test/fixtures/maroctelecom-france-mms-01.mail
66
+ test/fixtures/mediamessaging_o2_co_uk-image-01.mail
64
67
  test/fixtures/mmode-image-01.mail
65
68
  test/fixtures/mms.mycricket.com-pic-and-text.mail
66
69
  test/fixtures/mms.mycricket.com-pic.mail
@@ -109,6 +112,7 @@ test/fixtures/waw.plspictures.com-image-01.mail
109
112
  test/test_1nbox_net.rb
110
113
  test/test_bellsouth_net.rb
111
114
  test/test_helper.rb
115
+ test/test_mediamessaging_o2_co_uk.rb
112
116
  test/test_messaging_nextel_com.rb
113
117
  test/test_messaging_sprintpcs_com.rb
114
118
  test/test_mms2r_media.rb
data/README.txt CHANGED
@@ -4,7 +4,7 @@
4
4
  http://mms2r.rubyforge.org/
5
5
  http://rubyforge.org/tracker/?group_id=3065
6
6
 
7
- == DESCRIPTION:
7
+ == DESCRIPTION
8
8
 
9
9
  MMS2R is a library that decodes the parts of an MMS message to disk while
10
10
  stripping out advertising injected by the mobile carriers. MMS messages are
@@ -37,6 +37,7 @@ Corpus of carriers currently processed by MMS2R:
37
37
  * NetCom (Norway): mms.netcom.no
38
38
  * Nextel: messaging.nextel.com
39
39
  * O2 Germany: mms.o2online.de
40
+ * O2 UK: mediamessaging.o2.co.uk
40
41
  * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr
41
42
  * PXT New Zealand: pxt.vodafone.net.nz
42
43
  * Rogers of Canada: rci.rogers.com
@@ -55,7 +56,12 @@ Corpus of carriers currently processed by MMS2R:
55
56
  * #process can be made lazy when :process => :lazy is passed to new
56
57
  * logging is enabled when :logger => your_logger is passed to new
57
58
 
58
- == SYNOPSIS:
59
+ == BOOKS
60
+
61
+ MMS2R, Making email useful
62
+ http://peepcode.com/products/mms2r-pdf
63
+
64
+ == SYNOPSIS
59
65
 
60
66
  require 'rubygems'
61
67
  require 'mms2r'
@@ -112,37 +118,50 @@ Corpus of carriers currently processed by MMS2R:
112
118
  #remove all the media that was put to temporary disk
113
119
  mms.purge
114
120
 
115
- == REQUIREMENTS:
121
+ == REQUIREMENTS
116
122
 
117
123
  * Hpricot
118
124
  * TMail
119
125
 
120
- == INSTALL:
126
+ == INSTALL
121
127
 
122
128
  * sudo gem install mms2r
123
129
 
124
- == CONTRIBUTE:
130
+ <<<<<<< HEAD:README.txt
131
+ == SOURCE
132
+
133
+ git clone git://github.com/monde/mms2r.git
134
+ svn co svn://rubyforge.org/var/svn/mms2r/trunk mms2r
135
+
136
+ =======
137
+ >>>>>>> dcf89451ea7ba0ff098d0d7ebd8ea16db1cc44ef:README.txt
138
+ == CONTRIBUTE
125
139
 
126
140
  If you contribute a patch that is accepted then you'll get developer rights
127
141
  for the project on RubyForge. Please ensure your work includes 100% test
128
142
  converage. The library is ZenTest autotest discovery enabled so running
129
143
  autotest in the root of the project is very helpful during development.
130
144
 
131
- == Authors
145
+ == AUTHORS
132
146
 
133
147
  Copyright (c) 2007-2008 by Mike Mondragon (blog[http://blog.mondragon.cc/])
134
148
 
135
149
  MMS2R's Flickr page[http://www.flickr.com/photos/8627919@N05/]
136
150
 
137
- == Contributors
151
+ == CONTRIBUTORS
138
152
 
139
153
  * Luke Francl (blog[http://railspikes.com/])
140
154
  * Will Jessup (blog[http://www.willjessup.com/])
141
155
  * Shane Vitarana (blog[http://www.shanesbrain.net/])
142
156
  * Layton Wedgeworth (http://www.beenup2.com/)
143
157
  * Jason Haruska (blog[http://software.haruska.com/])
158
+ * Dave Myron (company[http://contentfree.com/])
159
+ * Vijay Yellapragada
160
+ * Jesse Dp
161
+ * "Nobody"
162
+ * Jeremy Wilkins
144
163
 
145
- == LICENSE:
164
+ == LICENSE
146
165
 
147
166
  (The MIT License)
148
167
 
@@ -0,0 +1,4 @@
1
+ ---
2
+ ignore:
3
+ text/plain:
4
+ - /This Media Message has been sent using an O2 camera phone/mi
@@ -39,12 +39,21 @@ module MMS2R
39
39
  ##
40
40
  # MMS2R library version
41
41
 
42
- VERSION = '2.0.5'
42
+ VERSION = '2.1.0'
43
43
 
44
44
  end
45
45
 
46
46
  end
47
47
 
48
+ require 'rubygems'
49
+ gem 'tmail', '>= 1.2.1'
50
+ require 'tmail/mail'
51
+ require 'fileutils'
52
+ require 'pathname'
53
+ require 'tmpdir'
54
+ require 'yaml'
55
+
56
+ require File.join(File.dirname(__FILE__), 'tmail_ext')
48
57
  require File.join(File.dirname(__FILE__), 'mms2r', 'media')
49
58
  require File.join(File.dirname(__FILE__), 'mms2r', 'media', 'sprint')
50
59
  MMS2R.register('pm.sprint.com', MMS2R::Media::Sprint)
@@ -4,20 +4,6 @@
4
4
  # Please see the LICENSE file for licensing information
5
5
  #++
6
6
 
7
- require 'rubygems'
8
- gem 'tmail', '>= 1.2.1'
9
- require 'tmail/mail'
10
- require 'fileutils'
11
- require 'pathname'
12
- require 'tmpdir'
13
- require 'yaml'
14
-
15
- class TMail::MessageIdHeader #:nodoc:
16
- def real_body
17
- @body
18
- end
19
- end
20
-
21
7
  ##
22
8
  # = Synopsis
23
9
  #
@@ -274,7 +260,7 @@ module MMS2R
274
260
  # Returns nil if there are not any video or image Files found.
275
261
 
276
262
  def default_media
277
- return @default_media ||= attachment(['video', 'image', 'text'])
263
+ @default_media ||= attachment(['video', 'image', 'text'])
278
264
  end
279
265
 
280
266
  # Returns a File with the most likely candidate that is text, or nil
@@ -286,7 +272,7 @@ module MMS2R
286
272
  # Returns nil if there are not any text Files found
287
273
 
288
274
  def default_text
289
- return @default_text ||= attachment(['text'])
275
+ @default_text ||= attachment(['text'])
290
276
  end
291
277
 
292
278
  ##
@@ -324,7 +310,7 @@ module MMS2R
324
310
  for i in 1..2
325
311
  flat = []
326
312
  parts.each do |p|
327
- if MULTIPARTS_TO_SPLIT.include?(self.class.part_type?(p))
313
+ if MULTIPARTS_TO_SPLIT.include?(p.part_type?)
328
314
  p.parts.each {|mp| flat << mp }
329
315
  else
330
316
  flat << p
@@ -335,7 +321,7 @@ module MMS2R
335
321
 
336
322
  # get to work
337
323
  parts.each do |p|
338
- t = self.class.part_type?(p)
324
+ t = p.part_type?
339
325
  unless ignore_media?(t,p)
340
326
  t,f = process_media(p)
341
327
  add_file(t,f) unless t.nil? || f.nil?
@@ -385,20 +371,23 @@ module MMS2R
385
371
  # TMail body auto-magically decodes quoted
386
372
  # printable for text/html type.
387
373
  file = temp_file(part)
388
- case
389
- when self.class.main_type?(part).eql?('text')
390
- type, content = transform_text_part(part)
391
- when self.class.part_type?(part).eql?('application/smil')
374
+ if part.main_type('text') == 'text' ||
375
+ part.content_type == 'application/smil'
392
376
  type, content = transform_text_part(part)
377
+ open_bits = 'w'
393
378
  else
394
- type = self.class.part_type?(part)
395
- type = type_from_filename(filename?(part)) if type == 'application/octet-stream'
379
+ if part.content_type == 'application/octet-stream'
380
+ type = type_from_filename(filename?(part))
381
+ else
382
+ type = part.content_type
383
+ end
396
384
  content = part.body
385
+ open_bits = 'wb' # open with binary bit for Windows for non text
397
386
  end
398
387
  return type, nil if content.nil? || content.empty?
399
388
 
400
389
  @logger.info("#{self.class} writing file #{file}") unless @logger.nil?
401
- File.open(file,'w'){ |f| f.write(content) }
390
+ File.open(file,'wb'){ |f| f.write(content) }
402
391
  return type, file
403
392
  end
404
393
 
@@ -432,7 +421,7 @@ module MMS2R
432
421
  # Helper for process_media template method to transform text.
433
422
 
434
423
  def transform_text_part(part)
435
- type = self.class.part_type?(part)
424
+ type = part.part_type?
436
425
  text = part.body.strip
437
426
  transform_text(type, text)
438
427
  end
@@ -490,11 +479,11 @@ module MMS2R
490
479
  if part['content-id'] && part['content-id'].real_body.strip =~ /^<(.+)>$/
491
480
  name = $1
492
481
  else
493
- name = "#{Time.now.to_f}.#{self.class.default_ext(self.class.part_type?(part))}"
482
+ name = "#{Time.now.to_f}.#{self.class.default_ext(part.part_type?)}"
494
483
  end
495
484
  end
496
485
  # XXX fwiw, janky look for dot extension 1 to 4 chars long
497
- name =~ /\..{1,4}$/ ? name : "#{name}.#{self.class.default_ext(self.class.part_type?(part))}"
486
+ name =~ /\..{1,4}$/ ? name : "#{name}.#{self.class.default_ext(part.part_type?)}"
498
487
  end
499
488
 
500
489
  ##
@@ -529,43 +518,18 @@ module MMS2R
529
518
  # id.
530
519
 
531
520
  def self.safe_message_id(mid)
532
- return "#{Time.now.to_i}" if mid.nil?
533
- mid.gsub(/\$|<|>|@|\./, "")
521
+ mid.nil? ? "#{Time.now.to_i}" : mid.gsub(/\$|<|>|@|\./, "")
534
522
  end
535
523
 
536
524
  ##
537
525
  # Returns a default file extension based on a content type
538
526
 
539
527
  def self.default_ext(content_type)
540
- ext = MMS2R::EXT[content_type]
541
- ext = content_type.split('/').last if ext.nil? rescue nil
528
+ ext = MMS2R::EXT[content_type] ||
529
+ content_type.split('/').last rescue nil
542
530
  ext
543
531
  end
544
532
 
545
- ##
546
- # Determines the mime-type of a part. Guarantees a type is returned.
547
-
548
- def self.part_type?(part)
549
- if part.content_type.nil?
550
- return 'text/plain'
551
- end
552
- part.content_type
553
- end
554
-
555
- ##
556
- # Determines the main type of the part's mime-type
557
-
558
- def self.main_type?(part)
559
- /^([^\/]+)\//.match(self.part_type?(part))[1]
560
- end
561
-
562
- ##
563
- # Determines the sub type of the part's mime-type
564
-
565
- def self.sub_type?(part)
566
- /\/([^\/]+)$/.match(self.part_type?(part))[1]
567
- end
568
-
569
533
  ##
570
534
  # Joins the generic mms2r configuration with the carrier specific
571
535
  # configuration.
@@ -45,7 +45,7 @@ module MMS2R
45
45
  #find the payload html
46
46
  doc = nil
47
47
  parts.each do |p|
48
- next unless self.class.part_type?(p).eql?('text/html')
48
+ next unless p.part_type? == 'text/html'
49
49
  d = Hpricot(p.body)
50
50
  title = d.at('title').inner_html
51
51
  if title =~ /You have new Picture Mail!/
@@ -53,7 +53,7 @@ module MMS2R
53
53
  @is_video = (p.body =~ /type=&quot;VIDEO&quot;&gt;/m ? true : false)
54
54
  end
55
55
  end
56
- return if doc.nil? #it was a dud
56
+ return if doc.nil? # it was a dud
57
57
  @is_video ||= false
58
58
 
59
59
  # break it down
@@ -0,0 +1,17 @@
1
+
2
+ class TMail::MessageIdHeader #:nodoc:
3
+ def real_body
4
+ @body
5
+ end
6
+ end
7
+
8
+ class TMail::Mail
9
+
10
+ ##
11
+ # Determines the mime-type of a part. Guarantees a type is returned.
12
+
13
+ def part_type?
14
+ self.content_type('text/plain')
15
+ end
16
+
17
+ end
@@ -0,0 +1,61 @@
1
+ Return-Path: <+2068675309@mediamessaging.o2.co.uk>
2
+ Delivered-To: testmail-tommy.tutone@example.com
3
+ Received: (qmail 4775 invoked from network); 18 Jul 2008 16:18:50 -0000
4
+ Received: from +2068675309@mediamessaging.o2.co.uk by ds2150.dedicated.turbodns.co.uk by uid 1005 with qmail-scanner-1.22
5
+ (clamdscan: 0.74. Clear:RC:0(192.109.216.142):.
6
+ Processed in 9.150085 secs); 18 Jul 2008 16:18:49 -0000
7
+ Received: from unknown (HELO relay5.materna-com.de) (192.109.216.142)
8
+ by ds2150.dedicated.turbodns.co.uk with SMTP; 18 Jul 2008 16:18:37 -0000
9
+ Received: from romulus.materna-com.de (romulus.materna-com.de [172.30.64.14])
10
+ by relay5.materna-com.de (Postfix-2.1-rc19/TIM-6.6.6) with ESMTP id 934745893FE
11
+ for <tommy.tutone@example.com>; Fri, 18 Jul 2008 18:47:42 +0200 (CEST)
12
+ Message-ID: <23041818.1216397891758.JavaMail.macs5@192.109.216.142>
13
+ Date: Fri, 18 Jul 2008 17:18:11 +0100 (BST)
14
+ From: +2068675309@mediamessaging.o2.co.uk
15
+ To: freddy.tutone@example.com
16
+ Subject: Office pic
17
+ MIME-Version: 1.0
18
+ Content-Type: multipart/related;
19
+ boundary="----=_Part_90339_494009.1216397887686"
20
+
21
+ ------=_Part_90339_494009.1216397887686
22
+ Content-Type: text/plain; charset=us-ascii
23
+ Content-Transfer-Encoding: 7bit
24
+
25
+ You have received a Media Message
26
+ This Media Message has been sent using an O2 camera phone.
27
+
28
+ Click here to view this message online
29
+ http://mediamessaging.o2.co.uk/mms2legacy/showMessage2.do?encMmsId=8BB0BB9DF2C3168F
30
+
31
+ To reply to this media message you will need to use your own camera phone.
32
+ Simply take a picture, or video and send it to the person that sent you this
33
+ message.
34
+
35
+ If you do not have a camera phone, get one today! Either visit
36
+ http://shop.o2.co.uk/shop/ or come and see us at your local o2 store.
37
+
38
+ Please note: You cannot reply to this message via email.
39
+
40
+ ------=_Part_90339_494009.1216397887686
41
+ Content-Type: image/jpeg; name=DSC00147.JPG
42
+ Content-Transfer-Encoding: base64
43
+ Content-Disposition: attachment; filename=DSC00147.JPG
44
+ Content-ID: <DSC00147.JPG>
45
+
46
+ /9j/4AAQSkZJRgABAQEASABIAAD/4QAWRXhpZgAATU0AKgAAAAgAAAAAAAD//gAXQ3JlYXRl
47
+ ZCB3aXRoIFRoZSBHSU1Q/9sAQwAFAwQEBAMFBAQEBQUFBgcMCAcHBwcPCwsJDBEPEhIRDxER
48
+ ExYcFxMUGhURERghGBodHR8fHxMXIiQiHiQcHh8e/9sAQwEFBQUHBgcOCAgOHhQRFB4eHh4e
49
+ Hh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e/8AAEQgAAQAB
50
+ AwEiAAIRAQMRAf/EABUAAQEAAAAAAAAAAAAAAAAAAAAH/8QAFBABAAAAAAAAAAAAAAAAAAAA
51
+ AP/EABUBAQEAAAAAAAAAAAAAAAAAAAcI/8QAFBEBAAAAAAAAAAAAAAAAAAAAAP/aAAwDAQAC
52
+ EQMRAD8AlgA6WW//2Q==
53
+ ------=_Part_90339_494009.1216397887686
54
+ Content-Type: text/plain; name=smil.txt; charset=utf-8
55
+ Content-Transfer-Encoding: 7bit
56
+ Content-Disposition: attachment; filename=smil.txt
57
+ Content-ID: <smil.txt>
58
+
59
+ Office pic
60
+ ------=_Part_90339_494009.1216397887686--
61
+
@@ -0,0 +1,52 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "mms2r")
2
+ require File.join(File.dirname(__FILE__), "test_helper")
3
+ require 'test/unit'
4
+ require 'rubygems'
5
+ require 'mocha'
6
+ gem 'tmail', '>= 1.2.1'
7
+ require 'tmail'
8
+
9
+ class TestMediamessagingO2CoUk < Test::Unit::TestCase
10
+ include MMS2R::TestHelper
11
+
12
+ def test_subject
13
+ mail = TMail::Mail.parse(load_mail('mediamessaging_o2_co_uk-image-01.mail').join)
14
+ mms = MMS2R::Media.new(mail)
15
+ assert_equal "Office pic", mms.subject
16
+ mms.purge
17
+ end
18
+
19
+ def test_image
20
+ mail = TMail::Mail.parse(load_mail('mediamessaging_o2_co_uk-image-01.mail').join)
21
+ mms = MMS2R::Media.new(mail)
22
+
23
+ assert_equal 2, mms.media.size
24
+ assert_not_nil mms.media['text/plain']
25
+ assert_equal 1, mms.media['text/plain'].size
26
+ assert_not_nil mms.media['image/jpeg']
27
+ assert_equal 1, mms.media['image/jpeg'].size
28
+ assert mms.media['image/jpeg'].detect{|f| File.size(f) == 337}
29
+
30
+ mms.purge
31
+ end
32
+
33
+ def test_default_media_should_return_user_generated_content
34
+ mail = TMail::Mail.parse(load_mail('mediamessaging_o2_co_uk-image-01.mail').join)
35
+ mms = MMS2R::Media.new(mail)
36
+ file = mms.default_media
37
+ assert_equal 337, file.size
38
+
39
+ mms.purge
40
+ end
41
+
42
+ def test_default_text_should_return_user_generated_content
43
+ mail = TMail::Mail.parse(load_mail('mediamessaging_o2_co_uk-image-01.mail').join)
44
+ mms = MMS2R::Media.new(mail)
45
+ file = mms.default_text
46
+ assert_equal 10, file.size
47
+ assert_equal "Office pic", file.read
48
+
49
+ mms.purge
50
+ end
51
+
52
+ end
@@ -40,8 +40,11 @@ class TestMms2rMedia < Test::Unit::TestCase
40
40
  :from => ['joe@example.com'],
41
41
  :multipart? => false,
42
42
  :parts => [],
43
+ :main_type => 'text',
43
44
  :content_type => 'text/plain',
45
+ :part_type? => 'text/plain',
44
46
  :sub_header => 'message.txt',
47
+
45
48
  :body => 'a',
46
49
  :header => {}
47
50
  }.except(keys)
@@ -83,24 +86,6 @@ class TestMms2rMedia < Test::Unit::TestCase
83
86
  assert_equal 'test', MMS2R::Media.default_ext('example/test')
84
87
  end
85
88
 
86
- def test_part_type
87
- part = stub(:content_type => nil)
88
- assert_equal 'text/plain', MMS2R::Media.part_type?(part)
89
-
90
- part = stub(:content_type => 'image/jpeg')
91
- assert_equal 'image/jpeg', MMS2R::Media.part_type?(part)
92
- end
93
-
94
- def test_main_type
95
- part = stub(:content_type => 'image/jpeg')
96
- assert_equal 'image', MMS2R::Media.main_type?(part)
97
- end
98
-
99
- def test_sub_type
100
- part = stub(:content_type => 'image/jpeg')
101
- assert_equal 'jpeg', MMS2R::Media.sub_type?(part)
102
- end
103
-
104
89
  def test_base_initialize_config_tries_to_open_default_config_yaml
105
90
  f = File.join(MMS2R::Media.conf_dir, 'mms2r_media.yml')
106
91
  YAML.expects(:load_file).once.with(f).returns({})
@@ -426,12 +411,12 @@ class TestMms2rMedia < Test::Unit::TestCase
426
411
  def test_filename_when_file_extension_missing_part
427
412
  name = 'foo'
428
413
  mms = MMS2R::Media.new(stub_mail())
429
- part = stub(:sub_header => name, :content_type => 'text/plain')
414
+ part = stub(:sub_header => name, :content_type => 'text/plain', :part_type? => 'text/plain')
430
415
  assert_equal 'foo.txt', mms.filename?(part)
431
416
 
432
417
  name = 'foo.janky'
433
418
  mms = MMS2R::Media.new(stub_mail())
434
- part = stub(:sub_header => name, :content_type => 'text/plain')
419
+ part = stub(:sub_header => name, :content_type => 'text/plain', :part_type? => 'text/plain')
435
420
  assert_equal 'foo.janky.txt', mms.filename?(part)
436
421
  end
437
422
 
@@ -510,7 +495,7 @@ class TestMms2rMedia < Test::Unit::TestCase
510
495
  name = 'foo.txt'
511
496
  mms = MMS2R::Media.new(stub_mail())
512
497
  mms.stubs(:transform_text_part).returns(['text/plain', nil])
513
- part = stub(:sub_header => name, :content_type => 'text/plain')
498
+ part = stub(:sub_header => name, :content_type => 'text/plain', :part_type? => 'text/plain', :main_type => 'text')
514
499
 
515
500
  assert_equal ['text/plain', nil], mms.process_media(part)
516
501
 
@@ -525,7 +510,7 @@ class TestMms2rMedia < Test::Unit::TestCase
525
510
  name = 'foo.txt'
526
511
  mms = MMS2R::Media.new(stub_mail())
527
512
  mms.stubs(:transform_text_part).returns(['text/plain', nil])
528
- part = stub(:sub_header => name, :content_type => 'text/plain')
513
+ part = stub(:sub_header => name, :content_type => 'text/plain', :part_type? => 'text/plain', :main_type => 'text')
529
514
 
530
515
  assert_equal ['text/plain', nil], mms.process_media(part)
531
516
 
@@ -538,7 +523,7 @@ class TestMms2rMedia < Test::Unit::TestCase
538
523
  name = 'foo.txt'
539
524
  mms = MMS2R::Media.new(stub_mail())
540
525
  mms.stubs(:transform_text_part).returns(['application/smil', nil])
541
- part = stub(:sub_header => name, :content_type => 'application/smil')
526
+ part = stub(:sub_header => name, :content_type => 'application/smil', :part_type? => 'application/smil', :main_type => 'application')
542
527
 
543
528
  assert_equal ['application/smil', nil], mms.process_media(part)
544
529
 
@@ -552,7 +537,7 @@ class TestMms2rMedia < Test::Unit::TestCase
552
537
  def test_process_media_for_application_octet_stream_when_image
553
538
  name = 'fake.jpg'
554
539
  mms = MMS2R::Media.new(stub_mail())
555
- part = stub(:sub_header => name, :content_type => 'application/octet-stream', :body => "data")
540
+ part = stub(:sub_header => name, :content_type => 'application/octet-stream', :part_type? => 'application/octet-stream', :body => "data", :main_type => 'application')
556
541
  result = mms.process_media(part)
557
542
  assert_equal 'image/jpeg', result.first
558
543
  assert_match(/fake\.jpg$/, result.last)
@@ -562,11 +547,13 @@ class TestMms2rMedia < Test::Unit::TestCase
562
547
  def test_process_media_for_all_other_media
563
548
  name = 'foo.txt'
564
549
  mms = MMS2R::Media.new(stub_mail())
565
- part = stub(:sub_header => name, :content_type => 'faux/text', :body => nil)
550
+ part = stub(:sub_header => name, :content_type => 'faux/text', :part_type? => 'faux/text', :body => nil)
551
+ part.expects(:main_type).with('text').returns('faux')
566
552
 
567
553
  assert_equal ['faux/text', nil], mms.process_media(part)
568
554
 
569
- part = stub(:sub_header => name, :content_type => 'faux/text', :body => 'hello world')
555
+ part = stub(:sub_header => name, :content_type => 'faux/text', :part_type? => 'faux/text', :body => 'hello world')
556
+ part.expects(:main_type).with('text').returns('faux')
570
557
  result = mms.process_media(part)
571
558
  assert_equal 'faux/text', result.first
572
559
  assert_equal 'hello world', IO.read(result.last)
@@ -604,15 +591,16 @@ class TestMms2rMedia < Test::Unit::TestCase
604
591
 
605
592
  def test_process_with_multipart_alternative_parts
606
593
  mail = stub_mail()
607
- plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :body => 'a')
608
- html = stub(:sub_header => 'message.html', :content_type => 'text/html', :body => 'a')
609
- multi = stub(:content_type => 'multipart/alternative', :parts => [plain, html])
594
+ plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :part_type? => 'text/plain', :body => 'a', :main_type => 'text')
595
+ html = stub(:sub_header => 'message.html', :content_type => 'text/html', :part_type? => 'text/html', :body => 'a', :main_type => 'text')
596
+ multi = stub(:content_type => 'multipart/alternative', :part_type? => 'multipart/alternative', :parts => [plain, html])
610
597
  mail.stubs(:multipart?).returns(true)
611
598
  mail.stubs(:parts).returns([multi])
612
599
 
613
600
  # the multipart/alternative should get flattend to text and html
614
601
  mms = MMS2R::Media.new(mail)
615
602
  assert_equal 2, mms.media.size
603
+ assert_equal 2, mms.media.size
616
604
  assert_not_nil mms.media['text/plain']
617
605
  assert_not_nil mms.media['text/html']
618
606
  assert_equal 1, mms.media['text/plain'].size
@@ -628,9 +616,9 @@ class TestMms2rMedia < Test::Unit::TestCase
628
616
 
629
617
  def test_process_when_media_is_ignored
630
618
  mail = stub_mail()
631
- plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :body => '')
632
- html = stub(:sub_header => 'message.html', :content_type => 'text/html', :body => '')
633
- multi = stub(:content_type => 'multipart/alternative', :parts => [plain, html])
619
+ plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :part_type? => 'text/plain', :body => '')
620
+ html = stub(:sub_header => 'message.html', :content_type => 'text/html', :part_type? => 'text/html', :body => '')
621
+ multi = stub(:content_type => 'multipart/alternative', :part_type? => 'multipart/alternative', :parts => [plain, html])
634
622
  mail.stubs(:multipart?).returns(true)
635
623
  mail.stubs(:parts).returns([multi])
636
624
  mms = MMS2R::Media.new(mail, :process => :lazy)
@@ -646,8 +634,8 @@ class TestMms2rMedia < Test::Unit::TestCase
646
634
  def test_process_when_yielding_to_a_block
647
635
  mail = stub_mail()
648
636
 
649
- plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :body => 'a')
650
- html = stub(:sub_header => 'message.html', :content_type => 'text/html', :body => 'b')
637
+ plain = stub(:sub_header => 'message.txt', :content_type => 'text/plain', :part_type? => 'text/plain', :body => 'a', :main_type => 'text')
638
+ html = stub(:sub_header => 'message.html', :content_type => 'text/html', :part_type? => 'text/html', :body => 'b', :main_type => 'text')
651
639
  mail.stubs(:multipart?).returns(true)
652
640
  mail.stubs(:parts).returns([plain, html])
653
641
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mms2r
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Mondragon
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-17 00:00:00 -07:00
12
+ date: 2008-07-30 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -34,15 +34,15 @@ dependencies:
34
34
  version:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: hoe
37
- type: :runtime
37
+ type: :development
38
38
  version_requirement:
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: 1.5.3
43
+ version: 1.7.0
44
44
  version:
45
- description: "== DESCRIPTION: MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile 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: * 1nbox/Idea: 1nbox.net * 3 Ireland: mms.3ireland.ie * Alltel: mms.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Bell South / Suncom: bellsouth.net * Cricket Wireless: mms.mycricket.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * INDOSAT M2: mobile.indosat.net.id * LUXGSM S.A.: mms.luxgsm.lu * Maroc Telecom / mms.mobileiam.ma * MTM South Africa: mms.mtn.co.za * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * Rogers of Canada: rci.rogers.com * SaskTel: sms.sasktel.com * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net, mmsreply.t-mobile.co.uk * Vodacom: mms.vodacom4me.co.za * Verizon: vzwpix.com, vtext.com * PLSPICTURES.COM mms hosting: waw.plspictures.com"
45
+ description: "== DESCRIPTION MMS2R is a library that decodes the parts of an MMS message to disk while stripping out advertising injected by the mobile 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: * 1nbox/Idea: 1nbox.net * 3 Ireland: mms.3ireland.ie * Alltel: mms.alltel.com * AT&T/Cingular/Legacy: mms.att.net, txt.att.net, mmode.com, mms.mycingular.com, cingularme.com * Bell South / Suncom: bellsouth.net * Cricket Wireless: mms.mycricket.com * Dobson/Cellular One: mms.dobson.net * Helio: mms.myhelio.com * Hutchison 3G UK Ltd: mms.three.co.uk * INDOSAT M2: mobile.indosat.net.id * LUXGSM S.A.: mms.luxgsm.lu * Maroc Telecom / mms.mobileiam.ma * MTM South Africa: mms.mtn.co.za * NetCom (Norway): mms.netcom.no * Nextel: messaging.nextel.com * O2 Germany: mms.o2online.de * O2 UK: mediamessaging.o2.co.uk * Orange & Regional Oranges: orangemms.net, mmsemail.orange.pl, orange.fr * PXT New Zealand: pxt.vodafone.net.nz * Rogers of Canada: rci.rogers.com * SaskTel: sms.sasktel.com * Sprint: pm.sprint.com, messaging.sprintpcs.com * T-Mobile: tmomail.net, mmsreply.t-mobile.co.uk * Vodacom: mms.vodacom4me.co.za * Verizon: vzwpix.com, vtext.com * PLSPICTURES.COM mms hosting: waw.plspictures.com"
46
46
  email: mikemondragon@gmail.com
47
47
  executables: []
48
48
 
@@ -60,6 +60,7 @@ files:
60
60
  - conf/1nbox.net.yml
61
61
  - conf/aliases.yml
62
62
  - conf/bellsouth.net.yml
63
+ - conf/mediamessaging.o2.co.uk.yml
63
64
  - conf/messaging.nextel.com.yml
64
65
  - conf/mms.3ireland.ie.yml
65
66
  - conf/mms.alltel.com.yml
@@ -89,6 +90,7 @@ files:
89
90
  - lib/mms2r.rb
90
91
  - lib/mms2r/media.rb
91
92
  - lib/mms2r/media/sprint.rb
93
+ - lib/tmail_ext.rb
92
94
  - test/fixtures/1nbox-2images-01.mail
93
95
  - test/fixtures/1nbox-2images-02.mail
94
96
  - test/fixtures/1nbox-2images-03.mail
@@ -116,6 +118,7 @@ files:
116
118
  - test/fixtures/indosat-image-02.mail
117
119
  - test/fixtures/luxgsm-image-01.mail
118
120
  - test/fixtures/maroctelecom-france-mms-01.mail
121
+ - test/fixtures/mediamessaging_o2_co_uk-image-01.mail
119
122
  - test/fixtures/mmode-image-01.mail
120
123
  - test/fixtures/mms.mycricket.com-pic-and-text.mail
121
124
  - test/fixtures/mms.mycricket.com-pic.mail
@@ -164,6 +167,7 @@ files:
164
167
  - test/test_1nbox_net.rb
165
168
  - test/test_bellsouth_net.rb
166
169
  - test/test_helper.rb
170
+ - test/test_mediamessaging_o2_co_uk.rb
167
171
  - test/test_messaging_nextel_com.rb
168
172
  - test/test_messaging_sprintpcs_com.rb
169
173
  - test/test_mms2r_media.rb
@@ -247,5 +251,6 @@ test_files:
247
251
  - test/test_helper.rb
248
252
  - test/test_mms_mobileiam_ma.rb
249
253
  - test/test_messaging_nextel_com.rb
254
+ - test/test_mediamessaging_o2_co_uk.rb
250
255
  - test/test_1nbox_net.rb
251
256
  - test/test_mms_vodacom4me_co_za.rb