|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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 provides information of all Application on phone. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <e32cmn.h> |
|
21 #include <APMSTD.H> |
|
22 #include <APAID.H> |
|
23 #include <APGCLI.H> |
|
24 #include "appiterator.h" |
|
25 #include "appinfo.h" |
|
26 #include "appmanagercommon.h" |
|
27 #include "appmanagerservice.h" |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CAppIterator::NewL |
|
31 // Returns the instance of CAppIterator class. |
|
32 // ----------------------------------------------------------------------------- |
|
33 CAppIterator* CAppIterator::NewL(RApaLsSession& aApaLsSession ,const CFilterParam* aFilterParam ) |
|
34 { |
|
35 CAppIterator* self = new(ELeave) CAppIterator(aApaLsSession); |
|
36 CleanupStack::PushL(self); |
|
37 self->ConstructL(aFilterParam); |
|
38 CleanupStack::Pop(self); |
|
39 return self; |
|
40 } |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CAppIterator::CAppIterator |
|
43 // C++ Constructor |
|
44 // ----------------------------------------------------------------------------- |
|
45 |
|
46 CAppIterator::CAppIterator(RApaLsSession& aApaLsSession):iApaLsSession(aApaLsSession),iUid(KNullUid),iHandler(EFalse) |
|
47 { |
|
48 |
|
49 |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CAppIterator::ConstructL |
|
54 // Two-phase constructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 void CAppIterator::ConstructL(const CFilterParam* aFilterParam) |
|
57 { |
|
58 // If both document name and mimetype are given then document name would be given priority |
|
59 if( NULL == aFilterParam) |
|
60 { |
|
61 //Get all Application |
|
62 User::LeaveIfError(iApaLsSession.GetAllApps()); |
|
63 } |
|
64 else if( (0 != aFilterParam->DocName().Length() ) ) |
|
65 { |
|
66 |
|
67 CAppManagerService::ValidateFilePathL(aFilterParam->DocName()); |
|
68 |
|
69 //Get Handler for Document |
|
70 iHandler = ETrue; |
|
71 TDataType notused; |
|
72 User::LeaveIfError(iApaLsSession.AppForDocument(aFilterParam->DocName(), iUid, notused)); |
|
73 |
|
74 if (iUid == KNullUid) |
|
75 User::Leave(KErrArgument); |
|
76 } |
|
77 else if( ( 0 != aFilterParam->MimeType().Length() ) ) |
|
78 { |
|
79 //Get Handler for MIME Type |
|
80 iHandler = ETrue; |
|
81 TDataType datatype( aFilterParam->MimeType() );// Now it is HBufC* |
|
82 /// now makeTDataType object |
|
83 User::LeaveIfError( iApaLsSession.AppForDataType(datatype,iUid) ); |
|
84 |
|
85 if (iUid == KNullUid) |
|
86 User::Leave(KErrArgument); |
|
87 } |
|
88 else |
|
89 { |
|
90 User::Leave( KErrNotFound); |
|
91 } |
|
92 |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CAppIterator::~CAppIterator |
|
98 // Destructor |
|
99 // ----------------------------------------------------------------------------- |
|
100 CAppIterator::~CAppIterator() |
|
101 { |
|
102 |
|
103 |
|
104 } |
|
105 |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CAppIterator::~CAppIterator |
|
108 // It gives the instance of MInfoMap which contains the information about next application on |
|
109 // iterator list. |
|
110 // ----------------------------------------------------------------------------- |
|
111 TBool CAppIterator::NextL(MInfoMap*& aInfo) |
|
112 { |
|
113 |
|
114 |
|
115 TApaAppInfo appinfo; |
|
116 TBool retValue = ETrue; |
|
117 |
|
118 if( KNullUid != iUid && iHandler) |
|
119 { |
|
120 //List will return Handler application and it contains only one handler application |
|
121 User::LeaveIfError (iApaLsSession.GetAppInfo(appinfo, iUid)); |
|
122 aInfo = CAppInfo::NewL(appinfo); |
|
123 iHandler = EFalse; |
|
124 |
|
125 } |
|
126 else if(KNullUid == iUid && iHandler == EFalse) |
|
127 { |
|
128 //List will return all application |
|
129 TInt ret = iApaLsSession.GetNextApp(appinfo); |
|
130 |
|
131 if(RApaLsSession::ENoMoreAppsInList == ret) |
|
132 { |
|
133 //underlying List finished |
|
134 aInfo = NULL; |
|
135 retValue = EFalse; |
|
136 } |
|
137 else if(KErrNone != ret) |
|
138 User::LeaveIfError (ret);//Some error comes |
|
139 else |
|
140 { |
|
141 aInfo = CAppInfo::NewL(appinfo); //send the object of map |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 aInfo = NULL; |
|
147 retValue = EFalse; |
|
148 } |
|
149 |
|
150 return retValue; |
|
151 |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CAppIterator::Reset |
|
156 // It resets the iterator |
|
157 // ----------------------------------------------------------------------------- |
|
158 void CAppIterator::Reset() |
|
159 { |
|
160 |
|
161 if( KNullUid != iUid ) |
|
162 { |
|
163 iHandler = ETrue; |
|
164 } |
|
165 else |
|
166 { |
|
167 //reset the underlying iterator to begining |
|
168 iApaLsSession.GetAllApps(); |
|
169 } |
|
170 |
|
171 |
|
172 |
|
173 } |