85
|
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 : Used for receive SIM Application name, icon or
|
|
15 |
* visibility information.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <e32property.h>
|
|
20 |
#include "cadef.h"
|
|
21 |
#include "ca2internalCRkeys.h"
|
|
22 |
#include "cainnerquery.h"
|
|
23 |
#include "cainnerentry.h"
|
|
24 |
#include "caarraycleanup.inl"
|
|
25 |
#include "castorageproxy.h"
|
|
26 |
#include "casatmonitor.h"
|
|
27 |
|
|
28 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// CCaSatMonitor::NewLC
|
|
32 |
// Two-phased constructor.
|
|
33 |
// -----------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
CCaSatMonitor* CCaSatMonitor::NewL( TPluginParams* aPluginParams )
|
|
36 |
{
|
|
37 |
CCaSatMonitor* self = new( ELeave ) CCaSatMonitor( *aPluginParams->storageProxy );
|
|
38 |
CleanupStack::PushL( self );
|
|
39 |
self->ConstructL();
|
|
40 |
CleanupStack::Pop(); // self;
|
|
41 |
return self;
|
|
42 |
}
|
|
43 |
|
|
44 |
// -----------------------------------------------------------------------------
|
|
45 |
// CCaSatMonitor::~CCaSatMonitor
|
|
46 |
// Destructor.
|
|
47 |
// -----------------------------------------------------------------------------
|
|
48 |
CCaSatMonitor::~CCaSatMonitor()
|
|
49 |
{
|
|
50 |
delete iCaSatNotifierVis;
|
|
51 |
delete iCaSatNotifierIcon;
|
|
52 |
delete iCaSatNotifierName;
|
|
53 |
}
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CCaSatMonitor::CCaSatMonitor
|
|
57 |
// C++ default constructor can NOT contain any code, that
|
|
58 |
// might leave.
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CCaSatMonitor::CCaSatMonitor( CCaStorageProxy& aCaStorageProxy ) :
|
|
62 |
iCaStorageProxy( aCaStorageProxy )
|
|
63 |
{
|
|
64 |
}
|
|
65 |
|
|
66 |
// -----------------------------------------------------------------------------
|
|
67 |
// CCaSatMonitor::ConstructL
|
|
68 |
// Symbian 2nd phase constructor can leave.
|
|
69 |
// -----------------------------------------------------------------------------
|
|
70 |
//
|
|
71 |
void CCaSatMonitor::ConstructL()
|
|
72 |
{
|
|
73 |
iCaSatNotifierName = CCaSatNotifier::NewL(
|
|
74 |
this, KCRUidCa, KCaSatUIName );
|
|
75 |
iCaSatNotifierIcon = CCaSatNotifier::NewL(
|
|
76 |
this, KCRUidCa, KCaSatUIIconId );
|
|
77 |
iCaSatNotifierVis = CCaSatNotifier::NewL(
|
|
78 |
this, KCRUidCa, KCaShowSatUI );
|
|
79 |
//first run of sat monitor to update storage data
|
|
80 |
SatChangeL();
|
|
81 |
}
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// CCaSatMonitor::SatChangeL
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
//
|
|
87 |
void CCaSatMonitor::SatChangeL()
|
|
88 |
{
|
|
89 |
CCaInnerQuery* satAppQuery = CCaInnerQuery::NewLC();
|
|
90 |
satAppQuery->SetUid( KSatUid.iUid );
|
|
91 |
RPointerArray<CCaInnerEntry> resultArray;
|
|
92 |
CleanupResetAndDestroyPushL( resultArray );
|
|
93 |
iCaStorageProxy.GetEntriesL( satAppQuery, resultArray );
|
|
94 |
|
|
95 |
TInt visibility( 0 );
|
|
96 |
//We handle error in case of not inserted sim card
|
|
97 |
//( RProperty could be not created yet for sat )
|
|
98 |
TInt error = GetSatVisibility( visibility );
|
|
99 |
if( ( error == KErrNone ) && visibility )
|
|
100 |
{
|
|
101 |
RBuf satName;
|
|
102 |
satName.CleanupClosePushL();
|
|
103 |
satName.Create( KCenRepBufferSize );
|
|
104 |
User::LeaveIfError( GetSatName( satName ) );
|
|
105 |
|
|
106 |
if( !resultArray.Count() )
|
|
107 |
{
|
|
108 |
//sat app was added we ned to add new entry to storage
|
|
109 |
//we will put new sat entry into array for simpler handling
|
|
110 |
CCaInnerEntry* newSat = CCaInnerEntry::NewLC();
|
|
111 |
resultArray.AppendL( newSat );
|
|
112 |
CleanupStack::Pop( newSat );
|
|
113 |
}
|
|
114 |
resultArray[0]->SetUid( KSatUid.iUid );
|
|
115 |
resultArray[0]->SetRole( EItemEntryRole );
|
|
116 |
resultArray[0]->SetEntryTypeNameL( KCaTypeApp );
|
|
117 |
resultArray[0]->SetTextL( satName );
|
98
|
118 |
resultArray[0]->AddAttributeL( KCaAttrShortName, satName );
|
85
|
119 |
resultArray[0]->SetFlags( resultArray[0]->GetFlags() | EVisible );
|
|
120 |
|
|
121 |
iCaStorageProxy.AddL( resultArray[0] );
|
|
122 |
|
|
123 |
CleanupStack::PopAndDestroy( &satName );
|
|
124 |
}
|
|
125 |
else
|
|
126 |
{
|
|
127 |
if( resultArray.Count() && resultArray[0]->GetFlags() & EVisible )
|
|
128 |
{
|
|
129 |
resultArray[0]->SetFlags(
|
|
130 |
resultArray[0]->GetFlags() & ~EVisible );
|
|
131 |
iCaStorageProxy.AddL( resultArray[0] );
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
CleanupStack::PopAndDestroy( &resultArray );
|
|
136 |
CleanupStack::PopAndDestroy( satAppQuery );
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CCaSatHandler::GetSatName
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
TInt CCaSatMonitor::GetSatName( TDes& aName )
|
|
144 |
{
|
|
145 |
return RProperty::Get( KCRUidCa, KCaSatUIName, aName );
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
// CCaSatHandler::GetSatVisibility
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
TInt CCaSatMonitor::GetSatVisibility( TInt& aVisibility )
|
|
153 |
{
|
|
154 |
return RProperty::Get( KCRUidCa, KCaShowSatUI, aVisibility );
|
|
155 |
}
|
|
156 |
|
|
157 |
// End of File
|