|
1 // Copyright (c) 1998-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 // Client observer class |
|
15 // |
|
16 // |
|
17 |
|
18 #include "UD_STD.H" |
|
19 |
|
20 // Class RDbNotifier |
|
21 |
|
22 EXPORT_C TInt RDbNotifier::Open(RDbDatabase& aDatabase) |
|
23 /** Opens a DBMS change notifier on a database. |
|
24 |
|
25 Note that a notifier cannot be opened on a client side database. |
|
26 |
|
27 @param aDatabase The database to be observed. |
|
28 @return KErrNone if successful, otherwise another of the system-wide error |
|
29 codes. */ |
|
30 { |
|
31 TRAPD(r,iNotifier=aDatabase.iDatabase->NotifierL()); |
|
32 return r; |
|
33 } |
|
34 |
|
35 EXPORT_C void RDbNotifier::Close() |
|
36 /** Closes a DBMS change notifier. Any outstanding notification request is automatically |
|
37 cancelled. |
|
38 |
|
39 Note that this function can be called on a DBMS change notifier that has already |
|
40 been closed. */ |
|
41 { |
|
42 iNotifier.Close(); |
|
43 } |
|
44 |
|
45 LOCAL_C void Notify(RDbHandle<CDbNotifier>& aNotifier,TRequestStatus& aStatus,CDbNotifier::TType aType) |
|
46 { |
|
47 aNotifier->Notify(aType,aStatus); |
|
48 } |
|
49 |
|
50 EXPORT_C void RDbNotifier::NotifyUnlock(TRequestStatus& aStatus) |
|
51 /** Makes an asynchronous request for notification of a database event. All events, |
|
52 including the release of all read locks, are reported. |
|
53 |
|
54 When a database event occurs, the request completes and the TRequestStatus |
|
55 objectcontains one of the enumerators defined by the TEvent enumeration member. |
|
56 |
|
57 Alternatively, if an outstanding request is cancelled by a call to the Cancel() |
|
58 member function of this class, then the request completes with KErrCancel. |
|
59 |
|
60 Only one notification request can be outstanding on this notifier at any one |
|
61 time. |
|
62 |
|
63 Note that if further database events occur while a client is handling a request |
|
64 completion, the notifier records the most significant database event and this |
|
65 is signalled as soon as the client issues the next NotifyUnlock() or NotifyChange() |
|
66 request. |
|
67 |
|
68 @param aStatus The request status object. If the request is cancelled, this |
|
69 is set to KErrCancel. If the request completes normally, this is set to one |
|
70 of the enumerator values defined by the TEvent enumeration member. */ |
|
71 { |
|
72 ::Notify(iNotifier,aStatus,CDbNotifier::EUnlock); |
|
73 } |
|
74 |
|
75 EXPORT_C void RDbNotifier::NotifyChange(TRequestStatus& aStatus) |
|
76 /** Makes an asynchronous request for notification of changes to the database. |
|
77 |
|
78 All events which indicate a change to the database are reported; in practice, |
|
79 this means all database events except RDbNotifier::EUnlock. |
|
80 |
|
81 When a change event occurs, the request completes and the TRequestStatus object |
|
82 contains one of the appropriate enumerators defined by the TEvent enumeration |
|
83 member. |
|
84 |
|
85 Alternatively, if an outstanding request is cancelled by a call to the Cancel() |
|
86 member function of this class, then the request completes with KErrCancel. |
|
87 |
|
88 Only one notification request can be outstanding on this notifier at any one |
|
89 time. |
|
90 |
|
91 Note that if further database events occur while a client is handling a request |
|
92 completion, the notifier records the most significant database event and this |
|
93 is signalled as soon as the client issues the next NotifyUnlock() or NotifyChange() |
|
94 request. |
|
95 |
|
96 @param aStatus The request status object. If the request is cancelled, this |
|
97 is set to KErrCancel. If the request completes normally, this is set to one |
|
98 of the enumerator values defined by the TEvent enumeration member. */ |
|
99 { |
|
100 ::Notify(iNotifier,aStatus,CDbNotifier::EChange); |
|
101 } |
|
102 |
|
103 EXPORT_C void RDbNotifier::Cancel() |
|
104 /** Cancels any outstanding notification request to this DBMS notifier. |
|
105 |
|
106 The outstanding request completes with a KErrCancel. */ |
|
107 { |
|
108 iNotifier->Cancel(); |
|
109 } |