24
|
1 |
// Copyright (c) 1997-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 |
// Implements the class TSmsAddr
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
/**
|
|
19 |
@file
|
|
20 |
*/
|
|
21 |
|
|
22 |
#include "smsumain.h"
|
|
23 |
#include "smsuaddr.H"
|
|
24 |
#include "smsstacklog.h"
|
|
25 |
|
|
26 |
|
|
27 |
/**
|
|
28 |
* Constructor.
|
|
29 |
* @capability None
|
|
30 |
*/
|
|
31 |
EXPORT_C TSmsAddr::TSmsAddr()
|
|
32 |
{
|
|
33 |
SetSmsAddrFamily(ESmsAddrUnbound);
|
|
34 |
}
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Gets the SMS address family.
|
|
39 |
*
|
|
40 |
* @return SMS address family
|
|
41 |
* @capability None
|
|
42 |
*/
|
|
43 |
EXPORT_C TSmsAddrFamily TSmsAddr::SmsAddrFamily() const
|
|
44 |
{
|
|
45 |
LOGSMSU1("TSmsAddr::SmsAddrFamily()");
|
|
46 |
|
|
47 |
return static_cast<TSmsAddrFamily>(Family());
|
|
48 |
} // TSmsAddr::SmsAddrFamily
|
|
49 |
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Sets the SMS address family.
|
|
53 |
*
|
|
54 |
* @param aFamily SMS address family
|
|
55 |
* @capability None
|
|
56 |
*/
|
|
57 |
EXPORT_C void TSmsAddr::SetSmsAddrFamily(TSmsAddrFamily aFamily)
|
|
58 |
{
|
|
59 |
LOGSMSU1("TSmsAddr::SetSmsAddrFamily()");
|
|
60 |
|
|
61 |
SetFamily(static_cast<TUint>(aFamily));
|
|
62 |
} // TSmsAddr::SetSmsAddrFamily
|
|
63 |
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Gets the identifier match.
|
|
67 |
*
|
|
68 |
* @return Identifier match
|
|
69 |
* @capability None
|
|
70 |
*/
|
|
71 |
EXPORT_C TInt TSmsAddr::IdentifierMatch() const
|
|
72 |
{
|
|
73 |
LOGSMSU1("TSmsAddr::IdentifierMatch()");
|
|
74 |
|
|
75 |
__ASSERT_DEBUG(SmsAddrFamily()==ESmsAddrMatchIEI,SmsuPanic(ESmsuPanicWrongSmsAddressFamily));
|
|
76 |
return (TInt) Port();
|
|
77 |
} // TSmsAddr::IdentifierMatch
|
|
78 |
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Sets the identifier match.
|
|
82 |
*
|
|
83 |
* @param aIdentifier Identifier match
|
|
84 |
* @capability None
|
|
85 |
*/
|
|
86 |
EXPORT_C void TSmsAddr::SetIdentifierMatch(TInt aIdentifier)
|
|
87 |
{
|
|
88 |
LOGSMSU1("TSmsAddr::SetIdentifierMatch()");
|
|
89 |
|
|
90 |
__ASSERT_DEBUG(SmsAddrFamily()==ESmsAddrMatchIEI,SmsuPanic(ESmsuPanicWrongSmsAddressFamily));
|
|
91 |
SetPort((TUint) aIdentifier);
|
|
92 |
} // TSmsAddr::SetIdentifierMatch
|
|
93 |
|
|
94 |
|
|
95 |
/**
|
|
96 |
* Gets the matched text.
|
|
97 |
*
|
|
98 |
* @return The match text
|
|
99 |
* @capability None
|
|
100 |
*/
|
|
101 |
EXPORT_C TPtrC8 TSmsAddr::TextMatch() const
|
|
102 |
{
|
|
103 |
LOGSMSU1("TSmsAddr::TextMatch()");
|
|
104 |
|
|
105 |
__ASSERT_DEBUG(SmsAddrFamily()==ESmsAddrMatchText,SmsuPanic(ESmsuPanicWrongSmsAddressFamily));
|
|
106 |
return TPtrC8(UserPtr(),const_cast<TSmsAddr*>(this)->GetUserLen());
|
|
107 |
} // TSmsAddr::TextMatch
|
|
108 |
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Sets the match text.
|
|
112 |
*
|
|
113 |
* @param aText The match text
|
|
114 |
* @capability None
|
|
115 |
*/
|
|
116 |
EXPORT_C void TSmsAddr::SetTextMatch(const TDesC8& aText)
|
|
117 |
{
|
|
118 |
LOGSMSU1("TSmsAddr::SetTextMatch()");
|
|
119 |
|
|
120 |
__ASSERT_DEBUG(SmsAddrFamily()==ESmsAddrMatchText,SmsuPanic(ESmsuPanicWrongSmsAddressFamily));
|
|
121 |
TUint8* target = UserPtr();
|
|
122 |
TInt length = aText.Length()<=EMaxTextMatchLength ? aText.Length() : EMaxTextMatchLength;
|
|
123 |
Mem::Copy(target,aText.Ptr(),length);
|
|
124 |
SetUserLen(length);
|
|
125 |
} // TSmsAddr::SetTextMatch
|
|
126 |
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Equality operator.
|
|
130 |
*
|
|
131 |
* @param aAddr Address to compare with
|
|
132 |
* @return ETrue if the addresses match
|
|
133 |
* @capability None
|
|
134 |
*/
|
|
135 |
EXPORT_C TBool TSmsAddr::operator==(const TSmsAddr& aAddr) const
|
|
136 |
{
|
|
137 |
LOGSMSU1("TSmsAddr::operator=()");
|
|
138 |
|
|
139 |
TSmsAddrFamily family=aAddr.SmsAddrFamily();
|
|
140 |
TBool same=(SmsAddrFamily()==family);
|
|
141 |
if (same)
|
|
142 |
switch(family)
|
|
143 |
{
|
|
144 |
case ESmsAddrUnbound:
|
|
145 |
case ESmsAddrSendOnly:
|
|
146 |
case ESmsAddrLocalOperation:
|
|
147 |
{
|
|
148 |
same=EFalse;
|
|
149 |
break;
|
|
150 |
}
|
|
151 |
case ESmsAddrRecvAny:
|
|
152 |
case ESmsAddrMessageIndication:
|
|
153 |
case ESmsAddrStatusReport:
|
|
154 |
case ESmsAddrEmail:
|
|
155 |
break;
|
|
156 |
case ESmsAddrMatchIEI:
|
|
157 |
{
|
|
158 |
same=(IdentifierMatch()==aAddr.IdentifierMatch());
|
|
159 |
break;
|
|
160 |
}
|
|
161 |
case ESmsAddrMatchText:
|
|
162 |
{
|
|
163 |
same=(!TextMatch().CompareF(aAddr.TextMatch()));
|
|
164 |
break;
|
|
165 |
}
|
|
166 |
case ESmsAddrApplication8BitPort:
|
|
167 |
case ESmsAddrApplication16BitPort:
|
|
168 |
{
|
|
169 |
same=(aAddr.Port()==Port());
|
|
170 |
break;
|
|
171 |
}
|
|
172 |
default:
|
|
173 |
SmsuPanic(ESmsuPanicAddrFamilyNotAllowed);
|
|
174 |
}
|
|
175 |
|
|
176 |
return same;
|
|
177 |
} // TSmsAddr::operator=
|