|
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 "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: Implements consume data encapsulation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32std.h> |
|
21 #include "consumedata.h" |
|
22 |
|
23 // LOCAL CONSTANTS AND MACROS |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CConsumeData::ConsumeData |
|
29 // C++ default constructor can NOT contain any code, that might leave. |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CConsumeData::CConsumeData() : CBase() |
|
33 { |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CConsumeData::~ConsumeData |
|
38 // C++ default destructor |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CConsumeData::~CConsumeData() |
|
42 { |
|
43 // If the connection is still open call finish |
|
44 if( iConnectionStatus && iContentURI8 ) |
|
45 { |
|
46 iRdb.Consume( ContentAccess::EStop, *iContentURI8 ); |
|
47 } |
|
48 |
|
49 // Close the connection to the server: |
|
50 iRdb.Close(); |
|
51 |
|
52 // Reset the connection status |
|
53 iConnectionStatus = EFalse; |
|
54 |
|
55 // Delete the content id |
|
56 if( iContentURI8 ) |
|
57 { |
|
58 delete iContentURI8; |
|
59 iContentURI8 = NULL; |
|
60 } |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CConsumeData::NewLC |
|
66 // 2-phase constructor |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CConsumeData* CConsumeData::NewLC( const TDesC8& aUri ) |
|
70 { |
|
71 CConsumeData* self = new (ELeave) CConsumeData(); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL( aUri ); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CConsumeData::NewL |
|
79 // 2-phase constructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CConsumeData* CConsumeData::NewL( const TDesC8& aUri ) |
|
83 { |
|
84 CConsumeData* self = NewLC( aUri ); |
|
85 CleanupStack::Pop( self ); |
|
86 return self; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CConsumeData::Consume |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 TInt CConsumeData::Consume( const ContentAccess::TIntent& aIntent ) |
|
94 { |
|
95 TInt retVal = KErrNone; |
|
96 |
|
97 if( !iConnectionStatus ) |
|
98 { |
|
99 return KErrNotReady; |
|
100 } |
|
101 |
|
102 retVal = iRdb.Consume( aIntent, *iContentURI8 ); |
|
103 |
|
104 if( aIntent == ContentAccess::EStop ) |
|
105 { |
|
106 iRdb.Close(); |
|
107 iConnectionStatus = EFalse; |
|
108 } |
|
109 |
|
110 return retVal; |
|
111 } |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CConsumeData::CompareUri |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 TInt CConsumeData::CompareUri( const TDesC8& aUri ) const |
|
117 { |
|
118 if( !iContentURI8 ) |
|
119 { |
|
120 return KErrNotReady; |
|
121 } |
|
122 |
|
123 return iContentURI8->Des().Compare( aUri ); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CConsumeData::ConstructL |
|
128 // 2nd phase constructor |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CConsumeData::ConstructL( const TDesC8& aUri ) |
|
132 { |
|
133 // Connect the rights client |
|
134 User::LeaveIfError( iRdb.Connect() ); |
|
135 |
|
136 // Set the connection status |
|
137 iConnectionStatus = ETrue; |
|
138 |
|
139 // copy the url for internal use |
|
140 iContentURI8 = aUri.AllocL(); |
|
141 } |
|
142 |
|
143 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
144 |
|
145 |
|
146 // End of File |