|
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: Class implementing SIP profile model. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_MUSSIPPROFILEMODEL_H |
|
21 #define C_MUSSIPPROFILEMODEL_H |
|
22 |
|
23 |
|
24 #include "mmussipprofilehandler.h" |
|
25 #include <e32base.h> |
|
26 #include <sipmanagedprofile.h> |
|
27 #include <gsplugininterface.h> |
|
28 #include <sipprofileregistryobserver.h> |
|
29 |
|
30 |
|
31 class CSIPManagedProfileRegistry; |
|
32 |
|
33 |
|
34 /** |
|
35 * CMusSIPProfileModel model class. |
|
36 * Model class implementing SIP profile model. |
|
37 * |
|
38 * @since S60 v3.2 |
|
39 */ |
|
40 class CMusSIPProfileModel |
|
41 :public CBase, |
|
42 public MSIPProfileRegistryObserver, |
|
43 public MMusSIPProfileHandler |
|
44 { |
|
45 public: |
|
46 |
|
47 static CMusSIPProfileModel* NewL(); |
|
48 |
|
49 /** |
|
50 * Destructor. |
|
51 */ |
|
52 virtual ~CMusSIPProfileModel(); |
|
53 |
|
54 public: // From base class MMusSIPProfileHandler. |
|
55 |
|
56 /** |
|
57 * From MMusSIPProfileHandler. |
|
58 * Returns the index of the default SIP profile. |
|
59 * @return KErrNotFound, if one does not exist, otherwise index of the |
|
60 * default SIP profile. |
|
61 */ |
|
62 virtual TInt DefaultProfileIndex(); |
|
63 |
|
64 /** |
|
65 * From MMusSIPProfileHandler. |
|
66 * Returns the id of the default SIP profile. |
|
67 * @return KErrNotFound, if one does not exist, otherwise id of the |
|
68 * default SIP profile. |
|
69 */ |
|
70 virtual TUint32 DefaultProfileId(); |
|
71 |
|
72 /** |
|
73 * From MMusSIPProfileHandler. |
|
74 * Returns SIP profile index on locally cached array based on id. |
|
75 * @param aId Profile id |
|
76 * @return Profile index or KErrNotFound if no matching profile is found. |
|
77 */ |
|
78 virtual TInt ProfileIndexByIdL( TUint32 aId ); |
|
79 |
|
80 /** |
|
81 * From MMusSIPProfileHandler. |
|
82 * Returns profile id based on index. |
|
83 * @param aIndex Profile index |
|
84 * @return Profile id or KUnknownProfileId if no matching profile is found. |
|
85 */ |
|
86 virtual TUint32 ProfileIdByIndex( TUint aIndex ); |
|
87 |
|
88 /** |
|
89 * From MMusSIPProfileHandler. |
|
90 * Returns pointer to the SIP profile array, does not change ownership. |
|
91 * Note that previously returned value goes out of scope after a new |
|
92 * call to ProfileArrayL. So it is not advised to store return value |
|
93 * in long persistent variable, but rather to be used like stack |
|
94 * variables for safety. |
|
95 * |
|
96 * @return Pointer to internally cached SIP profile array. |
|
97 */ |
|
98 virtual CArrayPtr<CSIPManagedProfile>* ProfileArrayL(); |
|
99 |
|
100 public: // From base class MSIPProfileRegistryObserver. |
|
101 |
|
102 /** |
|
103 * From MSIPProfileRegistryObserver. |
|
104 * SIP profile information event. |
|
105 * @param aProfileId Id of SIP profile in question. |
|
106 * @param aEvent Type of information event. |
|
107 */ |
|
108 virtual void ProfileRegistryEventOccurred( |
|
109 TUint32 aSIPProfileId, |
|
110 TEvent aEvent ); |
|
111 |
|
112 /** |
|
113 * From MSIPProfileRegistryObserver. |
|
114 * An asynchronous error has occurred related to SIP profile. |
|
115 * @param aSIPProfileId Id of the failed profile. |
|
116 * @param aError An error code. |
|
117 */ |
|
118 virtual void ProfileRegistryErrorOccurred( |
|
119 TUint32 aSIPProfileId, |
|
120 TInt aError ); |
|
121 |
|
122 protected: |
|
123 |
|
124 /** |
|
125 * Reads the profile array from SIP Profile Client. |
|
126 */ |
|
127 void ReadArrayFromEngineL(); |
|
128 |
|
129 /** |
|
130 * Sorts internal array of SIP profiles by id. |
|
131 */ |
|
132 void SortProfilesL(); |
|
133 |
|
134 /** |
|
135 * Deletes internally cached profiles. |
|
136 */ |
|
137 void DeleteProfiles(); |
|
138 |
|
139 /** |
|
140 * Reads profile list from the engine; if reading fails, |
|
141 * keeps the old list safe. |
|
142 */ |
|
143 void ReadProfileListFromEngineSafeL(); |
|
144 |
|
145 private: |
|
146 |
|
147 CMusSIPProfileModel(); |
|
148 |
|
149 void ConstructL(); |
|
150 |
|
151 /** |
|
152 * For deleting RPointerArray in case of leave. |
|
153 */ |
|
154 static void ResetAndDestroy( TAny* aPointerArray ); |
|
155 |
|
156 private: // data |
|
157 |
|
158 /** |
|
159 * Instance of the SIP profile registry engine for managing SIP profiles. |
|
160 * Own. |
|
161 */ |
|
162 CSIPManagedProfileRegistry* iEngine; |
|
163 |
|
164 /** |
|
165 * Locally cached array of SIP profiles. |
|
166 * Own. |
|
167 */ |
|
168 CArrayPtrFlat<CSIPManagedProfile>* iProfiles; |
|
169 |
|
170 }; |
|
171 |
|
172 #endif // C_MUSSIPPROFILEMODEL_H |