std::wstring FacadeDocumentProviderImpl::TranslateOdmaID(const std::wstring& id)
{
	std::wstring repositoryId, artifactId, artifactVersionLabel;
	bool supports = GetConnector().GetInfoFromOdmaId(id, repositoryId, artifactId, artifactVersionLabel);     
	if(supports)
	{
		// TODO: We do the following to ensure that we always have a fully qualified workshare id.
		// Some connectors may not include the version label for the most current document in the ODMA id
		Artifact artifact = GetConnector().GetRepositoryById(repositoryId).GetArtifactById(artifactId, artifactVersionLabel);
		return EncodeWorkshareId(artifact.Id, artifact.VersionLabel, artifact.GetRepository().Id);
	}
	else
		return L"";

}
void FacadeDocumentProviderImpl::Configure()
{
	wchar_t fileName[_MAX_PATH] = {0};
	if(0 >= ::GetModuleFileNameW(NULL, fileName, _MAX_PATH))
		throw Workshare::System::SystemException(_T("Failed to get the filename of the running executable"));

	PathRemoveExtensionW(fileName);
	PathStripPathW(fileName);

	DialogStyle style = dsTab;
	if(0 == lstrcmpiW(fileName, L"winword"))
	{
		style = dsWizard;	
	}
	else if(0 == lstrcmpiW(fileName, L"WmConfigAssistant"))	
	{
		style = dsWcaWizard;	
	}
	else if(0 == lstrcmpiW(fileName, L"WmConfigPixie"))
	{
		style = dsWcaWizard;	
	}
	else if(0 == lstrcmpiW(fileName, L"Msiexec"))
	{
		style = dsWcaWizard;
	}

	ConnectorManager::Configure(GetConnector(), style);
}
void FacadeDocumentProviderImpl::Resolve(WSDocNonCom& wsDoc)
{
	LOG_WS_FUNCTION_SCOPE();
	std::wstring fileName(wsDoc.GetLocalFile().ToLower().c_str());
	std::wstring::size_type posHttps = fileName.find(L"https://");
	std::wstring::size_type posHttp = fileName.find(L"http://");
	if(fileName.npos == posHttps && fileName.npos == posHttp)
	{
		if(!PathFileExistsW(fileName.c_str()))
		{
			throw Workshare::System::IO::FileNotFoundException(fileName.c_str(), _T("The filename to obtain the workshare id from, must exist."));
		}
	}
	fileName = wsDoc.GetLocalFile();

	std::wstring repositoryId, artifactId, artifactVersionLabel;
	if (!GetConnector().GetInfoFromFileName(fileName, repositoryId, artifactId, artifactVersionLabel))
	{
		std::tostringstream errorMsg;
		errorMsg << _T("The file [") << fileName.c_str() << _T("] could not be resolved in the storage device [") << m_serviceId.c_str() << _T("].") << std::ends;
		throw Workshare::Com::ComException(errorMsg.str().c_str(), S_FALSE);
	}

	wsDoc.SetDocId(EncodeWorkshareId(artifactId, artifactVersionLabel, repositoryId));
}
Ejemplo n.º 4
0
bool CDRMUtils::OpenDrm()
{
  std::vector<const char*>modules =
  {
    "i915",
    "amdgpu",
    "radeon",
    "nouveau",
    "vmwgfx",
    "msm",
    "imx-drm",
    "rockchip",
    "vc4",
    "virtio_gpu",
    "sun4i-drm",
  };

  for(int i = 0; i < 10; ++i)
  {
    std::string device = "/dev/dri/card";
    device.append(std::to_string(i));

    for (auto module : modules)
    {
      m_fd = drmOpen(module, device.c_str());
      if (m_fd >= 0)
      {
        if(!GetResources())
        {
          continue;
        }

        if(!GetConnector())
        {
          continue;
        }

        drmModeFreeResources(m_drm_resources);
        m_drm_resources = nullptr;

        drmModeFreeConnector(m_connector->connector);
        m_connector->connector = nullptr;

        drmModeFreeObjectProperties(m_connector->props);
        m_connector->props = nullptr;

        drmModeFreeProperty(*m_connector->props_info);
        *m_connector->props_info = nullptr;

        CLog::Log(LOGDEBUG, "CDRMUtils::%s - opened device: %s using module: %s", __FUNCTION__, device.c_str(), module);
        return true;
      }

      drmClose(m_fd);
      m_fd = -1;
    }
  }

  return false;
}
void FacadeDocumentProviderImpl::InvokeCustomCommand(long lIndex, LONG_PTR hWnd)
{
	UNREFERENCED_PARAMETER(hWnd);
	if(0 != lIndex)
		throw Workshare::ArgumentException(_T("lIndex"), _T("Does not support any commands other than zero"));

	ConnectorManager::Configure(GetConnector(), dsTab);
}
Ejemplo n.º 6
0
bool CDRMUtils::InitDrm()
{
  if(m_fd >= 0)
  {
    /* caps need to be set before allocating connectors, encoders, crtcs, and planes */
    auto ret = drmSetClientCap(m_fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
    if (ret)
    {
      CLog::Log(LOGERROR, "CDRMUtils::%s - failed to set Universal planes capability: %s", __FUNCTION__, strerror(errno));
      return false;
    }

    if(!GetResources())
    {
      return false;
    }

    if(!GetConnector())
    {
      return false;
    }

    if(!GetEncoder())
    {
      return false;
    }

    if(!GetCrtc())
    {
      return false;
    }

    if(!GetPlanes())
    {
      return false;
    }
  }

  drmModeFreeResources(m_drm_resources);
  m_drm_resources = nullptr;

  if(m_fd < 0)
  {
    return false;
  }

  if(!GetPreferredMode())
  {
    return false;
  }

  drmSetMaster(m_fd);

  m_orig_crtc = drmModeGetCrtc(m_fd, m_crtc->crtc->crtc_id);

  return true;
}
Artifact FacadeDocumentProviderImpl::GetArtifactByWorkshareId(const std::wstring& workshareId)
{
	std::wstring artifactId;
	std::wstring versionLabel;
	std::wstring repositoryId;
	std::wstring id = RemoveServiceIdFromWorkshareId(this->ServiceId, workshareId);
	DecodeWorkshareId(id, artifactId, versionLabel, repositoryId);

	Repository repository = GetConnector().GetRepositoryById(repositoryId);
	return repository.GetArtifactById(artifactId, versionLabel);
}
Ejemplo n.º 8
0
Command* PadView::InterpConnectManip (Manipulator* m) {
    Editor* ed = m->GetViewer()->GetEditor();
    ConnectManip* cm = (ConnectManip*) m;
    ConnectorView* target = cm->GetTarget();
    Command* cmd = nil;

    if (target != nil) {
        cmd = new ConnectCmd(ed, GetConnector(), target->GetConnector());
    }
    return cmd;
}
long FacadeDocumentProviderImpl::GetCapabilities(const std::wstring& /*szDocServiceId*/, long /*lFlags*/)
{
	long flags = 0;
	flags |= !GetConnector().GetProperty(CAN_OVERWRITE_VERSIONS) ? 0x1 : 0x0;
	flags |= GetConnector().GetProperty(VERSION_INDEPENDENT_RELATED_DOCUMENTS) ? 0x4 : 0x0;
	flags |= GetConnector().GetProperty(SUPPORTS_OFFLINE_MODE) ? 0x8 : 0x0;
	flags |= !GetConnector().GetProperty(SUPPORTS_ATTACH_ORIGINAL) ? 0x10 : 0x0;
	flags |= !GetConnector().GetProperty(SUPPORTS_ATTACH_MODIFIED) ? 0x20 : 0x0;
	flags |= !GetConnector().GetProperty(CAN_CHANGE_VERSION_FORMAT) ? 0x40 : 0x0;
	flags |= GetConnector().GetProperty(NEEDS_SHARE_PATH_CONFIGURED) ? 0x80 : 0x0;
	flags |= !GetConnector().GetProperty(SUPPORTS_RELATE) ? 0x400 : 0x0;

	return flags;
}
//*******************************************************************************
void CBCGPDiagramVisualContainer::NotifyConnectorOnDisconnect (const CBCGPDiagramItemID& idObjectToDisconnect, const CBCGPDiagramItemID& idConnector)
{
	CBCGPDiagramConnector* pConnector = DYNAMIC_DOWNCAST(CBCGPDiagramConnector, GetConnector (idConnector));
	if (pConnector != NULL)
	{
		//pConnector->DisconnectFrom (idObjectToDisconnect);
		for (int i = 0; i < pConnector->GetPointCount (); i++)
		{
			CBCGPDiagramAnchorPoint& ptAnchor = pConnector->AnchorPoint (i);

			if (idObjectToDisconnect == ptAnchor.m_idObject)
			{
				ptAnchor = CBCGPDiagramAnchorPoint::NullAnchor (CalculatePoint (ptAnchor));
			}
		}
	}
}
//*******************************************************************************
CBCGPBaseVisualObject* CBCGPDiagramVisualContainer::GetItem (CBCGPDiagramItemID id) const
{
	if (id.m_bConnector)
	{
		return GetConnector (id);
	}
	else
	{
		CBCGPBaseVisualObject* pObject = NULL;
		if (m_mapItems.Lookup (id.m_nId, pObject))
		{
			ASSERT_VALID(pObject);
			return pObject;
		}
	}

	return NULL;
}
bool FacadeDocumentProviderImpl::SelectDocumentEx(LONG_PTR lHwnd, const std::wstring& formatString, const std::wstring& /*previousSelectedDocumentId*/, std::wstring& documentId)
{
	// TODO: We need a SelectArtifactVersion if previousSelectedDocumentId has something.
	LOG_WS_FUNCTION_SCOPE();

	Connector& connector = GetConnector();
	LOG_WS_INFO(L"Retrieved connector" );
	
	Artifact document = connector.SelectArtifact((HWND)lHwnd, formatString);
	if(document.IsNull())
	{
		LOG_WS_INFO(L"document == NULL" );
		return false;
	}

	documentId = EncodeWorkshareId(document.Id, document.VersionLabel, document.GetRepository().Id);	
	return true;
}
Ejemplo n.º 13
0
void ConnectorManager_Client::RemoveAllConnector(){

	uint32_t uConnectorCount = GetConnectorCount();
	for(uint32_t i = 0; i < uConnectorCount; i++)
	{
		if(m_aConnecorID[i] == INVALID_ID)
		{
			WriteLog(KERN_ERR "ConnectorManager::RemoveAllConnector(): Error ! m_aConnecorID[%d] == INVALID_ID", i );
			continue;
		}

		Connector* pConnector = GetConnector(m_aConnecorID[i]);
		if(pConnector == NULL)
		{
			WriteLog(KERN_ERR "ConnectorManager::RemoveAllConnector(): Error ! pConnector==NULL, id=%d ", m_aConnecorID[i] );
			continue;
		}

		RemoveConnector(pConnector);
	}
}
Ejemplo n.º 14
0
TMQTTModbusObserver::TMQTTModbusObserver(PMQTTClientBase mqtt_client,
                                         PHandlerConfig handler_config,
                                         PModbusConnector connector)
    : MQTTClient(mqtt_client),
      Config(handler_config)
{
    for (const auto& port_config : Config->PortConfigs) {
        if (port_config->DeviceConfigs.empty()) {
            std::cerr << "Warning: no devices defined for port "
                      << port_config->ConnSettings.Device
                      << " . Skipping. " << std::endl;
            continue;
        }

        Ports.push_back(
            std::unique_ptr<TModbusPort>(
                new TModbusPort(mqtt_client, port_config,
                                connector ? connector :
                                GetConnector(port_config))));
    }
}
Ejemplo n.º 15
0
	virtual int RunCommand(CSimpleOptA & opts) override
	{
		int retVal = 1;
		tscrypto::tsCryptoString username, password, url;

		opts.Init(opts.FileCount(), opts.Files(), OptionList, SO_O_NOERR | SO_O_USEALL | SO_O_ICASE);
		while (opts.Next())
		{
			if (opts.LastError() == SO_SUCCESS)
			{
				if (opts.OptionId() == OPT_HELP)
				{
					Usage();
					return 0;
				}
				else if (opts.OptionId() == OPT_URL)
				{
					url = opts.OptionArg();
				}
				else if (opts.OptionId() == OPT_PASSWORD)
				{
					password = opts.OptionArg();
				}
				else if (opts.OptionId() == OPT_USERNAME)
				{
					username = opts.OptionArg();
				}
				else
				{
					Usage();
					return 1;
				}
			}
			else
			{
				Usage();
				return 1;
			}
		}

		std::shared_ptr<IKeyVEILConnector> connector = GetConnector(url, username, password);

		if (!connector)
		{
			printf("An error occurred while creating the KeyVEIL connector.\n");
			return 0;
		}

		size_t count = connector->tokenCount();
		for (size_t i = 0; i < count; i++)
		{
			std::shared_ptr<IToken> token = connector->token(i);

			printf("Token:  %s\n", token->tokenName().c_str());
			printf("    serial number:  %s\n         Token ID:  %s\n", token->serialNumber().ToHexString().c_str(), TSGuidToString(token->id()).c_str());
			printf("       Enterprise:  %s\n    Enterprise ID:  %s\n", token->enterpriseName().c_str(), TSGuidToString(token->enterpriseId()).c_str());
			printf("           Member:  %s\n        Member ID:  %s\n", token->memberName().c_str(), TSGuidToString(token->memberId()).c_str());

			std::shared_ptr<IKeyVEILSession> session = token->openSession();
			if (!!session)
			{
				printf("        Is Locked:  %s\n      Retry count:  %d\n", session->IsLocked() ? "true" : "false", (int)session->retriesLeft());
			}
			printf("\n");
		}


		return retVal;
	}
HRESULT FacadeDocumentProviderImpl::GetSaveInfo(HWND hWnd, const std::wstring& formatString, long lFlags, long& lFormatIndex, WSDocNonCom& wsDoc)
{
	//-- ArtifactImpl
	//TODO: Replace Existing Version
	//TODO: Create a relation

	//-- Connector
	// Create new artifact (Add Files)
	UNREFERENCED_PARAMETER(lFormatIndex);
	if(DF_NEW_DOCUMENT & lFlags)
	{
		std::wstring newFileName = wsDoc.GetDescription();
		Artifact artifact = GetConnector().CreateArtifact(hWnd, formatString, newFileName);
		if (artifact.IsNull())
			return E_DOCUMENT_NOT_FOUND;
		PopulateWSDocMembersFromArtifact(artifact, wsDoc);
		wsDoc.SetFlags(DOCUMENT_LOCKED_BY_US);
		lFormatIndex = CalculateFormatIndex(formatString, artifact.GetFileExtension());
		artifact.Lock();
	}
	// Create a relation
	else if(DF_ATTACH & lFlags)
	{
		Artifact existing = GetArtifactByWorkshareId(wsDoc.GetDocId());	

		if (existing.IsNull())
			return E_DOCUMENT_NOT_FOUND;

		CStdString sDummyFile = CTempFileManager::GetTempFileName();;
		CStdString sExt; 
		DocUtilities::GetExtensionFromFileName(sDummyFile,sExt);

		Artifact related = existing.CreateRelatedItem(CStdStringW(sDummyFile),GetDefaultSaveExtensionFromFormatString(formatString, lFormatIndex), formatString, true);

		if (related.IsNull())
			return E_DOCUMENT_NOT_FOUND;

		related.Lock();

		PopulateWSDocMembersFromArtifact(related, wsDoc);
		lFormatIndex = CalculateFormatIndex(formatString, related.GetFileExtension());

		wsDoc.SetFlags(DOCUMENT_LOCKED_BY_US);
	}
	// Create a new version
	else if(DF_VERSION & lFlags)
	{
		std::wstring repositoryId;
		std::wstring artifactId;
		std::wstring versionLabel;
		DecodeWorkshareId(wsDoc.GetDocId().c_str(), artifactId, versionLabel, repositoryId);
		Repository repository = GetConnector().GetRepositoryById(repositoryId.c_str());
		Artifact artifact = repository.GetArtifactById(artifactId.c_str(), versionLabel.c_str());
		Artifact artifactVersion = artifact.CreateNewVersion(L"", formatString);
		PopulateWSDocMembersFromArtifact(artifactVersion, wsDoc);
		artifactVersion.Lock(); 
		wsDoc.SetFlags(DOCUMENT_LOCKED_BY_US);
		lFormatIndex = CalculateFormatIndex(formatString, artifactVersion.GetFileExtension());

	}
	return S_OK;
}
Ejemplo n.º 17
0
bool	ConnectorManager_Client::Handle_Inputs()
{
	try
	{
		m_nEvents = epoll_wait(m_Epollfd, events, m_uEventsMaxSize, 0);
		if(m_nEvents > m_uEventsMaxSize || m_nEvents < 0)
		{
			WriteLog(KERN_ERR "epoll wait Error ! m_nEvents=%d", m_nEvents);
		}

	}
	catch(...)
	{
		WriteLog(KERN_ERR "ConnectorManager_Client::epoll_wait(): Error ! m_nEvents=%d", m_nEvents);
	}

	bool ret = false;

	for(int i = 0; i < m_nEvents; i++)
	{

		int32_t SockFD = GetHighSection(events[i].data.u64);
		ConnectorID_t idx = GetLowSection(events[i].data.u64);

		if(SockFD == m_SocketID)
		{
			if( m_bServerMode )
			{
				for(int32_t i = 0; i < ACCEPT_ONESTEP; i++)
				{
					if(AcceptNewConnection()==NULL) 
						break;
				}
			}
		}
		else if( events[i].events & EPOLLIN )
		{
			Connector* pConnector = GetConnector(idx);

			if( pConnector == NULL )
			{
				WriteLog(KERN_ERR "ConnectorManager_Epoll::ProcessInputs(): Error ! pConnector==NULL,id=%d", idx );
				continue;
			}

			if( pConnector->IsDisconnect() )
				continue;

			int fd = pConnector->GetSocket()->getFD();

			if(fd == INVALID_SOCKET)
			{
				WriteLog(KERN_ERR "ConnectorManager_Epoll::ProcessInputs(): Error ! socket==INVALID" );
				continue;
			}

			if(pConnector->GetSocket()->isSockError())
			{
				RemoveConnector(pConnector);
			}
			else
			{
				_NET_TRY
				{
					ret = pConnector->Handle_Input();
					if(!ret)
					{
						RemoveConnector(pConnector);
					}
				}
				_NET_CATCH
				{
					RemoveConnector(pConnector);
				}
			}
		}
	}
bool FacadeDocumentProviderImpl::IsConfigured()
{
	return GetConnector().IsConfigured();
}
// IWSDocumentProvider10
bool FacadeDocumentProviderImpl::TestConnection(const std::wstring& wsServer)
{
	return GetConnector().TestConnection(wsServer);
}
Ejemplo n.º 20
0
bool ConnectorManager_Client::DelConnector(Connector *pConnector){

	if( pConnector == NULL )
	{
		WriteLog(KERN_ERR "ConnectorManager::AddConnector(): Error ! pConnector == NULL" );
		return false;
	}

	int32_t fd = pConnector->GetSocket()->getFD();
	ConnectorID_t ConnectorID = pConnector->GetConnectorID();
	Connector* pLastConnector = NULL;
	ID_t ManagerID = INVALID_ID;

	bool bRet = false;

	bRet = DelConnectorSocket(pConnector->GetSocket()->getFD());

	if( !bRet )
	{
		WriteLog(KERN_ERR "ConnectorManager::DelConnector(): Error ! DelConnectorSocket Failed!" );
		goto EXCEPTION;
		return false;
	}

	if( m_uConnectorCount<=0 )
	{
		WriteLog(KERN_ERR "ConnectorManager::DelConnector(): Error ! count(%d)<=0", m_uConnectorCount );
		goto EXCEPTION;
		return false;
	}

	ManagerID = pConnector->GetManagerID();
	if(ManagerID < 0 || ManagerID >= m_uMaxConnectorCount)
	{
		WriteLog(KERN_ERR "ConnectorManager::DelConnector(): Error ! Invalid ManagerID %d second time", ManagerID );
		goto EXCEPTION;
		return false;
	}

	pLastConnector = GetConnector(m_aConnecorID[m_uConnectorCount - 1]);
	if( pLastConnector == NULL )
	{
		WriteLog(KERN_ERR
				"ConnectorManager::DelConnectorFromMgr(): Error ! pLastConnector==NULL,count=%d,id=%d",
				m_uConnectorCount,
				m_aConnecorID[m_uConnectorCount - 1]
				);
		goto EXCEPTION;
		return false;
	}

	if( pConnector != pLastConnector )
	{
		m_aConnecorID[ManagerID] = m_aConnecorID[m_uConnectorCount - 1];
		m_aConnecorID[m_uConnectorCount - 1] = INVALID_ID;
		pLastConnector->SetManagerID(ManagerID);
		pConnector->SetManagerID(INVALID_ID);
	}
	else
	{
		m_aConnecorID[ManagerID] = INVALID_ID;
		pConnector->SetManagerID(INVALID_ID);
	}

	m_uConnectorCount--;

	WriteLog(KERN_INFO "ConnectorManager::DelConnector(): Success ! fd=%d, pid=%d", fd, ConnectorID );

	return true;

EXCEPTION:
	DelConnectorSocket(pConnector->GetSocket()->getFD());
	return false;
}