Ejemplo n.º 1
0
    def load_tunnels(self):
        # Clear the tunnels list form the collection
        self.tunnels.clear_tunnels()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM tunnels WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            tunnel = Tunnel()
            tunnel.id = row['id_tunnel']
            tunnel.id_connection = self.id
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add on Tunnels
            self.tunnels.add_tunnel(tunnel)
Ejemplo n.º 2
0
    def load(self):
        # Create the Password Manager
        password_manager = PasswordManager()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM connections WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            self.name = row['name']
            self.host = row['host']
            self.port = row['port']
            self.user = row['user']
            self.password = password_manager.decrypt_password(row['passwd'])
            self.use_key = True if int(row['use_key']) == 1 else False
            self.key_path = row['key_path']
Ejemplo n.º 3
0
    def load_tunnels(self):
        # Clear the tunnels list form the collection
        self.tunnels.clear_tunnels()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM tunnels WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            tunnel = Tunnel()
            tunnel.id = row['id_tunnel']
            tunnel.id_connection = self.id
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add on Tunnels
            self.tunnels.add_tunnel(tunnel)
Ejemplo n.º 4
0
    def load(self):
        # Create the Password Manager
        password_manager = PasswordManager()

        # Create the DBConnection
        database = DBConnection()

        # Create the SQL
        sql = "SELECT * FROM connections WHERE id_connection = {}"

        # Bind the value
        sql = sql.format(self.id)

        # Execute the query
        rows = database.select_query(sql)

        # Set the attrs
        for row in rows:
            self.name = row['name']
            self.host = row['host']
            self.port = row['port']
            self.user = row['user']
            self.password = password_manager.decrypt_password(row['passwd'])
            self.use_key = True if int(row['use_key']) == 1 else False
            self.key_path = row['key_path']
Ejemplo n.º 5
0
class Connections:

    dbconnection = None
    connections = []
    model = None

    def __init__(self):
        # Create the DB connection
        self.dbconnection = DBConnection()

    def load_connections(self):
        # Reset the List
        self.connections = []

        # Create the SQL
        sql = "select * from connections order by name"

        # Execute the sql
        results = self.dbconnection.select_query(sql)

        # Create a model for every connection
        for row in results:
            # Create new Connection
            connection = Connection()
            connection.id = row['id_connection']
            connection.name = row['name']
            connection.host = row['host']
            connection.user = row['user']
            connection.port = row['port']
            connection.use_key = True if row['use_key'] == 1 else False
            connection.key_path = row['key_path']

            # Add to the list
            self.connections.append(connection)

    # Method to get ListStore of names
    def get_connection_names_model(self):
        # Create the ListStore
        self.model = Gtk.ListStore(str, int)

        # Looping passing by every connection
        for connection in self.connections:
            self.model.append([connection.name, connection.id])

        # return the model
        return self.model

    # Return all Connection
    def get_connections(self):
        return self.connections
Ejemplo n.º 6
0
    def load(self):
        # Create the databse
        database = DBConnection()

        # Make the select
        rows = database.select_query("SELECT * FROM settings")
        for row in rows:
            # Check the name of the property and set the value correctly
            if row['property'] == Settings.X11_FORWARD:
                self.x11_forward = int(row['value'])
            elif row['property'] == Settings.REQUEST_COMPRESSION:
                self.request_compression = int(row['value'])
            elif row['property'] == Settings.FORCE_IPV4:
                self.force_ipv4 = int(row['value'])
            elif row['property'] == Settings.FORCE_IPV6:
                self.force_ipv6 = int(row['value'])
Ejemplo n.º 7
0
    def load(self):
        # Create the databse
        database = DBConnection()

        # Make the select
        rows = database.select_query("SELECT * FROM settings")
        for row in rows:
            # Check the name of the property and set the value correctly
            if row['property'] == Settings.X11_FORWARD:
                self.x11_forward = int(row['value'])
            elif row['property'] == Settings.REQUEST_COMPRESSION:
                self.request_compression = int(row['value'])
            elif row['property'] == Settings.FORCE_IPV4:
                self.force_ipv4 = int(row['value'])
            elif row['property'] == Settings.FORCE_IPV6:
                self.force_ipv6 = int(row['value'])
Ejemplo n.º 8
0
class Tunnels:

    dbconnection = None
    tunnels = []
    model = None

    def __init__(self):
        # Create the DB connection
        self.dbconnection = DBConnection()

    def add_tunnel(self, tunnel):
        # Add to the list
        self.tunnels.append(tunnel)

    def remove_tunnel_at(self, index):
        # Remove the tunnel
        if len(self.tunnels) > 0:
            self.tunnels.pop(index)

    def load_tunnels(self, id_connection):
        # Reset the List
        self.tunnels = []

        # Create the SQL
        sql = "select * from tunnels where id_connection = {}"
        sql = sql.format(id_connection)

        # Execute the sql
        results = self.dbconnection.select_query(sql)

        # Create a model for every tunnel
        for row in results:
            # Create new Connection
            tunnel = Tunnel()
            tunnel.id = 0 if row['id_tunnel'] is None else row['id_tunnel']
            tunnel.id_connection = 0 if row['id_connection'] is None else row['id_connection']
            tunnel.local_port = row['local_port']
            tunnel.address = row['address']
            tunnel.remote_port = row['remote_port']

            # Add to the list
            self.tunnels.append(tunnel)

    def clear_tunnels(self):
        # Clear list of tunnels
        self.tunnels = []

    # Method to get ListStore of names
    def get_tunnels_model(self):
        # Create the ListStore
        self.model = Gtk.ListStore(int, str, int, int)

        # Looping passing by every tunnel
        index = 0
        for tunnel in self.tunnels:
            # Add the model
            self.model.append([int(tunnel.local_port), tunnel.address, int(tunnel.remote_port), index])

            # Increment the counter
            index += 1

        # return the model
        return self.model

    # Return all Connection
    def get_tunnels(self):
        return self.tunnels