Class Jabber::FileTransfer::FileSource
In: lib/xmpp4r/bytestreams/helper/filetransfer.rb
Parent: Object
XMLStanza Message Presence Iq REXML::Element X IqQuery Error StreamHost IqSiFileRange IqSiFile StreamHostUsed IqSi XRosterItem RosterItem IqFeature XMUCUserItem XMUCUserInvite XDataField XDataReported XDataTitle XDataInstructions Feature Identity Item IqVcard Singleton IdGenerator Connection Client Component Comparable JID RuntimeError AuthenticationFailure ErrorException SOCKS5Error Stream SOCKS5Bytestreams SOCKS5BytestreamsTarget SOCKS5BytestreamsInitiator SOCKS5BytestreamsServerStreamHost TCPSocket SOCKS5Socket IBB IBBTarget IBBInitiator IqQuery IqQueryBytestreams IqQueryVersion IqQueryRoster IqQueryDiscoItems IqQueryDiscoInfo Responder SimpleResponder X XRoster XMUCUser XMUC XDelay XData MUCClient SimpleMUCClient Base DigestMD5 Plain FileSource StreamParser SOCKS5BytestreamsPeer SOCKS5BytestreamsServer IBBQueueItem Helper MUCBrowser Helper Helper lib/xmpp4r/authenticationfailure.rb lib/xmpp4r/idgenerator.rb lib/xmpp4r/connection.rb lib/xmpp4r/iq.rb lib/xmpp4r/jid.rb lib/xmpp4r/xmlstanza.rb lib/xmpp4r/errorexception.rb lib/xmpp4r/stream.rb lib/xmpp4r/client.rb lib/xmpp4r/x.rb lib/xmpp4r/streamparser.rb lib/xmpp4r/error.rb lib/xmpp4r/component.rb lib/xmpp4r/query.rb lib/xmpp4r/message.rb lib/xmpp4r/presence.rb lib/xmpp4r/bytestreams/helper/ibb/initiator.rb lib/xmpp4r/bytestreams/iq/si.rb lib/xmpp4r/bytestreams/iq/bytestreams.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/base.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/target.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/server.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/socks5.rb lib/xmpp4r/bytestreams/helper/socks5bytestreams/initiator.rb lib/xmpp4r/bytestreams/helper/ibb/base.rb lib/xmpp4r/bytestreams/helper/ibb/target.rb Bytestreams lib/xmpp4r/version/iq/version.rb lib/xmpp4r/version/helper/responder.rb lib/xmpp4r/version/helper/simpleresponder.rb Version lib/xmpp4r/roster/helper/roster.rb lib/xmpp4r/roster/iq/roster.rb lib/xmpp4r/roster/x/roster.rb Roster lib/xmpp4r/feature_negotiation/iq/feature.rb FeatureNegotiation lib/xmpp4r/muc/x/muc.rb lib/xmpp4r/muc/helper/mucclient.rb lib/xmpp4r/muc/x/mucuseritem.rb lib/xmpp4r/muc/helper/mucbrowser.rb lib/xmpp4r/muc/x/mucuserinvite.rb lib/xmpp4r/muc/helper/simplemucclient.rb MUC lib/xmpp4r/sasl.rb SASL lib/xmpp4r/bytestreams/helper/filetransfer.rb TransferSource FileTransfer lib/xmpp4r/delay/x/delay.rb Delay lib/xmpp4r/dataforms/x/data.rb Dataforms lib/xmpp4r/discovery/iq/discoinfo.rb lib/xmpp4r/discovery/iq/discoitems.rb Discovery lib/xmpp4r/vcard/helper/vcard.rb lib/xmpp4r/vcard/iq/vcard.rb Vcard Jabber dot/m_60_0.png

Simple implementation of TransferSource for sending simple files (supports ranged transfers)

Methods

can_range?   date   filename   length=   mime   new   read   seek   size  

Included Modules

TransferSource

Public Class methods

[Source]

    # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 67
67:       def initialize(filename)
68:         @file = File.new(filename)
69:         @filename = filename
70:         @bytes_read = 0
71:         @length = nil
72:       end

Public Instance methods

[Source]

     # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 115
115:       def can_range?
116:         true
117:       end

[Source]

    # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 88
88:       def date
89:         @file.mtime
90:       end

[Source]

    # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 74
74:       def filename
75:         File::basename @filename
76:       end

[Source]

     # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 111
111:       def length=(l)
112:         @length = l
113:       end

Everything is ‘application/octet-stream‘

[Source]

    # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 80
80:       def mime
81:         'application/octet-stream'
82:       end

Because it can_range?, this method implements length checking

[Source]

     # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 94
 94:       def read(length=512)
 95:         if @length
 96:           return nil if @bytes_read >= @length  # Already read everything requested
 97:           if @bytes_read + length > @length # Will we read more than requested?
 98:             length = @length - @bytes_read  # Truncate it!
 99:           end
100:         end
101:         
102:         buf = @file.read(length)
103:         @bytes_read += buf.size if buf
104:         buf
105:       end

[Source]

     # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 107
107:       def seek(position)
108:         @file.seek(position)
109:       end

[Source]

    # File lib/xmpp4r/bytestreams/helper/filetransfer.rb, line 84
84:       def size
85:         File.size @filename
86:       end

[Validate]