Exemple #1
0
/* Constructor */
CoinMessage::CoinMessage(Language language) :
  CoinMessages(sizeof(us_english)/sizeof(Coin_message))
{
  language_=language;
  strcpy(source_,"Coin");
  class_= 2; // Coin
  Coin_message * message = us_english;

  while (message->internalNumber!=COIN_DUMMY_END) {
    CoinOneMessage oneMessage(message->externalNumber,message->detail,
		message->message);
    addMessage(message->internalNumber,oneMessage);
    message ++;
  }
  // Put into compact form
  toCompact();
  // now override any language ones

  switch (language) {
  case it:
    message = italian;
    break;

  default:
    message=NULL;
    break;
  }

  // replace if any found
  if (message) {
    while (message->internalNumber!=COIN_DUMMY_END) {
      replaceMessage(message->internalNumber,message->message);
      message ++;
    }
  }
}
Exemple #2
0
/**
 * used only for testing
 */
void addMessages(){
	Message m ;
	for (int i=0;i<2;i++){

		for (int j=0;j<i;j++){
			m.content[j]=(char)(j+40);
		}
		m.numberFromTo[0]=(char)('0'+i/10);
		m.numberFromTo[1]=(char)('0'+i%10);
		for (int k=0;k<6;k++){
			m.numberFromTo[k+2]=(char)(48+k);
		}
		if(i%2==0){
			m.inOrOut=IN;
			for(int k=0;k<TIME_STAMP_DIGITS;k++){
				m.timeStamp[k]='5';
			}
		}
		else m.inOrOut=OUT;
		m.size=(i*15+i)%MESSAGE_SIZE;
		memcpy(&m.content[0],&mess[0],m.size);
		addMessage(&m);
	}
}
Exemple #3
0
TEST_F(LearningUtilsTest, Spread64Ticker) {
    // A Spread64 ticker (select knob, jog wheel, etc.) shows up as a MIDI_CC
    // message, single channel, single control and a variety of values centered
    // around 0x40 but never including that value (since 0x40 means "not moving")
    addMessage(MIDI_CC | 0x01, 0x10, 0x41);
    addMessage(MIDI_CC | 0x01, 0x10, 0x41);
    addMessage(MIDI_CC | 0x01, 0x10, 0x42);
    addMessage(MIDI_CC | 0x01, 0x10, 0x41);
    addMessage(MIDI_CC | 0x01, 0x10, 0x3F);
    addMessage(MIDI_CC | 0x01, 0x10, 0x3F);
    addMessage(MIDI_CC | 0x01, 0x10, 0x3F);

    ConfigKey control("[Test]", "SomeControl");
    MidiInputMappings mappings =
            LearningUtils::guessMidiInputMappings(control, m_messages);

    ASSERT_EQ(1, mappings.size());
    MidiOptions options;
    options.spread64 = true;
    EXPECT_EQ(MidiInputMapping(MidiKey(MIDI_CC | 0x01, 0x10),
                               options, control),
              mappings.at(0));
}
//--------------------------------------------------------------
void OscMaster::update(vector<BlobMaster::soundBlob> blobs, vector<BlobMaster::soundEvent> events) {

	addMessage(-1, "volume", volume);

	for(unsigned int i = 0; i < events.size(); i++) {
		addMessage(events[i].voice, "spawn", events[i].type); 
	}

	if(synthType != lastSynth) {
		lastSynth = synthType;
		addMessage(-1, "synthType", synthType);
	}


	switch(synthType) {
		case 0 :
			fmSynth(blobs, events);
			addMessage(-1, "fmSynth", 1);
			addMessage(-1, "bbSynth", 0);
			break;
		case 1 :
			bbSynth(blobs, events);
			steps = 8;
			addMessage(-1, "bbSynth", 1);
			addMessage(-1, "fmSynth", 0);
			break;

	}


	//flush messages
	for(unsigned int i = 0; i < oscQueue.size(); i++) {
		oscOut.sendMessage(oscQueue[i]);
	}
	oscQueue.clear();

}
Exemple #5
0
void Console::dir(ScriptCallStack* callStack)
{
    addMessage(ObjectMessageType, LogMessageLevel, callStack);
}
Exemple #6
0
void Console::error(ScriptCallStack* callStack)
{
    addMessage(LogMessageType, ErrorMessageLevel, callStack);
}
Exemple #7
0
/**
 * adds searchresults to the playlist
 * range - title-display/artist/album
 * arg - either a title key or a string
 * insert - play next or append to the end of the playlist
 */
int playResults( mpcmd range, const char *arg, const int insert ) {
	mpconfig   *config=getConfig();
	mpplaylist *pos=config->current;
	mpplaylist *end=NULL;
	mpplaylist *res=config->found->titles;
	mptitle *title=NULL;
	int key=atoi(arg);

	/* insert results at current pos or at the end? */
	if( (pos != NULL ) && ( insert == 0 ) ) {
		while( pos->next != NULL ) {
			pos=pos->next;
		}
	}

	if( ( range == mpc_title ) || ( range == mpc_display ) ) {
		/* Play the current resultlist */
		if( key == 0 ) {
			/* should not happen but better safe than sorry! */
			if( config->found->tnum == 0 ) {
				addMessage( 0, "No results to be added!" );
				return 0;
			}
			if( config->found->titles == NULL ) {
				addMessage( 0, "%i titles found but none in list!", config->found->tnum );
				return 0;
			}

			end=res;
			/* find end of searchresults and mark titles as counted on the way */
			end->title->flags|=MP_CNTD;
			while( end->next != NULL ) {
				end=end->next;
				end->title->flags|=MP_CNTD;
			}

			while( res!=NULL ) {
				res->title->flags|=MP_CNTD;
				pos=addToPL( res->title, pos, 0 );
				if( config->current == NULL ) {
					config->current=pos;
				}
				res=res->next;
			}

			notifyChange();
			return config->found->tnum;
		}

		/* play only one */
		title=getTitleByIndex(key);
		if( title == NULL ) {
			addMessage( 0, "No title with key %i!", key );
			return 0;
		}
		/*
		 * do not count this title as played and do not mark it skipped during this play
		 * this will be reverted after play if needed.
		 */
		title->flags|=MP_CNTD;
		/*
		 * Do not touch marking, we searched the title so it's playing out of order.
		 * It has been played before? Don't care, we want it now and it won't come back!
		 * It's not been played before? Then play it now and whenever it's time comes.
		 */
		pos=addToPL( title, pos, 0 );
		if( config->current == NULL ) {
			config->current=pos;
		}

		notifyChange();
		return 1;
	}

	addMessage( 0, "Range not supported!" );
	return 0;
}
Exemple #8
0
/**
 * checks the current playlist.
 * If there are more than 10 previous titles, those get pruned.
 * While there are less that 10 next titles, titles will be added.
 *
 * todo: make this also work on other playlists
 */
void plCheck( int del ) {
	int cnt=0;
	mpplaylist *pl=getConfig()->current;
	mpplaylist *buf=pl;

	if( getConfig()->pledit ||
		( getConfig()->plplay && !getConfig()->plmix ) ){
		return;
	}

	if( pl != NULL ) {
		/* truncate stream title history to 20 titles */
		if( getConfig()->playstream ) {
			while( ( pl->next != NULL ) && ( cnt < 20 ) ) {
				pl=pl->next;
				cnt++;
			}

			buf=pl->next;
			pl->next=NULL;
			while( buf != NULL ) {
				pl=buf->next;
				free( buf->title );
				free( buf );
				buf=pl;
			}
			return;
		}

		/* truncate playlist title history to 10 titles */
		while( ( pl->prev != NULL ) && ( cnt < 10 ) ) {
			pl=pl->prev;
			cnt++;
		}

		buf=pl->prev;
		pl->prev=NULL;

		while( buf != NULL ) {
			pl=buf->prev;
			/* unmark title as it leaves the playlist */
			buf->title->flags&=~MP_MARK;
			free( buf );
			buf=pl;
		}

		cnt=0;
		pl=getConfig()->current;
		/* this should always be != NULL */
		if( pl == NULL ) {
			addMessage( 0, "There should not be no playlist!" );
		}
		else {
			/* go to the end of the playlist */
			while( pl->next != NULL ) {
				/* clean up on the way to remove DNP marked or deleted files? */
				if( del != 0 ) {
					if ( ( pl->title->flags | MP_DNP ) || ( !mp3Exists( pl->title ) ) ){
						buf=pl->next;
						if( pl->prev != NULL ) {
							pl->prev->next=pl->next;
						}
						pl->next->prev=pl->prev;
						free(pl);
						pl=buf;
						cnt--;
					}
				}
				else {
					pl=pl->next;
				}
				cnt++;
			}
		}
	}

	/* fill up the playlist with new titles */
	while( cnt < 10 ) {
		if( getConfig()->current == NULL ) {
			getConfig()->current=addNewTitle( NULL, getConfig()->root );
		}
		else {
			addNewTitle( getConfig()->current, getConfig()->root );
		}
		cnt++;
	}
}
Exemple #9
0
void Console::dirxml(ScriptCallStack* callStack)
{
    addMessage(NodeMessageLevel, callStack);
}
Exemple #10
0
void ScriptExecutionContext::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, JSC::ExecState* state, unsigned long requestIdentifier)
{
    addMessage(source, level, message, sourceURL, lineNumber, columnNumber, 0, state, requestIdentifier);
}
void IPLProcess::addSuccess(std::string msg)
{
    addMessage(IPLProcessMessage(msg, IPLProcessMessage::SUCCESS));
}
void IPLProcess::addWarning(std::string msg)
{
    addMessage(IPLProcessMessage(msg, IPLProcessMessage::WARNING));
}
void IPLProcess::addError(std::string msg)
{
    addMessage(IPLProcessMessage(msg, IPLProcessMessage::ERR));
}
LogMonitorFileModel::LogMonitorFileModel(const QString &dbPath, QObject *parent)
    :AbstractLogModel(parent)
{
    m_statistics.error = 0;
    m_statistics.warning = 0;
    m_statistics.notice = 0;
    m_statistics.info = 0;
    m_statistics.clients = 0;

    QFile f(dbPath);
    if (!f.exists())
    {
        QMessageBox msg;
        msg.setIcon(QMessageBox::Warning);
        msg.setText("File not found");
        msg.setInformativeText(QString("Could not find file %1").arg(dbPath));
        msg.exec();
        return;
    }

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(dbPath);
    auto success = db.open();
    if (!success)
    {
        auto e = db.lastError();

        QMessageBox msg;
        msg.setIcon(QMessageBox::Warning);
        msg.setText("Open failed");
        msg.setInformativeText(QString("Failed to open the file %1.\nError message: %2").arg(dbPath, e.text()));
        msg.exec();
        return;
    }
    QSqlQuery query("SELECT m.time, m.pid, m.level, h.name, c.facility, c.object, m.message, p.process"
                    " FROM messages AS m INNER JOIN hosts AS h ON m.host=h.id INNER JOIN channels AS c ON m.channel=c.id INNER JOIN processes AS p ON m.pid=p.id",
                    db);
    query.setForwardOnly(true);
    success = query.exec();
    if (!success)
    {
        auto e = db.lastError();

        QMessageBox msg;
        msg.setIcon(QMessageBox::Warning);
        msg.setText("Open failed");
        msg.setInformativeText(QString("Failed to open the file %1.\nError message: %2").arg(dbPath, e.text()));
        msg.exec();
        return;
    }
    while (query.next())
    {
        auto message = new LogMessage;
        message->timestamp.setMSecsSinceEpoch(qint64(query.value(0).toDouble() * 1000));
        message->pid = query.value(1).toULongLong();
        message->severity = LogSeverity(query.value(2).toInt());
        message->machineName = query.value(3).toString();
        message->module = query.value(4).toString();
        message->channel = query.value(5).toString();
        message->message = query.value(6).toString();
        message->executablePath = query.value(7).toString();
        switch (message->severity)
        {
        case SEVERITY_ERR:
            m_statistics.error++;
            break;
        case SEVERITY_WARN:
            m_statistics.warning++;
            break;
        case SEVERITY_NOTICE:
            m_statistics.notice++;
            break;
        case SEVERITY_INFO:
            m_statistics.info++;
            break;
        default:
            break;
        }
        addMessage(message);
    }
    if (m_messages.size())
    {
        beginInsertRows(QModelIndex(), 0, m_messages.size() - 1);
        endInsertRows();
    }
    db.close();
}
Exemple #15
0
/* process the results of a completed research topic */
void researchResult(UDWORD researchIndex, UBYTE player, bool bDisplay, STRUCTURE *psResearchFacility, bool bTrigger)
{
	RESEARCH                                       *pResearch = &asResearch[researchIndex];
	MESSAGE						*pMessage;
	//the message gets sent to console
	char						consoleMsg[MAX_RESEARCH_MSG_SIZE];

	ASSERT_OR_RETURN(, researchIndex < asResearch.size(), "Invalid research index %u", researchIndex);

	syncDebug("researchResult(%u, %u, …)", researchIndex, player);

	MakeResearchCompleted(&asPlayerResList[player][researchIndex]);

	//check for structures to be made available
	for (unsigned short pStructureResult : pResearch->pStructureResults)
	{
		if (apStructTypeLists[player][pStructureResult] != REDUNDANT)
		{
			apStructTypeLists[player][pStructureResult] = AVAILABLE;
		}
	}

	//check for structures to be made redundant
	for (unsigned short pRedStruct : pResearch->pRedStructs)
	{
		apStructTypeLists[player][pRedStruct] = REDUNDANT;
	}

	//check for component replacement
	if (!pResearch->componentReplacement.empty())
	{
		for (auto &ri : pResearch->componentReplacement)
		{
			COMPONENT_STATS *pOldComp = ri.pOldComponent;
			replaceComponent(ri.pNewComponent, pOldComp, player);
			apCompLists[player][pOldComp->compType][pOldComp->index] = REDUNDANT;
		}
	}

	//check for artefacts to be made available
	for (auto &componentResult : pResearch->componentResults)
	{
		//determine the type of artefact
		COMPONENT_TYPE type = componentResult->compType;
		//set the component state to AVAILABLE
		int compInc = componentResult->index;
		if (apCompLists[player][type][compInc] != REDUNDANT)
		{
			apCompLists[player][type][compInc] = AVAILABLE;
		}
		//check for default sensor
		if (type == COMP_SENSOR && (asSensorStats + compInc)->location == LOC_DEFAULT)
		{
			aDefaultSensor[player] = compInc;
		}
		//check for default ECM
		else if (type == COMP_ECM && (asECMStats + compInc)->location == LOC_DEFAULT)
		{
			aDefaultECM[player] = compInc;
		}
		//check for default Repair
		else if (type == COMP_REPAIRUNIT && (asRepairStats + compInc)->location == LOC_DEFAULT)
		{
			aDefaultRepair[player] = compInc;
			enableSelfRepair(player);
		}
	}

	//check for artefacts to be made redundant
	for (auto &pRedArtefact : pResearch->pRedArtefacts)
	{
		COMPONENT_TYPE type = pRedArtefact->compType;
		apCompLists[player][type][pRedArtefact->index] = REDUNDANT;
	}

	//Add message to player's list if Major Topic
	if ((pResearch->techCode == TC_MAJOR) && bDisplay)
	{
		//only play sound if major topic
		if (player == selectedPlayer)
		{
			audio_QueueTrack(ID_SOUND_MAJOR_RESEARCH);
		}

		//check there is viewdata for the research topic - just don't add message if not!
		if (pResearch->pViewData != nullptr)
		{
			pMessage = addMessage(MSG_RESEARCH, false, player);
			if (pMessage != nullptr)
			{
				pMessage->pViewData = pResearch->pViewData;
				jsDebugMessageUpdate();
			}
		}
	}
	else if (player == selectedPlayer && bDisplay)
	{
		audio_QueueTrack(ID_SOUND_RESEARCH_COMPLETED);
	}

	if (player == selectedPlayer && bDisplay)
	{
		//add console text message
		if (pResearch->pViewData != nullptr)
		{
			snprintf(consoleMsg, MAX_RESEARCH_MSG_SIZE, _("Research completed: %s"), _(pResearch->pViewData->textMsg[0].toUtf8().c_str()));
			addConsoleMessage(consoleMsg, LEFT_JUSTIFY, SYSTEM_MESSAGE);
		}
		else
		{
			addConsoleMessage(_("Research Completed"), LEFT_JUSTIFY, SYSTEM_MESSAGE);
		}
	}

	if (psResearchFacility)
	{
		psResearchFacility->pFunctionality->researchFacility.psSubject = nullptr;		// Make sure topic is cleared
	}
	if ((bMultiPlayer || player == selectedPlayer) && bTrigger)
	{
		psCBLastResearch = pResearch;  // Fun with pointers. Throw them into some random global variable, and get Nexus to absorb them.
		CBResFacilityOwner = player;
		psCBLastResStructure = psResearchFacility;
		eventFireCallbackTrigger((TRIGGER_TYPE)CALL_RESEARCHCOMPLETED);
		psCBLastResStructure = nullptr;
		CBResFacilityOwner = -1;
		psCBLastResearch = nullptr;
	}
	triggerEventResearched(pResearch, psResearchFacility, player);
}
Exemple #16
0
void Console::clear(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    addMessage(ClearMessageType, LogMessageLevel, state, arguments, true);
}
Exemple #17
0
void Console::trace(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    addMessage(TraceMessageType, LogMessageLevel, state, arguments, true, shouldPrintExceptions());
}
void IPLProcess::addInformation(std::string msg)
{
    addMessage(IPLProcessMessage(msg, IPLProcessMessage::INFORMATION));
}
Exemple #19
0
// slave operations
void i2cSlaveReceiveService(uint8_t receiveDataLength, uint8_t* receiveData)
{
	uint8_t i;
	// this function will run when a master somewhere else on the bus
	// addresses us and wishes to write data to us
	
	cbi(PORTB, PB6);

	// copy the received data to a local buffer
	for(i=0; i<receiveDataLength; i++)
		localBuffer[i] = *receiveData++;

	add_message_cmd *am;
	add_image_cmd *ai;
	pong_cmd *p;

	switch (localBuffer[0]) {
	case FRAME_CMD:
		frame = ((frame_cmd*) localBuffer)->frame;
		updateOffsets();
		draw();
		break;
	case SHOW_CMD:
		exclusivelyShow(((id_cmd*) localBuffer)->id);
		updateOffsets();
		draw();
		break;
	case ADD_MESSAGE_CMD:
		am = (add_message_cmd*) localBuffer;
		addMessage(am->id, am->message, am->rStart, am->rStep, am->rStop, am->cStart, am->cStep, am->cStop, am->loop); 
		updateOffsets();
		draw();
		break;
	case DELETE_CMD:
		removeDisplayable(((id_cmd*) localBuffer)->id);
		updateOffsets();
		draw();
		break;
	case ENABLE_CMD:
		changeVisibility(((id_cmd*) localBuffer)->id, true);
		updateOffsets();
		draw();
		break;
	case DISABLE_CMD:
		changeVisibility(((id_cmd*) localBuffer)->id, false);
		updateOffsets();
		draw();
		break;
	case ADD_IMAGE_CMD:
		ai = (add_image_cmd*) localBuffer;
		// only process valid pattern image ids
		if (ai->imageID >= TOTALPATTERNS || ai->imageID < 0) break; 
		addImage(ai->id, patternList[ai->imageID], ai->rStart, ai->rStep, ai->rStop, ai->cStart, ai->cStep, ai->cStop, ai->loop);
		updateOffsets();
		draw();
		break;
	case PONG_CMD:
		p = (pong_cmd*) localBuffer;
		drawPong(p->paddle1_y, p->paddle2_y, p->ball_x, p->ball_y);
		break;
	case TEST_CMD:
		test();
		break;
	default:
		PORTB = 0x00;
		PORTD = 0x00;
		PORTA = 0x00;
		break;
	}

	localBufferLength = receiveDataLength;
}
Exemple #20
0
void Remover::removePackageBegin(const Package *package)
{
	addMessage(Removing, QVariant::fromValue(package));
}
Exemple #21
0
/**
 * adds a new title to the current playlist
 *
 * Core functionality of the mixplay architecture:
 * - does not play the same artist twice in a row
 * - prefers titles with lower playcount
 *
 * returns the head of the (new/current) playlist
 */
mpplaylist *addNewTitle( mpplaylist *pl, mptitle *root ) {
	mptitle *runner=NULL;
	mptitle *guard=NULL;
	unsigned long num=0;
	char *lastpat;
	unsigned int pcount=getConfig()->playcount;
	unsigned int cycles=0;
	int valid=0;
	/* 0 - nothing checked
	   1 - namecheck okay
	   2 - playcount okay
	   3 - all okay
	  -1 - stuffing
	*/

	if( pl != NULL ) {
		while( pl->next != NULL ) {
			pl=pl->next;
		}
		runner=pl->title;
		lastpat=pl->title->artist ;
	}
	else {
		valid=1;
		runner=root;
	}

	/* select a random title from the database */
	/* skip forward until a title is found that is neither DNP nor MARK */
	num = countTitles( MP_ALL, MP_DNP|MP_MARK|MP_CNTD );
	runner=skipTitles( runner, rand()%num );

	if( runner==NULL ) {
		if( pl == NULL ) {
			addMessage( 0, "No titles in database and no playlist to add them to.." );
			return NULL;
		}
		runner=pl->title;
		addMessage( 0, "Next round!" );
		newCount( );
		/* Try again */
		num = countTitles( MP_ALL, MP_DNP|MP_MARK|MP_CNTD );
		runner=skipTitles( runner, rand()%num );
		if( runner == NULL ) {
			addMessage( 0, "No more titles in the database!?" );
			return NULL;
		}
	}

	cycles=0;

	while( ( valid & 3 ) != 3 ) {
		if( lastpat == NULL ) valid |=1;
		/* title did not pass namecheck */
		if( ( valid & 1 ) != 1 ) {
			guard=runner;

			while( checkSim( runner->artist, lastpat ) ) {
				addMessage( 3, "%s = %s", runner->artist, lastpat );
				activity( "Nameskipping" );
				runner=skipOver( runner->next, 1 );

				/* hopefully this will not happen */
				if( (runner == guard ) || ( runner == NULL ) ) {
					addMessage( 0, "Only %s left..", lastpat );
					newCount( );
					return(	addNewTitle( pl, root ) );
				}
			}
			addMessage( 3, "%s != %s", runner->artist, lastpat );

			if( guard != runner ) {
				valid=1; /* we skipped and need to check playcount */
			}
			else {
				valid |= 1; /* we did not skip, so if playcount was fine it's still fine */
			}
		}

		guard=runner;
		/* title did not pass playcountcheck and we are not in stuffing mode */
		while( (valid & 2 ) != 2 ) {
			if( runner->flags & MP_FAV ) {
				if ( runner-> playcount <= 2*pcount ) {
					valid|=2;
				}
			}
			else {
				if ( runner->playcount <= pcount ) {
					valid|=2;
				}
			}

			if( ( valid & 2 ) != 2 ) {
				activity( "Playcountskipping" );
				/* simply pick a new title at random to avoid edge cases */
				runner=skipTitles( runner, rand()%num );
				valid=0;

				if( (runner == NULL ) || ( guard == runner ) ) {
					pcount++;	/* allow more replays */
					getConfig()->playcount=pcount;
					addMessage( 1, "Increasing maxplaycount to %li", pcount );
					runner=guard;
				}
			}
		}

		if( ++cycles > 10 ) {
			addMessage( 1, "Looks like we ran into a loop" );
			cycles=0;
			pcount++;	/* allow replays */
			getConfig()->playcount=pcount;
			addMessage( 1, "Increasing maxplaycount to %li", pcount );
		}
	} /* while( valid != 3 ) */

	addMessage( 3, "[+] (%i/%li/%3s) %s", runner->playcount, pcount, ONOFF( runner->flags&MP_FAV ), runner->display );

	/* count again in case this is a favourite */
	if( runner->flags & MP_FAV ) {
		runner->flags &= ~MP_CNTD;
	}
	addMessage(2,"Added %2d %5d - %s", runner->playcount, runner->key, runner->display );
	return appendToPL( runner, pl, -1 );
}
Exemple #22
0
void Remover::errorRemoving(const QString &msg)
{
	addMessage(RemoveError, msg);
}
Exemple #23
0
/**
 * does a database scan and dumps information about playrate
 * favourites and DNPs
 */
void dumpInfo( mptitle *root, unsigned int skip ) {
	mptitle *current=root;
	unsigned int maxplayed=0;
	unsigned int minplayed=-1; /* UINT_MAX; */
	unsigned int pl=0;
	unsigned int skipped=0;
	unsigned int dnp=0;
	unsigned int fav=0;

	do {
		if( current->flags & MP_FAV ) {
			fav++;
		}

		if( current->flags & MP_DNP ) {
			dnp++;
		}

		if( !( current->flags &MP_DNP ) ) {
			if( current->playcount < minplayed ) {
				minplayed=current->playcount;
			}

			if( current->playcount > maxplayed ) {
				maxplayed=current->playcount;
			}

			if( current->skipcount > skip ) {
				skipped++;
			}
		}

		current=current->next;
	}
	while( current != root );

	for( pl=minplayed; pl <= maxplayed; pl++ ) {
		unsigned int pcount=0;
		unsigned int dnpcnt=0;
		unsigned int favcnt=0;
		char line[MAXPATHLEN];

		do {
			if( !( current->flags & MP_DNP ) && ( current->playcount == pl ) ) {
				pcount++;
				if( current->flags & MP_DNP ) {
					dnpcnt++;
				}
				if( current->flags & MP_FAV ) {
					favcnt++;
				}
			}
			current=current->next;
		} while( current != root );

		if( dnpcnt != pcount ){
			switch( pl ) {
			case 0:
				sprintf( line, "Never played\t%i", pcount);
				break;
			case 1:
				sprintf( line, " Once played\t%i", pcount);
				break;
			case 2:
				sprintf( line, "Twice played\t%i", pcount);
				break;
			default:
				sprintf( line, "%5i times\t%i", pl, pcount);
			}

			if ( favcnt == 0 ) {
				addMessage( 0, "%s", line );
			}
			else {
				if( favcnt < pcount ) {
					addMessage( 0, "%s (%i favs)", line, favcnt );
				}
				else {
					addMessage( 0, "%s (allfavs)", line );
				}
			}
		}
	}

	addMessage( 0, "%4i\tfavourites", fav );
	addMessage( 0, "%4i\tdo not plays", dnp );
	addMessage( 0, "%4i\tskipped", skipped );
}
Exemple #24
0
void Console::addMessage(MessageSource source, MessageType type, MessageLevel level, const String& message, PassRefPtr<ScriptCallStack> callStack)
{
    addMessage(source, type, level, message, String(), 0, callStack, 0);
}
Exemple #25
0
/**
 * fills the global searchresult structure with the results of the given search.
 * Returns the number of found titles.
 * pat - pattern to search for
 * global - include DNP
 * fill - fill artist and album results
 */
int search( const char *pat, const mpcmd range, const int global ) {
	mptitle *root=getConfig()->root;
	mptitle *runner=root;
	searchresults *res=getConfig()->found;
	unsigned int i=0;
	int found=0;
	unsigned int cnt=0;
	/* free buffer playlist, the arrays will not get lost due to the realloc later */
	res->titles=wipePlaylist(res->titles);
	res->tnum=0;
	res->anum=0;
	res->lnum=0;

	do {
		activity("searching");
		found=0;
		if( global || !(runner->flags & MP_DNP) ) {
			/* check for searchrange and pattern */
			if( MPC_ISTITLE(range) &&
					isMatch( runner->title, pat, MPC_ISFUZZY(range) ) ) {
				found=1;
			}
			if( MPC_ISDISPLAY( range ) &&
					isMatch( runner->display, pat, MPC_ISFUZZY(range) ) ) {
				found=1;
			}
			if( MPC_ISARTIST(range) &&
					isMatch( runner->artist, pat, MPC_ISFUZZY(range) ) ) {
				found=1;
			}
			if( MPC_ISALBUM( range ) &&
					isMatch( runner->album, pat, MPC_ISFUZZY(range) ) ) {
				found=1;
			}
			/* todo: genre and path are missing here */
			if( found ) {
				/* check for new artist */
				for( i=0; (i<res->anum) && strcmp( res->artists[i], runner->artist ); i++ );
				if( i == res->anum ) {
					res->anum++;
					res->artists=(char**)frealloc( res->artists, res->anum*sizeof(char*) );
					res->artists[i]=runner->artist;
				}

				for( i=0; (i<res->lnum) && strcmp( res->albums[i], runner->album ); i++ );
				if( i == res->lnum ) {
					res->lnum++;
					res->albums=(char**)frealloc( res->albums, res->lnum*sizeof(char*) );
					res->albums[i]=runner->album;
					res->albart=(char**)frealloc( res->albart, res->lnum*sizeof(char*) );
					res->albart[i]=runner->artist;
				}
				else if( !strcmp( res->albart[i], ARTIST_SAMPLER ) &&
						strcmp( res->albart[i], runner->artist ) ){
					addMessage(1, "%s is considered a sampler (%s <> %s).", runner->album, runner->artist, res->albart[i] );
					res->albart[i]=ARTIST_SAMPLER;
				}
			}

			/* add titles too */
			if( ( found != 0 ) && ( cnt++ < MAXSEARCH ) ) {
				res->titles=appendToPL( runner, res->titles, 0 );
				res->tnum++;
			}
		}
		runner=runner->next;
	} while( runner != root );

	res->send=-1;

	return (cnt>MAXSEARCH)?-1:cnt;
}
Exemple #26
0
void Console::error(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    addMessage(LogMessageType, ErrorMessageLevel, state, arguments);
}
Exemple #27
0
void Console::log(ScriptCallStack* callStack)
{
    addMessage(LogMessageType, LogMessageLevel, callStack);
}
Exemple #28
0
void Console::warn(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    addMessage(LogMessageType, WarningMessageLevel, state, arguments);
}
Exemple #29
0
void Console::warn(ScriptCallStack* callStack)
{
    addMessage(LogMessageType, WarningMessageLevel, callStack);
}
Exemple #30
0
void Console::dirxml(ScriptState* state, PassRefPtr<ScriptArguments> arguments)
{
    addMessage(DirXMLMessageType, LogMessageLevel, state, arguments);
}