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

📄 transportagent.h

📁 This SDK allows to integrate a syncml stack in a C++ application on a variety of platforms. Current
💻 H
字号:
/*
 * Copyright (C) 2003-2007 Funambol
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef INCL_TRANSPORT_AGENT
    #define INCL_TRANSPORT_AGENT
/** @cond DEV */

    #include "base/fscapi.h"

    #include "http/URL.h"
    #include "http/Proxy.h"

    //
    // number of seconds of waiting response timeout.
    //
    #define DEFAULT_MAX_TIMEOUT 300

    //
    // The max_msg_size parameter. Default is 512k.
    // The value is expressed in byte
    //
    #define DEFAULT_MAX_MSG_SIZE 512000    

    //
    // This is the default value for the size of the buffer used to store the 
    // incoming stram from server. It is expressed in byte     
    //
    #define DEFAULT_INTERNET_READ_BUFFER_SIZE  4096

    /*
     * This class is the transport agent responsible for messages exchange
     * over an HTTP connection.
     * This is a generic abtract class which is not bound to any paltform
     */

    class TransportAgent {

    protected:
        URL url;
        Proxy proxy;

        unsigned int timeout;
        unsigned int maxmsgsize;
        unsigned int readBufferSize;
        char userAgent[128];

    public:
        TransportAgent() EXTRA_SECTION_03;
        TransportAgent(URL& url, 
                       Proxy& proxy, 
                       unsigned int responseTimeout = DEFAULT_MAX_TIMEOUT, 
                       unsigned int maxmsgsize = DEFAULT_MAX_MSG_SIZE) EXTRA_SECTION_03;

        virtual ~TransportAgent() EXTRA_SECTION_03;

        /*
         * Change the URL the subsequent calls to setMessage() should
         * use as target url.
         *
         * @param url the new target url
         */
        virtual void setURL(URL& newURL) EXTRA_SECTION_03;

        /*
         * Returns the url.
         */
        virtual URL& getURL() EXTRA_SECTION_03;

        /**
         * Sets the connection timeout
         *
         * @param t the new timeout in seconds
         */
        virtual void setTimeout(unsigned int t) EXTRA_SECTION_03;

        /**
         * Returns the connection timeout
         */
        virtual unsigned int getTimeout() EXTRA_SECTION_03;
        
        /**
         * Sets the max msg size
         *
         * @param t the new msx msg size in bytes
         */
        virtual void setMaxMsgSize(unsigned int t) EXTRA_SECTION_03;
         
        /**
         * Returns the max msg size
         */
        virtual unsigned int getMaxMsgSize()EXTRA_SECTION_03;

        /**
         * Sets the buffer size
         *
         * @param t the buffer size size in bytes
         */
        virtual void setReadBufferSize(unsigned int t) EXTRA_SECTION_03;
        
        virtual void setUserAgent(const char*  ua);

        virtual const char* getUserAgent();

        /**
         * Returns the buffer size
         */
        virtual unsigned int getReadBufferSize()EXTRA_SECTION_03;


        /*
         * Sends the given SyncML message to the server specified
         * by the install property 'url'. Returns the server's response.
         * The response string has to be freed with delete [].
         * In case of an error, NULL is returned and lastErrorCode/Msg
         * is set.
         */
        virtual char*  sendMessage(const char*  msg) = 0;

    };

/** @endcond */
#endif

⌨️ 快捷键说明

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