23
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: this class is the implementaiton of this plugin
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
// Include Files
|
|
18 |
|
|
19 |
#include "instantmsgindicatorpluginimplementation.h"
|
|
20 |
#include <AknSmallIndicator.h> //Akn indicator
|
|
21 |
#include <avkon.hrh>
|
|
22 |
#include <e32property.h>
|
|
23 |
#include "cimalertmanager.h"
|
|
24 |
|
|
25 |
// Member Functions
|
|
26 |
|
|
27 |
// ---------------------------------------------------------------------------
|
|
28 |
// CInstantMsgIndicatorPluginImplementation::CInstantMsgIndicatorPluginImplementation()
|
|
29 |
// ---------------------------------------------------------------------------
|
|
30 |
//
|
|
31 |
CInstantMsgIndicatorPluginImplementation* CInstantMsgIndicatorPluginImplementation::NewLC()
|
|
32 |
{
|
|
33 |
CInstantMsgIndicatorPluginImplementation* self = new (ELeave) CInstantMsgIndicatorPluginImplementation();
|
|
34 |
CleanupStack::PushL(self);
|
|
35 |
self->ConstructL();
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
// ---------------------------------------------------------------------------
|
|
40 |
// CInstantMsgIndicatorPluginImplementation::CInstantMsgIndicatorPluginImplementation()
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CInstantMsgIndicatorPluginImplementation* CInstantMsgIndicatorPluginImplementation::NewL()
|
|
44 |
{
|
|
45 |
CInstantMsgIndicatorPluginImplementation* self = CInstantMsgIndicatorPluginImplementation::NewLC( );
|
|
46 |
CleanupStack::Pop(self);
|
|
47 |
return self;
|
|
48 |
}
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CInstantMsgIndicatorPluginImplementation::CInstantMsgIndicatorPluginImplementation()
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
CInstantMsgIndicatorPluginImplementation::CInstantMsgIndicatorPluginImplementation( )
|
|
54 |
{
|
|
55 |
}
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// CInstantMsgIndicatorPluginImplementation::ConstructL()
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
void CInstantMsgIndicatorPluginImplementation::ConstructL()
|
|
61 |
{
|
|
62 |
iIndicator = CAknSmallIndicator::NewL( TUid::Uid( EAknIndicatorMecoServiceTab ) );
|
|
63 |
//define the properties for publishing
|
|
64 |
// msg count, serive id, sender id, receiver id
|
|
65 |
|
|
66 |
// define first property to be integer type
|
|
67 |
TInt result = RProperty::Define(KIMStatusProperty,EIMStatusPropertyMessageCount,RProperty::EInt);
|
|
68 |
if (result != KErrAlreadyExists)
|
|
69 |
User::LeaveIfError(result);
|
|
70 |
|
|
71 |
// define first property to be integer type
|
|
72 |
result = RProperty::Define(KIMStatusProperty,EIMStatusPropertyServiceId,RProperty::EInt);
|
|
73 |
if (result != KErrAlreadyExists)
|
|
74 |
User::LeaveIfError(result);
|
|
75 |
|
|
76 |
result = RProperty::Define(KIMStatusProperty,EIMMultipleSender,RProperty::EInt);
|
|
77 |
if (result != KErrAlreadyExists)
|
|
78 |
User::LeaveIfError(result);
|
|
79 |
|
|
80 |
// define first property to be integer type
|
|
81 |
result = RProperty::Define(KIMStatusProperty,EIMStatusPropertySenderId,RProperty::EText);
|
|
82 |
if (result != KErrAlreadyExists)
|
|
83 |
User::LeaveIfError(result);
|
|
84 |
|
|
85 |
iIMAlertMgr = CIMAlertManager::NewL();
|
|
86 |
}
|
|
87 |
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
// CInstantMsgIndicatorPluginImplementation::~CInstantMsgIndicatorPluginImplementation
|
|
90 |
// ---------------------------------------------------------------------------
|
|
91 |
//
|
|
92 |
CInstantMsgIndicatorPluginImplementation::~CInstantMsgIndicatorPluginImplementation()
|
|
93 |
{
|
|
94 |
//Make the IM Indicator invisible here
|
|
95 |
if(iIndicator)
|
|
96 |
{
|
|
97 |
// using TRAP_IGNORE as we cannot call leaving methods in the destructor.
|
|
98 |
TRAP_IGNORE(iIndicator->SetIndicatorStateL(EAknIndicatorStateOff));
|
|
99 |
delete iIndicator;
|
|
100 |
iIndicator = NULL;
|
|
101 |
}
|
|
102 |
// delete the earlier defined property
|
|
103 |
RProperty::Delete(KIMStatusProperty,EIMStatusPropertyMessageCount);
|
|
104 |
|
|
105 |
// delete the earlier defined property
|
|
106 |
RProperty::Delete(KIMStatusProperty,EIMStatusPropertyServiceId);
|
|
107 |
|
|
108 |
// delete the earlier defined property
|
|
109 |
RProperty::Delete(KIMStatusProperty,EIMMultipleSender);
|
|
110 |
|
|
111 |
// delete the earlier defined property
|
|
112 |
RProperty::Delete(KIMStatusProperty,EIMStatusPropertySenderId);
|
|
113 |
}
|
|
114 |
|
|
115 |
|
|
116 |
// ---------------------------------------------------------------------------
|
|
117 |
// CInstantMsgIndicatorPluginImplementation::ShowIMIndicator
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
void CInstantMsgIndicatorPluginImplementation::ShowIMIndicatorL(TInt aNewMessages, TInt aSeriveId,
|
|
121 |
const TDesC& aSenderId ,
|
|
122 |
TInt aMultipleSender)
|
|
123 |
{
|
|
124 |
if(iIndicator)
|
|
125 |
{
|
|
126 |
if(aNewMessages>0)
|
|
127 |
{
|
|
128 |
TInt result = RProperty::Set(KIMStatusProperty,EIMStatusPropertyMessageCount,aNewMessages);
|
|
129 |
User::LeaveIfError(result);
|
|
130 |
|
|
131 |
result = RProperty::Set(KIMStatusProperty,EIMStatusPropertyServiceId,aSeriveId);
|
|
132 |
User::LeaveIfError(result);
|
|
133 |
|
|
134 |
result = RProperty::Set(KIMStatusProperty,EIMMultipleSender,aMultipleSender);
|
|
135 |
User::LeaveIfError(result);
|
|
136 |
|
|
137 |
result = RProperty::Set(KIMStatusProperty,EIMStatusPropertySenderId,aSenderId);
|
|
138 |
User::LeaveIfError(result);
|
|
139 |
|
|
140 |
iIndicator->SetIndicatorStateL( EAknIndicatorStateOn );
|
|
141 |
}
|
|
142 |
else
|
|
143 |
{
|
|
144 |
TInt result = RProperty::Set(KIMStatusProperty,EIMStatusPropertyMessageCount,aNewMessages);
|
|
145 |
User::LeaveIfError(result);
|
|
146 |
|
|
147 |
result = RProperty::Set(KIMStatusProperty,EIMStatusPropertyServiceId,aSeriveId);
|
|
148 |
User::LeaveIfError(result);
|
|
149 |
|
|
150 |
result = RProperty::Set(KIMStatusProperty,EIMMultipleSender,aMultipleSender);
|
|
151 |
User::LeaveIfError(result);
|
|
152 |
|
|
153 |
result = RProperty::Set(KIMStatusProperty,EIMStatusPropertySenderId,aSenderId);
|
|
154 |
User::LeaveIfError(result);
|
|
155 |
iIndicator->SetIndicatorStateL( EAknIndicatorStateOff );
|
|
156 |
}
|
|
157 |
}
|
|
158 |
|
|
159 |
}
|
|
160 |
|
|
161 |
// ---------------------------------------------------------------------------
|
|
162 |
// CInstantMsgIndicatorPluginImplementation::PlayMsgToneL
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
void CInstantMsgIndicatorPluginImplementation::PlayMsgToneL(TInt aNewMessages,TInt aSeriveId)
|
|
166 |
{
|
|
167 |
if(aNewMessages>0 && iIMAlertMgr)
|
|
168 |
{
|
|
169 |
iIMAlertMgr->PlayL(aSeriveId);
|
|
170 |
}
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// CInstantMsgIndicatorPluginImplementation::MessageInfoL
|
|
175 |
// ---------------------------------------------------------------------------
|
|
176 |
//
|
|
177 |
void CInstantMsgIndicatorPluginImplementation::MessageInfoL(TInt aNewMessages, TInt aSeriveId,
|
|
178 |
const TDesC& aSenderId ,
|
|
179 |
TInt aMultipleSender,
|
|
180 |
TBool aCloseConversation /*= EFalse*/)
|
|
181 |
{
|
|
182 |
|
|
183 |
ShowIMIndicatorL(aNewMessages, aSeriveId,aSenderId, aMultipleSender);
|
|
184 |
// this event is not from close conversation hence play the tone,
|
|
185 |
// else do not play the tone.
|
|
186 |
if(!aCloseConversation)
|
|
187 |
{
|
|
188 |
PlayMsgToneL(aNewMessages,aSeriveId);
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
//end of file
|
|
193 |
|
|
194 |
|