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

sessiondata.h

00001 /*
00002  * This file is part of signon
00003  *
00004  * Copyright (C) 2009-2010 Nokia Corporation.
00005  *
00006  * Contact: Alberto Mardegan <alberto.mardegan@nokia.com>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * version 2.1 as published by the Free Software Foundation.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00020  * 02110-1301 USA
00021  */
00032 #ifndef SESSIONDATA_H
00033 #define SESSIONDATA_H
00034 
00035 #include <QMap>
00036 #include <QString>
00037 #include <QStringList>
00038 #include <QVariant>
00039 
00040 #include <SignOn/libsignoncommon.h>
00041 
00042 namespace SignOn {
00043 
00052 #define SIGNON_SESSION_DECLARE_PROPERTY(type_, name_) \
00053           void set##name_(const type_ &value ) { m_data.insert(QLatin1String(#name_), value); } \
00054           type_ name_() const { return m_data.value(QLatin1String(#name_)).value<type_>(); }
00055 
00060 #define SSO_ACCESS_CONTROL_TOKENS QLatin1String("AccessControlTokens")
00061 
00070 enum SignonUiPolicy {
00071     DefaultPolicy = 0,          
00072     RequestPasswordPolicy,      
00073     NoUserInteractionPolicy,    
00074     ValidationPolicy,           
00077 };
00078 
00089 class SIGNON_EXPORT SessionData
00090 {
00091 public:
00098     SessionData(const QVariantMap &data = QVariantMap()) { m_data = data; }
00099 
00104     SessionData(const SessionData &other) { m_data = other.m_data; }
00105 
00111     SessionData &operator=(const SessionData &other) {
00112         m_data = other.m_data;
00113         return *this;
00114     }
00115 
00121     SessionData &operator+=(const SessionData &other) {
00122         m_data.unite(other.m_data);
00123         return *this;
00124     }
00125 
00130     const QStringList propertyNames() const {
00131         return m_data.keys();
00132     }
00133 
00140     const QVariant getProperty(const QString &propertyName) const {
00141         return m_data.value(propertyName, QVariant());
00142     }
00143 
00148     QStringList getAccessControlTokens() const {
00149         return getProperty(SSO_ACCESS_CONTROL_TOKENS).toStringList();
00150     }
00151 
00157     template <class T> T data() const {
00158         T dataImpl;
00159         dataImpl.m_data = m_data;
00160         return dataImpl;
00161     }
00162 
00168     SIGNON_SESSION_DECLARE_PROPERTY(QString, Secret)
00169 
00170     
00173     SIGNON_SESSION_DECLARE_PROPERTY(QString, UserName)
00174 
00179     SIGNON_SESSION_DECLARE_PROPERTY(QString, Realm)
00180 
00185     SIGNON_SESSION_DECLARE_PROPERTY(QString, NetworkProxy)
00186 
00192     SIGNON_SESSION_DECLARE_PROPERTY(int, UiPolicy)
00193 
00202     SIGNON_SESSION_DECLARE_PROPERTY(QString, Caption)
00203 
00209     SIGNON_SESSION_DECLARE_PROPERTY(quint32, NetworkTimeout)
00210 
00215     SIGNON_SESSION_DECLARE_PROPERTY(quint32, WindowId)
00216 
00224     SIGNON_SESSION_DECLARE_PROPERTY(bool, RenewToken)
00225 
00232     SIGNON_SESSION_DECLARE_PROPERTY(bool, KeepAlive)
00233 
00234 protected:
00235     QVariantMap m_data;
00236 };
00237 
00238 } //namespace SignOn
00239 
00240 Q_DECLARE_METATYPE(SignOn::SessionData)
00241 #endif // SESSIONDATA_H

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