2008-06-02 01:33:51 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
## This file is part of Gajim.
|
|
|
|
##
|
|
|
|
## Gajim 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; version 3 only.
|
|
|
|
##
|
|
|
|
## Gajim 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 Gajim. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
##
|
|
|
|
|
|
|
|
'''
|
|
|
|
Base class for implementing plugin.
|
|
|
|
|
|
|
|
:author: Mateusz Biliński <mateusz@bilinski.it>
|
2008-06-18 22:45:22 +02:00
|
|
|
:since: 1st June 2008
|
2008-06-02 01:33:51 +02:00
|
|
|
:copyright: Copyright (2008) Mateusz Biliński <mateusz@bilinski.it>
|
|
|
|
:license: GPL
|
|
|
|
'''
|
|
|
|
|
2008-06-14 20:20:24 +02:00
|
|
|
import os
|
|
|
|
|
2008-06-03 01:15:08 +02:00
|
|
|
from plugins.helpers import log_calls
|
2008-06-02 01:33:51 +02:00
|
|
|
|
|
|
|
class GajimPlugin(object):
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Base class for implementing Gajim plugins.
|
|
|
|
'''
|
2008-06-07 19:28:34 +02:00
|
|
|
name = u''
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Name of plugin.
|
|
|
|
|
|
|
|
Will be shown in plugins management GUI.
|
|
|
|
|
|
|
|
:type: unicode
|
|
|
|
'''
|
2008-06-07 19:28:34 +02:00
|
|
|
short_name = u''
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Short name of plugin.
|
|
|
|
|
|
|
|
Used for quick indentification of plugin.
|
|
|
|
|
|
|
|
:type: unicode
|
|
|
|
|
|
|
|
:todo: decide whether we really need this one, because class name (with
|
|
|
|
module name) can act as such short name
|
|
|
|
'''
|
2008-06-07 19:28:34 +02:00
|
|
|
version = u''
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Version of plugin.
|
|
|
|
|
|
|
|
:type: unicode
|
|
|
|
|
|
|
|
:todo: decide how to compare version between each other (which one
|
|
|
|
is higher). Also rethink: do we really need to compare versions
|
|
|
|
of plugins between each other? This would be only useful if we detect
|
|
|
|
same plugin class but with different version and we want only the newest
|
|
|
|
one to be active - is such policy good?
|
|
|
|
'''
|
2008-06-07 19:28:34 +02:00
|
|
|
description = u''
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Plugin description.
|
|
|
|
|
|
|
|
:type: unicode
|
|
|
|
|
|
|
|
:todo: should be allow rich text here (like HTML or reStructuredText)?
|
|
|
|
'''
|
2008-06-02 01:33:51 +02:00
|
|
|
authors = []
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Plugin authors.
|
|
|
|
|
|
|
|
:type: [] of unicode
|
|
|
|
|
|
|
|
:todo: should we decide on any particular format of author strings?
|
|
|
|
Especially: should we force format of giving author's e-mail?
|
|
|
|
'''
|
2008-06-07 19:28:34 +02:00
|
|
|
homepage = u''
|
|
|
|
'''
|
|
|
|
URL to plug-in's homepage.
|
|
|
|
|
|
|
|
:type: unicode
|
|
|
|
|
|
|
|
:todo: should we check whether provided string is valid URI? (Maybe
|
|
|
|
using 'property')
|
|
|
|
'''
|
2008-06-02 01:33:51 +02:00
|
|
|
gui_extension_points = {}
|
2008-06-03 01:15:08 +02:00
|
|
|
'''
|
|
|
|
Extension points that plugin wants to connect with.
|
|
|
|
'''
|
2008-06-02 01:33:51 +02:00
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def __init__(self):
|
2008-06-12 20:26:08 +02:00
|
|
|
self.config = Config()
|
|
|
|
'''
|
|
|
|
Plug-in configuration dictionary.
|
|
|
|
|
|
|
|
Automatically saved and loaded and plug-in (un)load.
|
|
|
|
|
|
|
|
:type: `plugins.plugin.Config`
|
|
|
|
'''
|
2008-06-18 22:45:22 +02:00
|
|
|
self.load_config()
|
|
|
|
self.init()
|
2008-06-12 20:26:08 +02:00
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
2008-06-18 22:45:22 +02:00
|
|
|
def save_config(self):
|
2008-06-12 20:26:08 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
2008-06-18 22:45:22 +02:00
|
|
|
def load_config(self):
|
2008-06-12 20:26:08 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def __del__(self):
|
|
|
|
self._save_config()
|
|
|
|
|
2008-06-14 20:20:24 +02:00
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def local_file_path(self, file_name):
|
|
|
|
return os.path.join(self.__path__, file_name)
|
2008-06-18 22:45:22 +02:00
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def init(self):
|
|
|
|
pass
|
2008-06-14 20:20:24 +02:00
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def activate(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@log_calls('GajimPlugin')
|
|
|
|
def deactivate(self):
|
|
|
|
pass
|
2008-06-12 20:26:08 +02:00
|
|
|
|
|
|
|
class Config(dict):
|
|
|
|
pass
|