37 // Destructor |
34 // Destructor |
38 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
39 // |
36 // |
40 WrtHarvesterRegistryAccess::~WrtHarvesterRegistryAccess() |
37 WrtHarvesterRegistryAccess::~WrtHarvesterRegistryAccess() |
41 { |
38 { |
42 iWidgetInfoArray.ResetAll(); |
|
43 } |
39 } |
44 |
40 |
45 // --------------------------------------------------------------------------- |
41 // --------------------------------------------------------------------------- |
46 // Collect bundle names of widgets supporting miniviews. |
42 // Collect bundle names of widgets supporting miniviews. |
47 // --------------------------------------------------------------------------- |
43 // --------------------------------------------------------------------------- |
48 // |
44 // |
49 void WrtHarvesterRegistryAccess::WidgetBundleNamesL( |
45 void WrtHarvesterRegistryAccess::WidgetInfosL( |
50 RPointerArray< HBufC >& aArray ) |
46 RWrtArray< CWrtInfo >& aWidgetInfoArray ) |
51 { |
47 { |
52 RWrtArray< CWidgetInfo > widgetInfoArr; |
48 RWrtArray< CWidgetInfo > widgetInfoArr; |
53 RWidgetRegistryClientSession session; |
|
54 |
|
55 CleanupClosePushL( session ); |
|
56 widgetInfoArr.PushL(); |
49 widgetInfoArr.PushL(); |
57 |
50 |
|
51 RWidgetRegistryClientSession session; |
|
52 CleanupClosePushL( session ); |
58 User::LeaveIfError( session.Connect() ); |
53 User::LeaveIfError( session.Connect() ); |
59 |
54 |
60 aArray.Reset(); |
|
61 // Reset previously appended widget infos |
55 // Reset previously appended widget infos |
62 iWidgetInfoArray.ResetAll(); |
56 aWidgetInfoArray.ResetAll(); |
63 |
57 |
64 TInt err = session.InstalledWidgetsL( widgetInfoArr ); |
58 TInt err = session.InstalledWidgetsL( widgetInfoArr ); |
65 |
59 |
66 for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) |
60 for( TInt i( widgetInfoArr.Count() - 1 ); i >= 0; --i ) |
67 { |
61 { |
68 CWidgetInfo* widgetInfo( widgetInfoArr[i] ); |
62 CWidgetInfo* widgetInfo( widgetInfoArr[i] ); |
69 |
63 |
70 if ( SupportsMiniviewL( session, widgetInfo->iUid ) ) |
64 if ( SupportsMiniviewL( session, widgetInfo->iUid ) ) |
71 { |
65 { |
72 aArray.AppendL( ConstructWidgetNameL( session, *widgetInfo ) ); |
66 CWrtInfo* info = new CWrtInfo(); |
73 iWidgetInfoArray.AppendL( widgetInfo ); |
67 info->iUid = widgetInfo->iUid; |
74 } |
68 info->iBundleId = WidgetPropertyL( session, widgetInfo->iUid, EBundleIdentifier ); |
75 else |
69 info->iDisplayName = WidgetPropertyL( session, widgetInfo->iUid, EBundleDisplayName ); |
76 { |
70 aWidgetInfoArray.AppendL( info ); |
77 delete widgetInfo; |
|
78 } |
|
79 |
|
80 widgetInfoArr.Remove( i ); |
|
81 } |
|
82 |
|
83 CleanupStack::PopAndDestroy( 2, &session ); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Find widget by UID. |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 TUid WrtHarvesterRegistryAccess::WidgetUid( TPtrC aBundleName ) |
|
91 { |
|
92 TUid uid={0}; |
|
93 TInt pos = aBundleName.Find( KSeparator ); |
|
94 if( pos != KErrNotFound ) |
|
95 { |
|
96 aBundleName.Set( aBundleName.Right( aBundleName.Length()-pos-1 )); |
|
97 } |
|
98 |
|
99 for( TInt i = 0; i < iWidgetInfoArray.Count(); i++ ) |
|
100 { |
|
101 if( aBundleName == *iWidgetInfoArray[i]->iBundleName ) |
|
102 { |
|
103 uid = iWidgetInfoArray[i]->iUid; |
|
104 break; |
|
105 } |
71 } |
106 } |
72 } |
107 return uid; |
73 CleanupStack::PopAndDestroy( &session ); |
|
74 CleanupStack::PopAndDestroy( &widgetInfoArr ); |
108 } |
75 } |
109 |
76 |
110 // --------------------------------------------------------------------------- |
77 // --------------------------------------------------------------------------- |
111 // Check if widget supports miniview. |
78 // Check if widget supports miniview. |
112 // --------------------------------------------------------------------------- |
79 // --------------------------------------------------------------------------- |
125 delete value; |
92 delete value; |
126 return res; |
93 return res; |
127 } |
94 } |
128 |
95 |
129 // --------------------------------------------------------------------------- |
96 // --------------------------------------------------------------------------- |
130 // Get the Bundle identifier. |
97 // Get the widget property as string. |
131 // --------------------------------------------------------------------------- |
98 // --------------------------------------------------------------------------- |
132 // |
99 // |
133 HBufC* WrtHarvesterRegistryAccess::ConstructWidgetNameL( |
100 HBufC* WrtHarvesterRegistryAccess::WidgetPropertyL( |
134 RWidgetRegistryClientSession& aSession, |
101 RWidgetRegistryClientSession& aSession, |
135 CWidgetInfo& aInfo ) |
102 const TUid& aUid, TWidgetPropertyId aPropertyId ) |
136 { |
103 { |
137 CWidgetPropertyValue* value( NULL ); |
104 CWidgetPropertyValue* value( NULL ); |
138 value = aSession.GetWidgetPropertyValueL( aInfo.iUid, EBundleIdentifier ); |
105 value = aSession.GetWidgetPropertyValueL( aUid, aPropertyId ); |
139 CleanupStack::PushL( value ); |
106 CleanupStack::PushL( value ); |
140 |
107 |
141 const TDesC& identifier = *value; |
108 const TDesC& str = *value; |
142 HBufC* bundle = aInfo.iBundleName; |
109 HBufC* strBuf = str.AllocL(); |
143 |
|
144 HBufC* name = HBufC::NewL( identifier.Length() + KSeparator().Length() + bundle->Length()); |
|
145 TPtr ptr = name->Des(); |
|
146 ptr.Append( identifier ); |
|
147 ptr.Append( KSeparator ); |
|
148 ptr.Append( *bundle); |
|
149 CleanupStack::PopAndDestroy( value ); |
110 CleanupStack::PopAndDestroy( value ); |
150 return name; |
111 return strBuf; |
151 } |
112 } |
152 |
113 |
153 // End of File |
114 // End of File |
154 |
115 |