Example #1
0
                        void TVDeviceId::deviceRemoved(UPnPDevice* device) {
                            UPnPStateVariable* variable = getService()->getUPnPStateVariable("DevicesIds");

                            string devices = variable->getValue();

                            int line = devices.find(device->getUDN());
                            if (line != string::npos) {
                                string first = devices.substr(0, line);
                                string last = devices.substr(line);

                                int first_pos = first.find_last_of("\n");
                                if ((first_pos == string::npos) || (first_pos == 0)) {
                                    first = "";
                                } else {
                                    first = first.substr(0, first_pos);
                                }

                                int last_pos = last.find("\n");
                                if (last_pos == string::npos) {
                                    last = "";
                                } else {
                                    last = last.substr(last_pos);
                                }

                                devices = first + last;

                                variable->setValue(devices.c_str());
                                Utils::updateLastChangeStateVariable(getService(), variable);
                            }
                        }
                        bool TVRConnectionManager::actionGetProtocolInfo(UPnPAction *action) {
                            LoggerUtil_info(logger, "Entrando no método actionGetProtocolInfo(action)!");

                            // Source
                            action->getUPnPArgument(SOURCE)->setValue(getService()->getUPnPStateVariable(SOURCE_PROTOCOL_INFO)->getValue());
                            // Sink
                            action->getUPnPArgument(SINK)->setValue(getService()->getUPnPStateVariable(SINK_PROTOCOL_INFO)->getValue());
                            return true;
                        }
                        void TVRConnectionManager::initializeStateVariables() {
                            ostringstream sinkProtocol;
                            int length = Utils::getDLNAProfilesLength();
                            for (int i = 0; i < length; i++) {
                                if (i > 0)
                                    sinkProtocol << ",";
                                sinkProtocol << "http-get:*:" << Utils::getDLNAProfiles()[i][0] << ":DLNA.ORG_PN=" << Utils::getDLNAProfiles()[i][1];
                            }

                            getService()->getUPnPStateVariable(CURRENT_CONNECTION_IDS)->setValue(""); // "" ou "0"
                            getService()->getUPnPStateVariable(SINK_PROTOCOL_INFO)->setValue(sinkProtocol.str().c_str()); // "http-get:*:*:*,rtsp:*:*:*,http-get:*:video/mpeg:*,http-get:*:audio/mpeg:*,http-get:*:image/jpeg:*,http-get:*:image/png:*"
                            getService()->getUPnPStateVariable(SOURCE_PROTOCOL_INFO)->setValue("");
                        }
int
ExternalSearchRequestData::save( Packet* packet, int& pos ) const
{
   int sizeInPacket = getSizeInPacket();
   int startPos = pos;
   packet->incWriteLong( pos, sizeInPacket );
   
   packet->incWriteLong( pos, getService() );
   packet->incWriteLong( pos, m_startHitIdx );
   packet->incWriteLong( pos, m_endHitIdx );
   packet->incWriteLong( pos, m_coord.lat );
   packet->incWriteLong( pos, m_coord.lon );
   packet->incWriteLong( pos, m_distance );
   packet->incWriteLong( pos, m_itemInfoFilter );

   m_searchParams->save( packet, pos );
   
   packet->incWriteLong( pos, m_values.size() );
   for ( stringMap_t::const_iterator it = m_values.begin();
         it != m_values.end();
         ++it ) {
      packet->incWriteLong( pos, it->first );
      packet->incWriteString( pos, it->second );
   }
   packet->incAlignWriteLong( pos );
   MC2_ASSERT( ( pos - startPos ) == sizeInPacket );
   return sizeInPacket;
}
void AppOpsManager::startWatchingMode(int32_t op, const String16& packageName,
        const sp<IAppOpsCallback>& callback) {
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
        service->startWatchingMode(op, packageName, callback);
    }
}
int32_t AppOpsManager::permissionToOpCode(const String16& permission) {
    sp<IAppOpsService> service = getService();
    if (service != NULL) {
        return service->permissionToOpCode(permission);
    }
    return -1;
}
Example #7
0
void NetworkService::run()
{
	m_impl->service->reset();

	m_impl->connectionsManager->enable();

	// Inizializza il timer
	m_impl->timer = createAsioObject<boost::asio::deadline_timer>(*getService());
	startTimer();

	OS_ASSERT(m_impl->workerThreads.empty());

	uint32 workerThreadsCount = getWorkerThreadsCount();
	for(uint32 i = 0; i < workerThreadsCount; i++)
	{
	    shared_ptr<WorkerThread> thread(OS_NEW WorkerThread(boost::bind(&NetworkService::runService, this)));
        // Assegna ai sotto threads la stessa priorità del thread principale
	    thread->setPriority(getPriority());
	    // Accoda e avvia il sottothread
		m_impl->workerThreads.add(thread, true);
	}

	// Avvia il servizio
	runService();

	// Attende la chiusura di tutti i threads
	m_impl->workerThreads.join();
	m_impl->workerThreads.clear();
}
Example #8
0
 /**
  * Returns a human-readable representation of a process.
  * 
  * @param processId Process' id.
  * @return Process' representation for debugging purposes.
  */
 std::string
 toString ( uint processId ) const
 {
     assert ( exists ( processId ) );
     
     std::string output;
                     
     output += "    #" ;
     output += boost::lexical_cast<std::string> ( processId ) ;
     output += ": s";
     output += boost::lexical_cast<std::string>
                   ( getService ( processId ) ) ;
     output += ", pmc=";
     output += boost::lexical_cast<std::string>
                   ( getPMC ( processId ) ) ;
     output += "\n";
     output += "        needs           : " ;
     for ( uint r = 0 ; r < _resources.size(); ++r )
     {
         output += "r" ;
         output += boost::lexical_cast<std::string>
                   ( r ) ;
         output += ":" ;
         output += boost::lexical_cast<std::string>
                   ( getRequirement ( processId, r ) ) ;
         output += "   ";
     }
     output += "\n";
     
     return output ;                
 }
Example #9
0
int32_t AppOpsManager::checkOp(int32_t op, int32_t uid, const String16& callingPackage)
{
    sp<IAppOpsService> service = getService();
    return service != NULL
            ? service->checkOperation(op, uid, callingPackage)
            : APP_OPS_MANAGER_UNAVAILABLE_MODE;
}
Example #10
0
bool P3ReplicationGroup::fireOnChangeToPrimary() {
    ACE_GUARD_RETURN(ACE_SYNCH_RECURSIVE_MUTEX, mon, m_lock, false);
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::fireOnChangeToPrimary - Peer is now PRIMARY!\n")));
    ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: P3ReplicationGroup::fireOnChangeToPrimary - service(%p)!\n"), getService().get()));
    bool serviceChangeStatus = getService()->changeToPrimaryRole();
    return serviceChangeStatus;
}
Example #11
0
bool DropUserHandler::handleURI(URI& uri)
{
    if (uri.action != "drop_user")
        return false;

    wxWindow* w = getParentWindow(uri);
    UserPtr u = extractMetadataItemPtrFromURI<User>(uri);
    if (!u || !w)
        return true;
    ServerPtr s = u->getServer();
    if (!s)
        return true;

    if (wxNO == wxMessageBox(_("Are you sure?"), _("Removing User"),
        wxYES_NO|wxICON_QUESTION))
        return true;

    ProgressDialog pd(w, _("Connecting to Server..."), 1);
    pd.doShow();
    IBPP::Service svc;
    if (!getService(s.get(), svc, &pd, true)) // true = need SYSDBA password
        return true;

    try
    {
        svc->RemoveUser(wx2std(u->getUsername()));
        s->notifyObservers();
    }
    catch(IBPP::Exception& e)
    {
        wxMessageBox(e.what(), _("Error"),
            wxOK | wxICON_WARNING);
    }
    return true;
}
Example #12
0
uint64_t TorProtocolManager::sendAddme(const AddmeReq& req)
{
    auto json = QJsonDocument{
        QJsonObject{
            {"type", "AddMe"},
            {"nick", req.nickName},
            {"address", getService(req.service).getAddress()},
            {"message", req.message}
        }
    };

    if (auto peer = getService(req.service).getPeer(req.connection)) {
        return peer->send(json);
    }

    throw runtime_error("Failed to access peer while sending addme");
}
Example #13
0
URegistryKey U_EXPORT2
Collator::registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status) 
{
    if (U_SUCCESS(status)) {
        return getService()->registerInstance(toAdopt, locale, status);
    }
    return NULL;
}
Example #14
0
uint64_t TorProtocolManager::sendAck(const AckMsg &ack)
{

    if (auto peer = getService(ack.service).getPeer(ack.connection)) {
        return peer->sendAck(ack.what, ack.status, ack.data);
    }

    throw runtime_error("Failed to access peer while sending addme");
}
Example #15
0
StringEnumeration* U_EXPORT2
BreakIterator::getAvailableLocales(void)
{
    ICULocaleService *service = getService();
    if (service == NULL) {
        return NULL;
    }
    return service->getAvailableLocales();
}
Example #16
0
                        bool TVDeviceId::variableRequest(UPnPStateVariable *stateVar) {
                            UPnPStateVariable* serviceStateVar = getService()->getUPnPStateVariable(stateVar->getName());
                            if (serviceStateVar == NULL)
                                return false;

                            stateVar->setValue(serviceStateVar->getValue());

                            return true;
                        }
Example #17
0
void BuildingFountain::deliverService()
{
  ServiceWalkerPtr walker = ServiceWalker::create( BuildingPtr( this ), getService());
  ServiceWalker::ReachedBuildings reachedBuildings = walker->getReachedBuildings( getTile().getIJ() );
  for( ServiceWalker::ReachedBuildings::iterator itBuilding = reachedBuildings.begin(); itBuilding != reachedBuildings.end(); ++itBuilding)
  {
    (*itBuilding)->applyService( walker );
  }
}
Example #18
0
// -------------------------------------
StringEnumeration* 
NumberFormat::getAvailableLocales(void)
{
  ICULocaleService *service = getService();
  if (service) {
    return service->getAvailableLocales();
  }
  return NULL; // no way to return error condition
}
Example #19
0
                        void TVDeviceId::deviceAdded(BtDevice* device) {
                            
                            UPnPStateVariable* variable = getService()->getUPnPStateVariable("DevicesIds");

                            string devices = variable->getValue();
                            devices.append("name=");
                            devices.append(device->getFriendlyName());
                            devices.append(" uuid=");
                            devices.append(device->getUDN());
                            devices.append(" network=");
                            devices.append("bluetooth");
                            devices.append(" host-uuid=");
                            devices.append(this->getUDN());
                            devices.append("\n");

                            variable->setValue(devices.c_str());
                            Utils::updateLastChangeStateVariable(getService(), variable);
                        }
Example #20
0
URegistryKey U_EXPORT2
BreakIterator::registerInstance(BreakIterator* toAdopt, const Locale& locale, UBreakIteratorType kind, UErrorCode& status)
{
    ICULocaleService *service = getService();
    if (service == NULL) {
        status = U_MEMORY_ALLOCATION_ERROR;
        return NULL;
    }
    return service->registerInstance(toAdopt, locale, kind, status);
}
Example #21
0
URegistryKey 
NumberFormat::registerFactory(NumberFormatFactory* toAdopt, UErrorCode& status)
{
  ICULocaleService *service = getService();
  if (service) {
    return service->registerFactory(new NFFactory(toAdopt), status);
  }
  status = U_MEMORY_ALLOCATION_ERROR;
  return NULL;
}
Example #22
0
void Well::deliverService()
{
  ServiceWalkerPtr walker = ServiceWalker::create( _getCity(), getService() );
  walker->setBase( BuildingPtr( this ) );

  ServiceWalker::ReachedBuildings reachedBuildings = walker->getReachedBuildings( getTile().getIJ() );
  foreach( BuildingPtr building, reachedBuildings)
  {
    building->applyService( walker );
  }
Example #23
0
bool MediaSession::removeEventListenerInternal(
    const AtomicString& eventType,
    const EventListener* listener,
    const EventListenerOptions& options) {
  if (mojom::blink::MediaSessionService* service = getService()) {
    auto mojomAction = eventNameToMojomAction(eventType);
    DCHECK(mojomAction.has_value());
    service->DisableAction(mojomAction.value());
  }
  return EventTarget::removeEventListenerInternal(eventType, listener, options);
}
status_t SensorManager::assertStateLocked() const {
    bool initSensorManager = false;
    if (mSensorServer == NULL) {
        initSensorManager = true;
    } else {
        // Ping binder to check if sensorservice is alive.
        status_t err = IInterface::asBinder(mSensorServer)->pingBinder();
        if (err != NO_ERROR) {
            initSensorManager = true;
        }
    }
    if (initSensorManager) {
        // try for 300 seconds (60*5(getService() tries for 5 seconds)) before giving up ...
        const String16 name("sensorservice");
        for (int i = 0; i < 60; i++) {
            status_t err = getService(name, &mSensorServer);
            if (err == NAME_NOT_FOUND) {
                sleep(1);
                continue;
            }
            if (err != NO_ERROR) {
                return err;
            }
            break;
        }

        class DeathObserver : public IBinder::DeathRecipient {
            SensorManager& mSensorManger;
            virtual void binderDied(const wp<IBinder>& who) {
                ALOGW("sensorservice died [%p]", who.unsafe_get());
                mSensorManger.sensorManagerDied();
            }
        public:
            explicit DeathObserver(SensorManager& mgr) : mSensorManger(mgr) { }
        };

        LOG_ALWAYS_FATAL_IF(mSensorServer.get() == NULL, "getService(SensorService) NULL");

        mDeathObserver = new DeathObserver(*const_cast<SensorManager *>(this));
        IInterface::asBinder(mSensorServer)->linkToDeath(mDeathObserver);

        mSensors = mSensorServer->getSensorList(mOpPackageName);
        size_t count = mSensors.size();
        mSensorList =
                static_cast<Sensor const**>(malloc(count * sizeof(Sensor*)));
        LOG_ALWAYS_FATAL_IF(mSensorList == NULL, "mSensorList NULL");

        for (size_t i=0 ; i<count ; i++) {
            mSensorList[i] = mSensors.array() + i;
        }
    }

    return NO_ERROR;
}
Example #25
0
 template <typename T> ComPointer<T> getService(const Filter &filter, REFGUID guidService, REFIID riid)
 {
     //normally we should use IID_IMFGetService but this introduces another dependency
     //so here we simply define our own IId with the same value
     ComPointer<T> ret;
     ComPointer<IMFGetService> getService(filter, IID_IMFGetService);
     if (getService) {
         getService->GetService(guidService, riid, reinterpret_cast<void**>(ret.pparam()));
     }
     return ret;
 }
Example #26
0
void BuildingFountain::deliverService()
{
   ServiceWalker walker(getService());
   walker.setServiceBuilding(*this);
   std::set<Building*> reachedBuildings = walker.getReachedBuildings(getTile().getI(), getTile().getJ());
   for (std::set<Building*>::iterator itBuilding = reachedBuildings.begin(); itBuilding != reachedBuildings.end(); ++itBuilding)
   {
      Building &building = **itBuilding;
      building.applyService(walker);
   }
}
void ServiceBuilding::deliverService()
{
  // make a service walker and send him to his wandering
  ServiceWalkerPtr serviceman = ServiceWalker::create( _getCity(), getService() );
  serviceman->setMaxDistance( getWalkerDistance() );
  serviceman->send2City( BuildingPtr( this ) );

  if( !serviceman->isDeleted() )
  {
    addWalker( serviceman.as<Walker>() );
  }
}
Example #28
0
URegistryKey U_EXPORT2
Collator::registerFactory(CollatorFactory* toAdopt, UErrorCode& status)
{
    if (U_SUCCESS(status)) {
        CFactory* f = new CFactory(toAdopt, status);
        if (f) {
            return getService()->registerFactory(f, status);
        }
        status = U_MEMORY_ALLOCATION_ERROR;
    }
    return NULL;
}
                        bool TVRConnectionManager::variableRequest(UPnPStateVariable *stateVar) {
                            LoggerUtil_info(logger, "Entrando no método queryControlReceived(stateVar)!");
                            LoggerUtil_debug(logger, "stateVar nome: " << stateVar->getName() << " valor: " << stateVar->getValue());

                            UPnPStateVariable* serviceStateVar = getService()->getUPnPStateVariable(stateVar->getName());
                            if(serviceStateVar == NULL)
                                return false;

                            stateVar->setValue(serviceStateVar->getValue());

                            return true;
                        }
Example #30
0
URegistryKey U_EXPORT2
Collator::registerInstance(Collator* toAdopt, const Locale& locale, UErrorCode& status) 
{
    if (U_SUCCESS(status)) {
        // Set the collator locales while registering so that createInstance()
        // need not guess whether the collator's locales are already set properly
        // (as they are by the data loader).
        toAdopt->setLocales(locale, locale, locale);
        return getService()->registerInstance(toAdopt, locale, status);
    }
    return NULL;
}