Removed clone button from UI at once
[ipypbx] / src / ipypbx / controllers.py
1 from ipypbx import models, state
2
3
4 class BaseHandler(object):
5     """
6     Base class for various entity handlers.
7
8     Doesn't do anything useful on its own.
9     """
10     items = None
11     current_items = None
12
13     def __init__(self, parent):
14         self.parent = parent
15
16
17 class ConnectionsHandler(BaseHandler):
18     """
19     Connections handler.
20     """
21     def select(self, index):
22         """
23         Select another connection as current.
24         """
25         state.currentConnection = state.connections[index]
26
27     def clone(self):
28         """
29         TODO: Clone an existing connection.
30
31         This creates a new connection with bound data copied from another one.
32         """
33
34     def add(self):
35         """
36         Add a new connection.
37         """
38         state.currentConnection = None
39         self.parent.ui.connectionName.setText('')
40         self.parent.ui.connectionLocalIpAddress.setText('')
41         self.parent.ui.connectionLocalPort.setText('')
42         self.parent.ui.connectionFreeswitchIpAddress.setText('')
43         self.parent.ui.connectionFreeswitchPort.setText('')
44
45     def save(self):
46         connection = models.Connection(
47             name=self.parent.ui.connectionName.getText(),
48             local_ip_address=self.parent.ui.connectionLocalIpAddress.\
49                 getText(),
50             local_port=self.parent.ui.connectionLocalPort.getText(),
51             freeswitch_ip_address=self.parent.ui.\
52                 connectionFreeswitchIpAddress.getText(),
53             freeswitch_port=self.parent.ui.connectionFreeswitchPort.getText()
54             )
55     #state.currentConnection =