Add device

@param \Sopinet\ChatBundle\Entity\Device $device

@return User
492904
public function addDevice(\Sopinet\ChatBundle\Entity\Device $device)
    {
        $this->devices[] = $device;

        return $this;
    }
695214
public function open($device, $mode = "w+b")
    {
        if (false === file_exists($device)) {
            throw new DeviceNotFound();
        }

        $this->getConfigure()->configure($device);
        $this->fd = fopen($device, $mode);

        if (false !== $this->fd) {
            stream_set_blocking($this->fd, false);

            return true;
        }

        unset($this->fd);
        throw new DeviceNotAvailable($device);
    }
181684
def add_device(dev):
    """"""
    global DEV_IDX, DEFAULT_DEV
    with DEV_LOCK:
        for idx in range(len(DEVS)):
            test_dev = DEVS[idx]
            if test_dev.dev_name_short == dev.dev_name_short:
                # This device is already in our list. Delete the old one
                if test_dev is DEFAULT_DEV:
                    DEFAULT_DEV = None
                del DEVS[idx]
                break
        if find_device_by_name(dev.name):
            # This name is taken - make it unique
            dev.name += '-%d' % DEV_IDX
        dev.name_path = '/' + dev.name + '/'
        DEVS.append(dev)
        DEV_IDX += 1
        if DEFAULT_DEV is None:
            DEFAULT_DEV = dev
965868
def add_device():
    
    req = request.get_json()
    success = False
    if 'device_id' in req and 'host' in req:
        success = add(req['device_id'], req['host'], req.get('adbkey', ''), req.get('adb_server_ip', ''), req.get('adb_server_port', 5037))
    return jsonify(success=success)
251099
public void add_device(final DeviceProxy deviceProxy, final DbDevInfo devinfo) throws DevFailed {
        checkIfTango(deviceProxy, "add_device");
        checkIfUseDb(deviceProxy, "add_device()");

        if (deviceProxy.getDb_dev() == null) {
            deviceProxy.setDb_dev(new DbDevice(deviceProxy.devname, deviceProxy.url.host,
                deviceProxy.url.strPort));
        }
        deviceProxy.getDb_dev().add_device(devinfo);
    }
1360274
public function addUser(\Haven\SecurityBundle\Entity\User $users)
    {
        $this->users[] = $users;
    
        return $this;
    }
1245201
public static function detect(Device $device, UserAgent $userAgent)
    {
        $device->setName($device::UNKNOWN);

        return (
            self::checkIpad($device, $userAgent) ||
            self::checkIphone($device, $userAgent) ||
            self::checkWindowsPhone($device, $userAgent) ||
            self::checkSamsungPhone($device, $userAgent)
        );
    }
550921
def _add_device(self, scs_id, ha_id, name):
        
        if scs_id in self._devices:
            return

        self._devices[scs_id] = {
            'name': name,
            'ha_id': ha_id
        }
1154048
public function addMyFriend(\CsnUser\Entity\User $user)
    {
        $user->addFriendWithMe($this); // synchronously updating inverse side. Tell your new friend you have added him as a friend
        $this->myFriends[] = $user;

        return $this;
    }
371537
public function toDevice($device)
    {
        if (is_array($device)) {
            $this->devices = array_merge($device, $this->devices);

            return $this;
        }
        $this->devices[] = $device;

        return $this;
    }
683705
public function getDevice(string $device) : Device
    {
        if (!array_key_exists($device, $this->devices)) {
            throw new \OutOfBoundsException(
                'Device "' . $device . '" does not exist in data'
            );
        }

        return $this->devices[$device];
    }
548188
public function addUser($userId)
    {
        if (true === is_numeric($userId) && false === in_array($userId, $this->users)) {
            $this->users[] = (int)$userId;
        }
        return $this;
    }
497154
private static function checkWindowsPhone(Device $device, UserAgent $userAgent)
    {
        if (stripos($userAgent->getUserAgentString(), 'Windows Phone') !== false) {
            if (preg_match('/Microsoft; (Lumia [^)]*)\)/', $userAgent->getUserAgentString(), $matches)) {
                $device->setName($matches[1]);
                return true;
            }

            $device->setName($device::WINDOWS_PHONE);
            return true;
        }
        return false;
    }
1280643
public function addUser($user)
    {
        if (!$this->getUsers()->contains($user))
        {
            $this->getUsers()->add($user);
            $user->addGroup($this);
        }

        return $this;
    }
202059
private static function normalizeOS(Device $device)
    {
        if (strpos($device->getDeviceUa(), 'Windows') !== false) {
            if (preg_match('/Windows NT ([0-9]+?\.[0-9])/', $device->getOs()->name, $matches)) {
                $device->getOs()->name    = 'Windows';
                $device->getOs()->version = array_key_exists($matches[1], self::$windowsMap) ? self::$windowsMap[$matches[1]]
                    : $matches[1];

                return;
            }

            if (preg_match('/Windows [0-9\.]+/', $device->getOs()->name)) {
                return;
            }
        }

        if (strpos($device->getOs()->name, 'Windows Phone') !== false) {
            if (array_key_exists($device->getOs()->version, self::$wds_map)) {
                $device->getOs()->version = self::$wds_map[$device->getOs()->version];

                return;
            }
        }

        if ($device->getOs()->setRegex($device->getDeviceUa(), '/PPC.+OS X ([0-9\._]+)/', 'Mac OS X')) {
            $device->getOs()->version = str_replace('_', '.', $device->getOs()->version);

            return;
        }

        if ($device->getOs()->setRegex($device->getDeviceUa(), '/PPC.+OS X/', 'Mac OS X')) {
            return;
        }

        if ($device->getOs()->setRegex($device->getDeviceUa(), '/Intel Mac OS X ([0-9\._]+)/', 'Mac OS X', 1)) {
            $device->getOs()->version = str_replace('_', '.', $device->getOs()->version);

            return;
        }

        if ($device->getOs()->setContains($device->getDeviceUa(), 'Mac_PowerPC', 'Mac OS X')) {
            return;
        }

        if ($device->getOs()->setContains($device->getDeviceUa(), 'CrOS', 'Chrome OS')) {
            return;
        }

        if ($device->getOs()->name) {
            return;
        }

        if (strpos($device->getDeviceUa(), 'FreeBSD') !== false) {
            $device->getOs()->name = 'FreeBSD';

            return;
        }

        if (strpos($device->getDeviceUa(), 'NetBSD') !== false) {
            $device->getOs()->name = 'NetBSD';

            return;
        }

        // Last ditch efforts
        if (strpos($device->getDeviceUa(), 'Linux') !== false || strpos($device->getDeviceUa(), 'X11') !== false) {
            $device->getOs()->name = 'Linux';

            return;
        }
    }
734883
public function getDevice($deviceId)
    {
        if (!isset($this->_deviceCache[$deviceId])) {
            $device = $this->persistenceStorage->load($deviceId);
            if (!$device) {
                throw new Exception("There is no device with ID [$deviceId] in the loaded WURFL Data");
            }
            $this->_deviceCache[$deviceId] = $device;
        }
        return $this->_deviceCache[$deviceId];
    }
1072456
public function addPersona(\Haven\PersonaBundle\Entity\Persona $persona) {
        $this->persona[] = $persona;

        return $this;
    }