示例#1
0
void TranslationInterface::selectService(int index)
{
    if (index == m_serviceItem->index() || index < 0 || index >= m_services->count())
        return;

    m_settings->setValue("SelectedService", index);
    createService(index);
}
示例#2
0
/*!
 * Creates a new session and sends the session key to the web browser.
 *
 * Subclasses may override this function to perform custom session initialization,
 * but they must call the base class implementation in order to update the internal
 * session database and fetch a new session ID.
 */
int QxtHttpSessionManager::newSession()
{
    QMutexLocker locker(&qxt_d().sessionLock);
    int sessionID = createService();
    QUuid key;
    do
    {
        key = QUuid::createUuid();
    }
    while (qxt_d().sessionKeys.contains(key));
    qxt_d().sessionKeys[key] = sessionID;
    postEvent(new QxtWebStoreCookieEvent(sessionID, qxt_d().sessionCookieName, key.toString()));
    return sessionID;
}
示例#3
0
void Process::Stub::onTransact(int32_t what, int32_t arg1, int32_t arg2, const sp<Object>& obj, const sp<Bundle>& data, const sp<Object>& result) {
    switch (what) {
    case MSG_CREATE_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        createService(intent, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_START_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        int32_t flags = arg1;
        int32_t startId = arg2;
        sp<IBinder> binder = data->getBinder("binder");
        startService(intent, flags, startId, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_STOP_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        if (binder == nullptr) {
            stopService(intent);
        } else {
            stopService(intent, RemoteCallback::Stub::asInterface(binder));
        }
        break;
    }
    case MSG_BIND_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<ServiceConnection> conn = object_cast<ServiceConnection>(data->getObject("conn"));
        int32_t flags = data->getInt("flags");
        sp<IBinder> binder = data->getBinder("binder");
        bindService(intent, conn, flags, RemoteCallback::Stub::asInterface(binder));
        break;
    }
    case MSG_UNBIND_SERVICE: {
        sp<Intent> intent = object_cast<Intent>(data->getObject("intent"));
        sp<IBinder> binder = data->getBinder("binder");
        if (binder == nullptr) {
            unbindService(intent);
        } else {
            unbindService(intent, RemoteCallback::Stub::asInterface(binder));
        }
        break;
    }
    default:
        Binder::onTransact(what, arg1, arg2, obj, data, result);
        break;
    }
}
示例#4
0
Ejs *ejsCreateVM(int argc, cchar **argv, int flags)
{
    EjsService  *sp;
    Ejs         *ejs;

    if ((ejs = mprAllocObj(Ejs, manageEjs)) == NULL) {
        return 0;
    }
    sp = ejs->service = MPR->ejsService;
    if (sp == 0) {
        sp = ejs->service = createService();
        defineSharedTypes(ejs);
    }
    ejs->empty = 1;
    ejs->state = mprAllocZeroed(sizeof(EjsState));
    ejs->argc = argc;
    ejs->argv = argv;
    ejs->name = sfmt("ejs-%d", sp->seqno++);
    ejs->dispatcher = mprCreateDispatcher(ejs->name, MPR_DISPATCHER_ENABLED);
    ejs->mutex = mprCreateLock(ejs);
    ejs->dontExit = sp->dontExit;
    ejs->flags |= (flags & (EJS_FLAG_NO_INIT | EJS_FLAG_DOC | EJS_FLAG_HOSTED));
    ejs->hosted = (flags & EJS_FLAG_HOSTED) ? 1 : 0;

    ejs->global = ejsCreateBlock(ejs, 0);
    mprSetName(ejs->global, "global");
    ejsDefineGlobalNamespaces(ejs);

    /*
        Modules are not marked in the modules list. This way, modules are collected when not referenced.
        Workers are marked. This way workers are preserved to run in the background until they exit.
     */
    ejs->modules = mprCreateList(-1, MPR_LIST_STATIC_VALUES);
    ejs->workers = mprCreateList(0, 0);

    initStack(ejs);
    initSearchPath(ejs, 0);
    mprAddItem(sp->vmlist, ejs);

    if (ejs->hasError || mprHasMemError(ejs)) {
        ejsDestroyVM(ejs);
        mprError("Cannot create VM");
        return 0;
    }
    mprLog(5, "ejs: create VM");
    return ejs;
}
示例#5
0
ObjectDesc *init_zero_dep_without_thread(char *ifname, char *depname, MethodInfoDesc * methods, jint size, char *subname)
{
    ClassDesc   *cd;
    u32         index;
    Proxy       *instance;
    u32         depIndex;

    cd                          = createDZClass(zeroLib, ifname, methods, size / sizeof(MethodInfoDesc), subname);
    cd->proxyVtable             = cd->vtable;
    instance                    = allocProxyInDomain(domainZero, cd, NULL, domainZero->id, 0);
    instance->vtable            = cd->vtable;  /* NOT a real proxy */
    instance->targetDomain      = NULL;  /* indicates direct portal */
    instance->targetDomainID    = domainZero->id;
    depIndex                    = createService(domainZero, (ObjectDesc *) instance, cd, NULL);

    if (depname != NULL)
        registerPortal(domainZero, (ObjectDesc *) instance, depname);
    index = depIndex;

    return (ObjectDesc *) instance;
}
void DiscoveryOperator::init()
{
  ROS_INFO("\n[Discovery Operator]\n\tSubscribing to topics...");
  
  //createSubscriber("hello_sub", "agent"+itos(myLocalConfig->getAgentId())+"/hello_topic", &DiscoveryOperator::helloCallback, this); // Connection Subscriber
  createSubscriber("from_json", "HelloMsg/from_json", &DiscoveryOperator::helloCallback, this); // Connection Subscriber

  createSubscriber("local_ip_address", "local_ip_address", &DiscoveryOperator::IPAddressCallback, this); // IP Address Subscriber

  createService(std::string("neighbor_service"), std::string("agent"+itos(myLocalConfig->getAgentId())+"/neighbor_service"), &DiscoveryOperator::neighborServiceCallback, this);
 
  createPublisher<coros_messages::NeighborhoodMsg>("neighborhood_pub", "agent"+itos(myLocalConfig->getAgentId())+"/neighborhood_list"); // Neighborhood Publisher

  createPublisher<coros_messages::HelloMsg>("to_json", "HelloMsg/to_json"); // To JSON Publisher
  
  ROS_INFO("\n[Discovery Operator]\n\tSubscription to topics completed.\n\t\t[Action]: Start broadcasting HELLO messages.\n");

  ros::AsyncSpinner spinner (2);
  spinner.start();
  broadcast_hello_message(myLocalConfig->getBroadcastFrequency());
  spinner.stop();

}
/** Callback function. Once the service is discovered this callback function will be invoked
* @param servQuery left for future purpose, currently unused
* @param error_code the error code
* @param commHandle the communication handle used to invoke the interfaces
 */
void subCallback(ServiceQuery *servQuery, int32_t error_code, CommHandle *commHandle) {

    int (**receive)(void (*)(char *, Context));
    ServiceSpec *serviceSpec = (ServiceSpec *) parseServiceSpec("./serviceSpecs/thermostat-spec.json");
    if (serviceSpec) {
        advertiseService(serviceSpec);
        CommHandle *serviceHandle = createService(NULL, serviceSpec);
        mypublisher = commInterfacesLookup(serviceHandle, "publish");
        topic = serviceSpec->service_name;
    }
    if (commHandle != NULL) {
        receive = commInterfacesLookup(commHandle, "receive");
        if (receive != NULL) {
            while (1) {  // Infinite Event Loop
                (*receive)(clientMessageCallback);
                sleep(2);
            }
        } else {
            fprintf(stderr, "Interface lookup failed\n");
        }
    } else {
        fprintf(stderr, "Comm Handle is NULL\n");
    }
}
示例#8
0
/**
 * @brief Create a %BLE Service.
 *
 * With a %BLE server, we can host one or more services.  Invoking this function causes the creation of a definition
 * of a new service.  Every service must have a unique UUID.
 * @param [in] uuid The UUID of the new service.
 * @return A reference to the new service object.
 */
BLEService* BLEServer::createService(const char* uuid) {
	return createService(BLEUUID(uuid));
}
示例#9
0
void
ServiceSummaryTest::standaloneTest()
{
    static const char * manifestJson =
        "{"
        "    \"type\": \"standalone\","
        "    \"ServiceLibrary\": \"lib.dll\","
        "    \"strings\": { "
        "        \"en\": { "
        "            \"title\": \"Image Manipulation Plugin\", "
        "            \"summary\": \"Allows authorized websites to manipulate images on your computer.  This includes the ability to rotate, crop, and scale images on your computer from within a web browser.\""
        "        },"
        "        \"bg\": { "
        "            \"title\": \"Инструмент За Снимки\","
        "            \"summary\": \"С този инструмент можеш да манипулираш снимки.\""
        "        }"
        "    },"
        "    \"permissions\" : ["
        "        \"foo\","
        "        \"bar\","
        "        \"baz\""
        "    ]"
        "}";

    std::vector<boost::filesystem::path> filesToTouch;
    filesToTouch.push_back(boost::filesystem::path(("lib.dll")));

    // now create it
    createService(manifestJson, filesToTouch);

    // now load it
    bp::service::Summary s;
    std::string error;
    CPPUNIT_ASSERT( s.detectService(m_testServiceDir, error) );

    //  --- now check everything is as expected --- 
    CPPUNIT_ASSERT( s.type() == bp::service::Summary::Standalone );
    CPPUNIT_ASSERT( !s.typeAsString().compare("standalone") );

    // now check that shutdownDelaySecs is set properly
    CPPUNIT_ASSERT_EQUAL( s.shutdownDelaySecs(), -1 );

    // instantiated from a non name/version dir.  they should be left
    // empty
    CPPUNIT_ASSERT_MESSAGE( s.name().c_str(), s.name().empty() );
    CPPUNIT_ASSERT_MESSAGE( s.version().c_str(), s.version().empty() );

    // should NOT be out of date
    CPPUNIT_ASSERT( !s.outOfDate() );
    
    // check localizations
    std::string title, summary;

    // first en should serve up ok
    CPPUNIT_ASSERT( s.localization("en", title, summary) );
    CPPUNIT_ASSERT( !title.compare("Image Manipulation Plugin") );    

    // and bg should serve up ok
    CPPUNIT_ASSERT( s.localization("bg", title, summary) );
    CPPUNIT_ASSERT( !title.compare("Инструмент За Снимки") );

    // and german should default to english
    CPPUNIT_ASSERT( s.localization("de", title, summary) );
    CPPUNIT_ASSERT( !title.compare("Image Manipulation Plugin") );    

    // empty dependent service stuff
    CPPUNIT_ASSERT_MESSAGE( s.usesService().c_str(), s.usesService().empty() );

    CPPUNIT_ASSERT( s.isInitialized() );

    // permissions load OK?
    std::set<std::string> wantPerms;
    wantPerms.insert("foo");
    wantPerms.insert("bar");
    wantPerms.insert("baz");

    std::set<std::string> havePerms = s.permissions();
    CPPUNIT_ASSERT( wantPerms == havePerms );    

    // now verify if we update the disk representation things are
    // considered "out of date"
    tearDown();
    setUp();
    createService(manifestJson, filesToTouch);
    CPPUNIT_ASSERT( s.outOfDate() );
}
示例#10
0
Commander::Commander()
{
	service_ = createService();
}
示例#11
0
int main(int argc, char* argv[])
{
  try
  {
    if(argc != 3)
    {
      //TODO: help message
      std::cout << "\n<< Help usage message >>\n" << std::endl;
      return SERVICE_PARAMETERS_ERROR;
    }
    std::string serviceType(argv[1]);
    std::transform(serviceType.begin(), serviceType.end(), serviceType.begin(), ::tolower);

    if(!checkServiceType(serviceType))
      return UNKNOWN_SERVICE_TYPE;

    int listeningPort = std::stoi(argv[2]);

    try
    {
      terrama2::core::initializeTerraMA();
      terrama2::core::registerFactories();
    }
    catch(...)
    {
      return TERRAMA2_INITIALIZATION_ERROR;
    }

    auto& serviceManager = terrama2::core::ServiceManager::getInstance();
    serviceManager.setServiceType(serviceType);
    serviceManager.setListeningPort(listeningPort);

    // service context
    // this is needed for calling the destructor of the service before finalizing terralib
    {
      // Must initialize the python interpreter before creating any thread.
      terrama2::services::analysis::core::initInterpreter();

      QCoreApplication app(argc, argv);

      std::shared_ptr<terrama2::core::DataManager> dataManager;
      std::shared_ptr<terrama2::core::Service> service;
      std::shared_ptr<terrama2::core::ProcessLogger> logger;
      std::tie(dataManager, service, logger) = createService(serviceType);
      if(!service.get()
          || !dataManager.get())
        return SERVICE_LOAD_ERROR;

      auto tcpManager = std::make_shared<terrama2::core::TcpManager>(dataManager, logger);
      if(!tcpManager->listen(QHostAddress::Any, serviceManager.listeningPort()))
      {
        std::cerr << QObject::tr("\nUnable to listen to port: ").toStdString() << serviceManager.listeningPort() << "\n" << std::endl;

        exit(TCP_SERVER_ERROR);
      }

      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::listeningPortUpdated, tcpManager.get(), &terrama2::core::TcpManager::updateListeningPort);

      QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::startProcess, service.get(), &terrama2::core::Service::addToQueue);
      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::numberOfThreadsUpdated, service.get(), &terrama2::core::Service::updateNumberOfThreads);

      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::logConnectionInfoUpdated, logger.get(), &terrama2::core::ProcessLogger::setConnectionInfo);

      QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::stopSignal, service.get(), &terrama2::core::Service::stopService);
      QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::closeApp, &app, &QCoreApplication::quit);

      app.exec();
    }

    try
    {
      terrama2::core::finalizeTerraMA();

      //Service closed by load error
      if(!serviceManager.serviceLoaded())
        return SERVICE_LOAD_ERROR;
    }
    catch(...)
    {
      return TERRAMA2_FINALIZATION_ERROR;
    }
  }
  catch(boost::exception& e)
  {
    TERRAMA2_LOG_ERROR() << boost::diagnostic_information(e);
  }
  catch(std::exception& e)
  {
    TERRAMA2_LOG_ERROR() << e.what();
  }
  catch(...)
  {
    TERRAMA2_LOG_ERROR() << QObject::tr("\n\nUnkown Exception...\n");
  }

  return 0;
}
示例#12
0
void serviceMgrTaskFxn(UArg arg0, UArg arg1)
{
    MessageQCopy_Handle msgq;
    UInt32 local;
    UInt32 remote;
    Char msg[HDRSIZE + sizeof(struct omx_connect_req)];
    struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)msg;
    struct omx_connect_rsp * rsp = (struct omx_connect_rsp *)hdr->data;
    struct omx_connect_req * req = (struct omx_connect_req *)hdr->data;
    struct omx_disc_req * disc_req = (struct omx_disc_req *)hdr->data;
    struct omx_disc_rsp * disc_rsp = (struct omx_disc_rsp *)hdr->data;
    UInt16 dstProc;
    UInt16 len;
    UInt32 newAddr = 0;


#ifdef BIOS_ONLY_TEST
    dstProc = MultiProc_self();
#else
    dstProc = MultiProc_getId("HOST");
#endif

    msgq = MessageQCopy_create(SERVICE_MGR_PORT, &local);

    System_printf("serviceMgr: started on port: %d\n", SERVICE_MGR_PORT);

    /*
     * Yeah, this is horrible.
     *
     * Without it, we might try to send a message before buffers are
     * available in the ring, and then the code just bluntly fails.
     *
     * The real fix is to pause initialization until buffers are available,
     * or allow users to get notified when a buffer is available after
     * they failed getting one.
     */
    Task_sleep(500);

    NameMap_register("rpmsg-omx", SERVICE_MGR_PORT);

    while (1) {
       MessageQCopy_recv(msgq, (Ptr)msg, &len, &remote, MessageQCopy_FOREVER);
       System_printf("serviceMgr: received msg type: %d from addr: %d\n",
                      hdr->type, remote);
       switch (hdr->type) {
           case OMX_CONN_REQ:
            /* This is a request to create a new service, and return
             * it's connection endpoint.
             */
            System_printf("serviceMgr: CONN_REQ: len: %d, name: %s\n",
                 hdr->len, req->name);

            rsp->status = createService(req->name, &newAddr);

            hdr->type = OMX_CONN_RSP;
            rsp->addr = newAddr;
            hdr->len = sizeof(struct omx_connect_rsp);
            len = HDRSIZE + hdr->len;
            break;

           case OMX_DISC_REQ:
            /* Destroy the service instance at given service addr: */
            System_printf("serviceMgr: OMX_DISCONNECT: len %d, addr: %d\n",
                 hdr->len, disc_req->addr);

            disc_rsp->status = deleteService(disc_req->addr);

            /* currently, no response expected from rpmsg_omx: */
            continue;
#if 0       // rpmsg_omx is not listening for this ... yet.
            hdr->type = OMX_DISC_RSP;
            hdr->len = sizeof(struct omx_disc_rsp);
            len = HDRSIZE + hdr->len;
            break;
#endif

           default:
            System_printf("unexpected msg type: %d\n", hdr->type);
            hdr->type = OMX_NOTSUPP;
            break;
       }

       System_printf("serviceMgr: Replying with msg type: %d to addr: %d "
                      " from: %d\n",
                      hdr->type, remote, local);
       MessageQCopy_send(dstProc, remote, local, msg, len);
    }
}
示例#13
0
TranslationInterface::TranslationInterface(QObject *parent)
    : QObject(parent)
    , m_service(NULL)
    , m_serviceItem(NULL)
    , m_busy(false)
    , m_suppressRetranslate(false)
    , m_sourceLanguages(new LanguageListModel(this))
    , m_targetLanguages(new LanguageListModel(this))
    , m_sourceLanguage(NULL)
    , m_targetLanguage(NULL)
    , m_dict(new DictionaryModel(this))
#ifdef Q_OS_SAILFISH
    , m_settings(new QSettings("harbour-taot", "taot", this))
#else
    , m_settings(new QSettings(QCoreApplication::organizationName(), "taot", this))
# ifdef WITH_ANALYTICS
    , m_analytics(new QAmplitudeAnalytics(AMPLITUDE_API_KEY))
# endif
#endif
{
#ifdef WITH_ANALYTICS
# if defined(Q_OS_SAILFISH)
    QString path = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation);
    path.append(QDir::separator()).append("harbour-taot");
    QDir dir(path);
    if (!dir.exists())
        dir.mkpath(".");
    m_analytics.reset(new QAmplitudeAnalytics(AMPLITUDE_API_KEY,
                                              dir.filePath("QtInAppAnalytics.ini")));

    // HACK: Get proper manufacturer and model values
    // TODO: Remove when QtSystemInfo is allowed in Harbour
    QAmplitudeAnalytics::DeviceInfo di = m_analytics->deviceInfo();
    org::nemo::ssu ssu("org.nemo.ssu", "/org/nemo/ssu", QDBusConnection::systemBus());
    di.manufacturer = ssu.displayName(0 /*Ssu::DeviceManufacturer*/);
    di.model = ssu.displayName(1 /*Ssu::DeviceModel*/);
    m_analytics->setDeviceInfo(di);
# endif

    updatePersistentProperties();

    m_privacyLevel = PrivacyLevel(m_settings->value("PrivacyLevel", UndefinedPrivacy).toInt());
    if (m_privacyLevel != NoPrivacy)
        m_analytics->setPrivacyEnabled(true);

    if (m_settings->contains("AppInfo/CurrentVersion")) {
        const QString version = m_settings->value("AppInfo/CurrentVersion").toString();
        if (version != QCoreApplication::applicationVersion()) {
            QVariantMap props;
            props.insert("Old Version", version);
            props.insert("New Version", QCoreApplication::applicationVersion());
            m_analytics->trackEvent("Upgrade", props);

            m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion());
        }
    } else {
        QVariantMap props;
        props.insert("Version", QCoreApplication::applicationVersion());
        m_analytics->trackEvent("Installation", props);

        m_settings->setValue("AppInfo/CurrentVersion", QCoreApplication::applicationVersion());
    }

    if (m_privacyLevel == NoPrivacy) {
        trackSessionStart();
    }
#endif

    setTranscription(new SourceTranslatedTextPair());
    setTranslit(new SourceTranslatedTextPair());

    QStringList list;
    list.insert(GoogleTranslateService, GoogleTranslate::displayName());
    list.insert(MicrosoftTranslatorService, MicrosoftTranslator::displayName());
    list.insert(YandexTranslateService, YandexTranslate::displayName());
    list.insert(YandexDictionariesService, YandexDictionaries::displayName());
    m_services = new TranslationServicesModel(list, this);

    createService(m_settings->value("SelectedService", 0).toUInt());

    connect(this, SIGNAL(sourceLanguageChanged()), SLOT(retranslate()));
    connect(this, SIGNAL(targetLanguageChanged()), SLOT(retranslate()));
    connect(this, SIGNAL(sourceLanguageChanged()), SIGNAL(canSwapLanguagesChanged()));
    connect(this, SIGNAL(targetLanguageChanged()), SIGNAL(canSwapLanguagesChanged()));
    connect(this, SIGNAL(detectedLanguageChanged()), SIGNAL(canSwapLanguagesChanged()));
    connect(this, SIGNAL(error(QString)), SLOT(onError(QString)));

#ifdef Q_OS_SYMBIAN
    connect(qApp, SIGNAL(visibilityChanged()), this, SIGNAL(appVisibilityChanged()));
#endif

#ifdef Q_OS_BLACKBERRY
    m_invoker = new bb::system::InvokeManager();
    connect(m_invoker, SIGNAL(invoked(bb::system::InvokeRequest)),
            this, SLOT(onInvoked(bb::system::InvokeRequest)));
#endif
}
示例#14
0
int main(int argc, char* argv[])
{
  try
  {
    std::string appName = boost::filesystem::basename(argv[0]);

    po::options_description desc("Allowed options");
    desc.add_options()
        ("help,h", "show help message.")
        ("version,v", "Show TerraMA2 version.")
        ("service,s", po::value<std::string>()->required(), "Service to be started.\nValid options:\n\t- ANALYSIS\n\t- COLLECTOR\n\t- VIEW")
        ("port,p", po::value<int>()->required(), "Port the service will listen.")
    ;
    po::positional_options_description positionalOptions;
        positionalOptions.add("service", 1);
        positionalOptions.add("port", 1);

    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(desc)
                      .positional(positionalOptions).run(),
                    vm);

    if (vm.count("help")) {
        std::cout << "usage: "+appName+" [--version] [--help] service port" << "\n";
        std::cout << desc << std::endl;
        return 0;
    }

    if (vm.count("version")) {
        std::cout << "TerraMA2 " << TERRAMA2_VERSION_STRING << std::endl;
        return 0;
    }

    po::notify(vm);

    std::string serviceType(vm["service"].as<std::string>());
    std::transform(serviceType.begin(), serviceType.end(), serviceType.begin(), ::tolower);

    if(!checkServiceType(serviceType))
      return UNKNOWN_SERVICE_TYPE;

    int listeningPort = vm["port"].as<int>();

    terrama2::core::TerraMA2Init terramaRaii(serviceType, listeningPort);
    terrama2::core::registerFactories();


    auto& serviceManager = terrama2::core::ServiceManager::getInstance();
    serviceManager.setServiceType(serviceType);
    serviceManager.setListeningPort(listeningPort);

    // service context
    // this is needed for calling the destructor of the service before finalizing terralib
    {
      TERRAMA2_LOG_INFO() << QObject::tr("Initializing TerraMA2 service...");
      TERRAMA2_LOG_INFO() << QObject::tr("Starting %1 service.").arg(QString::fromStdString(serviceType));

      // Must initialize the python interpreter before creating any thread.
      terrama2::services::analysis::core::PythonInterpreterInit pythonInterpreterInit;

      QCoreApplication app(argc, argv);

      // Changes in the initialization order may cause locale problems
      std::locale::global(std::locale::classic());

      std::shared_ptr<terrama2::core::DataManager> dataManager;
      std::shared_ptr<terrama2::core::Service> service;
      std::shared_ptr<terrama2::core::ProcessLogger> logger;
      std::tie(dataManager, service, logger) = createService(serviceType);
      if(!service.get()
          || !dataManager.get()
          || !logger.get())
        return SERVICE_LOAD_ERROR;

      auto tcpManager = std::make_shared<terrama2::core::TcpManager>(dataManager, logger);
      if(!tcpManager->listen(QHostAddress::Any, serviceManager.listeningPort()))
      {
        std::cerr << QObject::tr("\nUnable to listen to port: ").toStdString() << serviceManager.listeningPort() << "\n" << std::endl;

        exit(TCP_SERVER_ERROR);
      }

      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::listeningPortUpdated, tcpManager.get(), &terrama2::core::TcpManager::updateListeningPort);

      QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::startProcess, service.get(), &terrama2::core::Service::addToQueue);
      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::numberOfThreadsUpdated, service.get(), &terrama2::core::Service::updateNumberOfThreads);

      QObject::connect(&serviceManager, &terrama2::core::ServiceManager::logConnectionInfoUpdated, logger.get(), &terrama2::core::ProcessLogger::setConnectionInfo);

      QObject::connect(service.get(), &terrama2::core::Service::processFinishedSignal, tcpManager.get(), &terrama2::core::TcpManager::processFinishedSlot);
      QObject::connect(tcpManager.get(), &terrama2::core::TcpManager::stopSignal, service.get(), &terrama2::core::Service::stopService);
      QObject::connect(service.get(), &terrama2::core::Service::serviceFinishedSignal, &app, &QCoreApplication::quit);

      app.exec();
    }

    try
    {
      //Service closed by load error
      if(!serviceManager.serviceLoaded())
        return SERVICE_LOAD_ERROR;
    }
    catch(...)
    {
      return TERRAMA2_FINALIZATION_ERROR;
    }
  }
  catch(boost::program_options::error& e)
  {
    std::cout << "Invalid options.See 'terrama2_service --help'\n" << std::endl;
    TERRAMA2_LOG_ERROR() << e.what();
  }
  catch(boost::exception& e)
  {
    TERRAMA2_LOG_ERROR() << boost::diagnostic_information(e);
  }
  catch(std::exception& e)
  {
    TERRAMA2_LOG_ERROR() << e.what();
  }
  catch(...)
  {
    TERRAMA2_LOG_ERROR() << QObject::tr("\n\nUnknown Exception...\n");
  }

  return 0;
}