|
1 // Copyright (c) 2006-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 @publishedPartner |
|
19 @released |
|
20 */ |
|
21 |
|
22 #ifndef CMTPTYPESTRING_H |
|
23 #define CMTPTYPESTRING_H |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <mtp/mmtptype.h> |
|
27 |
|
28 /** |
|
29 Defines the MTP string data type. MTP strings consist of standard 2-byte |
|
30 Unicode characters and are null-terminated. Strings are prepended with a |
|
31 single 8-bit unsigned integer that identifies the number of characters (NOT |
|
32 bytes) to follow and includes the terminating null value. Strings are limited |
|
33 to 255 characters (including the null value). An empty string would consist |
|
34 of a single 8-bit integer containing the value 0x00. |
|
35 |
|
36 MTP strings are stored in a flat buffer to optimise streaming performance |
|
37 to/from the MTP transport connection. |
|
38 @publishedPartner |
|
39 @released |
|
40 */ |
|
41 class CMTPTypeString : public CBase, public MMTPType |
|
42 { |
|
43 public: |
|
44 |
|
45 IMPORT_C static CMTPTypeString* NewL(); |
|
46 IMPORT_C static CMTPTypeString* NewL(const TDesC& aString); |
|
47 IMPORT_C static CMTPTypeString* NewLC(); |
|
48 IMPORT_C static CMTPTypeString* NewLC(const TDesC& aString); |
|
49 IMPORT_C ~CMTPTypeString(); |
|
50 |
|
51 IMPORT_C TUint8 NumChars() const; |
|
52 IMPORT_C const TDesC& StringChars() const; |
|
53 |
|
54 IMPORT_C void SetL(const TDesC& aString); |
|
55 |
|
56 public: // From MMTPType |
|
57 |
|
58 IMPORT_C TInt FirstReadChunk(TPtrC8& aChunk) const; |
|
59 IMPORT_C TInt NextReadChunk(TPtrC8& aChunk) const; |
|
60 IMPORT_C TInt FirstWriteChunk(TPtr8& aChunk); |
|
61 IMPORT_C TInt NextWriteChunk(TPtr8& aChunk); |
|
62 IMPORT_C TUint64 Size() const; |
|
63 IMPORT_C TUint Type() const; |
|
64 IMPORT_C TBool CommitRequired() const; |
|
65 IMPORT_C MMTPType* CommitChunkL(TPtr8& aChunk); |
|
66 IMPORT_C TInt Validate() const; |
|
67 |
|
68 private: |
|
69 |
|
70 CMTPTypeString(); |
|
71 void ConstructL(const TDesC& aString); |
|
72 |
|
73 void ReAllocBufferL(TUint aNumNullTerminatedChars); |
|
74 |
|
75 private: // Owned |
|
76 |
|
77 /** |
|
78 The write data stream states. |
|
79 */ |
|
80 enum TWriteSequenceState |
|
81 { |
|
82 /** |
|
83 Write data stream inactive. |
|
84 */ |
|
85 EIdle, |
|
86 |
|
87 /** |
|
88 Streaming the NumChars data chunk. |
|
89 */ |
|
90 ENumChars, |
|
91 |
|
92 /** |
|
93 Streaming the String Characters data chunk. |
|
94 */ |
|
95 EStringChars |
|
96 }; |
|
97 |
|
98 /** |
|
99 The data buffer. |
|
100 */ |
|
101 RBuf8 iBuffer; |
|
102 |
|
103 /** |
|
104 The String Characters data pointer. |
|
105 */ |
|
106 TPtr iStringChars; |
|
107 |
|
108 /** |
|
109 The write data stream state variable. |
|
110 */ |
|
111 TUint iWriteSequenceState; |
|
112 |
|
113 /** |
|
114 The String type's validation state. |
|
115 */ |
|
116 TInt iValidationState; |
|
117 }; |
|
118 |
|
119 #endif // CMTPTYPESTRING_H |