|
1 /* |
|
2 * Copyright (c) 2004-2005 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: Message containing text. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "CCATextMessage.h" |
|
20 #include <stringloader.h> |
|
21 #include <caengineNG.rsg> |
|
22 |
|
23 //----------------------------------------------------------------------------- |
|
24 // CCATextMessage::CCATextMessage |
|
25 // ( Other items commented in header ) |
|
26 //----------------------------------------------------------------------------- |
|
27 CCATextMessage::CCATextMessage() |
|
28 { |
|
29 } |
|
30 |
|
31 //----------------------------------------------------------------------------- |
|
32 // CCATextMessage::~CCATextMessage |
|
33 // ( Other items commented in header ) |
|
34 //----------------------------------------------------------------------------- |
|
35 CCATextMessage::~CCATextMessage() |
|
36 { |
|
37 } |
|
38 |
|
39 //----------------------------------------------------------------------------- |
|
40 // CCATextMessage::NewL |
|
41 // ( Other items commented in header ) |
|
42 //----------------------------------------------------------------------------- |
|
43 CCATextMessage* CCATextMessage::NewL( TInt aOpCode, |
|
44 const TDesC& aSender, |
|
45 const TDesC& aRecipient, |
|
46 const MDesCArray* aRecipients, |
|
47 const MDesCArray* aScreenNames, |
|
48 const TDesC& aData ) |
|
49 { |
|
50 CCATextMessage* self = CCATextMessage::NewLC( aOpCode, aSender, aRecipient, aRecipients, aScreenNames, aData ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 //----------------------------------------------------------------------------- |
|
56 // CCATextMessage::NewL |
|
57 // ( Other items commented in header ) |
|
58 //----------------------------------------------------------------------------- |
|
59 CCATextMessage* CCATextMessage::NewL() |
|
60 { |
|
61 return CCATextMessage::NewL( 0, KNullDesC, KNullDesC, NULL, NULL, KNullDesC ); |
|
62 } |
|
63 |
|
64 //----------------------------------------------------------------------------- |
|
65 // CCATextMessage::NewLC |
|
66 // ( Other items commented in header ) |
|
67 //----------------------------------------------------------------------------- |
|
68 CCATextMessage* CCATextMessage::NewLC( TInt aOpCode, |
|
69 const TDesC& aSender, |
|
70 const TDesC& aRecipient, |
|
71 const MDesCArray* aRecipients, |
|
72 const MDesCArray* aScreenNames, |
|
73 const TDesC& aData ) |
|
74 { |
|
75 CCATextMessage* self = new ( ELeave ) CCATextMessage(); |
|
76 CleanupStack::PushL( self ); |
|
77 self->ConstructL( aData ); |
|
78 self->CCAMessageBase::ConstructL( aOpCode, aSender, aRecipient, aRecipients, aScreenNames ); |
|
79 return self; |
|
80 } |
|
81 |
|
82 //----------------------------------------------------------------------------- |
|
83 // CCATextMessage::ConstructL |
|
84 // ( Other items commented in header ) |
|
85 //----------------------------------------------------------------------------- |
|
86 void CCATextMessage::ConstructL( const TDesC& aData ) |
|
87 { |
|
88 iText = aData.AllocL(); |
|
89 } |
|
90 |
|
91 //----------------------------------------------------------------------------- |
|
92 // CCATextMessage::SizeInBytes |
|
93 // ( Other items commented in header ) |
|
94 //----------------------------------------------------------------------------- |
|
95 TInt CCATextMessage::SizeInBytes() const |
|
96 { |
|
97 return CCAMessageBase::SizeInBytes() + |
|
98 iText->Size() + |
|
99 sizeof( *this ); |
|
100 } |
|
101 |
|
102 //----------------------------------------------------------------------------- |
|
103 // CCATextMessage::ContentType |
|
104 // ( Other items commented in header ) |
|
105 //----------------------------------------------------------------------------- |
|
106 MCAMessage::TContentType CCATextMessage::ContentType() const |
|
107 { |
|
108 return EContentText; |
|
109 } |
|
110 |
|
111 //----------------------------------------------------------------------------- |
|
112 // CCATextMessage::SetFailed |
|
113 // ( Other items commented in header ) |
|
114 //----------------------------------------------------------------------------- |
|
115 void CCATextMessage::SetFailedL() |
|
116 { |
|
117 SetFailed(); |
|
118 |
|
119 CDesCArray* array = new( ELeave )CDesCArrayFlat( 2 ); // two items |
|
120 CleanupStack::PushL( array ); |
|
121 |
|
122 array->AppendL( KNullDesC ); |
|
123 array->AppendL( *iText ); |
|
124 |
|
125 // %0U Failed: %1U string is used |
|
126 HBufC* failed = StringLoader::LoadLC( R_CHATCLIENT_MESSAGE_FAILED, *array ); |
|
127 HBufC* temp = HBufC::NewLC( failed->Length() ); |
|
128 TPtr tempPtr( temp->Des() ); |
|
129 tempPtr.Zero(); |
|
130 tempPtr.Append( *failed ); |
|
131 CleanupStack::Pop( temp ); |
|
132 CleanupStack::PopAndDestroy( 2, array ); |
|
133 delete iText; |
|
134 iText = temp; |
|
135 } |
|
136 |
|
137 |
|
138 // end of file |