|
1 /* |
|
2 * Copyright (c) 2004 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: |
|
15 * Declaration of class CFavouritesSession |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef FAVOURITES_SRV_SESSION_H |
|
22 #define FAVOURITES_SRV_SESSION_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <e32base.h> |
|
27 #include <d32dbms.h> |
|
28 #include <f32file.h> |
|
29 #include "FavouritesSrv.h" |
|
30 |
|
31 // FORWARD DECLARATION |
|
32 class TFavouritesHandle; |
|
33 class TFavouritesSessionEntry; |
|
34 class MStreamBuf; |
|
35 |
|
36 // CLASS DECLARATION |
|
37 |
|
38 /** |
|
39 * Favourites Engine Server Session. |
|
40 */ |
|
41 NONSHARABLE_CLASS(CFavouritesSession) : public CSession2 |
|
42 { |
|
43 |
|
44 public: // construct / destruct |
|
45 |
|
46 /** |
|
47 * Two phase constructor. Leaves on failure. |
|
48 */ |
|
49 static CFavouritesSession* NewL(); |
|
50 |
|
51 /** |
|
52 * Destructor. |
|
53 */ |
|
54 virtual ~CFavouritesSession(); |
|
55 |
|
56 protected: // construct |
|
57 |
|
58 /** |
|
59 * Constructor. Leaves on failure. |
|
60 */ |
|
61 CFavouritesSession(); |
|
62 |
|
63 /** |
|
64 * Second phase constructor. Leaves on failure. |
|
65 */ |
|
66 void ConstructL(); |
|
67 |
|
68 public: // From CSession2 |
|
69 |
|
70 /** |
|
71 * Count resources. |
|
72 * @return Resource count. |
|
73 */ |
|
74 virtual TInt CountResources(); |
|
75 |
|
76 /** |
|
77 * Service message. |
|
78 * @param aMessage Message. |
|
79 */ |
|
80 virtual void ServiceL( const RMessage2& aMessage ); |
|
81 |
|
82 /** |
|
83 * Error in message processing. |
|
84 * @param aMessage Message. |
|
85 * @param aError Error. |
|
86 */ |
|
87 virtual void ServiceError( const RMessage2& aMessage, TInt aError ); |
|
88 |
|
89 public: // New methods |
|
90 |
|
91 /** |
|
92 * Access the server. |
|
93 * @return The server. |
|
94 */ |
|
95 inline CFavouritesSrv& Server() const; |
|
96 |
|
97 private: // Entry / object management: entries. |
|
98 |
|
99 /** |
|
100 * Create a new entry and return its handle. Possibly allocates. |
|
101 * @return Handle for the new empty entry. |
|
102 */ |
|
103 TFavouritesHandle NewHandleL(); |
|
104 |
|
105 /** |
|
106 * Get entry for handle. Can leave with KErrBadHandle. |
|
107 * @param aHandle Handle to get entry for. |
|
108 * @return The entry for this handle. |
|
109 */ |
|
110 TFavouritesSessionEntry& EntryL( TFavouritesHandle aHandle ); |
|
111 |
|
112 /** |
|
113 * Get entry for handle. Panics server if no such handle. |
|
114 * @param aHandle Handle to get entry for. |
|
115 * @return The entry for this handle. |
|
116 */ |
|
117 TFavouritesSessionEntry& Entry( TFavouritesHandle aHandle ); |
|
118 |
|
119 /** |
|
120 * Get a new check number. |
|
121 * @return New check number. |
|
122 */ |
|
123 TInt NextChkNum(); |
|
124 |
|
125 private: // New methods: objects. |
|
126 |
|
127 /** |
|
128 * Create and open a new stream hosted by aHost and return its handle. |
|
129 * @param aHost Stream buffer hosting the stream. Ownership taken. |
|
130 * @param aMessage If there is data, length is sent back in arg 3 of |
|
131 * this message. |
|
132 * @return Handle of new stream. |
|
133 */ |
|
134 TFavouritesHandle NewStreamL |
|
135 ( MStreamBuf& aHost, const RMessage2& aMessage ); |
|
136 |
|
137 private: // new methods |
|
138 |
|
139 /** |
|
140 * Get directory for named database. |
|
141 * @param aName Database name. |
|
142 * @param aParse Directory path returned here. |
|
143 */ |
|
144 void DatabaseDirL( const TDesC& aName, TParse& aParse ); |
|
145 |
|
146 /** |
|
147 * Delete directory with contents. Leaves with KErrInUse if there are |
|
148 * any open files. |
|
149 * @param aParse Path. |
|
150 */ |
|
151 void DeleteDirL( const TParse& aParse ); |
|
152 |
|
153 private: // Data |
|
154 |
|
155 RFs iFs; ///< File server session handle. |
|
156 RDbs iDbs; ///< DBMS session handle. |
|
157 TFavouritesSessionEntry* iEntries; ///< Session object entries. Owned. |
|
158 TInt iNumEntries; ///< Number of session entries. |
|
159 TInt iChkNum; ///< Check number. |
|
160 TParse iParse; ///< Misc. usage off stack. |
|
161 |
|
162 }; |
|
163 |
|
164 #include "FavouritesSrvSession.inl" |
|
165 |
|
166 #endif |
|
167 |
|
168 // End of File |