bluetoothengine/btnotif/btnotifsrv/inc/bluetoothnotification.h
changeset 19 43824b19ee35
child 31 a0ea99b6fa53
equal deleted inserted replaced
17:f05641c183ff 19:43824b19ee35
       
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : bluetoothnotification.h
       
     4 *  Part of     : bluetoothengine / btnotif
       
     5 *  Description : Class for managing an actual user notification or query.
       
     6 *                It hides UI framework-specifics in a private class.
       
     7 *
       
     8 *  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     9 *  All rights reserved.
       
    10 *  This component and the accompanying materials are made available
       
    11 *  under the terms of "Eclipse Public License v1.0"
       
    12 *  which accompanies this distribution, and is available
       
    13 *  at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    14 *
       
    15 *  Initial Contributors:
       
    16 *  Nokia Corporation - initial contribution.
       
    17 *
       
    18 *  Contributors:
       
    19 *  Nokia Corporation
       
    20 * ============================================================================
       
    21 * Template version: 4.2
       
    22 */
       
    23 
       
    24 #ifndef BLUETOOTHNOTIFICATION_H
       
    25 #define BLUETOOTHNOTIFICATION_H
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <hb/hbcore/hbdevicedialogsymbian.h>
       
    29 #include "bluetoothdevicedialogs.h"
       
    30 #include "btnotificationresult.h"
       
    31 #include "bluetoothtrace.h"
       
    32 
       
    33 class CBTNotificationManager;
       
    34 class CHbSymbianVariantMap;
       
    35 
       
    36 /**
       
    37  *  CBluetoothNotification manages and controls notifications.
       
    38  *  
       
    39  *  @since Symbian^4
       
    40  */
       
    41 NONSHARABLE_CLASS( CBluetoothNotification ) : public CBase,
       
    42                                               public MHbDeviceDialogObserver
       
    43     {
       
    44 
       
    45 
       
    46 public:
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      * @param aManager Reference to the notification manager.
       
    51      * @param aObserver Reference to our observer.
       
    52      */
       
    53     static CBluetoothNotification* NewL( CBTNotificationManager* aManager );
       
    54 
       
    55     /**
       
    56     * Destructor.
       
    57     */
       
    58     virtual ~CBluetoothNotification();
       
    59 
       
    60     /**
       
    61      * Sets the receiver of callbacks.
       
    62      *
       
    63      * @since Symbian^4
       
    64      * @param aObserver Pointer to the callback interface.
       
    65      */
       
    66     inline void SetObserver( MBTNotificationResult* aObserver )
       
    67         { iObserver = aObserver; }
       
    68 
       
    69     /**
       
    70      * Clears the receiver of callbacks.
       
    71      *
       
    72      * @since Symbian^4
       
    73      */
       
    74     inline void RemoveObserver()
       
    75         { iObserver = NULL; }
       
    76 
       
    77     /**
       
    78      * Reset the notification.
       
    79      *
       
    80      * @since Symbian^4
       
    81      */
       
    82     void Reset();
       
    83 
       
    84     /**
       
    85      * Getter for the notification type.
       
    86      *
       
    87      * @since Symbian^4
       
    88      * @return Notification type.
       
    89      */
       
    90     inline TBluetoothDialogParams::TBTDialogType NotificationType()
       
    91         { return iType; }
       
    92 
       
    93     /**
       
    94      * Getter for the resource id.
       
    95      *
       
    96      * @since Symbian^4
       
    97      * @return Resource identifier.
       
    98      */
       
    99     inline TBTDialogResourceId ResourceId()
       
   100         { return iResourceId; }
       
   101 
       
   102     inline CHbSymbianVariantMap* Data()
       
   103          { return iNotificationData; }
       
   104     
       
   105     /**
       
   106      * Sets the type of notification (query, note, etc).
       
   107      *
       
   108      * @since Symbian^4
       
   109      * @param aType The type of the notification.
       
   110      * @param aResourceId The id of the resource to be shown.
       
   111      * @return Error code
       
   112      */
       
   113     inline void SetNotificationType( TBluetoothDialogParams::TBTDialogType aType,
       
   114                 TBTDialogResourceId aResourceId )
       
   115             { iType = aType; iResourceId = aResourceId; }
       
   116 
       
   117     /**
       
   118      * Sets the data to be shown to the user.
       
   119      *
       
   120      * @since Symbian^4
       
   121      * @param aType Identifies the type of data parameter to be set.
       
   122      * @param aData Additional descriptor data to be shown in the dialog.
       
   123      * @return Error code
       
   124      */
       
   125     TInt SetData( TInt aDataType, const TDesC& aData );
       
   126 
       
   127     /**
       
   128      * Sets the data to be shown to the user.
       
   129      *
       
   130      * @since Symbian^4
       
   131      * @param aType Identifies the type of data parameter to be set.
       
   132      * @param aData Additional integer data to be shown in the dialog.
       
   133      * @return Error code
       
   134      */
       
   135     TInt SetData( TInt aDataType, TInt aData );
       
   136 
       
   137     /**
       
   138      * Updates the data to be shown to the user.
       
   139      *
       
   140      * @since Symbian^4
       
   141      * @param ?arg1 ?description
       
   142      * @return Error code
       
   143      */
       
   144     TInt Update( const TDesC& aData =KNullDesC );
       
   145 
       
   146     /**
       
   147      * Show the notification, which means that it 
       
   148      * is added to the queue.
       
   149      *
       
   150      * @since Symbian^4
       
   151      * @param ?arg1 ?description
       
   152      * @return Error code
       
   153      */
       
   154     TInt Show();
       
   155 
       
   156     /**
       
   157      * Stop showing the notification.
       
   158      *
       
   159      * @since Symbian^4
       
   160      * @param ?arg1 ?description
       
   161      * @return Error code
       
   162      */
       
   163     TInt Close();
       
   164 
       
   165 
       
   166 private:
       
   167 
       
   168     CBluetoothNotification( CBTNotificationManager* aManager );
       
   169 
       
   170     void ConstructL();
       
   171     
       
   172     /**
       
   173      * Sets the data to be shown to the user, leaves on error.
       
   174      *
       
   175      * @since Symbian^4
       
   176      * @param aType Identifies the type of data parameter to be set.
       
   177      * @param aData Additional descriptor data to be shown in the dialog.
       
   178      */
       
   179     void SetDataL( TInt aType, const TDesC& aData );
       
   180 
       
   181     /**
       
   182      * Sets the data to be shown to the user, leaves on error.
       
   183      *
       
   184      * @since Symbian^4
       
   185      * @param aType Identifies the type of data parameter to be set.
       
   186      * @param aData Additional integer data to be shown in the dialog.
       
   187      */
       
   188     void SetDataL( TInt aType, TInt aData );
       
   189     
       
   190     /**
       
   191      * From MHbDeviceDialogObserver.
       
   192      * This callback is called when data is received from a device dialog.
       
   193      *
       
   194      * @since Symbian^4
       
   195      * @param aData contains data from the dialog plugin.
       
   196      */
       
   197     virtual void DataReceived( CHbSymbianVariantMap& aData );
       
   198 
       
   199     /**
       
   200      * From MHbDeviceDialogObserver.
       
   201      * This callback is called when a device dialog is closed. Any data sent by
       
   202      * the dialog is indicated by the dataReceived() callback. If no observer is
       
   203      * set in CHbDeviceDialog::Show the latest data can be retrieved with
       
   204      * CHbDeviceDialog::receivedData().
       
   205      *
       
   206      * @since Symbian^4
       
   207      * @param aCompletionCode gives the result of the dialog completion. Code can be
       
   208      *                        either Symbian error code or device dialog error code.
       
   209      */
       
   210     virtual void DeviceDialogClosed( TInt aCompletionCode );
       
   211 
       
   212 #ifdef BLUETOOTHTRACE_ENABLED
       
   213     void debugHbSymbianVariantMap( CHbSymbianVariantMap& aData);
       
   214 #endif // BLUETOOTHTRACE_ENABLED
       
   215 
       
   216 private: // data
       
   217 
       
   218     /**
       
   219      * The type of notification currently showing.
       
   220      */
       
   221     TBluetoothDialogParams::TBTDialogType iType;
       
   222 
       
   223     /**
       
   224      * The id of the resource (string identifier)
       
   225      * of the currently showing notification.
       
   226      */
       
   227     TBTDialogResourceId iResourceId;
       
   228 
       
   229     /**
       
   230      * Reference to the queue manager.
       
   231      * Not own.
       
   232      */
       
   233     CBTNotificationManager* iManager;
       
   234 
       
   235     /**
       
   236      * Reference to the receiver of the results.
       
   237      * Not own.
       
   238      */
       
   239     MBTNotificationResult* iObserver;
       
   240     
       
   241     /**
       
   242      * The data to be shown to the user in a device dialog.
       
   243      * Own.
       
   244      */
       
   245     CHbSymbianVariantMap* iNotificationData;
       
   246 
       
   247     /**
       
   248      * Buffer for receiving return data from the notifier.
       
   249      */
       
   250     CHbSymbianVariantMap* iReturnData;
       
   251 
       
   252     /**
       
   253      * Session object with the notification server.
       
   254      * Own.
       
   255      */
       
   256     CHbDeviceDialogSymbian *iDialog;
       
   257     
       
   258     BTUNITTESTHOOK
       
   259 
       
   260     };
       
   261 
       
   262 #endif // BLUETOOTHNOTIFICATION_H