# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import os
import time
import pickle
import sys

from prelude import IDMEFTime
from preludecorrelator.idmef import IDMEF
from preludecorrelator import require, log

_last_wakeup = 0
_next_wakeup = 0
_TIMER_LIST = []
_CONTEXT_TABLE = {}
logger = log.getLogger(__name__)

_IDMEF_QUEUE_LIMIT = 256


class Timer:
    def __setstate__(self, dict):
        self.__dict__.update(dict)
        if self._timer_start:
            _TIMER_LIST.append(self)

    def __init__(self, expire, cb_func=None):
        self._timer_start = None
        self._timer_expire = expire
        self._timer_cb = cb_func
# This program 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 this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

import pkg_resources
import os
import imp

from preludecorrelator import log, error, require, plugins

logger = log.getLogger(__name__)


class Plugin(object):
    enable = True
    autoload = True
    conflict = []

    def getConfigValue(self, option, default=None, type=str):
        return self.env.config.get(self.__class__.__name__, option, default=default, type=type)

    def __init__(self, env):
        self.env = env

    def _getName(self):
        return self.__class__.__name__