javauis/softnotification_akn/inc/CSoftNotification.h
branchRCL_3
changeset 19 04becd199f91
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Controls the native soft notifications.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CSOFTNOTIFICATION_H
       
    20 #define CSOFTNOTIFICATION_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32base.h>
       
    24 #include <AknDynamicSoftNotifier.h>
       
    25 #include <jutils.h>
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 class TAknDynamicSoftNotificationParams;
       
    29 class CSoftNotificationEventSource;
       
    30 class CSoftNotificationEvent;
       
    31 
       
    32 
       
    33 // CLASS DECLARATION
       
    34 /**
       
    35  *  Controls the native soft notifications.
       
    36  *  This class delegates method calls to AvKon soft notification.
       
    37  *
       
    38  *  @since 3.2
       
    39  */
       
    40 NONSHARABLE_CLASS(CSoftNotification) : public CBase,
       
    41         public MAknDynamicSoftNoteObserver
       
    42 {
       
    43 public:  // Constructors and destructor
       
    44 
       
    45     /**
       
    46      * Static constructor
       
    47      */
       
    48     static CSoftNotification* NewL(TInt aAppId,
       
    49     TInt aNotificationId,
       
    50     CSoftNotificationEventSource& aEventSource);
       
    51 
       
    52     /**
       
    53      * Destructor.
       
    54      */
       
    55     virtual ~CSoftNotification();
       
    56 
       
    57 public: // From MAknDynamicSoftNotifierObserver
       
    58 
       
    59     /**
       
    60      * Dynamic soft notification was accepted by user.
       
    61      *
       
    62      * @param aNoteId Identification of notification.
       
    63      */
       
    64     void NotificationAccepted(TInt aIdentifier);
       
    65 
       
    66     /**
       
    67      * Dynamic soft notification was canceled by user.
       
    68      *
       
    69      * @param aNoteId Identification of notification.
       
    70      */
       
    71     void NotificationCanceled(TInt aIdentifier);
       
    72 
       
    73 public: // New functions
       
    74 
       
    75     /**
       
    76      * Add a custom soft notification. If a custom soft notification with
       
    77      * exactly the same parameters already exists,
       
    78      * its count is increased by aCount.
       
    79      *
       
    80      * @param aNotificationId identifier for this notification
       
    81      * @param aCount addition count
       
    82      */
       
    83     void ShowSoftNotificationL();
       
    84 
       
    85     /**
       
    86      * Cancels custom soft notification.
       
    87      *
       
    88      * @param aNotificationId identifier for this notification
       
    89      */
       
    90     void RemoveSoftNotificationL();
       
    91 
       
    92     /**
       
    93      * Set a text for a soft notification.
       
    94      *
       
    95      * @param aSingularText singular text for soft notification
       
    96      * @param aPluralText plural text for soft notification
       
    97      */
       
    98     void SetTextL(const TDesC& aText, const TDesC& aGroupText);
       
    99 
       
   100     /**
       
   101      * Set labels for soft notification's softkeys.
       
   102      *
       
   103      * @param aSoftkey1Label Label for the softkey 1
       
   104      * @param aSoftkey2Label Label for the softkey 2
       
   105      */
       
   106     void SetSoftkeyLabelsL(const TDesC& aSoftkey1Label,
       
   107                            const TDesC& aSoftkey2Label);
       
   108 
       
   109     /**
       
   110      * Set an image for a soft notification.
       
   111      *
       
   112      * @param aImage image for soft notification
       
   113      */
       
   114     void SetImageL(const TDesC8& aImage);
       
   115 
       
   116     /**
       
   117      * Returns the notification id.
       
   118      *
       
   119      * @return notification id
       
   120      */
       
   121     TInt Id();
       
   122 
       
   123     /**
       
   124      * Set Java peer observer instance for event callbacks.
       
   125      * Note: the observer has to be a global weak reference.
       
   126      *
       
   127      * @param aPeer Java peer observer as a weak reference.
       
   128      * @param aMethodId Callback method identifier.
       
   129      */
       
   130     void SetPeerObserver(jobject aPeer, jmethodID aMethodId);
       
   131 
       
   132     /**
       
   133      * Removes the Java peer observer. Deletes the stored
       
   134      * global weak reference.
       
   135      *
       
   136      * @param aJniEnv JNI environment used for deleting the
       
   137      *        stored weak reference.
       
   138      */
       
   139     void RemovePeerObserver(JNIEnv& aJniEnv);
       
   140 
       
   141 private:  // Constructors
       
   142     /**
       
   143      * C++ constructor.
       
   144      *
       
   145      * @param aAppId View activation application id.
       
   146      * @param aNotificationId Notification id.
       
   147      * @param aEventSource Event source used for posting events from
       
   148      *        native to Java side.
       
   149      */
       
   150     CSoftNotification(TInt aAppId,
       
   151                       TInt aNotificationId,
       
   152                       CSoftNotificationEventSource& aEventSource);
       
   153 
       
   154     /**
       
   155      * 2nd phase constructor.
       
   156      */
       
   157     void ConstructL();
       
   158 
       
   159 private:  // New methods
       
   160 
       
   161     /**
       
   162      * Posts an event to the Java side.
       
   163      *
       
   164      * @param aEventId Id of the event to be posted.
       
   165      */
       
   166     void PostEventL(TInt aEventId);
       
   167 
       
   168     /**
       
   169      * Set assigned member data to custom notification parameters
       
   170      *
       
   171      * @param aParam custom soft notification params to fill
       
   172      */
       
   173     void FillNotificationParams(TAknDynamicSoftNotificationParams& aParam);
       
   174 
       
   175 private:  // Data
       
   176     /// Own. AvKon custom soft notifier
       
   177     CAknDynamicSoftNotifier* iNotifier;
       
   178     /// View activation application id
       
   179     TUid iAppId;
       
   180     /// Notification Id
       
   181     TInt iNotificationId;
       
   182     /// Own. Softkey 1 label
       
   183     HBufC* iSoftkey1;
       
   184     /// Own. Softkey 2 label
       
   185     HBufC* iSoftkey2;
       
   186     /// Own. Note label when single dialog is shown
       
   187     HBufC* iLabel;
       
   188     /// Own. Note label when notifications are groupped
       
   189     HBufC* iGroupLabel;
       
   190     /// Own. Image data byte array
       
   191     HBufC8* iImageData;
       
   192 
       
   193     /// Observing Java peer object.
       
   194     jobject iPeer;
       
   195     /// Java peer callback method.
       
   196     jmethodID iMethodId;
       
   197     /// Event source instance.
       
   198     CSoftNotificationEventSource& iEventSource;
       
   199 };
       
   200 
       
   201 #endif // CSOFTNOTIFICATION_H
       
   202 
       
   203