Esempio n. 1
0
    def _device(self, user_id, name, destination=''):
        funckey_prefix = extensions_dao.exten_by_name('phoneprogfunckey')
        funckey_args = (user_id, extensions_dao.exten_by_name(name),
                        destination)
        funckey_pattern = xivo_helpers.fkey_extension(funckey_prefix,
                                                      funckey_args)

        hint = self.DEVICE_PATTERN % funckey_pattern

        return hint
Esempio n. 2
0
    def test_exten_by_name(self):
        self.add_extension(type='extenfeatures',
                           typeval='enablednd',
                           exten='*25')
        self.add_extension(type='extenfeatures',
                           typeval='phoneprogfunckey',
                           exten='_*735')
        enablednd = extensions_dao.exten_by_name('enablednd')
        phoneprogfunckey = extensions_dao.exten_by_name('phoneprogfunckey')

        self.assertEqual(enablednd, '*25')
        self.assertEqual(phoneprogfunckey, '_*735')
Esempio n. 3
0
    def test_exten_by_name(self):
        self.add_extension(type='extenfeatures',
                           typeval='enablednd',
                           exten='*25')
        self.add_extension(type='extenfeatures',
                           typeval='phoneprogfunckey',
                           exten='_*735')
        enablednd = extensions_dao.exten_by_name('enablednd')
        phoneprogfunckey = extensions_dao.exten_by_name('phoneprogfunckey')

        self.assertEqual(enablednd, '*25')
        self.assertEqual(phoneprogfunckey, '_*735')
Esempio n. 4
0
    def ipbxcommand_transfer(self):
        try:
            dst = self.parseid(self._commanddict['destination'])
            transferers_channel = self.innerdata.find_users_channels_with_peer(
                self.userid)[0]
            channel = self.innerdata.channels[transferers_channel].peerchannel
            dst_context = self.innerdata.xod_config['phones'].get_main_line(
                self.userid)['context']

            if dst['type'] == 'user':
                extentodial = self.innerdata.xod_config[
                    'phones'].get_main_line(dst['id'])['number']
            elif dst['type'] == 'phone' and dst[
                    'id'] in self.innerdata.xod_config['phones'].keeplist:
                extentodial = self.innerdata.xod_config['phones'].keeplist[
                    dst['id']]
            elif dst['type'] == 'exten':
                extentodial = dst['id']
            elif dst['type'] == 'voicemail' and dst[
                    'id'] in self.innerdata.xod_config['voicemails'].keeplist:
                voicemail = self.innerdata.xod_config['voicemails'].keeplist[
                    dst['id']]
                vm_number = voicemail['mailbox']
                prefix = extensions_dao.exten_by_name('vmboxslt')
                extentodial = prefix[:-1] + vm_number
                dst_context = voicemail['context']
            elif dst['type'] == 'meetme' and dst[
                    'id'] in self.innerdata.xod_config['meetmes'].keeplist:
                extentodial = self.innerdata.xod_config['meetmes'].keeplist[
                    dst['id']]['confno']
            else:
                extentodial = None

            return [{
                'amicommand': 'transfer',
                'amiargs': [channel, extentodial, dst_context]
            }]
        except (KeyError, IndexError):
            logger.exception('Failed to transfer call')
            return [{'error': 'Incomplete transfer information'}]
 def to_exten(self):
     with session_scope():
         call_vm_exten = extensions_dao.exten_by_name('vmboxslt')
     vm_number = dao.voicemail.get_number(self.value)
     return call_vm_exten.replace('.', vm_number)
 def to_exten(self):
     return extensions_dao.exten_by_name('vmusermsg')
Esempio n. 7
0
    def ipbxcommand_originate(self):
        src = self.parseid(self._commanddict.get('source'))
        if not src:
            return [{'error': 'source'}]
        dst = self.parseid(self._commanddict.get('destination'))
        if not dst:
            return [{'error': 'destination'}]

        innerdata = self._ctiserver.safe

        orig_protocol = None
        orig_name = None
        orig_number = None
        orig_context = None
        phoneidstruct_src = {}
        phoneidstruct_dst = {}

        if src.get('type') == 'user':
            if src.get('id') in innerdata.xod_config.get('users').keeplist:
                for k, v in innerdata.xod_config.get(
                        'phones').keeplist.iteritems():
                    if src.get('id') == str(v.get('iduserfeatures')):
                        phoneidstruct_src = innerdata.xod_config.get(
                            'phones').keeplist.get(k)
                        break
                # if not phoneidstruct_src: lookup over agents ?
        elif src.get('type') == 'phone':
            if src.get('id') in innerdata.xod_config.get('phones').keeplist:
                phoneidstruct_src = innerdata.xod_config.get(
                    'phones').keeplist.get(src.get('id'))
        elif src.get('type') == 'exten':
            orig_context = 'mamaop'  # XXX how should we define or guess the proper context here ?
            orig_protocol = 'local'
            orig_name = '%s@%s' % (
                src.get('id'), orig_context
            )  # this is the number actually dialed, in local channel mode
            orig_number = src.get(
                'id'
            )  # this is the number that will be displayed as ~ callerid
            orig_identity = ''  # how would we know the identity there ?

        if phoneidstruct_src:
            orig_protocol = phoneidstruct_src.get('protocol')
            orig_name = phoneidstruct_src.get('name')
            orig_number = phoneidstruct_src.get('number')
            orig_identity = phoneidstruct_src.get('useridentity')
            orig_context = phoneidstruct_src.get('context')

        extentodial = None
        dst_identity = None

        if dst.get('type') == 'user':
            if dst.get('id') in innerdata.xod_config.get('users').keeplist:
                for k, v in innerdata.xod_config.get(
                        'phones').keeplist.iteritems():
                    if dst.get('id') == str(v.get('iduserfeatures')):
                        phoneidstruct_dst = innerdata.xod_config.get(
                            'phones').keeplist.get(k)
                        break
                # if not phoneidstruct_dst: lookup over agents ?
        elif dst.get('type') == 'phone':
            if dst.get('id') in innerdata.xod_config.get('phones').keeplist:
                phoneidstruct_dst = innerdata.xod_config.get(
                    'phones').keeplist.get(dst.get('id'))
        elif dst.get('type') == 'voicemail':
            try:
                exten = extensions_dao.exten_by_name('vmusermsg')
                vm = innerdata.xod_config['voicemails'].keeplist[dst['id']]
                extentodial = exten
                dst_context = vm['context']
                dst_identity = 'Voicemail'
            except KeyError:
                logger.exception('Missing info to call this voicemail')
                extentodial = None
            # XXX especially for the 'dial' command, actually
            # XXX display password on phone in order for the user to know what to type
        elif dst.get('type') == 'meetme':
            if dst.get('id') in innerdata.xod_config.get('meetmes').keeplist:
                meetmestruct = innerdata.xod_config.get(
                    'meetmes').keeplist.get(dst.get('id'))
                extentodial = meetmestruct.get('confno')
                dst_identity = 'meetme %s' % meetmestruct.get('name')
                dst_context = meetmestruct.get('context')
            else:
                extentodial = None
        elif dst.get('type') == 'exten':
            extentodial = dst.get('id')
            dst_identity = extentodial
            dst_context = orig_context

        if phoneidstruct_dst:
            extentodial = phoneidstruct_dst.get('number')
            dst_identity = phoneidstruct_dst.get('useridentity')
            dst_context = phoneidstruct_dst.get('context')

        rep = {}
        if orig_protocol and orig_name and orig_number and extentodial:
            rep = {
                'amicommand':
                'originate',
                'amiargs':
                (orig_protocol, orig_name, orig_number, orig_identity,
                 extentodial, dst_identity, dst_context)
            }
        return [rep]
 def to_exten(self):
     return extensions_dao.exten_by_name('vmusermsg')
 def to_exten(self):
     call_vm_exten = extensions_dao.exten_by_name('vmboxslt')
     vm_number = dao.voicemail.get_number(self.value)
     return call_vm_exten.replace('.', vm_number)
Esempio n. 10
0
 def to_exten(self):
     with session_scope():
         return extensions_dao.exten_by_name('vmusermsg')