def __init__(self, backend_interaction, component=False):
     '''
     @param backend_interaction: The handler for cumminicating with the logic of the backend.
     @type backend_interaction: ServerInteraction 
     '''
     #init XEPs
     MessageProtocol.__init__(self)
     LocationQuery.__init__(self)
     JabberRPC.__init__(self)
     IQBasedAvatar.__init__(self)
     PresenceClientProtocol.__init__(self)
     self.component = component
     
     #register rpc functions
     self.registerMethodCall('getSettings', self.onGetSettings)
     self.registerMethodCall('setSettings', self.onSetSettings)
     self.registerMethodCall('getUserInfo', self.onGetUserInfo)
     self.registerMethodCall('createFriendship', self.onCreateFriendship)
     self.registerMethodCall('destroyFriendship', self.onDestroyFriendship)
     
     #give the backend (ServerInteraction) a reference to this protocol handler
     self.backend = backend_interaction
     self.backend.set_server_component(self)
 def setUp(self):
     self.locquery = LocationQuery()
class LocationQueryTest(unittest.TestCase):

    '''
    NOTE: Some changes prevent this test from running without a FAIL. Use breakpoints for Debugging.
    '''
    
    def setUp(self):
        self.locquery = LocationQuery()

    def test_onLocationShare(self):
        #build iq
        self.iq = domish.Element((None, 'iq'))
        self.iq['id'] = '1234'
        self.iq['type'] = 'set'
        self.iq['from'] = '*****@*****.**'
        self.iq['to'] = '*****@*****.**'
        
        locationqueryElement = self.iq.addElement(('urn:xmpp:locationquery:0', 'locationquery'))
        locationqueryElement.addElement('lat', content = '70')
        locationqueryElement.addElement('lon', content = '100')
        locationqueryElement.addElement('accuracy', content = '20')
        locationqueryElement.addElement('region', content = 'Münsterland')
        
        print self.iq.toXml()
        
        #add callback
        self.locquery.onLocationShare = self.onLocationShareCallback
        
        #call _onLocationShare
        self.locquery._onLocationShare(self.iq)
        pass
    
    def onLocationShareCallback(self, senderJID, receiverUsername, geodata, iq):
        print geodata
        
    def test_onLocationQuery(self):
        #build iq
        self.iq = domish.Element((None, 'iq'))
        self.iq['id'] = '1234'
        self.iq['type'] = 'get'
        self.iq['from'] = '*****@*****.**'
        self.iq['to'] = '*****@*****.**'
        
        locationqueryElement = self.iq.addElement(('urn:xmpp:locationquery:0', 'locationquery'))
        locationqueryElement.addElement('lat', content = '70')
        locationqueryElement.addElement('lon', content = '100')
        locationqueryElement.addElement('accuracy', content = '20')
        locationqueryElement.addElement('region', content = 'Münsterland')
        
        #add callback
        self.locquery.onLocationShare = self.onLocationQueryCallback
        
        #call _onLocationShare
        self.locquery._onLocationQuery(self.iq)
        pass
    
    def onLocationQueryCallback(self, senderJID, geodata, iq):
        print geodata
        
    def test_ShareGeoLocMessage(self):
        geoData = dict()
        geoData['lat'] = 70
        geoData['region'] = 'Münsterland'
        geoMessage = ShareGeoLocMessage('*****@*****.**', '*****@*****.**', geoData)
        print geoMessage.toXml()
        pass
 def connectionInitialized(self):
     LocationQuery.connectionInitialized(self)
     JabberRPC.connectionInitialized(self)
     MessageProtocol.connectionInitialized(self)
     IQBasedAvatar.connectionInitialized(self)
     PresenceClientProtocol.connectionInitialized(self)