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

KDECore

  • kdecore
  • auth
kauthhelpersupport.cpp
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2008 Nicola Gigante <nicola.gigante@gmail.com>
3 * Copyright (C) 2009 Dario Freddi <drf@kde.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published by
7 * the Free Software Foundation; either version 2.1 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program; if not, write to the
17 * Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA .
19 */
20 
21 #include "kauthhelpersupport.h"
22 
23 #include <cstdlib>
24 #include <syslog.h>
25 
26 #include <QCoreApplication>
27 #include <QTimer>
28 
29 #include "BackendsManager.h"
30 
31 Q_DECLARE_METATYPE(QTimer*)
32 
33 namespace KAuth
34 {
35 
36 namespace HelperSupport
37 {
38 void helperDebugHandler(QtMsgType type, const char *msg);
39 }
40 
41 static bool remote_dbg = false;
42 
43 int HelperSupport::helperMain(int argc, char **argv, const char *id, QObject *responder)
44 {
45  openlog(id, 0, LOG_USER);
46  qInstallMsgHandler(&HelperSupport::helperDebugHandler);
47 
48  if (!BackendsManager::helperProxy()->initHelper(QString::fromLatin1(id))) {
49  syslog(LOG_DEBUG, "Helper initialization failed");
50  return -1;
51  }
52 
53  //closelog();
54  remote_dbg = true;
55 
56  BackendsManager::helperProxy()->setHelperResponder(responder);
57 
58  QCoreApplication app(argc, argv);
59  // Attach the timer
60  QTimer *timer = new QTimer(0);
61  responder->setProperty("__KAuth_Helper_Shutdown_Timer", QVariant::fromValue(timer));
62  timer->setInterval(10000);
63  timer->start();
64  QObject::connect(timer, SIGNAL(timeout()), &app, SLOT(quit()));
65  app.exec(); //krazy:exclude=crashy
66 
67  return 0;
68 }
69 
70 void HelperSupport::helperDebugHandler(QtMsgType type, const char *msg)
71 {
72  if (!remote_dbg) {
73  int level = LOG_DEBUG;
74  switch (type) {
75  case QtDebugMsg:
76  level = LOG_DEBUG;
77  break;
78  case QtWarningMsg:
79  level = LOG_WARNING;
80  break;
81  case QtCriticalMsg:
82  case QtFatalMsg:
83  level = LOG_ERR;
84  break;
85  }
86  syslog(level, "%s", msg);
87  } else {
88  BackendsManager::helperProxy()->sendDebugMessage(type, msg);
89  }
90 
91  // Anyway I should follow the rule:
92  if (type == QtFatalMsg) {
93  exit(-1);
94  }
95 }
96 
97 void HelperSupport::progressStep(int step)
98 {
99  BackendsManager::helperProxy()->sendProgressStep(step);
100 }
101 
102 void HelperSupport::progressStep(const QVariantMap &data)
103 {
104  BackendsManager::helperProxy()->sendProgressStep(data);
105 }
106 
107 bool HelperSupport::isStopped()
108 {
109  return BackendsManager::helperProxy()->hasToStopAction();
110 }
111 
112 } // namespace Auth
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Wed Jun 5 2013 18:35:20 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

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

kdelibs-4.10.4 API Reference

Skip menu "kdelibs-4.10.4 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal