1 /* |
|
2 * Copyright (c) 2006-2007 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: Publish / Subscriber class for ChannelName and MetaData |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "irsonghistoryengpubsub.h" |
|
20 #include "irsonghistoryengpubsubnotifyhandler.h" |
|
21 #include "irdebug.h" |
|
22 |
|
23 |
|
24 // ==================== MEMBER FUNCTIONS =================== |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // CIRSongHistoryEngPubSub::CIRSongHistoryEngPubSub |
|
28 // Constructor. |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CIRSongHistoryEngPubSub::CIRSongHistoryEngPubSub( |
|
32 MIRSongHistoryEngPubSubNotifyHandler& aPubSubObserver, const TUid& aCategory, |
|
33 TUint aKey , const RProperty::TType aPropertyType): CActive( CActive:: |
|
34 EPriorityStandard ), iPropertyType(aPropertyType),iPubSubObserver( aPubSubObserver ), |
|
35 iCategory( aCategory ), iKey( aKey ) |
|
36 { |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // CIRSongHistoryEngPubSub::ConstructL |
|
41 // Second-phase constructor |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 void CIRSongHistoryEngPubSub::ConstructL() |
|
45 { |
|
46 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::ConstructL" ); |
|
47 User::LeaveIfError( iProperty.Attach( iCategory, iKey ) ); |
|
48 CActiveScheduler::Add( this ); |
|
49 iProperty.Subscribe( iStatus ); |
|
50 SetActive(); |
|
51 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::ConstructL - Exiting." ); |
|
52 } |
|
53 |
|
54 //----------------------------------------------------------------------------- |
|
55 // CIRHistoryListContainer::NewL |
|
56 // Creates a new instance of CIRSongHistoryEngPubSub |
|
57 //----------------------------------------------------------------------------- |
|
58 // |
|
59 CIRSongHistoryEngPubSub* CIRSongHistoryEngPubSub::NewL( |
|
60 MIRSongHistoryEngPubSubNotifyHandler& aPubSubObserver, const TUid& aCategory, |
|
61 TUint aKey, const RProperty::TType aPropertyType ) |
|
62 { |
|
63 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::NewL - Entering" ); |
|
64 CIRSongHistoryEngPubSub* self = CIRSongHistoryEngPubSub::NewLC(aPubSubObserver, |
|
65 aCategory,aKey, aPropertyType ); |
|
66 CleanupStack::Pop(self); |
|
67 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::NewL - Exiting." ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 //----------------------------------------------------------------------------- |
|
72 // CIRHistoryListContainer::NewLC |
|
73 // Creates a new instance of CIRSongHistoryEngPubSub and leaves it on the cleanup stack. |
|
74 //----------------------------------------------------------------------------- |
|
75 // |
|
76 CIRSongHistoryEngPubSub* CIRSongHistoryEngPubSub::NewLC( |
|
77 MIRSongHistoryEngPubSubNotifyHandler& aPubSubObserver, const TUid& aCategory, |
|
78 TUint aKey, const RProperty::TType aPropertyType ) |
|
79 { |
|
80 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::NewLC - Entering" ); |
|
81 CIRSongHistoryEngPubSub* self = new (ELeave) CIRSongHistoryEngPubSub( |
|
82 aPubSubObserver, aCategory, aKey, aPropertyType); |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(); |
|
85 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::NewLC - Exiting." ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CIRSongHistoryEngPubSub::~CIRSongHistoryEngPubSub() |
|
92 // Destructor |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CIRSongHistoryEngPubSub::~CIRSongHistoryEngPubSub() |
|
96 { |
|
97 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::~CIRSongHistoryEngPubSub" ); |
|
98 Cancel(); |
|
99 iProperty.Close(); |
|
100 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::~CIRSongHistoryEngPubSub - Exiting." ); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CIRSongHistoryEngPubSub::DoCancel() |
|
105 // Invoked when the active object is cancelled. |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void CIRSongHistoryEngPubSub::DoCancel() |
|
109 { |
|
110 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::DoCancel" ); |
|
111 iProperty.Cancel(); |
|
112 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::DoCancel - Exiting." ); |
|
113 } |
|
114 |
|
115 // --------------------------------------------------------------------------- |
|
116 // CIRSongHistoryEngPubSub::RunL() |
|
117 // The function is called by the active scheduler when a request completion event occurs, |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CIRSongHistoryEngPubSub::RunL() |
|
121 { |
|
122 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::RunL" ); |
|
123 |
|
124 iProperty.Subscribe( iStatus ); |
|
125 SetActive(); |
|
126 TInt err(KErrNone); |
|
127 |
|
128 |
|
129 err = iProperty.Get( iText ); |
|
130 if (!err) |
|
131 { |
|
132 iPubSubObserver.HandlePropertyChangeL( iCategory, iKey, iText ); |
|
133 } |
|
134 |
|
135 else |
|
136 { |
|
137 iPubSubObserver.HandlePropertyChangeErrorL(iCategory, iKey, err); |
|
138 } |
|
139 |
|
140 IRLOG_DEBUG( "CIRSongHistoryEngPubSub::RunL - Exiting." ); |
|
141 } |
|