qthighway/xqserviceutil/src/xqrequestinfo.cpp
changeset 24 9d760f716ca8
parent 4 90517678cc4f
equal deleted inserted replaced
19:46686fb6258c 24:9d760f716ca8
    21 
    21 
    22 #include "xqservicelog.h"
    22 #include "xqservicelog.h"
    23 #include "xqrequestinfo.h"
    23 #include "xqrequestinfo.h"
    24 #include "xqrequestutil.h"
    24 #include "xqrequestutil.h"
    25 
    25 
       
    26 /*!
       
    27     \class XQRequestInfo
       
    28     \inpublicgroup QtBaseModule
       
    29 
       
    30     \ingroup ipc
       
    31     \brief The XQRequestInfo class encapsulates additional information of a service request
       
    32     
       
    33     The XQRequestInfo class encapsulates additional information of a service request:
       
    34     - For service provider it contains additional information of the service request, some set by the client, some set by the QtHighway framework.
       
    35     - For client it gives possibility to add UI oriented options of the request
       
    36     The XQRequestInfo is exported by the xqserviceutil library
       
    37 */
       
    38 
       
    39 /*!
       
    40     Constructor.
       
    41 */
    26 XQRequestInfo::XQRequestInfo()
    42 XQRequestInfo::XQRequestInfo()
    27 {
    43 {
    28     XQSERVICE_DEBUG_PRINT("XQRequestInfo::XQRequestInfo");
    44     XQSERVICE_DEBUG_PRINT("XQRequestInfo::XQRequestInfo");
    29 }
    45 }
    30 
    46 
       
    47 /*!
       
    48     Destructor.
       
    49 */
    31 XQRequestInfo::~XQRequestInfo()
    50 XQRequestInfo::~XQRequestInfo()
    32 {
    51 {
    33     XQSERVICE_DEBUG_PRINT("XQRequestInfo::~XQRequestInfo");
    52     XQSERVICE_DEBUG_PRINT("XQRequestInfo::~XQRequestInfo");
    34 }
    53 }
    35 
    54 
       
    55 /*!
       
    56     Requests service application to be launched as embedded mode.
       
    57     \param on Set to true to turn embedded mode on.
       
    58 */
    36 void XQRequestInfo::setEmbedded(bool on)
    59 void XQRequestInfo::setEmbedded(bool on)
    37 {
    60 {
    38     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setEmbedded %d", on);
    61     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setEmbedded %d", on);
    39     setInfo(XQServiceUtils::OptEmbedded, on);
    62     setInfo(XQServiceUtils::OptEmbedded, on);
    40 }
    63 }
    41 
    64 
       
    65 /*!
       
    66     Get embedded option value.
       
    67     \return True if embedded mode is turned on, false otherwise.
       
    68 */
    42 bool XQRequestInfo::isEmbedded() const
    69 bool XQRequestInfo::isEmbedded() const
    43 {
    70 {
    44     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isEmbedded");
    71     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isEmbedded");
    45     return info(XQServiceUtils::OptEmbedded).toBool();
    72     return info(XQServiceUtils::OptEmbedded).toBool();
    46 }
    73 }
    47 
    74 
       
    75 /*!
       
    76     Requests service application to be set to background before a slot call to service provider. 
       
    77     If this option is set to false or not set, the QtHighway does not alter the Z-order.
       
    78     \param on Set to true if service application should be launched to background.
       
    79 */
    48 void XQRequestInfo::setBackground(bool on)
    80 void XQRequestInfo::setBackground(bool on)
    49 {
    81 {
    50     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setBackground %d", on);
    82     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setBackground %d", on);
    51     setInfo(XQServiceUtils::OptBackground, on);
    83     setInfo(XQServiceUtils::OptBackground, on);
    52 }
    84 }
    53 
    85 
       
    86 /*!
       
    87     Get the value of the background option.
       
    88     \return True if option has been set on, false otherwise.
       
    89 */
    54 bool XQRequestInfo::isBackground() const
    90 bool XQRequestInfo::isBackground() const
    55 {
    91 {
    56     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isBackground");
    92     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isBackground");
    57     return info(XQServiceUtils::OptBackground).toBool();
    93     return info(XQServiceUtils::OptBackground).toBool();
    58 }
    94 }
    59 
    95 
       
    96 /*!
       
    97     Requests service application to be brought to foreground before a slot call to service provider.
       
    98     If this option is false or not set, the QtHighway does not alter the Z-order.
       
    99     \param on Set to true if service application should be launched to foreground.
       
   100 */
    60 void XQRequestInfo::setForeground(bool on)
   101 void XQRequestInfo::setForeground(bool on)
    61 {
   102 {
    62     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setForeground %d", on);
   103     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setForeground %d", on);
    63     setInfo(XQServiceUtils::OptForeground, on);
   104     setInfo(XQServiceUtils::OptForeground, on);
    64 }
   105 }
    65 
   106 
       
   107 /*!
       
   108     Get the value of the foreground option.
       
   109     \return True if option has been set on, false otherwise.
       
   110 */
    66 bool XQRequestInfo::isForeground() const
   111 bool XQRequestInfo::isForeground() const
    67 {
   112 {
    68     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isForeground");
   113     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isForeground");
    69     return info(XQServiceUtils::OptForeground).toBool();
   114     return info(XQServiceUtils::OptForeground).toBool();
    70 }
   115 }
    71 
   116 
    72 
   117 /*!
       
   118     Gets the vaule of the synchronous option.
       
   119     \return True if request is synchronous , false if asynchronous.
       
   120 */
    73 bool XQRequestInfo::isSynchronous() const
   121 bool XQRequestInfo::isSynchronous() const
    74 {
   122 {
    75     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isSynchronous");
   123     XQSERVICE_DEBUG_PRINT("XQRequestInfo::isSynchronous");
    76     return info(XQServiceUtils::OptSynchronous).toBool();
   124     return info(XQServiceUtils::OptSynchronous).toBool();
    77 }
   125 }
    78 
   126 
    79 
   127 /*!
       
   128     Gets the client's secure id option. Valid only for service provider.
       
   129     \return Calling client's secure ID as defined by the Symbian OS platform security model.
       
   130 */
    80 quint32 XQRequestInfo::clientSecureId() const
   131 quint32 XQRequestInfo::clientSecureId() const
    81 {
   132 {
    82     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientSecureId");
   133     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientSecureId");
    83     bool b=false;
   134     bool b=false;
    84     quint32 id = info(XQServiceUtils::InfoSID).toUInt(&b);
   135     quint32 id = info(XQServiceUtils::InfoSID).toUInt(&b);
    85     XQSERVICE_DEBUG_PRINT("\tSID status=%d", b);
   136     XQSERVICE_DEBUG_PRINT("\tSID status=%d", b);
    86     return id;
   137     return id;
    87 }
   138 }
    88 
   139 
       
   140 /*!
       
   141     Gets the clients's vendor id option. Valid only for service provider.
       
   142     \return Calling client's vendor ID as defined by the Symbian OS platform security model.
       
   143 */
    89 quint32 XQRequestInfo::clientVendorId() const
   144 quint32 XQRequestInfo::clientVendorId() const
    90 {
   145 {
    91     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientVendorId");
   146     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientVendorId");
    92     bool b=false;
   147     bool b=false;
    93     quint32 id = info(XQServiceUtils::InfoVID).toUInt(&b);
   148     quint32 id = info(XQServiceUtils::InfoVID).toUInt(&b);
    94     XQSERVICE_DEBUG_PRINT("\tVID status=%d", b);
   149     XQSERVICE_DEBUG_PRINT("\tVID status=%d", b);
    95     return id;
   150     return id;
    96 }
   151 }
    97 
   152 
       
   153 /*!
       
   154     Gets the client's capabilities. Valid only for service provider.
       
   155     \return Calling client's capabilities as defined by the Symbian OS platform security model. 
       
   156             The values in the QSet are compatible with the TCapability values in e32capability.h.
       
   157 */
    98 QSet<int> XQRequestInfo::clientCapabilities() const
   158 QSet<int> XQRequestInfo::clientCapabilities() const
    99 {
   159 {
   100     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientCapabilities");
   160     XQSERVICE_DEBUG_PRINT("XQRequestInfo::clientCapabilities");
   101     bool b=false;
   161     bool b=false;
   102     quint32 caps = info(XQServiceUtils::InfoCap).toUInt(&b);
   162     quint32 caps = info(XQServiceUtils::InfoCap).toUInt(&b);
   116     }
   176     }
   117     
   177     
   118     return ret;
   178     return ret;
   119 }
   179 }
   120 
   180 
   121 
   181 /*!
       
   182     Sets a \a value of the named info \a key. Key names starting with "XQ" are reserved for
       
   183     the QtHighway internal usage. If the service operation (message) does not accept
       
   184     these parameters already, the recommened way is to pass these in the XQRequestInfo
       
   185     and use the following pre-defined keys:
       
   186     - XQINFO_KEY_WINDOW_TITLE for passing the title string be shown in the service application
       
   187       window (QtHighway does not pick the Orbit window title automatically).
       
   188     - ViewName (QString) for passing the view to be activated in the service application.
       
   189     \param key Info key for which \a value will be set.
       
   190     \param value Value to be set to a \a key
       
   191 */
   122 void XQRequestInfo::setInfo(const QString &key, const QVariant &value)
   192 void XQRequestInfo::setInfo(const QString &key, const QVariant &value)
   123 {
   193 {
   124     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setInfo %s:%s,%s",
   194     XQSERVICE_DEBUG_PRINT("XQRequestInfo::setInfo %s:%s,%s",
   125         qPrintable(key), qPrintable(value.toString()), value.typeName());
   195         qPrintable(key), qPrintable(value.toString()), value.typeName());
   126     mInfo.insert(key, value);
   196     mInfo.insert(key, value);
   127 }
   197 }
   128 
   198 
       
   199 /*!
       
   200     Gets the set value of the \a key. The returned value may be invalid if not set.
       
   201     \param key Key name for which value is retrieved.
       
   202     \return Value set to the key, or invalid QVariant if not set.
       
   203 */
   129 QVariant XQRequestInfo::info(const QString &key) const
   204 QVariant XQRequestInfo::info(const QString &key) const
   130 {
   205 {
   131     XQSERVICE_DEBUG_PRINT("XQRequestInfo::info %s", qPrintable(key));
   206     XQSERVICE_DEBUG_PRINT("XQRequestInfo::info %s", qPrintable(key));
   132     QVariant v =  mInfo.value(key);
   207     QVariant v =  mInfo.value(key);
   133     XQSERVICE_DEBUG_PRINT("XQRequestInfo::info type=%s,valid=%d,str=%s", v.typeName(), v.isValid(), qPrintable(v.toString()));
   208     XQSERVICE_DEBUG_PRINT("XQRequestInfo::info type=%s,valid=%d,str=%s", v.typeName(), v.isValid(), qPrintable(v.toString()));
   134     return v;
   209     return v;
   135 }
   210 }
   136 
   211 
       
   212 /*!
       
   213     Gets the list of key names set for the object.
       
   214     \return List of key names set for the object.
       
   215 */
   137 QStringList XQRequestInfo::infoKeys() const
   216 QStringList XQRequestInfo::infoKeys() const
   138 {
   217 {
   139     XQSERVICE_DEBUG_PRINT("XQRequestInfo::infoKeys");
   218     XQSERVICE_DEBUG_PRINT("XQRequestInfo::infoKeys");
   140     return mInfo.keys();
   219     return mInfo.keys();
   141 }
   220 }
   142 
   221 
       
   222 /*!
       
   223     Gets the internal id of the current request. As there can be several
       
   224     requests ongoing to the same interface, this separates multiple requests.
       
   225     Once the request has been completed the ID becomes invalid.
       
   226     This is the same value as returned by the XQServiceProvider::setCurrentRequestAsync()
       
   227     to set response asynchronous.
       
   228     \return Id of the current request as integer value.
       
   229 */
   143 int XQRequestInfo::id() const
   230 int XQRequestInfo::id() const
   144 {
   231 {
   145     XQSERVICE_DEBUG_PRINT("XQRequestInfo::id");
   232     XQSERVICE_DEBUG_PRINT("XQRequestInfo::id");
   146     bool b=false;
   233     bool b=false;
   147     int id = info(XQServiceUtils::InfoId).toInt(&b);
   234     int id = info(XQServiceUtils::InfoId).toInt(&b);
   151         return -1;
   238         return -1;
   152     }
   239     }
   153     return id;
   240     return id;
   154 }
   241 }
   155 
   242 
       
   243 /*!
       
   244     Checks if object is valid.
       
   245     \return True if object is valid, false otherwise.
       
   246 */
   156 bool XQRequestInfo::isValid() const
   247 bool XQRequestInfo::isValid() const
   157 {
   248 {
   158     return !mInfo.isEmpty();
   249     return !mInfo.isEmpty();
   159 }
   250 }
   160 
   251 
       
   252 /*!
       
   253     Serializes this XQRequestInfo data into the given stream.
       
   254     \param s Stream the data is serialized into.
       
   255 */
   161 template <typename Stream> void XQRequestInfo::serialize(Stream &s) const
   256 template <typename Stream> void XQRequestInfo::serialize(Stream &s) const
   162 {
   257 {
   163     XQSERVICE_DEBUG_PRINT("XQRequestInfo::serialize");
   258     XQSERVICE_DEBUG_PRINT("XQRequestInfo::serialize");
   164     s << mInfo;
   259     s << mInfo;
   165 }
   260 }
   166 
   261 
       
   262 /*!
       
   263     Deserializes XQRequestInfo data from the given stream.
       
   264     \param s Stream the data is deserialized from.
       
   265 */
   167 template <typename Stream> void XQRequestInfo::deserialize(Stream &s)
   266 template <typename Stream> void XQRequestInfo::deserialize(Stream &s)
   168 {
   267 {
   169     XQSERVICE_DEBUG_PRINT("XQRequestInfo::de-serialize");
   268     XQSERVICE_DEBUG_PRINT("XQRequestInfo::de-serialize");
   170     s >> mInfo;
   269     s >> mInfo;
   171 }
   270 }