--- /dev/null
+from ipypbx import models, state
+
+
+class BaseHandler(object):
+ """
+ Base class for various entity handlers.
+
+ Doesn't do anything useful on its own.
+ """
+ items = None
+ current_items = None
+
+ def __init__(self, parent):
+ self.parent = parent
+
+
+class ConnectionsHandler(BaseHandler):
+ """
+ Connections handler.
+ """
+ def select(self, index):
+ """
+ Select another connection as current.
+ """
+ state.currentConnection = state.connections[index]
+
+ def clone(self):
+ """
+ TODO: Clone an existing connection.
+
+ This creates a new connection with bound data copied from another one.
+ """
+
+ def add(self):
+ """
+ Add a new connection.
+ """
+ state.currentConnection = None
+ self.parent.ui.connectionName.setText('')
+ self.parent.ui.connectionLocalIpAddress.setText('')
+ self.parent.ui.connectionLocalPort.setText('')
+ self.parent.ui.connectionFreeswitchIpAddress.setText('')
+ self.parent.ui.connectionFreeswitchPort.setText('')
+
+ def save(self):
+ connection = models.Connection(
+ name=self.parent.ui.connectionName.getText(),
+ local_ip_address=self.parent.ui.connectionLocalIpAddress.\
+ getText(),
+ local_port=self.parent.ui.connectionLocalPort.getText(),
+ freeswitch_ip_address=self.parent.ui.\
+ connectionFreeswitchIpAddress.getText(),
+ freeswitch_port=self.parent.ui.connectionFreeswitchPort.getText()
+ )
+ #state.currentConnection =
--- /dev/null
+# Copyright (c) Stas Shtin, 2010
+
+# This file is part of IPyPBX.
+
+# IPyPBX is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# IPyPBX is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with IPyPBX. If not, see <http://www.gnu.org/licenses/>.
+
+
+from PyQt import QtNetwork
+
+
+class FreeswitchConfigServer(QTcpServer):
+ """
+ This is a server that gets instantiated for every connection.
+ """
+ def __init__(self, host, port, parent=None):
+ super(FreeswitchConfig, self).__init__(self, parent)
+
+ self.newConnection.connect(self, handleClientConnection)
+ self.listen(host, port)
+
+ def handleClientConnection(self):
+ if self.hasPendingConnections():
+ connectionClient = self.nextClientConnection()
+ connectionClient.readyRead.connect(self.receiveData)