summaryrefslogtreecommitdiff
path: root/swat/esptest/registry.esp
blob: b02def6f8389dcb342a366bbabd412fcab64dab7 (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<%
/******************************/
/* server side AJAJ functions */
libinclude("base.js");
libinclude("winreg.js");
libinclude("server_call.js");

/* 
   server side call to return a listing of elements in a winreg path
*/
function enum_path(binding, path) {
	printf("enum_path(%s, %s)\n", binding, path);
	var reg = winreg_init();
	security_init(reg);

	reg.credentials = session.authinfo.credentials;

	var status = reg.connect(binding);
	if (status.is_ok != true) {
		printVars(status);
		return undefined;
	}
	var list = winreg_enum_path(reg, path);
	return list;
}

/* register a call for clients to make */
var call = servCallObj();
call.add('enum_path', enum_path);

/* run the function that was asked for */
call.run();

  /***********************/
  /* now the main page */
  page_header("columns", "ESP registry edit", "esptest"); 
%>

<script type="text/javascript" src="/scripting/client/encoder.js"></script>
<script type="text/javascript" src="/scripting/client/call.js"></script>

<h1>Registry Editor</h1>

  <script type="text/javascript">

function folder_list(parent, list) {
	var i;
	parent.populated = true;
	parent.removeAll();
	for (i=0;i<list.length;i++) {
		var child;
		child = new QxTreeFolder(list[i]);
		parent.add(child);
		child.binding = parent.binding;
		if (parent.reg_path == '\\\\') {
			child.reg_path = list[i];
		} else {
			child.reg_path = parent.reg_path + '\\\\' + list[i];
		}
		child.add(new QxTreeFolder('Working ...'));
		child.addEventListener("click", function() { 
			var el = this; folder_click(el); 
		});
		parent.setOpen(1);
	}
}

function folder_click(node) {
	if (!node.populated) {
		server_call_url("@@request.REQUEST_URI", 'enum_path', 
			    function(list) { folder_list(node, list); }, 
			    node.binding, node.reg_path);
	}
}

/* return a registry tree for the given server */
function registry_tree(binding) {
      var tree = new QxTree("registry: " + binding);
      tree.binding = binding;
      tree.reg_path = "\\\\";
      tree.populated = false;
      with(tree)
      {
        setBackgroundColor(255);
        setBorder(QxBorder.presets.inset);
        setOverflow("scroll");
        setStyleProperty("padding", "2px");
        setWidth(400);
        setHeight(400);
        setTop(20);
      }
      tree.addEventListener("click", function() { 
	      var el = this; folder_click(el); 
      });
      return tree;
}

  window.application.main = function()
  {
    var inlineWidget = new QxInline;
    var fieldSet = new QxFieldSet("Registry");
    var binding = "ncalrpc:";

    with(fieldSet)
    {
	    setWidth("40%");
	    setMinHeight(500);
	    setBottom(48);
	    setMinWidth(500);
    };

    var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%");
    gl.setEdge(0);
    gl.setCellPaddingTop(3);
    gl.setCellPaddingBottom(3);

    inlineWidget.add(fieldSet);

    var t = registry_tree(binding);

    function change_binding(e) {
	    binding = e.getNewValue();
    	    srv_printf("changed binding to %s\\n", binding);
	    gl.remove(t);
	    t = registry_tree(binding);
	    gl.add(t, { row : 2, col : 1 });
    }

    var b = new QxTextField(binding);
    b.addEventListener("changeText", change_binding);

    gl.add(b, { row : 1, col : 1 });
    gl.add(t, { row : 2, col : 1 });

    fieldSet.add(gl);
    inlineWidget.add(fieldSet);
    this.getClientWindow().getDocument().add(inlineWidget, "canvas");
  };

  </script>


 <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div>

<% page_footer(); %>