SilentEye 0.4.1

controller.cpp

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye. If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #include "controller.h"
00017 
00018 using namespace SilentEyeFramework;
00019 
00020 namespace SilentEye {
00021 
00022     QPointer<Controller> Controller::m_pointer = NULL;
00023 
00024     Controller::Controller(QObject *parent) : QObject(parent)
00025     {
00026         setObjectName("Controller");
00027         m_logger = new Logger(this);
00028 
00029         appPath = "/";
00030 
00031         connect(&networkManager, SIGNAL(proxyAuthenticationRequired (const QNetworkProxy&, QAuthenticator*)),
00032                 this, SLOT(proxyAuthentication(const QNetworkProxy&, QAuthenticator*)));
00033     }
00034 
00035     Controller::~Controller()
00036     {
00037         // NOTHING TO DO
00038     }
00039 
00040     QPointer<Controller> Controller::instance()
00041     {
00042         if (m_pointer.isNull()) {
00043             m_pointer = new Controller();
00044         }
00045         return m_pointer;
00046     }
00047 
00048 
00049     void Controller::updateProxySettings()
00050     {
00051         QNetworkProxy proxy;
00052         if (config.get("proxyenable").toInt() == 1)
00053         {
00054             proxy.setType(QNetworkProxy::HttpProxy);
00055             proxy.setHostName(config.get("proxyhost"));
00056             proxy.setPort(config.get("proxyport").toInt());
00057         }
00058         networkManager.setProxy(proxy);
00059     }
00060 
00061     void Controller::proxyAuthentication(const QNetworkProxy & proxy, QAuthenticator * authenticator)
00062     {
00063         m_logger->warning("http proxy authentication required !");
00064     }
00065 }