Conversion of 'agent' library module.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/1/head
Michele Calgaro 2 years ago
parent 98b37ff3b1
commit a8e9f8dd80
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -109,19 +109,21 @@ install(
${INCLUDE_INSTALL_DIR}/PolkitTQt/Gui
)
install(
FILES
includes/PolkitTQt/Agent/Listener
includes/PolkitTQt/Agent/Session
DESTINATION
${INCLUDE_INSTALL_DIR}/PolkitTQt/Agent
)
install(
FILES
polkit-tqt-export.h
## agent/polkittqt1-agent-listener.h
## agent/polkittqt1-agent-session.h
##
## ${CMAKE_CURRENT_BINARY_DIR}/polkittqt1-version.h
##
DESTINATION
${INCLUDE_INSTALL_DIR} )
## find_package(GObject REQUIRED)
## find_package(GIO REQUIRED)
##
## include (${TQT_USE_FILE})
## include (InstallSettings)
@ -162,11 +164,6 @@ install(
## DESTINATION
## ${INCLUDE_INSTALL_DIR}/polkit-qt-1 )
##
## install(FILES
## includes/PolkitTQt/Agent/Listener
## includes/PolkitTQt/Agent/Session
## DESTINATION
## ${INCLUDE_INSTALL_DIR}/polkit-qt-1/PolkitTQt/Agent )
##
## # CMake Config files
## configure_file(PolkitTQt-1Config.cmake.in "${CMAKE_BINARY_DIR}/PolkitTQt-1Config.cmake" @ONLY)

@ -22,10 +22,16 @@ tde_setup_largefiles( )
# tqt
find_package( TQt )
# check for polkit
pkg_search_module( POLKIT polkit-gobject-1 )
if( NOT POLKIT_FOUND )
tde_message_fatal( "polkit is required, but was not found on your system" )
# check for polkit-gobject-1
pkg_search_module( POLKIT_GOBJECT polkit-gobject-1 )
if( NOT POLKIT_GOBJECT_FOUND )
tde_message_fatal( "polkit-gobject-1 is required, but was not found on your system" )
endif( )
# check for polkit-agent-1
pkg_search_module( POLKIT_AGENT polkit-agent-1 )
if( NOT POLKIT_AGENT_FOUND )
tde_message_fatal( "polkit-agent-1 is required, but was not found on your system" )
endif( )
# gcc visibility

@ -1,35 +1,35 @@
/**
\mainpage Polkit-tqt-1 - TQt wrapper around polkit-1
\mainpage Polkit-tqt - TQt wrapper around polkit-1
\section polkittqt1_overview Overview
\section polkit-tqt_overview Overview
polkit-tqt-1 aims to make it easy for TQt developers to take advantage of
polkit-tqt aims to make it easy for TQt developers to take advantage of
polkit API. It is a convenience wrapper around QAction and QAbstractButton
that lets you integrate those two components easily with polkit.
polkit-tqt-1 is split in three libraries: polkit-tqt-core-1, polkit-tqt-gui-1 and polkit-tqt-agent-1
polkit-tqt is split in three libraries: polkit-tqt-core, polkit-tqt-gui and polkit-tqt-agent
\b polkit-tqt-core-1 lets you control actions and authentication without a GUI, with some very
\b polkit-tqt-core lets you control actions and authentication without a GUI, with some very
simple functions. It also lets you retrieve and control useful informations on the polkit
authority. You will be mostly interested in the \c Authority class.
\b polkit-tqt-gui-1 lets you easily associate GUI items with polkit actions. Through some simple
\b polkit-tqt-gui lets you easily associate GUI items with polkit actions. Through some simple
wrapper classes you are able to associate QAction and QAbstractButton to a polkit action,
and get their properties changed accordingly to polkit's result. It includes the classes
Action, ActionButton and ActionButtons
\b polkit-tqt-agent-1 lets you write your own polkit authentication agents in a very simple way.
\b polkit-tqt-agent lets you write your own polkit authentication agents in a very simple way.
\li A sample usage of polkit-tqt-1 can be found in \ref polkittqt1_example
\li A sample usage of polkit-tqt can be found in \ref polkittqt1_example
\li <a href="classes.html">Alphabetical Class List</a>
\li <a href="hierarchy.html">Class Hierarchy</a>
\page polkittqt1_example Polkit-tqt-1 usage example
\page polkittqt1_example Polkit-tqt usage example
You can find an example usage of Polkit-tqt-1 in the examples/ dir. You can
You can find an example usage of Polkit-tqt in the examples/ dir. You can
build it by passing \c -DBUILD_EXAMPLES=TRUE to your cmake line. The structure
consists of a .ui file and a main class, to demonstrate how easy it is to integrate
polkit support in an existing application. Let's see some details about it:
@ -85,12 +85,12 @@ with even more ease, just by manually connecting the signal to ActionButton::act
to understand why this connection doesn't happen automatically), and Action::authorized() signal notifies
you when polkit has authorized you to perform the action.
As you can see, usage of polkit-tqt-1 is extremely simple. Have a look at the complete example
As you can see, usage of polkit-tqt is extremely simple. Have a look at the complete example
and to the API Docs for more details.
*/
// DOXYGEN_PROJECTVERSION=0.96.1
// DOXYGEN_PROJECTNAME=polkittqt-1
// DOXYGEN_PROJECTNAME=polkittqt
// DOXYGEN_ENABLE=YES

@ -10,9 +10,13 @@
#################################################
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/core
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${TQT_INCLUDE_DIRS}
${POLKIT_GOBJECT_INCLUDE_DIRS}
${POLKIT_AGENT_INCLUDE_DIRS}
)
link_directories(
@ -22,37 +26,33 @@ link_directories(
##### install headers ###########################
install( FILES
dummy-agent.h
DESTINATION ${INCLUDE_INSTALL_DIR} )
install(
FILES
polkit-tqt-agent-session.h
polkit-tqt-agent-listener.h
listeneradapter.h
polkit-tqt-listener.h
DESTINATION ${INCLUDE_INSTALL_DIR}
)
##### polkit-tqt-agent (shared) #########################
tde_add_library( polkit-tqt-agent SHARED AUTOMOC
SOURCES ${polkit_tqt_agent_MOCS}
dummy-agent.cpp
polkit-tqt-agent-session.cpp
polkit-tqt-agent-listener.cpp
listeneradapter.cpp
polkit-tqt-listener.cpp
VERSION 0.0.0
LINK ${TQT_LIBRARIES}
LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} ${POLKIT_AGENT_LIBRARIES} polkit-tqt-core-shared
DESTINATION ${LIB_INSTALL_DIR}
)
## set(polkit_tqt_agent_SRCS
## polkittqt1-agent-session.cpp
## polkittqt1-agent-listener.cpp
## listeneradapter.cpp
## polkittqtlistener.cpp
## )
## target_link_libraries(polkit-tqt-agent-1
## ${POLKIT_LIBRARIES}
## ${TQT_TQTCORE_LIBRARY}
## ${POLKIT_AGENT_LIBRARY}
## polkit-tqt-core-1
## )
##
## set_target_properties(polkit-tqt-agent-1 PROPERTIES VERSION ${POLKITTQT-1_LIBRARY_VERSION}
## SOVERSION ${POLKITTQT-1_ABI_VERSION}
## DEFINE_SYMBOL MAKE_POLKIT_TQT_LIB)
##
## install(TARGETS polkit-tqt-agent-1 ${INSTALL_TARGETS_DEFAULT_ARGS})
##
## set_target_properties(polkit-tqt-agent-1 PROPERTIES VERSION ${POLKITTQT-1_LIBRARY_VERSION}
## SOVERSION ${POLKITTQT-1_ABI_VERSION}
## DEFINE_SYMBOL MAKE_POLKIT_TQT_LIB)
##

@ -1,37 +0,0 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "dummy-agent.h"
namespace PolkitTQt
{
DummyAgent* DummyAgent::instance()
{
return 0;
}
}
#include "dummy-agent.moc"

@ -1,56 +0,0 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Daniel Nicoletti <dantti85-pk@yahoo.com.br>
* Copyright (C) 2009 Dario Freddi <drf@kde.org>
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef DUMMY_AGENT_H
#define DUMMY_AGENT_H
#define POLKIT_TQT_EXPORT TQ_EXPORT
/**
* \namespace PolkitTQt PolkitTQt
*
* \brief Namespace wrapping Polkit-TQt classes
*
* This namespace wraps all Polkit-TQt classes.
*/
namespace PolkitTQt
{
/**
* \class DummyAgent
*
* \brief Convenience class for TQt/KDE applications
*
* This class is a dummy used for initial basic compiling.
*/
class POLKIT_TQT_EXPORT DummyAgent
{
public:
static DummyAgent* instance();
};
}
#endif

@ -18,129 +18,119 @@
* Boston, MA 02110-1301, USA.
*/
#include "listeneradapter_p.h"
#include <TQtCore/TQDebug>
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
#include "listeneradapter.h"
namespace PolkitTQt
{
namespace Agent
{
class ListenerAdapterHelper
{
public:
ListenerAdapterHelper() : q(0) {}
~ListenerAdapterHelper() {
delete q;
}
ListenerAdapter *q;
};
//--------------------------------------
// ListenerAdapter
//--------------------------------------
TQ_GLOBAL_STATIC(ListenerAdapterHelper, s_globalListenerAdapter)
ListenerAdapter *ListenerAdapter::m_theListenerAdapter = NULL;
ListenerAdapter *ListenerAdapter::instance()
{
if (!s_globalListenerAdapter()->q) {
new ListenerAdapter();
}
return s_globalListenerAdapter()->q;
if (!m_theListenerAdapter)
{
m_theListenerAdapter = new ListenerAdapter();
}
return m_theListenerAdapter;
}
ListenerAdapter::ListenerAdapter(TQObject *parent)
: TQObject(parent)
ListenerAdapter::ListenerAdapter(TQObject *parent) : TQObject(parent)
{
Q_ASSERT(!s_globalListenerAdapter()->q);
s_globalListenerAdapter()->q = this;
}
Listener* ListenerAdapter::findListener(PolkitAgentListener *listener)
{
Listener *listItem;
TQ_FOREACH(listItem, m_listeners) {
Q_ASSERT(listItem);
if (listItem->listener() == listener) {
return listItem;
}
TQValueList<Listener*>::iterator listerIt;
for (listerIt = m_listeners.begin(); listerIt != m_listeners.end(); ++listerIt)
{
Listener *listItem = *listerIt;
if (listItem && listItem->listener() == listener)
{
return listItem;
}
}
return NULL;
return NULL;
}
void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GSimpleAsyncResult *result)
void ListenerAdapter::polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id, const gchar *message, const gchar *icon_name,
PolkitDetails *details, const gchar *cookie, GList *identities,
GCancellable *cancellable, GSimpleAsyncResult *result)
{
tqDebug() << "polkit_tqt_listener_initiate_authentication callback for " << listener;
PolkitTQt::Identity::List idents;
PolkitTQt::Details dets(details);
Listener *list = findListener(listener);
for (GList *identity = g_list_first(identities); identity != NULL; identity = g_list_next(identity)) {
idents.append(PolkitTQt::Identity((PolkitIdentity *)identity->data));
}
list->initiateAuthentication(TQString::fromUtf8(action_id),
TQString::fromUtf8(message),
TQString::fromUtf8(icon_name),
dets,
TQString::fromUtf8(cookie),
idents,
new AsyncResult(result));
tqDebug("polkit_tqt_listener_initiate_authentication callback for %p", listener);
Identity::List idents;
Details dets(details);
GList *identity;
for (identity = g_list_first(identities); identity != NULL; identity = g_list_next(identity))
{
idents.append(Identity((PolkitIdentity*)identity->data));
}
Listener *list = findListener(listener);
list->initiateAuthentication(TQString::fromUtf8(action_id), TQString::fromUtf8(message),
TQString::fromUtf8(icon_name), dets, TQString::fromUtf8(cookie), idents,
new AsyncResult(result));
}
gboolean ListenerAdapter::polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error)
gboolean ListenerAdapter::polkit_tqt_listener_initiate_authentication_finish(
PolkitAgentListener *listener, GAsyncResult *res, GError **error)
{
tqDebug() << "polkit_tqt_listener_initiate_authentication_finish callback for " << listener;
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
if (g_simple_async_result_propagate_error(simple, error)) {
return false;
}
return true;
tqDebug("polkit_tqt_listener_initiate_authentication_finish callback for %p", listener);
GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT(res);
if (g_simple_async_result_propagate_error(simple, error))
{
return false;
}
return true;
}
void ListenerAdapter::cancelled_cb(PolkitAgentListener *listener)
{
tqDebug() << "cancelled_cb for " << listener;
Listener *list = findListener(listener);
tqDebug("cancelled_cb for %p", listener);
Listener *list = findListener(listener);
if (list)
{
list->cancelAuthentication();
}
}
void ListenerAdapter::addListener(Listener *listener)
{
tqDebug() << "Adding new listener " << listener << "for " << listener->listener();
tqDebug("Adding new listener %p for %p", listener, listener->listener());
m_listeners.append(listener);
m_listeners.append(listener);
}
void ListenerAdapter::removeListener(Listener *listener)
{
tqDebug() << "Removing listener " << listener;
// should be safe as we don't have more than one same listener registered in one time
m_listeners.removeOne(listener);
tqDebug("Removing listener %p", listener);
// should be safe as we don't have more than one same listener registered in one time
TQValueList<Listener*>::iterator listerIt = m_listeners.find(listener);
if (listerIt != m_listeners.end())
{
m_listeners.remove(listerIt);
}
}
}
}
#include "listeneradapter_p.moc"
#include "listeneradapter.moc"

@ -21,11 +21,11 @@
#ifndef LISTENER_ADAPTER_P_H
#define LISTENER_ADAPTER_P_H
#include <TQtCore/TQObject>
#include "tqobject.h"
#include "polkittqt1-agent-listener.h"
#include "polkittqt1-identity.h"
#include "polkittqt1-details.h"
#include "polkit-tqt-agent-listener.h"
#include "polkit-tqt-identity.h"
#include "polkit-tqt-details.h"
typedef struct _GList GList;
typedef struct _GCancellable GCancellable;
@ -35,6 +35,10 @@ typedef struct _GError GError;
typedef int gboolean;
typedef char gchar;
class TQString;
template<typename> class TQValueList;
namespace PolkitTQt
{
@ -43,35 +47,40 @@ namespace Agent
class AsyncResult;
class Listener;
class ListenerAdapter : public TQObject
{
Q_OBJECT
TQ_DISABLE_COPY(ListenerAdapter)
public:
Q_OBJECT
public:
static ListenerAdapter* instance();
~ListenerAdapter() {}
void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GSimpleAsyncResult *result);
gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error);
~ListenerAdapter()
{
}
void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id, const gchar *message, const gchar *icon_name,
PolkitDetails *details, const gchar *cookie, GList *identities,
GCancellable *cancellable, GSimpleAsyncResult *result);
gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res, GError **error);
void cancelled_cb(PolkitAgentListener *listener);
private:
private:
void addListener(Listener *listener);
void removeListener(Listener *listener);
Listener* findListener(PolkitAgentListener *listener);
explicit ListenerAdapter(TQObject *parent = 0);
TQList<Listener *> m_listeners;
TQValueList<Listener*> m_listeners;
// Disable copy
ListenerAdapter(const ListenerAdapter&);
ListenerAdapter& operator=(const ListenerAdapter&);
static ListenerAdapter *m_theListenerAdapter;
friend class Listener;
};
@ -81,3 +90,4 @@ private:
}
#endif

@ -0,0 +1,105 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "polkit-tqt-listener.h"
#include "polkit-tqt-agent-listener.h"
#include "polkit-tqt-authority.h"
#include "polkit-tqt-subject.h"
#include "polkit-tqt-identity.h"
#include "polkit-tqt-details.h"
namespace PolkitTQt
{
namespace Agent
{
class ListenerPrivate
{
public:
PolkitAgentListener *listener;
void *registeredHandle;
};
Listener::Listener(TQObject *parent) : TQObject(parent), d(new ListenerPrivate)
{
d->listener = polkit_tqt_listener_new();
tqDebug("New PolkitAgentListener %p", d->listener);
ListenerAdapter::instance()->addListener(this);
}
Listener::Listener(PolkitAgentListener *listener, TQObject *parent)
: TQObject(parent), d(new ListenerPrivate)
{
d->listener = listener;
}
Listener::~Listener()
{
tqDebug("Destroying listener");
ListenerAdapter::instance()->removeListener(this);
if (d->registeredHandle)
{
polkit_agent_listener_unregister(d->registeredHandle);
}
if (d->listener != NULL)
{
g_object_unref(d->listener);
}
}
bool Listener::registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath)
{
GError *error = NULL;
d->registeredHandle = polkit_agent_listener_register(d->listener,
POLKIT_AGENT_REGISTER_FLAGS_NONE, subject.subject(), objectPath.ascii(), NULL, &error);
if (error != NULL)
{
tqWarning(TQString("Cannot register authentication agent: %1").arg(error->message));
g_error_free(error);
return false;
}
if (d->registeredHandle == NULL)
{
tqWarning(TQString("Cannot register authentication agent!"));
return false;
}
return true;
}
const PolkitAgentListener *Listener::listener()
{
return d->listener;
}
}
}
#include "polkit-tqt-agent-listener.moc"

@ -22,31 +22,28 @@
#define POLKIT_TQT_AGENT_LISTENER_H
#include "polkit-tqt-export.h"
#include "polkit-tqt-agent-session.h"
#include "polkit-tqt-identity.h"
#include <TQtCore/TQObject>
#include "tqobject.h"
#include "polkittqt1-agent-session.h"
typedef struct _PolkitAgentListener PolkitAgentListener;
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
class TQString;
typedef struct _PolkitAgentListener PolkitAgentListener;
namespace PolkitTQt
{
class Subject;
class Identity;
class Details;
}
namespace PolkitTQt
{
namespace Agent
{
class ListenerPrivate;
/**
* \class Listener polkittqt1-agent-listener.h Listener
* \class Listener polkit-tqt-agent-listener.h Listener
* \author Jaroslav Reznik <jreznik@redhat.com>
*
* \brief Listener is abstract class used for implementing authentication agents.
@ -60,9 +57,9 @@ class ListenerPrivate;
*/
class POLKIT_TQT_EXPORT Listener : public TQObject
{
Q_OBJECT
TQ_DISABLE_COPY(Listener)
public:
Q_OBJECT
public:
/**
* \brief Constructor of Listener class
*/
@ -93,7 +90,7 @@ public:
* \param objectPath DBus object path
* \return \c True if the polkittqt1-agent-listener.has been registered, \c False otherwise
*/
bool registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath);
bool registerListener(const Subject &subject, const TQString &objectPath);
/**
* \brief Returns pointer to the PolkitAgentListener.
@ -104,7 +101,7 @@ public:
*/
const PolkitAgentListener *listener();
public Q_SLOTS:
public slots:
/**
* \brief Initiate authentication for the action
*
@ -123,16 +120,11 @@ public Q_SLOTS:
* authentication is done. You can pass it to the constructor of the Session class
* and then call session->result()->complete() to mark the action as done.
*/
virtual void initiateAuthentication(const TQString &actionId,
const TQString &message,
const TQString &iconName,
const PolkitTQt::Details &details,
const TQString &cookie,
const PolkitTQt::Identity::List &identities,
AsyncResult *result) = 0;
virtual void initiateAuthentication(const TQString &actionId, const TQString &message,
const TQString &iconName, const Details &details, const TQString &cookie,
const Identity::List &identities, AsyncResult *result) = 0;
/**
* TODO: Is this method really required ?
* \brief Finishes an authentication request from the polkit daemon.
*
* \note You have to reimplement this method in the subclass.
@ -142,7 +134,6 @@ public Q_SLOTS:
virtual bool initiateAuthenticationFinish() = 0;
/**
* TODO: Is this method really required ?
* \brief Cancels an authentication request from the polkit daemon.
*
* \note You have to reimplement this method in the subclass.
@ -152,10 +143,16 @@ public Q_SLOTS:
virtual void cancelAuthentication() = 0;
private:
ListenerPrivate * const d;
// Disable copy
Listener(const Listener&);
Listener& operator=(const Listener&);
ListenerPrivate *const d;
};
}
}
#endif

@ -0,0 +1,189 @@
/*
* This file is part of the PolKit-tqt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE
#include <polkitagent/polkitagent.h>
#include "polkit-tqt-identity.h"
#include "polkit-tqt-agent-session.h"
#include <tqstring.h>
using namespace PolkitTQt;
using namespace PolkitTQt::Agent;
//--------------------------------------
// Session::Private
//--------------------------------------
class Session::Private
{
public:
Private()
{
}
~Private()
{
// polkitAgentSession is freed in Session d'tor
}
static void completed(PolkitAgentSession *s, gboolean gained_authorization, gpointer user_data);
static void request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data);
static void showError(PolkitAgentSession *s, gchar *text, gpointer user_data);
static void showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data);
AsyncResult *result;
PolkitAgentSession *polkitAgentSession;
};
void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authorization,
gpointer user_data)
{
Session *session = (Session *)user_data;
emit(session)->completed(gained_authorization);
//free session here as polkit documentation asks
g_object_unref(session->d->polkitAgentSession);
session->d->polkitAgentSession = 0;
}
void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on,
gpointer user_data)
{
emit((Session*)user_data)->request(TQString::fromUtf8(request), echo_on);
}
void Session::Private::showError(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
emit((Session*)user_data)->showError(TQString::fromUtf8(text));
}
void Session::Private::showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
emit((Session*)user_data)->showInfo(TQString::fromUtf8(text));
}
//--------------------------------------
// Session
//--------------------------------------
Session::Session(const Identity &identity, const TQString &cookie, AsyncResult *result,
TQObject *parent) : TQObject(parent), d(new Private)
{
d->result = result;
d->polkitAgentSession = polkit_agent_session_new(identity.identity(), cookie.utf8().data());
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::Session(PolkitAgentSession *pkAgentSession, TQObject *parent)
: TQObject(parent), d(new Private)
{
d->polkitAgentSession = pkAgentSession;
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::~Session()
{
if (d->polkitAgentSession)
{
g_object_unref(d->polkitAgentSession);
}
delete d;
}
void Session::initiate()
{
polkit_agent_session_initiate(d->polkitAgentSession);
}
void Session::setResponse(const TQString &response)
{
polkit_agent_session_response(d->polkitAgentSession, response.utf8().data());
}
void Session::cancel()
{
polkit_agent_session_cancel(d->polkitAgentSession);
}
//--------------------------------------
// AsyncResult::Private
//--------------------------------------
class AsyncResult::Private
{
public:
Private(GSimpleAsyncResult *r) : result(r)
{
}
GSimpleAsyncResult *result;
};
AsyncResult* Session::result()
{
return d->result;
}
AsyncResult::AsyncResult(GSimpleAsyncResult *result) : d(new Private(result))
{
}
AsyncResult::~AsyncResult()
{
if (d->result)
{
g_object_unref(d->result);
}
}
void AsyncResult::setCompleted()
{
if (d->result == NULL)
{
return;
}
g_simple_async_result_complete(d->result);
// Assure that completed won't be called twice
g_object_unref(d->result);
d->result = NULL;
}
void AsyncResult::setError(const TQString &text)
{
if (d->result == NULL)
{
return;
}
g_simple_async_result_set_error(d->result, POLKIT_ERROR, POLKIT_ERROR_FAILED, "%s",
text.utf8().data());
}
#include "polkit-tqt-agent-session.moc"

@ -1,5 +1,5 @@
/*
* This file is part of the PolKit1-tqt project
* This file is part of the PolKit-tqt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
@ -21,14 +21,19 @@
#ifndef POLKIT_TQT_AGENT_SESSION_H
#define POLKIT_TQT_AGENT_SESSION_H
#include <TQtCore/TQObject>
#include "polkittqt1-identity.h"
#include "polkit-tqt-export.h"
#include "tqobject.h"
typedef struct _GSimpleAsyncResult GSimpleAsyncResult;
typedef struct _PolkitAgentSession PolkitAgentSession;
class TQString;
namespace PolkitTQt
{
class Identity;
/**
* \namespace Agent Agent
@ -47,7 +52,7 @@ namespace Agent
*/
class POLKIT_TQT_EXPORT AsyncResult
{
public:
public:
explicit AsyncResult(GSimpleAsyncResult *result);
virtual ~AsyncResult();
@ -64,13 +69,13 @@ public:
*/
void setError(const TQString &text);
private:
private:
class Private;
Private * const d;
Private *const d;
};
/**
* \class Session polkittqt1-agent-session.h Session
* \class Session polkit-tqt-agent-session.h Session
* \author Radek Novacek <rnovacek@redhat.com>
*
* This class is interface for interacting with native
@ -79,9 +84,9 @@ private:
*/
class POLKIT_TQT_EXPORT Session : public TQObject
{
Q_OBJECT
TQ_DISABLE_COPY(Session)
public:
Q_OBJECT
public:
/**
* Create a new authentication session.
*
@ -90,7 +95,8 @@ public:
* \param result Result of the authentication action. Must be finished using complete() method.
* \param parent
*/
Session(const PolkitTQt::Identity& identity, const TQString &cookie, AsyncResult *result = 0, TQObject *parent = 0);
Session(const Identity &identity, const TQString &cookie, AsyncResult *result = 0,
TQObject *parent = 0);
/**
* Create a new authentication session from PolkitAgentSession object
@ -134,10 +140,10 @@ public:
*/
AsyncResult *result();
Q_SIGNALS:
signals:
/**
* This signal will be emitted when the authentication
* polkittqt1-agent-session.has been completed or cancelled.
* polkit-tqt-agent-session.has been completed or cancelled.
*
* \param gainedAuthorization \c True if authorization was successfully obtained.
*/
@ -169,8 +175,12 @@ Q_SIGNALS:
void showInfo(const TQString &text);
private:
// Disable copy
Session(const Session&);
Session& operator=(const Session&);
class Private;
Private * const d;
Private *const d;
};
}
@ -178,3 +188,4 @@ private:
}
#endif // SESSION_H

@ -0,0 +1,111 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* polkit-tqt-listener based on code by David Zeuthen <davidz@redhat.com>
*/
#include "polkit-tqt-listener.h"
#include <stdio.h>
using namespace PolkitTQt::Agent;
struct _PolkitTQtListener
{
PolkitAgentListener parent_instance;
};
struct _PolkitTQtListenerClass
{
PolkitAgentListenerClass parent_class;
};
static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *agent_listener,
const gchar *action_id, const gchar *message, const gchar *icon_name,
PolkitDetails *details, const gchar *cookie, GList *identities,
GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data);
static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res, GError **error);
G_DEFINE_TYPE(PolkitTQtListener, polkit_tqt_listener, POLKIT_AGENT_TYPE_LISTENER);
static void polkit_tqt_listener_init(PolkitTQtListener *listener)
{
}
static void polkit_tqt_listener_finalize(GObject *object)
{
PolkitTQtListener *listener = POLKIT_TQT_LISTENER(object);
if (G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize != NULL)
{
G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize(object);
}
}
static void polkit_tqt_listener_class_init(PolkitTQtListenerClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
PolkitAgentListenerClass *listener_class = POLKIT_AGENT_LISTENER_CLASS(klass);
gobject_class->finalize = polkit_tqt_listener_finalize;
listener_class->initiate_authentication = polkit_tqt_listener_initiate_authentication;
listener_class->initiate_authentication_finish = polkit_tqt_listener_initiate_authentication_finish;
}
PolkitAgentListener *polkit_tqt_listener_new(void)
{
return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_TQT_TYPE_LISTENER, NULL));
}
static void cancelled_cb(GCancellable *cancellable, gpointer user_data)
{
ListenerAdapter::instance()->cancelled_cb((PolkitAgentListener *)user_data);
}
static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *agent_listener,
const gchar *action_id, const gchar *message, const gchar *icon_name,
PolkitDetails *details, const gchar *cookie, GList *identities,
GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data)
{
tqDebug("Listener adapter polkit_tqt_listener_initiate_authentication");
PolkitTQtListener *listener = POLKIT_TQT_LISTENER(agent_listener);
// The result of asynchronous method will be created here and it will be pushed to the listener.
GSimpleAsyncResult *result = g_simple_async_result_new((GObject*)listener, callback, user_data,
agent_listener);
tqDebug("GSimpleAsyncResult: %p", result);
ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener,
action_id, message, icon_name, details, cookie, identities, cancellable, result);
if (cancellable != NULL)
{
g_signal_connect(cancellable, "cancelled", G_CALLBACK(cancelled_cb), agent_listener);
}
}
static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res, GError **error)
{
tqDebug("Listener adapter polkit_tqt_listener_initiate_authentication_finish");
return ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication_finish(listener,
res, error);
}

@ -20,23 +20,28 @@
* polkit-tqt-listener based on code by David Zeuthen <davidz@redhat.com>
*/
#ifndef POLKITTQT_LISTENER_P_H
#define POLKITTQT_LISTENER_P_H
#ifndef POLKIT_TQT_LISTENER_P_H
#define POLKIT_TQT_LISTENER_P_H
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
#include "listeneradapter_p.h"
#include "listeneradapter.h"
#include <polkitagent/polkitagent.h>
G_BEGIN_DECLS
#define POLKIT_TQT_TYPE_LISTENER (polkit_tqt_listener_get_type())
#define POLKIT_TQT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListener))
#define POLKIT_TQT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass))
#define POLKIT_TQT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass))
#define POLKIT_TQT_IS_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_TQT_TYPE_LISTENER))
#define POLKIT_TQT_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_TQT_TYPE_LISTENER))
#define POLKIT_TQT_LISTENER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), \
POLKIT_TQT_TYPE_LISTENER, PolkitTQtListener))
#define POLKIT_TQT_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), \
POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass))
#define POLKIT_TQT_LISTENER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
POLKIT_TQT_TYPE_LISTENER, PolkitTQtListenerClass))
#define POLKIT_TQT_IS_LISTENER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
POLKIT_TQT_TYPE_LISTENER))
#define POLKIT_TQT_IS_LISTENER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), \
POLKIT_TQT_TYPE_LISTENER))
typedef struct _PolkitTQtListener PolkitTQtListener;
typedef struct _PolkitTQtListenerClass PolkitTQtListenerClass;
@ -46,4 +51,5 @@ PolkitAgentListener *polkit_tqt_listener_new(void);
G_END_DECLS
#endif /* POLKIT_TQT_LISTENER_H */
#endif

@ -1,124 +0,0 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "polkittqt1-agent-listener.h"
#include <TQtCore/TQDebug>
#include "polkittqtlistener_p.h"
#include "polkittqt1-authority.h"
#include "polkittqt1-subject.h"
#include "polkittqt1-identity.h"
#include "polkittqt1-details.h"
namespace PolkitTQt
{
namespace Agent
{
class ListenerPrivate
{
public:
PolkitAgentListener *listener;
#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE
void *registeredHandle;
#endif
};
Listener::Listener(TQObject *parent)
: TQObject(parent), d(new ListenerPrivate)
{
g_type_init();
d->listener = polkit_tqt_listener_new();
tqDebug() << "New PolkitAgentListener " << d->listener;
ListenerAdapter::instance()->addListener(this);
}
Listener::Listener(PolkitAgentListener *listener, TQObject *parent)
: TQObject(parent), d(new ListenerPrivate)
{
g_type_init();
d->listener = listener;
}
Listener::~Listener()
{
tqDebug("Destroying listener");
ListenerAdapter::instance()->removeListener(this);
#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE
if (d->registeredHandle) {
polkit_agent_listener_unregister(d->registeredHandle);
}
#endif
if (d->listener != NULL) {
g_object_unref(d->listener);
}
}
bool Listener::registerListener(const PolkitTQt::Subject &subject, const TQString &objectPath)
{
GError *error = NULL;
#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE
d->registeredHandle = polkit_agent_listener_register(d->listener,
POLKIT_AGENT_REGISTER_FLAGS_NONE,
#else
bool r = polkit_agent_register_listener(d->listener,
#endif
subject.subject(),
objectPath.toAscii().data(),
#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE
NULL,
#endif
&error);
if (error != NULL) {
tqWarning() << TQString("Cannot register authentication agent: %1").arg(error->message);
g_error_free(error);
return false;
}
#ifndef POLKIT_TQT_1_COMPATIBILITY_MODE
if (d->registeredHandle == NULL) {
tqWarning() << TQString("Cannot register authentication agent!");
return false;
}
return true;
#else
return r;
#endif
}
const PolkitAgentListener *Listener::listener()
{
return d->listener;
}
}
}
#include "polkittqt1-agent-listener.moc"

@ -1,169 +0,0 @@
/*
* This file is part of the PolKit1-tqt project
* Copyright (C) 2009 Radek Novacek <rnovacek@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "polkittqt1-agent-session.h"
#include <TQtCore/TQDebug>
#include "polkittqt1-identity.h"
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
#include <polkitagent/polkitagent.h>
using namespace PolkitTQt::Agent;
class Session::Private
{
public:
Private() {}
~Private();
static void completed(PolkitAgentSession *s, gboolean gained_authorization, gpointer user_data);
static void request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data);
static void showError(PolkitAgentSession *s, gchar *text, gpointer user_data);
static void showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data);
AsyncResult *result;
PolkitAgentSession *polkitAgentSession;
};
Session::Private::~Private()
{
// polkitAgentSession is freed in Session d'tor
}
Session::Session(const PolkitTQt::Identity &identity, const TQString &cookie, AsyncResult *result, TQObject *parent)
: TQObject(parent)
, d(new Private)
{
d->result = result;
d->polkitAgentSession = polkit_agent_session_new(identity.identity(), cookie.toUtf8().data());
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::Session(PolkitAgentSession *pkAgentSession, TQObject *parent)
: TQObject(parent)
, d(new Private)
{
d->polkitAgentSession = pkAgentSession;
g_signal_connect(G_OBJECT(d->polkitAgentSession), "completed", G_CALLBACK(Private::completed), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "request", G_CALLBACK(Private::request), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-error", G_CALLBACK(Private::showError), this);
g_signal_connect(G_OBJECT(d->polkitAgentSession), "show-info", G_CALLBACK(Private::showInfo), this);
}
Session::~Session()
{
if (d->polkitAgentSession)
g_object_unref(d->polkitAgentSession);
delete d;
}
void Session::initiate()
{
polkit_agent_session_initiate(d->polkitAgentSession);
}
void Session::setResponse(const TQString &response)
{
polkit_agent_session_response(d->polkitAgentSession, response.toUtf8().data());
}
void Session::cancel()
{
polkit_agent_session_cancel(d->polkitAgentSession);
}
AsyncResult *Session::result()
{
return d->result;
}
void Session::Private::completed(PolkitAgentSession *s, gboolean gained_authorization, gpointer user_data)
{
tqDebug() << "COMPLETED";
Session *session = (Session *)user_data;
TQ_EMIT(session)->completed(gained_authorization);
//free session here as polkit documentation asks
g_object_unref(session->d->polkitAgentSession);
session->d->polkitAgentSession = 0;
}
void Session::Private::request(PolkitAgentSession *s, gchar *request, gboolean echo_on, gpointer user_data)
{
tqDebug() << "REQUEST";
TQ_EMIT((Session *)user_data)->request(TQString::fromUtf8(request), echo_on);
}
void Session::Private::showError(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
tqDebug() << "showError";
TQ_EMIT((Session *)user_data)->showError(TQString::fromUtf8(text));
}
void Session::Private::showInfo(PolkitAgentSession *s, gchar *text, gpointer user_data)
{
tqDebug() << "showInfo";
TQ_EMIT((Session *)user_data)->showInfo(TQString::fromUtf8(text));
}
//
class AsyncResult::Private
{
public:
Private(GSimpleAsyncResult *r) : result(r) {};
GSimpleAsyncResult *result;
};
AsyncResult::AsyncResult(GSimpleAsyncResult *result)
: d(new Private(result))
{
}
AsyncResult::~AsyncResult()
{
if (d->result)
g_object_unref(d->result);
}
void AsyncResult::setCompleted()
{
if (d->result == NULL)
return;
g_simple_async_result_complete(d->result);
// Assure that completed won't be called twice
g_object_unref(d->result);
d->result = NULL;
}
void AsyncResult::setError(const TQString &text)
{
Q_ASSERT(d->result);
g_simple_async_result_set_error(d->result, POLKIT_ERROR, POLKIT_ERROR_FAILED, "%s", text.toUtf8().data());
}
#include "polkittqt1-agent-session.moc"

@ -1,150 +0,0 @@
/*
* This file is part of the Polkit-tqt project
* Copyright (C) 2009 Jaroslav Reznik <jreznik@redhat.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
* polkit-tqt-listener based on code by David Zeuthen <davidz@redhat.com>
*/
#include "polkittqtlistener_p.h"
#include <stdio.h>
#include <TQtCore/TQDebug>
#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE 1
using namespace PolkitTQt::Agent;
/**
* \internal
*/
struct _PolkitTQtListener {
PolkitAgentListener parent_instance;
};
/**
* \internal
*/
struct _PolkitTQtListenerClass {
PolkitAgentListenerClass parent_class;
};
static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error);
G_DEFINE_TYPE(PolkitTQtListener, polkit_tqt_listener, POLKIT_AGENT_TYPE_LISTENER);
static void polkit_tqt_listener_init(PolkitTQtListener *listener)
{
g_type_init();
}
static void polkit_tqt_listener_finalize(GObject *object)
{
PolkitTQtListener *listener;
listener = POLKIT_TQT_LISTENER(object);
if (G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize != NULL) {
G_OBJECT_CLASS(polkit_tqt_listener_parent_class)->finalize(object);
}
}
static void polkit_tqt_listener_class_init(PolkitTQtListenerClass *klass)
{
GObjectClass *gobject_class;
PolkitAgentListenerClass *listener_class;
gobject_class = G_OBJECT_CLASS(klass);
listener_class = POLKIT_AGENT_LISTENER_CLASS(klass);
gobject_class->finalize = polkit_tqt_listener_finalize;
listener_class->initiate_authentication = polkit_tqt_listener_initiate_authentication;
listener_class->initiate_authentication_finish = polkit_tqt_listener_initiate_authentication_finish;
}
PolkitAgentListener *polkit_tqt_listener_new(void)
{
return POLKIT_AGENT_LISTENER(g_object_new(POLKIT_TQT_TYPE_LISTENER, NULL));
}
static void cancelled_cb(GCancellable *cancellable, gpointer user_data)
{
ListenerAdapter::instance()->cancelled_cb((PolkitAgentListener *)user_data);
}
static void polkit_tqt_listener_initiate_authentication(PolkitAgentListener *agent_listener,
const gchar *action_id,
const gchar *message,
const gchar *icon_name,
PolkitDetails *details,
const gchar *cookie,
GList *identities,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
tqDebug() << "Listener adapter polkit_tqt_listener_initiate_authentication";
PolkitTQtListener *listener = POLKIT_TQT_LISTENER(agent_listener);
// The result of asynchronous method will be created here and it will be pushed to the listener.
GSimpleAsyncResult *result = g_simple_async_result_new((GObject *) listener, callback, user_data, agent_listener);
tqDebug() << "GSimpleAsyncResult:" << result;
ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication(agent_listener,
action_id,
message,
icon_name,
details,
cookie,
identities,
cancellable,
result);
if (cancellable != NULL) {
g_signal_connect(cancellable,
"cancelled",
G_CALLBACK(cancelled_cb),
agent_listener);
}
}
static gboolean polkit_tqt_listener_initiate_authentication_finish(PolkitAgentListener *listener,
GAsyncResult *res,
GError **error)
{
tqDebug() << "Listener adapter polkit_tqt_listener_initiate_authentication_finish";
return ListenerAdapter::instance()->polkit_tqt_listener_initiate_authentication_finish(listener,
res,
error);
}

@ -14,7 +14,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${TQT_INCLUDE_DIRS}
${POLKIT_INCLUDE_DIRS}
${POLKIT_GOBJECT_INCLUDE_DIRS}
)
link_directories(
@ -25,7 +25,7 @@ link_directories(
##### install headers ###########################
install(
FILES
FILES
polkit-tqt-actiondescription.h
polkit-tqt-authority.h
polkit-tqt-details.h
@ -47,7 +47,7 @@ tde_add_library( polkit-tqt-core SHARED AUTOMOC
polkit-tqt-subject.cpp
polkit-tqt-temporaryauthorization.cpp
VERSION 0.0.0
LINK ${TQT_LIBRARIES} ${POLKIT_LIBRARIES}
LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES}
DESTINATION ${LIB_INSTALL_DIR}
)

@ -1,6 +1,6 @@
debian/tmp/usr/include/polkit-tqt/PolkitTQt/ActionDescription
#debian/tmp/usr/include/polkit-tqt/PolkitTQt/Agent/Listener
#debian/tmp/usr/include/polkit-tqt/PolkitTQt/Agent/Session
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Agent/Listener
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Agent/Session
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Authority
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Details
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Gui/Action
@ -10,8 +10,8 @@ debian/tmp/usr/include/polkit-tqt/PolkitTQt/Identity
debian/tmp/usr/include/polkit-tqt/PolkitTQt/Subject
debian/tmp/usr/include/polkit-tqt/PolkitTQt/TemporaryAuthorization
debian/tmp/usr/include/polkit-tqt/polkit-tqt-actiondescription.h
#debian/tmp/usr/include/polkit-tqt/polkit-tqt-agent-listener.h
#debian/tmp/usr/include/polkit-tqt/polkit-tqt-agent-session.h
debian/tmp/usr/include/polkit-tqt/polkit-tqt-agent-listener.h
debian/tmp/usr/include/polkit-tqt/polkit-tqt-agent-session.h
debian/tmp/usr/include/polkit-tqt/polkit-tqt-authority.h
debian/tmp/usr/include/polkit-tqt/polkit-tqt-details.h
debian/tmp/usr/include/polkit-tqt/polkit-tqt-export.h

@ -15,6 +15,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${TQT_INCLUDE_DIRS}
${POLKIT_GOBJECT_INCLUDE_DIRS}
)
link_directories(
@ -41,7 +42,7 @@ tde_add_library( polkit-tqt-gui SHARED AUTOMOC
polkit-tqt-gui-actionbutton.cpp
polkit-tqt-gui-actionbuttons.cpp
VERSION 0.0.0
LINK ${TQT_LIBRARIES} ${POLKIT_LIBRARIES} polkit-tqt-core-shared
LINK ${TQT_LIBRARIES} ${POLKIT_GOBJECT_LIBRARIES} polkit-tqt-core-shared
DESTINATION ${LIB_INSTALL_DIR}
)

@ -1 +1 @@
#include "../../polkittqt1-agent-listener.h"
#include "../../polkit-tqt-agent-listener.h"

@ -1 +1 @@
#include "../../polkittqt1-agent-session.h"
#include "../../polkit-tqt-agent-session.h"

Loading…
Cancel
Save