• Main Page
  • Related Pages
  • Classes
  • Files
  • File List

dbusoperationqueuehandler.h

00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  *
00006  * Contact: Aurel Popirtac <ext-aurel.popirtac@nokia.com>
00007  * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public License
00011  * version 2.1 as published by the Free Software Foundation.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  */
00023 
00024 #ifndef DBUSOPERATIONQUEUEHANDLER_H
00025 #define DBUSOPERATIONQUEUEHANDLER_H
00026 
00027 #include <QQueue>
00028 #include <QDBusInterface>
00029 
00030 
00031 #define SIGNOND_NORMALIZE_METHOD_SIGNATURE(method) \
00032     DBusOperationQueueHandler::normalizedOperationSignature(method).data()
00033 
00034 /*
00035  * @cond IMPL
00036  */
00037 namespace SignOn {
00038 
00039     class DBusOperationQueueHandler
00040     {
00041     public:
00042         struct Operation
00043         {
00044             Operation(const char *name,
00045                       QList<QGenericArgument *> args = QList<QGenericArgument *>());
00046             ~Operation();
00047 
00048             inline bool operator==(const Operation &op) const
00049                 { return QLatin1String(op.m_name) == m_name; }
00050 
00051             char *m_name;
00052             QList<QGenericArgument *> m_args;
00053 
00054         private:
00055             void copy(const char *name,
00056                       const QList<QGenericArgument *> &args);
00057         };
00058 
00059     public:
00060         DBusOperationQueueHandler(QObject *clientObject);
00061         ~DBusOperationQueueHandler();
00062 
00063         void enqueueOperation(Operation *operation);
00064         void enqueueOperation(const char *name,
00065                               QList<QGenericArgument *> args = QList<QGenericArgument *>());
00066 
00067         void execQueuedOperations();
00068         int queuedOperationsCount() const
00069             { return m_operationsQueue.count(); }
00070         void clearOperationsQueue()
00071             { m_operationsQueue.clear(); }
00072 
00073         void removeOperation(const char *name, bool removeAll = true);
00074 
00075         bool queueContainsOperation(const char *name);
00076         void stopOperationsProcessing()
00077         { m_operationsStopped = true; }
00078 
00079         static QByteArray normalizedOperationSignature(const char *operationName)
00080             { return QMetaObject::normalizedSignature(operationName); }
00081 
00082     private:
00083         QObject *m_clientObject;
00084         const int m_maxNumberOfOperationParameters;
00085         QQueue<Operation *> m_operationsQueue;
00086         bool m_operationsStopped;
00087     };
00088 
00089 } //SignOn
00090 
00091 /*
00092  * @endcond IMPL
00093  */
00094 
00095 #endif // DBUSOPERATIONQUEUEHANDLER_H

Generated on Wed Jul 13 2011 22:08:28 by  doxygen 1.7.1