예제 #1
0
void LLFloaterProperties::setExpanded(BOOL expanded)
{
	mExpanded = expanded;
	LLRect rect = getRect();
	if(expanded)
		rect.setOriginAndSize(rect.mLeft, rect.mBottom, 800, rect.getHeight());
	else
		rect.setOriginAndSize(rect.mLeft, rect.mBottom, 350, rect.getHeight());
	setRect(rect);
	childSetVisible("more_btn", !mExpanded);
	childSetVisible("less_btn", mExpanded);
	childSetVisible("item_text", mExpanded);
	childSetVisible("copy_btn", mExpanded);
	childSetVisible("update_btn", mExpanded);
	if(getHost())
		setCanTearOff(!expanded); // idk why it comes out ugly if expanded
}
예제 #2
0
LLPreviewAnim::LLPreviewAnim(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const S32& activate, const LLUUID& object_uuid )	:
	LLPreview( name, rect, title, item_uuid, object_uuid)
{
	LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_animation.xml");

	childSetAction("Anim play btn",playAnim,this);
	childSetAction("Anim audition btn",auditionAnim,this);

	const LLInventoryItem* item = getItem();
	
	childSetCommitCallback("desc", LLPreview::onText, this);
	childSetText("desc", item->getDescription());
	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	
	setTitle(title);

	if (!getHost())
	{
		LLRect curRect = getRect();
		translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
	}

	// preload the animation
	if(item)
	{
		gAgent.getAvatarObject()->createMotion(item->getAssetUUID());
	}
	
	switch ( activate ) 
	{
		case 1:
		{
			playAnim( (void *) this );
			break;
		}
		case 2:
		{
			auditionAnim( (void *) this );
			break;
		}
		default:
		{
		//do nothing
		}
	}
}
예제 #3
0
BSONObj ShardType::toBSON() const {
    BSONObjBuilder builder;

    if (_name)
        builder.append(name(), getName());
    if (_host)
        builder.append(host(), getHost());
    if (_draining)
        builder.append(draining(), getDraining());
    if (_maxSizeMB)
        builder.append(maxSizeMB(), getMaxSizeMB());
    if (_tags)
        builder.append(tags(), getTags());
    if (_state)
        builder.append(state(), static_cast<std::underlying_type<ShardState>::type>(getState()));

    return builder.obj();
}
예제 #4
0
// 別スレッドでタスクを開始する
void CSCConnection::startThread(CSCTask* task)
{
    task->setHost(getHost());
    task->setPort(getPort());
    // 別スレッドを作る
    if (task->Create() != wxTHREAD_NO_ERROR){
        delete task;
        task = NULL;
        return;
    }

    // 別スレッドを走らせる
    if (task->Run() != wxTHREAD_NO_ERROR){
        delete task;
        task = NULL;
        return;
    }
}
예제 #5
0
std::string AuthScope::toString() const
{
    std::stringstream ss;

    ss << "Scheme: " << (_hasScheme ? getScheme() : "Any");
    ss << " Host: " << (_hasHost ? getHost() : "Any");
    ss << " Port: ";
    if (_hasPort)
    {
        ss << getPort();
    }
    else
    {
        ss << "Any";
    }

    ss << " Realm: " << (_hasRealm ? getRealm() : "Any");
    ss << " AuthType: ";

    if (_hasAuthType)
    {
        switch (getAuthType())
        {
            case BASIC:
                ss << "BASIC";
                break;
            case DIGEST:
                ss << "DIGEST";
                break;
            case NONE:
                ss << "NONE";
                break;
            default:
                ss << "UNKNOWN";
        }
    }
    else
    {
        ss << "Any";
    }
    
    return ss.str();
}
예제 #6
0
		EID::Compressed EID::getCompressed() const
		{
			dtn::data::Number node = 0;
			dtn::data::Number app = 0;

			if (isCompressable())
			{
				std::stringstream ss_node(getHost());
				node.read(ss_node);

				if (hasApplication())
				{
					std::stringstream ss_app(getApplication());
					app.read(ss_app);
				}
			}

			return make_pair(node, app);
		}
예제 #7
0
void CpuCas01::apply_event(tmgr_trace_iterator_t event, double value)
{
  if (event == speed_.event) {
    /* TODO (Hypervisor): do the same thing for constraint_core[i] */
    xbt_assert(coresAmount_ == 1, "FIXME: add speed scaling code also for constraint_core[i]");

    speed_.scale = value;
    onSpeedChange();

    tmgr_trace_event_unref(&speed_.event);
  } else if (event == stateEvent_) {
    /* TODO (Hypervisor): do the same thing for constraint_core[i] */
    xbt_assert(coresAmount_ == 1, "FIXME: add state change code also for constraint_core[i]");

    if (value > 0) {
      if(isOff())
        host_that_restart.push_back(getHost());
      turnOn();
    } else {
      lmm_constraint_t cnst = getConstraint();
      lmm_variable_t var = nullptr;
      lmm_element_t elem = nullptr;
      double date = surf_get_clock();

      turnOff();

      while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) {
        Action *action = static_cast<Action*>(lmm_variable_id(var));

        if (action->getState() == Action::State::running ||
            action->getState() == Action::State::ready ||
            action->getState() == Action::State::not_in_the_system) {
          action->setFinishTime(date);
          action->setState(Action::State::failed);
        }
      }
    }
    tmgr_trace_event_unref(&stateEvent_);

  } else {
    xbt_die("Unknown event!\n");
  }
}
예제 #8
0
LLPreviewSound::LLPreviewSound(const std::string& name, const LLRect& rect, const std::string& title, const LLUUID& item_uuid, const LLUUID& object_uuid)	:
	LLPreview( name, rect, title, item_uuid, object_uuid)
{
	
	LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_sound.xml");

	childSetAction("Sound play btn",&LLPreviewSound::playSound,this);
	childSetAction("Sound audition btn",&LLPreviewSound::auditionSound,this);

	LLButton* button = getChild<LLButton>("Sound play btn");
	button->setSoundFlags(LLView::SILENT);
	
	button = getChild<LLButton>("Sound audition btn");
	button->setSoundFlags(LLView::SILENT);

	childSetCommitCallback("desc", LLPreview::onText, this);
	childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);	

	const LLInventoryItem* item = getItem();
	if (item)	// May be null (e.g. during prim contents fetches)...
	{
		childSetText("desc", item->getDescription());
		if (gAudiop)
		{
			// preload the sound
			gAudiop->preloadSound(item->getAssetUUID());
		}
	}
	else
	{
		childSetText("desc", std::string("(loading...)"));
	}

	setTitle(title);

	if (!getHost())
	{
		LLRect curRect = getRect();
		translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
	}

}
예제 #9
0
            nint NConnectionConfig::compareTo(const INObject * other) const
            {
                if (this == other)
                    return 0;
                try
                {
                    const NConnectionConfig * obj = dynamic_cast<const NConnectionConfig *>(other);

                    if (obj != NULL)
                    {
                        int result = 0;
                        if ((result = getName().compare(obj->getName())) == 0)
                        {
                            if ((result = getHost().compare(obj->getHost())) == 0)
                            {
                                if ((result = getPort().getValue() - obj->getPort().getValue()) == 0)
                                {
                                    if ((result = getUser().compare(obj->getUser())) == 0)
                                    {
                                        if ((result = getPassword().compare(obj->getPassword())) == 0)
                                        {
                                            if ((result = getSchema().compare(obj->getSchema())) == 0)
                                            {
                                                result = getConnectionType()->getValue().compare(obj->getConnectionType()->getValue());
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        return result;
                    }
                    else
                    {
                        return 1;
                    }
                }
                catch (bad_cast &)
                {
                    return 1;
                }
            }
예제 #10
0
char *semiUniqName(char *base)
/* Figure out a name likely to be unique.
 * Name will have no periods.  Returns a static
 * buffer, so best to clone result unless using
 * immediately. */
{
int pid = getpid();
int num = time(NULL)&0xFFFFF;
char host[512];
strcpy(host, getHost());
char *s = strchr(host, '.');
if (s != NULL)
     *s = 0;
subChar(host, '-', '_');
subChar(host, ':', '_');
static char name[PATH_LEN];
safef(name, sizeof(name), "%s_%s_%x_%x",
	base, host, pid, num);
return name;
}
예제 #11
0
파일: Image.cpp 프로젝트: posva/MangaDown
void Image::download()
{
	if (m_status != down_undone) return;
	
	std::string file;
	
	if (m_filename == "")
		file = (m_dir + getFile(m_url));
	else
		file = m_dir + m_filename + getExtension(m_url);
	FILE* f = fopen(file.c_str(), "rb");
	
	if (f != NULL) //Cover was alreayd downloaded
	{
		m_status = down_done;
	}
	
	if (m_status == down_done) return;
	
	m_status = down_started;
	sf::Http web(getHost(m_url));
	sf::Http::Request request(getUri(m_url));
	std::cout<<"Downloading "<<m_url<<"\n";
	sf::Http::Response response = web.sendRequest(request);
	
	
	sf::Http::Response::Status status = response.getStatus();
	
	if (status == sf::Http::Response::Ok)
	{
		f = fopen(file.c_str(), "wb");
		fwrite(response.getBody().c_str(), sizeof(char), response.getBody().size(), f);
		fclose(f);
		m_status = down_done;
	}
	else
	{
		std::cerr<<"Download fail, error: "<<status<<"\n";
		m_status = down_fail;
	}
}
예제 #12
0
void gbGetOutputTmp(char *path, char *tmpPath)
/* generate the tmp path name, moving the compress extension if needed */
{
char savedExt[32];
int len;
savedExt[0] = '\0';
strcpy(tmpPath, path);
/* don't add extension for special names */
if (!isSpecialName(path))
    {
    if (gbGetCompressor(tmpPath, "r") != NULL)
        {
        char *last = strrchr(tmpPath, '.');
        strcpy(savedExt, last);
        *last = '\0';
        }
    len = strlen(tmpPath);
    safef(tmpPath+len, PATH_LEN-len, ".%d.%s.tmp%s", getpid(), getHost(),
          savedExt);
    }
}
예제 #13
0
void CCMWorldContext::sendAccount(CAccount *acc, const char* name, int64 sync)
{
	CData data;
	data.wrt((byte)(SIGNALS_START+1));
	if( !acc )
	{
		data.wrt((byte)0);
		data << name;
	} else
	{
		data.wrt(acc->getId());
		if( acc->getSync() > sync )
		{
			data.wrt((byte)0); /// Isn't up to date
			acc->serialize(data);
		} else
			data.wrt((byte)1); /// Is up to date
	};
	CLog::instance()->log(CLog::msgLvlInfo,_("Sending account data to %s.\n"), getHost());
	write(data);
};
예제 #14
0
void LLViewerRegion::setCapability(const std::string& name, const std::string& url)
{
	if(name == "EventQueueGet")
	{
		delete mEventPoll;
		mEventPoll = NULL;
		mEventPoll = new LLEventPoll(url, getHost());
	}
	else if(name == "UntrustedSimulatorMessage")
	{
		LLHTTPSender::setSender(mHost, new LLCapHTTPSender(url));
	}
	else
	{
		mCapabilities[name] = url;
		if(name == "GetTexture")
		{
			mHttpUrl = url ;
		}
	}
}
예제 #15
0
void CCMWorldContext::onLogin(CData& data)
{
	uint worldId;
	data >> worldId;
	CData answer;
	answer.wrt((byte)SIGNALS_START);
	if( CCMApp::instance()->findWorldHost(getHost()) )
	{
		if( CCMApp::instance()->server()->findContext(worldId) )
		{
			CLog::instance()->log(CLog::msgLvlInfo,_("Try to log in second world with id %d.\n"),worldId);
			answer.wrt((byte)0);
		} else
		{
			CLog::instance()->log(CLog::msgLvlInfo,_("World with id %d logged in.\n"),worldId);
			answer.wrt((byte)1);
			m_worldId = worldId;
			data >> m_worldPort;
		}
	} else
	{
BOOL LLIMFloater::getVisible()
{
	if(isChatMultiTab())
	{
		LLIMFloaterContainer* im_container = LLIMFloaterContainer::getInstance();
		
		// Treat inactive floater as invisible.
		bool is_active = im_container->getActiveFloater() == this;
	
		//torn off floater is always inactive
		if (!is_active && getHost() != im_container)
		{
			return LLTransientDockableFloater::getVisible();
		}

		// getVisible() returns TRUE when Tabbed IM window is minimized.
		return is_active && !im_container->isMinimized() && im_container->getVisible();
	}
	else
	{
		return LLTransientDockableFloater::getVisible();
	}
}
void TrackerFiltersList::removeItem(const QString &tracker, const QString &hash)
{
    QString host = getHost(tracker);
    QListWidgetItem *trackerItem = nullptr;
    QStringList tmp = m_trackers.value(host);
    int row = 0;

    if (tmp.empty())
        return;
    tmp.removeAll(hash);

    if (!host.isEmpty()) {
        // Remove from 'Error' and 'Warning' view
        trackerSuccess(hash, tracker);
        row = rowFromTracker(host);
        trackerItem = item(row);
        if (tmp.empty()) {
            if (currentRow() == row)
                setCurrentRow(0, QItemSelectionModel::SelectCurrent);
            delete trackerItem;
            m_trackers.remove(host);
            updateGeometry();
            return;
        }
        if (trackerItem != nullptr)
            trackerItem->setText(QString("%1 (%2)").arg(host).arg(tmp.size()));
    }
    else {
        row = 1;
        trackerItem = item(1);
        trackerItem->setText(tr("Trackerless (%1)").arg(tmp.size()));
    }

    m_trackers.insert(host, tmp);
    if (currentRow() == row)
        applyFilter(row);
}
예제 #18
0
            nint NMySqlConnection::compareTo(const INObject * other) const
            {
                if (this == other)
                    return 0;
                try
                {
                    const NMySqlConnection * obj = dynamic_cast<const NMySqlConnection *>(other);

                    if (obj != NULL)
                    {
                        nint result = 0;
                        if ((result = getHost().compare(obj->getHost())) == 0)
                        {
                            if ((result = getPort().getValue() - obj->getPort().getValue()) == 0)
                            {
                                if ((result = getUser().compare(obj->getUser())) == 0)
                                {
                                    if ((result = getPassword().compare(obj->getPassword())) == 0)
                                    {
                                        result = getDatabase().compare(obj->getDatabase());
                                    }
                                }
                            }
                        }
                        return result;
                    }
                    else
                    {
                        return 1;
                    }
                }
                catch (bad_cast &)
                {
                    return 1;
                }
            }
LogStream*
SocketStreamCreator::create (FiltersFactory* ff, string location,
                             list<string>& filters, u_long cycle)
{
  Socket* out = new Socket ();
  string host = getHost (location);
  u_short port = getPort (location);

  if (out->socket (AF_INET, SOCK_STREAM, 0) < 0)
    return NULL;

  if (out && !out->connect (host.c_str (), port))
    {
      size_t nbw;
      FiltersChain* fc = ff->makeChain (filters, out, &nbw);
      if (fc)
        return new SocketStream (ff, cycle, out, fc);
    }

  if (out)
    delete out;

  return NULL;
}
// Default constructor
LLPreviewNotecard::LLPreviewNotecard(const std::string& name,
									 const LLRect& rect,
									 const std::string& title,
									 const LLUUID& item_id, 
									 const LLUUID& object_id,
									 const LLUUID& asset_id,
									 BOOL show_keep_discard,
									 LLPointer<LLViewerInventoryItem> inv_item) :
	LLPreview(name, rect, title, item_id, object_id, TRUE,
			  PREVIEW_MIN_WIDTH,
			  PREVIEW_MIN_HEIGHT,
			  inv_item),
	mAssetID( asset_id ),
	mNotecardItemID(item_id),
	mObjectID(object_id)
{
	LLRect curRect = rect;

	if (show_keep_discard)
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard_keep_discard.xml");
		childSetAction("Keep",onKeepBtn,this);
		childSetAction("Discard",onDiscardBtn,this);
	}
	else
	{
		LLUICtrlFactory::getInstance()->buildFloater(this,"floater_preview_notecard.xml");
		// <edit>
		childSetAction("Get Items", onClickGetItems, this);
		// </edit>

		if( mAssetID.isNull() )
		{
			const LLInventoryItem* item = getItem();
			if( item )
			{
				mAssetID = item->getAssetUUID();
			}
		}
	}	
	if (hasChild("Save", true))
		childSetAction("Save",onClickSave,this);

	// only assert shape if not hosted in a multifloater
	if (!getHost())
	{
		reshape(curRect.getWidth(), curRect.getHeight(), TRUE);
		setRect(curRect);
	}
			
	if (LLUICtrl* ctrl = findChild<LLUICtrl>("lock"))
		ctrl->setVisible(false);
	
	if (hasChild("desc", true))
	{
		childSetCommitCallback("desc", LLPreview::onText, this);
		if (const LLInventoryItem* item = getItem())
			childSetText("desc", item->getDescription());
		childSetPrevalidate("desc", &LLLineEditor::prevalidatePrintableNotPipe);
	}

	setTitle(title);
	
	LLViewerTextEditor* editor = findChild<LLViewerTextEditor>("Notecard Editor");

	if (editor)
	{
		editor->setWordWrap(TRUE);
		editor->setSourceID(item_id);
		editor->setHandleEditKeysDirectly(TRUE);
	}

	initMenu();

	gAgentCamera.changeCameraToDefault();
}
예제 #21
0
bool ConfigServer::init( vector<string> configHosts , bool infer ) {
    string hn = getHostName();
    if ( hn.empty() ) {
        sleepsecs(5);
        exit(16);
    }
    ourHostname = hn;

    char buf[256];
    strcpy(buf, hn.c_str());

    if ( configHosts.empty() ) {
        char *p = strchr(buf, '-');
        if ( p )
            p = strchr(p+1, '-');
        if ( !p ) {
            log() << "can't parse server's hostname, expect <city>-<locname>-n<nodenum>, got: " << buf << endl;
            sleepsecs(5);
            exit(17);
        }
        p[1] = 0;
    }

    string left, right; // with :port#
    string hostLeft, hostRight;

    if ( configHosts.empty() ) {
        if ( ! infer ) {
            out() << "--configdb or --infer required\n";
            exit(7);
        }
        stringstream sl, sr;
        sl << buf << "grid-l";
        sr << buf << "grid-r";
        hostLeft = sl.str();
        hostRight = sr.str();
        sl << ":" << Port;
        sr << ":" << Port;
        left = sl.str();
        right = sr.str();
    }
    else {
        hostLeft = getHost( configHosts[0] , false );
        left = getHost( configHosts[0] , true );

        if ( configHosts.size() > 1 ) {
            hostRight = getHost( configHosts[1] , false );
            right = getHost( configHosts[1] , true );
        }
    }


    if ( !isdigit(left[0]) )
        /* this loop is not really necessary, we we print out if we can't connect
           but it gives much prettier error msg this way if the config is totally
           wrong so worthwhile.
           */
        while ( 1 ) {
            if ( hostbyname(hostLeft.c_str()).empty() ) {
                log() << "can't resolve DNS for " << hostLeft << ", sleeping and then trying again" << endl;
                sleepsecs(15);
                continue;
            }
            if ( !hostRight.empty() && hostbyname(hostRight.c_str()).empty() ) {
                log() << "can't resolve DNS for " << hostRight << ", sleeping and then trying again" << endl;
                sleepsecs(15);
                continue;
            }
            break;
        }

    Nullstream& l = log();
    l << "connecting to griddb ";

    if ( !hostRight.empty() ) {
        // connect in paired mode
        l << "L:" << left << " R:" << right << "...";
        l.flush();
        _primary = left + "," + right;
    }
    else {
        l << left << "...";
        l.flush();
        _primary = left;
    }

    return true;
}
예제 #22
0
void SmartMote::work(){
    while(1){
        /*  se l'ora corrente è di scansione                                    */
        if(!(RTCC.hours() % 6) && (RTCC.minutes() >= 0x00 && RTCC.minutes() <= 0x05)){
            AString data;
            AString message;
            AString answer;
            /*  abilito il core timer (la prima volta è già abilitato)          */
            System::wakeCoreTimer();
            /*  accendo il led verde                                            */
            turnOnGreen();
            /*  accendo la seriale                                              */
            openUART();
            /*  accendo l'i2c                                                   */
            openI2C();
            /*  prendo le misure                                                */
            data += mac();
            data += luminosity();
            data += ambientTempAndHum();
            data += groundTemp();
            data += groundHum();
            data += battey();
            /*  compongo la stringa                                             */
            message += _PHP_CHUNK1;
            /*  inserisco l'hostname                                            */
            message += getHost();
            /*  inserisco la seconda parte di richiesta http                    */
            message += _PHP_CHUNK2;
            /*  inserisco la lunghezza dei dati                                 */
            message += AString(static_cast<sint32>(data.size()));
            /*  inserisco la terza parte di richiesta http                      */
            message += _PHP_CHUNK3;
            /*  inserisco i dati                                                */
            message += data;

            /*  se fallisce l'inizializzazione dell'esp                         */
            if(!m_net.initialize()){
                /*  notifico l'errore                                           */
                error();
            }
            /*  se fallisce l'avvio del dhcp                                    */
            if(!m_net.setDhcp(true)){
                /*  notifico l'errore                                           */
                error();
            }
            /*  se fallisce la connessione alla rete                            */
            if(!m_net.joinAP(getSSID(), getKey())){
                /*  notifico l'errore                                           */
                error();
            }
            /*  se fallisce la connessione al server                            */
            if(!m_net.connectToHost(getHost(), 80)){
                /*  notifico l'errore                                           */
                error();
            }
            /*  invio i dati                                                    */
            m_net.send(message);
            /*  aspetto l'ok                                                    */
            m_net.waitForData(answer);
            /*  notifico l'ok o lerrore dell'invio                              */
            wasSuccess(answer);
            /*  lascio l'ap                                                     */
            m_net.leaveAP();
            /*  libero la memoria occupata dalle stringhe                       */
            message.clear();
            data.clear();
            answer.clear();
        }
        /*  calcolo del tempo di sleep per il wifi                              */
        m_net.sleep(getSleepTime());
        /*  punto la prossima sveglia                                           */
        setNextAlarm();
        /*  spengo il led verde                                                 */
        turnOffGreen();
        /*  spengo l'uart                                                       */
        closeUART();
        /*  chiudo l'i2c                                                        */
        closeI2C();
        /*  spengo il core timer                                                */
        System::stopCoreTimer();
        /*  vado a dormire                                                      */
        System::sleep();
            
    }
}
예제 #23
0
/// Returns a std::string of stats, ended by a newline.
/// Requires the current connector name as an argument.
std::string Socket::Connection::getStats(std::string C){
  return "S " + getHost() + " " + C + " " + uint2string(Util::epoch() - conntime) + " " + uint2string(up) + " " + uint2string(down) + "\n";
}
예제 #24
0
 void DocumentBrowser::Drive::createNewDocument() const
 {
     KiwiApp::useInstance().openRemotePatcher(getHost(), getPort(), m_new_session_id);
 }
예제 #25
0
std::string SIPFrom::getHost() const
{
  std::string host;
  getHost(_data, host);
  return host;
}
예제 #26
0
파일: jp_env.cpp 프로젝트: anthrotype/jpype
bool JPEnv::isInitialized()
{
	return getJava() != NULL && getHost() != NULL;
}
예제 #27
0
std::string net::URL::toString() const
{
    return net::urlJoin(getProtocol(), getHost(), getPort(), getPath(),
                        getQuery(), getFragment());
}
void ThreadedSSLSocketInitiator::doConnect(const SessionID &s,
                                           const Dictionary &d)
{
  try
  {
    Session *session = Session::lookupSession(s);
    if (!session->isSessionTime(UtcTimeStamp()))
      return;

    Log *log = session->getLog();

    std::string address;
    short port = 0;
    getHost(s, d, address, port);

    int socket = socket_createConnector();
    if (m_noDelay)
      socket_setsockopt(socket, TCP_NODELAY);
    if (m_sendBufSize)
      socket_setsockopt(socket, SO_SNDBUF, m_sendBufSize);
    if (m_rcvBufSize)
      socket_setsockopt(socket, SO_RCVBUF, m_rcvBufSize);

    setPending(s);
    log->onEvent("Connecting to " + address + " on port " +
                 IntConvertor::convert((unsigned short)port));

    SSL *ssl = SSL_new(m_ctx);
    if (ssl == 0)
    {
      log->onEvent("Failed to create ssl object");
      return;
    }
    SSL_clear(ssl);
    BIO *sbio = BIO_new_socket(socket, BIO_CLOSE);
    SSL_set_bio(ssl, sbio, sbio);

    ThreadedSSLSocketConnection *pConnection = new ThreadedSSLSocketConnection(
        s, socket, ssl, address, port, getLog());

    ThreadPair *pair = new ThreadPair(this, pConnection);

    {
      Locker l(m_mutex);
      thread_id thread;
      if (thread_spawn(&socketThread, pair, thread))
      {
        addThread(SocketKey(socket, ssl), thread);
      }
      else
      {
        delete pair;
        pConnection->disconnect();
        delete pConnection;
        SSL_free(ssl);
        setDisconnected(s);
      }
    }
  }
  catch (std::exception &)
  {
  }
}
예제 #29
0
// Default constructor
LLFloaterBulkPermission::LLFloaterBulkPermission(const std::string& name,
											 const LLRect& rect,
											 const char* title,
											 const char* start_string) :
	LLFloater(name, rect, title,
			  RESIZE_YES, DEFAULT_MIN_WIDTH, DEFAULT_MIN_HEIGHT,
			  DRAG_ON_TOP, MINIMIZE_YES, CLOSE_YES)
{

	req_perm_mask=0; // This should match the default state the checkboxes are set to
	recurse=false;

	LLUICtrlFactory::getInstance()->buildFloater(this,"floater_bulk_perms.xml");

	childSetAction("Apply...",onApplyBtn,this);
	childSetEnabled("Apply...",TRUE);

	childSetCommitCallback("Modify",&onCommitPermissions, this);
	childSetCommitCallback("Trans",&onCommitPermissions, this);
	childSetCommitCallback("Copy",&onCommitPermissions, this);

	//childSetCommitCallback("Recurse",&onRecurse, this);

	childSetCommitCallback("Parent",&onParent, this);

	childSetCommitCallback("objects",&InvSelection, this);
	childSetCommitCallback("scripts",&InvSelection, this);
	childSetCommitCallback("textures",&InvSelection, this);
	childSetCommitCallback("sounds",&InvSelection, this);
	childSetCommitCallback("animations",&InvSelection, this);
	childSetCommitCallback("notecards",&InvSelection, this);
	childSetCommitCallback("landmarks",&InvSelection, this);
	childSetCommitCallback("bodyparts",&InvSelection, this);
	childSetCommitCallback("clothing",&InvSelection, this);
	childSetCommitCallback("gestures",&InvSelection, this);

	//Set variable state to XUI default state consistancy
	processObject=getChild<LLCheckBoxCtrl>("objects")->get();
	processScript=getChild<LLCheckBoxCtrl>("scripts")->get();
	processTexture=getChild<LLCheckBoxCtrl>("textures")->get();
	processSound=getChild<LLCheckBoxCtrl>("sounds")->get();
	processAnimation=getChild<LLCheckBoxCtrl>("animations")->get();
	processNotecard=getChild<LLCheckBoxCtrl>("notecards")->get();
	processGesture=getChild<LLCheckBoxCtrl>("gestures")->get();
	processClothing=getChild<LLCheckBoxCtrl>("clothing")->get();
	processBodypart=getChild<LLCheckBoxCtrl>("bodyparts")->get();
	processLandmark=getChild<LLCheckBoxCtrl>("landmarks")->get();
	parent=getChild<LLCheckBoxCtrl>("Parent")->get();


	setTitle(title);
	
	if (!getHost())
	{
		LLRect curRect = getRect();
		translate(rect.mLeft - curRect.mLeft, rect.mTop - curRect.mTop);
	}
	
	mStartString = start_string;
	mDone = FALSE;
	sInstances.addData(mID, this);

}
예제 #30
0
파일: Headless.cpp 프로젝트: Arakash/ppsspp
int main(int argc, const char* argv[])
{
#ifdef ANDROID_NDK_PROFILER
	setenv("CPUPROFILE_FREQUENCY", "500", 1);
	setenv("CPUPROFILE", "/sdcard/gmon.out", 1);
	monstartup("ppsspp_headless");
#endif

	bool fullLog = false;
	bool useJit = true;
	bool autoCompare = false;
	bool verbose = false;
	const char *stateToLoad = 0;
	GPUCore gpuCore = GPU_NULL;
	
	std::vector<std::string> testFilenames;
	const char *mountIso = 0;
	const char *screenshotFilename = 0;
	bool readMount = false;
	float timeout = std::numeric_limits<float>::infinity();

	for (int i = 1; i < argc; i++)
	{
		if (readMount)
		{
			mountIso = argv[i];
			readMount = false;
			continue;
		}
		if (!strcmp(argv[i], "-m") || !strcmp(argv[i], "--mount"))
			readMount = true;
		else if (!strcmp(argv[i], "-l") || !strcmp(argv[i], "--log"))
			fullLog = true;
		else if (!strcmp(argv[i], "-i"))
			useJit = false;
		else if (!strcmp(argv[i], "-j"))
			useJit = true;
		else if (!strcmp(argv[i], "-c") || !strcmp(argv[i], "--compare"))
			autoCompare = true;
		else if (!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose"))
			verbose = true;
		else if (!strncmp(argv[i], "--graphics=", strlen("--graphics=")) && strlen(argv[i]) > strlen("--graphics="))
		{
			const char *gpuName = argv[i] + strlen("--graphics=");
			if (!strcasecmp(gpuName, "gles"))
				gpuCore = GPU_GLES;
			else if (!strcasecmp(gpuName, "software"))
				gpuCore = GPU_SOFTWARE;
			else if (!strcasecmp(gpuName, "directx9"))
				gpuCore = GPU_DIRECTX9;
			else if (!strcasecmp(gpuName, "null"))
				gpuCore = GPU_NULL;
			else
			{
				printUsage(argv[0], "Unknown gpu backend specified after --graphics=");
				return 1;
			}
		}
		// Default to GLES if no value selected.
		else if (!strcmp(argv[i], "--graphics"))
			gpuCore = GPU_GLES;
		else if (!strncmp(argv[i], "--screenshot=", strlen("--screenshot=")) && strlen(argv[i]) > strlen("--screenshot="))
			screenshotFilename = argv[i] + strlen("--screenshot=");
		else if (!strncmp(argv[i], "--timeout=", strlen("--timeout=")) && strlen(argv[i]) > strlen("--timeout="))
			timeout = strtod(argv[i] + strlen("--timeout="), NULL);
		else if (!strcmp(argv[i], "--teamcity"))
			teamCityMode = true;
		else if (!strncmp(argv[i], "--state=", strlen("--state=")) && strlen(argv[i]) > strlen("--state="))
			stateToLoad = argv[i] + strlen("--state=");
		else if (!strcmp(argv[i], "--help") || !strcmp(argv[i], "-h"))
		{
			printUsage(argv[0], NULL);
			return 1;
		}
		else
			testFilenames.push_back(argv[i]);
	}

	// TODO: Allow a filename here?
	if (testFilenames.size() == 1 && testFilenames[0] == "@-")
	{
		testFilenames.clear();
		char temp[2048];
		temp[2047] = '\0';

		while (scanf("%2047s", temp) == 1)
			testFilenames.push_back(temp);
	}

	if (readMount)
	{
		printUsage(argv[0], "Missing argument after -m");
		return 1;
	}
	if (testFilenames.empty())
	{
		printUsage(argv[0], argc <= 1 ? NULL : "No executables specified");
		return 1;
	}

	HeadlessHost *headlessHost = getHost(gpuCore);
	host = headlessHost;

	std::string error_string;
	bool glWorking = host->InitGL(&error_string);

	LogManager::Init();
	LogManager *logman = LogManager::GetInstance();
	
	PrintfLogger *printfLogger = new PrintfLogger();

	for (int i = 0; i < LogTypes::NUMBER_OF_LOGS; i++)
	{
		LogTypes::LOG_TYPE type = (LogTypes::LOG_TYPE)i;
		logman->SetEnable(type, fullLog);
		logman->SetLogLevel(type, LogTypes::LDEBUG);
		logman->AddListener(type, printfLogger);
	}

	CoreParameter coreParameter;
	coreParameter.cpuCore = useJit ? CPU_JIT : CPU_INTERPRETER;
	coreParameter.gpuCore = glWorking ? gpuCore : GPU_NULL;
	coreParameter.enableSound = false;
	coreParameter.mountIso = mountIso ? mountIso : "";
	coreParameter.startPaused = false;
	coreParameter.printfEmuLog = !autoCompare;
	coreParameter.headLess = true;
	coreParameter.renderWidth = 480;
	coreParameter.renderHeight = 272;
	coreParameter.pixelWidth = 480;
	coreParameter.pixelHeight = 272;
	coreParameter.unthrottle = true;

	g_Config.bEnableSound = false;
	g_Config.bFirstRun = false;
	g_Config.bIgnoreBadMemAccess = true;
	// Never report from tests.
	g_Config.sReportHost = "";
	g_Config.bAutoSaveSymbolMap = false;
	g_Config.iRenderingMode = 0;
	g_Config.bHardwareTransform = true;
#ifdef USING_GLES2
	g_Config.iAnisotropyLevel = 0;
#else
	g_Config.iAnisotropyLevel = 8;
#endif
	g_Config.bVertexCache = true;
	g_Config.bTrueColor = true;
	g_Config.iLanguage = PSP_SYSTEMPARAM_LANGUAGE_ENGLISH;
	g_Config.iTimeFormat = PSP_SYSTEMPARAM_TIME_FORMAT_24HR;
	g_Config.bEncryptSave = true;
	g_Config.sNickName = "shadow";
	g_Config.iTimeZone = 60;
	g_Config.iDateFormat = PSP_SYSTEMPARAM_DATE_FORMAT_DDMMYYYY;
	g_Config.iButtonPreference = PSP_SYSTEMPARAM_BUTTON_CROSS;
	g_Config.iLockParentalLevel = 9;
	g_Config.iInternalResolution = 1;
	g_Config.bFrameSkipUnthrottle = false;
	g_Config.bEnableLogging = fullLog;
	g_Config.iNumWorkerThreads = 1;
	g_Config.iBGMVolume = MAX_CONFIG_VOLUME;
	g_Config.iSFXVolume = MAX_CONFIG_VOLUME;
	g_Config.bSoftwareSkinning = true;
	g_Config.bVertexDecoderJit = true;

#ifdef _WIN32
	InitSysDirectories();
#endif

#if defined(ANDROID)
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__)
#elif !defined(_WIN32)
	g_Config.memCardDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
#endif

	// Try to find the flash0 directory.  Often this is from a subdirectory.
	for (int i = 0; i < 3; ++i)
	{
		if (!File::Exists(g_Config.flash0Directory))
			g_Config.flash0Directory += "../../flash0/";
	}
	// Or else, maybe in the executable's dir.
	if (!File::Exists(g_Config.flash0Directory))
		g_Config.flash0Directory = File::GetExeDirectory() + "flash0/";

	if (screenshotFilename != 0)
		headlessHost->SetComparisonScreenshot(screenshotFilename);

#ifdef ANDROID
	// For some reason the debugger installs it with this name?
	if (File::Exists("/data/app/org.ppsspp.ppsspp-2.apk")) {
		VFSRegister("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp-2.apk", "assets/"));
	}
	if (File::Exists("/data/app/org.ppsspp.ppsspp.apk")) {
		VFSRegister("", new ZipAssetReader("/data/app/org.ppsspp.ppsspp.apk", "assets/"));
	}
#endif

	if (stateToLoad != NULL)
		SaveState::Load(stateToLoad);

	std::vector<std::string> failedTests;
	std::vector<std::string> passedTests;
	for (size_t i = 0; i < testFilenames.size(); ++i)
	{
		coreParameter.fileToStart = testFilenames[i];
		if (autoCompare)
			printf("%s:\n", coreParameter.fileToStart.c_str());
		bool passed = RunAutoTest(headlessHost, coreParameter, autoCompare, verbose, timeout);
		if (autoCompare)
		{
			std::string testName = GetTestName(coreParameter.fileToStart);
			if (passed)
			{
				passedTests.push_back(testName);
				printf("  %s - passed!\n", testName.c_str());
			}
			else
				failedTests.push_back(testName);
		}
	}

	if (autoCompare)
	{
		printf("%d tests passed, %d tests failed.\n", (int)passedTests.size(), (int)failedTests.size());
		if (!failedTests.empty())
		{
			printf("Failed tests:\n");
			for (size_t i = 0; i < failedTests.size(); ++i) {
				printf("  %s\n", failedTests[i].c_str());
			}
		}
	}

	host->ShutdownGL();
	delete host;
	host = NULL;
	headlessHost = NULL;

#ifdef ANDROID_NDK_PROFILER
	moncleanup();
#endif

	return 0;
}