Exemplo n.º 1
0
bool InstallWindow::Step2Finished()
{
    ui->animationLabel->hide();
    _movie.stop();
    disconnect(&_proc2, SIGNAL(finished(int)), this, SLOT(Step2Finished()));

    if (_proc2.exitCode() != 0)
        return Failed(tr("Cannot parse JSON: ") +
                   QString::fromLocal8Bit(_proc2.readAllStandardError()));

    QString result = QString::fromLocal8Bit(_proc2.readAllStandardOutput());

    // Parse returned Json answer
    if (!_game->ParseJson(result))
        return Failed(tr("Error parsing appinfo.json!"));

    // Check if ID matches
    QRegExp rx(_game->ID());
    if (!_game->JsonID().contains(rx))
        return Failed(tr("Seems to be wrong game or naming error!<br />"
                         "Ipk ID: %1<br />"
                         "Expected ID mask: %2")
                      .arg(_game->JsonID())
                      .arg(_game->ID()));

    PrintOK(_game->JsonTitle() + " " +
            _game->JsonVersion() + tr(" by ") +
            _game->JsonVendor());

    return Step3PrepareDirs();
}
bool
CompositorD3D11::UpdateConstantBuffers()
{
  HRESULT hr;
  D3D11_MAPPED_SUBRESOURCE resource;
  resource.pData = nullptr;

  hr = mContext->Map(mAttachments->mVSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
  if (Failed(hr) || !resource.pData) {
    gfxCriticalError() << "Failed to map VSConstantBuffer. Result: " << hr;
    return false;
  }
  *(VertexShaderConstants*)resource.pData = mVSConstants;
  mContext->Unmap(mAttachments->mVSConstantBuffer, 0);
  resource.pData = nullptr;

  hr = mContext->Map(mAttachments->mPSConstantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
  if (Failed(hr) || !resource.pData) {
    gfxCriticalError() << "Failed to map PSConstantBuffer. Result: " << hr;
    return false;
  }
  *(PixelShaderConstants*)resource.pData = mPSConstants;
  mContext->Unmap(mAttachments->mPSConstantBuffer, 0);

  ID3D11Buffer *buffer = mAttachments->mVSConstantBuffer;

  mContext->VSSetConstantBuffers(0, 1, &buffer);

  buffer = mAttachments->mPSConstantBuffer;
  mContext->PSSetConstantBuffers(0, 1, &buffer);
  return true;
}
Exemplo n.º 3
0
void
HttpRequest::Open (const char *verb, Uri *uri, DownloaderAccessPolicy policy)
{
    Surface *surface;
    Application *application;
    const char *source_location;
    Uri *src_uri = NULL;

    VERIFY_MAIN_THREAD;
    LOG_DOWNLOADER ("HttpRequest::Open (%s, %p = %s, %i)\n", verb, uri, uri == NULL ? NULL : uri->ToString (), policy);

    g_free (this->verb);
    delete original_uri;
    g_free (this->uri);

    this->verb = g_strdup (verb);
    this->original_uri = new Uri (*uri);
    this->uri = uri->ToString ();

    access_policy = policy;

    surface = GetDeployment ()->GetSurface ();
    application = GetDeployment ()->GetCurrentApplication ();

    if (application->IsRunningOutOfBrowser ()) {
        source_location = surface->GetSourceLocation ();
    } else {
        source_location = GetDeployment ()->GetXapLocation ();
        if (source_location == NULL)
            source_location = surface->GetSourceLocation ();
    }

    // FIXME: ONLY VALIDATE IF USED FROM THE PLUGIN
    if (!Downloader::ValidateDownloadPolicy (source_location, uri, policy)) {
        LOG_DOWNLOADER ("HttpRequest::Open (): aborting due to security policy violation\n");
        Failed ("Security Policy Violation");
        Abort ();
        return;
    }

    /* Make the uri we request to the derived http request an absolute uri */
    if (!uri->isAbsolute && source_location) {
        src_uri = new Uri ();
        if (!src_uri->Parse (source_location, true)) {
            Failed ("Could not parse source location");
            delete src_uri;
            return;
        }

        src_uri->Combine (uri);
        g_free (this->uri);
        this->uri = src_uri->ToString ();
        delete src_uri;
        LOG_DOWNLOADER ("HttpRequest::Open (%s, %p = %s, %i) Url was absolutified to '%s' using source location '%s'\n", verb, uri, uri == NULL ? NULL : uri->ToString (), policy, this->uri, source_location);
    }

    OpenImpl ();
}
void CTraverseBySourceExchange::SendPacket()
{
	m_bFailed = m_dwState & NAT_E_NOPEER;

	try
	{
		if(!m_bFailed && (m_dwState&NAT_S_SYNC)==0 && time(NULL)-m_SendReqTime > m_dwNextSyncInterval) //  5 seconds
		{
			//  failed to connect
			if(m_nSendReqCount > SYNC_ATTEMPT_TIMES)
			{
				m_dwState|=NAT_E_TIMEOUT;
				Failed();
			}
			else
			{
				if(m_nSendReqCount==0)
					_AddLogLine(false, _T("Begin to connect %s."), UserHashToString(m_UserHash));
				SendConnectReq();
			}
		}

		if(m_bFailed)
		{
			if(m_Sock)// && pClientSock->client)
			{
				//m_Sock->m_bUseNat = false;
			}

			if(m_dwState & NAT_E_NOPEER)
			{
				_AddLogLine(false, _T("Unconnected NatSock was deleted. server return E_NOPEER. %s."), UserHashToString(m_UserHash));
			}
			else
			{
				_AddLogLine(false, _T("Unconnected NatSock was deleted. time out. %s."), UserHashToString(m_UserHash));
			}
		}

		if(m_dwState & NAT_S_SYNC && time(NULL)-m_SendPingTime > PING_ATTEMPT_INTERVAL)
		{
			if(m_nPassivePing> PING_ATTEMPT_TIMES)
			{
				_AddLogLine(false, _T("Passive Unconnected NatSock was deleted. timeout. %s."), UserHashToString(m_UserHash));
				Failed();
			}
			else 
			{
				SendPingPacket();
			}
		}
	}
	catch(...)
	{
		//  the CAsyncSocketEx maybe is deleted
		Failed();
	}
}
Exemplo n.º 5
0
int CKMotionIO::NumberBytesAvailToRead(int *navail, bool ShowMessage)
{
	FT_STATUS ftStatus;
	DWORD EventDWord;
	DWORD RxBytes;
	DWORD TxBytes;

	*navail = strlen(m_SaveChars);  // take into account any already read in
	
	Mutex->Lock();
	ftStatus = FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord);

	if (ftStatus != FT_OK) 
	{
		if (ShowMessage)
			Failed();
		else
			m_Connected=false;

		Mutex->Unlock();
		return 1;
	}
	else
	{
		*navail+=(int)RxBytes;
		Mutex->Unlock();
		return 0;
	}
}
Exemplo n.º 6
0
 /* ---------------------------------------------------------------------------------------------
  * Send the payload to the associated server to keep the server alive in the master-list.
 */
 void Update(mg_mgr * manager)
 {
     // Is there a connection already waiting response and are we allowed to update?
     if (m_Conn || !m_Valid)
     {
         return; // Keep waiting for a reply and ignore this request
     }
     // Attempt to create a connection to the associated master-server
     m_Conn = mg_connect(manager, m_Addr.Addr(), EventHandler);
     // Make sure that the connection could be created
     if (!m_Conn)
     {
         MtVerboseError("Unable to create connection for '%s'", m_Addr.Addr());
         // This operation failed
         Failed();
     }
     else
     {
         // Set associated connection user data to this instance
         m_Conn->user_data = this;
         // Attach the HTTP protocol component
         mg_set_protocol_http_websocket(m_Conn);
         // Send the payload data
         mg_printf(m_Conn, "%s", m_Data);
         // Verbose status
         MtVerboseMessage("Connection created for '%s'", m_Addr.Addr());
     }
 }
Exemplo n.º 7
0
TemporaryRef<CompositingRenderTarget>
CompositorD3D11::CreateRenderTarget(const gfx::IntRect& aRect,
                                    SurfaceInitMode aInit)
{
  MOZ_ASSERT(aRect.width != 0 && aRect.height != 0);

  if (aRect.width * aRect.height == 0) {
    return nullptr;
  }

  CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, aRect.width, aRect.height, 1, 1,
                             D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);

  RefPtr<ID3D11Texture2D> texture;
  HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
  if (Failed(hr) || !texture) {
    return nullptr;
  }

  RefPtr<CompositingRenderTargetD3D11> rt = new CompositingRenderTargetD3D11(texture, aRect.TopLeft());
  rt->SetSize(IntSize(aRect.width, aRect.height));

  if (aInit == INIT_MODE_CLEAR) {
    FLOAT clear[] = { 0, 0, 0, 0 };
    mContext->ClearRenderTargetView(rt->mRTView, clear);
  }

  return rt;
}
Exemplo n.º 8
0
void Site::OnConnect(int iErrorCode)
{
    CIoKnockDlg *pDlg = theApp.GetDialog();

    if (!iErrorCode)
    {
        Close();
        m_bCloseNeeded = false;

        pDlg->SetKnock(m_dwCurrentKnock+1, true, _T("Knocked"));
        m_dwCurrentKnock++;
        NextKnock();
        return;
    }

    CString err;
    switch(iErrorCode)
    {
    case WSAECONNREFUSED:
        err.Format(_T("Error: Rejected"));
        break;
    case WSAENETUNREACH:
        err.Format(_T("Error: Unreachable"));
        break;
    case WSAETIMEDOUT:
        err.Format(_T("Error: Timeout"));
        break;
    default:
        err.Format(_T("Error: #%d"), iErrorCode);
    }
    pDlg->SetKnock(m_dwCurrentKnock+1, false, err);

    Failed(SITE_TIMEDOUT);
    pDlg->KnockDone();
}
Exemplo n.º 9
0
void
CompositorD3D11::VerifyBufferSize()
{
  DXGI_SWAP_CHAIN_DESC swapDesc;
  HRESULT hr;

  hr = mSwapChain->GetDesc(&swapDesc);
  if (Failed(hr)) {
    return;
  }

  if ((swapDesc.BufferDesc.Width == mSize.width &&
       swapDesc.BufferDesc.Height == mSize.height) ||
      mSize.width <= 0 || mSize.height <= 0) {
    return;
  }

  mDefaultRT = nullptr;

  if (IsRunningInWindowsMetro()) {
    hr = mSwapChain->ResizeBuffers(2, mSize.width, mSize.height,
                                   DXGI_FORMAT_B8G8R8A8_UNORM,
                                   0);
    HandleError(hr);
    mDisableSequenceForNextFrame = true;
  } else {
    hr = mSwapChain->ResizeBuffers(1, mSize.width, mSize.height,
                                   DXGI_FORMAT_B8G8R8A8_UNORM,
                                   0);
    HandleError(hr);
  }
}
void XITServerTest::TearDown() {
    alarm(0);
    if (server.Pid() != -1) {
        if (!server.Terminate(3000))
            server.Kill(3000);
        EXPECT_EQ(server.GetState(), xorg::testing::Process::FINISHED_SUCCESS) << "Unclean server shutdown";
        failed = failed || (server.GetState() != xorg::testing::Process::FINISHED_SUCCESS);

        std::ifstream logfile(server.GetLogFilePath().c_str());
        std::string line;
        std::string bug_warn("BUG");
        if (logfile.is_open()) {
            while(getline(logfile, line)) {
                size_t found = line.find(bug_warn);
                bool error = (found != std::string::npos);
                EXPECT_FALSE(error) << "BUG warning found in log" << std::endl << line << std::endl;
                failed = failed || error;
                break;
            }
        }
    }

    if (!Failed()) {
        config.RemoveConfig();
        server.RemoveLogFile();
    }

    testing::TestEventListeners &listeners = ::testing::UnitTest::GetInstance()->listeners();
    listeners.Release(this);
}
Exemplo n.º 11
0
void ezStatus::LogFailure(ezLogInterface* pLog)
{
  if (Failed())
  {
    ezLogInterface* pInterface = pLog ? pLog : ezLog::GetThreadLocalLogSystem();
    ezLog::Error(pInterface, "{0}", m_sMessage);
  }
}
Exemplo n.º 12
0
void VerifyResult(nsresult rv)
{
    if (NS_FAILED(rv))
    {
        Failed("rv failed");
        printf("rv = %d\n", rv);
    }
}
Exemplo n.º 13
0
void CInstance::CheckTime(uint32 tick)
{
	if (m_lastTimeCheck + 1000 <= tick && !Failed())
	{
		luautils::OnInstanceTimeUpdate(m_zone, this, GetElapsedTime(tick));
		m_lastTimeCheck = tick;
	}
}
Exemplo n.º 14
0
TemporaryRef<CompositingRenderTarget>
CompositorD3D11::CreateRenderTargetFromSource(const gfx::IntRect &aRect,
                                              const CompositingRenderTarget* aSource,
                                              const gfx::IntPoint &aSourcePoint)
{
  MOZ_ASSERT(aRect.width != 0 && aRect.height != 0);

  if (aRect.width * aRect.height == 0) {
    return nullptr;
  }

  CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
                             aRect.width, aRect.height, 1, 1,
                             D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);

  RefPtr<ID3D11Texture2D> texture;
  HRESULT hr = mDevice->CreateTexture2D(&desc, nullptr, byRef(texture));
  NS_ASSERTION(texture, "Could not create texture");
  if (Failed(hr) || !texture) {
    return nullptr;
  }

  if (aSource) {
    const CompositingRenderTargetD3D11* sourceD3D11 =
      static_cast<const CompositingRenderTargetD3D11*>(aSource);

    D3D11_BOX srcBox;
    srcBox.left = aSourcePoint.x;
    srcBox.top = aSourcePoint.y;
    srcBox.front = 0;
    srcBox.right = aSourcePoint.x + aRect.width;
    srcBox.bottom = aSourcePoint.y + aRect.height;
    srcBox.back = 1;

    const IntSize& srcSize = sourceD3D11->GetSize();
    MOZ_ASSERT(srcSize.width >= 0 && srcSize.height >= 0,
               "render targets should have nonnegative sizes");
    if (srcBox.left >= 0 &&
        srcBox.top >= 0 &&
        srcBox.left < srcBox.right &&
        srcBox.top < srcBox.bottom &&
        srcBox.right <= static_cast<uint32_t>(srcSize.width) &&
        srcBox.bottom <= static_cast<uint32_t>(srcSize.height)) {
      mContext->CopySubresourceRegion(texture, 0,
                                      0, 0, 0,
                                      sourceD3D11->GetD3D11Texture(), 0,
                                      &srcBox);
    } else {
      NS_WARNING("Could not copy render target - source rect out of bounds");
    }
  }

  RefPtr<CompositingRenderTargetD3D11> rt =
    new CompositingRenderTargetD3D11(texture, aRect.TopLeft());
  rt->SetSize(aRect.Size());

  return rt;
}
Exemplo n.º 15
0
void
CompositorD3D11::PaintToTarget()
{
  nsRefPtr<ID3D11Texture2D> backBuf;
  HRESULT hr;

  hr = mSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), (void**)backBuf.StartAssignment());
  if (Failed(hr)) {
    return;
  }

  D3D11_TEXTURE2D_DESC bbDesc;
  backBuf->GetDesc(&bbDesc);

  CD3D11_TEXTURE2D_DESC softDesc(bbDesc.Format, bbDesc.Width, bbDesc.Height);
  softDesc.MipLevels = 1;
  softDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
  softDesc.Usage = D3D11_USAGE_STAGING;
  softDesc.BindFlags = 0;

  nsRefPtr<ID3D11Texture2D> readTexture;

  hr = mDevice->CreateTexture2D(&softDesc, nullptr, getter_AddRefs(readTexture));
  if (Failed(hr)) {
    return;
  }
  mContext->CopyResource(readTexture, backBuf);

  D3D11_MAPPED_SUBRESOURCE map;
  hr = mContext->Map(readTexture, 0, D3D11_MAP_READ, 0, &map);
  if (Failed(hr)) {
    return;
  }
  RefPtr<DataSourceSurface> sourceSurface =
    Factory::CreateWrappingDataSourceSurface((uint8_t*)map.pData,
                                             map.RowPitch,
                                             IntSize(bbDesc.Width, bbDesc.Height),
                                             SurfaceFormat::B8G8R8A8);
  mTarget->CopySurface(sourceSurface,
                       IntRect(0, 0, bbDesc.Width, bbDesc.Height),
                       IntPoint(-mTargetBounds.x, -mTargetBounds.y));

  mTarget->Flush();
  mContext->Unmap(readTexture, 0);
}
Exemplo n.º 16
0
void ElevationLayeri3d::RequestTile(
   const std::string& sQuadcode, 
   boost::function<void(const std::string&, ElevationTile*)> cbfReady, 
   boost::function<void(const std::string&)> cbfFailed)
{
   if (Failed())
   {
      assert(false); // attempting to request tile from a failed image layer!!
      return;
   }

   if (!Ready())
   {
      assert(false); // attempting to request a tile from a non ready image layer!
      return;
   }

   // File-Format;
   std::string sExtension = ".elv";

   if (_oDatasetInfo.GetTileFormat() == "image/png")
   {
     
   }

   //  Check lod:
   
   unsigned int nRequestedLod = sQuadcode.length();
   unsigned int nLod = _oDatasetInfo.GetLevelOfDetail();
   bool bInterpolate = false;

   SElevationTileRequestI3D* pTileRequest = new SElevationTileRequestI3D;
   pTileRequest->cbfFailed = cbfFailed;
   pTileRequest->cbfReady = cbfReady;
   pTileRequest->pLayer = this;
   pTileRequest->sQuadcode = sQuadcode;

   if (nRequestedLod>nLod)
   {
      delete pTileRequest;
      // can't get!
   }
   else
   {
      pTileRequest->bInterpolate = false;
      pTileRequest->nLod = 0;
      std::string sFilename = FilenameUtils::DelimitPath(_servername + _layername);
      sFilename += sQuadcode;
      sFilename += sExtension;
      sFilename = FilenameUtils::MakeHierarchicalFileName(sFilename, 2);

      //ImageLoader::LoadFromUrl_ThreadedUnpack(eFormat, sFilename, ePixelformat, _OnImageReadyi3d, _OnImageFailedi3d, (void*) pTileRequest);

   }

  }
Exemplo n.º 17
0
 void
 outsync ()
 {
   if (!alone_ && ++silence_period_ >= Protocol::FATAL_SILENCE_FRAME)
   {
     // cerr << "Silence period has been passed." << endl;
     // cerr << "Decalring the node failed." << endl;
     throw Failed ();
   }
 }
Exemplo n.º 18
0
//
// Step 3
// Check if directories are exists and
// create root directories if needed
//
bool InstallWindow::Step3PrepareDirs()
{
    PrintStep(tr("Prepare directories"));

    QSettings settings(ORGANIZATION_NAME,
                       APPLICATION_NAME);

    QString mainName(_game->JsonTitle());

    if (mainName.isEmpty())
        return Failed(tr("Main property not found in Json: ") +
                   mainName);

    _game->SetBinPath(settings.value("Main/BinDir",
                               BIN_DIR_ROOT).toString()  +
                       QString("/") + mainName);
    _game->SetDataPath(settings.value("Main/DataDir",
                               DATA_DIR_ROOT).toString() +
                       QString("/") + mainName);

    QDir dataDir(_game->DataPath());
    QDir binDir(_game->BinPath());

    if (dataDir.exists())
        if (!ConfirmRemoveDir(dataDir.path()))
            return false;
    if (binDir.exists())
        if (!ConfirmRemoveDir(binDir.path()))
            return false;

    if (!dataDir.mkpath(dataDir.path()))
        return Failed(QString(tr("Can't create directory %1"))
                   .arg(dataDir.path()));

    if (!binDir.mkpath(binDir.path()))
        return Failed(QString(tr("Can't create directory %1"))
                   .arg(binDir.path()));

    PrintOK();
    return Step4Unpack();
}
Exemplo n.º 19
0
int CKMotionIO::ReadBytesAvailable(char *RxBuffer, int maxbytes, DWORD *BytesReceived, int timeout_ms)
{
	FT_STATUS ftStatus;
	DWORD EventDWord;
	DWORD RxBytes;
	DWORD TxBytes;

	Mutex->Lock();
	ftStatus=FT_GetStatus(ftHandle,&RxBytes,&TxBytes,&EventDWord);

	if (ftStatus != FT_OK)
	{
		Failed();
		Mutex->Unlock();
		return 1;
	}

	if ((int)RxBytes > maxbytes) RxBytes = maxbytes-1; // leave room for null

	RxBuffer[0]=0;  // set buf empty initially
	*BytesReceived=0;

	if (RxBytes > 0) 
	{
		ftStatus = FT_Read(ftHandle,RxBuffer,RxBytes,BytesReceived);
		if (ftStatus == FT_OK) 
		{
			RxBuffer[*BytesReceived]=0;  // null terminate
		}
		else 
		{
			Failed();
			Mutex->Unlock();
			return 1;
		}
	}

	Mutex->Unlock();
	return 0;
}
Exemplo n.º 20
0
void
HttpRequest::SendAsync ()
{
    char *templ;

    VERIFY_MAIN_THREAD;
    LOG_DOWNLOADER ("HttpRequest::SendAsync () is_aborted: %i is_completed: %i\n", is_aborted, is_completed);

    if (is_aborted || is_completed)
        return;

    /* create tmp file */
    if ((options & DisableFileStorage) == 0) {
        const char *dir = handler->GetDownloadDir ();
        if (dir == NULL) {
            Failed ("Could not create temporary download directory");
            return;
        }

        templ = g_build_filename (dir, "XXXXXX", NULL);
        tmpfile_fd = g_mkstemp (templ);
        if (tmpfile_fd == -1) {
            char *msg = g_strdup_printf ("Could not create temporary download file %s for url %s\n", templ, GetUri ());
            Failed (msg);
            g_free (msg);
            g_free (templ);
            return;
        }
        tmpfile = templ;
        LOG_DOWNLOADER ("HttpRequest::Send () uri %s is being saved to %s\n", GetUri (), tmpfile);
    } else {
        LOG_DOWNLOADER ("HttpRequest::Send () uri %s is not being saved to disk\n", GetUri ());
    }

#if DEBUG
    GetDeployment ()->AddSource (GetOriginalUri (), tmpfile == NULL ? "Not stored on disk" : tmpfile);
#endif

    SendImpl ();
}
Exemplo n.º 21
0
BOOL
Site::CancelKnock()
{
    CIoKnockDlg *pDlg = theApp.GetDialog();

    if (m_Status != SITE_KNOCKED)
    {
        pDlg->SetKnock(m_dwCurrentKnock+1, false, _T("Aborted"));
        Failed(SITE_ABORTED);
    }
    pDlg->KnockDone();
    return TRUE;
}
Exemplo n.º 22
0
ResultVal<std::shared_ptr<Directory>> ArchiveManager::OpenDirectoryFromArchive(
    ArchiveHandle archive_handle, const FileSys::Path& path) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return FileSys::ERR_INVALID_ARCHIVE_HANDLE;

    auto backend = archive->OpenDirectory(path);
    if (backend.Failed())
        return backend.Code();

    auto directory = std::shared_ptr<Directory>(new Directory(std::move(backend).Unwrap(), path));
    return MakeResult<std::shared_ptr<Directory>>(std::move(directory));
}
Exemplo n.º 23
0
void
HttpRequest::NotifyFinalUri (const char *value)
{
    g_free (final_uri);
    final_uri = g_strdup (value);

    // check if (a) it's a redirection and (b) if it is allowed for the current downloader policy

    if (!CheckRedirectionPolicy (final_uri)) {
        LOG_DOWNLOADER ("HttpRequest::NotifyFinalUri ('%s'): Security Policy Validation failed\n", value);
        Failed ("Security Policy Violation");
        Abort ();
    }
}
Exemplo n.º 24
0
void CTraverseByBuddy::SendPacket()
{
	try
	{
		if(!m_bFailed && (m_dwState&NAT_S_SYNC)==0 && time(NULL)-m_SendReqTime > 10)
		{
			//  failed to connect
			if(m_nSendReqCount>60)
			{
				m_dwState|=NAT_E_TIMEOUT;
				if(m_nSendReqCount>70)
					Failed();
				m_nSendReqCount++;
			}
			else
			{
				SendConnectReq();
				SendPingPacket();
			}
		}

		if(m_bFailed)
		{
			if(m_Sock)// && pClientSock->client)
			{
				//m_Sock->m_bUseNat = false;
			}
			_AddLogLine(false, _T("Unconnected NatSock was deleted. time out. %s."), UserHashToString(m_UserHash));
		}
	}
	catch(...)
	{
		//  the CAsyncSocketEx maybe is deleted
		TRACE("Exception: %s\n", __FUNCTION__);
		Failed();
	}
}
Exemplo n.º 25
0
bool InstallWindow::Step4Finished()
{
    ui->animationLabel->hide();
    _movie.stop();
    disconnect(&_proc1, SIGNAL(finished(int)), this, SLOT(Step4Finished()));

    if (_proc1.exitCode() != 0)
    {
        return Failed(tr("Cannot unpack archive:<br />") +
                      QString::fromLocal8Bit(_proc1.readAllStandardError()));
    }

    PrintOK();
    return Step5PrepareFiles();
}
Exemplo n.º 26
0
OCIType *OGROCISession::PinTDO( const char *pszType )

{
    OCIParam *hGeomParam = NULL;
    OCIRef *hGeomTypeRef = NULL;
    OCIType *hPinnedTDO = NULL;

    if( Failed( 
        OCIDescribeAny(hSvcCtx, hError, 
                       (text *) pszType, (ub4) strlen(pszType), 
                       OCI_OTYPE_NAME, (ub1)1, (ub1)OCI_PTYPE_TYPE, 
                       hDescribe ), 
        "GetTDO()->OCIDescribeAny()" ) )
        return NULL;

    if( Failed( 
        OCIAttrGet((dvoid *)hDescribe, (ub4)OCI_HTYPE_DESCRIBE,
                   (dvoid *)&hGeomParam, (ub4 *)0, (ub4)OCI_ATTR_PARAM, 
                   hError), "GetTDO()->OCIGetAttr(ATTR_PARAM)") )
        return NULL;

    if( Failed( 
        OCIAttrGet((dvoid *)hGeomParam, (ub4)OCI_DTYPE_PARAM,
                   (dvoid *)&hGeomTypeRef, (ub4 *)0, (ub4)OCI_ATTR_REF_TDO, 
                   hError), "GetTDO()->OCIAttrGet(ATTR_REF_TDO)" ) )
        return NULL;

    if( Failed( 
        OCIObjectPin(hEnv, hError, hGeomTypeRef, (OCIComplexObject *)0, 
                     OCI_PIN_ANY, OCI_DURATION_SESSION, 
                     OCI_LOCK_NONE, (dvoid **)&hPinnedTDO ),
        "GetTDO()->OCIObjectPin()" ) )
        return NULL;

    return hPinnedTDO;
}
Exemplo n.º 27
0
void CreateUniqueTest(const char* creationPath, const char* appendPath,
                 PRInt32 whatToCreate, PRInt32 perm)
{
    nsresult rv;
    nsCOMPtr<nsILocalFile> file =
        do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);

    if (NS_FAILED(rv) || (!file)) 
    {
        printf("create nsILocalFile failed\n");
        return;
    }

    Banner("Creation Test");
    printf("creationPath == %s\nappendPath == %s\n", creationPath, appendPath);

    rv = file->InitWithNativePath(nsDependentCString(creationPath));
    VerifyResult(rv);
 
    printf("Appending %s\n", appendPath);
    rv = file->AppendNative(nsDependentCString(appendPath));
    VerifyResult(rv);
    
    printf("Check For Existence\n");

    PRBool exists;
    file->Exists(&exists);

    if (exists)
        printf("Yup!\n");
    else
        printf("no.\n");


    rv = file->CreateUnique(whatToCreate, perm);  
    VerifyResult(rv);

    rv = file->Exists(&exists);
    VerifyResult(rv);

    
    if (!exists)
    {
        Failed("Did not create file system object!");
        return;
    }
    
}    
Exemplo n.º 28
0
void
HttpRequest::Abort ()
{
    VERIFY_MAIN_THREAD;
    LOG_DOWNLOADER ("HttpRequest::Abort () is_completed: %i is_aborted: %i original_uri: %s\n", is_completed, is_aborted, original_uri == NULL ? NULL : original_uri->ToString ());

    if (is_completed || is_aborted)
        return;

    is_aborted = true;
    AbortImpl ();

    Failed ("aborted");

    Dispose ();
}
Exemplo n.º 29
0
std::tuple<ResultVal<std::shared_ptr<File>>, std::chrono::nanoseconds>
ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys::Path& path,
                                    const FileSys::Mode mode) {
    ArchiveBackend* archive = GetArchive(archive_handle);
    if (archive == nullptr)
        return std::make_tuple(FileSys::ERR_INVALID_ARCHIVE_HANDLE,
                               static_cast<std::chrono::nanoseconds>(0));

    std::chrono::nanoseconds open_timeout_ns{archive->GetOpenDelayNs()};
    auto backend = archive->OpenFile(path, mode);
    if (backend.Failed())
        return std::make_tuple(backend.Code(), open_timeout_ns);

    auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
    return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}
Exemplo n.º 30
0
//
// Step 5
// Copy binary to bindir, create symlinks
//
bool InstallWindow::Step5PrepareFiles()
{
    PrintStep(tr("Prepare files and symlinks"));

    QString binaryBase = _game->JsonBinary().section('/', 0, -2);
    QString binaryFilename = _game->JsonBinary().section('/', -1, -1);
    QString fullDataDir(_game->DataPath() +
                        "/usr/palm/applications/" +
                        _game->JsonID() + "/");

    // Copy binary to BinDir
    QFile bin(fullDataDir + _game->JsonBinary());
    QString toPath(_game->BinPath() + "/" + binaryFilename);
    qDebug() << "Copying binary " << bin.fileName() << " to " <<
            toPath;
    if (!bin.copy(toPath))
        return Failed(tr("Cannot copy binary file ") +
                      bin.fileName() + " to " +
                      toPath);
    QFile copiedBin(toPath);
    copiedBin.setPermissions(copiedBin.permissions() | QFile::ExeOwner | QFile::ExeGroup);

    // Create symlinks
    // Assuming main game directory is the basedir for binary
    QDir baseDir(fullDataDir + binaryBase);
    baseDir.setFilter(QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
    QStringList filesList = baseDir.entryList();
    for (int i = 0; i < filesList.size(); ++i)
    {
        if (filesList.at(i) != binaryFilename)
        {
            QFile::link(fullDataDir + binaryBase + "/" + filesList.at(i),
                        _game->BinPath() + "/" + filesList.at(i));
            qDebug() << "Creating symlink from " <<
                    fullDataDir + binaryBase + "/" + filesList.at(i) <<
                    " to " << _game->BinPath() + "/" + filesList.at(i);
        }
    }

    PrintOK();
    Sync();

    return Step6CreateShortcuts();
}