Esempio n. 1
0
TBool CpiDeviceListUpnp::Update(const Brx& aUdn, const Brx& aLocation, TUint aMaxAge)
{
    if (!IsLocationReachable(aLocation)) {
        return false;
    }
    iLock.Wait();
    CpiDevice* device = RefDeviceLocked(aUdn);
    if (device != NULL) {
        CpiDeviceUpnp* deviceUpnp = reinterpret_cast<CpiDeviceUpnp*>(device->OwnerData());
        if (deviceUpnp->Location() != aLocation) {
            /* Device appears to have moved to a new location.
               Ask it to check whether the old location is still contactable.  If it is,
               stick with the older location; if it isn't, remove the old device and add
               a new one. */
            iLock.Signal();
            CpiDeviceUpnp* newDevice = new CpiDeviceUpnp(iCpStack, aUdn, aLocation, aMaxAge, *this, *this);
            deviceUpnp->CheckStillAvailable(newDevice);
            device->RemoveRef();
            return true;
        }
        deviceUpnp->UpdateMaxAge(aMaxAge);
        iLock.Signal();
        device->RemoveRef();
        return !iRefreshing;
    }
    iLock.Signal();
    return false;
}
Esempio n. 2
0
void CpiDeviceUpnp::CheckStillAvailable(CpiDeviceUpnp* aNewLocation)
{
    iLock.Wait();
    if (iNewLocation != NULL) {
        if (iNewLocation->Location() == aNewLocation->Location()) {
            iLock.Signal();
            aNewLocation->iDevice->RemoveRef();
            return;
        }
        CpiDevice* d = iNewLocation->iDevice;
        iNewLocation = aNewLocation;
        iLock.Signal();
        d->RemoveRef();
        return;
    }
    iNewLocation = aNewLocation;
    XmlFetchManager& xmlFetchManager = iDevice->GetCpStack().XmlFetchManager();
    ASSERT(iXmlCheck == NULL);
    iXmlCheck = xmlFetchManager.Fetch();
    Uri* uri = new Uri(iLocation);
    iDevice->AddRef();
    FunctorAsync functor = MakeFunctorAsync(*this, &CpiDeviceUpnp::XmlCheckCompleted);
    iXmlCheck->CheckContactable(uri, functor);
    xmlFetchManager.Fetch(iXmlCheck);
    iLock.Signal();
}
Esempio n. 3
0
TBool CpiDeviceListUpnp::Update(const Brx& aUdn, TUint aMaxAge)
{
    AutoMutex a(iLock);
    CpiDevice* device = RefDeviceLocked(aUdn);
    if (device != NULL) {
        reinterpret_cast<CpiDeviceUpnp*>(device->OwnerData())->UpdateMaxAge(aMaxAge);
        device->RemoveRef();
        return !iRefreshing;
    }
    return false;
}
Esempio n. 4
0
TBool CpiDeviceListUpnp::Update(const Brx& aUdn, const Brx& aLocation, TUint aMaxAge)
{
    if (!IsLocationReachable(aLocation)) {
        return false;
    }
    iLock.Wait();
    iCpStack.Env().Mutex().Wait();
    if (iRefreshing && iPendingRefreshCount > 1) {
        // we need at most one final msearch once a network card starts working following an adapter change
        iPendingRefreshCount = 1;
    }
    iCpStack.Env().Mutex().Signal();
    CpiDevice* device = RefDeviceLocked(aUdn);
    if (device != NULL) {
        CpiDeviceUpnp* deviceUpnp = reinterpret_cast<CpiDeviceUpnp*>(device->OwnerData());
        if (deviceUpnp->Location() != aLocation) {
            // device appears to have moved to a new location.
            // Remove the old record, leaving the caller to add the new one.
            iLock.Signal();
            Remove(aUdn);
            device->RemoveRef();
            return false;
        }
        deviceUpnp->UpdateMaxAge(aMaxAge);
        device->RemoveRef();
        iLock.Signal();
        LOG(kTrace, "Device alive {udn{");
        LOG(kTrace, aUdn);
        LOG(kTrace, "}, location{");
        LOG(kTrace, aLocation);
        LOG(kTrace, "}}\n");
        return !iRefreshing;
    }
    iLock.Signal();
    return false;
}