# Path: RapacheCore/Module.py
# def is_denormalized_module ( fname ):
# def is_not_normalizable( fname):
# def blacklisted ( fname ):
# def normalize_module( fname ):
# def get_module_dependants ( name, mods_dict ):
# def get_module_descriptions():
# def module_list ():
#     def __init__(self, name = None):
#     def load (self, name = False):        
#     def __get_dependecies(self, content):   
#     def is_enabled ( self ):
#     def _write(self, complete_path, content ):  
#     def toggle(self, status ):
#     def get_description(self):
#     def get_configuration_file_name(self):
#     def get_backup_files(self):
#     def get_source ( self ):
#     def get_configuration ( self ):
#     def get_configuration_version( self, date_stamp):
#     def save_configuration (self, content):
# class ModuleModel:
# 
# Path: RapacheCore/Configuration.py
# SYSCONFDIR = '/etc/apache2'
# SITES_ENABLED_DIR = SYSCONFDIR + '/sites-enabled'
# SITES_AVAILABLE_DIR = SYSCONFDIR + '/sites-available'
# MODS_ENABLED_DIR = SYSCONFDIR + '/mods-enabled'
# MODS_AVAILABLE_DIR = SYSCONFDIR + '/mods-available'
# APPPATH = '/usr/bin' #please fill at run-time
# GLADEPATH = '/usr/share/rapache/Glade' #please fill at run-time
# NUMBER_OF_BACKUPS = 10
# TEST_CONNECTION_INTERVAL = 30


import gtk
import gobject
import os
import re
from CheckListView import *
from RapacheCore.VirtualHost import *
from RapacheCore import Module
from RapacheCore import Configuration
from xml.sax import saxutils
        lstore = self._reset_model()   
        res, text  = True, ""     
        
        # -1 = nothing to fix
        # 0  = nothing auto-fixable
        # 1 = something to be done
        returncode = -1
        if test_apache:
            res, text = apache.test_config()
            text = saxutils.escape(text)
            if not res:       
                returncode = 0
                iter = lstore.append()
                markup = site_template % "Apache Config Error"
                
                pixbuf = self.render_icon(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_LARGE_TOOLBAR)
                
                lstore.set(iter,
                    COLUMN_ICON, pixbuf,
                    COLUMN_FIXED, False,
                    COLUMN_SEVERITY, "Apache Config Error",
                    COLUMN_MARKUP, markup + "\n" + text +"\n<small><i>You may need to resolve this error to restart apache</i></small>"
                    )
                    
        self._add_ssl_port_error_vhosts()
        fixable_items = self._add_denormalized_vhosts()
        return max( returncode,  fixable_items )

    def _add_ssl_port_error_vhosts( self ):
        fixable_items = 0

# Path: RapacheCore/Module.py
# def is_denormalized_module ( fname ):
# def is_not_normalizable( fname):
# def blacklisted ( fname ):
# def normalize_module( fname ):
# def get_module_dependants ( name, mods_dict ):
# def get_module_descriptions():
# def module_list ():
#     def __init__(self, name = None):
#     def load (self, name = False):        
#     def __get_dependecies(self, content):   
#     def is_enabled ( self ):
#     def _write(self, complete_path, content ):  
#     def toggle(self, status ):
#     def get_description(self):
#     def get_configuration_file_name(self):
#     def get_backup_files(self):
#     def get_source ( self ):
#     def get_configuration ( self ):
#     def get_configuration_version( self, date_stamp):
#     def save_configuration (self, content):
# class ModuleModel:
# 
# Path: RapacheCore/Configuration.py
# SYSCONFDIR = '/etc/apache2'
# SITES_ENABLED_DIR = SYSCONFDIR + '/sites-enabled'
# SITES_AVAILABLE_DIR = SYSCONFDIR + '/sites-available'
# MODS_ENABLED_DIR = SYSCONFDIR + '/mods-enabled'
# MODS_AVAILABLE_DIR = SYSCONFDIR + '/mods-available'
# APPPATH = '/usr/bin' #please fill at run-time
# GLADEPATH = '/usr/share/rapache/Glade' #please fill at run-time
# NUMBER_OF_BACKUPS = 10
# TEST_CONNECTION_INTERVAL = 30


# Path: RapacheGtk/VhostsTreeView.py
import gtk
import gobject
import os
import re
from CheckListView import *
from RapacheCore.VirtualHost import *
from RapacheCore import Module
from RapacheCore import Configuration
from xml.sax import saxutils

        lstore = self._reset_model()   
        res, text  = True, ""     
        
        # -1 = nothing to fix
        # 0  = nothing auto-fixable
        # 1 = something to be done
        returncode = -1
        if test_apache:
            res, text = apache.test_config()
            text = saxutils.escape(text)
            if not res:       
                returncode = 0
                iter = lstore.append()
                markup = site_template % "Apache Config Error"
                
                pixbuf = self.render_icon(gtk.STOCK_DIALOG_ERROR, gtk.ICON_SIZE_LARGE_TOOLBAR)
                
                lstore.set(iter,
                    COLUMN_ICON, pixbuf,
                    COLUMN_FIXED, False,
                    COLUMN_SEVERITY, "Apache Config Error",
                    COLUMN_MARKUP, markup + "\n" + text +"\n<small><i>You may need to resolve this error to restart apache</i></small>"
                    )
                    
        self._add_ssl_port_error_vhosts()
        fixable_items = self._add_denormalized_vhosts()
        return max( returncode,  fixable_items )

    def _add_ssl_port_error_vhosts( self ):
        fixable_items = 0

        mod = Module.ModuleModel( "ssl" )