66
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "aicalendarplugin2constantdata.h"
|
|
19 |
#include "aicalendarplugin2contentmodel.h"
|
|
20 |
#include <aicalendarplugin2res.rsg>
|
|
21 |
#include <avkon.rsg>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <aicontentmodel.h>
|
|
24 |
#include <aiutility.h>
|
|
25 |
#include <AknUtils.h>
|
|
26 |
|
|
27 |
// CONSTANTS
|
|
28 |
#include "aicalendarplugin2constants.hrh"
|
|
29 |
|
|
30 |
_LIT( KAI2CalShortDayName, "%*E" );
|
|
31 |
|
|
32 |
template<class Array>
|
|
33 |
void CleanupReset(TAny* aObj)
|
|
34 |
{
|
|
35 |
static_cast<Array*>(aObj)->Reset();
|
|
36 |
delete aObj;
|
|
37 |
}
|
|
38 |
|
|
39 |
template<class Array>
|
|
40 |
void CleanupResetPushL(Array& aPointerArray)
|
|
41 |
{
|
|
42 |
CleanupStack::PushL( TCleanupItem(&CleanupReset<Array>, &aPointerArray) );
|
|
43 |
}
|
|
44 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
45 |
|
|
46 |
CAICalendarPlugin2ConstantData* CAICalendarPlugin2ConstantData::NewL()
|
|
47 |
{
|
|
48 |
CAICalendarPlugin2ConstantData* self = new( ELeave )CAICalendarPlugin2ConstantData;
|
|
49 |
CleanupStack::PushL( self );
|
|
50 |
self->ConstructL();
|
|
51 |
CleanupStack::Pop( self );
|
|
52 |
return self;
|
|
53 |
}
|
|
54 |
|
|
55 |
CAICalendarPlugin2ConstantData::CAICalendarPlugin2ConstantData()
|
|
56 |
: iDaysToHandleAsNotToday( KAIRangeTomorrowOnly ) // platform defaults to "tomorrow only"
|
|
57 |
{
|
|
58 |
}
|
|
59 |
|
|
60 |
void CAICalendarPlugin2ConstantData::ConstructL()
|
|
61 |
{
|
|
62 |
// load time format strings
|
|
63 |
iTimeFormatUsual = StringLoader::LoadL( R_QTN_TIME_USUAL );
|
|
64 |
iDateFormatWithoutYearWithZero = StringLoader::LoadL( R_QTN_DATE_WITHOUT_YEAR_WITH_ZERO );
|
|
65 |
iDateFormatShortWithZero = StringLoader::LoadL( R_QTN_DATE_SHORT_WITH_ZERO );
|
|
66 |
iContent = AiUtility::CreateContentItemArrayIteratorL( KAICalendarPlugin2Content );
|
|
67 |
iResources = AiUtility::CreateContentItemArrayIteratorL( KAICalendarPlugin2Resources );
|
|
68 |
iEvents = AiUtility::CreateContentItemArrayIteratorL( KAICalendarPlugin2Events );
|
|
69 |
}
|
|
70 |
|
|
71 |
CAICalendarPlugin2ConstantData::~CAICalendarPlugin2ConstantData()
|
|
72 |
{
|
|
73 |
Release( iEvents );
|
|
74 |
Release( iResources );
|
|
75 |
Release( iContent );
|
|
76 |
delete iDateFormatShortWithZero;
|
|
77 |
delete iDateFormatWithoutYearWithZero;
|
|
78 |
delete iTimeFormatUsual;
|
|
79 |
delete iNextEventOnCombined;
|
|
80 |
}
|
|
81 |
|
|
82 |
const TDesC& CAICalendarPlugin2ConstantData::TimeFormatUsual()
|
|
83 |
{
|
|
84 |
return *iTimeFormatUsual;
|
|
85 |
}
|
|
86 |
|
|
87 |
const TDesC& CAICalendarPlugin2ConstantData::DateFormatWithoutYearWithZero()
|
|
88 |
{
|
|
89 |
return *iDateFormatWithoutYearWithZero;
|
|
90 |
}
|
|
91 |
|
|
92 |
const TDesC& CAICalendarPlugin2ConstantData::MakeEventOnL( const TTime& aTime )
|
|
93 |
{
|
|
94 |
delete iNextEventOnCombined;
|
|
95 |
iNextEventOnCombined = NULL;
|
|
96 |
|
|
97 |
CDesC16ArrayFlat* desArray = new(ELeave) CDesC16ArrayFlat( 2 );
|
|
98 |
CleanupStack::PushL( desArray );
|
|
99 |
|
|
100 |
|
|
101 |
// Format day name short (Mon, Tue etc.)
|
|
102 |
HBufC* day = HBufC::NewLC( KAICal2SizeDayShort );
|
|
103 |
TPtr bufPtr2 = day->Des();
|
|
104 |
aTime.FormatL( bufPtr2, KAI2CalShortDayName );
|
|
105 |
desArray->AppendL( *day );
|
|
106 |
CleanupStack::PopAndDestroy( day );
|
|
107 |
|
|
108 |
|
|
109 |
// Format date (8/11 31/1/08 etc)
|
|
110 |
TTime today;
|
|
111 |
today.HomeTime();
|
|
112 |
TDateTime todayDate = today.DateTime();
|
|
113 |
TDateTime time = aTime.DateTime();
|
|
114 |
HBufC* date = HBufC::NewLC( KAICal2SizeDateShort );
|
|
115 |
TPtr bufPtr = date->Des();
|
|
116 |
if( todayDate.Year() == time.Year() )
|
|
117 |
{
|
|
118 |
aTime.FormatL( bufPtr, *iDateFormatWithoutYearWithZero );
|
|
119 |
}
|
|
120 |
else
|
|
121 |
{
|
|
122 |
aTime.FormatL( bufPtr, *iDateFormatShortWithZero );
|
|
123 |
}
|
|
124 |
AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
|
|
125 |
desArray->AppendL( *date );
|
|
126 |
CleanupStack::PopAndDestroy( date );
|
|
127 |
|
|
128 |
|
|
129 |
// Load the string with formatters
|
|
130 |
iNextEventOnCombined = StringLoader::LoadL( R_QTN_AI_CALE_NEXT_LATER, *desArray );
|
|
131 |
|
|
132 |
// Destroy the formatters
|
|
133 |
CleanupStack::PopAndDestroy(); // desArray
|
|
134 |
|
|
135 |
return *iNextEventOnCombined;
|
|
136 |
}
|
|
137 |
|
|
138 |
TAny* CAICalendarPlugin2ConstantData::GetPropertyL( CHsContentPublisher::TProperty aProperty )
|
|
139 |
{
|
|
140 |
if( aProperty == CHsContentPublisher::EPublisherContent )
|
|
141 |
{
|
|
142 |
return iContent;
|
|
143 |
}
|
|
144 |
else if( aProperty == CHsContentPublisher::EPublisherResources )
|
|
145 |
{
|
|
146 |
return iResources;
|
|
147 |
}
|
|
148 |
else if( aProperty == CHsContentPublisher::EPublisherEvents )
|
|
149 |
{
|
|
150 |
return iEvents;
|
|
151 |
}
|
|
152 |
else if( aProperty == CHsContentPublisher::EPluginName )
|
|
153 |
{
|
|
154 |
return StringLoader::LoadL( R_QTN_AI_CALE_PLUGIN_NAME );
|
|
155 |
}
|
|
156 |
|
|
157 |
return NULL;
|
|
158 |
}
|
|
159 |
|