qthighway/xqservice/src/xqaiwrequest.h
branchRCL_3
changeset 10 cd2778e5acfe
parent 9 5d007b20cfd0
child 11 19a54be74e5e
equal deleted inserted replaced
9:5d007b20cfd0 10:cd2778e5acfe
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 *
       
     5 * This program is free software: you can redistribute it and/or modify
       
     6 * it under the terms of the GNU Lesser General Public License as published by
       
     7 * the Free Software Foundation, version 2.1 of the License.
       
     8 * 
       
     9 * This program is distributed in the hope that it will be useful,
       
    10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 * GNU Lesser General Public License for more details.
       
    13 *
       
    14 * You should have received a copy of the GNU Lesser General Public License
       
    15 * along with this program.  If not, 
       
    16 * see "http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html/".
       
    17 *
       
    18 * Description:
       
    19 *
       
    20 */
       
    21 
       
    22 #ifndef XQAIWREQUEST_H_
       
    23 #define XQAIWREQUEST_H_
       
    24 
       
    25 #include <f32file.h>
       
    26 
       
    27 #include <xqaiwglobal.h>
       
    28 
       
    29 #include <QObject>
       
    30 #include <qglobal.h>
       
    31 
       
    32 #include <QList>
       
    33 #include <QStringList>
       
    34 #include <QVariant>
       
    35 #include <QAction>
       
    36 #include <QUrl>
       
    37 #include <QFile>
       
    38 #include <xqaiwinterfacedescriptor.h>
       
    39 #include <xqrequestinfo.h>
       
    40 #include <xqsharablefile.h>
       
    41 
       
    42 class XQAiwRequestDriver;
       
    43 
       
    44 class XQSERVICE_EXPORT XQAiwRequest : public QObject
       
    45     {
       
    46     Q_OBJECT
       
    47 
       
    48 public:
       
    49 
       
    50     XQAiwRequest(const XQAiwInterfaceDescriptor &descriptor, const QString &operation, bool embedded = true);
       
    51     XQAiwRequest(const QUrl &uri, const XQAiwInterfaceDescriptor &descriptor, const QString &operation);
       
    52     XQAiwRequest(const QFile &file, const XQAiwInterfaceDescriptor &descriptor, const QString &operation);
       
    53     XQAiwRequest(const XQSharableFile &file, const XQAiwInterfaceDescriptor &descriptor, const QString &operation);
       
    54     virtual ~XQAiwRequest();
       
    55 
       
    56 public slots:
       
    57     
       
    58     QAction *createAction();
       
    59     
       
    60     void setArguments(const QList<QVariant> &arguments);
       
    61 
       
    62     int lastError() const;
       
    63 
       
    64     const QString& lastErrorMessage() const;
       
    65 
       
    66     const XQAiwInterfaceDescriptor &descriptor() const;
       
    67 
       
    68     bool send();
       
    69     bool send(QVariant &returnValue);
       
    70 
       
    71     void setEmbedded(bool embedded);
       
    72     bool isEmbedded() const;
       
    73 
       
    74     void setOperation(const QString &operation);
       
    75     const QString &operation() const;
       
    76 
       
    77     void setSynchronous(bool synchronous);
       
    78     bool isSynchronous() const;
       
    79     
       
    80     void setBackground(bool background );
       
    81     bool isBackground() const;
       
    82 
       
    83     void setInfo(const XQRequestInfo &info);
       
    84     XQRequestInfo info() const;
       
    85 
       
    86     
       
    87 signals:
       
    88 
       
    89 /*!
       
    90     Emitted when the QAction attached to request has been triggered.
       
    91     Upon this signal is the latest time to call
       
    92     setArguments(const QList<QVariant> &arguments) if not done earlier.
       
    93 */
       
    94     void triggered();
       
    95     
       
    96 /*!
       
    97     This signal is emitted when interworking request has been successfully
       
    98     executed (synchronous or asynchronous). That is, the service has returned
       
    99     data back according to the slot spec. The return value may be real data
       
   100     or indicate an service specific error.
       
   101     \param result Result of the executed request
       
   102 */
       
   103     void requestOk(const QVariant& result);
       
   104     
       
   105 /*!
       
   106     This signal is emitted when an error has happened in interworking request
       
   107     handling. That is, e.g. the required slot could not be called or connection
       
   108     to server is lost. If the service itself return service specific errors,
       
   109     those should be returned as successfull return value of the slot
       
   110     (requestOk(const QVariant& result)).
       
   111     \param errorCode Error code as integer value
       
   112     \param errorMessage Contains needed R&D specific data that will be added to support error debugging
       
   113     \sa xqserviceglobal.h for error codes.
       
   114 */
       
   115     void requestError(int errorCode, const QString& errorMessage);
       
   116 
       
   117 protected:
       
   118     
       
   119     virtual const QVariant& results() const;
       
   120     virtual bool sendExecute();
       
   121     
       
   122 private slots:
       
   123 
       
   124    void handleAsyncResponse(const QVariant& value);
       
   125    void sendFromAction(bool checked);
       
   126    void handleAsyncError(int err);
       
   127     
       
   128 private:
       
   129 
       
   130     XQAiwRequestDriver* currentRequest;
       
   131     QString errorMsg;
       
   132     int errorCode;
       
   133     QVariant result;  // Client can use results whenever wants
       
   134     QList<QAction*> actionList;
       
   135     bool completeSignalConnected;
       
   136     bool errorSignalConnected;
       
   137     
       
   138     };
       
   139 
       
   140 #endif /* XQAIWREQUEST_H_ */