Beispiel #1
0
    def first_step(self, request):
        # first query...
        response, cmd = self.build_response(request,
                                            defaultaction='execute',
                                            actions=['execute'])

        cmd.addChild(node=dataforms.SimpleDataForm(
            title=_('Change status'),
            instructions=_('Set the presence type and description'),
            fields=[
                dataforms.create_field(
                    'list-single',
                    var='presence-type',
                    label='Type of presence:',
                    options=[('chat',
                              _('Free for chat')), (
                                  'online', _('Online')), ('away', _('Away')),
                             ('xa',
                              _('Extended away')), ('dnd',
                                                    _('Do not disturb')),
                             ('offline', _('Offline - disconnect'))],
                    value='online',
                    required=True),
                dataforms.create_field('text-multi',
                                       var='presence-desc',
                                       label=_('Presence description:'))
            ]))

        self.connection.connection.send(response)

        # for next invocation
        self._callback = self.second_step

        return True  # keep the session
Beispiel #2
0
def _parse_fields_form(query):
    fields = []
    for field in query.getChildren():
        field_name = field.getName()
        if field_name not in REGISTER_FIELDS:
            continue

        required = field_name in ('username', 'password')
        typ = 'text-single' if field_name != 'password' else 'text-private'
        fields.append(create_field(typ=typ, var=field_name, required=required))

    if not fields:
        return None

    fields.append(create_field(typ='hidden', var='fakeform'))
    return SimpleDataForm(type_='form',
                          instructions=query.getTagData('instructions'),
                          fields=fields)
Beispiel #3
0
def _make_query_form(start, end, with_):
    fields = [
        create_field(typ='hidden', var='FORM_TYPE', value=Namespace.MAM_2)
    ]

    if start:
        fields.append(create_field(
            typ='text-single',
            var='start',
            value=start.strftime('%Y-%m-%dT%H:%M:%SZ')))

    if end:
        fields.append(create_field(
            typ='text-single',
            var='end',
            value=end.strftime('%Y-%m-%dT%H:%M:%SZ')))

    if with_:
        fields.append(create_field(
            typ='jid-single',
            var='with',
            value=with_))

    return SimpleDataForm(type_='submit', fields=fields)
Beispiel #4
0
    def first_step(self, request):
        # first query...
        response, cmd = self.build_response(request,
                                            defaultaction='execute',
                                            actions=['execute'])
        options = []
        account = self.connection.name
        for gc in find_current_groupchats(account):
            options.append(('%s' % gc[0], _('%(nickname)s on %(room_jid)s') % {
                'nickname': gc[1],
                'room_jid': gc[0]
            }))
        if not options:
            response, cmd = self.build_response(request, status='completed')
            cmd.addChild('note', {}, _('You have not joined a group chat.'))

            self.connection.connection.send(response)
            return False

        cmd.addChild(node=dataforms.SimpleDataForm(
            title=_('Leave Group Chats'),
            instructions=_('Choose the group chats you want to leave'),
            fields=[
                dataforms.create_field('list-multi',
                                       var='groupchats',
                                       label=_('Group chats'),
                                       options=options,
                                       required=True)
            ]))

        self.connection.connection.send(response)

        # for next invocation
        self._callback = self.second_step

        return True  # keep the session
Beispiel #5
0
from nbxmpp.modules.dataforms import create_field
from nbxmpp.modules.dataforms import SimpleDataForm

from gajim.common.const import CSSPriority

from gajim import gui
gui.init('gtk')

from gajim.gui.change_password import ChangePassword

from test.gtk import util
util.load_style('gajim.css', CSSPriority.APPLICATION)

fields = [
    create_field(typ='text-single', label='Username', var='username'),
    create_field(typ='text-single', label='Old Password', var='old_password'),
    create_field(typ='text-single',
                 label='Mothers name',
                 var='mother',
                 required=True),
]

form = SimpleDataForm(type_='form', fields=fields)


def _apply(self, next_stage=False):
    if next_stage:
        print(self.get_page('next_stage').get_submit_form())
    else:
        self.get_page('next_stage').set_form(form)