Denis Muratshin 8 år sedan
förälder
incheckning
00c23d2a2e

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 788 - 754
oxygine/SDL/ios/oxygine/oxygine_ios.xcodeproj/project.pbxproj


+ 0 - 56
oxygine/src/oxygine/core/s3e/HttpRequestTaskS3E.cpp

@@ -1,56 +0,0 @@
-#include "HttpRequestTaskS3E.h"
-
-namespace oxygine
-{
-    static HttpRequestTask* createS3E()
-    {
-        return new HttpRequestTaskS3E;
-    }
-
-
-    void HttpRequestTask::init()
-    {
-        setCustomRequests(createS3E);
-    }
-
-    void HttpRequestTask::release()
-    {
-
-    }
-}
-
-
-HttpRequestTaskS3E::HttpRequestTaskS3E()
-{
-
-}
-
-void HttpRequestTaskS3E::_run()
-{
-    _http._cbDone = CLOSURE(this, &HttpRequestTaskS3E::onDone);
-    _http._cbError = CLOSURE(this, &HttpRequestTaskS3E::onError);
-    if (_fname.empty())
-    {
-        if (_postData.empty())
-            _http.get(_url);
-        else
-            _http.post(_url, (const char*)&_postData.front(), _postData.size());
-    }
-    else
-        _http.getFile(_url, _fname);
-
-    addRef();
-}
-
-void HttpRequestTaskS3E::onDone(MyHttp*)
-{
-    std::swap(_response, _http.getBuffer());
-    onComplete();
-    releaseRef();
-}
-
-void HttpRequestTaskS3E::onError(MyHttp*)
-{
-    AsyncTask::onError();
-    releaseRef();
-}

+ 0 - 18
oxygine/src/oxygine/core/s3e/HttpRequestTaskS3E.h

@@ -1,18 +0,0 @@
-#pragma once
-#include "HttpRequestTask.h"
-#include "MyHttp.h"
-
-DECLARE_SMART(HttpRequestTaskS3E, spHttpRequestTaskS3E);
-class HttpRequestTaskS3E: public oxygine::HttpRequestTask
-{
-public:
-    HttpRequestTaskS3E();
-
-protected:
-    void _run();
-
-    void onDone(MyHttp*);
-    void onError(MyHttp*);
-    MyHttp _http;
-};
-

+ 0 - 315
oxygine/src/oxygine/core/s3e/MyHttp.cpp

@@ -1,315 +0,0 @@
-#include "MyHttp.h"
-//#include "net/downloader.h"
-//#include "shared.h"
-//#include "utils/debug_tools.h"
-//#include "utils/net_utils.h"
-
-#define NETWORK_AVAILABLE() OX_ASSERT(s3eSocketGetInt(S3E_SOCKET_NETWORK_AVAILABLE) == 1)
-
-using namespace std;
-using namespace oxygine;
-
-
-const int httpTimeout = 20000;
-
-const int bufSize = 1024 * 64;
-
-MyHttp::MyHttp() : _http(0), _status(status_none), _handle(0), _method(GETFILE)
-{
-
-}
-
-MyHttp::~MyHttp()
-{
-    destroy();
-}
-
-void MyHttp::destroy()
-{
-    if (_http)
-        _http->Cancel();
-    delete _http;
-    _http = 0;
-    if (_handle)
-        file::close(_handle);
-    _handle = 0;
-    _status = status_none;
-    _data.clear();
-    _tempBuffer.clear();
-}
-
-unsigned int MyHttp::getTotalSize() const
-{
-    return _http->ContentLength();
-}
-
-unsigned int MyHttp::getReceivedSize() const
-{
-    return _http->ContentReceived();
-}
-
-int MyHttp::_delayedError(void* systemData, void* userData)
-{
-    MyHttp* http = (MyHttp*)userData;
-    http->onError();
-    return 0;
-}
-
-void MyHttp::getFile(const string& url, const string& name)
-{
-    destroy();
-
-    _method = GETFILE;
-    _url = url;
-
-    log::messageln("getfile:");
-    puts(url.c_str());
-
-    _status = status_inprogress;
-    _http = new CIwHTTP;
-
-    if (!name.empty())
-        _handle = file::open(name.c_str(), "wb");
-
-    _http->Get(url.c_str(), _gotHeaders, this);
-}
-
-void MyHttp::get(const string& url)
-{
-    destroy();
-
-    _method = GET;
-    _url = url;
-    log::messageln("post: %s", url.c_str());
-    _status = status_inprogress;
-
-
-    _http = new CIwHTTP;
-    //_http->SetRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
-    if (!isNetworkAvailable())
-    {
-        //it is too dangerous call onError from there
-        //do it at next update
-#ifdef __S3E__
-        s3eThreadEnqueueCallback(s3eThreadGetCurrent(), _delayedError, this);
-#endif
-        return;
-    }
-
-
-    _http->Get(url.c_str(), _gotHeaders, this);
-}
-
-void MyHttp::post(const string& url, const char* data, int size)
-{
-    destroy();
-
-    _post = data;
-    _postSize = size;
-    _method = POST;
-    _url = url;
-    log::messageln("post: %s", url.c_str());
-    _status = status_inprogress;
-
-
-    _http = new CIwHTTP;
-    _http->SetRequestHeader("Content-type", "application/x-www-form-urlencoded");
-
-    if (!isNetworkAvailable())
-    {
-        //it is too dangerous call onError from there
-        //do it at next update
-#ifdef __S3E__
-        s3eThreadEnqueueCallback(s3eThreadGetCurrent(), _delayedError, this);
-#endif
-        return;
-    }
-
-
-    _http->Post(url.c_str(), data, size, _gotHeaders, this);
-}
-
-int MyHttp::getResponseCode() const
-{
-    return _http->GetResponseCode();
-}
-
-void MyHttp::gotHeaders()
-{
-    //log::messageln("gotHeaders");
-    if (_http->GetStatus() == S3E_RESULT_ERROR)
-    {
-        onError();
-    }
-    else
-    {
-        if (_cbProgress)
-            _cbProgress(this, 0);
-
-        int resp = _http->GetResponseCode();
-        if (resp != 200)
-        {
-            if (resp == 302)
-            {
-                string res;
-                _http->GetHeader("Location", res);
-                if (!res.empty())
-                {
-                    switch (_method)
-                    {
-                        case MyHttp::GETFILE:
-                            get(res);
-                            break;
-                        case MyHttp::GET:
-                            getFile(res, "");
-                            break;
-                        case MyHttp::POST:
-                            post(res, _post, _postSize);
-                            break;
-                        default:
-                            break;
-                    }
-                    getFile(res, "");
-                    return;
-                }
-            }
-
-            _status = status_error;
-            if (_cbError)
-                _cbError(this);
-            return;
-        }
-
-        int len = _http->ContentExpected();
-        if (!len)
-            len = 1024;
-
-        if (!_handle)
-            _data.reserve(len);
-
-        len = min(bufSize, len);
-        _tempBuffer.resize(len);
-
-        _http->ReadDataAsync((char*)&_tempBuffer.front(), len, httpTimeout, _gotData, this);
-    }
-}
-
-void MyHttp::progress(int size)
-{
-    if (_cbProgress)
-        _cbProgress(this, size);
-
-    if (_handle)
-        file::write(_handle, &_tempBuffer.front(), size);
-    else
-        _data.insert(_data.end(), _tempBuffer.begin(), _tempBuffer.begin() + size);
-
-
-    int rec = _http->ContentReceived();
-    /*
-    int32 v = 0;
-    _http->GetHeader("Content-Length", v);
-    string r;
-    _http->GetHeader("Content-Range", r);
-    */
-    int ln = _http->ContentLength();
-
-    if (!ln)
-    {
-        //something is wrong
-        ln = rec + _http->ContentExpected();
-    }
-
-    //if (rec != ln)
-    if (!_http->ContentFinished())
-    {
-        int len = ln - rec;
-
-        len = min(bufSize, len);
-        _tempBuffer.resize(len);
-
-        _http->ReadDataAsync((char*)&_tempBuffer.front(), len, httpTimeout, _gotData, this);
-        return;
-    }
-
-    if (_handle)
-        file::close(_handle);
-    _handle = 0;
-    _status = status_done;
-    if (_cbDone)
-        _cbDone(this);
-}
-
-void MyHttp::onError()
-{
-    log::messageln("http error: %s", _url.c_str());
-    if (_handle)
-        file::close(_handle);
-    _handle = 0;
-    _status = status_error;
-    if (_cbError)
-        _cbError(this);
-}
-
-void MyHttp::gotData(int size)
-{
-    progress(size);
-}
-
-int MyHttp::_gotData(void* systemData, void* userData)
-{
-    MyHttp* http = (MyHttp*)userData;
-    http->gotData((size_t)systemData);
-    return 0;
-}
-
-int MyHttp::_gotHeaders(void* systemData, void* userData)
-{
-    MyHttp* http = (MyHttp*)userData;
-    http->gotHeaders();
-    return 0;
-}
-
-
-class SingleHttpAsyncRequest: public Object
-{
-public:
-    void get(const char* url)
-    {
-        _http.getFile(url, "");
-        _http._cbDone = CLOSURE(this, &SingleHttpAsyncRequest::_delete);
-        _http._cbError = CLOSURE(this, &SingleHttpAsyncRequest::_delete);
-    }
-
-    void post(const char* url, const char* data, int size)
-    {
-        _http.post(url, data, size);
-        _http._cbDone = CLOSURE(this, &SingleHttpAsyncRequest::_delete);
-        _http._cbError = CLOSURE(this, &SingleHttpAsyncRequest::_delete);
-    }
-
-    void _delete(MyHttp*)
-    {
-        delete this;
-    }
-    MyHttp _http;
-};
-
-void makeSingleHttpAsyncGetRequest(const char* url)
-{
-    if (!isNetworkAvailable())
-        return;
-
-    SingleHttpAsyncRequest* r = new SingleHttpAsyncRequest;
-    r->get(url);
-}
-
-void makeSingleHttpAsyncPostRequest(const char* url, const char* data, int size)
-{
-    if (!isNetworkAvailable())
-        return;
-
-    SingleHttpAsyncRequest* r = new SingleHttpAsyncRequest;
-    r->post(url, data, size);
-}

+ 0 - 73
oxygine/src/oxygine/core/s3e/MyHttp.h

@@ -1,73 +0,0 @@
-#pragma once
-#include "core/oxygine.h"
-#include "closure/closure.h"
-#include "core/file.h"
-
-#include "IwHTTP.h"
-
-class MyHttp
-{
-public:
-    typedef Closure<void (MyHttp*)> DownloadDoneCallback;
-    typedef Closure<void (MyHttp*)> ErrorCallback;
-    typedef Closure<void (MyHttp*, int)> ProgressCallback;
-
-    enum status
-    {
-        status_none,
-        status_inprogress,
-        status_done,
-        status_error
-    };
-
-    MyHttp();
-    virtual ~MyHttp();
-
-
-    DownloadDoneCallback    _cbDone;
-    ProgressCallback        _cbProgress;
-    ErrorCallback           _cbError;
-
-    void            getFile(const std::string& url, const std::string& name);
-    void            get(const std::string& url);
-    void            post(const std::string& url, const char* data, int size);
-
-
-    std::vector<unsigned char>&  getBuffer() {return _data;}
-    status          getStatus() const {return _status;}
-    unsigned int    getTotalSize() const;
-    unsigned int    getReceivedSize() const;
-    int             getResponseCode() const;
-
-private:
-
-    enum METHOD {GETFILE, GET, POST};
-    METHOD _method;
-    static int _gotHeaders(void* systemData, void* userData);
-    static int _gotData(void* systemData, void* userData);
-    static int _delayedError(void* systemData, void* userData);
-
-
-    void destroy();
-
-    void gotHeaders();
-    void gotData(int size);
-    void progress(int size);
-
-    void onError();
-
-    std::string _url;
-    const char* _post;
-    int _postSize;
-
-    std::vector<unsigned char> _tempBuffer;
-    std::vector<unsigned char> _data;
-    oxygine::file::handle _handle;
-    CIwHTTP* _http;
-
-    status _status;
-};
-
-
-void makeSingleHttpAsyncGetRequest(const char* url);
-void makeSingleHttpAsyncPostRequest(const char* url, const char* data, int size);

+ 0 - 0
oxygine/src/oxygine/math/vector2.h → oxygine/src/oxygine/math/Vector2.h


Vissa filer visades inte eftersom för många filer har ändrats