aboutsummaryrefslogtreecommitdiffstats
path: root/packages/torouter-web/tui/utils/configuration.py
blob: 88bbc057e25128cf7f9afd05b3eeca5590e4553e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import web
import config

def get(name):
  conf = {}
  # XXX The content of these functions are just
  #     skeletons
  if name == "wireless":
    conf['essid'] = "Torouter"
    conf['encryption'] = "WPA2"
    conf['key'] = "ljdasjkbcuBH12389Ba"   
    return conf
  elif name == "firewall":
    conf['el1'] = "Element 1"
    conf['el2'] = "Element 2"
    conf['el3'] = "Element 3"
    return conf
  elif name == "wired":
    conf['el1'] = "Element 1"
    conf['el2'] = "Element 2"
    conf['el3'] = "Element 3"
    return conf
  elif name == "tor":
    conf['el1'] = "Element 1"
    conf['el2'] = "Element 2"
    conf['el3'] = "Element 3"
    return conf
  
def write(name, data):
  if name == "wireless":
    return True
  elif name == "firewall":
    return True
  elif name == "wired":
    return True
  elif name == "tor":
    return True
  
def get_form(name):
  # Also these are just skeletons
  if name == "wireless":
    c = get(name)
    return web.form.Form(
      web.form.Textbox(name='essid',
        description='Wireless ESSID', value=c['essid']),
      web.form.Dropdown(name='enctype', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
        description='Wireless encryption scheme', value=c['encryption']),
      web.form.Password(name='key',
        description='key', value=c['key']),
      web.form.Button('save')
    )
  elif name == "firewall":
    c = get(name) 
    return web.form.Form(
      web.form.Textbox(name='el1',
        description='The first element', value=c['el2']),
      web.form.Dropdown(name='el2', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
        description='The second selement', value=c['el2']),
      web.form.Password(name='el3',
        description='The third element', value=c['el3']),
      web.form.Button('save')
    )
  elif name == "wired":
    c = get(name)
    return web.form.Form(
      web.form.Textbox(name='el1',
        description='The first element', value=c['el2']),
      web.form.Dropdown(name='el2', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
        description='The second selement', value=c['el2']),
      web.form.Password(name='el3',
        description='The third element', value=c['el3']),
      web.form.Button('save')
    )
  elif name == "tor":
    c = get(name)
    return web.form.Form(
      web.form.Textbox(name='el1',
        description='The first element', value=c['el2']),
      web.form.Dropdown(name='el2', args=['WPA2', 'WPA', 'WEP (not reccomended)', 'open'],
        description='The second selement', value=c['el2']),
      web.form.Password(name='el3',
        description='The third element', value=c['el3']),
      web.form.Button('save')
    )