homescreensrv_plat/servicemodel_api/service.h
author hgs
Wed, 24 Mar 2010 13:06:03 +0200
changeset 90 0e41c72311af
parent 85 7feec50967db
permissions -rw-r--r--
201011_02
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
7feec50967db 201003_02
hgs
parents:
diff changeset
     1
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7feec50967db 201003_02
hgs
parents:
diff changeset
     3
* All rights reserved.
7feec50967db 201003_02
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
7feec50967db 201003_02
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
7feec50967db 201003_02
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
7feec50967db 201003_02
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
7feec50967db 201003_02
hgs
parents:
diff changeset
     8
*
7feec50967db 201003_02
hgs
parents:
diff changeset
     9
* Initial Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
7feec50967db 201003_02
hgs
parents:
diff changeset
    11
*
7feec50967db 201003_02
hgs
parents:
diff changeset
    12
* Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    13
*
7feec50967db 201003_02
hgs
parents:
diff changeset
    14
* Description:  
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
*
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
7feec50967db 201003_02
hgs
parents:
diff changeset
    18
7feec50967db 201003_02
hgs
parents:
diff changeset
    19
#ifndef SERVICE_H
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
#define SERVICE_H
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include "servicemodel_global.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
#include <QObject>
7feec50967db 201003_02
hgs
parents:
diff changeset
    24
#include <QVariant>
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
class ServiceParameters;
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
/**
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
 * @ingroup group_hsservicemodel group_service_api_candidates
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
 * @brief Base class for all the services. 
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
class HSSERVICEMODEL_EXPORT HsService : public QObject
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
{
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
	Q_OBJECT
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
	
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
public:
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
    * Constructor
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
    * @param aParent 
7feec50967db 201003_02
hgs
parents:
diff changeset
    41
    */
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
    HsService( QObject* aParent = 0 ) : QObject( aParent ) {}
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
	  
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
     * destructor
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
     * @since S60 ?S60_version.
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
    virtual ~HsService() {}
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
    
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
public:
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
     * Execute service command
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
     * @param aCommand service command 
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
     * @param aInParameters parameters. 
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
     * For example messaging service
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
     * needs to have at least the following pairs to send short message:
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
     * 'MessageType' - 'SMS'
7feec50967db 201003_02
hgs
parents:
diff changeset
    59
     * 'To' - 'phone number here'
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
     * 'BodyText' - 'this is text to be sent'
7feec50967db 201003_02
hgs
parents:
diff changeset
    61
     * So aInParameters should include QMap:
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
     * @code
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
     *   QMap<QString, QVariant> parameters;
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
     *   parameters["MessageType"]=QVariant(QString("SMS"));
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
     *   parameters["To"]=QVariant(QString("555555"));
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
     *   parameters["BodyText"]=QVariant(QString("this is bodytext"));
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
     *   QVariant inParameters;
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
     *   inParameters.setValue(parameters);
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
     * @endcode
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
    virtual void executeCommand(const QByteArray &aCommand, const QVariant &aInParameters) = 0;
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
    
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
    * Cancels ALL then pending commands.
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
    */
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
    virtual void cancelCommands() = 0;
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
    
7feec50967db 201003_02
hgs
parents:
diff changeset
    78
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
     * Get data after dataReceived signal has been received.
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
     * 
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
     * @param aData data buffer to be filled
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
     * TODO: error?
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
    virtual void getData(QVariant &aData) = 0;
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
        
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
signals:
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
     * Signal emitted when data is received, client can then make query for the received data using getData function.
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    91
    void dataReceived();
7feec50967db 201003_02
hgs
parents:
diff changeset
    92
    
7feec50967db 201003_02
hgs
parents:
diff changeset
    93
    /**
7feec50967db 201003_02
hgs
parents:
diff changeset
    94
     * Signal emitted when data is received
7feec50967db 201003_02
hgs
parents:
diff changeset
    95
     * @param aData (QMap<QString, QVariant>) data received from the service 
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
     */
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
    void dataReceived(const QVariant &aData);
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
    	    
7feec50967db 201003_02
hgs
parents:
diff changeset
    99
};
7feec50967db 201003_02
hgs
parents:
diff changeset
   100
7feec50967db 201003_02
hgs
parents:
diff changeset
   101
#endif