summaryrefslogtreecommitdiffstats
path: root/net/can
AgeCommit message (Expand)Author
2016-06-23can: only call can_stat_update with procfsArnd Bergmann
2016-06-17can: bcm: add support for CAN FD framesOliver Hartkopp
2016-06-17can: bcm: unify bcm_msg_head handling and prepare function parametersOliver Hartkopp
2016-06-17can: bcm: use CAN frame instead of can_frame in commentsOliver Hartkopp
2016-06-17can: bcm: fix indention and other minor style issuesOliver Hartkopp
2016-06-17can: build proc support only if CONFIG_PROC_FS is activatedAlexander Aring
2016-04-04sock: enable timestamping using control messagesSoheil Hassas Yeganeh
2015-10-13can: avoid using timeval for uapiArnd Bergmann
2015-07-12can: replace timestamp as unique skb attributeOliver Hartkopp
2015-06-24Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller
2015-06-21can: fix loss of CAN frames in raw_rcvOliver Hartkopp
2015-06-09can: cangw: introduce optional uid to reference created routing jobsOliver Hartkopp
2015-05-11net: Pass kern from net_proto_family.create to sk_allocEric W. Biederman
2015-04-01can: introduce new raw socket option to join the given CAN filtersOliver Hartkopp
2015-04-01can: fix multiple delivery of a single CAN frame for overlapping CAN filtersOliver Hartkopp
2015-03-09Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller
2015-03-09can: add missing initialisations in CAN related skbuffsOliver Hartkopp
2015-03-02net: Remove iocb argument from sendmsg and recvmsgYing Xue
2015-03-02net: use common macro for assering skb->cb[] available size in protocol familiesEyal Birger
2015-01-18netlink: make nlmsg_end() and genlmsg_end() voidJohannes Berg
2014-12-07can: fix spelling errorsJeremiah Mahler
2014-12-07can: eliminate banner[] variable and switch to pr_info()Jeremiah Mahler
2014-11-24new helper: memcpy_to_msg()Al Viro
2014-11-24new helper: memcpy_from_msg()Al Viro
2014-05-19can: add hash based access to single EFF frame filtersOliver Hartkopp
2014-05-19can: proc: make array printing function indenpendent from sff framesOliver Hartkopp
2014-04-24net: Use netlink_ns_capable to verify the permisions of netlink messagesEric W. Biederman
2014-03-03can: remove CAN FD compatibility for CAN 2.0 socketsOliver Hartkopp
2014-01-30Merge tag 'linux-can-fixes-for-3.14-20140129' of git://gitorious.org/linux-ca...David S. Miller
2014-01-30can: add destructor for self generated skbsOliver Hartkopp
2014-01-29can: Propagate SO_PRIORITY of raw sockets to skbsRostislav Lisovy
2014-01-18net: add build-time checks for msg->msg_name sizeSteffen Hurrle
2014-01-14can: use __dev_get_by_index instead of dev_get_by_index to find interfaceYing Xue
2013-12-21can: gw: remove obsolete checksOliver Hartkopp
2013-11-15Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jik...Linus Torvalds
2013-10-19net: 8021q/bluetooth/bridge/can/ceph: Remove extern from function prototypesJoe Perches
2013-10-14treewide: Fix common typo in "identify"Maxime Jayat
2013-08-29can: gw: add a per rule limitation of frame hopsOliver Hartkopp
2013-05-28net: pass info struct via netdevice notifierJiri Pirko
2013-05-01Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/vir...Linus Torvalds
2013-04-22Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/netDavid S. Miller
2013-04-14net: sock: make sock_tx_timestamp voidDaniel Borkmann
2013-04-09procfs: new helper - PDE_DATA(inode)Al Viro
2013-04-09can: gw: use kmem_cache_free() instead of kfree()Wei Yongjun
2013-03-22rtnetlink: Remove passing of attributes into rtnl_doit functionsThomas Graf
2013-03-19can: dump stack on protocol bugsOliver Hartkopp
2013-03-11net: can: af_can.c: Fix checkpatch warningsValentin Ilie
2013-02-27hlist: drop the node parameter from iteratorsSasha Levin
2013-02-18net: proc: change proc_net_remove to remove_proc_entryGao feng
2013-01-28can: rework skb reserved data handlingOliver Hartkopp
n152' href='#n152'>152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
<?php
/**
 * Nextcloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author    Alessandro Cosentino <cosenal@gmail.com>
 * @author    Bernhard Posselt <dev@bernhard-posselt.com>
 * @copyright 2012 Alessandro Cosentino
 * @copyright 2012-2014 Bernhard Posselt
 */

namespace OCA\News\AppInfo;

use Closure;
use FeedIo\FeedIo;
use HTMLPurifier;
use HTMLPurifier_Config;
use Favicon\Favicon;

use OCA\News\Config\FetcherConfig;
use OCA\News\Utility\PsrLogger;
use OCP\BackgroundJob\IJobList;

use OCP\IContainer;
use OCP\INavigationManager;
use OCP\IURLGenerator;
use OCP\IConfig;
use OCP\ITempManager;
use OCP\AppFramework\App;
use OCP\Files\IRootFolder;
use OCP\Files\Node;


use OCA\News\Config\AppConfig;
use OCA\News\Config\Config;
use OCA\News\Db\MapperFactory;
use OCA\News\Db\ItemMapper;
use OCA\News\Fetcher\FeedFetcher;
use OCA\News\Fetcher\Fetcher;
use OCA\News\Fetcher\YoutubeFetcher;
use OCA\News\Utility\ProxyConfigParser;
use OCA\News\Scraper\Scraper;

/**
 * Class Application
 *
 * @package OCA\News\AppInfo
 */
class Application extends App
{

    /**
     * Application constructor.
     *
     * @param array $urlParams Parameters
     */
    public function __construct(array $urlParams = [])
    {
        parent::__construct('news', $urlParams);

        $container = $this->getContainer();

        // files
        $container->registerService('checksums', function () {
            return file_get_contents(__DIR__ . '/checksum.json');
        });
        $container->registerService('info', function () {
            return file_get_contents(__DIR__ . '/../../appinfo/info.xml');
        });

        // parameters
        $container->registerParameter('exploreDir', __DIR__ . '/../Explore/feeds');
        $container->registerParameter('configFile', 'config.ini');

        // factories
        $container->registerService(ItemMapper::class, function (IContainer $c): ItemMapper {
            return $c->query(MapperFactory::class)->build();
        });

        /**
         * App config parser.
         */
        $container->registerService(AppConfig::class, function (IContainer $c): AppConfig {
            $config = new AppConfig(
                $c->query(INavigationManager::class),
                $c->query(IURLGenerator::class),
                $c->query(IJobList::class)
            );

            $config->loadConfig($c->query('info'));
            return $config;
        });

        /**
         * Core
         */
        $container->registerService('LoggerParameters', function (IContainer $c): array {
            return ['app' => $c->query('AppName')];
        });

        $container->registerService('databaseType', function (IContainer $c) {
            return $c->query(IConfig::class)->getSystemValue('dbtype');
        });

        $container->registerService('ConfigView', function (IContainer $c): Node {
            /** @var IRootFolder $fs */
            $fs = $c->query(IRootFolder::class);
            $path = 'news/config';
            if ($fs->nodeExists($path)) {
                return $fs->get($path);
            } else {
                return $fs->newFolder($path);
            }
        });

        /**
         * Logger base
         */
        $container->registerService(PsrLogger::class, function (IContainer $c): PsrLogger {
            return new PsrLogger(
                $c->query('ServerContainer')->getLogger(),
                $c->query('AppName')
            );
        });

        $container->registerService(Config::class, function (IContainer $c): Config {
            $config = new Config(
                $c->query('ConfigView'),
                $c->query(PsrLogger::class),
                $c->query('LoggerParameters')
            );
            $config->read($c->query('configFile'), true);
            return $config;
        });

        $container->registerService(HTMLPurifier::class, function (IContainer $c): HTMLPurifier {
            $directory = $c->query(IConfig::class)->getSystemValue('datadirectory') . '/news/cache/purifier';

            if (!is_dir($directory)) {
                mkdir($directory, 0770, true);
            }

            $config = HTMLPurifier_Config::createDefault();
            $config->set('HTML.ForbiddenAttributes', 'class');
            $config->set('Cache.SerializerPath', $directory);
            $config->set('HTML.SafeIframe', true);
            $config->set(
                'URI.SafeIframeRegexp',
                '%^https://(?:www\.)?(' .
                'youtube(?:-nocookie)?.com/embed/|' .
                'player.vimeo.com/video/|' .
                'vk.com/video_ext.php)%'
            ); //allow YouTube and Vimeo
            $def = $config->getHTMLDefinition(true);
            $def->addAttribute('iframe', 'allowfullscreen', 'Bool');
            return new HTMLPurifier($config);
        });

        /**
         * Fetchers
         */
        $container->registerService(FetcherConfig::class, function (IContainer $c): FetcherConfig {
            $fConfig = new FetcherConfig();
            $fConfig->setConfig($c->query(Config::class))
                    ->setProxy($c->query(IConfig::class));

            return $fConfig;
        });

        $container->registerService(FeedIo::class, function (IContainer $c): FeedIo {
            $config = $c->query(FetcherConfig::class);
            return new FeedIo($config->getClient(), $c->query(PsrLogger::class));
        });

        $container->registerService(Favicon::class, function (IContainer $c): Favicon {
            $favicon = new Favicon();
            $tempManager = $c->query(ITempManager::class);
            $settings = ['dir' => $tempManager->getTempBaseDir()];
            $favicon->cache($settings);
            return $favicon;
        });

        /**
         * @noinspection PhpParamsInspection
         */
        $container->registerService(Fetcher::class, function (IContainer $c): Fetcher {
            $fetcher = new Fetcher();

            // register fetchers in order, the most generic fetcher should be
            // the last one
            $fetcher->registerFetcher($c->query(YoutubeFetcher::class));
            $fetcher->registerFetcher($c->query(FeedFetcher::class));
            return $fetcher;
        });

        /**
         * Scrapers
         */
        $container->registerService(Scraper::class, function (IContainer $c): Scraper {
            return new Scraper(
                $c->query(PsrLogger::class)
            );
        });
    }
}