⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 session.c

📁 SyncML ToolKits,学习syncml的参考工具包.非常好用.
💻 C
📖 第 1 页 / 共 2 页
字号:
/*************************************************************************//* module:          Communication Services, WSP Session Functions        *//* file:            src/xpt/all/session.c                                *//* target system:   all                                                  *//* target OS:       all                                                  *//*************************************************************************//* * Copyright Notice * Copyright (c) Ericsson, IBM, Lotus, Matsushita Communication  * Industrial Co., Ltd., Motorola, Nokia, Openwave Systems, Inc.,  * Palm, Inc., Psion, Starfish Software, Symbian, Ltd. (2001). * All Rights Reserved. * Implementation of all or part of any Specification may require  * licenses under third party intellectual property rights,  * including without limitation, patent rights (such a third party  * may or may not be a Supporter). The Sponsors of the Specification  * are not responsible and shall not be held responsible in any  * manner for identifying or failing to identify any or all such  * third party intellectual property rights. *  * THIS DOCUMENT AND THE INFORMATION CONTAINED HEREIN ARE PROVIDED  * ON AN "AS IS" BASIS WITHOUT WARRANTY OF ANY KIND AND ERICSSON, IBM,  * LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO. LTD, MOTOROLA,  * NOKIA, PALM INC., PSION, STARFISH SOFTWARE AND ALL OTHER SYNCML  * SPONSORS DISCLAIM ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING  * BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION  * HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT  * SHALL ERICSSON, IBM, LOTUS, MATSUSHITA COMMUNICATION INDUSTRIAL CO.,  * LTD, MOTOROLA, NOKIA, PALM INC., PSION, STARFISH SOFTWARE OR ANY  * OTHER SYNCML SPONSOR BE LIABLE TO ANY PARTY FOR ANY LOSS OF  * PROFITS, LOSS OF BUSINESS, LOSS OF USE OF DATA, INTERRUPTION OF  * BUSINESS, OR FOR DIRECT, INDIRECT, SPECIAL OR EXEMPLARY, INCIDENTAL,  * PUNITIVE OR CONSEQUENTIAL DAMAGES OF ANY KIND IN CONNECTION WITH  * THIS DOCUMENT OR THE INFORMATION CONTAINED HEREIN, EVEN IF ADVISED  * OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE. *  * The above notice and this paragraph must be included on all copies  * of this document that are made. *  *//* * Version Label * * RELEASE ??? CANDIDATE ? * 13.06.2000 */#include "syncml_tk_prefix_file.h" // %%% luz: needed for precompiled headers in eVC++#include <session.h>#include <xpt.h>           /* For the SML_ERR defines */#include <wsputil.h>#include <xptport.h>/*****************************************************************************//*****************************************************************************//**                                                                         **//**                         Private Implementation Methods                  **//**                                                                         **//*****************************************************************************//*****************************************************************************//** *  sessionCreate *       - allocates storage for a session structure, connects to server, *         populates session with connect results. * *  IN:    session      A pointer to a session structure * *  RETURN: *       An indication of whether or not the session was created. * *  Note:  According to the WSP spec the alias is informational, not negotiable. *         So, if the client has multiple addresses depending on the bearer, this *         would list the client's bearer addresses.  All the other capabilities are *         negotiable. **/unsigned int sessionCreate(awsp_ConnectionHandle connHandle,                        awsp_Capabilities *requestedCapabilities,                        const char *staticClientHdrs,                        WspSession_t **session){   unsigned int rc  = SML_ERR_OK;   awsp_Rc_t    aRc = AWSP_RC_OK;   size_t       len = 0;   char        *tmp = NULL;   XPTDEBUG(("    sessionCreate(%lx, %lx, %lx, %lx)\n",             (unsigned long) connHandle, (unsigned long) requestedCapabilities,             (unsigned long) staticClientHdrs, (unsigned long) session));   if (connHandle == NULL)      return SML_ERR_A_XPT_NO_TRANSPORTS;   if (session == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   rc = initializeSession(session);   if (rc != SML_ERR_OK)      return rc;   len = xppStrlen(staticClientHdrs);   if ((staticClientHdrs != NULL) && (len > 0)) {      tmp = (char *) xppMalloc(len + 1);      if (tmp != NULL)         xppStrcpy(tmp, staticClientHdrs);      (*session)->staticClientHeaders = tmp;   }   aRc = awsp_connect_req(connHandle,                          &((*session)->sessionHandle),                          (*session)->staticClientHeaders,                          (len + 1),                          requestedCapabilities);   /* Can the connect RC indicate that the failure is because the SAP    * was not opened in session mode?  If so, should we try to recover?        */   if (aRc != AWSP_RC_OK) {      setLastError(aRc, "WSP Binding awsp connect request failed.");      rc = SML_ERR_A_XPT_COMMUNICATION;   } else      rc = getConnectResponse(*session);   if (rc != SML_ERR_OK)      sessionRelease(*session);   return rc;}  /* End of sessionCreate() *//** *  sessionDisconnect *       - disconnects the active session and releases its associated storage * *  IN:    session      A pointer to a session structure * **/unsigned int sessionDisconnect(WspSession_t *session){   unsigned int rc  = SML_ERR_OK;   awsp_Rc_t aRc = AWSP_RC_OK;   XPTDEBUG(("    sessionDisconnect(%lx)\n", (unsigned long) session));   /* Maybe this should return OK - after all, the goal is reached */   if (session == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   /* I'm not sure it's possible to have a session without a handle at this    * point, so this check may be extraneous                                   */   if (session->sessionHandle == NULL)      return SML_ERR_OK;   aRc = awsp_disconnect_req(session->sessionHandle,                             AWSP_USERREQ,         /* Reason Code                 */                             AWSP_FALSE,           /* Redirect Secure Session? No */                             NULL,                 /* Redirect Addresses (none)   */                             NULL,                 /* Error Header (none)         */                             0,                    /* Error Header Length         */                             NULL,                 /* Error Body (none)           */                             0);                   /* Error Body Length           */   if (aRc != AWSP_RC_OK) {      setLastError(aRc, "WSP Binding awsp disconnect request failed.");      rc = SML_ERR_A_XPT_COMMUNICATION;   }   sessionRelease(session);   return rc;} /* End of sessionDisconnect() *//** *  sessionSuspend *       - suspends the active session, if it exists, and indicates it has *         been suspended. * *  IN:    session      A pointer to a session structure * *  RETURN: *       An indication of whether or not the suspension was successful. * **/unsigned int sessionSuspend(WspSession_t *session){   unsigned int rc  = SML_ERR_OK;   awsp_Rc_t aRc = AWSP_RC_OK;   XPTDEBUG(("    sessionSuspend(%lx)\n", (unsigned long) session));   /* Should return something like 'No active session to suspend'              */   if (session == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   if (session->sessionHandle != NULL) {      aRc = awsp_suspend_req(session->sessionHandle);      if (aRc != AWSP_RC_OK) {         setLastError(aRc, "WSP Binding awsp suspend request failed.");         rc = SML_ERR_A_XPT_COMMUNICATION;      } else         session->sessionSuspended = AWSP_TRUE;   }   return rc;}  /* End of sessionSuspend() *//** *  sessionResume *       - resumes a suspended session. * *  IN:    session      A pointer to a session structure * *  RETURN: *       An indication of whether or not the resume was successful. * **/unsigned int sessionResume(awsp_ConnectionHandle connHandle,                        WspSession_t *session){   unsigned int rc       = SML_ERR_OK;   awsp_Rc_t aRc      = AWSP_RC_OK;   XPTDEBUG(("    sessionResume(%lx, %lx)\n", (unsigned long) connHandle, (unsigned long) session));   if (connHandle == NULL)      return SML_ERR_A_XPT_NO_TRANSPORTS;   /* Should return 'No session to resume' */   if (session == NULL)      return SML_ERR_A_XPT_INVALID_PARM;   /* Session is already active, which was goal, so return OK?    */   if (session->sessionSuspended == AWSP_FALSE)      return SML_ERR_A_XPT_COMMUNICATION;   aRc = awsp_resume_req(connHandle,                         session->staticClientHeaders,                         xppStrlen(session->staticClientHeaders));   if (aRc != AWSP_RC_OK) {      setLastError(aRc, "WSP Binding awsp resume request failed.");      return SML_ERR_A_XPT_COMMUNICATION;   }   rc = getResumeResponse(connHandle, session);   if (rc == SML_ERR_OK)      session->sessionSuspended = AWSP_FALSE;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -