Msrp/inc/MsrpCommon.h
branchMSRP_FrameWork
changeset 25 505ad3f0ce5c
child 58 cdb720e67852
equal deleted inserted replaced
22:f1578314b8da 25:505ad3f0ce5c
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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 * Initial Contributors:
       
     9 * Nokia Corporation - initial contribution.
       
    10 * Contributors:
       
    11 *
       
    12 * Description:
       
    13 * MSRP Implementation
       
    14 *
       
    15 */
       
    16 
       
    17 #ifndef __MSRPCOMMON_H__
       
    18 #define __MSRPCOMMON_H__
       
    19 
       
    20 // EXTERNAL INCLUDES
       
    21 #include <e32base.h>
       
    22 #include <e32debug.h>
       
    23 #include <flogger.h>
       
    24 
       
    25 
       
    26 #ifdef UT_TEST
       
    27 
       
    28 const TInt KTimeOutInSeconds( 5 );
       
    29 const TInt KSecondinMicroseconds( 1000000 );
       
    30 
       
    31 const TInt KListenTimeoutInSeconds( 10 );
       
    32 const TInt KBufSize = 4096;
       
    33 const TInt KThreshold = 3839;
       
    34 
       
    35 #else
       
    36 
       
    37 const TInt KTimeOutInSeconds( 30 );
       
    38 const TInt KSecondinMicroseconds( 1000000 );
       
    39 
       
    40 const TInt KListenTimeoutInSeconds( 30 );
       
    41 const TInt KBufSize = 4096;
       
    42 const TInt KThreshold = 1024;
       
    43 
       
    44 #endif
       
    45 
       
    46 // CONSTANTS
       
    47 // Server name.
       
    48 _LIT( KMSRPServerName, "!MSRPServer" );
       
    49 // The name of the MSRP Client module
       
    50 _LIT( KMSRPClientName, "MSRPClient" );
       
    51 
       
    52 _LIT( KLogDir1, "MSRP" );
       
    53 _LIT( KLogFile1, "msrp.txt" );
       
    54 _LIT8( KLog8Dir1, "MSRP" );
       
    55 _LIT8( KLog8File1, "msrp.txt" );
       
    56 _LIT( KMSRPExe, "MSRPServer.exe" );
       
    57 
       
    58 #ifdef __WINSCW__
       
    59 _LIT( KProgramsDir, "\\" );
       
    60 #else
       
    61 _LIT( KProgramsDir, "\\sys\\bin\\" );
       
    62 #endif
       
    63 
       
    64 _LIT8( KCRAndLF, "\r\n" );
       
    65 _LIT8( KMatchCRAndLF, "*\r\n*" );
       
    66 _LIT8( KMatch2CRAndLF, "*\r\n\r\n*" );
       
    67 _LIT8( KSpaceChar, " " );
       
    68 _LIT8( KDashLine, "-------" );
       
    69 _LIT8( KMessageEndSign, "$" );
       
    70 _LIT8( KMessageContinuesSign, "+" );
       
    71 _LIT8( KMessageTerminatedSign, "#" );
       
    72 _LIT8( KAsterisk, "*" );
       
    73 
       
    74 _LIT8( KMsrpUriScheme, "msrp://" );
       
    75 _LIT8( KColon, ":" );
       
    76 _LIT8( KSemicolon, ";" );
       
    77 _LIT8( KForwardSlash, "/" );
       
    78 _LIT8( KTransport, "tcp" );
       
    79 
       
    80 _LIT8( KMSRP,"MSRP" );
       
    81 _LIT8( KMSRPSend,"SEND" );
       
    82 _LIT8( KMSRPReport,"REPORT" );
       
    83 _LIT8( KMSRPMessageID, "Message-ID" );
       
    84 _LIT8( KMSRPByteRange,"Byte-Range" );
       
    85 _LIT8( KMSRPContentType, "Content-Type" );
       
    86 _LIT8( KMSRPToPath, "To-Path" );
       
    87 _LIT8( KMSRPFromPath,"From-Path" );
       
    88 _LIT8( KMSRPSuccessReport,"Success-Report" );
       
    89 _LIT8( KMSRPFailureReport,"Failure-Report" );
       
    90 _LIT8( KMSRPStatus, "Status" );
       
    91 
       
    92 // temporary file path
       
    93 _LIT( KDefaultTempFilePath, "C:\\system\\temp\\" );
       
    94 
       
    95 // CONSTANTS
       
    96 const TInt KMaxLengthOfUrl = 255;
       
    97 const TInt KMaxLengthOfHost = 255;
       
    98 const TInt KMaxLengthOfSessionId = 255;
       
    99 const TInt KSizeOfProgramPath = 50;
       
   100 
       
   101 // maximum length of incoming message buffer (for externalizing CMSRPMessage
       
   102 // class
       
   103 const TInt KMaxLengthOfIncomingMessageExt = 4096;
       
   104 
       
   105 // max length of small MSRP message
       
   106 const TInt KMaxLengthOfSmallMSRPMessage = 2048;
       
   107 
       
   108 // MSRP port number, IANA assigned
       
   109 const TInt KMsrpPort = 2855;
       
   110 
       
   111 // MSRP server version
       
   112 const TUint KMSRPServerMajorVersionNumber = 1;
       
   113 const TUint KMSRPServerMinorVersionNumber = 0;
       
   114 const TUint KMSRPServerBuildVersionNumber = 0;
       
   115 
       
   116 // end of line chars
       
   117 const TUint KDashCharacter = 0x2D;
       
   118 const TUint KDividedCharacter = 0x2F;
       
   119 const TUint KSpaceCharacter = 0x20;
       
   120 
       
   121 const TUint KColonCharacter = 0x3A;
       
   122 const TUint KSemiColonCharacter = 0x3B;
       
   123 const TInt KMaxLengthOfStatusCode = 3;
       
   124 
       
   125 // the maximum length of MSRP end line string
       
   126 const TInt KMaxLengthOfMessageEndString = 100;
       
   127 
       
   128 // the maximum length of transaction id string
       
   129 const TInt KMaxLengthOfTransactionIdString = 100;
       
   130 
       
   131 const TInt KUnknownRange = -1;
       
   132 
       
   133 // MACROS
       
   134 #ifdef _DEBUG
       
   135 
       
   136 	// logging
       
   137 	#define MSRPLOG( text ) \
       
   138 		{ \
       
   139 		_LIT( KText, text ); \
       
   140 		RFileLogger::Write( KLogDir1, KLogFile1, EFileLoggingModeAppend, KText ); \
       
   141 		RDebug::Print( KText ); \
       
   142 		}
       
   143 
       
   144 	#define MSRPLOG2( text, value ) \
       
   145 		{ \
       
   146 		_LIT( KText, text ); \
       
   147 		RFileLogger::WriteFormat( KLogDir1, KLogFile1, EFileLoggingModeAppend, \
       
   148 		TRefByValue<const TDesC>( KText() ), value ); \
       
   149 		RDebug::Print( KText, value ); \
       
   150 		}
       
   151 
       
   152 	#define MSRPLOG3( text, value, value2 ) \
       
   153 		{ \
       
   154 		_LIT( KText, text ); \
       
   155 		RFileLogger::WriteFormat( KLogDir1, KLogFile1, EFileLoggingModeAppend, \
       
   156 		TRefByValue<const TDesC>( KText() ), value, value2 ); \
       
   157 		RDebug::Print( KText, value, value2 ); \
       
   158 		}
       
   159 
       
   160 #else
       
   161 
       
   162 	// not used
       
   163 	#define MSRPLOG( text )
       
   164 	#define MSRPLOG2( text, value1 )
       
   165 	#define MSRPLOG3( text, value1, value2 )
       
   166 
       
   167 #endif // END MACROS
       
   168 
       
   169 // ENUMS
       
   170 // MSRP API IPC request definitions
       
   171 
       
   172 enum TMSRPRequests
       
   173 	{
       
   174     EMSRPCreateSubSession,
       
   175 	EMSRPCloseSubSession,
       
   176 	EMSRPLocalPath,
       
   177 	EMSRPConnect,
       
   178 	EMSRPListenConnections,
       
   179     EMSRPListenMessages,
       
   180     EMSRPListenSendResult,
       
   181     EMSRPSendMessage,    
       
   182     EMSRPSendFile,
       
   183     EMSRPReceiveFile,
       
   184 	EMSRPCancelSending,
       
   185 	EMSRPCancelReceiving,
       
   186 	EMSRPCancelSendRespListening,
       
   187 	EMSRPReserved
       
   188 	};
       
   189 
       
   190 enum TMSRPMessageContent
       
   191 	{
       
   192 	EMSRPChunkEndHeaders,
       
   193 	EMSRPChunkEndNoHeaders,
       
   194 	EMSRPChunkPartialChunkNoHeaders,
       
   195 	EMSRPChunkPartialChunkHeaders
       
   196 	};
       
   197 
       
   198 enum TServerClientResponses
       
   199     {
       
   200     ESubSessionHandle=3, // type integer and returned as response to EMSRPCreateSubSession  
       
   201     // Reserved,    
       
   202     };
       
   203 
       
   204 enum TPanicCode
       
   205     {
       
   206     EBadRequest = 1,
       
   207     EBadDescriptor,
       
   208     EBadSubsessionHandle 
       
   209     };
       
   210 
       
   211 enum TReportStatus
       
   212     {
       
   213     EYes,
       
   214     ENo,
       
   215     EPartial
       
   216     };
       
   217 
       
   218 enum TErrorCode
       
   219     {
       
   220     EUndefined = -1,
       
   221     ENoError = 0,
       
   222     ENetworkTimeout = 1,
       
   223     EUnrecoverableError = 2,    
       
   224     ELocalTimeout = 3,
       
   225     EInvalidAction = 4
       
   226     };
       
   227 
       
   228 
       
   229 // Local host name and session id
       
   230 typedef struct TLocalPathMSRPData
       
   231     {
       
   232     TBuf8< KMaxLengthOfHost> iLocalHost;
       
   233     TBuf8< KMaxLengthOfSessionId > iSessionID;
       
   234     } TLocalPathMSRPData;
       
   235     
       
   236 
       
   237 // for connection parameters
       
   238 typedef struct TConnectMSRPData
       
   239 	{
       
   240 	TBuf8< KMaxLengthOfHost > iRemoteHost;
       
   241 	TUint iRemotePort;
       
   242 	TBuf8< KMaxLengthOfSessionId > iRemoteSessionID;
       
   243 	} TConnectMSRPData;
       
   244 
       
   245 	
       
   246 // for listening parameters
       
   247 typedef struct TListenMSRPData
       
   248 	{
       
   249 	TBuf8< KMaxLengthOfHost > iRemoteHost;
       
   250 	TUint iRemotePort;
       
   251 	TBuf8< KMaxLengthOfSessionId > iRemoteSessionID;
       
   252 	TBuf8< KMaxLengthOfIncomingMessageExt > iExtMessageBuffer;
       
   253 	TBool iIsMessage;
       
   254 	TBool iIsProgress;
       
   255     TInt iBytesRecvd;
       
   256     TInt iTotalBytes;
       
   257 	TInt iStatus; 
       
   258 	} TListenMSRPData;
       
   259 
       
   260 	
       
   261 // for sending a message
       
   262 typedef struct TSendMSRPData
       
   263 	{
       
   264 	TBuf8< KMaxLengthOfIncomingMessageExt > iExtMessageBuffer;
       
   265 	} TSendMSRPData;
       
   266 
       
   267     
       
   268 // for listening to result of a sent message
       
   269 typedef struct TListenSendResultMSRPData
       
   270 	{
       
   271 	TBuf8< KMaxLengthOfSessionId > iSessionID;
       
   272 	TBuf8< KMaxLengthOfSessionId > iMessageId;
       
   273     TBool iIsProgress;
       
   274     TInt iBytesSent;
       
   275     TInt iTotalBytes;
       
   276 	TInt iStatus; // error codes propagated to the client
       
   277 	} TListenSendResultMSRPData;
       
   278 
       
   279 
       
   280 #endif // __MSRPCOMMON_H__
       
   281 
       
   282 // End of File