messagingfw/biomsgfw/wappinc/wapp.h
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 1999-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 // Header file for the WAP Access Point Parser
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __WAPP_H__
       
    19 #define __WAPP_H__
       
    20 
       
    21 
       
    22 #include <bsp.h>
       
    23 #include <commsdattypesv1_1.h>
       
    24 #include <commsdat.h>
       
    25 using namespace CommsDat;
       
    26 #include <cdbcols.h>
       
    27 #include <cdblen.h>
       
    28 #include <charconv.h>
       
    29 
       
    30 class MMsvAttachmentManager;
       
    31 class MMsvAttachmentManagerSync;
       
    32 
       
    33 #define BIO_MSG_ENTRY_UNPARSED	 0 // iMtmData3=0 - an untouched, a virgin message entry!
       
    34 #define BIO_MSG_ENTRY_PARSED	 1 // iMtmData3=1 - entry parsed and externalised (has a store)
       
    35 #define BIO_MSG_ENTRY_PROCESSED	 2 // iMtmData3=2 - entry been parsed,externalised and processed
       
    36 
       
    37 
       
    38 _LIT8(KDummyModemInitStr, "Modem Init String - final version to be decided!!!");
       
    39 _LIT(KWapDefaultSettingsName, "WAP Settings");
       
    40 _LIT(KWappDefaultBMName, "Unknown Bookmark"); // Default name for a bookmark.
       
    41 _LIT(KWappDll, "KWAPP-DLL");
       
    42 
       
    43 const TInt KGsmCsdSuffixLen = 8;
       
    44 _LIT(KGsmCsdSuffix, "-GsmCsd");	// Suffix - append to Settings Name for Gsm/Csd ISP/IAP entry
       
    45 _LIT(KGsmUssdSuffix, "-GsmUssd");	// Suffix - append to Settings Name for Gsm/Ussd ISP/IAP entry
       
    46 _LIT(KIS136CsdSuffix, "-Is136Csd"); // Suffix - append to Settings Name for IS136/Csd ISP/IAP entry
       
    47 _LIT(KGprsSuffix, "-Gprs"); // Suffix - append to Settings Name for GPRS ISP/IAP entry
       
    48 
       
    49 
       
    50 enum TWappPanic  // Assert Debug panic codes
       
    51 	{
       
    52 	EWappLimitsExceeded,
       
    53 	EWappErrMessageProcessed,
       
    54 	EWappEmptyBuffer,
       
    55 	EWappInvalidEntry,
       
    56 	EWappNullPointer
       
    57 	};
       
    58 /*
       
    59 enum TBearer
       
    60 	{
       
    61 	EAll,
       
    62 	EIP,
       
    63 	ESMS7,
       
    64 	ESMS
       
    65 	};
       
    66 */
       
    67 enum TCsdCallType
       
    68 	{
       
    69 	EAnalogue,
       
    70 	EIsdn
       
    71 	};
       
    72 
       
    73 enum TCsdCallSpeed
       
    74 	{
       
    75 	EAutobauding,
       
    76 	E9600baud,
       
    77 	E14400baud,
       
    78 	E19200baud,
       
    79 	E28800baud,
       
    80 	E38400baud,
       
    81 	E43200baud,
       
    82 	E57600baud
       
    83 	};
       
    84 
       
    85 
       
    86 // Forward declarations
       
    87 class RResourceFile;
       
    88 class CRichText;
       
    89 class CCommsDatabase;
       
    90 class CCommsDbTableView;
       
    91 class CIspTableData;
       
    92 class TBearerSpeed;
       
    93 class CWappBookmark;
       
    94 class CWapIpBearerData;
       
    95 class CWapSmsBearerData;
       
    96 class CWapGprsBearerData;
       
    97 class CWapCharsetConverter;
       
    98 
       
    99 class CMsvBIOWapAccessParser : public CBaseScriptParser2
       
   100 /**
       
   101 @internalComponent
       
   102 @released
       
   103 */
       
   104     {
       
   105 // Enum and inline class defines
       
   106 private:
       
   107     enum TParseSession
       
   108         { 
       
   109 		EStart,				// Don't do anything-just check message not empty & set Scheduler going
       
   110         EUnfoldMessage,     //  Don't have to unfold the message, just save it
       
   111         EParseMessage,      //  Parsing 
       
   112 		EProcessInitialise,	//  Start ProcessL - restore data if necessary, PreProcess and Validate it 
       
   113 		EProcessMessage,	//	Actual Processing of message data
       
   114         ECompleteMessage    //  Completing ..
       
   115         };
       
   116 
       
   117 	enum TWappBearerType
       
   118 		{
       
   119 		EWappUnknownBearer,
       
   120 		EWappGsmCsdBearer,
       
   121 		EWappGsmSmsBearer,
       
   122 		EWappGsmUssdBearer,
       
   123 		EWappIS136CsdBearer,
       
   124 		EWappGprsBearer
       
   125 		};
       
   126 
       
   127 
       
   128 // Member Variables
       
   129 public:	
       
   130 	//Defines which type of characteristic we're dealing with
       
   131 	enum TWappCharacteristicType
       
   132 		{
       
   133 		EWappUnknown,				// Don't know the type yet
       
   134 		EWappAddressCharacteristic, // An address, but specific type undetermined
       
   135 		EWappGsmCsdCharacteristic,		// A GSM/CSD address 
       
   136 		EWappGsmSmsCharacteristic,		// A GSM/SMS address
       
   137 		EWappGsmUssdCharacteristic,		// A GSM/USSD address
       
   138 		EWappIS136CsdCharacteristic,    // A IS136/CSD address
       
   139 		EWappGprsCharacteristic,		// A GPRS address
       
   140 		EWappBookmarkCharacteristic, // A Bookmark	
       
   141 		EWappURLCharacteristic,		 // A URL
       
   142 		EWappNameCharacteristic,	// A name characteristic
       
   143 		EWappIDCharacteristic,		// A ID characteristic
       
   144 		EWappMMSURLCharacteristic   // A Multi Media Service Centre Url characteristic
       
   145 		};
       
   146 
       
   147 
       
   148     IMPORT_C static CMsvBIOWapAccessParser* NewL(CRegisteredParserDll& aRegisteredParserDll, CMsvEntry& aEntry, RFs& aFs);
       
   149     ~CMsvBIOWapAccessParser();
       
   150 
       
   151     void ParseL(TRequestStatus& aStatus, const TDesC& aSms);
       
   152     void ProcessL(TRequestStatus& aStatus);
       
   153 
       
   154 private:
       
   155 	//Constructors
       
   156     CMsvBIOWapAccessParser(CRegisteredParserDll& aRegisteredParserDll, // Only constructor-passes
       
   157 									CMsvEntry& aEntry, RFs& aFs);	   // parameters to base const
       
   158 
       
   159     void ConstructL();
       
   160 
       
   161 	// Active Object stuff
       
   162     void DoCancel();
       
   163     void RunL();
       
   164 
       
   165 	// State Engine functions
       
   166 
       
   167 	void CallChangeStateL(TInt aState); // Calls ChangeStateL with the right state
       
   168     void ChangeStateL(TParseSession aState);    // Advances State Machine to next state
       
   169 
       
   170     void ParseMessageL(); // Only checks & saves parsed data - calls DoParseL 
       
   171 
       
   172     void CompleteMessageL();  //Sets the flag on TMsvEntry to show message parsed.
       
   173 
       
   174     void RequestComplete(TRequestStatus& aStatus, TInt aError); // Complete our async op.
       
   175 	
       
   176 	// *****************	Additional helper functions added by AHF	*********************
       
   177 private:	
       
   178 
       
   179 	void StoreParsedDataL();	// Saves CParsedField data in a store
       
   180 	
       
   181 	void RestoreParsedDataL();	// Loads the CParsedField data from store
       
   182 
       
   183 	void ResetProcessVariablesL();  // Resets variables, delete and create if necessary
       
   184 	
       
   185 	void DoParseL();			// Does the actual parsing of the message. 
       
   186 	
       
   187 	void DoProcessL();		// Get data from array, commit to COMMDB
       
   188 	
       
   189 	void PreProcessL(); //  Called by DoProcessL,extracts data from array into 
       
   190 						//  Mapping object,rejects duplicate data
       
   191 
       
   192 	// *******************	Helper Functions for Parsing	**********************
       
   193 
       
   194 	void ReadCharacteristicL();	// Gets a CHARACTERISTIC from the message 
       
   195 
       
   196 	void ReadParmL();			// Reads in a PARM	from the message
       
   197 
       
   198 	void SettingsNamePresentL(); // Ensures that a NAME characteristic is present. 
       
   199 
       
   200 	
       
   201 	TUint32 Read_mb_u_int32L();	// Extract a multiple byte encoded 32 bit int
       
   202 	
       
   203 	HBufC* ReadStringTableReferenceLC(TUint32 anOffset);// Gets string from the string table
       
   204  											// using a 32 bit integer offset
       
   205 
       
   206 	void ReadASCIIorUTF8StringL(); //finds the end of a string encoded in UTF-8 or ASCII
       
   207 	void ReadUCS2StringL();	//finds end of a string encoded in 2-byte Unicode
       
   208 	HBufC* ReadInlineStringLC();		 // Extracts an inline string from the message	
       
   209 	
       
   210 	void AppendDataPairL(const TDesC& aFieldName, const TDesC& aFieldValue);// Creates CParsedField,
       
   211 																			// & appends to array
       
   212 
       
   213 	void AppendNameFieldL(const TDesC& aFieldName); // Creates a CParsedField,
       
   214 													// & append to array
       
   215 	
       
   216 	void InsertDataPairL(const TDesC& aFieldName,const TDesC& aFieldValue,TInt anIndex);// Inserts CParsedField
       
   217 																				// at specified position. 
       
   218 
       
   219 	TChar GetNextMessageByteL();   // Gets next character from TLex - leaves if at end of buffer
       
   220 
       
   221 	// ******************	 Helper functions for ProcessL	*****************************
       
   222 	void ExtractBearerDataL(TInt& aCurrentPos);//Extracts data from iParsedFieldArray 
       
   223 											   // & stores in WAP & ISP table objects. 
       
   224 											   // Increments the current pos ref as it goes 
       
   225 
       
   226 	void ExtractBookmarkDataL(TInt& aIndex);  // Extracts bookmark data from array to create
       
   227 											  // a bookmark. Rejects invalid bookmarks.
       
   228 											  // Ensures that array positioned at next characteristic
       
   229 
       
   230 	void ValidateCharacteristicsL();		  // Ensures that don't have invalid combinations
       
   231 											  // of characteristic eg URLs, IDs, NAMES must have a bearer type
       
   232 											  // but Bookmarks can be by themselves
       
   233 
       
   234 	TBool IsCharacteristicName(TInt anIndex); // True if name at index positino is a Characteristic name
       
   235 	
       
   236 
       
   237 	TInt IsValidTokenNameL(const TInt anArrayIndex);	// Validates the name against defined strings 
       
   238 												// returns 0 if OK, error otherwise
       
   239 	
       
   240 	void WriteDataToDBL();			// Creates entries in the tables using 
       
   241 									// data in the arrays of table info	
       
   242 	
       
   243 	TBool DeleteTableEntryL(const TDesC& aTableName, const TDesC& aEntryName);   // returns True if there are records in the CommDB table
       
   244 	void WriteToCommDatDialOutISPTableL(const TDesC& aRecName); // Writes/amends Dial Out ISP table
       
   245 	void WriteToCommsDatIAPTableL(const TDesC& aRecName); // Writes/amends WAP table
       
   246 	void WriteToCommDatGprsTableL(const TDesC& aRecName); // Writes/amends Gprs table
       
   247 	void WriteToCommDatWapAccessPointTableL(const TDesC& aRecName); // Writes/amends WAP table
       
   248 	void WriteToCommDatWapIpBearerTableL();
       
   249 	void WriteToCommDatWapSmsBearerTableL(); // Writes/amends Dial-Out WAP table	
       
   250 	void DeleteCommDatTableEntryL(TMDBElementId aElementName, const TDesC& aCsdNameStr);
       
   251 	
       
   252 
       
   253 	void WriteBookmarksToFileL();  // Stores bookmarks as an attachment file in the .eBM format
       
   254 
       
   255 	void WriteMMSURLL(); // Write the MMS URL to the setting in the message server.
       
   256 
       
   257 	TCommsDbWapWspOption GetWSPType(TDesC& aPortValue);   // Returns the appropriate enum for the Port value
       
   258 	
       
   259 	TBool UseSecurity(TDesC& aPortValue);  //Returns the security level for the Port Value
       
   260 
       
   261 	void SetWapIspEntryIdL(const TDesC& aEntryName);  // Set the iCurrentBearerType BEFORE calling this!!!!
       
   262 													 //Sets variables holding ID of Dial Out ISP ID entry 
       
   263 
       
   264 	void SetWapIapEntryIdL(const TDesC& aEntryName, CWapIpBearerData& aWapIpTable);  // Sets variables holding ID of Dial Out IAP ID entry 
       
   265 	
       
   266 	void SetWapAPEntryIdL();	// Sets ID of entry in WAP Access Point Table. Uses iWAPSettings
       
   267 
       
   268 	void SetModemInitStringL(); // Sets the modem initialisation string
       
   269 
       
   270 	void UpdateStartPageUrlL(); // Updates the URL of start page in WAP table
       
   271 
       
   272 	// ******************    General Functions    *****************************
       
   273 	
       
   274 	// Locate a Name value, default is from start of array, returns -1 if search fails
       
   275 	TInt LocateParsedFieldName(const TDesC& aFieldName, const TInt aStartIndex=0); 
       
   276 
       
   277 	void RemoveAttachmentIfExistL(const TDesC& aFileName, MMsvAttachmentManager& aManager, MMsvAttachmentManagerSync& aManagerSync);
       
   278 
       
   279 	void Panic(TInt aPanic);
       
   280 	//Member variables
       
   281 private:
       
   282     TInt            iState;          // Current session state
       
   283     TRequestStatus* iReport;
       
   284     TInt            iCompleted;      // Stores completion code from previous session state
       
   285 
       
   286 private: 
       
   287 	// Additional variables added by AHF
       
   288 
       
   289 	TWappCharacteristicType iCurrentCharacteristic;
       
   290 
       
   291 	TUint32				iWBXMLversionX10;   // WBXML version *10 to give an int eg 1.0 -> 10
       
   292 	TUint32				iPublicID;			//PublicId of document
       
   293 	// Internal Symbian character set identifier for incoming strings
       
   294 	TUint32				iCharacterSet;		
       
   295 	HBufC*				iStringTable;		// Table of strings to be used for str table reference
       
   296 
       
   297 	CArrayPtrSeg<CWappBookmark>* iBookmarkList;   // Array of bookmarks to store
       
   298 	TPtrC				iWAPSettingsName;	// Name for these WAP settings-get from NAME characteristic
       
   299 	TPtrC				iUrl;				// URL of the start page
       
   300 	TPtrC				iMMSUrl;			// URL of the MMSC
       
   301 	TPtrC				iID;				// ID used by these settings
       
   302 	HBufC8*				iModemInitString;	// String used to hold Modem Initialisation string
       
   303 
       
   304 	CWapIpBearerData*	iGsmCsdWapIpTable;		//  Wap IP table data GSM/CSD 
       
   305 	CWapIpBearerData*	iGprsWapIpTable;		//  Wap IP table data for GPRS
       
   306 
       
   307 	CIspTableData*		iWapIpISPTable;		// 1 WAP GSM/CSD table entry = 1 ISP table entry
       
   308 	CWapSmsBearerData*	iWapSmsTable;		// No links to ISP table.
       
   309 	CWapGprsBearerData*	iWapGprsTable;				
       
   310 
       
   311 	TBool				iGsmCsdData;
       
   312 	TBool				iGsmSmsData;
       
   313 	TBool				iGprsData;
       
   314 	TBool				iURLData;
       
   315 	TBool				iNameData;
       
   316 	TBool				iIdData;
       
   317 	TBool				iMMSURLData; 
       
   318 
       
   319 	//commit data
       
   320 	CMDBSession* 		iDBSession;
       
   321 	
       
   322 	
       
   323 	TUint32				iRecordId; 
       
   324 	
       
   325 	TUint32				iWapAccessPtID;		// ID of entry in WAP Access Point Table
       
   326 
       
   327 	TUint32				iWapLocation; 
       
   328 	TUint32				iWapChargeCard;
       
   329 	TUint32				iWapModem;
       
   330 
       
   331 	CWapCharsetConverter* iCharsetConverter;
       
   332 	TWappBearerType		iCurrentBearerType;
       
   333 	};
       
   334 
       
   335 
       
   336 class CWapCharsetConverter: public CBase
       
   337 /**
       
   338 @internalComponent
       
   339 @released
       
   340 */
       
   341 	{
       
   342 	public:
       
   343 		static CWapCharsetConverter* NewL(RFs& aFs, TUint aMibEnum);
       
   344 		void ConvertL(const TDesC& aSource, TDes& aSink);
       
   345 		~CWapCharsetConverter();
       
   346 	private:
       
   347 		void ConstructL(TInt aMibEnum);
       
   348 		CWapCharsetConverter(RFs& aFs) : iFs(aFs){}
       
   349 	private:
       
   350 		RFs& iFs;
       
   351 		CCnvCharacterSetConverter* iConverter;
       
   352 		CArrayFix<CCnvCharacterSetConverter::SCharacterSet>*  iAvailableCharsets;
       
   353 		TBool iParseable;
       
   354 	};
       
   355 
       
   356 
       
   357 #endif // __WAPP_H__