예제 #1
0
파일: upnp.cpp 프로젝트: Flameeyes/vlc
/**
 * Subscribes current client handle to Content Directory Service.
 * CDS exports the server shares to clients.
 */
void MediaServer::subscribeToContentDirectory()
{
    const char* psz_url = getContentDirectoryEventURL();
    if ( !psz_url )
    {
        msg_Dbg( _p_sd, "No subscription url set!" );
        return;
    }

    int i_timeout = 1810;
    Upnp_SID sid;

    int i_res = UpnpSubscribe( _p_sd->p_sys->client_handle, psz_url, &i_timeout, sid );

    if ( i_res == UPNP_E_SUCCESS )
    {
        _i_subscription_timeout = i_timeout;
        memcpy( _subscription_id, sid, sizeof( Upnp_SID ) );
    }
    else
    {
        msg_Dbg( _p_sd, "Subscribe failed: '%s': %s",
                getFriendlyName(), UpnpGetErrorMessage( i_res ) );
    }
}
예제 #2
0
void MediaServer::subscribeToContentDirectory()
{
    const char* url = getContentDirectoryEventURL();
    if ( !url || strcmp( url, "" ) == 0 )
    {
        msg_Dbg( _p_sd, "No subscription url set!" );
        return;
    }

    int timeOut = 1810;
    Upnp_SID sid;

    int res = UpnpSubscribe( _p_sd->p_sys->clientHandle, url, &timeOut, sid );

    if ( res == UPNP_E_SUCCESS )
    {
        _subscriptionTimeOut = timeOut;
        memcpy( _subscriptionID, sid, sizeof( Upnp_SID ) );
    }
    else
    {
        msg_Dbg( _p_sd,
                "%s:%d: WARNING: '%s': %s", __FILE__, __LINE__,
                getFriendlyName(), UpnpGetErrorMessage( res ) );
    }
}
예제 #3
0
void MediaServer::fetchContents()
{
    Container* root = new Container( 0, "0", getFriendlyName() );
    _fetchContents( root );

    _contents = root;
    _contents->setInputItem( _inputItem );

    _buildPlaylist( _contents );
}
예제 #4
0
string LevelDB::getStats() throw(DbException) {
	string ret;
	string value = "leveldb.stats";
	leveldb::Slice prop(value.c_str(), value.length());
	db->GetProperty(prop, &ret);

	ret = "\r\n-=[ Stats for " + getFriendlyName() + " ]=-\n\n" + ret;
	ret += "\r\n\r\nTotal entries: " + Util::toString(size(true, nullptr));
	ret += "\r\nTotal reads: " + Util::toString(totalReads);
	ret += "\r\nTotal Writes: " + Util::toString(totalWrites);
	ret += "\r\nI/O errors: " + Util::toString(ioErrors);
	ret += "\r\nCurrent block size: " + Util::formatBytes(defaultOptions.block_size);
	ret += "\r\nCurrent size on disk: " + Util::formatBytes(getSizeOnDisk());
	ret += "\r\n";
	return ret;
}
void
AudioPluginOSCGUIManager::startGUI(InstrumentId instrument, int position)
{
    RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: " << instrument << "," << position
             << endl;

    checkOSCThread();

    if (m_guis.find(instrument) != m_guis.end() &&
            m_guis[instrument].find(position) != m_guis[instrument].end()) {
        RG_DEBUG << "stopping GUI first";
        stopGUI(instrument, position);
    }

    // check the label
    PluginContainer *container = 0;
    container = m_studio->getContainerById(instrument);
    if (!container) {
        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no such instrument or buss as "
                 << instrument << endl;
        return;
    }

    AudioPluginInstance *pluginInstance = container->getPlugin(position);
    if (!pluginInstance) {
        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: no plugin at position "
                 << position << " for instrument " << instrument << endl;
        return ;
    }

    try {
        AudioPluginOSCGUI *gui =
            new AudioPluginOSCGUI(pluginInstance,
                                  getOSCUrl(instrument,
                                            position,
                                            strtoqstr(pluginInstance->getIdentifier())),
                                  getFriendlyName(instrument,
                                          position,
                                          strtoqstr(pluginInstance->getIdentifier())));
        m_guis[instrument][position] = gui;

    } catch (Exception e) {

        RG_DEBUG << "AudioPluginOSCGUIManager::startGUI: failed to start GUI: "
                 << e.getMessage() << endl;
    }
}
예제 #6
0
파일: upnp.cpp 프로젝트: Flameeyes/vlc
void MediaServer::fetchContents()
{
    /* Delete previous contents to prevent duplicate entries */
    if ( _p_contents )
    {
        delete _p_contents;
        services_discovery_RemoveItem( _p_sd, _p_input_item );
        services_discovery_AddItem( _p_sd, _p_input_item, NULL );
    }

    Container* root = new Container( 0, "0", getFriendlyName() );

    _fetchContents( root );

    _p_contents = root;
    _p_contents->setInputItem( _p_input_item );

    _buildPlaylist( _p_contents, NULL );
}
void UsbUiSettingModel::initializeModelData( int aModeId )
{
    myDebug() << ">>> UsbUiSettingModel::initializeModelData aModeId="
            << aModeId;
    RUsb usbMan;
    if ( usbMan.Connect() == KErrNone ) {
        RArray<TInt> personalityIds;
        mPersonalityIds.clear();
        if ( usbMan.GetPersonalityIds( personalityIds ) == KErrNone ) {
            for ( int i = 0; i < personalityIds.Count(); i++ ) {
                myDebug() << ">>> UsbUiSettingModel::initializeModelData personality ID ="
                    << personalityIds[i];
                if ( !isPersonalityHidden(usbMan, personalityIds[i]) ) {
                    mPersonalityIds.append( personalityIds[i] );                    
                    QString friendlyName = getFriendlyName(usbMan, personalityIds[i]);
                    
                    QStringList displayList;
                    //text-1 mode name
                    displayList.append( modeName( friendlyName ) );
                    
                    //text-2 description
                    QString textId = TextIdPrefix + friendlyName + DescriptionIdPostfix;
                    displayList.append( hbTrId(textId.toAscii()) );
                    
                    QMap< int, QVariant > dataRow;
                    dataRow[ Qt::DisplayRole ] = QVariant( displayList );
                    
                    //icon-1
                    QString iconName = ModeIconNamePrefix + friendlyName;
                    HbIcon icon(iconName);
                    QList<QVariant> icons;
                    icons << icon;                    
                    dataRow[ Qt::DecorationRole ] = QVariant( icons );
                    
                    mSettingsList << dataRow;
                }
            }
        }
        personalityIds.Close();
        usbMan.Close();
    }
    myDebug() << "<<< UsbUiSettingModel::initializeModelData";
}
예제 #8
0
////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//                                        Main Task
//
////////////////////////////////////////////////////////////////////////////////////////////////////////
task main()
{
	// Setup
	string sFriendlyName;
	getFriendlyName(sFriendlyName);
	IAmNXT = sFriendlyName == "HRF2" ? 0 : 1;
	MaxNXT = 2;
	setupHighSpeedLink();

	//
	eraseDisplay();
	bNxtLCDStatusDisplay = true; // Enable top status line display

	nxtDisplayTextLine(2, "IAmNXT: %d MAX: %d", IAmNXT, MaxNXT);

	if ( IAmNXT == 0 )
	{
		send();
	}
	else
	{
		recieve();
	}
}
task main ()
{
    int index;
    // port to use for the socket
    int BOFHport = 6666;
    string dataString;

    // get our bluetooth name
    getFriendlyName(dataString);

    int avail = 0;

    nNxtButtonTask = -2;
    StartTask(updateScreen);

    // initialise the port, etc
    RS485initLib();

    memset(RS485rxbuffer, 0, sizeof(RS485rxbuffer));
    memset(RS485txbuffer, 0, sizeof(RS485txbuffer));

    N2WchillOut();

    // Disconnect if already connected
    N2WDisconnect();
    N2WchillOut();

    // if a custom profile exists, use that instead
    if (N2WCustomExist())
    {
        N2WLoad();
    }
    else
    {
        // enable DHCP
        N2WsetDHCP(true);
        wait1Msec(100);
        // Disable adhoc
        N2WsetAdHoc(false);
        wait1Msec(100);
        // SSID to connect to
        N2WsetSSID("YOURWIFINETWORK");
        wait1Msec(100);
        // The passphrase to use
        N2WSecurityWPA2Passphrase("YOURWIFIPASSPHRASE");
        wait1Msec(100);
        // Save this profile to the custom profile
        N2WSave();
        wait1Msec(100);
        // Load the custom profile
        N2WLoad();
    }

    wait1Msec(100);
    N2WConnect(true);
    connStatus = "connecting";

    while (!N2WConnected())
        wait1Msec(1000);

    connStatus = "connected";
    PlaySound(soundBeepBeep);

    wait1Msec(3000);
    N2WgetIP(IPaddress);

    wait1Msec(1000);

    // Open a listening socket on port 6666
    if (!N2WTCPOpenServer(1, BOFHport))
    {
        writeDebugStreamLine("Err open port %d", BOFHport);
        PlaySound(soundException);
        while(bSoundActive) EndTimeSlice();
        StopAllTasks();
    }

    while (true)
    {
        // Check if anyone has sent us anything
        avail = N2WTCPAvail(1);
        if (avail > 0)
        {
            rxbytes += avail;
            N2WchillOut();


            PlaySound(soundFastUpwardTones);

            // Read what the client sent us
            sprintf(dataStrings[0], "%d bytes from", avail);
            N2WTCPRead(1, avail);
            N2WchillOut();

            // Get the MAC address of the client
            dataStrings[2] = "Remote MAC:";
            N2WTCPClientMAC(1, dataStrings[3]);

            writeDebugStream("MAC: ");
            writeDebugStreamLine(dataStrings[3]);
            N2WchillOut();

            // check the IP address of the client
            N2WTCPClientIP(1, dataStrings[1]);
            N2WchillOut();

            // Send back a hearty "Hi there, <IP>!"
            index = 0;
            returnMsg = "Hi there, ";
            index = RS485appendToBuff(buffer, index, returnMsg);
            index = RS485appendToBuff(buffer, index, dataStrings[1]);
            returnMsg = "\n";
            index = RS485appendToBuff(buffer, index, returnMsg);
            txbytes += index;
            N2WTCPWrite(1, (tHugeByteArray)buffer, index);
            N2WchillOut();

            // Terminate the connection to the client
            N2WTCPDetachClient(1);
            N2WchillOut();
        }
        // Wait a bit
        wait1Msec(50);
    }
}
task main ()
{
  int index;
  // port to use for the socket
  int BOFHport = 6666;
  string dataString;

  // get our bluetooth name
  getFriendlyName(dataString);

  int avail = 0;

  StartTask(updateScreen);

  // initialise the port, etc
  RS485initLib();
  N2WchillOut();
  N2WsetDebug(true);
  N2WchillOut();

  // Disconnect if already connected
  N2WDisconnect();
  wait1Msec(100);

  if (!N2WCustomExist())
  {
    StopTask(updateScreen);
    wait1Msec(50);
    eraseDisplay();
    PlaySound(soundException);
    nxtDisplayCenteredBigTextLine(1, "ERROR");
    nxtDisplayTextLine(3, "No custom profile");
    nxtDisplayTextLine(4, "configured!!");
    while(true) EndTimeSlice();
  }

  N2WLoad();
  wait1Msec(100);
  N2WConnect(true);
  connStatus = "connecting";

  while (!N2WConnected())
    wait1Msec(1000);

  connStatus = "connected";
  PlaySound(soundBeepBeep);

  wait1Msec(3000);
  N2WgetIP(IPaddress);
  memcpy(dataStrings[4], IPaddress, strlen(IPaddress) + 1);

  wait1Msec(1000);

  N2WTCPClose(0);
  N2WchillOut();
  RS485clearRead();
  N2WchillOut();
  // Open a listening socket on port 6666
  if (!N2WTCPOpenServer(1, BOFHport))
  {
    writeDebugStreamLine("Err open port %d", BOFHport);
    PlaySound(soundException);
    while(bSoundActive) EndTimeSlice();
    StopAllTasks();
  }

  while (true)
  {
    // Check if anyone has sent us anything
    avail = N2WTCPAvail(1);
    if (avail > 0)
    {
      rxbytes += avail;
      N2WchillOut();


      PlaySound(soundFastUpwardTones);

      // Read what the client sent us
      sprintf(dataStrings[0], "%d bytes from", avail);
      N2WTCPRead(1, avail);
      N2WchillOut();

      // Get the MAC address of the client
      dataStrings[2] = "Remote MAC:";
      N2WTCPClientMAC(1, dataStrings[3]);

      writeDebugStream("MAC: ");
      writeDebugStreamLine(dataStrings[3]);
      N2WchillOut();

      // check the IP address of the client
      N2WTCPClientIP(1, dataStrings[1]);
      N2WchillOut();

      // Send back a hearty "Hi there, <IP>!"
      index = 0;
      returnMsg = "Hi there, ";
      index = RS485appendToBuff(buffer, index, returnMsg);
      index = RS485appendToBuff(buffer, index, dataStrings[1]);
      returnMsg = "\n";
      index = RS485appendToBuff(buffer, index, returnMsg);
      txbytes += index;
      N2WTCPWrite(1, (tHugeByteArray)buffer, index);
      N2WchillOut();

      // Terminate the connection to the client
      N2WTCPDetachClient(1);
      N2WchillOut();
      wait1Msec(1000);
	  }
	  // Wait a bit
    wait1Msec(50);
  }
}
task main ()
{
  string BOFHserver = "192.168.0.100"; // Linux VM
  int BOFHport = 6666;
  string dataString;
  getFriendlyName(dataString);

  int avail = 0;

  nNxtButtonTask = -2;
  StartTask(updateScreen);

  // initialise the port, etc
  RS485initLib();

  memset(RS485rxbuffer, 0, sizeof(RS485rxbuffer));
  memset(RS485txbuffer, 0, sizeof(RS485txbuffer));

  // Disconnect if already connected
  N2WDisconnect();
  N2WchillOut();

  if (!N2WCustomExist())
  {
    StopTask(updateScreen);
    wait1Msec(50);
    eraseDisplay();
    PlaySound(soundException);
    nxtDisplayCenteredBigTextLine(1, "ERROR");
    nxtDisplayTextLine(3, "No custom profile");
    nxtDisplayTextLine(4, "configured!!");
    while(true) EndTimeSlice();
  }

  N2WLoad();

  wait1Msec(100);
  N2WConnect(true);
  connStatus = "connecting";

  while (!N2WConnected())
    wait1Msec(1000);

  connStatus = "connected";
  PlaySound(soundBeepBeep);

  wait1Msec(3000);
  N2WgetIP(IPaddress);

  wait1Msec(1000);


  while (true)
  {
    while (nNxtButtonPressed != kEnterButton) EndTimeSlice();
    while (nNxtButtonPressed != kNoButton) EndTimeSlice();
    if (N2WTCPOpenClient(1, BOFHserver, BOFHport)) {
      data[0] = 0x0A;
      N2WTCPWrite(1, data, 1);
      txbytes++;
      // How many bytes are available in the buffers?
	    avail = N2WTCPAvail(1);
	    if (avail > 0)
	    {
	      sizeOfReceivedData = avail;
	      rxbytes += avail;
	      N2WchillOut();
	      // read the current buffer
	      N2WTCPRead(1, avail);
	      processData();
	      for (int i = 0; i < avail; i++)
	      {
	        writeDebugStream("%c", RS485rxbuffer[i]);
	      }
	      writeDebugStreamLine("");
	    }
	    // Wait a bit
      N2WchillOut();
      // Disconnect
      N2WTCPClose(1);
    }
  }
}