コード例 #1
0
 void HttpRequestEmscriptenTask::_onload(void* data, unsigned size)
 {
     log::messageln("HttpRequestEmscriptenTask::_onload");
     _response.assign((char*)data, (char*)data + size);
     onComplete();
     releaseRef();
 }
コード例 #2
0
bool UIUpdateServiceTask::initService()
{
	if (!UIBaseServiceTask::initService())
	{
		onComplete();
		return false;
	}

	gcString oldBranchMcf = getBranchMcf(getItemInfo()->getId(), getItemInfo()->getInstalledBranch(), getMcfBuild());

	m_pIPCIM = getServiceMain()->newUninstallBranch();
			
	if (!m_pIPCIM)
	{
		gcException eFailCrtBrnch(ERR_NULLHANDLE, "Failed to create uninstall update mcf service!\n");
		onErrorEvent(eFailCrtBrnch);
		return false;
	}

	m_pIPCIM->onCompleteEvent += delegate(this, &UIUpdateServiceTask::onComplete);
	m_pIPCIM->onProgressEvent += delegate(&onMcfProgressEvent);
	m_pIPCIM->onErrorEvent += delegate((UIBaseServiceTask*)this, &UIBaseServiceTask::onServiceError);

	m_pIPCIM->start(oldBranchMcf.c_str(), m_szPath.c_str(), getItemInfo()->getPath(), "");

	return true;
}
コード例 #3
0
void ClientConnection::close()
{
    if (!closed()) {
        onComplete();
        Connection::close();
    }
}
コード例 #4
0
ファイル: NemAPI.cpp プロジェクト: NemOry/NemSMS
void Snap2ChatAPISimple::request(QVariant params)
{
	QUrl dataToSend;

	QVariantMap paramsMap = params.toMap();

	const QString endpoint		= paramsMap.value("endpoint").toString();

	if(endpoint == "listen")
	{
		dataToSend.addQueryItem("userid", paramsMap.value("userid").toString());
	}
	else if(endpoint == "login" || endpoint == "register")
	{
		dataToSend.addQueryItem("username", paramsMap.value("username").toString());
		dataToSend.addQueryItem("password", paramsMap.value("password").toString());
	}

	QNetworkRequest request;
	request.setUrl(QUrl(PROTOCOL + API_ENDPOINT + endpoint + ".php"));
	request.setHeader(QNetworkRequest::ContentTypeHeader, CONTENT_TYPE);

	QNetworkReply* reply = m_manager.post(request, dataToSend.encodedQuery());
	reply->setProperty("endpoint", endpoint);
	connect (reply, SIGNAL(finished()), this, SLOT(onComplete()));
}
コード例 #5
0
ファイル: NemAdsController.cpp プロジェクト: NemOry/Spo2fy
void NemAdsController::getRequest(QVariant params)
{
	QVariantMap paramsMap 	= params.toMap();

	QString endpoint		= paramsMap.value("endpoint").toString();
	QString data            = paramsMap.value("data").toString();

	QString theurl          = "";

	if(endpoint == "load")
	{
	    theurl = ADS_BASEURL;
	}
	else if(endpoint == "clicked")
    {
        theurl = CLICK_BASEURL;
    }

	QNetworkRequest request;
	request.setUrl(QUrl(theurl + data));
    request.setRawHeader("Accept-Language", ACCEPT_LANGUAGE.toAscii());
    request.setRawHeader("Accept-Locale", ACCEPT_LOCALE.toAscii());
    request.setHeader(QNetworkRequest::ContentTypeHeader, CONTENT_TYPE);
    request.setRawHeader("User-Agent", USER_AGENT.toAscii());

	QNetworkReply* reply = networkAccessManager.get(request);
	reply->setProperty("endpoint", endpoint);
	connect (reply, SIGNAL(finished()), this, SLOT(onComplete()));
}
コード例 #6
0
ファイル: VideoProgress.cpp プロジェクト: sigint9/shadercap
void VideoProgress::onFinalPress() {
  if (captureDone) {
    onComplete();
  } else {
    finalFrame = true;
  }
}
コード例 #7
0
ファイル: client.cpp プロジェクト: sourcey/libsourcey
void ClientConnection::onClose()
{
    // LTrace("On close")

    if (!_complete)
        onComplete();
    Close.emit(*this);
}
コード例 #8
0
ファイル: HttpParserImpl.cpp プロジェクト: jimmy486/kuma
bool HttpParserImpl::setEOF()
{
    if(readEOF() && HTTP_READ_BODY == read_state_) {
        read_state_ = HTTP_READ_DONE;
        onComplete();
        return true;
    }
    return false;
}
コード例 #9
0
ファイル: HttpParserImpl.cpp プロジェクト: jimmy486/kuma
void HttpParserImpl::resume() {
    paused_ = false;
    if(hasBody() && !upgrade_) {
        read_state_ = HTTP_READ_BODY;
    } else {
        read_state_ = HTTP_READ_DONE;
        onComplete();
    }
}
コード例 #10
0
ファイル: frmlog.cpp プロジェクト: hominlinx/cppbed
void frmLog::startRun()
{
	changeRunBtnState(true);

	pCShell = new threadCShell(txtProg->document()->toPlainText());
	connect(pCShell, SIGNAL(finished()), this, SLOT(onComplete()));
	pCShell->start();
	
}
コード例 #11
0
ファイル: broadcast.cpp プロジェクト: sigint9/torrentmod
void Broadcast::beginNextPeer(const size_t peerIndex) {
    if (stopped_ || peerIndex == peers_.size()) {
        onComplete();
        return;
    }

    router_ = boost::make_shared<Router>(boost::ref(io_), peers_[peerIndex], packet_);
    router_->onPacket.connect(boost::bind(&Broadcast::handleResponse, this, _1));
    router_->onDisconnect.connect(boost::bind(&Broadcast::handleDisconnect, this));
}
コード例 #12
0
ファイル: HTTPRequest.cpp プロジェクト: Trenair/evexin
void HTTPRequest::handleDisconnected(const boost::optional<Swift::Connection::Error>& error) {
	//std::cerr << "HTTP Disconnected" << std::endl;
	cancelConnector();
	if (receivedHeaders_) {
		onComplete(Swift::createByteArray(safeByteArrayToString(buffer_))); // Yes, this is getting a little silly with the conversions.
	}
	else {
		onError();
	}
	connection_.reset(); // Delete the connection, the signals that keep the HTTPRequest alive get cleared, this gets cleaned up.
}
コード例 #13
0
ファイル: testApp.cpp プロジェクト: Aharobot/ofxTweenzor
//--------------------------------------------------------------
void testApp::keyPressed(int key){
    if (key == ' ') {
		paused = !paused;
		Tweenzor::toggleAllTweens();
	} else if (key == 'r') {
		Tweenzor::resetAllTweens();
	} else if ( key == 't') {
		float num = 0.f;
		onComplete(&num);
	}
}
コード例 #14
0
 void HttpRequestEmscriptenTask::_onload(void* data, unsigned size)
 {
     log::messageln("HttpRequestEmscriptenTask::_onload");
     _response.assign((char*)data, (char*)data + size);
     if (!_fname.empty())
     {
         file::write(_fname.c_str(), data, size);
     }
     onComplete();
     releaseRef();
 }
コード例 #15
0
void E002_C030_P130::onSuccesses(CCNode *node)
{
    setTouchEnableBaseLayer();
    
    mSuccessCount++;

    if(mSuccessCount > 4)
    {
        onComplete();
    }
    
}
コード例 #16
0
void DownloadToolTask::doRun()
{
	uint32 per = 0;
	getItemInfo()->setPercent(per);

	if (m_ToolTTID == UINT_MAX)
		validateTools();

	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	UserCore::Misc::ToolTransaction* tt = new UserCore::Misc::ToolTransaction();

	tt->onCompleteEvent += delegate(this, &DownloadToolTask::onDLComplete);
	tt->onErrorEvent += delegate(this, &DownloadToolTask::onDLError);
	tt->onProgressEvent += delegate(this, &DownloadToolTask::onDLProgress);
	tt->toolsList = toolList;
	
	if (m_ToolTTID != UINT_MAX)
	{
		bool res = getUserCore()->getToolManager()->updateTransaction(m_ToolTTID, tt);

		if (!res) //must be complete
		{
			onComplete();
			return;
		}
	}
	else
	{
		m_ToolTTID = getUserCore()->getToolManager()->downloadTools(tt);
	}

	if (m_ToolTTID != UINT_MAX)
		m_WaitCond.wait();

	onComplete();
}
コード例 #17
0
    void HttpRequestJavaTask::complete_(jbyteArray ar)
    {
        if (ar)
        {
            JNIEnv* env = jniGetEnv();
            jbyte* data = env->GetByteArrayElements(ar, 0);
            jint len = env->GetArrayLength(ar);
            _response.assign((char*)data, (char*)data + len);
            env->ReleaseByteArrayElements(ar, data, 0);
        }

        onComplete();
        releaseRef();
    }
コード例 #18
0
void
SegmentFetcher::finalizeFetch()
{
  // Combine segments into final buffer
  OBufferStream buf;
  // We may have received more segments than exist in the object.
  BOOST_ASSERT(m_receivedSegments.size() >= static_cast<uint64_t>(m_nSegments));

  for (int64_t i = 0; i < m_nSegments; i++) {
    buf.write(m_receivedSegments[i].get<const char>(), m_receivedSegments[i].size());
  }

  onComplete(buf.buf());
  stop();
}
コード例 #19
0
void E002_C010_P230::OnLastFrame(CJAnimation* pAnimation)
{
    if (pAnimation->getDataPool()->getKey() == FLASH_ANISON) {
        if (pAnimation->getKey() == FLASH_KEY_SPEAK) {
            removeAnimation(pAnimation);
            playAnimationByKey(pAnimation->getDataPool()->getKey(), FLASH_KEY_LOOPING, -1, pAnimation->getZOrder());
            return;
        }
        
        if (pAnimation->getKey() == FLASH_KEY_SUCCESS) {
            removeAnimation(pAnimation);
            playAnimationByKey(pAnimation->getDataPool()->getKey(), FLASH_KEY_LOOPING, -1, pAnimation->getZOrder());
            onComplete();
            return;
        }
    }
    
    if (pAnimation->getDataPool()->getKey() == FLASH_ROBOT) {

        if (pAnimation->getKey() == FLASH_KEY_SUCCESS) {
            mRobot= _playAnimationRobot(FLASH_KEY_LOOPING2);
            mRobot ->setPositionX(totalDist+mRobot->getPositionX());

            return;
        }
    }

    
    if (pAnimation->getDataPool()->getKey() == FLASH_BOOM )
    {
        if (pAnimation->getKey() == FLASH_KEY_ACTION1) {
            bIsJumping = false;
            removeAnimation(pAnimation);
            _playAnimationBoomBoom(FLASH_KEY_LOOPING2);
        }
        
        if (pAnimation->getKey() == FLASH_KEY_FAIL) {
            bIsKoong = false;
            removeAnimation(pAnimation);
            _playAnimationBoomBoom(FLASH_KEY_LOOPING2);
        }
        
    }

}
コード例 #20
0
/**
* @static 
* interrupt handler - called whenever the interrupt pin state changes
*/
void PulseInZero::pinChange(){
	
	static unsigned long pulseStart = 0;
	
	state = !state;
	
	if(state){ 
		// interrupt pin has changed, a pulse has started
		pulseStart = micros(); // store the current microseconds
		attachInterrupt(0, pinChange, FALLING); // now wait for the falling edge
	} else {  	
		
		// pulse complete, detach the interrupt...
		detachInterrupt(0);
		
		// pin state changed again - pulse ended
		unsigned long duration = micros() - pulseStart; // get the pulse length
		
		active = false;
		onComplete(duration);
	}
}
コード例 #21
0
ファイル: HttpParserImpl.cpp プロジェクト: jimmy486/kuma
HttpParserImpl::ParseState HttpParserImpl::parseHttp(const char*& cur_pos, const char* end)
{
    const char* line = nullptr;
    const char* line_end = nullptr;
    bool b_line = false;
    
    if(HTTP_READ_LINE == read_state_)
    {// try to get status line
        while ((b_line = getLine(cur_pos, end, line, line_end)) && line == line_end && str_buf_.empty())
            ;
        if(b_line && (line != line_end || !str_buf_.empty())) {
            if(!parseStartLine(line, line_end)) {
                read_state_ = HTTP_READ_ERROR;
                return PARSE_STATE_ERROR;
            }
            read_state_ = HTTP_READ_HEAD;
        } else {
            // need more data
            if(saveData(cur_pos, end) != KUMA_ERROR_NOERR) {
                return PARSE_STATE_ERROR;
            }
            cur_pos = end; // all data was consumed
            return PARSE_STATE_CONTINUE;
        }
    }
    if(HTTP_READ_HEAD == read_state_)
    {
        while ((b_line = getLine(cur_pos, end, line, line_end)))
        {
            if(line == line_end && bufferEmpty())
            {// blank line, header completed
                onHeaderComplete();
                if(paused_) {
                    return PARSE_STATE_CONTINUE;
                }
                if(hasBody() && !upgrade_) {
                    read_state_ = HTTP_READ_BODY;
                } else {
                    read_state_ = HTTP_READ_DONE;
                    onComplete();
                    return PARSE_STATE_DONE;
                }
                break;
            }
            parseHeaderLine(line, line_end);
        }
        if(HTTP_READ_HEAD == read_state_)
        {// need more data
            if(saveData(cur_pos, end) != KUMA_ERROR_NOERR) {
                return PARSE_STATE_ERROR;
            }
            cur_pos = end; // all data was consumed
            return PARSE_STATE_CONTINUE;
        }
    }
    if(HTTP_READ_BODY == read_state_ && cur_pos < end)
    {// try to get body
        if(is_chunked_) {
            return parseChunk(cur_pos, end);
        } else {
            uint32_t cur_len = uint32_t(end - cur_pos);
            if(has_content_length_ && (content_length_ - total_bytes_read_) <= cur_len)
            {// data enough
                const char* notify_data = cur_pos;
                uint32_t notify_len = content_length_ - total_bytes_read_;
                cur_pos += notify_len;
                total_bytes_read_ = content_length_;
                read_state_ = HTTP_READ_DONE;
                KUMA_ASSERT(!destroy_flag_ptr_);
                bool destroyed = false;
                destroy_flag_ptr_ = &destroyed;
                if(cb_data_) cb_data_(notify_data, notify_len);
                if(destroyed) {
                    return PARSE_STATE_DESTROY;
                }
                destroy_flag_ptr_ = nullptr;
                onComplete();
                return PARSE_STATE_DONE;
            }
            else
            {// need more data, or read untill EOF
                const char* notify_data = cur_pos;
                total_bytes_read_ += cur_len;
                cur_pos = end;
                if(cb_data_) cb_data_(notify_data, cur_len);
                return PARSE_STATE_CONTINUE;
            }
        }
    }
    return HTTP_READ_DONE == read_state_?PARSE_STATE_DONE:PARSE_STATE_CONTINUE;
}
コード例 #22
0
void FinishedManager::on(UploadManagerListener::Complete, Upload* u) throw() {
    onComplete(u, true);
}
コード例 #23
0
void FinishedManager::on(DownloadManagerListener::Complete, Download* d) throw() {
    onComplete(d, false);
}
コード例 #24
0
void FinishedManager::on(UploadManagerListener::Failed, Upload* u, const string&) noexcept {
    if(u->getPos() > 0)
        onComplete(u, true);
}
コード例 #25
0
void FinishedManager::on(UploadManagerListener::Complete, Upload* u) noexcept {
    onComplete(u, true);
}
コード例 #26
0
void FinishedManager::on(DownloadManagerListener::Failed, Download* d, const string&) noexcept {
    if(d->getPos() > 0)
        onComplete(d, false);
}
コード例 #27
0
void FinishedManager::on(DownloadManagerListener::Complete, Download* d) noexcept {
    onComplete(d, false);
}
コード例 #28
0
void FinishedManager::on(QueueManagerListener::CRCChecked, Download* d) noexcept {
    onComplete(d, false, /*crc32Checked*/true);
}
コード例 #29
0
bool UIComplexModServiceTask::initService()
{
	m_OldBranch = getItemInfo()->getInstalledBranch();
	m_OldBuild = getItemInfo()->getInstalledBuild();

	UserCore::Item::ItemInfo* parentInfo = getParentItemInfo();

	if (getItemInfo()->getInstalledModId().isOk())
		parentInfo = getItemInfo();

	if (!parentInfo)
	{
		onComplete();
		return false;
	}

	m_idLastInstalledMod = parentInfo->getInstalledModId();
	getUserCore()->getItemManager()->setInstalledMod(parentInfo->getId(), DesuraId());

	if (!m_idLastInstalledMod.isOk())
	{
		onComplete();
		return false;
	}

	UserCore::Item::ItemInfo* modInfo = dynamic_cast<UserCore::Item::ItemInfo*>(getUserCore()->getItemManager()->findItemInfo(m_idLastInstalledMod));

	if (!modInfo)
	{
		gcException eModNoExist(ERR_NULLHANDLE, "Installed mod doesnt exist in database!\n");
		onErrorEvent(eModNoExist);
		return false;
	}

	m_pIPCCL = getServiceMain()->newComplexLaunch();

	if (!m_pIPCCL)
	{
		gcException eFailedUninstall (ERR_NULLHANDLE, "Failed to create uninstall complex branch mcf service!\n");
		onErrorEvent(eFailedUninstall);
		return false;
	}

	UserCore::MCFManager *mm = UserCore::GetMCFManager();

	gcString installPath = modInfo->getPath();
	gcString parPath = mm->getMcfBackup(parentInfo->getId(), m_idLastInstalledMod);
	gcString modMcfPath;

	if (m_idLastInstalledMod == getItemInfo()->getId())
		modMcfPath = getBranchMcf(modInfo->getId(), m_OldBranch, m_OldBuild);
	else
		modMcfPath = getBranchMcf(modInfo->getId(), modInfo->getInstalledBranch(), modInfo->getInstalledBuild());

	if (m_uiCompleteAction == CA_UNINSTALL)
		modInfo->resetInstalledMcf();

	m_pIPCCL->onCompleteEvent += delegate(this, &UIComplexModServiceTask::onComplete);
	m_pIPCCL->onProgressEvent += delegate(this, &UIComplexModServiceTask::onProgress);
	m_pIPCCL->onErrorEvent += delegate((UIBaseServiceTask*)this, &UIBaseServiceTask::onServiceError);
	m_pIPCCL->startRemove(modMcfPath.c_str(), parPath.c_str(), installPath.c_str(), getItemInfo()->getInstallScriptPath());	

	return true;
}
コード例 #30
0
ファイル: HttpParserImpl.cpp プロジェクト: jimmy486/kuma
HttpParserImpl::ParseState HttpParserImpl::parseChunk(const char*& cur_pos, const char* end)
{
    const char* p_line = nullptr;
    const char* p_end = nullptr;
    bool b_line = false;
    while (cur_pos < end)
    {
        switch (chunk_state_)
        {
            case CHUNK_READ_SIZE:
            {
                b_line = getLine(cur_pos, end, p_line, p_end);
                if(!b_line)
                {// need more data, save remain data.
                    if(saveData(cur_pos, end) != KUMA_ERROR_NOERR) {
                        return PARSE_STATE_ERROR;
                    }
                    cur_pos = end;
                    return PARSE_STATE_CONTINUE;
                }
                std::string str;
                if(!str_buf_.empty()) {
                    str.swap(str_buf_);
                    clearBuffer();
                }
                str.append(p_line, p_end);
                // need not parse chunk extension
                chunk_size_ = (uint32_t)strtol(str.c_str(), NULL, 16);
                KUMA_INFOTRACE("HttpParser::parseChunk, chunk_size="<<chunk_size_);
                if(0 == chunk_size_)
                {// chunk completed
                    chunk_state_ = CHUNK_READ_TRAILER;
                } else {
                    chunk_bytes_read_ = 0;
                    chunk_state_ = CHUNK_READ_DATA;
                }
                break;
            }
            case CHUNK_READ_DATA:
            {
                uint32_t cur_len = uint32_t(end - cur_pos);
                if(chunk_size_ - chunk_bytes_read_ <= cur_len) {// data enough
                    const char* notify_data = cur_pos;
                    uint32_t notify_len = chunk_size_ - chunk_bytes_read_;
                    total_bytes_read_ += notify_len;
                    chunk_bytes_read_ = chunk_size_ = 0; // reset
                    chunk_state_ = CHUNK_READ_DATA_CR;
                    cur_pos += notify_len;
                    bool destroyed = false;
                    destroy_flag_ptr_ = &destroyed;
                    if(cb_data_) cb_data_(notify_data, notify_len);
                    if(destroyed) {
                        return PARSE_STATE_DESTROY;
                    }
                    destroy_flag_ptr_ = nullptr;
                } else {// need more data
                    const char* notify_data = cur_pos;
                    total_bytes_read_ += cur_len;
                    chunk_bytes_read_ += cur_len;
                    cur_pos += cur_len;
                    if(cb_data_) cb_data_(notify_data, cur_len);
                    return PARSE_STATE_CONTINUE;
                }
                break;
            }
            case CHUNK_READ_DATA_CR:
            {
                if(*cur_pos != CR) {
                    KUMA_ERRTRACE("HttpParser::parseChunk, can not find data CR");
                    read_state_ = HTTP_READ_ERROR;
                    return PARSE_STATE_ERROR;
                }
                ++cur_pos;
                chunk_state_ = CHUNK_READ_DATA_LF;
                break;
            }
            case CHUNK_READ_DATA_LF:
            {
                if(*cur_pos != LF) {
                    KUMA_ERRTRACE("HttpParser::parseChunk, can not find data LF");
                    read_state_ = HTTP_READ_ERROR;
                    return PARSE_STATE_ERROR;
                }
                ++cur_pos;
                chunk_state_ = CHUNK_READ_SIZE;
                break;
            }
            case CHUNK_READ_TRAILER:
            {
                b_line = getLine(cur_pos, end, p_line, p_end);
                if(b_line) {
                    if(p_line == p_end && bufferEmpty()) {
                        // blank line, http completed
                        read_state_ = HTTP_READ_DONE;
                        onComplete();
                        return PARSE_STATE_DONE;
                    }
                    clearBuffer(); // discard trailer
                } else { // need more data
                    if(saveData(cur_pos, end) != KUMA_ERROR_NOERR) {
                        return PARSE_STATE_ERROR;
                    }
                    cur_pos = end; // all data was consumed
                    return PARSE_STATE_CONTINUE;
                }
                break;
            }
        }
    }
    return HTTP_READ_DONE == read_state_?PARSE_STATE_DONE:PARSE_STATE_CONTINUE;
}