Changes

Line 312: Line 312:  
     #### Method: __init__, initialize this AnnotateActivity instance
 
     #### Method: __init__, initialize this AnnotateActivity instance
 
     def __init__(self, handle):
 
     def __init__(self, handle):
 +
 +
        ...
 +
    
         #Joining activity needs to know which stream tubes are available for downloading  
 
         #Joining activity needs to know which stream tubes are available for downloading  
Line 331: Line 334:  
                 # Wait for a successful join before trying to get the document
 
                 # Wait for a successful join before trying to get the document
 
                 self.connect("joined", self._joined_cb)
 
                 self.connect("joined", self._joined_cb)
 +
 +
        ...
 +
 +
    ######################## SETUP SERVER ON SHARING ACTIVITY ####################################
 +
 +
    #### Method _shared_cb, which is called when this activity is successfully
 +
    # shared on a mesh channel.
 +
    def _shared_cb(self, activity):
 +
        # We initiated this activity and have now shared it, so by
 +
        # definition we have the file.
 +
        _logger.debug('SYSTEM:', '_shared_cb(): Activity being shared')
 +
        self._want_document = False;
 +
        self._share_document()
 +
 +
    #### Method: _share_document, which sets up an http server that will serve a specific file to
 +
    # any joining activities.
 +
    def _share_document(self):
 +
        _logger.debug('SYSTEM', '_share_document() -- sharing file ' + str(object_path))
 +
        object_path = os.path.join(self.get_activity_root(), 'data', 'sample-shared-file.doc')
 +
 +
        _logger.debug('SYSTEM', '_share_document() -- Starting HTTP server on port '+str(self.port))
 +
        self._fileserver = AnnotateHTTPServer(("", self.port), object_path)
 +
 +
        # Make a tube for the server
 +
        chan = self._shared_activity.telepathy_tubes_chan
 +
        iface = chan[telepathy.CHANNEL_TYPE_TUBES]
 +
        self._fileserver_tube_id = iface.OfferStreamTube(ANNOTATE_STREAM_SERVICE,
 +
                {},
 +
                telepathy.SOCKET_ADDRESS_TYPE_IPV4,
 +
                ('127.0.0.1', dbus.UInt16(self.port)),
 +
                telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0)
     
Anonymous user