|
1 /******************************************************************************* |
|
2 * Copyright (c) 2009, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. This program and the accompanying materials |
|
4 * are made available under the terms of the Eclipse Public License v1.0 |
|
5 * which accompanies this distribution, and is available at |
|
6 * http://www.eclipse.org/legal/epl-v10.html |
|
7 * |
|
8 * Contributors: |
|
9 * Nokia Corporation - initial implementation |
|
10 *******************************************************************************/ |
|
11 |
|
12 #ifndef CSOFTNOTIFICATION_H |
|
13 #define CSOFTNOTIFICATION_H |
|
14 |
|
15 #include <e32base.h> |
|
16 #include <jni.h> |
|
17 #include <HbIndicatorsymbian.h> |
|
18 |
|
19 NONSHARABLE_CLASS(CSoftNotification) : public CBase, |
|
20 MHbIndicatorSymbianObserver |
|
21 { |
|
22 public: |
|
23 |
|
24 /** |
|
25 * Static constructor |
|
26 */ |
|
27 static CSoftNotification* NewL(TInt aAppId, TInt aNotificationId); |
|
28 |
|
29 /** |
|
30 * Destructor. |
|
31 */ |
|
32 virtual ~CSoftNotification(); |
|
33 |
|
34 public: |
|
35 // From MHbIndicatorSymbianObserver |
|
36 |
|
37 /** |
|
38 * Dynamic soft notification was activated by user. |
|
39 */ |
|
40 void IndicatorUserActivated(const TDesC &aType, |
|
41 CHbSymbianVariantMap &aData); |
|
42 |
|
43 public: |
|
44 // New functions |
|
45 |
|
46 /** |
|
47 * Add a custom soft notification. |
|
48 */ |
|
49 bool ShowSoftNotificationL(); |
|
50 |
|
51 /** |
|
52 * Cancels custom soft notification. |
|
53 */ |
|
54 void RemoveSoftNotificationL(); |
|
55 |
|
56 /** |
|
57 * Set a text for a soft notification. |
|
58 * |
|
59 * @param aSingularText singular text for soft notification |
|
60 * @param aPluralText plural text for soft notification |
|
61 */ |
|
62 void SetTextL(const TDesC& aPrimaryText, const TDesC& aSecondaryText); |
|
63 |
|
64 /** |
|
65 * Set an image path for a soft notification. |
|
66 * |
|
67 * @param aImagePath image path for soft notification |
|
68 */ |
|
69 void SetImagePathL(const TDesC& aImagePath); |
|
70 |
|
71 /** |
|
72 * Returns the notification id. |
|
73 * |
|
74 * @return notification id |
|
75 */ |
|
76 TInt Id(); |
|
77 |
|
78 /** |
|
79 * Set Java peer observer instance for event callbacks. |
|
80 * Note: the observer has to be a global weak reference. |
|
81 * |
|
82 * @param aPeer Java peer observer |
|
83 * @param aMethodId Callback method identifier. |
|
84 * @param aJniEnv JNI environment |
|
85 */ |
|
86 void SetPeerObserver(jobject aPeer, jmethodID aMethodId, JNIEnv* aJniEnv); |
|
87 |
|
88 private: |
|
89 // Constructors |
|
90 /** |
|
91 * C++ constructor. |
|
92 * |
|
93 * @param aAppId View activation application id. |
|
94 * @param aNotificationId Notification id. |
|
95 */ |
|
96 CSoftNotification(TInt aAppId, TInt aNotificationId); |
|
97 |
|
98 /** |
|
99 * 2nd phase constructor. |
|
100 */ |
|
101 void ConstructL(); |
|
102 |
|
103 private: |
|
104 // New methods |
|
105 |
|
106 /** |
|
107 * Set assigned member data to custom notification parameters |
|
108 * |
|
109 * @param aParam custom soft notification params to fill |
|
110 */ |
|
111 CHbSymbianVariant* NotificationParamsL(); |
|
112 |
|
113 private: |
|
114 // Data |
|
115 |
|
116 CHbIndicatorSymbian* iIndicator; |
|
117 TUid iMidletId; |
|
118 TInt iNotificationId; |
|
119 HBufC* iPrimaryText; |
|
120 HBufC* iSecondaryText; |
|
121 HBufC* iImagePath; |
|
122 jobject iPeer; |
|
123 jmethodID iMethodId; |
|
124 JNIEnv* iJniEnv; |
|
125 }; |
|
126 |
|
127 #endif // CSOFTNOTIFICATION_H |
|
128 |