ECode NotificationManager::GetEffectsSuppressor(
    /* [out] */ IComponentName** cn)
{
    VALIDATE_NOT_NULL(cn)
    AutoPtr<IINotificationManager> service = GetService();
    return service->GetEffectsSuppressor(cn);
}
void InitCycle(std::shared_ptr<NamedPipe>& pipe)
{
   auto globals = globalStruct::GetGlobals();
   if (!globals)
      return;
   auto svc = globals->GetService();
   if (!svc)
      return;
   std::atomic_store(&globals->pipe, pipe);
   StartRecv(pipe);

   svc->post([pipe, globals]()
                          {
                             if (!pipe || !pipe->IsConnected())
                                return;
                             auto strm = globals->GetStreamer();
                             if (!strm)
                                return;
                             try
                             {
                                Writer MyWriter(pipe);
                                strm->startStream(MyWriter);
                                strm->stream(MyWriter);
                             }
                             catch (NamedPipeException& ex)
                             {
                                pipe->Cleanup();
                             }
                          });
}
gint
DisplayStopThread(camera_t* cam)
{
  displaythread_info_t *info;
  chain_t *display_service;
  display_service=GetService(cam,SERVICE_DISPLAY);
  
  if (display_service!=NULL) { // if display service running... 
    info=(displaythread_info_t*)display_service->data;
    
    // send request for cancellation:
    pthread_mutex_lock(&info->mutex_cancel);
    info->cancel_req=1;
    pthread_mutex_unlock(&info->mutex_cancel);
    
    // when cancellation occured, join:
    pthread_join(display_service->thread, NULL);
    
    pthread_mutex_lock(&display_service->mutex_data);
    pthread_mutex_lock(&display_service->mutex_struct);
    RemoveChain(cam,display_service);
#ifdef HAVE_SDLLIB
    SDLQuit(display_service);
#endif
    
    pthread_mutex_unlock(&display_service->mutex_struct);
    pthread_mutex_unlock(&display_service->mutex_data);
    FreeChain(display_service);
  }
  return (1);
}
//--------------------------------------------------------------------------------------------------
le_msg_ServiceRef_t le_msg_CreateService
(
    le_msg_ProtocolRef_t    protocolRef,    ///< [in] Reference to the protocol to be used.
    const char*             serviceName     ///< [in] The service instance name.
)
//--------------------------------------------------------------------------------------------------
{
    // Must lock the mutex to prevent races between different threads trying to offer the
    // same service at the same time, or one thread trying to delete a service while another
    // tries to create it, or accessing the Service List hashmap while another thread
    // is updating it.

    LOCK

    // Get a Service object.
    Service_t* servicePtr = GetService(protocolRef, serviceName);

    // If the Service object already has a server thread, then it means that this service
    // is already being offered by someone else in this very process.
    LE_FATAL_IF(servicePtr->serverThread != NULL,
                "Duplicate service (%s:%s) offered in same process.",
                serviceName,
                le_msg_GetProtocolIdStr(protocolRef));

    servicePtr->serverThread = le_thread_GetCurrent();

    UNLOCK

    return servicePtr;
}
TAG_METHOD_IMPL(CWSDLServiceParser, OnPort)
{
	TRACE_PARSE_ENTRY();

	CWSDLService *pCurr = GetService();
	if (pCurr != NULL)
	{
		CWSDLPort *pElem = pCurr->AddPort();
		if (pElem != NULL)
		{
			SetXMLElementInfo(pElem, pCurr, GetLocator());

			CAutoPtr<CWSDLServicePortParser> p( new CWSDLServicePortParser(GetReader(), this, GetLevel(), pElem) );
			if (p != NULL)
			{
				if (g_ParserList.AddHead(p) != NULL)
				{
					return p.Detach()->GetAttributes(pAttributes);
				}
			}
		}
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Exemple #6
0
DWORD Service::HandlerEx(DWORD dwOpcode,DWORD dwEventType,LPVOID lpEventData,LPVOID lpContext)
#endif  
{
    // Get a pointer to the object
    Service* pService = GetService();
	return pService->_HandlerEx(dwOpcode, dwEventType, lpEventData, lpContext);
}
bool ServiceManager::Call(LPCSTR p_serviceID, LPCSTR p_function, const ServiceArg &p_arg1, const ServiceArg &p_arg2, const ServiceArg &p_arg3, const ServiceArg &p_arg4)
{
	Service *service = GetService(p_serviceID);
	if (service)
	{
		ATOM function = FindAtomA(p_function);
		if (function)
		{
			if (typeid(p_arg4) != typeid(ServiceArg))
			{
				return service->Call(function, p_arg1, p_arg2, p_arg3, p_arg4);
			}
			if (typeid(p_arg3) != typeid(ServiceArg))
			{
				return service->Call(function, p_arg1, p_arg2, p_arg3);
			}
			if (typeid(p_arg2) != typeid(ServiceArg))
			{
				return service->Call(function, p_arg1, p_arg2);
			}
			if (typeid(p_arg1) != typeid(ServiceArg))
			{
				return service->Call(function, p_arg1);
			}
			return service->Call(function);
		}
	}
	return false;
}
String GeocoderProxy::GetFromLocationName(
    /* [in] */ const String& locationName,
    /* [in] */ Double lowerLeftLatitude,
    /* [in] */ Double lowerLeftLongitude,
    /* [in] */ Double upperRightLatitude,
    /* [in] */ Double upperRightLongitude,
    /* [in] */ Int32 maxResults,
    /* [in] */ IGeocoderParams* params,
    /* [out] */ IObjectContainer** addrs)
{
    assert(addrs != NULL);
    *addrs = NULL;

    AutoPtr<IIGeocodeProvider> provider = GetService();
    if (provider != NULL) {

        String temp;
        provider->GetFromLocationName(locationName, lowerLeftLatitude,
                lowerLeftLongitude, upperRightLatitude, upperRightLongitude,
                maxResults, params, addrs, &temp);
        return temp;

    }

    return String("Service not Available");
}
void ServiceList::SetActiveService(const QString &name) {
  Service service = GetService(name);

  if (service.getName().isEmpty() || service.getName().isNull()) {
    qCritical() << Q_FUNC_INFO << "Fatal error emptry service - Input";
    return;
  }

  Service active_service = GetActiveService();

  if (active_service.getName().isEmpty() || active_service.getName().isNull()) {
    qCritical() << Q_FUNC_INFO << "Fatal error emptry service - Active";

    service.setActive(true);
    UpdateService(service);

    return;
  }

  active_service.setActive(false);
  UpdateService(active_service);

  service.setActive(true);
  UpdateService(service);
}
Exemple #10
0
MgByteReader* MgDwfController::GetPlot(MgMap* map, MgPlotSpecification* plotSpec, MgLayout* layout, CREFSTRING dwfVersion,
        CREFSTRING ePlotVersion, MgPropertyCollection* mapViewCommands)
{
    //apply new commands
    ApplyMapViewCommands(map, mapViewCommands);

    Ptr<MgDwfVersion> dwfv = new MgDwfVersion(dwfVersion, ePlotVersion);

    //get an instance of the mapping service and call the GetMapUpdate API
    Ptr<MgMappingService> mappingService = (MgMappingService*)GetService(MgServiceType::MappingService);
    MgByteReader* br = NULL;

    // the presence of the data extent determines which GeneratePlot API we use
    Ptr<MgProperty> val;
    if (mapViewCommands != NULL)
        val = mapViewCommands->FindItem(m_mapCmdSetDataExtent);

    if (val != NULL)
    {
        Ptr<MgEnvelope> extent = map->GetDataExtent();
        br = mappingService->GeneratePlot(map, extent, true, plotSpec, layout, dwfv);
    }
    else
    {
        Ptr<MgPoint> center = map->GetViewCenter();
        Ptr<MgCoordinate> coord = center? center->GetCoordinate(): NULL;
        double scale = map->GetViewScale();
        br = mappingService->GeneratePlot(map, coord, scale, plotSpec, layout, dwfv);
    }

    return br;
}
Exemple #11
0
	void Application::SetMousePosition(int x, int y)
	{
		FramesService* svc = dynamic_cast<FramesService*>(GetService("FRAMES"));
		if (svc != NULL)
		{
			svc->SetMousePosition(x, y);
		}
	}
Exemple #12
0
	void Application::SetMouseButtonUp(int button)
	{
		FramesService* svc = dynamic_cast<FramesService*>(GetService("FRAMES"));
		if (svc != NULL)
		{
			svc->SetMouseButtonUp(button);
		}
	}
HRESULT AIMPCoreWrapper::MessageDispatcherSend(DWORD message, int param1, void* param2) {
    IAIMPServiceMessageDispatcherPtr messageService;
    if (GetService(IID_IAIMPServiceMessageDispatcher, (void**)&messageService)) {
        messageService->Send(message, param1, param2);
        return S_OK;
    }
    return E_UNEXPECTED;
}
ECode NotificationManager::MatchesCallFilter(
    /* [in] */ IBundle* extras,
    /* [out] */ Boolean* result)
{
    VALIDATE_NOT_NULL(result)
    AutoPtr<IINotificationManager> service = GetService();
    return service->MatchesCallFilter(extras, result);
}
Exemple #15
0
//
/// This function is blocking. Given an input service in szName, this function fills
/// nPort with the port (in network order). The port is a reference to an int. If
/// the call returns OK, this will be the port in network ordering. szProtocol is
/// the protocol name, but may be passed as 0 to mean default or first found.
//
int TServiceManager::GetServicePort(char* name, uint16& port, const char* protocol)
{
  TServiceEntry* tempServiceEntry;

  int returnValue = GetService(tempServiceEntry, name, protocol);
  port = tempServiceEntry->s_port; // Note that port is already in host byte order.
  return returnValue;
}
HRESULT AIMPCoreWrapper::LangLoadString(PWCHAR keyPath, int partIndex, IAIMPString** out) {
    IAIMPServiceMUIPtr muiService;
    if (GetService(IID_IAIMPServiceMUI, (void**)&muiService)) {
        IAIMPStringPtr sKeyPath;
        MakeString(keyPath, &sKeyPath);
        return muiService->GetValuePart(sKeyPath, partIndex, out);
    }
    return E_NOINTERFACE;
}
ECode NotificationManager::Notify(
    /* [in] */ const String& tag,
    /* [in] */ Int32 id,
    /* [in] */ INotification* notification)
{
    VALIDATE_NOT_NULL(notification);

    AutoPtr<ArrayOf<Int32> > idOut = ArrayOf<Int32>::Alloc(1);
    AutoPtr<IINotificationManager> service = GetService();
    String pkgName;
    mContext->GetPackageName(&pkgName);

    AutoPtr<IUri> sound;
    notification->GetSound((IUri**)&sound);
    if (sound != NULL) {
        AutoPtr<IUri> newSound;
        sound->GetCanonicalUri((IUri**)&newSound);
        notification->SetSound(newSound);
        assert(0 && "TODO");
        // if (StrictMode.vmFileUriExposureEnabled()) {
        //     newSound->CheckFileUriExposed("Notification.sound");
        // }
    }

    if (localLOGV) {
        String notificationStr = Object::ToString(notification);
        Slogger::V(TAG, "%s: notify(%d, %s)", pkgName.string(), id, notificationStr.string());
    }

    AutoPtr<IInterface> tmp;
    ICloneable::Probe(notification)->Clone((IInterface**)&tmp);
    AutoPtr<INotification> stripped = INotification::Probe(tmp);
    CNotificationBuilder::StripForDelivery(stripped);

    // try {
    ECode ec;
    do {
        Int32 userId = UserHandle::GetMyUserId();
        AutoPtr<ArrayOf<Int32> > idOutTmp;
        ec = service->EnqueueNotificationWithTag(
            pkgName, pkgName, tag, id, stripped, idOut, userId, (ArrayOf<Int32>**)&idOutTmp);
        idOut = idOutTmp;
        if (FAILED(ec)) break;
        if (idOut == NULL || idOut->GetLength() == 0 || id != (*idOut)[0]) {
            Slogger::W(TAG, "notify: id corrupted: sent %d, got back %d",
                id, (idOut && idOut->GetLength() > 0) ? (*idOut)[0] : -1);
        }
    } while(FALSE);
    // } catch (RemoteException e) {
    if (FAILED(ec)) {
        if ((ECode) E_REMOTE_EXCEPTION == ec) {
            ec = NOERROR;
        }
    }
    // }
    return ec;
}
bool vzsdk::VzTcpDeviceManage::CloseService(int session_id) {
    CritScope crit_scope(&crit_section_);
    if (!ExistService(session_id))
        return false;

    GetService(session_id)->Stop();
    RemoveService(session_id);
    return true;
}
IAIMPString* AIMPCoreWrapper::LangGetName() {
    IAIMPServiceMUIPtr muiService;
    if (GetService(IID_IAIMPServiceMUI, (void**)&muiService)) {
        IAIMPString* langName;
        muiService->GetName(&langName);
        return langName;
    }
    return MakeString(L"");
}
ECode NotificationManager::CancelAll()
{
    AutoPtr<IINotificationManager> service = GetService();
    String cap;
    mContext->GetPackageName(&cap);
//    if (localLOGV) Log.v(TAG, pkg + ": cancelAll()");
    Int32 userId = UserHandle::GetMyUserId();
    return service->CancelAllNotifications(cap, userId);
}
Exemple #21
0
//////////////////////////////////////////////////////////////////
// Processes a QueryMapFeatures request from the Viewer
//
MgByteReader* MgHtmlController::QueryMapFeatures(
    CREFSTRING mapName,
    MgStringCollection* layerNames,
    MgGeometry* selectionGeometry,
    INT32 selectionVariant,
    CREFSTRING featureFilter,
    INT32 maxFeatures,
    bool persist,
    INT32 layerAttributeFilter)
{
    // Create a Resource Service instance
    Ptr<MgResourceService> resourceService = (MgResourceService*)GetService(MgServiceType::ResourceService);

    // Create MgMap
    Ptr<MgMap> map = new MgMap();
    map->Open(resourceService, mapName);

    // Make sure we clear any track changes - these are not applicable for AJAX.
    Ptr<MgNamedCollection> changeLists = map->GetChangeLists();
    if (changeLists->GetCount() > 0)
    {
        map->ClearChanges();
        map->Save(resourceService);
    }

    // Create Proxy Rendering Service instance
    Ptr<MgRenderingService> service = (MgRenderingService*)(GetService(MgServiceType::RenderingService));

    // Call the C++ API
    Ptr<MgFeatureInformation> featureInfo = service->QueryFeatures(map, layerNames, selectionGeometry,
        selectionVariant, featureFilter, maxFeatures, layerAttributeFilter);

    if(persist)
    {
        //save the selection set in the session repository
        Ptr<MgSelection> selection = featureInfo->GetSelection();
        if(!selection)
            selection = new MgSelection(map);
        selection->Save(resourceService, mapName);
    }

    // Return XML
    return featureInfo->ToXml();
}
Exemple #22
0
//
/// This function is blocking. The szName needs to be big enough to hold the
/// service's name (N_MAX_SERVICE_NAME). The port must be passed in network byte
/// ordering. szProtocol is the protocol name, but may be passed as 0 to mean
/// default or first found.
//
int TServiceManager::GetServiceName(uint16 port, char* name, const char* protocol)
{
  // Note that because we are calling our own member function, we don't convert
  //  the address from local to network format.
  //
  TServiceEntry* tempServiceEntry;
  int returnValue = GetService(tempServiceEntry, port, protocol);
  if (returnValue == WINSOCK_NOERROR)
    strcpy(name, tempServiceEntry->s_name);
  return returnValue;
}
ECode NotificationManager::Cancel(
    /* [in] */ const String& tag,
    /* [in] */ Int32 id)
{
    AutoPtr<IINotificationManager> service = GetService();
    String cap;
    mContext->GetPackageName(&cap);
//    if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")");
    Int32 userId = UserHandle::GetMyUserId();
    return service->CancelNotificationWithTag(cap, tag, id, userId);
}
void CleanUpEverything()
{
   auto glbl = globalStruct::GetGlobals();
   if (!glbl)
      return;

   auto svr = glbl->GetServer();
   if (svr)
   {
      svr->Stop();
   }

   auto strm = glbl->GetStreamer();
   if (strm)
   {
      strm->stopStream();
   }
   auto pipe = glbl->GetPipe();
   if (pipe)
   {
      pipe->Cleanup();
   }
   glbl->work_guard.reset();
   auto svc = glbl->GetService();

   glbl->ResetAllPointers();

   svr.reset();
   strm.reset();
   pipe.reset();

   if (svc && !svc->stopped())
   {
      svc->stop();
   }
   std::for_each(glbl->globalThreads.begin(), glbl->globalThreads.end(),
                 [](decltype(*glbl->globalThreads.begin())& thr)
                 {
                    thr.join();
                 });
   svc.reset();
   auto trkr = glbl->GetTracker();
   if (trkr)
   {
      trkr->WaitUntilThreadVecEmpty();
      trkr.reset();
      std::shared_ptr<FunctionUsageTracker> resetTracker;
      std::atomic_store(&glbl->fcnTracker, resetTracker);
      std::this_thread::sleep_for(std::chrono::seconds(10)); // Wait some time for threads to exit
   }
   glbl.reset();
   globalStruct::nullifyGlobals();
}
Exemple #25
0
HRESULT __stdcall CWSDLServiceParser::startPrefixMapping(
     const wchar_t  *wszPrefix,
     int cchPrefix,
     const wchar_t  *wszUri,
     int cchUri)
{
	CWSDLService * pCurr = GetService();
	if (pCurr != NULL)
	{
		return pCurr->SetNamespaceUri(wszPrefix, cchPrefix, wszUri, cchUri);
	}
	return E_FAIL;
}
void
GMPRemoveTest::Setup()
{
  GeneratePlugin();
  EXPECT_OK(GetServiceParent()->RemovePluginDirectory(mOriginalPath));

  GetServiceParent()->AddPluginDirectory(mTmpPath);

  nsCOMPtr<nsIObserverService> obs = mozilla::services::GetObserverService();
  obs->AddObserver(this, GMP_DELETED_TOPIC, false /* strong ref */);

  GetService()->GetThread(getter_AddRefs(mGMPThread));
}
ECode NotificationManager::CancelAsUser(
    /* [in] */ const String& tag,
    /* [in] */ Int32 id,
    /* [in] */ IUserHandle* user)
{
    AutoPtr<IINotificationManager> service = GetService();
    String cap;
    mContext->GetPackageName(&cap);
//    if (localLOGV) Log.v(TAG, pkg + ": cancel(" + id + ")");
    Int32 identifier;
    user->GetIdentifier(&identifier);
    return service->CancelNotificationWithTag(cap, tag, id, identifier);
}
Exemple #28
0
ATTR_METHOD_IMPL(CWSDLServiceParser, OnName)
{
	TRACE_PARSE_ENTRY();

	CWSDLService * pCurr = GetService();
	if (pCurr != NULL)
	{
		return pCurr->SetName(wszValue, cchValue);
	}

	EmitErrorHr(E_OUTOFMEMORY);

	return E_FAIL;
}
Exemple #29
0
// static member function (callback)
void Service::ServiceMain(DWORD dwArgc, LPTSTR* lpszArgv)
{
#ifdef _DEBUG
	Sleep(10000);
#endif

    // Get a pointer to the C++ object
	Service* pService = GetService();
	if (!pService) {
		pService = new HVService;
	}

	pService->_ServiceMain(dwArgc, lpszArgv);
}
ECode NotificationManager::GetShowNotificationForPackageOnKeyguard(
    /* [in] */ const String& pkg,
    /* [in] */ Int32 uid,
    /* [out] */ Int32* result)
{
    VALIDATE_NOT_NULL(result)
    AutoPtr<IINotificationManager> service = GetService();
    // try {
    ECode ec = service->GetShowNotificationForPackageOnKeyguard(pkg, uid, result);
    if (FAILED(ec)) {
        *result = INotification::SHOW_ALL_NOTI_ON_KEYGUARD;
    }
    return NOERROR;
}