Пример #1
0
CDBDefaultConnParams::CDBDefaultConnParams(
        const string&   srv_name,
        const string&   user_name,
        const string&   passwd,
        I_DriverContext::TConnectionMode mode,
        bool            reusable,
        const string&   pool_name)
{
    SetServerName(srv_name);
    SetUserName(user_name);
    SetPassword(passwd);

    SetParam(
        "pool_name",
        pool_name
        );

    SetParam(
        "secure_login",
        ((mode & I_DriverContext::fPasswordEncrypted) != 0) ? "true" : "false"
        );

    SetParam(
        "is_pooled",
        reusable ? "true" : "false"
        );

    SetParam(
        "do_not_connect",
        (mode & I_DriverContext::fDoNotConnect) != 0 ? "true" : "false"
        );
}
Пример #2
0
RepRap::RepRap() : toolList(nullptr), currentTool(nullptr), lastWarningMillis(0), activeExtruders(0),
	activeToolHeaters(0), ticksInSpinState(0), spinningModule(noModule), debug(0), stopped(false),
	active(false), resetting(false), processingConfig(true), beepFrequency(0), beepDuration(0)
{
	OutputBuffer::Init();
	platform = new Platform();
	network = new Network(platform);
	webserver = new Webserver(platform, network);
	gCodes = new GCodes(platform, webserver);
	move = new Move(platform, gCodes);
	heat = new Heat(platform);

#if SUPPORT_ROLAND
	roland = new Roland(platform);
#endif
#if SUPPORT_SCANNER
	scanner = new Scanner(platform);
#endif

	printMonitor = new PrintMonitor(platform, gCodes);

	SetPassword(DEFAULT_PASSWORD);
	SetName(DEFAULT_NAME);
	message[0] = 0;
}
Пример #3
0
void CDB_ODBC_ConnParams::x_MapPairToParam(const string& key, const string& value)
{
    // MS SQL Server related attributes ...
    if (NStr::Equal(key, "SERVER", NStr::eNocase)) {
        SetServerName(value);
    } else if (NStr::Equal(key, "UID", NStr::eNocase)) {
        SetUserName(value);
    } else if (NStr::Equal(key, "PWD", NStr::eNocase)) {
        SetPassword(value);
    } else if (NStr::Equal(key, "DRIVER", NStr::eNocase)) {
        SetDriverName(value);
    } else if (NStr::Equal(key, "DATABASE", NStr::eNocase)) {
        SetDatabaseName(value);
    } else if (NStr::Equal(key, "ADDRESS", NStr::eNocase)) {
        string host;
        string port;

        NStr::SplitInTwo(value, ",", host, port);
        NStr::TruncateSpacesInPlace(host);
        NStr::TruncateSpacesInPlace(port);

        // SetHost(host);
        SetPort(static_cast<Uint2>(NStr::StringToInt(port)));
    } else {
        SetParam(key, value);
    }
}
Пример #4
0
Файл: q.cpp Проект: ZachBeta/znc
	virtual bool OnLoad(const CString& sArgs, CString& sMessage) {
		if (!sArgs.empty()) {
			SetUsername(sArgs.Token(0));
			SetPassword(sArgs.Token(1));
		} else {
			m_sUsername = GetNV("Username");
			m_sPassword = GetNV("Password");
		}

		CString sTmp;
		m_bUseCloakedHost = (sTmp = GetNV("UseCloakedHost")).empty() ? true : sTmp.ToBool();
		m_bUseChallenge   = (sTmp = GetNV("UseChallenge")).empty()  ? true : sTmp.ToBool();
		m_bRequestPerms   = GetNV("RequestPerms").ToBool();

		OnIRCDisconnected(); // reset module's state

		if (IsIRCConnected()) {
			// check for usermode +x if we are already connected
			set<unsigned char> scUserModes = GetUser()->GetIRCSock()->GetUserModes();
			if (scUserModes.find('x') != scUserModes.end())
				m_bCloaked = true;

			OnIRCConnected();
		}

		return true;
	}
Пример #5
0
void Display::Init()
{
  writing = false;
  receivingPost = false;
  postSeen = false;
  getSeen = false;
  jsonPointer = -1;
  clientLineIsBlank = true;
  needToCloseClient = false;
  clientLinePointer = 0;

  SetPassword(DEFAULT_PASSWORD);
  SetName(DEFAULT_NAME);
  //gotPassword = false;
  gcodeReadIndex = gcodeWriteIndex = 0;
  InitialisePost();
  lastTime = platform->Time();
  longWait = lastTime;
  active = true;
  seq = 0;
  webDebug = false;

  for (int i=0; i<=maxMenuIndex; i++){
	  menus[i] = (Menu){0, MenuItem[0]};
  }
}
Пример #6
0
void Tracker::CreateAndStoreAccountHandleReply() {
  QNetworkReply *reply = static_cast< QNetworkReply* >( sender() );
  if( reply->error() == QNetworkReply::NoError ) {
    LOG( "Account creation was successful!" );

    QByteArray jsonData = reply->readAll();

    bool ok;
    QtJson::JsonObject user = QtJson::parse( jsonData, ok ).toMap();

    if( !ok ) {
      LOG( "Couldn't parse response" );
    } else {
      LOG( "Welcome %s", user[ "username" ].toString().toStdString().c_str() );

      SetUsername( user["username"].toString() );
      SetPassword( user["password"].toString() );

      emit AccountCreated();
    }
  } else {
    int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
    LOG( "There was a problem creating an account. Error: %i HTTP Status Code: %i", reply->error(), statusCode );
  }
}
Пример #7
0
void Webserver::Init()
{
  writing = false;
  receivingPost = false;
  postSeen = false;
  getSeen = false;
  jsonPointer = -1;
  clientLineIsBlank = true;
  needToCloseClient = false;
  clientLinePointer = 0;
  clientLine[0] = 0;
  clientRequest[0] = 0;
  SetPassword(DEFAULT_PASSWORD);
  SetName(DEFAULT_NAME);
  //gotPassword = false;
  gcodeReadIndex = gcodeWriteIndex = 0;
  InitialisePost();
  lastTime = platform->Time();
  longWait = lastTime;
  active = true;
  gcodeReply[0] = 0;
  seq = 0;
  
  // Reinitialise the message file
  
  //platform->GetMassStorage()->Delete(platform->GetWebDir(), MESSAGE_FILE);
}
Пример #8
0
NS_IMETHODIMP
nsSmtpServer::GetUsernamePasswordWithUI(const PRUnichar * aPromptMessage, const
                                PRUnichar *aPromptTitle,
                                nsIAuthPrompt* aDialog,
                                nsACString &aUsername,
                                nsACString &aPassword)
{
  nsresult rv;
  if (!m_password.IsEmpty())
  {
    rv = GetUsername(aUsername);
    NS_ENSURE_SUCCESS(rv, rv);

    return GetPassword(aPassword);
  }

  NS_ENSURE_ARG_POINTER(aDialog);

  nsCString serverUri;
  rv = GetServerURI(serverUri);
  NS_ENSURE_SUCCESS(rv, rv);

  nsString uniUsername;
  nsString uniPassword;
  bool okayValue = true;

  rv = aDialog->PromptUsernameAndPassword(aPromptTitle, aPromptMessage,
                                          NS_ConvertASCIItoUTF16(serverUri).get(),
                                          nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                                          getter_Copies(uniUsername),
                                          getter_Copies(uniPassword),
                                          &okayValue);
  NS_ENSURE_SUCCESS(rv, rv);

  // If the user pressed cancel, just return emtpy strings.
  if (!okayValue)
  {
    aUsername.Truncate();
    aPassword.Truncate();
    return rv;
  }

  // We got a username and password back...so remember them.
  NS_LossyConvertUTF16toASCII username(uniUsername);

  rv = SetUsername(username);
  NS_ENSURE_SUCCESS(rv, rv);

  NS_LossyConvertUTF16toASCII password(uniPassword);

  rv = SetPassword(password);
  NS_ENSURE_SUCCESS(rv, rv);

  aUsername = username;
  aPassword = password;
  return NS_OK;
}
Пример #9
0
NS_IMETHODIMP
nsSmtpServer::ForgetPassword()
{
  nsresult rv;
  nsCOMPtr<nsILoginManager> loginMgr =
    do_GetService(NS_LOGINMANAGER_CONTRACTID, &rv);
  NS_ENSURE_SUCCESS(rv, rv);

  // Get the current server URI without the username
  nsCAutoString serverUri(NS_LITERAL_CSTRING("smtp://"));

  nsCString hostname;
  rv = GetHostname(hostname);

  if (NS_SUCCEEDED(rv) && !hostname.IsEmpty()) {
    nsCString escapedHostname;
    *((char **)getter_Copies(escapedHostname)) =
      nsEscape(hostname.get(), url_Path);
    // not all servers have a hostname
    serverUri.Append(escapedHostname);
  }

  PRUint32 count;
  nsILoginInfo** logins;

  NS_ConvertUTF8toUTF16 currServer(serverUri);

  nsCString serverCUsername;
  rv = GetUsername(serverCUsername);
  NS_ENSURE_SUCCESS(rv, rv);

  NS_ConvertUTF8toUTF16 serverUsername(serverCUsername);

  rv = loginMgr->FindLogins(&count, currServer, EmptyString(),
                            currServer, &logins);
  NS_ENSURE_SUCCESS(rv, rv);

  // There should only be one-login stored for this url, however just in case
  // there isn't.
  nsString username;
  for (PRUint32 i = 0; i < count; ++i)
  {
    if (NS_SUCCEEDED(logins[i]->GetUsername(username)) &&
        username.Equals(serverUsername))
    {
      // If this fails, just continue, we'll still want to remove the password
      // from our local cache.
      loginMgr->RemoveLogin(logins[i]);
    }
  }
  NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY(count, logins);

  rv = SetPassword(EmptyCString());
  m_logonFailed = PR_TRUE;
  return rv;
}
Пример #10
0
void HandlePacket_FORCE_PASSWORD_CHANGE( bf_read &buf, const CIPAddr &ipFrom )
{
	char newPassword[512];
	buf.ReadString( newPassword, sizeof( newPassword ) );
	
	Msg( "Got a FORCE_PASSWORD_CHANGE (%s) packet.\n", newPassword );
	
	SetPassword( newPassword );
	if ( g_pConnMgr )
		g_pConnMgr->SendCurStateTo( -1 );
}
Пример #11
0
void CVMPIServiceConnMgr::HandlePacket( const char *pData, int len )
{
	switch( pData[0] )
	{
		case VMPI_KILL_PROCESS:
		{
			HandlePacket_KILL_PROCESS( NULL );
		}
		break;
		
		case VMPI_SERVICE_DISABLE:
		{
			KillRunningProcess( "Got a VMPI_SERVICE_DISABLE packet", true );
			SetAppState( VMPI_SERVICE_STATE_DISABLED );
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_ENABLE:
		{
			if ( g_iCurState == VMPI_SERVICE_STATE_DISABLED )
			{
				SetAppState( VMPI_SERVICE_STATE_IDLE );
			}
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_UPDATE_PASSWORD:
		{
			const char *pStr = pData + 1;
			SetPassword( pStr );
			
			// Send out the new state.
			SendCurStateTo( -1 );
		}
		break;

		case VMPI_SERVICE_SCREENSAVER_MODE:
		{
			g_bScreensaverMode = (pData[1] != 0);
			SendCurStateTo( -1 );
			SaveStateToRegistry();
		}
		break;

		case VMPI_SERVICE_EXIT:
		{
			Msg( "Got a VMPI_SERVICE_EXIT packet.\n ");
			ServiceHelpers_ExitEarly();
		}
		break;
	}
}
Пример #12
0
  void OrthancPeerParameters::FromJson(const Json::Value& peer)
  {
    if (!peer.isArray() ||
        (peer.size() != 1 && peer.size() != 3))
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    std::string url;

    try
    {
      url = peer.get(0u, "").asString();

      if (peer.size() == 1)
      {
        SetUsername("");
        SetPassword("");
      }
      else if (peer.size() == 3)
      {
        SetUsername(peer.get(1u, "").asString());
        SetPassword(peer.get(2u, "").asString());
      }
      else
      {
        throw OrthancException(ErrorCode_BadFileFormat);
      }
    }
    catch (...)
    {
      throw OrthancException(ErrorCode_BadFileFormat);
    }

    if (url.size() != 0 && url[url.size() - 1] != '/')
    {
      url += '/';
    }

    SetUrl(url);
  }
Пример #13
0
NS_IMETHODIMP
nsSmtpServer::GetPasswordWithUI(const PRUnichar *aPromptMessage,
                                const PRUnichar *aPromptTitle,
                                nsIAuthPrompt* aDialog,
                                nsACString &aPassword)
{
  if (!m_password.IsEmpty())
    return GetPassword(aPassword);

  // We need to get a password, but see if we can get it from the password
  // manager without requiring a prompt.
  nsresult rv = GetPasswordWithoutUI();
  if (rv == NS_ERROR_ABORT)
    return NS_MSG_PASSWORD_PROMPT_CANCELLED;

  // Now re-check if we've got a password or not, if we have, then we
  // don't need to prompt the user.
  if (!m_password.IsEmpty())
  {
    aPassword = m_password;
    return NS_OK;
  }

  NS_ENSURE_ARG_POINTER(aDialog);

  // PromptPassword needs the username as well.
  nsCString serverUri(GetServerURIInternal(true));

  bool okayValue = true;
  nsString uniPassword;

  rv = aDialog->PromptPassword(aPromptTitle, aPromptMessage,
                               NS_ConvertASCIItoUTF16(serverUri).get(),
                               nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                               getter_Copies(uniPassword), &okayValue);
  NS_ENSURE_SUCCESS(rv, rv);

  // If the user pressed cancel, just return an empty string.
  if (!okayValue)
  {
    aPassword.Truncate();
    return NS_MSG_PASSWORD_PROMPT_CANCELLED;
  }

  NS_LossyConvertUTF16toASCII password(uniPassword);

  rv = SetPassword(password);
  NS_ENSURE_SUCCESS(rv, rv);

  aPassword = password;
  return NS_OK;
}
Пример #14
0
ComicBookRAR::ComicBookRAR(wxString file, wxUint32 cacheLen, COMICAL_ZOOM zoom, long zoomLevel, bool fitOnlyOversize, COMICAL_MODE mode, FREE_IMAGE_FILTER filter, COMICAL_DIRECTION direction, wxInt32 scrollbarThickness) : ComicBook(file, cacheLen, zoom, zoomLevel, fitOnlyOversize, mode, filter, direction, scrollbarThickness)
{
	HANDLE rarFile;
	int RHCode = 0, PFCode = 0;
	struct RARHeaderDataEx header;
	struct RAROpenArchiveDataEx flags;
	wxString page, new_password;
	
	open_rar:
	
	rarFile = openRar(&flags, &header, RAR_OM_LIST);

	if (flags.Flags & 0x0080) { // if the headers are encrypted
		new_password = wxGetPasswordFromUser(
				wxT("This archive is password-protected.  Please enter the password."),
				wxT("Enter Password"));
		if (new_password.IsEmpty()) { // the dialog was cancelled, and the archive cannot be opened
			closeRar(rarFile, &flags);
			throw ArchiveException(filename, wxT("Comical could not open this file because it is password-protected."));
		}
		SetPassword(new_password.ToAscii());
	}
	if (password)
		RARSetPassword(rarFile, password);

	while ((RHCode = RARReadHeaderEx(rarFile, &header)) == 0) {
#ifdef wxUSE_UNICODE
		page = wxString(header.FileNameW);
#else
		page = wxString(header.FileName);
#endif
		if(page.Right(5).Upper() == wxT(".JPEG") || page.Right(4).Upper() == wxT(".JPG") ||
		page.Right(4).Upper() == wxT(".GIF") ||
		page.Right(4).Upper() == wxT(".PNG"))
			Filenames->Add(page);
		
		if ((PFCode = RARProcessFile(rarFile, RAR_SKIP, NULL, NULL)) != 0) {
			closeRar(rarFile, &flags);
			throw ArchiveException(filename, ProcessFileError(PFCode, page));
		}
	}

	closeRar(rarFile, &flags);
	
	// Wrong return code + needs password = wrong password given
	if (RHCode != ERAR_END_ARCHIVE && flags.Flags & 0x0080) 
		goto open_rar;

	postCtor();
	Create(); // create the wxThread
}
Пример #15
0
void CChatChannel::ChangePassword(CChatChanMember * pByMember, LPCTSTR pszPassword)
{
	ADDTOCALLSTACK("CChatChannel::ChangePassword");
	if (!IsModerator(pByMember->GetChatName()))
	{
		pByMember->GetClient()->addChatSystemMessage(CHATMSG_MustHaveOps);
	}
	else
	{
		SetPassword(pszPassword);
		g_Serv.m_Chats.SendNewChannel(pByMember->GetChannel());
		Broadcast(CHATMSG_PasswordChanged, "","");
	}
}
Пример #16
0
C7zWorker::C7zWorker(const QString &ArchivePath, const QString &WorkingPath, const QString &Password, quint64 PartSize, const QStringList& Parts)
: CArchive(ArchivePath)
{
	SetPassword(Password);
	SetPartSize(PartSize);
	m_WorkingPath = WorkingPath;
	SetPartList(Parts);

	if(QFile::exists(ArchivePath))
	{
		if(!Open())
			m_Errors.append("Open Failed");
	}
}
Пример #17
0
void ConnectionSettings::Load(QSettings & settings, bool dontDecryptPassword)
{
    settings.beginGroup(connectionSettingsSection);
    SetDC(settings.value(dcNameParam).toString().toStdWString());
    SetLogin(settings.value(userNameParam).toString().toStdWString());
    QString protectedPassword = settings.value(passwordParam).toString();    
    CurrentUserCredentials(settings.value(currentUserCredParam, true).toBool());
    CurrentDomain(settings.value(currentDomainParam, true).toBool());
    QString unprotectedPassword = dontDecryptPassword ? protectedPassword : 
        UnprotectPassword(protectedPassword);
    SetPassword(unprotectedPassword.toStdWString());
#pragma warning(push, 3)
#pragma warning(disable: 4003)
    BOOST_SCOPE_EXIT(&settings) { settings.endGroup(); } BOOST_SCOPE_EXIT_END
#pragma warning(pop)
}
Пример #18
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;
}
Пример #19
0
	QString ProxyObject::GetAccountPassword (QObject *accObj, bool useStored)
	{
		if (useStored)
		{
			const QString& result = GetPassword (accObj);
			if (!result.isNull ())
				return result;
		}

		IAccount *acc = qobject_cast<IAccount*> (accObj);

		QString result = QInputDialog::getText (0,
				"LeechCraft",
				tr ("Enter password for %1:").arg (acc->GetAccountName ()),
				QLineEdit::Password);
		if (!result.isNull ())
			SetPassword (result, accObj);
		return result;
	}
Пример #20
0
LONG32 SnarlInterface::Register(LPCWSTR signature, LPCWSTR name, LPCWSTR icon, LPCWSTR password, HWND hWndReplyTo, LONG32 msgReply, SnarlEnums::AppFlags flags)
{
    SnarlParameterList<wchar_t> spl(7);
    spl.Add(L"app-sig", signature);
    spl.Add(L"title", name);
    spl.Add(L"icon", icon);
    spl.Add(L"password", password);
    spl.Add(L"reply-to", hWndReplyTo);
    spl.Add(L"reply", msgReply);
    spl.Add(L"flags", flags);

    // If password was given, save and use in all other functions requiring password
    if (password != NULL && wcslen(password) > 0)
        SetPassword(password);

    LONG32 request = DoRequest(Requests::RegisterW(), spl);
    if (request > 0)
        appToken = request;

    return request;
}
Пример #21
0
NS_IMETHODIMP
nsSmtpServer::GetPasswordWithUI(const PRUnichar *aPromptMessage,
                                const PRUnichar *aPromptTitle,
                                nsIAuthPrompt* aDialog,
                                nsACString &aPassword)
{
  if (!m_password.IsEmpty())
    return GetPassword(aPassword);

  NS_ENSURE_ARG_POINTER(aDialog);

  nsCString serverUri;
  nsresult rv = GetServerURI(serverUri);
  NS_ENSURE_SUCCESS(rv, rv);

  PRBool okayValue = PR_TRUE;
  nsString uniPassword;

  rv = aDialog->PromptPassword(aPromptTitle, aPromptMessage,
                               NS_ConvertASCIItoUTF16(serverUri).get(),
                               nsIAuthPrompt::SAVE_PASSWORD_PERMANENTLY,
                               getter_Copies(uniPassword), &okayValue);
  NS_ENSURE_SUCCESS(rv, rv);

  // If the user pressed cancel, just return an empty string.
  if (!okayValue)
  {
    aPassword.Truncate();
    return rv;
  }

  NS_LossyConvertUTF16toASCII password(uniPassword);

  rv = SetPassword(password);
  NS_ENSURE_SUCCESS(rv, rv);

  aPassword = password;
  return NS_OK;
}
Пример #22
0
LONG32 SnarlInterface::Register(LPCSTR signature, LPCSTR title, LPCSTR icon, LPCSTR password, HWND hWndReplyTo, LONG32 msgReply, SnarlEnums::AppFlags flags)
{
    // register?app-sig=<signature>&title=<title>[&icon=<icon>][&password=<password>][&reply-to=<reply window>][&reply=<reply message>]

    SnarlParameterList<char> spl(6);
    spl.Add("app-sig", signature);
    spl.Add("title", title);
    spl.Add("icon", icon);
    spl.Add("password", password);
    spl.Add("reply-to", hWndReplyTo);
    spl.Add("reply", msgReply);
    spl.Add("flags", flags);

    // If password was given, save and use in all other functions requiring password
    if (password != NULL && strlen(password) > 0)
        SetPassword(password);

    LONG32 request = DoRequest(Requests::RegisterA(), spl);
    if (request > 0)
        appToken = request;

    return request;
}
Пример #23
0
Файл: q.cpp Проект: ZachBeta/znc
	void Auth(const CString& sUsername = "", const CString& sPassword = "") {
		if (m_bAuthed)
			return;

		if (!sUsername.empty())
			SetUsername(sUsername);
		if (!sPassword.empty())
			SetPassword(sPassword);

		if (m_sUsername.empty() || m_sPassword.empty()) {
			PutModule("You have to set a username and password to use this module! See 'help' for details.");
			return;
		}

		if (m_bUseChallenge) {
			PutModule("Auth: Requesting CHALLENGE...");
			m_bRequestedChallenge = true;
			PutQ("CHALLENGE");
		} else {
			PutModule("Auth: Sending AUTH request...");
			PutQ("AUTH " + m_sUsername + " " + m_sPassword);
		}
	}
Пример #24
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;
}
Пример #25
0
CDBUriConnParams::CDBUriConnParams(const string& params)
{
    string::size_type pos = 0;
    string::size_type cur_pos = 0;

    // Check for 'dbapi:' ...
    pos = params.find_first_of(":", pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    if (! NStr::StartsWith(params, "dbapi:", NStr::eNocase)) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should start with 'dbapi:'", 20001);
    }

    cur_pos = pos + 1;

    // Check for driver name ...
    pos = params.find("//", cur_pos);
    if (pos == string::npos) {
        DATABASE_DRIVER_ERROR("Invalid database locator format, should contain driver name", 20001);
    }

    if (pos != cur_pos) {
        string driver_name = params.substr(cur_pos, pos - cur_pos - 1);
        SetDriverName(driver_name);
    }

    cur_pos = pos + 2;

    // Check for user name and password ...
    pos = params.find_first_of(":@", cur_pos);
    if (pos != string::npos) {
        string user_name = params.substr(cur_pos, pos - cur_pos);

        if (params[pos] == '@') {
            SetUserName(user_name);

            cur_pos = pos + 1;

            ParseServer(params, cur_pos);
        } else {
            // Look ahead, we probably found a host name ...
            cur_pos = pos + 1;

            pos = params.find_first_of("@", cur_pos);

            if (pos != string::npos) {
                // Previous value was an user name ...
                SetUserName(user_name);

                string password = params.substr(cur_pos, pos - cur_pos);
                SetPassword(password);

                cur_pos = pos + 1;
            }

            ParseServer(params, cur_pos);
        }
    } else {
        ParseServer(params, cur_pos);
    }

}
Пример #26
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;
	}
}
void CLibrefmScrobbler::LoadCredentials()
{
  SetUsername(g_guiSettings.GetString("scrobbler.librefmusername"));
  SetPassword(g_guiSettings.GetString("scrobbler.librefmpass"));
}
Пример #28
0
 void SetSysParameter()
 {
	 BROWINFO setpar_menu;
	 char parameter_str[]=" 1.时间设置    "
					      " 2.显示设置    "
					 " 3.按键设置    "
					 " 4.自动关机时间"
					 " 5.背光时间设置"
					 " 6.开机密码设置"
					 " 7.WIFI网络设置"
					 " 8.WIFI网络查询"
					 " 9.本机站点设置"
					 " 10.恢复出场设置";
	 
	 int select;
	 setpar_menu.iStr=parameter_str;//浏览字符串
	 setpar_menu.lPtr = 0;//起始显示行
	 setpar_menu.cPtr = 0;//初始选择项
	 while(1)
	 {
		DispStr_CE(0,1,"系统设置菜单",DISP_CENTER|DISP_NORMAL|DISP_CLRSCR);
		setpar_menu.mInt=10;//显示总行数
		setpar_menu.lineMax=15;//每行显示最大字符数 
		setpar_menu.startLine=3;//起始行 
		setpar_menu.dispLines=10;//
		setpar_menu.sFont=0;  //0 -大字体
		setpar_menu.numEnable=1;//是否允许键盘方向键 1-允许
		setpar_menu.qEvent=(EXIT_KEY_F1);
		setpar_menu.autoexit =120;
		select=EXT_Brow_Select(&setpar_menu);
		switch(select)
		{
			 case 0:
				 SetTime();
				 break;
			 case 1:
				 SetDisp();
				 break;
			 case 2:
				 SetKeyBoard();
				 break;
			 case 3:
				 AutoPowerDown();
				 break;
			 case 4:
				 SetElAutoTime();
				 break;
			 case 5:
				 SetPassword();
				 break;
			 case 6:
				 Wifi_SetDemo();
				 break;
			 case 7:
			 	Wifi_GetDemo();
				break;
			 case 8:
				 SetLocalSite();
				 break;
			 case 9:
				 ResetPlant();
				 break;
			 default:
				 return;
				 //break;
		 }
	 }
 }
Пример #29
0
void CScrobbler::LoadCredentials()
{
    SetUsername("");
    SetPassword("");
}
Пример #30
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;
}