示例#1
0
void MessageCarbons::onDiscoInfoReceived(const IDiscoInfo &AInfo)
{
	if (AInfo.node.isEmpty() && AInfo.contactJid==AInfo.streamJid.domain() && !FEnabled.contains(AInfo.streamJid))
	{
		FEnabled.insert(AInfo.streamJid,false);
		if (AInfo.features.contains(NS_MESSAGE_CARBONS))
			setEnabled(AInfo.streamJid,true);
		else
			LogWarning(QString("[MessageCarbons] Message Carbons does not supported by '%1'").arg(AInfo.streamJid.full()));
	}
}
示例#2
0
void InputAPI::UnregisterInputContextRaw(const String &name)
{
    for(auto iter = untrackedInputContexts.Begin();
        iter != untrackedInputContexts.End(); ++iter)
        if ((*iter)->Name() == name)
        {
            untrackedInputContexts.Erase(iter);
            return;
        }
    LogWarning("Failed to delete non-refcounted Input Context \"" + name + "\": an Input Context with that name doesn't exist!");
}
void AssetRefListener::HandleAssetRefChange(IAttribute *assetRef, const String& assetType)
{
    Attribute<AssetReference> *attr = dynamic_cast<Attribute<AssetReference> *>(assetRef);
    if (!attr)
    {
        LogWarning("AssetRefListener::HandleAssetRefChange: Attribute's type not AssetReference (was " +
            (assetRef == 0 ? "null" : assetRef->TypeName()) + " instead).");
        return;
    }
    HandleAssetRefChange(attr->Owner()->GetFramework()->Asset(), attr->Get().ref, assetType);
}
示例#4
0
void EC_DynamicComponent::SetAttribute(int index, const QVariant &value, AttributeChange::Type change)
{
    int attrIndex = GetInternalAttributeIndex(index);
    if (attrIndex < 0)
    {
        LogWarning("Cannot set attribute, index out of bounds");
        return;
    }
    
    attributes[attrIndex]->FromQVariant(value, change);
}
示例#5
0
void CMMDVMHost::readParams()
{
	m_dstarEnabled = m_conf.getDStarEnabled();
	m_dmrEnabled   = m_conf.getDMREnabled();
	m_ysfEnabled   = m_conf.getFusionEnabled();

	if (!m_conf.getDuplex() && m_dmrEnabled) {
		LogWarning("DMR operation disabled because system is not duplex");
		m_dmrEnabled = false;
	}
}
示例#6
0
data_OCTAVE_DIS Att::StrToOctaveDis(std::string value)
{
    if (value == "8") return OCTAVE_DIS_8;
    else if (value == "15") return OCTAVE_DIS_15;
    else if (value == "22") return OCTAVE_DIS_22;
    else {
        LogWarning("Unsupported octave dis '%s'", value.c_str() );
    }
    // default
    return OCTAVE_DIS_NONE;
}
示例#7
0
int main(int argc, const char * argv[])
{
    CreateLog();
    
    LogWarning("Warning message example with number = %d", 1);
    LogError("Error message example with number = %d", 2);
    LogInfo("Info message example with number = %d", 3);
    LogDebug("Debug message example with number = %d", 4);
    
    return 0;
}
示例#8
0
void ConsoleAPI::UnregisterCommand(const QString &name)
{
    CommandMap::iterator it = commands.find(name);
    if (it == commands.end())
    {
        LogWarning("ConsoleAPI: Trying to unregister non-existing command " + name + ".");
        return;
    }

    commands.erase(it);
}
示例#9
0
int CEMSocket::OnLayerCallback(const CAsyncSocketExLayer *pLayer, int nType, int nCode, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(wParam);
    ASSERT( pLayer );
    if (nType == LAYERCALLBACK_STATECHANGE)
    {
        /*CString logline;
        if (pLayer==m_pProxyLayer)
        {
        	//logline.Format(_T("ProxyLayer changed state from %d to %d"), wParam, nCode);
        	//AddLogLine(false,logline);
        }else
        	//logline.Format(_T("Layer @ %d changed state from %d to %d"), pLayer, wParam, nCode);
        	//AddLogLine(false,logline);*/
        return 1;
    }
    else if (nType == LAYERCALLBACK_LAYERSPECIFIC)
    {
        if (pLayer == m_pProxyLayer)
        {
            switch (nCode)
            {
            case PROXYERROR_NOCONN:
                // We failed to connect to the proxy.
                m_bProxyConnectFailed = true;
                /* fall through */
            case PROXYERROR_REQUESTFAILED:
                // We are connected to the proxy but it failed to connect to the peer.
                if (thePrefs.GetVerbose())
                {
                    m_strLastProxyError = GetProxyError(nCode);
                    if (lParam && ((LPCSTR)lParam)[0] != '\0')
                    {
                        m_strLastProxyError += _T(" - ");
                        m_strLastProxyError += (LPCSTR)lParam;
                    }
                    // Appending the Winsock error code is actually not needed because that error code
                    // gets reported by to the original caller anyway and will get reported eventually
                    // by calling 'GetFullErrorMessage',
                    /*if (wParam) {
                    	CString strErrInf;
                    	if (GetErrorMessage(wParam, strErrInf, 1))
                    		m_strLastProxyError += _T(" - ") + strErrInf;
                    }*/
                }
                break;
            default:
                m_strLastProxyError = GetProxyError(nCode);
                LogWarning(false, _T("Proxy-Error: %s"), m_strLastProxyError);
            }
        }
    }
    return 1;
}
示例#10
0
Font::Font(const TString& filename, int pitch) : CStatus(){
	SetClassName("Font");
	font = 0;
	if (!ttf_initialized)
		if (TTF_Init() != 0){
			SetStatus(STATUS_ERROR);
			LogWarning("Could not initialize libSDL_ttf");
			return;
			}
	ttf_initialized = true;

	font = TTF_OpenFont(filename.text(),pitch);
	if (!font){
			SetStatus(STATUS_ERROR);
			LogWarning("Could not load font %s",filename.text());
			return;
			}

	setColor(255,255,255);
}
示例#11
0
data_STAFFREL Att::StrToStaffRel(std::string value)
{
    if (value == "below") return STAFFREL_below;
    else if (value == "above") return STAFFREL_above;
    else if (value == "within") return STAFFREL_within;
    else {
        LogWarning("Unsupported staff rel '%s'", value.c_str() );
    }
    // default
    return STAFFREL_NONE;
}
bool SyncManagerImpl::RegisterListener(SyncListener* listener)
{
	if (listener)
	{
		// If we do not already have a listener...
		if (!m_listener)
		{
			// If the listener is not already registered...
			if (!listener->IsRegistered())
			{
				m_listener = listener;
				RegistrationReceiptPtr receipt = CreateRegistrationReceipt(SyncManagerImplPtr(this), &SyncManagerImpl::UnregisterListener, listener);
				m_listener->AddRegistration(receipt, receipt->GetKey());
				return true;
			}
			else
			{
				LogError("Trying to register a listener that has already been registered");
				return false;
			}
		}
		else
		{
			if (m_listener == listener)
			{
				LogWarning("SyncListener registration failed because the given listener is already registered");
			}
			else
			{
				LogWarning("SyncListener registration failed because another listener is already registered");
			}

			return false;
		}
	}
	else
	{
		LogError("Trying to register a NULL pointer");
		return false;
	}
}
示例#13
0
OpenJabNab::OpenJabNab(int argc, char ** argv):QCoreApplication(argc, argv)
{
	GlobalSettings::Init();
	LogInfo("-- OpenJabNab Start --");
	TTSManager::Init();
	BunnyManager::Init();
	Bunny::Init();
	ZtampManager::Init();
	Ztamp::Init();
	AccountManager::Init();
	NetworkDump::Init();
	PluginManager::Init();
	BunnyManager::LoadBunnies();
	ZtampManager::LoadZtamps();

	if(GlobalSettings::Get("Config/HttpListener", true) == true)
	{
		// Create Listeners
		httpListener = new QTcpServer(this);
		httpListener->listen(QHostAddress::LocalHost, GlobalSettings::GetInt("OpenJabNabServers/ListeningHttpPort", 8080));
		connect(httpListener, SIGNAL(newConnection()), this, SLOT(NewHTTPConnection()));
	}
	else
		LogWarning("Warning : HTTP Listener is disabled !");

	if(GlobalSettings::Get("Config/XmppListener", true) == true)
	{
		xmppListener = new QTcpServer(this);
		xmppListener->listen(QHostAddress::Any, GlobalSettings::GetInt("OpenJabNabServers/XmppPort", 5222));
		connect(xmppListener, SIGNAL(newConnection()), this, SLOT(NewXMPPConnection()));
	}
	else
		LogWarning("Warning : XMPP Listener is disabled !");

	httpApi = GlobalSettings::Get("Config/HttpApi", true).toBool();
	httpViolet = GlobalSettings::Get("Config/HttpViolet", true).toBool();
	standAlone = GlobalSettings::Get("Config/StandAlone", true).toBool();
	LogInfo(QString("Parsing of HTTP Api is ").append((httpApi == true)?"enabled":"disabled"));
	LogInfo(QString("Parsing of HTTP Bunny messages is ").append((httpViolet == true)?"enabled":"disabled"));
	LogInfo(QString("Current mode is ").append((standAlone == true)?"standalone":"connected to Violet"));
}
示例#14
0
sp<PaletteImage> RawImage::load(Data &data, const UString &filename, const Vec2<int> &size)
{
	auto infile = data.fs.open(filename);
	if (!infile)
	{
		LogWarning("Failed to open file \"%s\"", filename.cStr());
		return nullptr;
	}
	if (size.x <= 0 || size.y <= 0)
	{
		LogWarning("Trying to read image of invalid size {%d,%d}", size.x, size.y);
		return nullptr;
	}

	if (infile.size() != static_cast<size_t>(size.x * size.y))
	{
		LogWarning("File \"%s\" has incorrect size for raw image of size {%d,%d}", filename.cStr(),
		           size.x, size.y);
	}

	auto image = mksp<PaletteImage>(size);

	PaletteImageLock l(image, ImageLockUse::Write);

	for (int y = 0; y < size.y; y++)
	{
		for (int x = 0; x < size.x; x++)
		{
			// TODO: can read a stride at a time? Or just the whole chunk as it's tightly packed?
			uint8_t idx;
			if (!infile.read(reinterpret_cast<char *>(&idx), 1))
			{
				LogError("Unexpected EOF in file \"%s\" at {%d,%d}", filename.cStr(), x, y);
				return nullptr;
			}
			l.set(Vec2<unsigned int>{x, y}, idx);
		}
	}

	return image;
}
/* Gets identifier of the UICC */
uint32_t getUicc()
{
	if (uiccId == UNDEFINED)
	{
		getSecureElementList();
		if (uiccId == UNDEFINED)
		{
			LogWarning("UICC can't be detected");
		}
	}
	return uiccId;
}
示例#16
0
bonobo::DataType bonobo::Type(types::DataType dt)
{
#	define TYPE_OPERATION(C_TYPE, DATA_TYPE, SIZE, GL_DATA_TYPE) \
		case DATA_TYPE: return (bonobo::DataType) GL_DATA_TYPE;
	switch (dt) {
#		include "Types.inl"
		default: break;
	}
	LogWarning("GL type conversion failed");
	return bonobo::TYPE_INT;
#	undef TYPE_OPERATION
}
示例#17
0
文件: Font.cpp 项目: Asido/Tamagotchi
bool Font::AddSymbol(unsigned char symbol, std::shared_ptr<FontSymbol> fontChar)
{
    FontSymbols::iterator it = this->symbols.find(symbol);
    if (it != this->symbols.end())
    {
        LogWarning("Duplicate symbol '%c'.", symbol);
        return false;
    }

    std::pair<FontSymbols::iterator, bool> status = this->symbols.insert(std::make_pair(symbol, fontChar));
    return status.second;
}
示例#18
0
QVariant ConfigAPI::Read(const ConfigData &data, QString key, const QVariant &defaultValue) const
{
    if (data.file.isEmpty() || data.section.isEmpty())
    {
        LogWarning("ConfigAPI::Read: ConfigData does not have enough information (file and section).");
        return data.defaultValue;
    }
    if (defaultValue.isNull())
        return Read(data.file, data.section, key, data.defaultValue);
    else
        return Read(data.file, data.section, key, defaultValue);
}
示例#19
0
data_LAYERSCHEME Att::StrToLayerscheme(std::string value)
{
    if (value == "1") return LAYERSCHEME_1;
    else if (value == "2o") return LAYERSCHEME_2o;
    else if (value == "2f") return LAYERSCHEME_2f;
    else if (value == "3o") return LAYERSCHEME_3o;
    else if (value == "3f") return LAYERSCHEME_3f;
    else {
        LogWarning("Unsupported layerscheme '%s'", value.c_str() );
    }
    return LAYERSCHEME_NONE;
}
示例#20
0
void EC_DynamicComponent::AddQVariantAttribute(const QString &name, AttributeChange::Type change)
{
    //Check if the attribute has already been created.
    if(!ContainsAttribute(name))
    {
        Attribute<QVariant> *attribute = new Attribute<QVariant>(this, name.toStdString().c_str());
        EmitAttributeChanged(attribute, change);
        emit AttributeAdded(attribute);
    }
    else
        LogWarning("Failed to add a new QVariant in name of " + name.toStdString() + ", cause there already is an attribute in that name.");
}
示例#21
0
    int CWorldDbmgr::InsertDB(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if(p->size() != 3)
        {
            return -1;
        }

        CEntityMailbox& emb = VOBJECT_GET_EMB((*p)[0]);
        int32_t ref = VOBJECT_GET_I32((*p)[1]);
        SEntityPropFromPluto* p2 = (SEntityPropFromPluto*)((*p)[2]->vv.p);

        const string& strEntityName = GetDefParser().GetTypeName(p2->etype);

        //string strSql;
        //db.make_insert_sql(strEntityName, p2->data, strSql);
        //cout << strSql << endl;

        //string strSql2;
        //db.make_create_sql(strEntityName, strSql2);
        //cout << strSql2 << endl;

        //LogWarning("insert to db", "emb ref strEntityName = %s", strEntityName.c_str());

        string strErr;
        TDBID newid = db.InsertEntity(strEntityName, p2->data, strErr);
        if(newid == 0)
        {
            LogWarning("InsertDB_err", "newid=0;err=%s", strErr.c_str());
            //cout << strErr << endl;
            //return -2;
        }

        //通知db结果
        CEpollServer* s = this->GetServer();
        CMailBox* mb = s->GetServerMailbox(emb.m_nServerMailboxId);
        if(mb)
        {
#ifdef _WIN32
            mb->RpcCall(GetRpcUtil(), MSGID_BASEAPP_INSERT_ENTITY_CALLBACK, emb, newid, ref, strErr.c_str());
#else
            CRpcUtil& rpc = GetRpcUtil();
            CPluto* u = new CPluto;
            rpc.Encode(*u, MSGID_BASEAPP_INSERT_ENTITY_CALLBACK, emb, newid, ref, strErr.c_str());
            u->SetMailbox(mb);

            LogDebug("CDbOper::InsertDB", "u.GenLen()=%d", u->GetLen());

            g_pluto_sendlist.PushPluto(u);
#endif
        }

        return 0;
    }
示例#22
0
void Lab::update(unsigned int ticks, StateRef<Lab> lab, sp<GameState> state)
{
	if (lab->current_project && lab->getTotalSkill() > 0)
	{
		// A little complication as we want to be correctly calculating progress in an integer when
		// working with sub-single progress 'unit' time units.
		// This also leaves any remaining ticks in the lab's ticks_since_last_progress, so they will
		// get added onto the next project that lab undertakes at the first update.
		unsigned ticks_per_progress_point = TICKS_PER_HOUR / lab->getTotalSkill();
		unsigned ticks_remaining_to_progress = ticks + lab->ticks_since_last_progress;

		unsigned progress_points =
		    std::min(ticks_remaining_to_progress / ticks_per_progress_point,
		             lab->current_project->man_hours - lab->current_project->man_hours_progress);
		unsigned ticks_left =
		    ticks_remaining_to_progress - progress_points * ticks_per_progress_point;

		lab->ticks_since_last_progress = ticks_left;

		lab->current_project->man_hours_progress += progress_points;
		if (lab->current_project->isComplete())
		{
			// FIXME: Show 'research complete' screen
			LogWarning("Completed research %s", lab->current_project->name.c_str());
			sp<Facility> lab_facility;

			for (auto &base : state->player_bases)
			{
				for (auto &facility : base.second->facilities)
				{
					if (facility->lab == lab)
					{
						lab_facility = facility;
						break;
					}
				}
				if (lab_facility)
					break;
			}
			if (!lab_facility)
			{
				LogError("No facility owns the current lab");
			}

			auto complete_data = mksp<ResearchCompleteData>();
			complete_data->topic = lab->current_project;
			complete_data->lab = lab;
			auto event = new UserEvent("RESEARCH_COMPLETE", complete_data);
			fw().PushEvent(event);
			Lab::setResearch(lab, {state.get(), ""});
		}
	}
}
示例#23
0
data_BEATRPT_REND Att::StrToBeatrptRend(std::string value) const
{
    if (value == "4") return BEATRPT_REND_4;
    if (value == "8") return BEATRPT_REND_8;
    if (value == "16") return BEATRPT_REND_16;
    if (value == "32") return BEATRPT_REND_32;
    if (value == "64") return BEATRPT_REND_64;
    if (value == "128") return BEATRPT_REND_128;
    if (value == "mixed") return BEATRPT_REND_mixed;
    LogWarning("Unsupported beatrpt rend '%s'", value.c_str());
    return BEATRPT_REND_NONE;
}
示例#24
0
data_PITCHNAME Att::StrToPitchname(std::string value) const
{
    if (value == "c") return PITCHNAME_c;
    if (value == "d") return PITCHNAME_d;
    if (value == "e") return PITCHNAME_e;
    if (value == "f") return PITCHNAME_f;
    if (value == "g") return PITCHNAME_g;
    if (value == "a") return PITCHNAME_a;
    if (value == "b") return PITCHNAME_b;
    LogWarning("Unsupported pitch name '%s'", value.c_str());
    return PITCHNAME_NONE;
}
示例#25
0
void DifficultyMenu::EventOccurred(Event *e)
{
	difficultymenuform->EventOccured(e);
	fw().gamecore->MouseCursor->EventOccured(e);

	if (e->Type() == EVENT_KEY_DOWN)
	{
		if (e->Keyboard().KeyCode == SDLK_ESCAPE)
		{
			stageCmd.cmd = StageCmd::Command::POP;
			return;
		}
	}

	if (e->Type() == EVENT_FORM_INTERACTION && e->Forms().EventFlag == FormEventType::ButtonClick)
	{
		UString initialStatePath;
		if (e->Forms().RaisedBy->Name.compare("BUTTON_DIFFICULTY1") == 0)
		{
			initialStatePath = "data/difficulty1_patched";
		}
		else if (e->Forms().RaisedBy->Name.compare("BUTTON_DIFFICULTY2") == 0)
		{
			initialStatePath = "data/difficulty2_patched";
		}
		else if (e->Forms().RaisedBy->Name.compare("BUTTON_DIFFICULTY3") == 0)
		{
			initialStatePath = "data/difficulty3_patched";
		}
		else if (e->Forms().RaisedBy->Name.compare("BUTTON_DIFFICULTY4") == 0)
		{
			initialStatePath = "data/difficulty4_patched";
		}
		else if (e->Forms().RaisedBy->Name.compare("BUTTON_DIFFICULTY5") == 0)
		{
			initialStatePath = "data/difficulty5_patched";
		}
		else
		{
			LogWarning("Unknown button pressed: %s", e->Forms().RaisedBy->Name.c_str());
			return;
		}

		auto state = mksp<GameState>();
		state->loadGame(initialStatePath);
		state->startGame();
		state->initState();

		stageCmd.cmd = StageCmd::Command::REPLACE;
		stageCmd.nextStage = mksp<CityView>(state, StateRef<City>{state.get(), "CITYMAP_HUMAN"});
		return;
	}
}
示例#26
0
    int CWorldDbmgr::UpdateArrayItemsToDb(T_VECTOR_OBJECT* p, CDbOper& db)
    {
        if( p->size() != 5 )
        {
            return -1;
        }
        const string & itemName = VOBJECT_GET_SSTR((*p)[0]);
        const TDBID dbid = VOBJECT_GET_U64((*p)[1]);
        const uint16_t nBaseappId = VOBJECT_GET_U16((*p)[2]);
        const int32_t ref = VOBJECT_GET_I32((*p)[3]);
        const string& itemsData = VOBJECT_GET_SSTR((*p)[4]);
        //uint32_t l = itemsData.size();

        //LogError("UpdateArrayItemsToDb", "[itemName = %s] [dbid = %d] [nBaseappId = %d] [ref = %d] [itemsData = %d]", 
        //        itemName.c_str(), dbid, nBaseappId, ref, itemsData.size());
        //cout<<itemsData.c_str()<<endl;
        //cout<<itemsData.size()<<endl;
        CPluto* u = new CPluto();
        u->FillBuff(itemsData.c_str(), itemsData.size());
        u->SetMaxLen(u->GetLen());
        string strErr;
        
        //cout<<"world update"<<endl;
        if( !db.UpdateArrayToDb(itemName, dbid, *u, nBaseappId, ref, strErr) )
        {
            LogError("UpdateArrayToDb failure", "[error = %s] [status = %d]", strErr.c_str(), -1);
            CPluto* u1 = new CPluto;
            u1->Encode(MSGID_BASEAPP_UPDATE_ITEMS_CALLBACK);
            *u1 << ref << (uint16_t)1 << strErr<< EndPluto;
            CMailBox* mb = GetServerMailbox(nBaseappId);
            if(mb)
            {
                //cout<<"send pluto"<<endl;
                u1->SetMailbox(mb);

                //LogDebug("CWorldDbmgr::UpdateArrayItemsToDb", "u1.GenLen()=%d", u1->GetLen());

                g_pluto_sendlist.PushPluto(u1);
            }
            else
            {
                delete u1;
                LogWarning("CWorldDbmgr::UpdateArrayItemsToDb", "");
            }
        }

        delete u;

        //cout<<"do success update"<<endl;
        return 0;

    }
示例#27
0
std::string Att::TempusToStr(data_TEMPUS data) const
{
    std::string value;
    switch (data) {
        case TEMPUS_2: value = "2"; break;
        case TEMPUS_3: value = "3"; break;
        default:
            LogWarning("Unknown tempus '%d'", data);
            value = "";
            break;
    }
    return value;
}
示例#28
0
std::string Att::StemdirectionToStr(data_STEMDIRECTION data) const
{
    std::string value;
    switch (data) {
        case STEMDIRECTION_up: value = "up"; break;
        case STEMDIRECTION_down: value = "down"; break;
        default:
            LogWarning("Unknown stem direction '%d'", data);
            value = "";
            break;
    }
    return value;
}
示例#29
0
std::string Att::ProlatioToStr(data_PROLATIO data) const
{
    std::string value;
    switch (data) {
        case PROLATIO_2: value = "2"; break;
        case PROLATIO_3: value = "3"; break;
        default:
            LogWarning("Unknown prolatio '%d'", data);
            value = "";
            break;
    }
    return value;
}
示例#30
0
std::string Att::ModusminorToStr(data_MODUSMINOR data) const
{
    std::string value;
    switch (data) {
        case MODUSMINOR_2: value = "2"; break;
        case MODUSMINOR_3: value = "3"; break;
        default:
            LogWarning("Unknown modusmaior '%d'", data);
            value = "";
            break;
    }
    return value;
}