Ejemplo n.º 1
0
UDisks2Plugin::UDisks2Plugin(QObject *parent) : QObject(parent)
{
    qDBusRegisterMetaType<QVariantMapMap>();
    qDBusRegisterMetaType<QByteArrayList>();

    m_manager = new UDisks2Manager(this);
    m_actions = new QActionGroup(this);
    connect(m_manager,SIGNAL(deviceAdded(QDBusObjectPath)), SLOT(addDevice(QDBusObjectPath)));
    connect(m_manager,SIGNAL(deviceRemoved(QDBusObjectPath)), SLOT(removeDevice(QDBusObjectPath)));
    connect(m_actions,SIGNAL(triggered (QAction *)), SLOT(processAction(QAction *)));
    //load settings
    QSettings settings(Qmmp::configFile(), QSettings::IniFormat);
    settings.beginGroup("UDisks2");
    m_detectCDA = settings.value("cda", true).toBool();
    m_detectRemovable = settings.value("removable", true).toBool();
    m_addTracks = false; //do not load tracks on startup
    m_addFiles = false;
    //find existing devices
    QList<QDBusObjectPath> devs = m_manager->findAllDevices();
    foreach(QDBusObjectPath o, devs)
        addDevice(o);
    //load remaining settings
    m_addTracks = settings.value("add_tracks", false).toBool();
    m_removeTracks = settings.value("remove_tracks", false).toBool();
    m_addFiles = settings.value("add_files", false).toBool();
    m_removeFiles = settings.value("remove_files", false).toBool();
    settings.endGroup();
}
QTM_BEGIN_NAMESPACE

QNmWifiEngine::QNmWifiEngine(QObject *parent)
:   QNetworkSessionEngine(parent)
{
    iface = new QNetworkManagerInterface(this);
    if(!iface->isValid()) {
        return;
    }
    iface->setConnections();
    connect(iface,SIGNAL(deviceAdded(QDBusObjectPath)),
            this,SLOT(addDevice(QDBusObjectPath)));
//     connect(iface,SIGNAL(deviceRemoved(QDBusObjectPath)),
//             this,SLOT(removeDevice(QDBusObjectPath)));
    connect(iface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
            this, SLOT(slotActivationFinished(QDBusPendingCallWatcher*)));

    foreach (const QDBusObjectPath &path, iface->getDevices())
        addDevice(path);

    QStringList connectionServices;
    connectionServices << NM_DBUS_SERVICE_SYSTEM_SETTINGS;
    connectionServices << NM_DBUS_SERVICE_USER_SETTINGS;
    QNetworkManagerSettings *settingsiface;
    foreach (const QString &service, connectionServices) {
        settingsiface = new QNetworkManagerSettings(service, this);
        settingsiface->setConnections();
        connect(settingsiface,SIGNAL(newConnection(QDBusObjectPath)),
                this,(SLOT(newConnection(QDBusObjectPath))));
    }
Ejemplo n.º 3
0
void UdisksManager::changeDevice(const QDBusObjectPath &device)
{
    UdisksInfo *info = m_devices.take(device.path());
    if (!info)
    {
        addDevice(device);
    }
    else
    {
        removeDevice(device);
        addDevice(device);
    }
}
Ejemplo n.º 4
0
INDI::BaseDevice * INDI::BaseClientQt::findDev (XMLEle * root, int create, char * errmsg)
{
    XMLAtt * ap;
    INDI::BaseDevice * dp;
    char * dn;

    /* get device name */
    ap = findXMLAtt (root, "device");
    if (!ap)
    {
        snprintf(errmsg, MAXRBUF, "No device attribute found in element %s", tagXMLEle(root));
        return (NULL);
    }

    dn = valuXMLAtt(ap);

    if (*dn == '\0')
    {
        snprintf(errmsg, MAXRBUF, "Device name is empty! %s", tagXMLEle(root));
        return (NULL);
    }

    dp = findDev(dn, errmsg);

    if (dp)
        return dp;

    /* not found, create if ok */
    if (create)
        return (addDevice (root, errmsg));

    snprintf(errmsg, MAXRBUF, "INDI: <%s> no such device %s", tagXMLEle(root), dn);
    return NULL;
}
Ejemplo n.º 5
0
VirtualNetwork::VirtualNetwork(Json::Value &json_data, EntityLookup *lookup)
    : Entity(DEFAULT_NAME, json_data)
{
    interface_name = DEFAULT_VNET_NAME;
    
    parseOptionalJsonParam(interface_name, json_data, "interface_name");
    parseOptionalJsonParam(ipv4_address, json_data, "ipv4_address");
    
    init();
    
    if (json_data.isMember("devices")) {
        if (!json_data["devices"].isArray()) {
            fail("'devices' should be an array");
        }

        for (auto& it : json_data["devices"]) {
            const char *dev_id = it.asCString();
            Entity *ent = lookup->lookupEntity(dev_id);
            
            if (!ent) {
                fail("Device '%s' not defined at this point", dev_id);
            }

            NetworkDevice *as_net_dev = dynamic_cast<NetworkDevice *>(ent);
            if (as_net_dev == NULL) {
                fail("Device '%s' is not a network device", dev_id);
            }

            addDevice(as_net_dev);
        }
    }
}
Ejemplo n.º 6
0
_BlockDevices::_BlockDevices(QWidget *parent) :
    QWidget(parent)
{
    devices = new QListWidget(this);
    add = new QPushButton(QIcon::fromTheme("list-add"), "", this);
    browse = new QPushButton(QIcon::fromTheme("edit-find"), "", this);
    del = new QPushButton(QIcon::fromTheme("list-remove"), "", this);
    name = new QLineEdit(this);
    name->setPlaceholderText("Block device name");
    panelLayout = new QHBoxLayout(this);
    panel = new QWidget(this);
    panelLayout->addWidget(add, 1);
    panelLayout->addWidget(browse, 1);
    panelLayout->addWidget(name, 20);
    panelLayout->addWidget(del, 1);
    panel->setLayout(panelLayout);
    commonLayout = new QVBoxLayout(this);
    commonLayout->addWidget(devices);
    commonLayout->addWidget(panel);
    commonLayout->addStretch(-1);
    setLayout(commonLayout);
    connect(add, SIGNAL(clicked()),
            this, SLOT(addDevice()));
    connect(del, SIGNAL(clicked()),
            this, SLOT(delDevice()));
    connect(browse, SIGNAL(clicked()),
            this, SLOT(setBlockDevPath()));
    setOneDeviceMode(false);
}
Ejemplo n.º 7
0
//
// Replace train window when no ride
//
BlankStateTrainPage::BlankStateTrainPage(Context *context) : BlankStatePage(context)
{
    dontShow->setChecked(appsettings->cvalue(context->athlete->cyclist, GC_BLANK_TRAIN, false).toBool());
    welcomeTitle->setText(tr("Train"));
    welcomeText->setText(tr("No devices or workouts ?\nLet's get you setup."));

    img->setIcon(QPixmap(":images/train.png"));
    img->setIconSize(QSize(800,330));

    ShortCut scAddDevice;
    // - add a realtime device
    // - find video and workouts
    scAddDevice.label = tr("Find and add training devices.");
    scAddDevice.buttonLabel = tr("Add device");
    scAddDevice.buttonIconPath = ":images/devices/kickr.png";
    QPushButton *addDeviceButton = addToShortCuts(scAddDevice);
    connect(addDeviceButton, SIGNAL(clicked()), context->mainWindow, SLOT(addDevice()));


    ShortCut scImportWorkout;
    scImportWorkout.label = tr("Find and Import your videos and workouts.");
    scImportWorkout.buttonLabel = tr("Scan hard drives");
    scImportWorkout.buttonIconPath = ":images/toolbar/Disk.png";
    QPushButton *importWorkoutButton = addToShortCuts(scImportWorkout);
    connect(importWorkoutButton, SIGNAL(clicked()), context->mainWindow, SLOT(manageLibrary()));

    ShortCut scDownloadWorkout;
    scDownloadWorkout.label = tr("Download workout files from the Erg DB.");
    scDownloadWorkout.buttonLabel = tr("Download workouts");
    scDownloadWorkout.buttonIconPath = ":images/mac/download.png";
    QPushButton *downloadWorkoutButton = addToShortCuts(scDownloadWorkout);
    connect(downloadWorkoutButton, SIGNAL(clicked()), context->mainWindow, SLOT(downloadErgDB()));

    canShow_ = !appsettings->cvalue(context->athlete->cyclist, GC_BLANK_TRAIN).toBool();
}
Ejemplo n.º 8
0
/**
 * Probe all plugged devices
 * 
 * \return number of devices recognized
 */
int
DeviceManager::Probe(BusType type)
{
	int n = 0;

	m_DeviceList->Clear();

	Driver *drv = Managers::Instance->driverManager->getDriver((unsigned) 0);

	while(drv != NULL)
	{
		if((drv != NULL) && (drv->Probe()))
		{
			n++;
			
			char dev_name[128];
			strcpy(dev_name, drv->getDevName());
			strcat(dev_name, "0\0");

			Device *dev = new Device(dev_name, drv);
			addDevice(dev);

			/* init the device? */

			cout<<dev->getName();
			cout<<" ";
		}

		drv = drv->Next;
	}

	return n;
}
Ejemplo n.º 9
0
void UnplacedComponentsDock::on_btnAdd_clicked()
{
    if (mBoard && mSelectedComponent && mSelectedDevice && mSelectedPackage && (!mSelectedFootprintUuid.isNull())) {
        addDevice(*mSelectedComponent, mSelectedDevice->getUuid(), mSelectedFootprintUuid);
    }
    updateComponentsList();
}
Ejemplo n.º 10
0
Devices::~Devices()
{
    if ( deviceStack!=NULL ) {
        delete deviceStack;
        deviceStack = NULL;
    };
    disconnect(usedDeviceList,
               SIGNAL(customContextMenuRequested(const QPoint&)),
               this,
               SLOT(showContextMenu(const QPoint&)));
    disconnect(addNewDevice, SIGNAL(clicked()), this, SLOT(addDevice()));
    disconnect(delSelDevice, SIGNAL(clicked()), this, SLOT(delDevice()));
    delete usedDeviceList;
    usedDeviceList = NULL;
    delete addNewDevice;
    addNewDevice = NULL;
    delete delSelDevice;
    delSelDevice = NULL;

    delete buttonlayout;
    buttonlayout = NULL;
    delete buttons;
    buttons = NULL;

    delete listLayout;
    listLayout = NULL;
    delete listWidget;
    listWidget = NULL;

    delete infoWidget;
    infoWidget = NULL;
    delete commonLayout;
    commonLayout = NULL;
}
Ejemplo n.º 11
0
UdisksManager::UdisksManager(QObject *parent)
    : QObject(parent)
{
    QDBusConnection system = QDBusConnection::systemBus();

    if (!system.isConnected())
    {
        emit error(tr("Cannot connect to Udisks daemon"));
    }

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceAdded",
                    this,
                    SLOT(onDeviceAdded(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceRemoved",
                    this,
                    SLOT(onDeviceRemoved(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceChanged",
                    this,
                    SLOT(onDeviceChanged(QDBusObjectPath)));

    QDBusInterface devEnum("org.freedesktop.UDisks",
                           "/org/freedesktop/UDisks",
                           "org.freedesktop.UDisks",
                           QDBusConnection::systemBus());

    QDBusMessage enumRes = devEnum.call("EnumerateDevices");
    // TODO/FIXME: error checking
//    if (enumRes.type() == QDBusMessage::ErrorMessage)
//    {
//        fprintf(stderr, "ERROR: Can't call EnumerateDevices\n");
//        fprintf(stderr, "       %s : %s\n", qPrintable(enumRes.errorName()), qPrintable(enumRes.errorMessage()));
//    }
//
//    if (enumRes.type() != QDBusMessage::ReplyMessage || !enumRes.arguments().at(0).canConvert<QDBusArgument>())
//    {
//        fprintf(stderr, "ERROR: Unexpected result type of EnumerateDevices call\n");
//    }
//
    const QDBusArgument enumArg = enumRes.arguments().at(0).value<QDBusArgument>();
//    if (enumArg.currentType() != QDBusArgument::ArrayType)
//    {
//        fprintf(stderr, "ERROR: Unexpected argument type of EnumerateDevices call\n");
//    }

    enumArg.beginArray();
    while (!enumArg.atEnd())
    {
        addDevice(qdbus_cast<QDBusObjectPath>(enumArg));
    }
    enumArg.endArray();
}
Ejemplo n.º 12
0
DeviceRef DeviceManagerOpenSl::getDefaultDevice()
{
	if( ! mDefaultDevice )
		mDefaultDevice = addDevice( DEFAULT_DEVICE_KEY );

	return mDefaultDevice;
}
Ejemplo n.º 13
0
void arctechDimInit(void) {

	strcpy(arctech_dimmer.id, "archtech_dimmers");
	addDevice(&arctech_dimmer, "kaku_dimmer", "KlikAanKlikUit Dimmers");
	arctech_dimmer.type = DIMMER;
	arctech_dimmer.header = 10;
	arctech_dimmer.pulse = 5;
	arctech_dimmer.footer = 38;
	arctech_dimmer.multiplier = 0.3;
	arctech_dimmer.rawLength = 148;
	arctech_dimmer.binaryLength = 37;
	arctech_dimmer.repeats = 1;
	arctech_dimmer.message = malloc(sizeof(JsonNode));

	arctech_dimmer.bit = 0;
	arctech_dimmer.recording = 0;

	addOption(&arctech_dimmer.options, 'd', "dimlevel", has_value, config_state, "[0-9]");
	addOption(&arctech_dimmer.options, 'a', "all", no_value, 0, NULL);
	addOption(&arctech_dimmer.options, 'u', "unit", has_value, config_id, "[0-9]");
	addOption(&arctech_dimmer.options, 'i', "id", has_value, config_id, "[0-9]");

	arctech_dimmer.parseBinary=&arctechDimParseBinary;
	arctech_dimmer.createCode=&arctechDimCreateCode;
	arctech_dimmer.printHelp=&arctechDimPrintHelp;

	protocol_register(&arctech_dimmer);
}
Ejemplo n.º 14
0
void EWingInput::slotReadSocket()
{
    while (m_socket->hasPendingDatagrams() == true)
    {
        QHostAddress sender;
        QByteArray data;
        EWing* wing;

        /* Read data from socket */
        data.resize(m_socket->pendingDatagramSize());
        m_socket->readDatagram(data.data(), data.size(), &sender);

        /* Check, whether we already have a device from this address */
        wing = device(sender, EWing::resolveType(data));
        if (wing == NULL)
        {
            /* New address. Create a new device. */
            wing = createWing(this, sender, data);
            if (wing != NULL)
                addDevice(wing);
        }

        if (wing != NULL)
            wing->parseData(data);
    }
}
Ejemplo n.º 15
0
void DetaDoc::createActions()
{
	/*menu File*/
	/*menu newTicket*/
	connect(ui->firstDiagnosticAct, SIGNAL(triggered()), this, SLOT(firstDiagnostic()));
	connect(ui->secondDiagnosticAct, SIGNAL(triggered()), this, SLOT(secondDiagnostic()));
	/*menu new ticket*/
	connect(ui->SaleInOfficeAct, SIGNAL(triggered()), this, SLOT(saleInOfficeS()));
        connect(ui->forSallingAct, SIGNAL(triggered()), this, SLOT(forSaleS()));
	connect(ui->timeTableAct, SIGNAL(triggered()), this, SLOT(timeTable()));
	connect(ui->devicesRentAct, SIGNAL(triggered()), this, SLOT(devicesRent()));
	connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(quit()));
	/*menu file end*/

	/*menu partners*/
	connect(ui->addPartnerAct, SIGNAL(triggered()), this, SLOT(addPartner()));
	connect(ui->partnerDictionaryAct, SIGNAL(triggered()), this, SLOT(openPartnerDictionary()));
	/*menu partners end*/

	/*menu devices*/
	connect(ui->deviceAddAct, SIGNAL(triggered()), this, SLOT(addDevice()));
	connect(ui->devicesDictionaryAct, SIGNAL(triggered()), this, SLOT(openDeviceDict()));
    connect(ui->warehouseDevicesAct, SIGNAL(triggered()), this, SLOT(openDeviceWarehouse()));

    connect(ui->addLiteratureAct, SIGNAL(triggered()), this, SLOT(addLiterature()));
    connect(ui->literatureDictAct, SIGNAL(triggered()), this, SLOT(openLiteratureDict()));
    connect(ui->warehouseLiteratureAct, SIGNAL(triggered()), this, SLOT(openLiteratureWarehouse()));

    connect(ui->setLicenseCostAct, SIGNAL(triggered()), this, SLOT(changeLicenseCost()));
    connect(ui->warehouseLicense, SIGNAL(triggered()), this, SLOT(openLicenseWarehouse()));
	/*menu devices end*/

	/*menu customers*/
	connect(ui->addCustomerAct, SIGNAL(triggered()), this, SLOT(addCustomer()));
	connect(ui->customersDictionaryAct, SIGNAL(triggered()), this, SLOT(openCustomersDict()));
    connect(ui->addRangeCustomerCardsAct, SIGNAL(triggered()), this, SLOT(addRangeOfCustomerCards()));
    connect(ui->deleteRangeCustomerCardsAct, SIGNAL(triggered()), this, SLOT(deleteRangeOfCustomerCards()));
    connect(ui->customerCardsDictAct, SIGNAL(triggered()), this, SLOT(openDictOfCustomerCards()));
	/*menu customers end*/

	/*menu doctors*/
	connect(ui->addDoctorAct, SIGNAL(triggered()), this, SLOT(addDoctor()));
	connect(ui->doctorsDictionaryAct, SIGNAL(triggered()), this, SLOT(openDoctorsDict()));
	/*menu doctors end*/

	/*menu reports*/
	connect(ui->reportCustomersAct, SIGNAL(triggered()), this, SLOT(customerReport()));
	connect(ui->reportDevicesAct, SIGNAL(triggered()), this, SLOT(devicesReport()));
	/*menu reports end*/

	/*menu settings*/
	connect(ui->dbSettingsAct, SIGNAL(triggered()), this, SLOT(DBSettings()));
	connect(ui->manageUsersAct, SIGNAL(triggered()), this, SLOT(manageUsers()));
	/*menu setting end*/

	/*menu about*/
	connect(ui->aboutProgrammAct, SIGNAL(triggered()), this, SLOT(AboutProgramm()));
	connect(ui->aboutQtAct, SIGNAL(triggered()), this, SLOT(AboutQt()));
	/*menu about end*/
}
  void winDisplayDeviceManager::scanDisplays()
  {
    // TODO mutex for this variable ???
    descMap.clear();
    EnumDisplayMonitors(0,0,winDisplayDeviceManager::EnumDispProc,(LPARAM)this);

    // Add new descriptors
    set<DisplayDeviceDescriptor> tempSet, resultSet;
    for (descMap_t::iterator it = descMap.begin(); it != descMap.end(); it++)
    {
      addDevice(it->second);
      tempSet.insert(it->second);
    }

    // We could just copy the new descriptors, however, we need to call callback functions
    // for old displays, that's why we do this:
    std::set_difference(descriptors.begin(), descriptors.end(), tempSet.begin(), tempSet.end(),
                        std::inserter(resultSet, resultSet.end()));

    set<DisplayDeviceDescriptor>::iterator it = resultSet.begin();
    for (; it != resultSet.end(); it++)
    {
      DisplayDeviceDescriptor desc = *it;
      removeDevice(desc);
    }
  }
Ejemplo n.º 17
0
void ofxGSTT::setup(int sampleRate,string language, float _volumeThreshold){
	/*** SOUND INPUT ***/
	bufferSize = 256;
	left.assign(bufferSize, 0.0);
	right.assign(bufferSize, 0.0);

	/*** SOUND RECORDING ***/
	info.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
	info.frames = sampleRate * 60; //TODO revisit -> why *60? because of 60fps?
	info.samplerate = sampleRate;
	info.channels = 2;
	volumeThreshold = _volumeThreshold;

	this->language = language;

	ofDirectory dir;
	if(!dir.doesDirectoryExist("tmpAudio")){
		dir.createDirectory("tmpAudio");
	}

	//add and setup default device
	addDevice(OFXGSTT_DEFAULTDEVICE_ID);

	ofAddListener(ofEvents.audioReceived, this, &ofxGSTT::audioInWODevice);
	ofAddListener(audioDeviceEvent, this, &ofxGSTT::audioInByDevice);
	bListen = true;
}
/**
 * Update devicename, ip, port, public folder, and private folder
 * @param currentDevicename
 * @param newDevicename
 * @param username
 * @param ip
 * @param port
 * @param pulicFolder
 * @param privateFolder
 * @return 0 on success, -1 when currentDevice does not exist, otherwise DB
 * error code
 */
int DeviceCassandraController::updateDevice(
    const string &currentDevicename, const string &newDevicename,
    const string &username, const string &ip, const string &port,
    const string &publicFolder, const string &privateFolder) {
  string errorCode = "";
  int result;
  // Get the current device.
  boost::shared_ptr<Device> device =
      getDevice(currentDevicename, username, errorCode);
  if (!errorCode.empty()) {
    return boost::lexical_cast<int>(errorCode);
  }

  // Delete the current device from db.
  result = deleteDevice(currentDevicename, username);
  if (result != 0) {
    return result;
  }

  // Update data in the current device.
  device->setDevicename(newDevicename);
  device->setIp(ip);
  unsigned short portValue = -1;
  if (!ControllerHelper::isNullOREmptyString(port))
    portValue = boost::lexical_cast<unsigned short>(port);
  device->setPort(portValue);
  device->setPublicFolder(publicFolder);
  device->setPrivateFolder(privateFolder);

  // Add the new device.
  result = addDevice(device);
  return result;
}
Connect_Bluetooth::Connect_Bluetooth(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Connect_Bluetooth)
{
    ui->setupUi(this);

    discoveryAgent = new QBluetoothDeviceDiscoveryAgent();

    connect(ui->inquiryType, SIGNAL(toggled(bool)), this, SLOT(setGeneralUnlimited(bool)));
    connect(ui->scan, SIGNAL(clicked()), this, SLOT(startScan()));

    connect(discoveryAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)),
            this, SLOT(addDevice(QBluetoothDeviceInfo)));
    connect(discoveryAgent, SIGNAL(finished()), this, SLOT(scanFinished()));

    connect(ui->list, SIGNAL(itemActivated(QListWidgetItem*)),
            this, SLOT(itemActivated(QListWidgetItem*)));

    /*
    connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)),
            this, SLOT(hostModeStateChanged(QBluetoothLocalDevice::HostMode)));

    hostModeStateChanged(localDevice->hostMode());
    // add context menu for devices to be able to pair device
    ui->list->setContextMenuPolicy(Qt::CustomContextMenu);
    */




}
Ejemplo n.º 20
0
/**
 * LoadDevices
 * 
 * Loads devices from configuration object(YAML::Node)
 */
void
InsteonNetwork::loadDevices() {
    YAML::Node device = config_["DEVICES"];
    for (auto it = device.begin(); it != device.end(); ++it) {
        addDevice(it->first.as<int>(0));
    }
}
const DeviceRef& DeviceManagerXAudio::getDefaultDevice()
{
	if( ! mDefaultDevice )
		mDefaultDevice = addDevice( DEFAULT_XAUDIO2_DEVICE_KEY );

	return mDefaultDevice;
}
Ejemplo n.º 22
0
void Devices::execDevExistanceMenuResult(Device_Action ret)
{
    if ( ret==ADD ) {
        addDevice();
    } else if ( ret==DEL ) {
        delDevice();
    };
}
Ejemplo n.º 23
0
void MIDIOut::rescanDevices()
{
	/* Treat all devices nonexistent and doomed for destruction */
	QList <MIDIDevice*> destroyList(m_devices);

	/* Find out which devices are still present */
	for (ItemCount i = 0; i < MIDIGetNumberOfDevices(); i++)
	{
		MIDIDeviceRef dev = MIDIGetDevice(i);
		for (ItemCount j = 0; j < MIDIDeviceGetNumberOfEntities(dev); j++)
		{
			MIDIEntityRef entity = MIDIDeviceGetEntity(dev, j);
			OSStatus s = 0;
			SInt32 uid = 0;

			/* Check if the entity is able to send data */
			if (MIDIEntityGetNumberOfDestinations(entity) == 0)
				continue;

			/* Extract UID from the entity */
			s = MIDIObjectGetIntegerProperty(entity,
							 kMIDIPropertyUniqueID,
							 &uid);
			if (s != 0)
			{
				qWarning() << "Unable to get entity UID";
				continue;
			}

			MIDIDevice* dev(deviceByUID(uid));
			if (dev != NULL)
			{
				/* Device still exists */
				destroyList.removeAll(dev);
			}
			else
			{
				/* New device */
				dev = new MIDIDevice(this, entity);
				Q_ASSERT(dev != NULL);
				if (dev->extractUID() == true &&
				    dev->extractName() == true)
				{
					addDevice(dev);
				}
				else
				{
					delete dev;
					dev = NULL;
				}
			}
		}
	}

	/* Destroy all devices that were no longer present */
	while (destroyList.isEmpty() == false)
		delete destroyList.takeFirst();
}
Ejemplo n.º 24
0
QEvdevTabletManager::QEvdevTabletManager(const QString &key, const QString &specification, QObject *parent)
    : QObject(parent)
{
    Q_UNUSED(key);

    if (qEnvironmentVariableIsSet("QT_QPA_EVDEV_DEBUG"))
        const_cast<QLoggingCategory &>(qLcEvdevTablet()).setEnabled(QtDebugMsg, true);

    QString spec = QString::fromLocal8Bit(qgetenv("QT_QPA_EVDEV_TABLET_PARAMETERS"));

    if (spec.isEmpty())
        spec = specification;

    QStringList args = spec.split(QLatin1Char(':'));
    QStringList devices;

    foreach (const QString &arg, args) {
        if (arg.startsWith(QLatin1String("/dev/"))) {
            devices.append(arg);
            args.removeAll(arg);
        }
    }

    // build new specification without /dev/ elements
    m_spec = args.join(QLatin1Char(':'));

    foreach (const QString &device, devices)
        addDevice(device);

    // when no devices specified, use device discovery to scan and monitor
    if (devices.isEmpty()) {
        qCDebug(qLcEvdevTablet) << "evdevtablet: Using device discovery";
        m_deviceDiscovery = QDeviceDiscovery::create(QDeviceDiscovery::Device_Tablet, this);
        if (m_deviceDiscovery) {
            const QStringList devices = m_deviceDiscovery->scanConnectedDevices();
            for (const QString &device : devices)
                addDevice(device);

            connect(m_deviceDiscovery, &QDeviceDiscovery::deviceDetected,
                    this, &QEvdevTabletManager::addDevice);
            connect(m_deviceDiscovery, &QDeviceDiscovery::deviceRemoved,
                    this, &QEvdevTabletManager::removeDevice);
        }
    }
}
Ejemplo n.º 25
0
void DeviceManagerPulseAudio::parseDevices( DeviceInfo::Usage usage )
{
	std::vector<DeviceInfo> devInfos = pulse::getDeviceInfos( usage );

	for( auto& devInfo : devInfos ) {
		DeviceRef addedDevice = addDevice( devInfo.mKey );
		mDeviceInfoSet.insert( std::make_pair( addedDevice, devInfo ) );
	}
}
Ejemplo n.º 26
0
void MidiRouter::setup(std::initializer_list<std::shared_ptr<MidiDevice>> devices) {
  for (auto& device : devices) {
    addDevice(device);
  }
  loadMappings();
  _eventRouter = std::make_shared<MidiEventRouter>(*this);
  _eventRouter->setup();
  _eventRouter->attach(AppSystem::get().simulation().getEvents());
}
Ejemplo n.º 27
0
void LocalStorage::init()
{
    setName(i18n("Local Storage"));

    LocalStorageDevice *device = new LocalStorageDevice(this);

    addDevice(device);
    connectDevice(device);
    emit deviceConnected(device);
}
Ejemplo n.º 28
0
void MountTray::slotDevChanges(bool showPopup){
  //This function actually checks the system device list for changes
  //  and updates the available devices appropriately
  
  if(DEBUG_MODE){ qDebug() << "Checking for Device Changes:"; }
  //Get the current list of devices
  QStringList nsd = DCheck->devChildren("");
  //Remove all the currently managed devices
  qDebug() << "Rescanning Device List";
  for(int i=0; i<deviceList.length(); i++){
    QString dev = deviceList[i]->device.section("/",-1);
    if(DEBUG_MODE){ qDebug() << " - Check device:" << dev; }
    int ni = nsd.indexOf(dev);
    if(ni == -1){
      //Device Removed
      if(DEBUG_MODE){ qDebug() << " - Device no longer connected:" << dev; }
      removeDevice(dev);
      i--;
    }else{
      //Probe the device for validity if not currently mounted
      if( !deviceList[i]->isMounted() ){
	QString ja, jb, jc, jd; //junk variables
        if( !DCheck->devInfo(dev,&ja,&jb,&jc,&jd) ){
	  if(DEBUG_MODE){ qDebug() << " - Device no longer valid:" << dev; }
	  //no longer valid device
	  removeDevice(dev);
	  i--;
	}
      }
      nsd.removeAt(ni);
    }
  }
  //Now Iterate through all available devices and probe them for validity
  // (This should catch devices that do not "announce" their presence by creating a new device node)
  for(int i=0; i<nsd.length(); i++){
    //Check if it is a good device
    QString dlabel, dtype, dfs, dsize; //additional output info
    bool good = DCheck->devInfo(nsd[i],&dtype,&dlabel,&dfs,&dsize);
    if(good){
      //Now create a new entry for this device
      bool added = addDevice(nsd[i],dlabel,dtype,dfs);  
      //Show a message bubble
      if(showPopup && added){ //make sure this is not shown for previously added devices
        QString title = tr("New Device");
        QString message = QString( tr("%1 can now be accessed")).arg(dlabel);
        slotDisplayPopup(title, message, nsd[i]);
      }
    }
  }
  
  //Run the disk space check if appropriate
  if(useDiskWatcher && useDiskTimerDevd && showPopup){ diskWatcher->checkFS(); }
}
Ejemplo n.º 29
0
void MIDIOut::rescanDevices()
{
	UINT deviceCount;

	/* Destroy existing devices in case something has changed */
	while (m_devices.isEmpty() == false)
		removeDevice(m_devices.takeFirst());

	/* Create devices for each valid midi input */
	deviceCount = midiOutGetNumDevs();
	for (UINT id = 0; id < deviceCount; id++)
		addDevice(new MIDIDevice(this, id));
}
Ejemplo n.º 30
0
Studio::Studio() :
    m_midiThruFilter(0),
    m_midiRecordFilter(0),
    m_mixerDisplayOptions(0),
    m_metronomeDevice(0)
{
    // We _always_ have a buss with id zero, for the master out
    m_busses.push_back(new Buss(0));

    // And we always create one audio record in
    m_recordIns.push_back(new RecordIn());

    // And we always have one audio and one soft-synth device, whose
    // IDs match the base instrument numbers (for no good reason
    // except easy identifiability)
    addDevice(QObject::tr("Audio").toUtf8().data(),
              AudioInstrumentBase, AudioInstrumentBase,
              Device::Audio);
    addDevice(QObject::tr("Synth plugin").toUtf8().data(),
              SoftSynthInstrumentBase, SoftSynthInstrumentBase,
              Device::SoftSynth);
}