|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalTechnology |
|
19 */ |
|
20 |
|
21 #ifndef RMEDIASYNCSERVER_H_ |
|
22 #define RMEDIASYNCSERVER_H_ |
|
23 |
|
24 #include <e32std.h> |
|
25 #include "cmediasyncserverdef.h" |
|
26 |
|
27 struct TMDSNotification |
|
28 { |
|
29 TUint objectId; |
|
30 TUint8 changeType; |
|
31 TUint8 activeSchedulerWait; |
|
32 TUint8 reserved[2]; |
|
33 }; |
|
34 |
|
35 class CMediaSyncDataReader : public CBase |
|
36 { |
|
37 public: |
|
38 static CMediaSyncDataReader* NewL(const RChunk& aChunk); |
|
39 /** virtual C++ destructor */ |
|
40 IMPORT_C ~CMediaSyncDataReader(); |
|
41 |
|
42 IMPORT_C TInt Count(); |
|
43 IMPORT_C TBool HasNext(); |
|
44 IMPORT_C void GetNextL(TUint32& aObjectId, TUint8& aType, TPtr16& aUri); |
|
45 |
|
46 private: |
|
47 /** C++ constructor initialises */ |
|
48 CMediaSyncDataReader(); |
|
49 void ConstructL(const RChunk& aChunk); |
|
50 |
|
51 private: |
|
52 TDataHeaderInfo* iHeaderInfo; |
|
53 TUint8* iReadBase; |
|
54 TInt iOffset; |
|
55 TInt iCurrentIdx; |
|
56 }; |
|
57 |
|
58 class RMediaSyncServer : public RSessionBase |
|
59 { |
|
60 public: |
|
61 IMPORT_C RMediaSyncServer(); |
|
62 |
|
63 /** |
|
64 * Starts up MediaSyncServer |
|
65 */ |
|
66 IMPORT_C TInt Startup(); |
|
67 |
|
68 /** |
|
69 * Shut down MediaSyncServer |
|
70 */ |
|
71 IMPORT_C void Shutdown(); |
|
72 |
|
73 /** |
|
74 * Connects to MediaSyncServer, does not start up MediaSyncServer if it is |
|
75 * not running |
|
76 * @return KErrNone on successfull connection, |
|
77 * KMediaSyncServerCleanupYourDatabase on successful connection, |
|
78 * but the database needs to be resynched. The client must empty |
|
79 * MTP database on the objects under its control before reading |
|
80 * the change information since it will get everything that is in |
|
81 * MDS. |
|
82 * Systen wide error code if the connection fails. |
|
83 */ |
|
84 IMPORT_C TInt Connect(); |
|
85 |
|
86 /** |
|
87 * Client should call this when it has detected that the databases are |
|
88 * out of sync or that its database is corrupted. This will lead MSS to |
|
89 * reread everything from the MDS after all the session were closed and |
|
90 * at next connection Connect to return KMediaSyncServerCleanupYourDatabase |
|
91 * to all dataproviders. |
|
92 * @param aNeedFullSync ETrue if the MSS DB file is corrupt and the client need to fully sync with MDE |
|
93 * @return KErrNone if successful, otherwise one of the system-wide error codes |
|
94 * |
|
95 */ |
|
96 IMPORT_C TInt NeedFullSync(TBool& aNeedFullSync); |
|
97 |
|
98 /** |
|
99 * Clear full synchronization flag from MSS |
|
100 * @return KErrNone if successful, otherwise one of the system-wide error codes |
|
101 * |
|
102 */ |
|
103 IMPORT_C TInt ClearFullSync(); |
|
104 |
|
105 /** |
|
106 * This methods returns changes and their type. It only returns one type of |
|
107 * changes at one call. Removals will be returned first then Additions, |
|
108 * then Changes. The change information will be deleted from the DB when returned. |
|
109 * If an object is both added, changed and then deleted between the |
|
110 * connections, no information on it is returned, on the other hand if |
|
111 * object is first deleted the object with a same name is added, both |
|
112 * deletion and addition entry are available. |
|
113 * |
|
114 * Moving objects are treated as deletion and addition (keeping the metadata if possible) |
|
115 * |
|
116 * @param aNotifications on return the array of MDE notifications |
|
117 * @param aIsFinished ETrue if this array is the last one for MDE notifications |
|
118 * @param aStatus async call, KErrNone if changes received, |
|
119 * KErrNotFound if there are no changes, |
|
120 * otherwise another system wide error code. |
|
121 * |
|
122 */ |
|
123 IMPORT_C void GetChangesL(CMediaSyncDataReader*& aDataReader, TBool& aIsFinished, TRequestStatus& aStatus, TInt aMaxFetchCount = 512); |
|
124 |
|
125 /** |
|
126 * Remove all recodes from MSS |
|
127 */ |
|
128 IMPORT_C void RemoveAllRecords(); |
|
129 |
|
130 /** |
|
131 * Enable MSS subscribes MDS notifications |
|
132 * @return KErrNone if successful, otherwise one of the system-wide error codes |
|
133 */ |
|
134 IMPORT_C TInt EnableMonitor(); |
|
135 |
|
136 /** |
|
137 * Disable MSS subscribes MDS notifications |
|
138 * @return KErrNone if successful, otherwise one of the system-wide error codes |
|
139 */ |
|
140 IMPORT_C TInt DisableMonitor(); |
|
141 |
|
142 IMPORT_C void Close(); |
|
143 |
|
144 private: |
|
145 TInt GetGlobalSharedHeapHandle(); |
|
146 void RelaseGlobalSharedHeap(); |
|
147 |
|
148 private: |
|
149 TBool iHasSharedHeap; |
|
150 |
|
151 /** Handle to the Global Shared Heap */ |
|
152 RChunk iGlobalSharedHeap; |
|
153 }; |
|
154 |
|
155 |
|
156 #endif /*RMEDIASYNCSERVER_H_*/ |