|
1 /* |
|
2 * Copyright (c) 2006-2006 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: ImIndicatorPlugin plugin implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <coemain.h> |
|
22 #include <coeaui.h> |
|
23 #include <vwsdef.h> |
|
24 #include <e32property.h> |
|
25 #include <imindicatorng.rsg> |
|
26 #include <stringloader.h> |
|
27 #include <aknutils.h> |
|
28 |
|
29 #include "cimindicatorpluginimplementation.h" |
|
30 #include "chatdebugprint.h" |
|
31 #include "chatdebugassert.h" |
|
32 #include "caexternalinterface.h" |
|
33 #include "caminimalresourcereader.h" |
|
34 #include "iminternalpskeys.h" |
|
35 |
|
36 // CONSTANTS |
|
37 _LIT( KIndicatorResourceFile, "imindicatorng.rsc" ); |
|
38 const TInt KMaxMessageNumberLength = 4; // 9999 = 4 numbers |
|
39 |
|
40 |
|
41 // ======== MEMBER FUNCTIONS ======== |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CImIndicatorPluginImplementation::CImIndicatorPluginImplementation |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CImIndicatorPluginImplementation::CImIndicatorPluginImplementation() |
|
50 { |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CImIndicatorPluginImplementation::ConstructL |
|
55 // Symbian 2nd phase constructor can leave. |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 void CImIndicatorPluginImplementation::ConstructL() |
|
59 { |
|
60 CHAT_DP_FUNC_ENTER( "CImIndicatorPluginImplementation::ConstructL" ); |
|
61 |
|
62 // Read resource strings |
|
63 CAMinimalResourceReader* reader = CAMinimalResourceReader::NewLC(); |
|
64 TPtrC file( KIndicatorResourceFile ); |
|
65 reader->OpenResourceFileL( file ); |
|
66 |
|
67 iPopupHeading = |
|
68 reader->ReadTextResourceL( R_QTN_CHAT_STYLUS_POPUP_IM ); |
|
69 iPopupTextOne = |
|
70 reader->ReadTextResourceL( R_QTN_CHAT_STYLUS_POPUP_NEW1 ); |
|
71 iPopupTextMultiple = |
|
72 reader->ReadTextResourceL( R_QTN_CHAT_STYLUS_POPUP_NEW ); |
|
73 |
|
74 CleanupStack::PopAndDestroy(); // reader |
|
75 |
|
76 CHAT_DP_FUNC_DONE( "CImIndicatorPluginImplementation::ConstructL" ); |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CImIndicatorPluginImplementation::NewL |
|
81 // Two-phased constructor. |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 CImIndicatorPluginImplementation* CImIndicatorPluginImplementation::NewL() |
|
85 { |
|
86 CImIndicatorPluginImplementation* self = |
|
87 new( ELeave ) CImIndicatorPluginImplementation; |
|
88 CleanupStack::PushL( self ); |
|
89 self->ConstructL(); |
|
90 CleanupStack::Pop( self ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 |
|
95 // Destructor |
|
96 CImIndicatorPluginImplementation::~CImIndicatorPluginImplementation() |
|
97 { |
|
98 CHAT_DP_FUNC_ENTER( "~CImIndicatorPluginImplementation" ); |
|
99 delete iPopupTextMultiple; |
|
100 delete iPopupTextOne; |
|
101 delete iPopupHeading; |
|
102 CHAT_DP_FUNC_DONE( "~CImIndicatorPluginImplementation" ); |
|
103 } |
|
104 |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CImIndicatorPluginImplementation::HandleIndicatorTapL |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CImIndicatorPluginImplementation::HandleIndicatorTapL( const TInt /*aUid*/ ) |
|
111 { |
|
112 CHAT_DP_FUNC_ENTER( "CImIndicatorPluginImplementation::HandleIndicatorTapL" ); |
|
113 ShowMessageL(); |
|
114 CHAT_DP_FUNC_DONE( "CImIndicatorPluginImplementation::HandleIndicatorTapL" ); |
|
115 } |
|
116 |
|
117 |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CImIndicatorPluginImplementation::CreatePopupContentMessageL() |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 HBufC* CImIndicatorPluginImplementation::CreatePopupContentMessageL() |
|
124 { |
|
125 if ( !iPopupTextMultiple || !iPopupTextOne ) |
|
126 { |
|
127 // Load resource strings before calling this method! |
|
128 __CHAT_ASSERT_DEBUG( EFalse ); |
|
129 return KNullDesC().AllocL(); |
|
130 } |
|
131 |
|
132 // Get unread message count |
|
133 TInt messageCount = 0; |
|
134 RProperty::Get( KPSUidIMUI, KIMUnreadMsgKey, messageCount ); |
|
135 |
|
136 // Construct proper popup message (singular or plural) |
|
137 HBufC* dynStringBuf = NULL; |
|
138 if ( messageCount > 1 ) |
|
139 { |
|
140 TInt reqDynLen = iPopupTextMultiple->Length() + |
|
141 KMaxMessageNumberLength; |
|
142 dynStringBuf = HBufC::NewL( reqDynLen ); |
|
143 TPtr dynString = dynStringBuf->Des(); |
|
144 StringLoader::Format( dynString, |
|
145 iPopupTextMultiple->Des(), |
|
146 -1, //No index code in source string |
|
147 messageCount ); |
|
148 } |
|
149 else // mesageCount <= 1 |
|
150 { |
|
151 dynStringBuf = iPopupTextOne->AllocL(); |
|
152 } |
|
153 return dynStringBuf; |
|
154 } |
|
155 |
|
156 |
|
157 |
|
158 // --------------------------------------------------------------------------- |
|
159 // CImIndicatorPluginImplementation::TextL() |
|
160 // --------------------------------------------------------------------------- |
|
161 // |
|
162 HBufC* CImIndicatorPluginImplementation::TextL( const TInt /*aUid*/, TInt& aTextType ) |
|
163 { |
|
164 aTextType = CAknIndicatorPlugin::EAknIndicatorPluginLinkText; |
|
165 return CreatePopupContentMessageL(); |
|
166 } |
|
167 // --------------------------------------------------------------------------- |
|
168 // CImIndicatorPluginImplementation::ShowMessageL() |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CImIndicatorPluginImplementation::ShowMessageL() |
|
172 { |
|
173 // Launch "conversation list view" |
|
174 TVwsViewId view( KUidChatClient, KUidFriendsListView ); |
|
175 CCoeEnv::Static()->AppUi()->CreateActivateViewEventL( |
|
176 view, KUidChatPrivateChatListViewSoftNoteActivationId, |
|
177 KNullDesC8 ); |
|
178 } |
|
179 |
|
180 // End of File |