Cocoa System Services: Name of calling app - cocoa

First of all I would like to thank all of the contributors of this site.
Now for the questions:
I have implemented a simple system service using the System Services Guide and posts on this site.
I would like to find out the name of the application that initiated the call to my service either in my - (void)handleServices:(NSPasteboard *)pboard or via some other means.

The application that initiated the call to your service has to be the most active.
So you can get information about it via NSWorkSpace:
[[[NSWorkspace sharedWorkspace] activeApplication] valueForKey:#"NSApplicationName"] // you might also be interested via #"NSApplicationBundleIdentifier
I just tested this with a very basic Service, and it works as expected.

Related

How to determine whether macOS app was started because it needs to handle URL

I have macOS application which registers for custom scheme URL (in Info.plist) and I have a code
NSAppleEventManager.shared().setEventHandler(self, andSelector: #selector(self.handleGetURL(event:reply:)), forEventClass: UInt32(kInternetEventClass), andEventID: UInt32(kAEGetURL) )
It all works fine, when my application is launched and somebody clicks on a URL (containing this custom scheme).
However, in the case, if my app isn't started then system start is (which is good). Unfortunately, handleGetURL() isn't called.
There are two problems with it:
- How can I learn whether an application was launched a usual way or was triggered by the system to handle url?
- How can I get a URL which I need to handle (if an application wasn't running)
Apparently, registering on applicationDidFinishLaunching is too late. I registered on applicationWillFinishLaunching and everything worked as a charm.

wxWebView Page Load Fails with no Internet Connection

I am writing a windows application that uses a wxWebView (Trident) to display pages served from an internal server that binds to the localhost interface on an ephemeral port. I have run into a problem where, if the host computer does not have any active external IP interfaces enabled (such as a laptop in airplane mode), the wxWebView instance refuses to load the page and sends a page load failure event with a string of "INET_E_DOWNLOAD_FAILURE". When this happens, I can make an external browser (including internet explorer) load the page from my web server so I know that the loopback interface(s) are working. Is there any way to configure the wxWebView instance so that it WILL load the page?
When I try this in the webview sample application, i can see the following in the log window:
13:33:33: Navigation request to 'res://ieframe.dll/navcancl.htm#http://www.wxwidgets.org/' (target='')
13:33:33: Title changed; title='http://www.wxwidgets.org/'
13:33:33: Navigation complete; url='http://www.wxwidgets.org/'
13:33:33: Title changed; title='Navigation Canceled'
13:33:33: Document loaded; url='http://www.wxwidgets.org/'
13:34:12: Navigation request to 'http://localhost:57588/stations.html' (target='')
13:34:12: Error; url='http://localhost:57588/stations.html', error='wxWEBVIEW_NAV_ERR_CONNECTION (INET_E_DOWNLOAD_FAILURE)'
After searching in vain for methods that could be used to configure the iWebBrowser2 instance, I have decided to dump the Trident engine altogether and managed to get wxWebViewChromium to work. If anyone faces something similar to this, they need to be aware that the current version of wxWebViewChromium do not appear to work with the latest version of CEF.
Note: not an answer, but a comment/question to #Jon Trauntvein, because I don't have enough reputation to comment
I too decided to drop the wxWebView IE engine because it does not render Google Maps polygons.
discussed here, if you want to know
https://forums.wxwidgets.org/viewtopic.php?f=1&t=43186
so, I am trying to build a current CEF build
https://bitbucket.org/chromiumembedded/cef
into wxWebViewChromium
https://github.com/sjlamerton/wxWebViewChromium
but this project is 4 years old and the CEF API changed.
Would you care to post here the changes you made to wxWebViewChromium ?
thanks

XPCServices not updating the code

I create project for os x application with xpcservices that run by loginItems. that's mean the service is founded in the app in the path:{APP_NAME}.app/Contents/Library/LoginItems
and who is responsible for run the service is the the main app:
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithLoginItemName:#"{SERVICE_NAME}.app" error:&error];
I used the class :NSXPCConnection+LoginItem.h from apple's docs example :
https://developer.apple.com/library/mac/samplecode/AppSandboxLoginItemXPCDemo/Listings/iDecide_NSXPCConnection_LoginItem_h.html
Q:
Why when I update the service code (even just logs) it's not changed?
you should know:
I deleted all the files that related to this projects and service
( I don't used LaunchAgents or LaunchDaemons folders)
I did remove the service by: launchctl remove {SERVICE_LABLE}
I used the Console App for seeing the difference between the version that I'm running
I even bought "cleanMyMac3.app" and did restart and still I run from Xcode the app and still show logs from previous version.
I searched file on the system that related to the service name, and I find few folders that created and I deleted them:
~/Library/Group Containers/{SERVICE_NAME}
~/Library/Containers/{SERVICE_NAME}
~/Library/Caches/{SERVICE_NAME}
~/Library/Saved Application State/{SERVICE_NAME}
I'm not work sandbox
Do you reference the service (XPC service) properly?
i.e. (as per Apples Example)
`NSXPCConnection *connection = [[NSXPCConnection alloc] initWithLoginItemName:#"XYZABC1234.com.example.iDecideHelper.app" error:&error];`
Also as this example is pretty old, if you traverse the XPC requirements you'll notice that some changes need to be made:
Both the containing project (the iOS or OSX App) and the XPC service App ned to be sandboxed
Ideally, the XPC service should be named as: com.theMainApp.identifier.com.whateverServiceName.
So in the Apple example you've listed IDecideHelpers identifier would be: com.example.iDecide.WhateverServiceName. iDecide (the main app) would be com.example.iDecide

C# - Services how to set the start parameters

I am currently working on a windows service (which starts so that is a good thing).
The big question is how can I get parameters in the start parameter field (without doing it manual ofcourse).
So what I would like to see is the following. Upon installation of the service I would like it if the following happens.
The services gets installed and the start parameters are set.
How would one do such a thing (already been browsing StackOverflow but it doesn't comply with what I want)
The reason I ask the question is the following: The service is part of a communication layer between GUI and a receiving backend. If the backend location differs (e.g. another IP address) the service needs to have the new address accordingly.
If you would like to have some more info please ask (don't down the post if something is not in order 'just ask :)')
Thanks in advance
After the update of your question, I understand what you are trying to accomplish. As far as I currently know, it is not possible to set these start parameters without using the registry. You'll have to do it manually from the services console or by using an installer. When you look at the MSDN page covering ServiceBase.OnStart (MSDN ServiceBase.OnStart method) it clearly states:
Process initialization arguments for the service in the OnStart method, not in the Main method. The arguments in the args parameter array can be set manually in the properties window for the service in the Services console. The arguments entered in the console are not saved; they are passed to the service on a one-time basis when the service is started from the control panel. Arguments that must be present when the service is automatically started can be placed in the ImagePath string value for the service's registry key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\). You can obtain the arguments from the registry using the GetCommandLineArgs method, for example: string[] imagePathArgs = Environment.GetCommandLineArgs();
Thing is that you will still have to keep track of these registry settings when removing the service.
Therefore the link provided here ("Am I running as a service") might help out as well.
use sc.exe:
c:\>sc config <myservice> binPath= "\path\to\myservice.exe -param -param"
In your OnStart() or your service thread use something like:
string myArg = ConfigurationManager.AppSettings["MyArg"]
where in your App.Config you've added
<appSettings>
<!-- My keys -->
<add key="MyArg" value="xxx"/>
</appSettings>
Start a Windows Service passing arguments by using the System.ServiceProcess ServiceController Start(String[]) method like this:
ServiceController sc = new ServiceController("BDESVC");
sc.Start(new string[] { "argValue" });

Oracle CRM On-Demand - Use Tasks Status to update Service Request Status

We're using CRM On-Demand for our Service Group and I'm running into an application limitation and am wondering if anyone has a workaround or just some general ideas on how to accomplish our goal.
In the application, our major focus is around the Service Request and driving for users to create Tasks for all Activities related to working towards closure. For example, a customer calls in and we need a technical resource to make a return call to diagnose the issue in detail, so a Task is assigned to that resource. Once that Task has been marked as completed, I'd like the Status to be updated. I tried creating a workflow using JoinFieldValue(), which wasn't working. I tried a more basic approach and tried to just have a field on the Service Request be populated with the Status of the Task, but that did not work either.
Upon further investigation in the Help File, there is a relationship from the Activity object to the Service Request object, but not one the other way.
So, has anyone else run into this limitation and found some other method to have a Status change on the Task update the Status of a Service Request?
(Also, I'd like to try and avoid writing a custom web service for this purpose, which is why I'm trying to use the tools in the app)
Thanks in advance for any ideas!
actually, if I well understood your issue is related on workflow cross object.
OCOD doesn't manage this type of workflow when you need to use workaround.
In order to cover a cross object worklflow you have many possibilities:
webservices as you said, but you could imagine a js code that will run WS and hosted directly into OCOD (in R19 you could hoste that in Client Side extension). That could be a good solution
Another one could be using Report with a custom look up functionnality with the usage of "Callback" function
I would prefer the 1st solution.

Resources