23 #include <qgpgme/eventloopinteractor.h>
24 #include <gpgme++/context.h>
26 #include <QCoreApplication>
27 #include <QSocketNotifier>
30 using namespace GpgME;
32 QGpgME::EventLoopInteractor::EventLoopInteractor(
QObject * parent )
33 :
QObject( parent ), GpgME::EventLoopInteractor()
35 setObjectName(
QLatin1String(
"QGpgME::EventLoopInteractor::instance()" ) );
38 connect( app, SIGNAL(aboutToQuit()), SLOT(deleteLater()) );
39 connect( app, SIGNAL(aboutToQuit()), SIGNAL(aboutToDestroy()) );
45 QGpgME::EventLoopInteractor::~EventLoopInteractor() {
46 emit aboutToDestroy();
50 QGpgME::EventLoopInteractor * QGpgME::EventLoopInteractor::mSelf = 0;
52 QGpgME::EventLoopInteractor * QGpgME::EventLoopInteractor::instance() {
56 qWarning(
"QGpgME::EventLoopInteractor: Need a Q(Core)Application object before calling instance()!" );
59 (void)
new EventLoopInteractor;
69 template <
typename T_Enableable>
72 const bool wasEnabled;
74 explicit QDisabler( T_Enableable * t ) : o( t ), wasEnabled( o && o->isEnabled() )
77 t->setEnabled(
false );
83 o->setEnabled( wasEnabled );
89 void QGpgME::EventLoopInteractor::slotWriteActivity(
int socket ) {
94 const QDisabler<QSocketNotifier> disabled( qobject_cast<QSocketNotifier*>( sender() ) );
95 actOn( socket , Write );
98 void QGpgME::EventLoopInteractor::slotReadActivity(
int socket ) {
99 const QDisabler<QSocketNotifier> disabled( qobject_cast<QSocketNotifier*>( sender() ) );
100 actOn( socket , Read );
103 void QGpgME::EventLoopInteractor::nextTrustItemEvent( GpgME::Context * context,
const GpgME::TrustItem & item ) {
104 emit nextTrustItemEventSignal( context, item );
107 void QGpgME::EventLoopInteractor::nextKeyEvent( GpgME::Context * context,
const GpgME::Key & key ) {
108 emit nextKeyEventSignal( context, key );
111 void QGpgME::EventLoopInteractor::operationDoneEvent( GpgME::Context * context,
const GpgME::Error & e ) {
112 emit operationDoneEventSignal( context, e );
115 void QGpgME::EventLoopInteractor::operationStartEvent( GpgME::Context * context ) {
116 emit operationStartEventSignal( context );
QCoreApplication * instance()