[bc5d5b2] | 1 | <?xml version="1.0" encoding="iso-8859-1"?>
|
---|
| 2 | <!DOCTYPE html
|
---|
| 3 | PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
---|
| 4 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
---|
| 5 |
|
---|
| 6 | <html>
|
---|
| 7 | <head>
|
---|
| 8 | <title>doCrudeObexAppComm (m2a.rb)</title>
|
---|
| 9 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
---|
| 10 | <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
|
---|
| 11 | </head>
|
---|
| 12 | <body class="standalone-code">
|
---|
| 13 | <pre><span class="ruby-comment cmt"># File m2a.rb, line 24</span>
|
---|
| 14 | <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">doCrudeObexAppComm</span>
|
---|
| 15 | <span class="ruby-keyword kw">begin</span>
|
---|
| 16 | <span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
|
---|
| 17 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"ls"</span>
|
---|
| 18 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close_write</span>
|
---|
| 19 | <span class="ruby-identifier">lines</span> = <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">readlines</span>
|
---|
| 20 | <span class="ruby-identifier">cam</span> = <span class="ruby-identifier">getObexIOObject</span>
|
---|
| 21 | <span class="ruby-identifier">lines</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
---|
| 22 | <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp re">/Bild\(\d+\).jpg/</span>
|
---|
| 23 | <span class="ruby-comment cmt">#black-magic-ruby $& holds the match</span>
|
---|
| 24 | <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">$&</span>.<span class="ruby-identifier">nil?</span>
|
---|
| 25 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"get"</span>
|
---|
| 26 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$&</span>
|
---|
| 27 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">$destination</span><span class="ruby-operator">+</span><span class="ruby-value str">'/'</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&</span>
|
---|
| 28 | <span class="ruby-identifier">puts</span> <span class="ruby-value str">"copy picture "</span><span class="ruby-operator">+</span><span class="ruby-identifier">$&</span><span class="ruby-operator">+</span><span class="ruby-value str">" to to "</span><span class="ruby-operator">+</span><span class="ruby-identifier">$destination</span>
|
---|
| 29 | <span class="ruby-comment cmt">#delete picturea after copying? uncomment...</span>
|
---|
| 30 | <span class="ruby-comment cmt">#doesn't work on my phone:(</span>
|
---|
| 31 | <span class="ruby-comment cmt">#cam.puts "delete"</span>
|
---|
| 32 | <span class="ruby-comment cmt">#cam.puts $&</span>
|
---|
| 33 | <span class="ruby-keyword kw">end</span>
|
---|
| 34 | <span class="ruby-keyword kw">end</span>
|
---|
| 35 | <span class="ruby-keyword kw">rescue</span> <span class="ruby-constant">Exception</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">ex</span>
|
---|
| 36 | <span class="ruby-identifier">puts</span>(<span class="ruby-identifier">ex</span>.<span class="ruby-identifier">to_s</span>)
|
---|
| 37 | <span class="ruby-keyword kw">ensure</span>
|
---|
| 38 | <span class="ruby-comment cmt"># TODO: ensure connection is closed</span>
|
---|
| 39 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">puts</span> <span class="ruby-value str">"disconnect"</span>
|
---|
| 40 | <span class="ruby-identifier">cam</span>.<span class="ruby-identifier">close</span>
|
---|
| 41 | <span class="ruby-keyword kw">end</span>
|
---|
| 42 | <span class="ruby-keyword kw">end</span></pre>
|
---|
| 43 | </body>
|
---|
| 44 | </html>
|
---|