1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef DMPROCESSSCRIPTSESSION_H 18 #define DMPROCESSSCRIPTSESSION_H 19 20 #ifndef __cplusplus 21 #error "This is a C++ header file; it requires C++ to compile." 22 #endif 23 24 /*================================================================================================== 25 26 Header Name: dmProcessScriptSession.h 27 28 General Description: This file contains declaration of DMProcessScriptSession calls. 29 30 ==================================================================================================*/ 31 32 #include "dmSession.h" 33 #include "SYNCML_DM_BuildPackage.H" 34 #include "dm_security.h" 35 #include "dmSessionDefs.h" 36 #include "dmClientSrvCreds.h" 37 38 /*================================================================================================== 39 CONSTANTS 40 ==================================================================================================*/ 41 42 /*================================================================================================== 43 CLASSES DECLARATION 44 ==================================================================================================*/ 45 46 class DMProcessScriptSession : public DMSession 47 { 48 49 public: 50 51 DMProcessScriptSession(); 52 53 virtual ~DMProcessScriptSession(); 54 55 56 /* set response URI */ 57 virtual SYNCML_DM_RET_STATUS_T SetURI (CPCHAR szURI) { return SYNCML_DM_SUCCESS; } 58 59 void IncCommandCount (); 60 61 /* Get and Set the inAtomicCommand.*/ 62 void SetInAtomicCommand (BOOLEAN newInAtomicCommand); 63 64 BOOLEAN GetInAtomicCommand (); 65 66 UINT16 GetServerSessionId (); 67 68 /* Get the sendInstanceId member.*/ 69 InstanceID_t GetSendInstanceId(); 70 71 void SetClientRetryCount(UINT8 newcount); 72 73 void IncClientRetryCount(); 74 75 void SetSessionAborted() { m_bSessionAborted = TRUE; } 76 77 inline BOOLEAN IsSessionAborted() { return m_bSessionAborted; } 78 79 inline void ResetServerRetryCount() {serverRetryCount = 0;} 80 81 void SetSecState( SYNCML_DM_SEC_STATE_FLAG_T ua_SecState ) { m_nSecState = ua_SecState; } 82 83 SYNCML_DM_SEC_STATE_FLAG_T GetSecState() { return m_nSecState; } 84 85 inline void SetSecStateSrv( BOOLEAN bAuthorized ) 86 { 87 if ( bAuthorized ) 88 m_nSecState |= DM_CLIENT_NO_SERVER_Y_AUTH; 89 else 90 m_nSecState &= (~DM_CLIENT_NO_SERVER_Y_AUTH); 91 } 92 93 inline BOOLEAN IsServerAuthorized() const 94 { 95 return (m_nSecState & DM_CLIENT_NO_SERVER_Y_AUTH) != 0; 96 } 97 98 99 inline BOOLEAN IsAuthorized() const 100 { 101 return ( m_nSecState == DM_BOTH_CLIENT_SERVER_AUTH || 102 m_nSecState == DM_CLIENT_NO_SERVER_Y_AUTH ); 103 104 } 105 106 inline SYNCML_DM_RET_STATUS_T GetNotAuthorizedStatus() 107 { 108 return ( isServCredsMissing ? SYNCML_DM_AUTHENTICATION_REQUIRED : SYNCML_DM_UNAUTHORIZED); 109 } 110 111 /* Get the clientServerCreds structure.*/ 112 virtual DMClientServerCreds * GetClientServerCreds(); 113 114 115 virtual SYNCML_DM_RET_STATUS_T Start(const UINT8 *docInputBuffer , 116 UINT32 inDocSize, 117 BOOLEAN isWBXML, 118 DMBuffer & oResult); 119 120 121 virtual BOOLEAN IsProcessScript() { return TRUE; } 122 #ifdef LOB_SUPPORT 123 BOOLEAN IsLargeObjectSupported() const{ return isLargeObjectSupported; }; 124 UINT32 GetDefaultMaxObjectSize() const{ return dmtMaxObjectSize; }; 125 #endif 126 127 #ifdef TNDS_SUPPORT 128 BOOLEAN IsWBXMLEncoding() const{ return smlEncodingType == SML_WBXML; }; 129 #endif 130 131 132 protected: 133 /* This function will be called to register the DM Engine with the SyncML Toolkit. */ 134 virtual SYNCML_DM_RET_STATUS_T SetToolkitCallbacks(SmlCallbacks_t * pSmlCallbacks); 135 136 /* This function will be called when a new DM package is received. */ 137 SYNCML_DM_RET_STATUS_T ParseMessage(); 138 139 140 BOOLEAN inAtomicCommand; /* Flag for atomic command */ 141 142 UINT16 commandCount; /* Keep track of the management commands.*/ 143 144 UINT8 serverRetryCount; /* Keep track of server auth failures.*/ 145 146 UINT8 clientRetryCount; /* Keep track of client auth failures.*/ 147 148 UINT16 serverSessionId; /* Holds the Server's SessionID */ 149 150 BOOLEAN m_bSessionAborted; 151 152 BOOLEAN isServCredsMissing; 153 154 SYNCML_DM_SEC_STATE_FLAG_T m_nSecState; /* DMUA Security state */ 155 156 SYNCML_DM_USER_DATA_T userData; /* Structure that contains data shared between our 157 code and the callbacks. */ 158 DMCredHeaders m_oRecvCredHeaders; 159 160 DMClientServerCreds clientServerCreds; /* Holds the Security Info for this 161 session.*/ 162 163 SYNCML_DM_BuildPackage m_oPkgBuilder; 164 #ifdef LOB_SUPPORT 165 BOOLEAN isLargeObjectSupported; 166 UINT32 dmtMaxObjectSize; /* Maximum object size can be handled */ 167 #endif 168 }; 169 170 #endif /* DMProcessScriptSession */ 171