|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : ChatSdpAttributeParser.h 00004 * Part of : Chat 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2005-2006 Nokia Corporation. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia Corporation. 00013 * ============================================================================== 00014 */ 00015 00016 #ifndef CHATSDPATTRIBUTEPARSER_H 00017 #define CHATSDPATTRIBUTEPARSER_H 00018 00019 // INCLUDES 00020 #include <btsdp.h> 00021 00022 // FORWARD DECLARATIONS 00023 class MChatSdpAttributeNotifier; 00024 00025 // CLASS DECLARATIONS 00026 /** 00027 * TChatSdpAttributeParser 00028 * An instance of TChatSdpAttributeParser is used to check an SDP 00029 * attribute value, and read selected parts 00030 */ 00031 class TChatSdpAttributeParser : public MSdpAttributeValueVisitor 00032 { 00033 public: // Enumerations 00034 00035 /** 00036 * TNodeCommand 00037 * The command to be carried out at a node 00038 * ECheckType. Check the type of the value 00039 * ECheckValue. Check the type and the value 00040 * ECheckEnd. Check that a list ends at this point 00041 * ESkip. Do not check this value - can not match a list end 00042 * EReadValue. Pass the value onto the observer 00043 * EFinished. Marks the end of the node list 00044 */ 00045 enum TNodeCommand 00046 { 00047 ECheckType, 00048 ECheckValue, 00049 ECheckEnd, 00050 ESkip, 00051 EReadValue, 00052 EFinished 00053 }; 00054 00055 /** 00056 * TChatSdpAttributeNode 00057 * An instance of TChatSdpAttributeNode is used to determine how 00058 * to parse an SDP attribute value data element 00059 */ 00060 class TChatSdpAttributeNode 00061 { 00062 public: 00063 00064 /** 00065 * TChatSdpAttributeNode 00066 * Construct a TChatSdpAttributeNode 00067 */ 00068 TChatSdpAttributeNode(); 00069 00070 /** 00071 * ~TChatSdpAttributeNode 00072 * destructor 00073 */ 00074 ~TChatSdpAttributeNode(); 00075 00076 /** 00077 * SetCommand 00078 * set value of iCommand member variable, 00079 * iCommand is the command for the node 00080 * @param aCommand the value of the iCommand 00081 */ 00082 void SetCommand( TNodeCommand aCommand ); 00083 00084 /** 00085 * SetType 00086 * set value of iType member variable 00087 * iType is the expected type 00088 * @param aType the value of the iType 00089 */ 00090 void SetType( TSdpElementType aType ); 00091 00092 /** 00093 * SetValue 00094 * set value of iValue member variable, 00095 * iValue the expected value for ECheckValue,the value of aKey 00096 * passed to the observer for EReadValue 00097 * @param aValue the value of the iValue 00098 */ 00099 void SetValue( TInt aValue ); 00100 00101 /** 00102 * Command 00103 * get value of iCommand member variable 00104 * @return the value of the iCommand 00105 */ 00106 TNodeCommand Command() const; 00107 00108 /** 00109 * Type 00110 * get value of iType member variable 00111 * @return the value of the iType 00112 */ 00113 TSdpElementType Type() const; 00114 00115 /** 00116 * Value 00117 * get value of iValue member variable 00118 * @return the value of the iValue 00119 */ 00120 TInt Value() const; 00121 00122 private: 00123 00124 /** 00125 * iCommand the command for the node 00126 */ 00127 TNodeCommand iCommand; 00128 00129 /** 00130 * iType the expected type 00131 */ 00132 TSdpElementType iType; 00133 00134 /** 00135 * iValue the expected value for ECheckValue,the value of aKey 00136 * passed to the observer for EReadValue 00137 */ 00138 TInt iValue; 00139 }; 00140 00141 00142 /** 00143 * TChatSdpAttributeParser 00144 * Construct a TChatSdpAttributeParser 00145 * @param aNodeList the list of expected nodes 00146 * @param aObserver an observer to read specified node values 00147 */ 00148 TChatSdpAttributeParser( 00149 RArray<TChatSdpAttributeParser::TChatSdpAttributeNode>& aNodeList, 00150 MChatSdpAttributeNotifier& aObserver ); 00151 00152 /** 00153 * ~TChatSdpAttributeParser 00154 * Destructor 00155 */ 00156 virtual ~TChatSdpAttributeParser(); 00157 00158 /** 00159 * HasFinished 00160 * Check if parsing processed the whole list 00161 * @return true is the index refers to the EFinished node 00162 */ 00163 TBool HasFinished() const; 00164 00165 public: // from MSdpAttributeValueVisitor 00166 00167 /** 00168 * VisitAttributeValueL 00169 * Process a data element 00170 * @param aValue the data element 00171 * @param aType the type of the data element 00172 */ 00173 void VisitAttributeValueL( CSdpAttrValue& aValue, 00174 TSdpElementType aType ); 00175 00176 /** 00177 * StartListL 00178 * Process the start of a data element list 00179 * @param aList the data element list 00180 */ 00181 void StartListL( CSdpAttrValueList& aList ); 00182 00183 /** 00184 * EndListL 00185 * Process the end of a data element list 00186 */ 00187 void EndListL(); 00188 00189 private: // Functions from base classes 00190 00191 /** 00192 * CheckTypeL 00193 * Check the type of the current node is the same as 00194 * the specified type. 00195 * @param aElementType the type of the current data element 00196 */ 00197 void CheckTypeL( TSdpElementType aElementType ) const; 00198 00199 /** 00200 * CheckValueL 00201 * Check the value of the current node is the same as the specified value 00202 * @param aValue the value of the current data element. 00203 */ 00204 void CheckValueL( CSdpAttrValue& aValue ) const; 00205 00206 /** 00207 * ReadValueL 00208 * Pass the data element value to the observer 00209 * @param aValue the value of the current data element. 00210 */ 00211 void ReadValueL( CSdpAttrValue& aValue ) const; 00212 00213 /** 00214 * AdvanceL 00215 * Advance to the next node. Leaves with KErrEof 00216 * if at the finished node. 00217 */ 00218 void AdvanceL(); 00219 00220 private: // data 00221 00222 /** 00223 * iObserver the observer to read values 00224 */ 00225 MChatSdpAttributeNotifier& iObserver; 00226 00227 /** 00228 * iNodeList a list defining the expected 00229 * structure of the value 00230 */ 00231 RArray<TChatSdpAttributeParser::TChatSdpAttributeNode>& iNodeList; 00232 00233 /** 00234 * iCurrentNodeIndex the index of the current node in iNodeList 00235 */ 00236 TInt iCurrentNodeIndex; 00237 00238 /** 00239 * iCurrentNode the current node 00240 */ 00241 TChatSdpAttributeNode iCurrentNode; 00242 }; 00243 00244 00245 00246 #endif // CHATSDPATTRIBUTEPARSER_H 00247 00248 // End of File
|
© Nokia 2006 |