Beispiel #1
0
bool Service::finishLoad()
{
    setStatus(SS_WORKING);
    if (!isShell())
    {
       if (true)
       {
           LoadServiceNotice notice;
           notice.shellServiceInfos.push_back(ServiceInfo(
               getServiceDockerID(),
               getServiceType(),
               getServiceID(),
               getServiceName(),
               getStatus(),
               getClientDockerID(),
               getClientSessionID()));
           Docker::getRef().broadcastToDockers(notice, false);
       }

        if (getServiceTrait(getServiceType()) == STrait_Multi)
        {
            RefreshServiceToMgrNotice refreshNotice;
            refreshNotice.shellServiceInfos.push_back(ServiceInfo(
                getServiceDockerID(),
                getServiceType(),
                getServiceID(),
                getServiceName(),
                getStatus(),
                getClientDockerID(),
                getClientSessionID()));

            for (auto sd : ServiceDepends)
            {
                if (getServiceTrait(sd.first) == STrait_Single )
                {
                    toService(sd.first, refreshNotice, nullptr);
                }
            }
        }

        LOGI(*this << "local service finish load. service=" << getServiceName() << ", id=" << getServiceID());
    }
    else
    {
        LOGI(*this << "remote service finish load. service=" << getServiceName() << ", id=" << getServiceID());
    }
    
    return true;
}
void WINAPI winServiceMain(DWORD, LPTSTR *)
{
    auto serviceName = getServiceName(GetCurrentProcessId());
    statusHandle = RegisterServiceCtrlHandler((const wchar_t*)serviceName.utf16(), serviceHandler);
    if (! statusHandle) {
        return;
    }

    // Service status
    serviceStatus.dwCurrentState = SERVICE_RUNNING;
    SetServiceStatus(statusHandle, &serviceStatus);

    // Main function
    int ret = 1;
    QString pathstr = getServiceFilePath(serviceName);
    if (!pathstr.isEmpty()) {
        auto argList = parseArguments(pathstr);
        auto *args = new char*[argList.count()];

        for (int i = 0; i < argList.count(); i++) {
            args[i] = argList[i].data();
        }
        ret = managerMain(argList.count(), args);
        delete[] args;
    }

    // Cleanup code must be executed before setting status to SERVICE_STOPPED
    tSystemInfo("Windows service stopped");
    Tf::releaseSystemLogger();

    // Service status
    serviceStatus.dwCurrentState = SERVICE_STOPPED;
    serviceStatus.dwWin32ExitCode = ret;
    SetServiceStatus(statusHandle, &serviceStatus);
}
bool InstallCommand::saveServiceConfig()
{
	RegistryHandler* registryHandler = new RegistryHandler(getServiceName());

	bool saved = registryHandler->writeServiceParams(*serviceParameters);

	delete registryHandler;

	return saved;
}
/*
 * Execute the 'install service' command
 */
int InstallCommand::execute()
{

	int commandStatus = COMMAND_FAILURE;
	bool lookupError = true;

	if (!parametersValid)
	{
		cerr << "JavaService install command parameters not valid, or incomplete";
	}
	else if (isServiceInstalled(lookupError) && !lookupError)
	{
		cerr << "The " << getServiceName() << " service is already installed";
	}
	else if (lookupError)
	{
		cerr << "Error while checking to see if " << getServiceName() << " service is installed" << endl;
		printLastError();
	}
	else
	{
		bool installed = installService();

		if (installed)
		{
			commandStatus = COMMAND_SUCCESS; // success, even if saving config fails

			if (!saveServiceConfig())
			{
				cerr << "Error saving " << getServiceName() << "  service configuration (service installed)" << endl;
				printLastError();
			}
		}
		else
		{
			cerr << "Error attempting to install " << getServiceName() << "  service" << endl;
			printLastError();
		}
	}

	return commandStatus;
}
Beispiel #5
0
bool EnigmaCache::isInServiceList( char *name )
{
	std::list<eServiceReferenceDVB>::iterator curService = serviceList.begin();

	while ( curService != serviceList.end() ) {
		if ( strcmp( getServiceName( *curService ).c_str(), name ) == 0 )
			return true;
		curService++;
	}
	return false;
}
Beispiel #6
0
Properties::Properties(const QString &objectPath,
                       const QString &interface,
                       QObject *parent)
    : SystemBusInterface(parent),
      mObjectPath(objectPath),
      mInterface(interface)
{
   qDebug() << "Connected" <<
               QDBusConnection::systemBus().connect(getServiceName(), getObjectPath(), getInterfaceName(), "PropertiesChanged", this, SLOT(PropertiesChanged(QString,QMap<QString,QVariant>,QList<QString>)));

}
Beispiel #7
0
void ServiceController::restart() {
    m_mutex->acquire();
    if (active && setState(getActualState()) && autorestart && startreq == NULL /*&& stopreq == NULL*/) {
        // restarts only if state has just changed from RUNNING/DEGRADED to NOT_EXISTING

        ACS_SHORT_LOG((LM_WARNING, "Restarting %s.", getServiceName().c_str()));
        stopreq = NULL;
        context->getRequestProcessor()->process(startreq = createControlledServiceRequest(START_SERVICE)); // enqueue service startup request
    }
    m_mutex->release();
}
Beispiel #8
0
bool Service::finishUnload()
{
    setStatus(SS_DESTROY);
    if (!isShell())
    {
        if (getServiceTrait(getServiceType()) == STrait_Multi)
        {
            RefreshServiceToMgrNotice refreshNotice;
            refreshNotice.shellServiceInfos.push_back(ServiceInfo(
                getServiceDockerID(),
                getServiceType(),
                getServiceID(),
                getServiceName(),
                getStatus(),
                getClientDockerID(),
                getClientSessionID()));
            for (auto sd : ServiceDepends)
            {
                if (getServiceTrait(sd.first) == STrait_Single)
                {
                    toService(sd.first, refreshNotice, nullptr);
                }
            }
        }

        UnloadedServiceNotice notice(getServiceType(), getServiceID());
        Docker::getRef().broadcastToDockers(notice, true);
        LOGI(*this << "local service finish unload. service=" << getServiceName() << ", id=" << getServiceID());
    }
    else
    {
        LOGI(*this << "remote service finish unload. service=" << getServiceName() << ", id=" << getServiceID());
    }
    for (auto tID : _repeatTimers)
    {
        SessionManager::getRef().cancelTimer(tID);
    }
    _repeatTimers.clear();
    return true;
}
Beispiel #9
0
bool EnigmaCache::getServiceRef( eString &name, eServiceReferenceDVB *eref )
{
	std::list<eServiceReferenceDVB>::iterator curService = serviceList.begin();

	while ( curService != serviceList.end() ) {
		if ( getServiceName( *curService ) == name ) {
			*eref = *curService;
			return true;
		}
		curService++;
	}
	return false;
}
void ServiceController::restart() {
    m_mutex->acquire();
    if (active && setState(getActualState()) && autorestart && startreq == NULL /*&& stopreq == NULL*/) {
        // restarts only if state has just changed from RUNNING/DEGRADED to NOT_EXISTING

        ACS_SHORT_LOG((LM_WARNING, "Restarting %s.", getServiceName().c_str()));
        stopreq = NULL;
        context->getRequestProcessor()->process(startreq = createControlledServiceRequest(START_SERVICE)); // enqueue service startup request
        //restart loggingService, otherwise remote logger get stuck
        if (ACSServiceController * c = dynamic_cast<ACSServiceController*>(this)) {
        	if (c->desc->getACSService() == NOTIFICATION_SERVICE &&
        			std::string(c->desc->getName()).compare("LoggingNotifyEventChannelFactory") == 0) {
        		std::ostringstream addr_str;
        		addr_str << "corbaloc::";
        		addr_str << c->desc->getHost() << ":" << acsServices[LOGGING_SERVICE].impport << "/";
        		addr_str << acsServices[LOGGING_SERVICE].imptype;

        		ACS_SHORT_LOG((LM_INFO, "Getting reference of %s using address: %s",
        				acsServices[LOGGING_SERVICE].imptype,
        				addr_str.str().c_str()));
        		int argc = 1;
        		char *argv[] = {"some_daemon"};
        		CORBA::ORB_var orb = CORBA::ORB_init (argc,argv,"TAO");
        		CORBA::Object_var obj = orb->string_to_object(addr_str.str().c_str());
        		if (CORBA::is_nil(obj.in())){
					ACS_SHORT_LOG(
							(LM_ERROR, "Failed to resolve reference '%s'.", addr_str.str().c_str()));
					return;
				}
				acsdaemon::LoggingServiceImp_var imp = acsdaemon::LoggingServiceImp::_narrow(obj.in());
				if (CORBA::is_nil(imp.in())) {
					ACS_SHORT_LOG(
							(LM_ERROR, "Failed to narrow reference '%s'.", addr_str.str().c_str()));
					return;
				}
				ACS_SHORT_LOG((LM_INFO, "Calling stop_logging_service"));
				imp->stop_logging_service("Log",
						acsdaemon::DaemonCallback::_nil(),
						c->desc->getInstanceNumber());
				ACS_SHORT_LOG((LM_INFO, "Calling stop_logging_service completed"));
				sleep(5);
				ACS_SHORT_LOG((LM_INFO, "Calling start_logging_service"));
				imp->start_logging_service("Log",
						acsdaemon::DaemonCallback::_nil(),
						c->desc->getInstanceNumber());
				ACS_SHORT_LOG((LM_INFO, "Calling start_logging_service completed"));
        	}
        }
    }
    m_mutex->release();
}
Beispiel #11
0
eString EnigmaCache::nextBouquetName( bool fromStartFlag ) 
{
	static std::list<eServiceReferenceDVB>::iterator curService;

	if ( fromStartFlag ) 
		curService = serviceList.begin();
	if ( curService == serviceList.end() )
		return "";

	eString name = getServiceName( *curService );
	curService++;
	if (!name.length()) name=".";
	return name;
}
Beispiel #12
0
eString getFullServiceName( const eServiceReferenceDVB &ref )
{
	eService *sv = eServiceInterface::getInstance()->addRef( ref );
	eString name;
	if ( sv ) {
		name = sv->service_name;
		eServiceInterface::getInstance()->removeRef( ref );
	}
	else {
		name = getServiceName( ref );
	}

	return name;
}
Beispiel #13
0
QJsonObject NetflixSource::toJSON()
{
	QJsonObject obj;

	if (kind == INVALID)
	{
		obj.insert("invalid_source", QString("invalid_source"));
		return obj;
	}

	obj.insert("name",  getName());
	obj.insert("service", getServiceName());
	obj.insert("kind", kindToStr(kind));
	return obj;
}
Beispiel #14
0
void EnigmaCache::readOneChannelProgramData( bool partOfGlobal, eServiceReferenceDVB ref, time_t from, time_t to, bool includeDescriptionsFlag )
{
        timeMapPtr evmap = cacheP->getTimeMapPtr( ref, from, to );
        if ( !evmap )
		return;

	timeMap::const_iterator ibegin = evmap->lower_bound( from );
	if ((ibegin != evmap->end()) && (ibegin != evmap->begin())) {
		if ( ibegin->first != from )
                	--ibegin;
	}
        else
		ibegin=evmap->begin();

	timeMap::const_iterator iend = evmap->lower_bound( to );

	struct ProgramData p;
	p.channelName = getServiceName( ref );

	eServiceReferenceDVB &rref=(eServiceReferenceDVB&)ref;
        int tsidonid =
              (rref.getTransportStreamID().get()<<16)|rref.getOriginalNetworkID().get();

	for (timeMap::const_iterator event(ibegin); event != iend; ++event) {
		EITEvent *ev = new EITEvent(*event->second,tsidonid, event->second->type);

		// This will be done in receiveData, but doing
		// it also here prevents all the work in between
		if (((ev->start_time+ev->duration)>= from) && (ev-> start_time <= to)) {

			p.name = "";
			p.flags = 0;

			if ( parseProgramData( ev, p, includeDescriptionsFlag, true ) ) {
				p.flags |= programDataFlagFromCache;
				p.startTime = ev->start_time;
				p.duration = ev->duration;
				p.idxFic=-1;
				p.offset=-1;
				if ( partOfGlobal )
					/*emit*/ gotData( p );
				else
					/*emit*/ gotOneChannelData( p );
			}
		}
		delete ev;
	}
}
Beispiel #15
0
eString ENgrab::startxml( const char* descr )
{
	eString xmlstart;

	xmlstart+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
	xmlstart+=" <neutrino commandversion=\"1\">\n";
	xmlstart+="   <record command=\"record\">\n";
	xmlstart+="    <channelname>"+getServiceName()+"</channelname>\n";//übernommen von trh
	xmlstart+="    <epgtitle>"+(descr?eString(descr):getEPGTitle())+"</epgtitle>\n"; //übernommen von trh
	xmlstart+="    <onidsid>123456</onidsid>\n"; // keine ahnung aber wies aussieht wird die sid und die onid nicht gebraucht von ngrab
	xmlstart+="    <epgid>123456</epgid>\n"; // und die epgid auch nicht
	xmlstart+="    <videopid>"+eString().sprintf("%d", Decoder::current.vpid)+"</videopid>\n";
	xmlstart+="    <audiopids selected=\""+eString().sprintf("%d", Decoder::current.apid)+"\">\n";
	eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI();
	if (!sapi || !sapi->service)
		xmlstart+="       <audio pid=\""+eString().sprintf("%d", Decoder::current.apid)+"\" name=\"standard\"/>\n";
	else
	{
		std::list<eDVBServiceController::audioStream> &audioStreams = sapi->audioStreams;
		for (std::list<eDVBServiceController::audioStream>::iterator it = audioStreams.begin(); it != audioStreams.end(); ++it)
			xmlstart+="       <audio pid=\""+eString().sprintf("%d", it->pmtentry->elementary_PID) + "\" name=\"" + it->text + "\"/>\n";
	}
	xmlstart+="    </audiopids>\n";
	xmlstart+="  </record>\n";
	xmlstart+=" </neutrino>\n";


#ifdef TMP_NgrabXML
	std::fstream xmlstartf;
	char* Name0 =TMP_NgrabXML;
	xmlstartf.open(Name0,ios::out);
	xmlstartf<<xmlstart<<endl;
	xmlstartf.close();
#endif

	return xmlstart;
}
Beispiel #16
0
void ChannelManager::rebuildFromBox( void )
{
	if ( fromBoxP != NULL )
		fromBoxP->hide();

	fromBoxP =  makeNewListbox(
                this,
                5,5,
		CM_TO_BOX_X - 10, clientrect.height() - CM_BUTTON_HEIGHT - 20
        );


	// Fill box from bouquet

	int entryNo = 0;
	std::list<eServiceReferenceDVB>::iterator curService = serviceList->begin();

        while ( curService != serviceList->end() ) {
                eString name = getServiceName( *curService );
                eString mapped = getMappedName( name );
		if(
		    (showFlags & CM_SHOW_UNKNOWN)
		    || mapped.length()==0
		  )
		{
		new eListBoxEntryText(fromBoxP, name, (void*) entryNo );
		if(entryNo==0)
		  toLabelP->setText( mapped);
		entryNo++;
		}
                curService++;
        }

	CONNECT( fromBoxP->selchanged, ChannelManager::fromSelectionChanged );
	CONNECT( fromBoxP->selected, ChannelManager::fromSelectedItem );
}
Beispiel #17
0
void GuiCHI::pong(string id, int miliseconds) {
	sm.send(
			"{\"type\" : \"internal\" , \"node\" : \"ping\" , \"name\" : \"" + getServiceName() +
			"\" , \"version\" : \"1\""
			+ (id.length() > 0 ? " , \"id\" : \"" + getInstallID() + "\"" : "") + "}");//todo:@NAVIDI wtf?
}
Beispiel #18
0
PendingReply *ObjectProxy::doExecute(const QString &methodName, const QVariantList &parameters, bool expectReturnValue) const
{
	return getCBus().execute(getServiceName(), getObjectName(), methodName, parameters, expectReturnValue);
}
AcSensorBridge::AcSensorBridge(AcSensor *acSensor, AcSensorSettings *settings,
							   bool isSecundary, QObject *parent) :
	DBusBridge(getServiceName(acSensor, settings, isSecundary), true, parent)
{
	Q_ASSERT(acSensor != 0);
	Q_ASSERT(settings != 0);
	connect(acSensor, SIGNAL(destroyed()), this, SLOT(deleteLater()));
	connect(settings, SIGNAL(destroyed()), this, SLOT(deleteLater()));

	bool isGridmeter =
		(isSecundary ? settings->l2ServiceType() : settings->serviceType()) == "grid";
	// Changes in QT properties will not be propagated to the D-Bus at once, but in 1000ms/2500ms
	// intervals.
	setUpdateInterval(isGridmeter ? 1000 : 2500);

	produce(acSensor, "connectionState", "/Connected");
	produce(acSensor, "errorCode", "/ErrorCode");

	producePowerInfo(acSensor->total(), "/Ac", isGridmeter);
	producePowerInfo(acSensor->l1(), "/Ac/L1", isGridmeter);
	producePowerInfo(acSensor->l2(), "/Ac/L2", isGridmeter);
	producePowerInfo(acSensor->l3(), "/Ac/L3", isGridmeter);

	if (isSecundary || settings->serviceType() == "pvinverter")
		produce(settings, isSecundary ? "l2Position" : "position", "/Position");
	produce(settings, isSecundary ? "l2ProductName" : "productName", "/ProductName");
	produce(settings, isSecundary ? "l2CustomName" : "customName", "/CustomName");

	QString processName = QCoreApplication::applicationName();
	// The values of the items below will not change after creation, so we don't
	// need an update mechanism.
	produce("/Mgmt/ProcessName", processName);
	produce("/Mgmt/ProcessVersion", QCoreApplication::applicationVersion());
	produce("/FirmwareVersion", acSensor->firmwareVersion());
	int productId = 0;
	switch (acSensor->protocolType()) {
	case AcSensor::Em24Protocol:
		productId = isSecundary ?
			VE_PROD_ID_CARLO_GAVAZZI_EM24_PIGGY_BACK :
			VE_PROD_ID_CARLO_GAVAZZI_EM24;
		break;
	case AcSensor::Et112Protocol:
		productId = VE_PROD_ID_CARLO_GAVAZZI_ET112;
		break;
	case AcSensor::Em340Protocol:
		productId = isSecundary ?
			VE_PROD_ID_CARLO_GAVAZZI_ET340_PIGGY_BACK :
			VE_PROD_ID_CARLO_GAVAZZI_ET340;
		break;
	default:
		Q_ASSERT(false);
		break;
	}
	produce("/ProductId", productId);
	produce("/DeviceType", acSensor->deviceType());
	produce("/Mgmt/Connection", acSensor->portName());

	int deviceInstance = isSecundary ?
		settings->l2DeviceInstance() :
		settings->deviceInstance();
	produce("/DeviceInstance", deviceInstance);
	produce("/Serial", acSensor->serial());

	registerService();
}