void Management::addMachine(int uniqueID, QString address, ProtocolHandler *handler){
    lock->lock();//lock the critical sections

    bool updatedMachineiD = false;
    if(uniqueID <= 0){
        updatedMachineiD = true;
        //thus generate a unique id
        uniqueID = generateUniqueId();
        Database::instance()->insert_machine(uniqueID,address);
    }

    if(handler == 0){
        lock->unlock();
        return;
    }

    Machine *machine = new Slave(uniqueID, address);
    machine->setProtocolHandler(handler);
    handler->setMachine(machine);

    if(updatedMachineiD){
        //go and update the machine id on the machine
        machine->updateUniqueID(uniqueID);
    }

    allMachines.push_back(machine);
    machineCount++;
    //emit the signal so it can be used by main form
    emit newSlaveConnected(machine);

    lock->unlock();//finally unlock for the critical section
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
PlayerProfile::PlayerProfile(const XMLNode* node) :
    m_player_group("Player", "Represents one human player"),
    m_name("-", "name", &m_player_group),
    m_is_guest_account(false, "guest", &m_player_group),
    m_use_frequency(0, "use_frequency", &m_player_group),
    m_unique_id("", "unique_id", &m_player_group)
{
    //m_player_group.findYourDataInAChildOf(node);
    m_name.findYourDataInAnAttributeOf(node);
    m_is_guest_account.findYourDataInAnAttributeOf(node);
    m_use_frequency.findYourDataInAnAttributeOf(node);
    m_unique_id.findYourDataInAnAttributeOf(node);

    if ((std::string)m_unique_id == "")
    {
        fprintf(stderr, "** WARNING: Player has no unique ID, probably it is from an older STK version\n");
        int64_t unique_id = generateUniqueId(core::stringc(m_name.c_str()).c_str());
        std::ostringstream tostring;
        tostring << std::hex << unique_id;
        m_unique_id = tostring.str();
    }

    #ifdef DEBUG
    m_magic_number = 0xABCD1234;
    #endif
}   // PlayerProfile
Ejemplo n.º 3
0
void SlickerCardManager::registerCard(CardDesk::Card *card)
{
 	kdDebug(155003) << "Manager::registerCard()" << endl;
	/*
		we're not concerned with performance when adding/removing
		cards, since it won't happen but a handful of times while
		the program is running. So we'll resize the deck for each
		insertion/deletion
	*/

	if (card->cardId().isNull())
		card->setCardId(generateUniqueId());

	_cards.append(card);

	connect(card, SIGNAL(deckingChanged(Card *)), SLOT(slotDeckingModified(Card *)));
	connect(card, SIGNAL(deckingRulesChanged(Card *)), SLOT(slotDeckingRulesModified(Card *)));
	connect(card, SIGNAL(opened(Card *)), SLOT(slotCardOpened(Card *)));
	connect(card, SIGNAL(closed(Card *)), SLOT(slotCardClosed(Card *)));
	connect(card, SIGNAL(nameChanged(Card *, QString, QString)), SLOT(slotCardRenamed(Card *, QString, QString)));
	connect(card, SIGNAL(positionChanged(Card *, double, double, int)),
	        SLOT(slotCardMoved(Card *, double, double, int)));

	emit cardRegistered(QString(card->name()), card);
}
Ejemplo n.º 4
0
const pchar *PResourceCache::addMeshCache(const pchar *id, pfloat32 *vertices, puint32 numVertices, puint16 *indices,
        puint32 numIndices, const PBox &box, PGlVertexFormat *vertexFormat, pbool autoRelease) 
{
    if (id == P_NULL)
    {
        id = generateUniqueId();
    }
    // FIXME: check the uniqueness of the user specified id in asset space.
    PMeshCache *cache = PNEW(PMeshCache(this, id, vertices, numVertices, indices, numIndices, box, vertexFormat, autoRelease));
    insertObject(cache);
    return cache->id();
}
Ejemplo n.º 5
0
const pchar *PResourceCache::addImages(const pchar *id, 
                                      PImage **images, 
                                      puint32 numImages, 
                                      pbool autoRelease)
{
    if (id == P_NULL)
    {
        id = generateUniqueId();
    }
    // FIXME: check the uniqueness of the user specified id in asset space.
    PTextureCache *cache = PNEW(PTextureCache(this, id, images, numImages, autoRelease));
    insertObject(cache);
    return cache->id();
}
Ejemplo n.º 6
0
int CLegendWnd::AllocaLegend(void)
{
    int id = generateUniqueId();

    Legend newLegend;
    newLegend.id = id;
    newLegend.state = LS_DIE;
    newLegend.sel_state = SS_NORMAL;

    m_legendMap.insert(std::make_pair(id, newLegend));

    InvalidateLegend();
    return id;
}
Ejemplo n.º 7
0
OsmAnd::ObfObjectId OsmAnd::ObfObjectId::generateUniqueId(
    const uint64_t rawId,
    const uint32_t offsetInObf,
    const std::shared_ptr<const ObfSectionInfo>& obfSectionInfo)
{
    ObfObjectId uniqueId;
    uniqueId.id = rawId;

    // In case object originates from OSM, it should be unique
    if (uniqueId.isOsmId())
        return uniqueId;

    return generateUniqueId(offsetInObf, obfSectionInfo);
}
Ejemplo n.º 8
0
//------------------------------------------------------------------------------
PlayerProfile::PlayerProfile(const core::stringw& name) :
    m_player_group("Player", "Represents one human player"),
    m_name(name, "name", &m_player_group),
    m_is_guest_account(false, "guest", &m_player_group),
    m_use_frequency(0, "use_frequency", &m_player_group),
    m_unique_id("", "unique_id", &m_player_group)
{
#ifdef DEBUG
    m_magic_number = 0xABCD1234;
#endif
    int64_t unique_id = generateUniqueId(core::stringc(name.c_str()).c_str());

    std::ostringstream to_string;
    to_string << std::hex << unique_id;
    m_unique_id = to_string.str();
}
Ejemplo n.º 9
0
PResourceObject::PResourceObject(const pchar *id, PResourceManager *parent, PResourceTypeEnum type)
{
    m_type       = type;
    m_parent     = parent;
    m_available  = false;

    if (id == P_NULL)
    {
        m_id = PNEWARRAY(pchar, 7);
        generateUniqueId(m_id);
    }
    else
    {
        m_id = pstrdup(id);
    }
}
Ejemplo n.º 10
0
const pchar *PResourceCache::addMaterialCache(const pchar *id, 
                                              const pchar *text,
                                              pbool autoRelease)
{
    if (id == P_NULL)
    {
        id = generateUniqueId();
    }
    // Check the uniqueness of the user specified id in asset space.
    PCacheObject *obj = findObject(id);
    if (obj == P_NULL)
    {
        obj = PNEW(PMaterialCache(this, id, text, autoRelease));
        insertObject(obj);
    }
    
    return obj->id();
}
Ejemplo n.º 11
0
// registration of distributables. an object can only be distributed in one
// group at a time. all other group members will be able to see and modify a registered
// object. an unregistered object is only visible to the creator.
void
av::NetNode::registerObj(const Link<Distributed>& obj)
{
  registerObj(obj, generateUniqueId());
}
Ejemplo n.º 12
0
bool KviIrcServer::load(KviConfigurationFile * pCfg, const QString & szPrefix)
{
	QString szTmp;
	szTmp = QString("%1Hostname").arg(szPrefix);
	m_szHostname = pCfg->readEntry(szTmp);
	szTmp = QString("%1Ip").arg(szPrefix);
	m_szIp = pCfg->readEntry(szTmp);
	if(m_szHostname.isEmpty() && m_szIp.isEmpty())
		return false;

	szTmp = QString("%1Description").arg(szPrefix);
	m_szDescription = pCfg->readEntry(szTmp);
	szTmp = QString("%1User").arg(szPrefix);
	m_szUser = pCfg->readEntry(szTmp);
	szTmp = QString("%1Pass").arg(szPrefix);
	m_szPass = pCfg->readEntry(szTmp);
	szTmp = QString("%1Nick").arg(szPrefix);
	m_szNick = pCfg->readEntry(szTmp);
	szTmp = QString("%1AlternativeNick").arg(szPrefix);
	m_szAlternativeNick = pCfg->readEntry(szTmp);
	szTmp = QString("%1SaslPass").arg(szPrefix);
	m_szSaslPass = pCfg->readEntry(szTmp);
	szTmp = QString("%1SaslNick").arg(szPrefix);
	m_szSaslNick = pCfg->readEntry(szTmp);
	szTmp = QString("%1RealName").arg(szPrefix);
	m_szRealName = pCfg->readEntry(szTmp);
	szTmp = QString("%1InitUmode").arg(szPrefix);
	m_szInitUMode = pCfg->readEntry(szTmp);
	szTmp = QString("%1AutoJoinChannels").arg(szPrefix);
	QStringList l = pCfg->readStringListEntry(szTmp,QStringList());
	if(l.count() > 0)
		setAutoJoinChannelList(new QStringList(l));

	szTmp = QString("%1AutoConnect").arg(szPrefix);
	m_bAutoConnect = pCfg->readBoolEntry(szTmp,false);
	szTmp = QString("%1Encoding").arg(szPrefix);
	m_szEncoding = pCfg->readEntry(szTmp);
	szTmp = QString("%1TextEncoding").arg(szPrefix);
	m_szTextEncoding = pCfg->readEntry(szTmp);
	szTmp = QString("%1OnConnectCommand").arg(szPrefix);
	m_szOnConnectCommand = pCfg->readEntry(szTmp);
	szTmp = QString("%1OnLoginCommand").arg(szPrefix);
	m_szOnLoginCommand = pCfg->readEntry(szTmp);
	szTmp = QString("%1LinkFilter").arg(szPrefix);
	m_szLinkFilter = pCfg->readEntry(szTmp);
	szTmp = QString("%1Port").arg(szPrefix);
	m_uPort = pCfg->readUIntEntry(szTmp,6667);
	szTmp = QString("%1Id").arg(szPrefix);
	m_szId = pCfg->readEntry(szTmp);
	if(m_szId.isEmpty())
		generateUniqueId();

	szTmp = QString("%1IPv6").arg(szPrefix);
	setIPv6(pCfg->readBoolEntry(szTmp,false));
	szTmp = QString("%1CacheIp").arg(szPrefix);
	setCacheIp(pCfg->readBoolEntry(szTmp,false)); // true ?
	szTmp = QString("%1SSL").arg(szPrefix);
	setUseSSL(pCfg->readBoolEntry(szTmp,false));
	szTmp = QString("%1EnabledCAP").arg(szPrefix);
	setEnabledCAP(pCfg->readBoolEntry(szTmp,true));
	szTmp = QString("%1EnabledSTARTTLS").arg(szPrefix);
	setEnabledSTARTTLS(pCfg->readBoolEntry(szTmp,true));
	szTmp = QString("%1EnabledSASL").arg(szPrefix);
	setEnabledSASL(pCfg->readBoolEntry(szTmp,false));
	szTmp = QString("%1Proxy").arg(szPrefix);
	setProxy(pCfg->readIntEntry(szTmp,-2));
	szTmp = QString("%1UserIdentityId").arg(szPrefix);
	m_szUserIdentityId = pCfg->readEntry(szTmp);
	szTmp = QString("%1Favorite").arg(szPrefix);
	setFavorite(pCfg->readBoolEntry(szTmp,false));
	return true;
}
Ejemplo n.º 13
0
Msg::Msg(int msgId)
  : msgId_(msgId), uniqueId_(generateUniqueId())
{
}