void ServicesManager::createServices() { addService(sptr<ExceptionManager>{new ExceptionManager{}}); addService(sptr<UtilProvider>{new UtilProvider{}}); addService(sptr<draw::SceneManager>{ new draw::SceneManager{} }); addService(sptr<draw::RenderManager>{ new draw::RenderManager{} }); addService(sptr<Input>{new Input{}}); }
void Browser::browserCallback(AvahiSServiceBrowser *b, AvahiIfIndex iface, AvahiProtocol protocol, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata) noexcept { auto browser = static_cast<Browser*>(userdata); switch (event) { case AVAHI_BROWSER_NEW: printf("Found %s of type %s in domain %s\n", name, type, domain); browser->addService(iface, protocol, name, type, domain); break; case AVAHI_BROWSER_REMOVE: printf("Removing %s of type %s in domain %s\n", name, type, domain); browser->removeService(name); break; case AVAHI_BROWSER_FAILURE: printf("Error: %s\n", avahi_strerror(avahi_server_errno(browser->server_.get()))); break; default: break; } }
ServiceDiscoveryDialog::ServiceDiscoveryDialog(const QString &name, const QBluetoothAddress &address, QWidget *parent) : QDialog(parent), ui(new Ui_ServiceDiscovery) { ui->setupUi(this); //Using default Bluetooth adapter QBluetoothLocalDevice localDevice; QBluetoothAddress adapterAddress = localDevice.address(); /* * In case of multiple Bluetooth adapters it is possible to * set which adapter will be used by providing MAC Address. * Example code: * * QBluetoothAddress adapterAddress("XX:XX:XX:XX:XX:XX"); * discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress); */ discoveryAgent = new QBluetoothServiceDiscoveryAgent(adapterAddress); discoveryAgent->setRemoteAddress(address); setWindowTitle(name); connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(addService(QBluetoothServiceInfo))); connect(discoveryAgent, SIGNAL(finished()), ui->status, SLOT(hide())); discoveryAgent->start(); }
void Session_Service::onRemoteObjectComplete(qi::Future<void> future, long requestId) { qiLogDebug() << "Got metaobject"; boost::recursive_mutex::scoped_lock l(_requestsMutex); ServiceRequest *sr = serviceRequest(requestId); if (!sr) return; if (future.hasError()) { sr->promise.setError(future.error()); removeRequest(requestId); return; } { boost::recursive_mutex::scoped_lock sl(_remoteObjectsMutex); RemoteObjectMap::iterator it = _remoteObjects.find(sr->name); if (it != _remoteObjects.end()) { //another object have been registered before us, return it //the new socket will be closed when the request is deleted qiLogVerbose() << "A request for the service " << sr->name << " have been discarded, " << "the remoteobject on the service was already available."; sr->promise.setValue(it->second); } else { AnyObject o = makeDynamicAnyObject(sr->remoteObject); //register the remote object in the cache addService(sr->name, o); sr->promise.setValue(o); sr->remoteObject = 0; } } removeRequest(requestId); }
bool PeerInfo::addService(const UUIDPtr& sid) { if (m_serviceMap.find(sid) == -1) { ServiceInfoPtr serviceInfo(new ServiceInfo(sid)); return addService(serviceInfo); } return false; }
void ServiceList::assignSystemServices(void) { struct servent *entry; clearServiceList(true); /* Open /etc/services */ entry = getservent(); while (entry != NULL) { /* Only show protocol tcp and udp. */ wxString prot = wxString::From8BitData(entry->s_proto); if (prot == wxT("tcp") || prot == wxT("udp")) { Service *service = new Service( wxString::From8BitData(entry->s_name), entry->s_port, (prot == wxT("tcp") ? Service::TCP : Service::UDP), false); addService(service); } entry = getservent(); } /* Close /etc/services */ endservent(); sizeChangeEvent(serviceList_.size()); }
ContactListSettings::ContactListSettings() { m_layout = new QVBoxLayout(this); addService("ContactModel", QT_TR_NOOP("Model")); addService("ContactListWidget", QT_TR_NOOP("Widget style")); addService("ContactDelegate", QT_TR_NOOP("Contacts style")); m_layout->addItem(new QSpacerItem(0, 20, QSizePolicy::Preferred, QSizePolicy::Expanding)); foreach(const ObjectGenerator *gen, ObjectGenerator::module<ContactListSettingsExtention>()) { QByteArray service = MetaObjectBuilder::info(gen->metaObject(), "ServiceSettings"); if (service.isEmpty()) addExtensionWidget(QByteArray(), gen, false); else m_extensions.insert(service, gen); }
void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const HostAddressPort& address) { static int hostid = 0; std::string hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid)); hostid++; addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, address.getPort(), 0, 0)); addAddress(hostname, address.getAddress()); }
void CZeroconfAvahi::updateServices(AvahiClient* fp_client) { for(tServiceMap::const_iterator it = m_services.begin(); it != m_services.end(); ++it) { if (!it->second->mp_group) addService(it->second, fp_client); } }
void MDNSResponder::enableArduino(uint16_t port, bool auth){ addService("arduino", "tcp", port); addServiceTxt("arduino", "tcp", "tcp_check", "no"); addServiceTxt("arduino", "tcp", "ssh_upload", "no"); addServiceTxt("arduino", "tcp", "board", ARDUINO_BOARD); addServiceTxt("arduino", "tcp", "auth_upload", (auth) ? "yes":"no"); }
void init(QString serviceType) { delete browser; browser = new ZConfServiceBrowser(q); type = serviceType; QObject::connect(browser, SIGNAL(serviceEntryAdded(QString)), q, SLOT(addService(QString))); QObject::connect(browser, SIGNAL(serviceEntryRemoved(QString)), q, SLOT(removeService(QString))); q->clear(); browser->browse(type); }
boolean addRuleEngine(SensorinoRuleEngine* newRuleEngine){ if(ruleEngine && newRuleEngine) /* Only one engine allowed atm */ return false; ruleEngine = newRuleEngine; addService(newRuleEngine); return true; }
bool PeerInfo::addServiceInstance(const UUIDPtr& sid, const UUIDPtr& iid, SAPInfoPtr& sapInfo/*list<EndpointPtr>& list*/) { ServiceInfoPtr info; //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)INFO: PeerInfo::addServiceInstance - SID=%s\n"), sid->toString().c_str())); if (m_serviceMap.find(sid, info) == -1) { info.reset(new ServiceInfo(sid)); if (!addService(info)) { return false; } } return info->addServiceInstance(iid, sapInfo); }
// 初期化します ret_code_t initSenstickMetaDataService(uint8_t uuid_type) { // サービス構造体を初期化 memset(&context, 0, sizeof(senstick_metadata_service_t)); context.connection_handle = BLE_CONN_HANDLE_INVALID; // サービスを追加 addService(uuid_type); return NRF_SUCCESS; }
bool PeerInfo::addServiceInstance(const UUIDPtr& sid, const UUIDPtr& iid) { ServiceInfoPtr info; if (m_serviceMap.find(sid, info) == -1) { info.reset(new ServiceInfo(sid)); if (!addService(info)) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)Failed Service bind\n"))); return false; } ///ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)KKKKKK123213\n"))); } //ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%t|%T)KKKKKK54444444\n"))); return info->addServiceInstance(iid); }
void ContactsKopete::load(bool forceReload) { if (forceReload) { d->delayTimer.stop(); d->contactsToUpdate.clear(); } setEmitInhibited(true); if (!d->interface) { clear(); if (addService("kopete")) { // Item * item = const_cast < Item * > (& itemAt(0)); // item->title = i18n("Messaging client"); // item->description = i18n("Messaging client is not running"); } else { add(i18n("Unable to find Kopete"), "", KIcon("application-x-executable"), QVariant("http://kopete.kde.org")); } } else { if (forceReload) { // kDebug() << "full"; clear(); d->noOnlineContacts = false; QDBusReply < QStringList > contacts = d->interface->contactsByFilter("online"); if (!contacts.isValid()) { return; } foreach (const QString& contact, contacts.value()) { updateContactData(contact); } if (size() == 0) { add(i18n("No online contacts"), "", KIcon("user-offline"), QVariant()); d->noOnlineContacts = true; setSelfTitle(i18n("Contacts")); } else { setSelfTitle(i18nc("Contacts (number of online contacts)", "Contacts (%1)", QString::number(size()))); } } } setEmitInhibited(false); emit updated(); }
MprisControlPlugin::MprisControlPlugin(QObject* parent, const QVariantList& args) : KdeConnectPlugin(parent, args) , prevVolume(-1) { m_watcher = new QDBusServiceWatcher(QString(), QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForOwnerChange, this); connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &MprisControlPlugin::addService); connect(m_watcher, &QDBusServiceWatcher::serviceUnregistered, this, &MprisControlPlugin::removeService); //Add existing interfaces QStringList services = QDBusConnection::sessionBus().interface()->registeredServiceNames().value(); Q_FOREACH (const QString& service, services) { addService(service); }
void CZeroconfAvahi::addService(tServiceMap::mapped_type fp_service_info, AvahiClient* fp_client) { assert(fp_client); CLog::Log(LOGDEBUG, "CZeroconfAvahi::addService() named: %s type: %s port:%i", fp_service_info->m_name.c_str(), fp_service_info->m_type.c_str(), fp_service_info->m_port); //create the group if it doesn't exist if (!fp_service_info->mp_group) { if (!(fp_service_info->mp_group = avahi_entry_group_new(fp_client, &CZeroconfAvahi::groupCallback, this))) { CLog::Log(LOGDEBUG, "CZeroconfAvahi::addService() avahi_entry_group_new() failed: %s", avahi_strerror(avahi_client_errno(fp_client))); fp_service_info->mp_group = 0; return; } } // add entries to the group if it's empty int ret; if (avahi_entry_group_is_empty(fp_service_info->mp_group)) { if ((ret = avahi_entry_group_add_service_strlst(fp_service_info->mp_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, AvahiPublishFlags(0), fp_service_info->m_name.c_str(), fp_service_info->m_type.c_str(), NULL, NULL, fp_service_info->m_port, fp_service_info->mp_txt) < 0)) { if (ret == AVAHI_ERR_COLLISION) { char* alt_name = avahi_alternative_service_name(fp_service_info->m_name.c_str()); fp_service_info->m_name = alt_name; avahi_free(alt_name); CLog::Log(LOGNOTICE, "CZeroconfAvahi::addService: Service name collision. Renamed to: %s", fp_service_info->m_name.c_str()); addService(fp_service_info, fp_client); return; } CLog::Log(LOGERROR, "CZeroconfAvahi::addService(): failed to add service named:%s@$(HOSTNAME) type:%s port:%i. Error:%s :/ FIXME!", fp_service_info->m_name.c_str(), fp_service_info->m_type.c_str(), fp_service_info->m_port, avahi_strerror(ret)); return; } } // Tell the server to register the service if ((ret = avahi_entry_group_commit(fp_service_info->mp_group)) < 0) { CLog::Log(LOGERROR, "CZeroconfAvahi::addService(): Failed to commit entry group! Error:%s", avahi_strerror(ret)); // TODO what now? reset the group? free it? } }
void loadService(const char * path) { if(path==NULL || strlen(path)==0) { logN(TAG ,LOG_LEVEL_WARNING," path is empty"); return; } logI(TAG," prepare to load service from library:%s",path); void * dlHandler=NULL; char * errmsg; #ifdef LINUX dlHandler=dlopen(path,RTLD_NOW); if(dlHandler==NULL) { errmsg=dlerror(); logN("SERVICE",LOG_LEVEL_WARNING," can not open library:%s %s",path,errmsg); return; } #elif WIN32 #endif struct TGService * pService=NULL; if(checkLib(dlHandler,&pService)==0) { logD(TAG,"check lib successfully"); //FIXME use system seportor char * pLibName=NULL; getLibName(path,&pLibName); if(pLibName==NULL) { pLibName=(char *)malloc(sizeof(5)); memset(pLibName,0,10); sprintf(pLibName,"%d",pService->sID); } pService->serviceName=pLibName; addService(pService); } else { logW(TAG,"check library error"); } }
void PingPong::startClient() { //! [Searching for the service] discoveryAgent = new QBluetoothServiceDiscoveryAgent(QBluetoothAddress()); connect(discoveryAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(addService(QBluetoothServiceInfo))); connect(discoveryAgent, SIGNAL(finished()), this, SLOT(done())); connect(discoveryAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceScanError(QBluetoothServiceDiscoveryAgent::Error))); discoveryAgent->setUuidFilter(QBluetoothUuid(serviceUuid)); discoveryAgent->start(QBluetoothServiceDiscoveryAgent::FullDiscovery); //! [Searching for the service] setMessage(QStringLiteral("Starting server discovery. You are the right player")); // m_role is set to 2 if it is a client m_role = 2; Q_EMIT roleChanged(); }
status_t BnServiceManager::onTransact( uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { //printf("ServiceManager received: "); data.print(); switch(code) { case GET_SERVICE_TRANSACTION: { CHECK_INTERFACE(IServiceManager, data, reply); String16 which = data.readString16(); sp<IBinder> b = const_cast<BnServiceManager*>(this)->getService(which); reply->writeStrongBinder(b); return NO_ERROR; } break; case CHECK_SERVICE_TRANSACTION: { CHECK_INTERFACE(IServiceManager, data, reply); String16 which = data.readString16(); sp<IBinder> b = const_cast<BnServiceManager*>(this)->checkService(which); reply->writeStrongBinder(b); return NO_ERROR; } break; case ADD_SERVICE_TRANSACTION: { CHECK_INTERFACE(IServiceManager, data, reply); String16 which = data.readString16(); sp<IBinder> b = data.readStrongBinder(); status_t err = addService(which, b); reply->writeInt32(err); return NO_ERROR; } break; case LIST_SERVICES_TRANSACTION: { CHECK_INTERFACE(IServiceManager, data, reply); Vector<String16> list = listServices(); const size_t N = list.size(); reply->writeInt32(N); for (size_t i=0; i<N; i++) { reply->writeString16(list[i]); } return NO_ERROR; } break; default: return BBinder::onTransact(code, data, reply, flags); } }
bool CZeroconfAvahi::doPublishService(const std::string& fcr_identifier, const std::string& fcr_type, const std::string& fcr_name, unsigned int f_port, std::map<std::string, std::string> txt) { CLog::Log(LOGDEBUG, "CZeroconfAvahi::doPublishService identifier: %s type: %s name:%s port:%i", fcr_identifier.c_str(), fcr_type.c_str(), fcr_name.c_str(), f_port); ScopedEventLoopBlock l_block(mp_poll); tServiceMap::iterator it = m_services.find(fcr_identifier); if (it != m_services.end()) { //fcr_identifier exists, no update functionality yet, so exit return false; } //txt records to AvahiStringList AvahiStringList *txtList = NULL; for(std::map<std::string, std::string>::iterator it=txt.begin(); it!=txt.end(); it++) { txtList = avahi_string_list_add_pair(txtList, it->first.c_str(), it->second.c_str()); } //create service info and add it to service map tServiceMap::mapped_type p_service_info(new CZeroconfAvahi::ServiceInfo(fcr_type, fcr_name, f_port, txtList)); it = m_services.insert(it, std::make_pair(fcr_identifier, p_service_info)); //if client is already running, directly try to add the new service if ( mp_client && avahi_client_get_state(mp_client) == AVAHI_CLIENT_S_RUNNING ) { //client's already running, add this new service addService(p_service_info, mp_client); } else { CLog::Log(LOGDEBUG, "CZeroconfAvahi::doPublishService: client not running, queued for publishing"); } return true; }
void DNSSDNetworkBuilder::addServiceType( const QString& serviceType ) { kDebug()<<serviceType<<mServiceBrowserTable.contains(serviceType); if( mServiceBrowserTable.contains(serviceType)) return; // kDebug()<<serviceType; DNSSD::ServiceBrowser* serviceBrowser = new DNSSD::ServiceBrowser( serviceType, true ); connect( serviceBrowser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), SLOT(addService(DNSSD::RemoteService::Ptr)) ); connect( serviceBrowser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)), SLOT(removeService(DNSSD::RemoteService::Ptr)) ); if( mIsInit ) { ++mNoOfInitServiceTypes; connect( serviceBrowser, SIGNAL(finished()), SLOT(onServiceBrowserFinished()) ); } mServiceBrowserTable[serviceType] = serviceBrowser; serviceBrowser->startBrowse(); }
void ZeroConfProtocol::listDir( const KUrl& url ) { if (!dnssdOK()) return; const ZeroConfUrl zeroConfUrl( url ); ZeroConfUrl::Type type = zeroConfUrl.type(); switch (type) { case ZeroConfUrl::RootDir: serviceTypeBrowser = new ServiceTypeBrowser(zeroConfUrl.domain()); connect( serviceTypeBrowser, SIGNAL(serviceTypeAdded(QString)), SLOT(addServiceType(QString)) ); connect( serviceTypeBrowser, SIGNAL(finished()), SLOT(onBrowserFinished()) ); serviceTypeBrowser->startBrowse(); enterLoop(); break; case ZeroConfUrl::ServiceDir: if( !knownProtocols.contains(zeroConfUrl.serviceType()) ) { error( ERR_SERVICE_NOT_AVAILABLE, zeroConfUrl.serviceType() ); break; } serviceBrowser = new ServiceBrowser( zeroConfUrl.serviceType(), false, zeroConfUrl.domain() ); connect( serviceBrowser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)), SLOT(addService(DNSSD::RemoteService::Ptr)) ); connect( serviceBrowser, SIGNAL(finished()), SLOT(onBrowserFinished()) ); serviceBrowser->startBrowse(); enterLoop(); break; case ZeroConfUrl::Service: resolveAndRedirect( zeroConfUrl ); break; default: error( ERR_MALFORMED_URL, url.prettyUrl() ); } }
int ZPClient::add_cb(do_something_callback cb) { Parcel data, reply; sp<IBinder> binder = ClientBinder::getInstance(); if(binder == NULL) { return -1; } addService(binder, client_binder_key); data.writeInt32(getpid()); data.writeInt32((int32_t)cb); //data.writeStrongBinder(binder); printf("add_cb:0x%x \n",cb); if (client_binder_key == NULL) { data.writeInt32(-1); } else { int len = sizeof("client.test"); data.writeInt32((int)len * sizeof(unsigned char));//write length, only support 32 bits length yet Parcel::WritableBlob keyblob; data.writeBlob(len, &keyblob); memcpy(keyblob.data(), client_binder_key, len* sizeof(unsigned char)); } binder = getService(server_binder_key); if(binder == 0) { printf("binder service is not published, waiting... \n"); return -1; } binder->transact(TEST_ADD_CALLBACK_TRANSACTION, data, &reply); int status = reply.readInt32(); return status; }
void RenderAf::setTask( af::TaskExec *taskexec, MonitorContainer * monitoring, bool start) { if( isOffline()) { AF_ERR << "Render is offline."; return; } if( taskexec == NULL) { AF_ERR << "taskexec == NULL."; return; } addTask( taskexec); addService( taskexec->getServiceType()); if( monitoring ) monitoring->addEvent( af::Monitor::EVT_renders_change, m_id); if( start) { // Add exec pointer to events, // so on refresh, render will receive a task to execute. m_re.addTaskExec( taskexec); // Log: std::string str = "Starting task: "; str += taskexec->v_generateInfoString( false); appendTasksLog( str); } else { // This is multihost task. std::string str = "Captured by task: "; str += taskexec->v_generateInfoString( false); appendTasksLog( str); } }
void SSDPParser::parseServiceList( xmlDocPtr doc, const xmlChar* ns, const xmlChar* udn, xmlNodeSetPtr serviceNodeSet, xmlBufferPtr configBuf) { int i; for (i = 0; i < serviceNodeSet->nodeNr; i++) { xmlNodePtr serviceNode = serviceNodeSet->nodeTab[i]; xmlNodePtr childNode = serviceNode->xmlChildrenNode; xmlNodePtr next = childNode; char* serviceType = 0; char* serviceId = 0; char* controlURL = 0; char* eventSubURL = 0; /* check namespace */ if (strcmp((const char*)serviceNode->ns->href, (const char*)ns)) continue; while (next) { char* value = (char*)xmlNodeListGetString(doc, next->xmlChildrenNode, 1); bool found = false; if (!strcmp((const char*)next->name, "serviceType")) { serviceType = value; found = true; } else if (!strcmp((const char*)next->name, "serviceId")) { serviceId = value; found = true; } else if (!strcmp((const char*)next->name, "controlURL")) { controlURL = value; found = true; } else if (!strcmp((const char*)next->name, "eventSubURL")) { eventSubURL = value; found = true; } if (!found) xmlFree(value); next = xmlNextElementSibling(next); } if (udn && serviceId && serviceType && controlURL) addService((const char*)udn, serviceId, serviceType, controlURL, (const char*)configBuf->content, eventSubURL); else LOG_ERROR("resolve failed for service id %s", serviceId); if (serviceType) xmlFree(serviceType); if (serviceId) xmlFree(serviceId); if (controlURL) xmlFree(controlURL); if (eventSubURL) xmlFree(eventSubURL); } }
void CommunicationModule::init() { CommunicationService *commService = new CommunicationService(this); addService(commService->serviceName(), commService); RFIDMonitor::instance()->setDefaultService(ServiceType::KCommunicator, commService->serviceName()); }
void ServiceManager::addService(Service* service) { ServiceDescription desc; addService(service, desc); }
void ServiceManager::addService(Service* service) { addService(service, new ServiceDescription(service->getName(), map<string, string>())); }