• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KDECore

kauthhelpersupport.cpp

Go to the documentation of this file.
00001 /*
00002 *   Copyright (C) 2008 Nicola Gigante <nicola.gigante@gmail.com>
00003 *   Copyright (C) 2009 Dario Freddi <drf@kde.org>
00004 *
00005 *   This program is free software; you can redistribute it and/or modify
00006 *   it under the terms of the GNU Lesser General Public License as published by
00007 *   the Free Software Foundation; either version 2.1 of the License, or
00008 *   (at your option) any later version.
00009 *
00010 *   This program is distributed in the hope that it will be useful,
00011 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 *   GNU General Public License for more details.
00014 *
00015 *   You should have received a copy of the GNU Lesser General Public License
00016 *   along with this program; if not, write to the
00017 *   Free Software Foundation, Inc.,
00018 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .
00019 */
00020 
00021 #include "kauthhelpersupport.h"
00022 
00023 #include <cstdlib>
00024 #include <syslog.h>
00025 
00026 #include <QCoreApplication>
00027 #include <QTimer>
00028 
00029 #include "BackendsManager.h"
00030 
00031 Q_DECLARE_METATYPE(QTimer*)
00032 
00033 namespace KAuth
00034 {
00035 
00036 namespace HelperSupport
00037 {
00038 void helperDebugHandler(QtMsgType type, const char *msg);
00039 }
00040 
00041 static bool remote_dbg = false;
00042 
00043 int HelperSupport::helperMain(int argc, char **argv, const char *id, QObject *responder)
00044 {
00045     openlog(id, 0, LOG_USER);
00046     qInstallMsgHandler(&HelperSupport::helperDebugHandler);
00047 
00048     if (!BackendsManager::helperProxy()->initHelper(QString::fromLatin1(id))) {
00049         syslog(LOG_DEBUG, "Helper initialization failed");
00050         return -1;
00051     }
00052 
00053     //closelog();
00054     remote_dbg = true;
00055 
00056     BackendsManager::helperProxy()->setHelperResponder(responder);
00057 
00058     QCoreApplication app(argc, argv);
00059     // Attach the timer
00060     QTimer *timer = new QTimer(0);
00061     responder->setProperty("__KAuth_Helper_Shutdown_Timer", QVariant::fromValue(timer));
00062     timer->setInterval(10000);
00063     timer->start();
00064     QObject::connect(timer, SIGNAL(timeout()), &app, SLOT(quit()));
00065     app.exec(); //krazy:exclude=crashy
00066 
00067     return 0;
00068 }
00069 
00070 void HelperSupport::helperDebugHandler(QtMsgType type, const char *msg)
00071 {
00072     if (!remote_dbg) {
00073         int level = LOG_DEBUG;
00074         switch (type) {
00075         case QtDebugMsg:
00076             level = LOG_DEBUG;
00077             break;
00078         case QtWarningMsg:
00079             level = LOG_WARNING;
00080             break;
00081         case QtCriticalMsg:
00082         case QtFatalMsg:
00083             level = LOG_ERR;
00084             break;
00085         }
00086         syslog(level, "%s", msg);
00087     } else {
00088         BackendsManager::helperProxy()->sendDebugMessage(type, msg);
00089     }
00090 
00091     // Anyway I should follow the rule:
00092     if (type == QtFatalMsg) {
00093         exit(-1);
00094     }
00095 }
00096 
00097 void HelperSupport::progressStep(int step)
00098 {
00099     BackendsManager::helperProxy()->sendProgressStep(step);
00100 }
00101 
00102 void HelperSupport::progressStep(const QVariantMap &data)
00103 {
00104     BackendsManager::helperProxy()->sendProgressStep(data);
00105 }
00106 
00107 bool HelperSupport::isStopped()
00108 {
00109     return BackendsManager::helperProxy()->hasToStopAction();
00110 }
00111 
00112 } // namespace Auth

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal