2011-02-06 19:05:52 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# gPodder - A media aggregator and podcast client
|
2012-01-09 21:19:24 +01:00
|
|
|
# Copyright (c) 2005-2012 Thomas Perl and the gPodder Team
|
2011-02-06 19:05:52 +01:00
|
|
|
#
|
|
|
|
# gPodder 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.
|
|
|
|
#
|
|
|
|
# gPodder 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
# gpodder.core - Common functionality used by all UIs
|
|
|
|
# Thomas Perl <thp@gpodder.org>; 2011-02-06
|
|
|
|
|
|
|
|
|
|
|
|
import gpodder
|
|
|
|
|
|
|
|
from gpodder import util
|
|
|
|
from gpodder import config
|
|
|
|
from gpodder import dbsqlite
|
|
|
|
from gpodder import hooks
|
2011-10-12 19:59:09 +02:00
|
|
|
from gpodder import model
|
2011-02-06 19:05:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
class Core(object):
|
2011-10-12 19:59:09 +02:00
|
|
|
def __init__(self,
|
|
|
|
config_class=config.Config,
|
|
|
|
database_class=dbsqlite.Database,
|
|
|
|
model_class=model.Model):
|
2011-02-06 19:05:52 +01:00
|
|
|
# Initialize the gPodder home directory
|
|
|
|
util.make_directory(gpodder.home)
|
|
|
|
|
|
|
|
# Load hook modules and install the hook manager
|
2011-07-08 22:57:20 +02:00
|
|
|
gpodder.user_hooks = hooks.HookManager()
|
2011-02-06 19:05:52 +01:00
|
|
|
|
2011-10-19 12:37:55 +02:00
|
|
|
# Load installed/configured plugins
|
|
|
|
gpodder.load_plugins()
|
|
|
|
|
2011-02-06 19:05:52 +01:00
|
|
|
# Open the database and configuration file
|
|
|
|
self.db = database_class(gpodder.database_file)
|
2011-10-12 19:59:09 +02:00
|
|
|
self.model = model_class(self.db)
|
2011-02-06 19:05:52 +01:00
|
|
|
self.config = config_class(gpodder.config_file)
|
|
|
|
|
|
|
|
# Update the current device in the configuration
|
2012-01-03 23:59:19 +01:00
|
|
|
self.config.mygpo.device.type = util.detect_device_type()
|
2011-02-06 19:05:52 +01:00
|
|
|
|
|
|
|
def shutdown(self):
|
|
|
|
# Close the database and store outstanding changes
|
|
|
|
self.db.close()
|
|
|
|
|