Ejemplo n.º 1
0
void nepa_destroy(struct nepa * epa)
{
    NREQUIRE(N_IS_EPA_OBJECT(epa));
    
    nthread_term(&epa->thread);
    nsm_free(epa->sm);
    NOBLIGATION(NSIGNATURE_IS(epa, ~NSIGNATURE_EPA));
    
    while (!nqueue_is_empty(epa->queue)) {
        nevent_destroy(nqueue_get(epa->queue));
    }
    nqueue_free(epa->queue);
    nmem_free(epa->mem, epa);
}
Ejemplo n.º 2
0
void start_program(int argc, char **argv){

  QApplication app(argc, argv);

  {


    // nsm
    {
      const char *nsm_url = getenv( "NSM_URL" );
      if ( nsm_url )                                        
        {                                                     
          g_nsm = nsm_new();                                  
          
          printf("NSM: %p\n",g_nsm);

          nsm_set_open_callback( g_nsm, rc_nsm_open, 0 );     
          nsm_set_save_callback( g_nsm, rc_nsm_save, 0 );     
          
          if ( 0 == nsm_init( g_nsm, nsm_url ) )              
            {                                                
              signal(SIGTERM, rc_nsm_signalHanlder);
              nsm_send_announce( g_nsm, "Radium Compressor", "", argv[0] ); 
              g_nsm_timer.setInterval(50);
              g_nsm_timer.start();
              
            }                                                 
          else                                              
            {                                                 
              nsm_free( g_nsm );                              
              g_nsm = 0;                                      
            }                                                 
        }                                                     
    }

    if(g_nsm == NULL){
      if (g_compressor == NULL)
        g_compressor = COMPRESSOR_create(0);
      g_compressor_editor = create_compressor_editor(NULL, g_compressor);
      g_compressor_editor->show();
    }

    app.exec();

    if(g_compressor_editor != NULL)
      delete_compressor_editor(g_compressor_editor);
  }
}
Ejemplo n.º 3
0
void NsmClient::createInitialClient()
{
	/*
	 * Make first contact with NSM server.
	 */

	nsm_client_t* nsm = 0;

	H2Core::Preferences *pPref = H2Core::Preferences::get_instance();
	QString H2ProcessName = pPref->getH2ProcessName();
	QByteArray byteArray = H2ProcessName.toLatin1();

	const char *nsm_url = getenv( "NSM_URL" );

	if ( nsm_url )
	{
		nsm = nsm_new();

		if ( nsm )
		{
			nsm_set_open_callback( nsm, nsm_open_cb, (void*) 0 );
			nsm_set_save_callback( nsm, nsm_save_cb, (void*) 0 );

			if ( nsm_init( nsm, nsm_url ) == 0 )
			{
				nsm_send_announce( nsm, "Hydrogen", "", byteArray.data() );
				nsm_check_wait( nsm, 10000 );

				if(pthread_create(&m_NsmThread, NULL, nsm_processEvent, nsm)) {
					___ERRORLOG("Error creating NSM thread\n	");
					return;
				}

			}
			else
			{
				___ERRORLOG("failed, freeing NSM client");
				nsm_free( nsm );
				nsm = 0;
			}
		}
	}
	else
	{
		___WARNINGLOG("No NSM URL available: no NSM management\n");
	}
}