Exemple #1
0
/* This detects changes in the title, and also draws the title when appropriate.
 * It should be called once for each frame.
 */
static guchar *show_info(guchar *img, gint height, gint bpl)
{
	gint pos, length;
	gchar *title;
	time_t now;
	static int prevpos;
	static gchar *prevtitle;
	static char buf[200];
	static time_t start, then;
	static gboolean persistent = FALSE;
	char	showinfo;

	/* Once per second, check for any changes in the title.  Note that we
	 * do this even for the "Never show title" setting, because a change
	 * in the title should trigger "quiet" actions even if the title isn't
	 * shown.
	 */
	time(&now);
	if (now != then)
	{
		then = now;
		pos = cf_position;
		title = (gchar*)cf_title.c_str();
/*		pos = xmms_remote_get_playlist_pos(0);
		title = xmms_remote_get_playlist_title(0, pos);*/
		if (!title) {
			title = "Unknown";
		}
		
		
		if (pos != prevpos || !prevtitle || strcmp(title, prevtitle))
		{
			
			/* Yes, it changed.  Regenerate the info string */
			prevpos = pos;
			if (prevtitle)
				free(prevtitle);
			prevtitle = strdup(title);
			
			sprintf(buf, "{%d} %s", pos + 1, title);
			
			start = now;

			/* Trigger "quiet" acctions. */
			beatquiet = TRUE;
		}
	}

	/* If the user pressed 'i' recently, then show info for 4 seconds */
	showinfo = *config.show_info;
	if (blurskinfo || persistent)
	{
		if (showinfo == 'A')
		{
			config.show_info = config_default_show_info;
			showinfo = 'N';
		}
		else
		{
			showinfo = '4';
			if (blurskinfo)
			{
				start = now;
				persistent = TRUE;
			}
		}
		blurskinfo = FALSE;
	}

	/* If not supposed to show text, then we're done */
	switch (showinfo)
	{
	  case 'N': /* Never show info */
		return img;

	  case '4': /* 4 second info */
		if (now - start > 4)
		{
			persistent = FALSE;
			return img;
		}

	  case 'A': /* Always show info */
		break;
	}

	/* We don't want to draw onto the main image, because then the text
	 * would leave blur trails.  Most combinations of cpu_speed and
	 * overall_effect copy the image data into a temporary buffer, but
	 * the specific combination of cpu_speed=Fast and overall_effect=Normal
	 * (which is very common!) normally leaves the image in the main buffer.
	 * We need to detect this, and copy the image before we draw the text.
	 */
	if (img != img_tmp)
	{
		memcpy(img_tmp, img, img_chunks * 8);
		img = img_tmp;
	}
	
	/* draw the text */
	textdraw(img, height, bpl, "Center", buf);
	return img;
}
Exemple #2
0
status_t MboxImporter::AddMessage( os::String &cMessage )
{
	if( cMessage != "" )
	{
		if( m_bDoCrLf )
		{
			/* Convert linefeeds to CRLF pairs */
			const char *pStart, *pEnd;
			int nLf = 0;

			pStart = cMessage.c_str();
			while( ( pEnd = strchr( pStart, '\n' ) ) != NULL )
			{
				nLf++;
				pStart = pEnd + 1;
			}

			char *pMessage = (char*)calloc( 1, cMessage.size() + nLf + 1 );
			if( NULL == pMessage )
				return ENOMEM;

			const char *pIn;
			char *pOut;

			pIn = cMessage.c_str();
			pOut = pMessage;

			while( '\0' != *pIn )
			{
				if( '\n' == *pIn )
					*pOut++ = '\r';
				*pOut++ = *pIn++;
			}
			cMessage = pMessage;
			free( pMessage );
		}

		/* Add an RFC2822 terminating sequence */
		cMessage += "\r\n.\r\n";

		/* Create a Mailmessage and send it back down to the application along with the relevent data */
		Mailmessage *pcImport = new Mailmessage( cMessage.c_str(), cMessage.size() );

		Message *pcImportMessage = new Message( M_IMPORT_NEW );
		pcImportMessage->AddPointer( "message", pcImport );
		pcImportMessage->AddString( "folder", m_cFolder );

		m_pcMessenger->SendMessage( pcImportMessage );

		/* Update the progress dialog & check if the user canceled */
		float vProgress = ( (double)m_nBytes / (double)m_nSize );

		char zMessage[64] = { '\0' };
		snprintf( zMessage, 64, "Importing message #%Ld", m_nCount++ );

		m_pcDialog->Lock();
		m_pcDialog->SetMessage( zMessage );
		m_pcDialog->SetProgress( vProgress );
		m_bRun = !m_pcDialog->IsCancelled();
		m_pcDialog->Unlock();
	}

	cMessage = "";
	return EOK;
}
Exemple #3
0
/* Unregister an event */
void SrvEvents::UnregisterEvent( os::String zID, int64 nProcess, int64 nTargetPort )
{
	/* Find parent node */
	m_cLock.Lock();
	
	SrvEventNode_s* psParent;
	os::String zEventName;
	
	psParent = GetParentNode( zID, zEventName );
	if( psParent == NULL )
	{
		dbprintf( "SrvEvents::UnregisterCall(): Call %s by %i not present\n", zID.c_str(), (int)nProcess );	
		m_cLock.Unlock();
		return;
	}
	
	/* Find node */
	SrvEventNode_s* psNode = GetNode( psParent, zEventName );
	if( psNode == NULL )
	{
		dbprintf( "SrvEvents::UnregisterCall(): Call %s by %i not present\n", zID.c_str(), (int)nProcess );	
		m_cLock.Unlock();
		return;
	}
	
	/* Find event */
	psNode->AddRef();
	std::vector<SrvEvent_s*>::iterator i = psNode->m_cEvents.begin();
	while( i != psNode->m_cEvents.end() )
	{
		SrvEvent_s* psEvent = (*i);
		if( psEvent->m_nProcess == nProcess
			&& ( nTargetPort == -1 || ( psEvent->m_nTargetPort == nTargetPort ) ) )
		{
			/* Send notifications to the monitors */
			os::Message cReply;
			cReply.AddBool( "event_unregistered", true );
			cReply.AddString( "id", zID );
			cReply.AddInt64( "target", psEvent->m_nTargetPort );
			cReply.AddInt64( "token", psEvent->m_nHandlerToken );
			cReply.AddInt64( "message_code", psEvent->m_nMessageCode );
			cReply.AddInt64( "process", psEvent->m_nProcess );
			
			psParent = psNode;
			while( psParent != NULL )
			{
				std::vector<SrvEventMonitor_s*>::iterator j = psParent->m_cMonitors.begin();
				for( ; j != psParent->m_cMonitors.end(); j++ )
				{
					cReply.SetCode( (*j)->m_nMessageCode );
					os::Messenger cLink( (*j)->m_nTargetPort, (*j)->m_nHandlerToken, -1 );
					
					cLink.SendMessage( &cReply );
					
					//dbprintf( "Notification %s about unregistration sent to %i\n", zID.c_str(), (int)(*j)->m_nTargetPort );
				}
				psParent = psParent->m_psParent;	
			}
			
			i = psNode->m_cEvents.erase( i );
			delete( psEvent );
			psNode->Release();			
			//dbprintf( "Event %s unregistered by %i\n", zID.c_str(), (int)nProcess );
		} else
			i++;
	}
	/* Release the node */
	psNode->Release();
			
	m_cLock.Unlock();
	
	//dbprintf( "SrvEvents::UnregisterCall(): Call %s by %i unregistered\n", zID.c_str(), (int)nProcess );	
}