|
1 /* |
|
2 * Copyright (c) 2005-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: A class for using contact store URIs |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include <TVPbkContactStoreUriPtr.h> |
|
21 #include <s32strm.h> |
|
22 |
|
23 namespace |
|
24 { |
|
25 _LIT(KDomainStoreSeparator, "://"); |
|
26 _LIT(KDriveSeparator, ":"); |
|
27 } |
|
28 |
|
29 // TVPbkContactStoreUriPtr implementation |
|
30 EXPORT_C TVPbkContactStoreUriPtr::TVPbkContactStoreUriPtr( |
|
31 const TDesC& aStoreUri) |
|
32 { |
|
33 iUriBufferPointer.Set(aStoreUri); |
|
34 } |
|
35 |
|
36 EXPORT_C TVPbkContactStoreUriPtr::TVPbkContactStoreUriPtr() |
|
37 { |
|
38 } |
|
39 |
|
40 EXPORT_C const TDesC& TVPbkContactStoreUriPtr::UriDes() const |
|
41 { |
|
42 return iUriBufferPointer; |
|
43 } |
|
44 |
|
45 EXPORT_C TInt TVPbkContactStoreUriPtr::Compare( |
|
46 const TVPbkContactStoreUriPtr& aUri, |
|
47 TVPbkContactStoreUriComponent aComponent) const |
|
48 { |
|
49 const TVPbkContactStoreUriPtr uri(iUriBufferPointer); |
|
50 return Compare(uri.Component(aComponent), aUri.Component(aComponent)); |
|
51 } |
|
52 |
|
53 EXPORT_C TInt TVPbkContactStoreUriPtr::Compare( |
|
54 const TDesC& aUriComponent, |
|
55 TVPbkContactStoreUriComponent aComponent) const |
|
56 { |
|
57 const TVPbkContactStoreUriPtr uri(iUriBufferPointer); |
|
58 return Compare(uri.Component(aComponent), aUriComponent); |
|
59 } |
|
60 |
|
61 TInt TVPbkContactStoreUriPtr::Compare( |
|
62 const TDesC& aLhsUri, |
|
63 const TDesC& aRhsUri) const |
|
64 { |
|
65 return aLhsUri.Compare(aRhsUri); |
|
66 } |
|
67 |
|
68 EXPORT_C const TPtrC TVPbkContactStoreUriPtr::Component( |
|
69 TVPbkContactStoreUriComponent aComponent) const |
|
70 { |
|
71 TPtrC component; |
|
72 switch(aComponent) |
|
73 { |
|
74 case EContactStoreUriAllComponents: |
|
75 { |
|
76 component.Set(iUriBufferPointer); |
|
77 } |
|
78 break; |
|
79 case EContactStoreUriStoreType: |
|
80 { |
|
81 const TInt offset = iUriBufferPointer.Find(KDomainStoreSeparator); |
|
82 if (offset != KErrNotFound) |
|
83 { |
|
84 component.Set(iUriBufferPointer.Left(offset)); |
|
85 } |
|
86 } |
|
87 break; |
|
88 case EContactStoreUriStoreDrive: |
|
89 { |
|
90 const TPtrC nonDomain = iUriBufferPointer.Right( |
|
91 iUriBufferPointer.Length()-(iUriBufferPointer.Find(KDomainStoreSeparator)+ |
|
92 KDomainStoreSeparator().Length())); |
|
93 const TInt offset = nonDomain.Locate( KDriveSeparator()[0] ); |
|
94 if (offset == KErrNotFound) |
|
95 { |
|
96 component.Set(KNullDesC); |
|
97 } |
|
98 else |
|
99 { |
|
100 component.Set(nonDomain.Left(offset)); |
|
101 } |
|
102 } |
|
103 break; |
|
104 case EContactStoreUriStoreLocation: |
|
105 { |
|
106 TInt offset = iUriBufferPointer.Find(KDomainStoreSeparator); |
|
107 if (offset != KErrNotFound) |
|
108 { |
|
109 offset += KDomainStoreSeparator().Length(); |
|
110 component.Set(iUriBufferPointer.Mid(offset)); |
|
111 } |
|
112 } |
|
113 break; |
|
114 } |
|
115 return component; |
|
116 } |
|
117 |
|
118 EXPORT_C void TVPbkContactStoreUriPtr::Set(const TVPbkContactStoreUriPtr& aUri) |
|
119 { |
|
120 iUriBufferPointer.Set(aUri.UriDes()); |
|
121 } |
|
122 |
|
123 EXPORT_C TInt TVPbkContactStoreUriPtr::Length() const |
|
124 { |
|
125 return iUriBufferPointer.Length(); |
|
126 } |
|
127 |
|
128 // -------------------------------------------------------------------------- |
|
129 // TVPbkContactStoreUriPtr::ExternalizeL |
|
130 // TVPbkContactStoreUriPtr pack: |
|
131 // |
|
132 // URILength = TInt16 |
|
133 // URIDescriptor= char* |
|
134 // -------------------------------------------------------------------------- |
|
135 // |
|
136 EXPORT_C void TVPbkContactStoreUriPtr::ExternalizeL(RWriteStream& aStream) const |
|
137 { |
|
138 aStream.WriteInt16L(iUriBufferPointer.Length()); // URI length |
|
139 aStream.WriteL(iUriBufferPointer, iUriBufferPointer.Length()); // URI descriptor |
|
140 } |
|
141 |
|
142 EXPORT_C TInt TVPbkContactStoreUriPtr::ExternalizedSize() const |
|
143 { |
|
144 // Reserve space for length information, |
|
145 return sizeof(TInt16) + iUriBufferPointer.Size(); |
|
146 } |
|
147 |
|
148 // End of file |