def onUserAdded(self, response, email, group, *callback_and_args_triple):
        '''this method is called when the addUser soapRequest get a response'''

        common.debug('add user: '******' ' + str(response.status))

        if response.status[0] == 200:
            # Now that we have the contact id, we show it
            self.contactManager.setContactIdXml(email, response.body)
            guid = response.body.split('<guid>')[1].split('</guid>')[0]
            self.emit('contact-added', email, guid, None, None, 'FLN', None,
                False)

            if group == '':
                self.emit('user-list-change')
            else:
                # once we now the id we can add it to a group
                self.addUserToGroup(email, group)
            if len(callback_and_args_triple[0]) == 3: # alias hack foo(bar, lol)
                func, acco, alias = callback_and_args_triple[0]
                if alias != '':
                    func(acco, alias)
        else:
            self.contactManager.removeContact(email)
            self.emit('user-list-change')
            self.emit('error', 'user-add-error',
                _('User could not be added: %s') % \
                common.parseSoapFault(response))
    def onUserAdded(self, response, email, group, *callback_and_args_triple):
        '''this method is called when the addUser soapRequest get a response'''

        common.debug('add user: '******' ' + str(response.status))

        if response.status[0] == 200:
            # Now that we have the contact id, we show it
            self.contactManager.setContactIdXml(email, response.body)
            guid = response.body.split('<guid>')[1].split('</guid>')[0]
            self.emit('contact-added', email, guid, None, None, 'FLN', None,
                      False)

            if group == '':
                self.emit('user-list-change')
            else:
                # once we now the id we can add it to a group
                self.addUserToGroup(email, group)
            if len(callback_and_args_triple[0]
                   ) == 3:  # alias hack foo(bar, lol)
                func, acco, alias = callback_and_args_triple[0]
                if alias != '':
                    func(acco, alias)
        else:
            self.contactManager.removeContact(email)
            self.emit('user-list-change')
            self.emit('error', 'user-add-error',
                _('User could not be added: %s') % \
                common.parseSoapFault(response))
 def onPmChanged(self, response, oldPm):
     return  # shhht! user exceeded the limit can be bad
     if response.status[0] != 200:
         self.emit('self-personal-message-changed', self.personalMessage,
                   oldPm)
         self.emit('error', 'pm-change-error',
                   common.parseSoapFault(response))
 def onNickChanged(self, response, oldNick):
     return # shhht! user exceeded the limit can be bad
     if response.status[0] != 200:
         #self.contactManager.setContactNick(self.user, oldNick)
         self.emit('self-nick-changed', self.nick, oldNick)
         self.emit('error', 'nick-change-error',
             common.parseSoapFault(response))
 def onNickChanged(self, response, oldNick):
     return  # shhht! user exceeded the limit can be bad
     if response.status[0] != 200:
         #self.contactManager.setContactNick(self.user, oldNick)
         self.emit('self-nick-changed', self.nick, oldNick)
         self.emit('error', 'nick-change-error',
                   common.parseSoapFault(response))
 def onAliasChanged(self, response, user, oldAlias):
     if response.status[0] != 200:
         self.emit('contact-attr-changed', user, 'alias', oldNick)
         self.contactManager.setContactAlias(user, oldNick)
         contact = self.contactManager.getContact(user)
         self.emit('user-attr-changed', contact)
         self.emit('error', 'nick-change-error',
                   common.parseSoapFault(response))
示例#7
0
 def onAliasChanged(self, response, user, oldAlias):
     if response.status[0] != 200:
         self.emit('contact-attr-changed', user, 'alias', oldNick)
         self.contactManager.setContactAlias(user, oldNick)
         contact = self.contactManager.getContact(user)
         self.emit('user-attr-changed', contact)
         self.emit('error', 'nick-change-error',
             common.parseSoapFault(response))
示例#8
0
 def onUserRemovedFromGroup(self, response, groupId, group, user):
     common.debug('remove user from group: ' + str(response.status))
     if response.status[0] == 200:
         self.emit('contact-removed-from-group', user, group)
     else:
         self.contactManager.addUserToGroup(user, groupId)
         self.emit('user-list-change')
         self.emit('error', 'user-remove-error', common.parseSoapFault(response))
示例#9
0
 def onUserAddedToGroup(self, response, user, group, groupId):
     common.debug('add user to group: ' + str(response.status))
     if response.status[0] == 200:
         self.emit('contact-added-to-group', user, group)
     else:
         self.contactManager.removeUserFromGroup(user, groupId)
         self.emit('user-list-change')
         self.emit('error', 'user-add-to-group-error', \
             _('User could not be added to group: %s') % \
             common.parseSoapFault(response))
    def onUserRemovedFromGroup(self, response, groupId, group, user):
        common.debug('remove user from group: ' + str(response.status))

        if response.status[0] == 200:
            self.emit('contact-removed-from-group', user, group)
        else:
            self.contactManager.addUserToGroup(user, groupId)
            self.emit('user-list-change')
            self.emit('error', 'user-remove-error',
                      common.parseSoapFault(response))
    def onUserAddedToGroup(self, response, user, group, groupId):
        common.debug('add user to group: ' + str(response.status))

        if response.status[0] == 200:
            self.emit('contact-added-to-group', user, group)
        else:
            self.contactManager.removeUserFromGroup(user, groupId)
            self.emit('user-list-change')
            self.emit('error', 'user-add-to-group-error', \
                _('User could not be added to group: %s') % \
                common.parseSoapFault(response))
示例#12
0
 def onUserRemoved(self, response, email, contact):
     '''this method is called when the removeUser soapRequest get a response
     renes means if we have to renew the di,ml,ab data'''
     common.debug('remove user: '******' ' + str(response.status))
     if response.status[0] == 200:
         self.emit('contact-removed', email)
     else:
         self.sendDL('ADL', email, '1')
         self.contactManager.addContact(contact)
         self.emit('error', 'user-remove-error',
             _('User could not be removed: %s') %
             common.parseSoapFault(response))
     self.emit('user-list-change')
    def onGroupRemoved(self, response, gid, group):
        '''this method is called when the removeGroup soap request get a response'''

        common.debug('remove group ' + str(response.status))

        if response.status[0] == 200:
            self.emit('group-removed', group)
        else:
            # TODO: change it to setGroup when it manages contacts
            self.contactManager.setGroup(gid, group)
            self.emit('user-list-change')
            self.emit(
                'error', 'group-remove-error',
                _('Group could not be removed: %s') %
                common.parseSoapFault(response))
    def onUserRemoved(self, response, email, contact):
        '''this method is called when the removeUser soapRequest get a response
        renes means if we have to renew the di,ml,ab data'''

        common.debug('remove user: '******' ' + str(response.status))

        if response.status[0] == 200:
            self.emit('contact-removed', email)
        else:
            self.sendDL('ADL', email, '1')
            self.contactManager.addContact(contact)

            self.emit(
                'error', 'user-remove-error',
                _('User could not be removed: %s') %
                common.parseSoapFault(response))
        self.emit('user-list-change')
    def onGroupRenamed(self, response, oldGroup, newGroup):
        '''this method is called when the renameGroup soap request get a response'''

        common.debug('rename group ' + str(response.status))

        if response.status[0] == 200:
            self.emit('group-renamed', oldGroup, newGroup)
        else:
            gid = self.contactManager.getGroupId(newGroup)
            self.contactManager.renameGroup(gid, oldGroup)
            group = self.contactManager.getGroup(gid)
            # its old because we revert the changes
            objOldGroup = ContactData.Group(newGroup)
            self.emit('group-attr-changed', objOldGroup, group)
            self.emit(
                'error', 'group-rename-error',
                _('Group could not be renamed: %s') %
                common.parseSoapFault(response))
示例#16
0
 def onUserAdded(self, response, email, group=''):
     '''this method is called when the addUser soapRequest get a response'''
     common.debug('add user: '******' ' + str(response.status))
     if response.status[0] == 200:
         self.contactManager.setContactIdXml(email, response.body)
         guid = response.body.split('<guid>')[1].split('</guid>')[0]
         self.emit('contact-added', email, guid, None, None, 'FLN', None,
             False)
         if group == '':
             self.emit('user-list-change')
         else:
             self.addUserToGroup(email, group)
     else:
         self.contactManager.removeContact(email)
         self.emit('user-list-change')
         self.emit('error', 'user-add-error',
             _('User could not be added: %s') % \
             common.parseSoapFault(response))
    def onMoveUserToGroup(self, response, user, srcGroup, destGroup, stage):

        common.debug('move user (stage ' + str(stage) + '): ' \
                           + str(response.status))

        status = response.status

        if response.status[0] == 200:
            if stage == 0:  # continue the moving procedure
                self.moveUserToGroup(user, srcGroup, destGroup, 1)
        else:
            # restore the old visual
            sourceGid = self.contactManager.getGroupId(srcGroup)
            destGid = self.contactManager.getGroupId(destGroup)

            self.contactManager.removeUserFromGroup(user, destGid)
            self.contactManager.addUserToGroup(user, sourceGid)
            self.emit('user-list-change')
            self.emit(
                'error', 'user-move-to-group-error',
                _('User could not be moved to group: %s') %
                common.parseSoapFault(response))
        common.debug('add group ' + str(response.status))

        if response.status[0] == 200:
            try:
                gid = response.body.split('<guid>')[1].split('</guid>')[0]
                self.contactManager.addGroup(group, gid)
                self.emit('group-added', group, gid)
                self.emit('user-list-change')
            except IndexError, e:
                common.debug('cannot add group to userlist')
                common.debug(str(e))
        else:
            self.emit(
                'error', 'group-add-error',
                _('Group could not be added: %s') %
                common.parseSoapFault(response))

    def removeGroup(self, group):
        '''remove a group from the group list'''

        gid = self.contactManager.getGroupId(group)
        if gid:
            groupObj = self.contactManager.getGroup(gid)
            self.contactManager.removeGroup(gid)
            self.emit('user-list-change')

            soap.manager.do_request(self.proxy,\
                'http://www.msn.com/webservices/AddressBook/ABGroupDelete', \
                'contacts.msn.com', 443, '/abservice/abservice.asmx', \
                soap.templates.deleteGroup % (gid,), \
                self.onGroupRemoved, (gid, groupObj))
示例#19
0
 def onGroupRenamed(self, response, oldGroup, newGroup):
     '''this method is called when the renameGroup soap request get a response'''
     common.debug('rename group ' + str(response.status))
     if response.status[0] == 200:
         self.emit('group-renamed', oldGroup, newGroup)
     else:
         gid = self.contactManager.getGroupId(newGroup)
         self.contactManager.renameGroup(gid, oldGroup)
         group = self.contactManager.getGroup(gid)
         objOldGroup = ContactData.Group(newGroup)
         self.emit('group-attr-changed', objOldGroup, group)
         self.emit('error', 'group-rename-error', _('Group could not be renamed: %s') % common.parseSoapFault(response))
示例#20
0
 def onNickChanged(self, response, oldNick):
     if response.status[0] != 200:
         self.emit('self-nick-changed', self.nick, oldNick)
         self.emit('error', 'nick-change-error',
             common.parseSoapFault(response))
示例#21
0
 def onGroupRemoved(self, response, gid, group):
     '''this method is called when the removeGroup soap request get a response'''
     common.debug('remove group ' + str(response.status))
     if response.status[0] == 200:
         self.emit('group-removed', group)
     else:
         self.contactManager.setGroup(gid, group)
         self.emit('user-list-change')
         self.emit('error', 'group-remove-error', _('Group could not be removed: %s') % common.parseSoapFault(response))
 def onPmChanged(self, response, oldPm):
     return # shhht! user exceeded the limit can be bad
     if response.status[0] != 200:
         self.emit('self-personal-message-changed', self.personalMessage, oldPm)
         self.emit('error', 'pm-change-error',
             common.parseSoapFault(response))
示例#23
0
 def onMoveUserToGroup(self, response, user, srcGroup, destGroup, stage):
     common.debug('move user (stage ' + str(stage) + '): ' \
                        + str(response.status))
     status = response.status
     if response.status[0] == 200:
         if stage == 0: # continue the moving procedure
             self.moveUserToGroup(user, srcGroup, destGroup, 1)
     else:
         sourceGid = self.contactManager.getGroupId(srcGroup)
         destGid = self.contactManager.getGroupId(destGroup)
         self.contactManager.removeUserFromGroup(user, destGid)
         self.contactManager.addUserToGroup(user, sourceGid)
         self.emit('user-list-change')
         self.emit('error', 'user-move-to-group-error', _('User could not be moved to group: %s') % common.parseSoapFault(response))
示例#24
0
 def onNickChanged(self, response, user, oldNick):
     '''this method is called when the changeNick soap request get a response'''
     common.debug('change nick ' + str(response.status))
     
     if response.status[0] != 200:
         if user == 'Me':
             #self.contactManager.setContactNick(self.user, oldNick)
             self.emit('self-nick-changed', self.nick, oldNick)
         else:
             self.emit('contact-attr-changed', user, 'alias', oldNick)
             self.contactManager.setContactAlias(user, oldNick)
             contact = self.contactManager.getContact(user)
             self.emit('user-attr-changed', contact)
             
         self.emit('error', 'nick-change-error', _('Nick could not be changed: %s') % common.parseSoapFault(response))
示例#25
0
         soap.templates.addGroup % (group,),
         self.onGroupAdded, (group,))
 def onGroupAdded(self, response, group):
     '''this method is called when the addGroup soap request get a response'''
     common.debug('add group ' + str(response.status))
     if response.status[0] == 200:
         try:
             gid = response.body.split('<guid>')[1].split('</guid>')[0]
             self.contactManager.addGroup(group, gid)
             self.emit('group-added', group, gid)
             self.emit('user-list-change')
         except IndexError, e:
             common.debug('cannot add group to userlist')
             common.debug(str(e))
     else:
         self.emit('error', 'group-add-error', _('Group could not be added: %s') % common.parseSoapFault(response))
 def removeGroup(self, group):
     '''remove a group from the group list'''
     gid = self.contactManager.getGroupId(group)
     if gid:
         groupObj = self.contactManager.getGroup(gid)
         self.contactManager.removeGroup(gid)
         self.emit('user-list-change')
         soap.manager.do_request(
             'http://www.msn.com/webservices/AddressBook/ABGroupDelete', \
             'omega.contacts.msn.com', 443, '/abservice/abservice.asmx', \
             soap.templates.deleteGroup % (gid,), \
             self.onGroupRemoved, (gid, groupObj))
     else:
         common.debug('Unable to remove: Group "' + group \
                            + '" does not exist')