Ejemplo n.º 1
0
int CIEProxy::ReadReg()
{
	SetEnable(0);
	SetHost("");
	SetPort2(-1);
	SetOverride("");

	HKEY hKeyIn = HKEY_CURRENT_USER, hKeyOut;
	if( ERROR_SUCCESS != RegOpenKeyExA(hKeyIn, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", 0, KEY_CREATE_LINK | KEY_WRITE | KEY_READ | KEY_NOTIFY, &hKeyOut))
	{
		return -1;
	}
	
	DWORD proxyEnable = 0;
	ULONG regSize = sizeof(DWORD);
	if(ERROR_SUCCESS != RegQueryValueExA(hKeyOut, "ProxyEnable", NULL, NULL, (BYTE *)&proxyEnable, &regSize))
	{
		return 0;
	}

	SetEnable(proxyEnable);

	char proxyServer[1024] = { 0 };
	regSize = sizeof(proxyServer);
	if(ERROR_SUCCESS != RegQueryValueExA(hKeyOut, "ProxyServer", NULL, NULL, (BYTE *)&proxyServer, &regSize))
	{
		return 0;
	}

	string strProxyServer = proxyServer;
	if(strProxyServer.find("://") != string::npos)
	{
		strProxyServer = strProxyServer.substr(strProxyServer.find("://") + 3);
	}

	if(strProxyServer.find(":") != string::npos)
	{
		SetHost(strProxyServer.substr(0, strProxyServer.find(":")));
		SetPort2(atoi(strProxyServer.substr(strProxyServer.find(":") + 1).c_str()));
	}
	else
	{
		SetHost(strProxyServer);
		SetPort2(80);
	}

	char proxyOverride[1024] = { 0 };
	regSize = sizeof(proxyOverride);
	if(ERROR_SUCCESS == RegQueryValueExA(hKeyOut, "ProxyOverride", NULL, NULL, (BYTE *)&proxyOverride, &regSize))
	{
		SetOverride(proxyOverride);
	}

	return 0;
}
Ejemplo n.º 2
0
BOOL Gadgets2NetworkPrefs(struct NetPEditor_DATA *data)

{
    STRPTR str = NULL;
    IPTR lng = 0;

    GET(data->netped_deviceString, MUIA_String_Contents, &str);
    SetDevice(str);
    GET(data->netped_IPString, MUIA_String_Contents, &str);
    SetIP(str);
    GET(data->netped_maskString, MUIA_String_Contents, &str);
    SetMask(str);
    GET(data->netped_gateString, MUIA_String_Contents, &str);
    SetGate(str);
    GET(data->netped_DNSString[0], MUIA_String_Contents, &str);
    SetDNS(0, str);
    GET(data->netped_DNSString[1], MUIA_String_Contents, &str);
    SetDNS(1, str);
    GET(data->netped_hostString, MUIA_String_Contents, &str);
    SetHost(str);
    GET(data->netped_domainString, MUIA_String_Contents, &str);
    SetDomain(str);
    GET(data->netped_DHCPState, MUIA_Cycle_Active, &lng);
    SetDHCP(lng);
    GET(data->netped_Autostart, MUIA_Selected, &lng);
    SetAutostart(lng);

    return TRUE;
}
Ejemplo n.º 3
0
EHost IPlugVST::GetHost()
{
  EHost host = IPlugBase::GetHost();

  if (host == kHostUninit)
  {
    char productStr[256];
    productStr[0] = '\0';
    int version = 0;
    mHostCallback(&mAEffect, audioMasterGetProductString, 0, 0, productStr, 0.0f);

    if (CSTR_NOT_EMPTY(productStr))
    {
      int decVer = mHostCallback(&mAEffect, audioMasterGetVendorVersion, 0, 0, 0, 0.0f);
      int ver = decVer / 10000;
      int rmaj = (decVer - 10000 * ver) / 100;
      int rmin = (decVer - 10000 * ver - 100 * rmaj);
      version = (ver << 16) + (rmaj << 8) + rmin;
    }

    SetHost(productStr, version);
    host = IPlugBase::GetHost();
  }

  return host;
}
Ejemplo n.º 4
0
wxPOP3::wxPOP3(wxString client_name,
               wxString client_password,
               wxString server_name,
               unsigned long port,
               AuthenticationScheme_t authentication_scheme,
               bool ssl_enabled,
               Listener* default_listener)
      :default_instance_listener(default_listener),
       user_name(client_name),
       user_password(client_password),
       in_init(true),
       ssl_enabled(ssl_enabled),
       authentication_scheme(authentication_scheme)
{
   timeout_value = DEFAULT_TIMEOUT_VALUE;

   SetHost(server_name, port);

   if (default_instance_listener == NULL)
   {
      default_instance_listener = &default_class_listener;
   }
   
   ChangeState(exit_state);

   in_init = false;
}
Ejemplo n.º 5
0
Archivo: Nick.cpp Proyecto: jimloco/znc
void CNick::Clone(const CNick& SourceNick) {
	SetNick(SourceNick.GetNick());
	SetIdent(SourceNick.GetIdent());
	SetHost(SourceNick.GetHost());

	m_sChanPerms = SourceNick.m_sChanPerms;
	m_pNetwork = SourceNick.m_pNetwork;
}
// --------------------------------------------------------------------------
// CUPnPPlayListFiller::FillL
// Fill track data into the playlist
// --------------------------------------------------------------------------
//
void CUPnPPlayListFiller::FillL(
    CUPnPMusicAdapter& aHost,
    CMPXMediaArray& aPlaylist )
    {
    __LOG( "CUPnPPlayListFiller::FillL" );
    SetHost( aHost );
    DoFillL( aPlaylist, iItemList );
    DoComplete();
    }
Ejemplo n.º 7
0
void Client::ConnectToHost(const char* host, int portNum)
{
  SetHost(host);

  bzero((char *) &m_serv_addr, sizeof(m_serv_addr));
  m_serv_addr.sin_family = AF_INET;
  bcopy((char *)m_pServer->h_addr, (char *)&m_serv_addr.sin_addr.s_addr, m_pServer->h_length);
  m_serv_addr.sin_port = htons(portNum);
  if(connect(m_sockfd, (struct sockaddr *) &m_serv_addr, sizeof(m_serv_addr)) < 0)
    error("ERROR connecting!");
}
Ejemplo n.º 8
0
void CCore::ConnectToServer(CString strHost, unsigned short usPort, CString strPass)
{
	// Declare our basic network connection
	SetHost(strHost);
	SetClientPort(usPort);
	SetPass(strPass);

	// Connect to the network
	CHECK_VALID_VOID(m_pNetworkManager)
		m_pNetworkManager->Connect(GetHost(), (unsigned short) GetPort(), GetPass());
}
Ejemplo n.º 9
0
/**
 * @class UVWSConnection UVConnection.h
 * @brief implements an unsecured WebSocket connection over a libuv raw tcp socket.
 * sets up two connected CnxLayers ... a websocket layer, which will talk to a uv layer ... the object using us will request stuff which we push to the ws layer which then
 * talks over uv.
 *
 * connectState will be READY only once we have a correctly negotiated web socket
 */
UVWSConnection::UVWSConnection(std::string service, std::string host)
	: AbstractConnection(host, service)
	, CnxLayerUpper()
	, ws(this, &uv)
	, uv(&ws, service, host)
{
	SetHost(host);
	SetService(service);
	ConnectionPropertySet s;
	s.insert(CONNECTION_PERSISTENT);
	SetProperties(s);
}
Ejemplo n.º 10
0
/**
 * Gets HTML from the Given URL if bDownload is true and gets Host and Scheme out of the URL
 * @param sUrl Web page URL
 * @param bDownload if true Html is downloaded from the specified URL otherwise it is assumed
 * that HTML is already populated using SetHtml() function
 */
void COfflineBrowser::LoadHtml(const std::string& sUrl, bool bDownload /*= false*/)
{
	if(bDownload)
	{
		//Download Web Page using WININET
		HINTERNET hNet = InternetOpen("Offline Browser", INTERNET_OPEN_TYPE_PRECONFIG/*INTERNET_OPEN_TYPE_PROXY*/,
									  NULL, NULL, 0);
		if(hNet == NULL)
		{
			DWORD dwErr = GetLastError();
			return;
		}

		HINTERNET hFile = InternetOpenUrl(hNet, sUrl.c_str(), NULL, 0, 0, 0); 
		if(hFile == NULL)
			return;

		while(true)
		{
			const int MAX_BUFFER_SIZE = 65536;
			unsigned long nSize = 0;
			wchar_t szBuffer[MAX_BUFFER_SIZE+1];
			BOOL bRet = InternetReadFile(hFile, szBuffer, MAX_BUFFER_SIZE, &nSize);
			if(!bRet || nSize <= 0)
				break;
			szBuffer[nSize] = '\0';
			m_sHtml += szBuffer;
		}
	}

	//Get host name and scheme(protocol) out of URL
	int nStart = sUrl.find("://");
	if(nStart < 0)
		nStart = 0;
	else 
	{
		nStart += strlen("://");
		m_sScheme = sUrl.substr(0, nStart);
	}
	std::string sTemp = sUrl.substr(nStart, sUrl.length()-nStart);
	int nEnd = sTemp.find("/");
	if(nEnd < 0)
		nEnd = sUrl.length();
	sTemp = sTemp.substr(0, nEnd);
	
	if(sTemp[sTemp.length()-1] != '/')
		sTemp += "/";

	SetHost(sTemp);
}
Ejemplo n.º 11
0
IPlugAAX::IPlugAAX(IPlugInstanceInfo instanceInfo, 
                                 int nParams, 
                                 const char* channelIOStr, 
                                 int nPresets,
                                 const char* effectName, 
                                 const char* productName, 
                                 const char* mfrName,
                                 int vendorVersion, 
                                 int uniqueID, 
                                 int mfrID, 
                                 int latency,
                                 bool plugDoesMidi, 
                                 bool plugDoesChunks, 
                                 bool plugIsInst,
                                 int plugScChans)
: IPlugBase(nParams,
            channelIOStr,
            nPresets,
            effectName,
            productName,
            mfrName,
            vendorVersion,
            uniqueID,
            mfrID,
            latency,
            plugDoesMidi,
            plugDoesChunks,
            plugIsInst,
            kAPIAAX)

, AAX_CIPlugParameters()
, mTransport(0)
{
  Trace(TRACELOC, "%s%s", effectName, channelIOStr);

  SetInputChannelConnections(0, NInChannels(), true);
  SetOutputChannelConnections(0, NOutChannels(), true);
  
  if (NInChannels()) 
  {
    mDelay = new NChanDelayLine(NInChannels(), NOutChannels());
    mDelay->SetDelayTime(latency);
  }
  
  SetBlockSize(DEFAULT_BLOCK_SIZE);
  SetHost("ProTools", vendorVersion); // TODO:vendor version correct?  
}
Ejemplo n.º 12
0
bool CHostTracker::InitConfig()
{	
	stHostTrackerConfigInfo* configInfo = rho_wmimpl_get_hostTrackerInfo();
	m_bIsFeatureEnabled = configInfo->isTrackConnectionSet;	
	if(m_bIsFeatureEnabled)
	{
		SetHost(configInfo->szHostName);
		SetPort(configInfo->iPort);
		SetNetworkPollInterval(configInfo->iPollInterval);
		SetConnectionTimeout(configInfo->iPingTimeout);
		SetConnectionDlgTimeout(configInfo->iDialogTimeout);
		SetBadLinkUrl(rho_wmimpl_get_BadLinkURLPath());
		m_szConnectionDlgMsg = rho_wmimpl_get_HostTrackerDlgMsg();	
	}
	
	return true;
}
Ejemplo n.º 13
0
IPlugStandalone::IPlugStandalone(IPlugInstanceInfo instanceInfo,
                                 int nParams,
                                 const char* channelIOStr,
                                 int nPresets,
                                 const char* effectName,
                                 const char* productName,
                                 const char* mfrName,
                                 int vendorVersion,
                                 int uniqueID,
                                 int mfrID,
                                 int latency,
                                 bool plugDoesMidi,
                                 bool plugDoesChunks,
                                 bool plugIsInst,
                                 int plugScChans)
  : IPlugBase(nParams,
              channelIOStr,
              nPresets,
              effectName,
              productName,
              mfrName,
              vendorVersion,
              uniqueID,
              mfrID,
              latency,
              plugDoesMidi,
              plugDoesChunks,
              plugIsInst,
              kAPISA)
{
  Trace(TRACELOC, "%s%s", effectName, channelIOStr);

  SetInputChannelConnections(0, NInChannels(), true);
  SetOutputChannelConnections(0, NOutChannels(), true);

  SetBlockSize(DEFAULT_BLOCK_SIZE);
  SetHost("standalone", vendorVersion);

  #ifdef OS_IOS
  mIOSLink = instanceInfo.mIOSLink;
  #else
  mMidiOutChan = instanceInfo.mMidiOutChan;
  mMidiOut = instanceInfo.mRTMidiOut;
  #endif
}
Ejemplo n.º 14
0
status_t
GoogleTalk::UpdateSettings( BMessage & msg )
{
	const char *username = NULL;
	const char *password = NULL;
	const char *res = NULL;
	
	msg.FindString("username", &username);
	msg.FindString("password", &password);
	msg.FindString("resource", &res);
	
	if ( (username == NULL) || (password == NULL) ){ 
		LOG( kProtocolName, liHigh, "Invalid settings!");
		return B_ERROR;
	};
	
	fUsername = username;
	int32 atpos=fUsername.FindLast("@");
	if(	 atpos> 0 ) {
		BString server;
		fUsername.CopyInto(server,atpos + 1,fUsername.Length()-atpos);
		fUsername.Remove(atpos,fUsername.Length()-atpos);
		LOG( kProtocolName, liHigh, "Server %s\n",server.String());
		fServer = server;		
	}
	else
		fServer.SetTo("gmail.com");
		
	
	fPassword = password;
	
	SetUsername(fUsername);
	SetHost(fServer);
	SetPassword(fPassword);
	
	if(strlen(res)==0)
		SetResource("IMKit GoogleTalk AddOn");
	else
		SetResource(res);
	
	SetPriority(5);
	SetPort(5222);
	
	return B_OK;
}
Ejemplo n.º 15
0
status_t
Jabber::UpdateSettings( BMessage & msg )
{
	const char *username = NULL;
	const char *server=NULL;
	const char *password = NULL;
	const char *res = NULL;
	
	msg.FindString("username", &username);
	msg.FindString("server",&server);
	msg.FindString("password", &password);
	msg.FindString("resource", &res);
	
	if ( (username == NULL) || (password == NULL) || (server == NULL)) {
//		invalid settings, fail
		LOG( kProtocolName, liHigh, "Invalid settings!");
		return B_ERROR;
	};
	
	fUsername = username;
	fServer = server;
	fPassword = password;
	
	SetUsername(fUsername);
	SetHost(fServer);
	SetPassword(fPassword);
	
	if(strlen(res)==0)
		SetResource("IMKit Jabber AddOn");
	else
		SetResource(res);
	
	SetPriority(5);
	SetPort(5222);
	
	return B_OK;
}
Ejemplo n.º 16
0
EPromoteRoomHost GroupFairyLandRoom::OnPromoteRoomHost(unsigned int nRoleID, char nNewHostRoomType, char nNewHostPos)
{
    if (HostRoleID() != nRoleID)
        return PromoteRoomHost_NoAuthority;

    if (nNewHostRoomType != RoleRoomType_Dancer)
        return PromoteRoomHost_UnKnow; //

    unsigned int nNewHostRoleID = m_pRoomPosManager->GetPostionRole(RoleRoomType_Dancer, nNewHostPos);
    if (0 == nNewHostRoleID)
        return PromoteRoomHost_NewHostNotInRoom; // 

    ERoleRoomType eOldHostType;
    unsigned int nOldHostPos;
    if (!m_pRoomPosManager->GetRolePos(nRoleID, eOldHostType, nOldHostPos))
        return PromoteRoomHost_UnKnow;
    LWDanceRoleInfo *pOldHost = m_pRoomDanceInfo->GetDanceRole(nRoleID);
    LWDanceRoleInfo *pNewHost = m_pRoomDanceInfo->GetDanceRole(nNewHostRoleID);
    if (NULL == pNewHost || NULL == pOldHost)
        return PromoteRoomHost_UnKnow;

    SetHost(nNewHostRoleID); // 设置新的房主
    m_pRoomDanceInfo->SetDancerState(nNewHostRoleID, RoleRoomState_Ready);
    m_pRoomDanceInfo->SetDancerState(nRoleID, RoleRoomState_Wait);

    GameMsg_S2C_PromoteRoomHostSuc sucMsg;
    sucMsg.m_chOldHostRoomType = (char)eOldHostType;
    sucMsg.m_chOldHostRoomPos = (char)nOldHostPos;
    sucMsg.m_chOldHostState = (char)pOldHost->GetState();
    sucMsg.m_chNewHostRoomType = (char)nNewHostRoomType;
    sucMsg.m_chNewHostRoomPos = (char)nNewHostPos;
    sucMsg.m_chNewHostRoomState = (char)pNewHost->GetState();

    RoomGroupCommon::SendMsgToAll(this, sucMsg, 0);

    return PromoteRoomHost_Sucess;
}
Ejemplo n.º 17
0
tresult PLUGIN_API IPlugVST3Plugin::initialize (FUnknown* context)
{
  TRACE;

  tresult result = SingleComponentEffect::initialize(context);

  String128 tmpStringBuf;
  char hostNameCString[128];
  FUnknownPtr<IHostApplication>app(context);

  if (app)
  {
    app->getName(tmpStringBuf);
    Steinberg::UString(tmpStringBuf, 128).toAscii(hostNameCString, 128);
    SetHost(hostNameCString, 0); // Can't get version in VST3
  }

  if (result == kResultOk)
  {
    int maxInputs = getSpeakerArrForChans(NInChannels()-mScChans);
    if(maxInputs < 0) maxInputs = 0;

    // add io buses with the maximum i/o to start with

    if (maxInputs)
    {
      Steinberg::UString(tmpStringBuf, 128).fromAscii(GetInputBusLabel(0)->Get(), 128);
      addAudioInput(tmpStringBuf, maxInputs);
    }

    if(!mIsInst) // if effect, just add one output bus with max chan count
    {
      Steinberg::UString(tmpStringBuf, 128).fromAscii(GetOutputBusLabel(0)->Get(), 128);
      addAudioOutput(tmpStringBuf, getSpeakerArrForChans(NOutChannels()) );
    }
    else
    {
      for (int i = 0, busIdx = 0; i < NOutChannels(); i+=2, busIdx++)
      {
        Steinberg::UString(tmpStringBuf, 128).fromAscii(GetOutputBusLabel(busIdx)->Get(), 128);
        addAudioOutput(tmpStringBuf, SpeakerArr::kStereo );
      }
    }

    if (mScChans)
    {
      if (mScChans > 2) mScChans = 2;
      Steinberg::UString(tmpStringBuf, 128).fromAscii(GetInputBusLabel(1)->Get(), 128);
      addAudioInput(tmpStringBuf, getSpeakerArrForChans(mScChans), kAux, 0);
    }

    if(DoesMIDI())
    {
      addEventInput (STR16("MIDI Input"), 1);
      //addEventOutput(STR16("MIDI Output"), 1);
    }

    if (NPresets())
    {
      parameters.addParameter(new Parameter(STR16("Preset"),
                                            kPresetParam,
                                            STR16(""),
                                            0,
                                            NPresets(),
                                            ParameterInfo::kIsProgramChange));
    }

    if(!mIsInst)
    {
      StringListParameter * bypass = new StringListParameter(STR16("Bypass"),
                                                            kBypassParam,
                                                            0,
                                                            ParameterInfo::kCanAutomate | ParameterInfo::kIsBypass | ParameterInfo::kIsList);
      bypass->appendString(STR16("off"));
      bypass->appendString(STR16("on"));
      parameters.addParameter(bypass);
    }

    for (int i=0; i<NParams(); i++)
    {
      IParam *p = GetParam(i);

      int32 flags = 0;
      UnitID unitID = kRootUnitId;
      
      const char* paramGroupName = p->GetParamGroupForHost();

      if (CSTR_NOT_EMPTY(paramGroupName))
      {        
        for(int j = 0; j < mParamGroups.GetSize(); j++)
        {
          if(strcmp(paramGroupName, mParamGroups.Get(j)) == 0)
          {
            unitID = j+1;
          }
        }
        
        if (unitID == kRootUnitId) // new unit, nothing found, so add it
        {
          mParamGroups.Add(paramGroupName);
          unitID = mParamGroups.GetSize();
        }
      }

      if (p->GetCanAutomate())
      {
        flags |= ParameterInfo::kCanAutomate;
      }

      switch (p->Type())
      {
        case IParam::kTypeDouble:
        case IParam::kTypeInt:
        {
          Parameter* param = new RangeParameter( STR16(p->GetNameForHost()),
                                                 i,
                                                 STR16(p->GetLabelForHost()),
                                                 p->GetMin(),
                                                 p->GetMax(),
                                                 p->GetDefault(),
                                                 0, // continuous
                                                 flags,
                                                 unitID);

          param->setPrecision (p->GetPrecision());
          parameters.addParameter(param);

          break;
        }
        case IParam::kTypeEnum:
        case IParam::kTypeBool:
        {
          StringListParameter* param = new StringListParameter (STR16(p->GetNameForHost()),
                                                                i,
                                                                STR16(p->GetLabelForHost()),
                                                                flags | ParameterInfo::kIsList,
                                                                unitID);

          int nDisplayTexts = p->GetNDisplayTexts();

          assert(nDisplayTexts);

          for (int j=0; j<nDisplayTexts; j++)
          {
            param->appendString(STR16(p->GetDisplayText(j)));
          }

          parameters.addParameter(param);
          break;
        }
        default:
          break;
      }
    }
  }

  OnHostIdentified();
  RestorePreset(0);
  
  return result;
}
Ejemplo n.º 18
0
void
BUrl::SetAuthority(const BString& authority)
{
	fAuthority = authority;

	fHasPort = false;
	fHasUserName = false;
	fHasPassword = false;

	// An empty authority is still an authority, making it possible to have
	// URLs such as file:///path/to/file.
	// TODO however, there is no way to unset the authority once it is set...
	// We may want to take a const char* parameter and allow NULL.
	fHasHost = true;

	if (fAuthority.IsEmpty())
		return;

	int32 userInfoEnd = fAuthority.FindFirst('@');

	// URL contains userinfo field
	if (userInfoEnd != -1) {
		BString userInfo;
		fAuthority.CopyInto(userInfo, 0, userInfoEnd);

		int16 colonDelimiter = userInfo.FindFirst(':', 0);

		if (colonDelimiter == 0) {
			SetPassword(userInfo);
		} else if (colonDelimiter != -1) {
			userInfo.CopyInto(fUser, 0, colonDelimiter);
			userInfo.CopyInto(fPassword, colonDelimiter + 1,
				userInfo.Length() - colonDelimiter);
			SetUserName(fUser);
			SetPassword(fPassword);
		} else {
			SetUserName(fUser);
		}
	}


	// Extract the host part
	int16 hostEnd = fAuthority.FindFirst(':', userInfoEnd);
	userInfoEnd++;

	if (hostEnd < 0) {
		// no ':' found, the host extends to the end of the URL
		hostEnd = fAuthority.Length() + 1;
	}

	// The host is likely to be present if an authority is
	// defined, but in some weird cases, it's not.
	if (hostEnd != userInfoEnd) {
		fAuthority.CopyInto(fHost, userInfoEnd, hostEnd - userInfoEnd);
		SetHost(fHost);
	}

	// Extract the port part
	fPort = 0;
	if (fAuthority.ByteAt(hostEnd) == ':') {
		hostEnd++;
		int16 portEnd = fAuthority.Length();

		BString portString;
		fAuthority.CopyInto(portString, hostEnd, portEnd - hostEnd);
		fPort = atoi(portString.String());

		//  Even if the port is invalid, the URL is considered to
		// have a port.
		fHasPort = portString.Length() > 0;
	}
}
Ejemplo n.º 19
0
void
BUrl::SetAuthority(const BString& authority)
{
	fAuthority = authority;

	fHasPort = false;
	fHasUserInfo = false;
	fHasHost = false;

	if (fAuthority.IsEmpty())
		return;

	fHasAuthority = true;
	int32 userInfoEnd = fAuthority.FindFirst('@');

	// URL contains userinfo field
	if (userInfoEnd != -1) {
		BString userInfo;
		fAuthority.CopyInto(userInfo, 0, userInfoEnd);

		int16 colonDelimiter = userInfo.FindFirst(':', 0);

		if (colonDelimiter == 0) {
			SetPassword(userInfo);
		} else if (colonDelimiter != -1) {
			userInfo.CopyInto(fUser, 0, colonDelimiter);
			userInfo.CopyInto(fPassword, colonDelimiter + 1,
				userInfo.Length() - colonDelimiter);
			SetUserName(fUser);
			SetPassword(fPassword);
		} else {
			SetUserName(fUser);
		}

		fHasUserInfo = true;
	}


	// Extract the host part
	int16 hostEnd = fAuthority.FindFirst(':', userInfoEnd);
	userInfoEnd++;

	if (hostEnd < 0) {
		// no ':' found, the host extends to the end of the URL
		hostEnd = fAuthority.Length() + 1;
	}

	// The host is likely to be present if an authority is
	// defined, but in some weird cases, it's not.
	if (hostEnd != userInfoEnd) {
		fAuthority.CopyInto(fHost, userInfoEnd, hostEnd - userInfoEnd);
		SetHost(fHost);
	}

	// Extract the port part
	fPort = 0;
	if (fAuthority.ByteAt(hostEnd) == ':') {
		hostEnd++;
		int16 portEnd = fAuthority.Length();

		BString portString;
		fAuthority.CopyInto(portString, hostEnd, portEnd - hostEnd);
		fPort = atoi(portString.String());

		//  Even if the port is invalid, the URL is considered to
		// have a port.
		fHasPort = portString.Length() > 0;
	}
}
Ejemplo n.º 20
0
void
BUrl::SetAuthority(const BString& authority)
{
	fAuthority = authority;

	fUser.Truncate(0);
	fPassword.Truncate(0);
	fHost.Truncate(0);
	fPort = 0;
	fHasPort = false;
	fHasUserName = false;
	fHasPassword = false;

	bool hasUsernamePassword = B_ERROR != fAuthority.FindFirst('@');
	authority_parse_state state = AUTHORITY_USERNAME;
	int32 offset = 0;
	int32 length = authority.Length();
	const char *authority_c = authority.String();

	while (AUTHORITY_COMPLETE != state && offset < length) {

		switch (state) {

			case AUTHORITY_USERNAME:
			{
				if (hasUsernamePassword) {
					int32 end_username = char_offset_until_fn_false(
						authority_c, length, offset,
						authority_is_username_char);

					SetUserName(BString(&authority_c[offset],
						end_username - offset));

					state = AUTHORITY_PASSWORD;
					offset = end_username;
				} else {
					state = AUTHORITY_HOST;
				}
				break;
			}

			case AUTHORITY_PASSWORD:
			{
				if (hasUsernamePassword && ':' == authority[offset]) {
					offset++; // move past the delimiter
					int32 end_password = char_offset_until_fn_false(
						authority_c, length, offset,
						authority_is_password_char);

					SetPassword(BString(&authority_c[offset],
						end_password - offset));

					offset = end_password;
				}

				// if the host was preceded by a username + password couple
				// then there will be an '@' delimiter to avoid.

				if (authority_c[offset] == '@') {
					offset++;
				}

				state = AUTHORITY_HOST;
				break;
			}

			case AUTHORITY_HOST:
			{

				// the host may be enclosed within brackets in order to express
				// an IPV6 address.

				if (authority_c[offset] == '[') {
					int32 end_ipv6_host = char_offset_until_fn_false(
						authority_c, length, offset + 1,
						authority_is_ipv6_host_char);

					if (authority_c[end_ipv6_host] == ']') {
						SetHost(BString(&authority_c[offset],
							(end_ipv6_host - offset) + 1));
						state = AUTHORITY_PORT;
						offset = end_ipv6_host + 1;
					}
				}

				// if an IPV6 host was not found.

				if (AUTHORITY_HOST == state) {
					int32 end_host = char_offset_until_fn_false(
						authority_c, length, offset, authority_is_host_char);

					SetHost(BString(&authority_c[offset], end_host - offset));
					state = AUTHORITY_PORT;
					offset = end_host;
				}

				break;
			}

			case AUTHORITY_PORT:
			{
				if (authority_c[offset] == ':') {
					offset++;
					int32 end_port = char_offset_until_fn_false(
						authority_c, length, offset, authority_is_port_char);
					SetPort(atoi(&authority_c[offset]));
					offset = end_port;
				}

				state = AUTHORITY_COMPLETE;

				break;
			}

			case AUTHORITY_COMPLETE:
				// should never be reached - keeps the compiler happy
				break;
		}
	}

	// An empty authority is still an authority, making it possible to have
	// URLs such as file:///path/to/file.
	// TODO however, there is no way to unset the authority once it is set...
	// We may want to take a const char* parameter and allow NULL.
	fHasHost = true;
}
Ejemplo n.º 21
0
void
DBPluginInfoAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("DBPluginInfoAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    DataNode **children;
    if((node = searchNode->GetNode("types")) != 0)
        SetTypes(node->AsStringVector());
    if((node = searchNode->GetNode("hasWriter")) != 0)
        SetHasWriter(node->AsIntVector());

    // Clear all the DBOptionsAttributess if we got any.
    bool clearedDbReadOptions = false;
    // Go through all of the children and construct a new
    // DBOptionsAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DBOptionsAttributes"))
            {
                if (!clearedDbReadOptions)
                {
                    ClearDbReadOptions();
                    clearedDbReadOptions = true;
                }
                DBOptionsAttributes temp;
                temp.SetFromNode(children[i]);
                AddDbReadOptions(temp);
            }
        }
    }


    // Clear all the DBOptionsAttributess if we got any.
    bool clearedDbWriteOptions = false;
    // Go through all of the children and construct a new
    // DBOptionsAttributes for each one of them.
    children = searchNode->GetChildren();
    if(children != 0)
    {
        for(int i = 0; i < searchNode->GetNumChildren(); ++i)
        {
            if(children[i]->GetKey() == std::string("DBOptionsAttributes"))
            {
                if (!clearedDbWriteOptions)
                {
                    ClearDbWriteOptions();
                    clearedDbWriteOptions = true;
                }
                DBOptionsAttributes temp;
                temp.SetFromNode(children[i]);
                AddDbWriteOptions(temp);
            }
        }
    }

    if((node = searchNode->GetNode("typesFullNames")) != 0)
        SetTypesFullNames(node->AsStringVector());
    if((node = searchNode->GetNode("license")) != 0)
        SetLicense(node->AsStringVector());
    if((node = searchNode->GetNode("host")) != 0)
        SetHost(node->AsString());
}
Ejemplo n.º 22
0
void sfHttp_SetHost(sfHttp* http, const char* host, unsigned short port)
{
    CSFML_CALL(http, SetHost(host ? host : "", port));
}