|
1 /* |
|
2 * Copyright (c) 2008-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: Utility class to manage attribute retrieval errors |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef _GLXERRORMANAGER_H |
|
21 #define _GLXERRORMANAGER_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include "glxfetcherror.h" |
|
25 |
|
26 // Forward declaration |
|
27 class CGlxMedia; |
|
28 |
|
29 /// How long temporary errors remain valid for until they can be checked again |
|
30 /// @todo Find optimal value for this |
|
31 const TInt KGlxTemporaryErrorValidityPeriodInSeconds = 30; |
|
32 |
|
33 /** |
|
34 * GlxErrorManager |
|
35 * |
|
36 * Utility class for handling the error attribute that may be attached to items |
|
37 * |
|
38 * @lib glxmedialists.lib |
|
39 */ |
|
40 class GlxErrorManager |
|
41 { |
|
42 public: |
|
43 /** |
|
44 * Check whether an error has been recorded against the given attribute |
|
45 * @param aItem The item to check |
|
46 * @param aAttribute The attribute to check |
|
47 * @return The error associated with the attribute; KErrNone if none |
|
48 */ |
|
49 IMPORT_C static TInt HasAttributeErrorL(const CGlxMedia* aItem, const TMPXAttribute& aAttribute); |
|
50 |
|
51 /** |
|
52 * Check whether an error has been recorded against the given attribute |
|
53 * @param aItem The item to check |
|
54 * @param aContentId The content id for attribute to check |
|
55 * @return The error associated with the attribute; KErrNone if none |
|
56 */ |
|
57 IMPORT_C static TInt HasAttributeErrorL(const CGlxMedia* aItem, TInt aContentId); |
|
58 |
|
59 /** |
|
60 * Heuristic to determine whether errors may exist within an item. |
|
61 * @return EFalse, if there are no errors; ETrue if there might be errors (includes possibly expired errors) |
|
62 */ |
|
63 static TBool HasError(const CGlxMedia* aItem); |
|
64 |
|
65 /** |
|
66 * Sets error values for the given attributes |
|
67 * @param aItem The item to add the errors to |
|
68 * @param aAttributes The attributes affected |
|
69 * @param aError The error code to set against the attributes |
|
70 */ |
|
71 static void SetAttributeErrorL(CGlxMedia* aItem, const RArray<TMPXAttribute>& aAttributes, TInt aError); |
|
72 |
|
73 /** |
|
74 * Performs some maintainance on the error attribute of an item. |
|
75 * - Removes any expired temporary errors |
|
76 * - Removes any errors for attributes that don't occur in aAttributesInUse |
|
77 * @param aMedia Media object to clean |
|
78 * @param aAttributesInUse Superset of all attributes that the item may hold. |
|
79 */ |
|
80 static void ClearExpiredAndUnusedErrorsL( CGlxMedia& aMedia, |
|
81 const RArray<TMPXAttribute>& aAttributesInUse ); |
|
82 |
|
83 /** |
|
84 * @return the attribute used to store the error list |
|
85 */ |
|
86 static TMPXAttribute ErrorAttribute(); |
|
87 |
|
88 private: |
|
89 /** |
|
90 * Check whether a given error code is classed as "temporary" |
|
91 * @param aError Error code to check |
|
92 * @return ETrue iff aError is temporary |
|
93 */ |
|
94 static TBool IsTemporaryError(TInt aError); |
|
95 |
|
96 /** |
|
97 * Given an error, check if it has expired. |
|
98 * @param aError The error to check |
|
99 * @return Whether the error has expired |
|
100 */ |
|
101 static TBool IsExpired( const TGlxFetchError& aError ); |
|
102 }; |
|
103 |
|
104 #endif // _GLXERRORMANAGER_H |
|
105 |