sl@0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// Internal classes for PREQ748 - Adding support for the SIP scheme in URIs.
|
sl@0
|
15 |
// Classes for validating URIs according to their scheme
|
sl@0
|
16 |
// File contains internal classes for validatin URIs according to
|
sl@0
|
17 |
// their scheme type
|
sl@0
|
18 |
//
|
sl@0
|
19 |
//
|
sl@0
|
20 |
|
sl@0
|
21 |
/**
|
sl@0
|
22 |
@file TValidator.h
|
sl@0
|
23 |
@see Uri8.h
|
sl@0
|
24 |
*/
|
sl@0
|
25 |
|
sl@0
|
26 |
#ifndef __TVALIDATOR_H__
|
sl@0
|
27 |
#define __TVALIDATOR_H__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <uri8.h>
|
sl@0
|
30 |
#include <delimitedparser8.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
// Constants
|
sl@0
|
33 |
//
|
sl@0
|
34 |
_LIT8(KAlwaysValidChars, "-_.!~*'");
|
sl@0
|
35 |
_LIT8(KCommonValidChars, "()/+$");
|
sl@0
|
36 |
_LIT8(KValidUserChars, "=,;?&");
|
sl@0
|
37 |
_LIT8(KValidParamChars, "[]:&");
|
sl@0
|
38 |
_LIT8(KValidHeaderChars, "[]:?");
|
sl@0
|
39 |
_LIT8(KUriAlwaysValidSipMarkChars, "-_.!~*'()");
|
sl@0
|
40 |
_LIT8(KUriValidSipPwdChars, "&=+$,");
|
sl@0
|
41 |
_LIT8(KUriValidSipToken, "%+`");
|
sl@0
|
42 |
|
sl@0
|
43 |
const TUint32 KCharSetNumber = 0x001;
|
sl@0
|
44 |
const TUint32 KCharSetLowerAlpha = 0x002;
|
sl@0
|
45 |
const TUint32 KCharSetUpperAlpha = 0x004;
|
sl@0
|
46 |
const TUint32 KCharSetAlways = 0x008;
|
sl@0
|
47 |
const TUint32 KCharSetCommon = 0x010;
|
sl@0
|
48 |
const TUint32 KCharSetUser = 0x020;
|
sl@0
|
49 |
const TUint32 KCharSetParam = 0x040;
|
sl@0
|
50 |
const TUint32 KCharSetHeader = 0x080;
|
sl@0
|
51 |
const TUint32 KCharSetSipMark = 0x100;
|
sl@0
|
52 |
const TUint32 KCharSetSipPwd = 0x200;
|
sl@0
|
53 |
const TUint32 KCharSetSipTkn = 0x400;
|
sl@0
|
54 |
const TUint32 KCharSetAlphnumberic = KCharSetNumber | KCharSetLowerAlpha | KCharSetUpperAlpha;
|
sl@0
|
55 |
const TUint32 KCharSetUserAll = KCharSetUser | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
|
sl@0
|
56 |
const TUint32 KCharSetParamAll = KCharSetParam | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
|
sl@0
|
57 |
const TUint32 KCharSetHeaderAll = KCharSetHeader | KCharSetAlphnumberic | KCharSetAlways | KCharSetCommon;
|
sl@0
|
58 |
const TUint32 KCharSetSipPassWord = KCharSetAlphnumberic| KCharSetSipPwd | KCharSetSipMark ;
|
sl@0
|
59 |
const TUint32 KCharSetSipToken = KCharSetAlphnumberic| KCharSetAlways | KCharSetSipTkn;
|
sl@0
|
60 |
|
sl@0
|
61 |
/**
|
sl@0
|
62 |
Comments : This class provides Base functionality for Validation of an URI.
|
sl@0
|
63 |
which needs to be overridden by derived classes for validation Based on their RFC
|
sl@0
|
64 |
specifications.
|
sl@0
|
65 |
|
sl@0
|
66 |
@internalComponent
|
sl@0
|
67 |
@released
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
class TValidatorBase
|
sl@0
|
70 |
{
|
sl@0
|
71 |
public:
|
sl@0
|
72 |
TValidatorBase(const TUriC8& aUri);
|
sl@0
|
73 |
TInt Validate();
|
sl@0
|
74 |
|
sl@0
|
75 |
protected:
|
sl@0
|
76 |
// Implemented by derived validator classes
|
sl@0
|
77 |
virtual TBool IsValidUserInfo() const = 0;
|
sl@0
|
78 |
virtual TBool IsValidHost() const = 0;
|
sl@0
|
79 |
virtual TBool IsValidPort() const = 0;
|
sl@0
|
80 |
virtual TBool IsValidPath() const = 0;
|
sl@0
|
81 |
virtual TBool IsValidQuery() const = 0;
|
sl@0
|
82 |
virtual TBool IsValidFragment() const = 0;
|
sl@0
|
83 |
|
sl@0
|
84 |
// general utility methods
|
sl@0
|
85 |
TBool IsValidCharacters(const TDesC8& aDes, TUint32 aCharTypes, TBool aEscapeValid = EFalse) const;
|
sl@0
|
86 |
TBool IsEmpty(const TDesC8& aDes) const;
|
sl@0
|
87 |
|
sl@0
|
88 |
private:
|
sl@0
|
89 |
TBool IsInCharSet(TText8 aChar, const TDesC8& aCharSet) const;
|
sl@0
|
90 |
|
sl@0
|
91 |
protected:
|
sl@0
|
92 |
const TUriC8& iUri;
|
sl@0
|
93 |
};
|
sl@0
|
94 |
|
sl@0
|
95 |
/**
|
sl@0
|
96 |
Dependencies : TValidatorBase.
|
sl@0
|
97 |
Comments : This class provides Sip Uri Validation functinality.
|
sl@0
|
98 |
This is implemented as specified in RFC 3261.
|
sl@0
|
99 |
|
sl@0
|
100 |
@internalComponent
|
sl@0
|
101 |
@released
|
sl@0
|
102 |
*/
|
sl@0
|
103 |
class TValidatorSip: public TValidatorBase
|
sl@0
|
104 |
{
|
sl@0
|
105 |
public:
|
sl@0
|
106 |
TValidatorSip(const TUriC8& aUri);
|
sl@0
|
107 |
private:
|
sl@0
|
108 |
// from TValidatorBase
|
sl@0
|
109 |
TBool IsValidUserInfo() const;
|
sl@0
|
110 |
TBool IsValidHost() const;
|
sl@0
|
111 |
TBool IsValidPort() const;
|
sl@0
|
112 |
TBool IsValidPath() const;
|
sl@0
|
113 |
TBool IsValidQuery() const;
|
sl@0
|
114 |
TBool IsValidFragment() const;
|
sl@0
|
115 |
|
sl@0
|
116 |
// supporting methods for the above
|
sl@0
|
117 |
TBool IsValidUser(const TDesC8& aUser) const;
|
sl@0
|
118 |
TBool IsValidPassword(const TDesC8& aPassword) const;
|
sl@0
|
119 |
TBool IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const;
|
sl@0
|
120 |
TBool IsValidParam(const TDesC8& aParam) const;
|
sl@0
|
121 |
TBool IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const;
|
sl@0
|
122 |
TBool IsValidHeader(const TDesC8& aHeader) const;
|
sl@0
|
123 |
TBool IsValidHeaderSegment(const TDesC8& aName, const TDesC8& aValue) const;
|
sl@0
|
124 |
TBool IsValidParamToken(const TDesC8& aParam) const;
|
sl@0
|
125 |
TBool IsValidParamTtl(const TDesC8& aParam) const;
|
sl@0
|
126 |
TBool IsValidParamMaddr(const TDesC8& aParam) const;
|
sl@0
|
127 |
};
|
sl@0
|
128 |
|
sl@0
|
129 |
/**
|
sl@0
|
130 |
Dependencies : TValidatorBase.
|
sl@0
|
131 |
Comments : This class provides Tel Uri Validation functinality.
|
sl@0
|
132 |
Only Partial support for tel-Uris specified in RFC 3966.
|
sl@0
|
133 |
section 5 of RFC 3966 is not supported.
|
sl@0
|
134 |
@internalComponent
|
sl@0
|
135 |
@released
|
sl@0
|
136 |
*/
|
sl@0
|
137 |
class TValidatorTel: public TValidatorBase
|
sl@0
|
138 |
{
|
sl@0
|
139 |
public:
|
sl@0
|
140 |
TValidatorTel(const TUriC8& aUri);
|
sl@0
|
141 |
private:
|
sl@0
|
142 |
// from TValidatorBase
|
sl@0
|
143 |
TBool IsValidUserInfo() const;
|
sl@0
|
144 |
TBool IsValidHost() const;
|
sl@0
|
145 |
TBool IsValidPort() const;
|
sl@0
|
146 |
TBool IsValidPath() const;
|
sl@0
|
147 |
TBool IsValidQuery() const;
|
sl@0
|
148 |
TBool IsValidFragment() const;
|
sl@0
|
149 |
|
sl@0
|
150 |
// supporting methods for the above
|
sl@0
|
151 |
TBool IsDuplicated(const TDesC8& aParamName, const TDelimitedParserBase8 aParamList) const;
|
sl@0
|
152 |
TBool IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const;
|
sl@0
|
153 |
};
|
sl@0
|
154 |
|
sl@0
|
155 |
#endif // __TVALIDATOR_H__
|