I need to read the gnome-shell notifications to send an e-mail whenever event X happens (like a torrent was successfully downloaded). Is there a file or a callback that I can read/set in C code?
A very easy option would be to call the notify-send tool from your code. It is used like this:
notify-send [OPTION...] <SUMMARY> [BODY] - create a notification
For more information, see the accompanying man-page.
Edit: I first read this question wrong and thought you wanted to send notifications. For reacting to notifications, I would suggest writing a gnome-shell extension. There is already an example extension that shows how to react to all notifications.
I am not aware of any callbacks for your own code, sorry. But you could probably roll your own notification callback via DBUS. See the DBUS homepage for more details. In short, your shell extension could generate an appropriate DBUS message, to which your program then could react.
Sorry for my reading error :)
Related
I've just started learning Mosquitto recently. I need to create a custom event handler (on client connect and on message received) that will be built in Mosquitto and run on server as a bundle. The idea is not in using separate program (client) subscribed to some topics (as it works in most use-cases) but make Mosquitto handle data.
My idea is:
Some imagine client do a pub to Mosquitto in some topic.
Mosquitto do its magic (default behavior) and also runs a callback (so the data handled the way I describe it in CB)
I've read Mosquitto API docs but can hardly understand how to use it.
Questions are:
Is that possible to create such plugin using Mosquitto/API?
Do you have a repository with an example of creating callbacks? Seen mysql example and auth-plug example but none worked for me - still no luck in building custom plugin.
Or maybe someone can describe the process of creating plugins / extending mosquitto?
Any instructions on building plugins and injecting them into Mosquitto?
If you know rust, this might be useful, I just wrote it. Just because I did not want to figure out how to do stuff in C.
https://crates.io/crates/mosquitto-plugin
There is an example showing how to use it.
Regarding your callback to do something with the data,I havent tried it, but I believe that you could use ACL rule check to do something with the data, even spawning a thread do do something asynchronous
I am using 'c-client' api to access the Websphere IBM MQ 8. Is it possible to identify the source topic from which the message was published ?
To inquire on the topic string, use the MQCRTMH API call to obtain a message handle, then inquire the properties of the message using the MQINQMP API call specifying the MQTopicString property.
MQCRTMH - Create message handle
MQINQMP - Property Names
Sample IBM MQ procedural programs
Admittedly, it can be difficult to track this info down in the IBM MQ reference documentation, especially if you do not already know the way it works and the names of the calls and fields. One approach that can help is to start with the sample programs to get a basic understanding and then work back into the manuals to fill in the missing details. The sample code is available from the install media by selecting the appropriate optional component.
On Windows these end up in {MQM Home}/Tools and on UNIX systems at {MQM Home}/samp. If the samples are installed, AMQSIQMA will demonstrate how to inquire properties of a message handle, and is an example of the use of the MQINQMP API call.
To inquire on the topic string, use the MQCRTMH API call to obtain a
message handle, then inquire the properties of the message using the
MQINQMP API call specifying the MQTopicString property.
The correct message property name is 'mqps.Top' (case sensitive & no quotes).
I have an Win32 application with no window written in C.
My question is: is there any way to handle the termination of my application. Ex. closing it from the task manager or via the console.
It is unclear from the question, but if this is a console mode application then you can call SetConsoleCtrlHandler to install a callback that Windows will call just before it terminates your app. Beware that this callback runs on a separate thread and that you have to complete the callback function quickly.
If it is a native Windows program that just doesn't create a window then you really do need a window to get notifications like this. Which is not a problem, it doesn't have to be visible. Just don't call ShowWindow().
Note that atexit() as mentioned will not work, these are rude aborts you are talking about that don't let the program go through its normal shutdown sequence.
You might like to take a look at the atexit() function (http://msdn.microsoft.com/en-us/library/tze57ck3%28v=vs.100%29.aspx).
Using this function you can install handlers which are called when the program terminates.
I have a WPF app that uses a non-WPF vendor library. My app does not receive any events that the library fires. I've been told that this is because I need a message pump.
In another (very similar) question, the accepted answer suggested using System.Windows.Threading.Dispatcher.Run().
When I add in that call, however, my window won't pop up-- the app is effectively backgrounded and I have to shut it down with Task Manager.
I'm really stumped here, and I'm not even sure how to investigate it. Any help would be greatly appreciated.
You already have one if you use WPF, there's no other way that it can get any Windows notifications. Every WPF app starts life with a call to Application.Run() on the main thread. It is usually well hidden, auto-generated in the bin\debug\app.g.cs source code file. Application.Run() in turn calls Dispatcher.Run()
Your vendor is correct, without a message loop many COM components go catatonic. But since you have one you need to look for the problem elsewhere. Don't use the component on threads.
I am attempting to hook into whatever explorer calls when a file is opened (double-click, context menu open, etc.), however I can't figure out which function that is.
Originally, I thought it was ShellExecute, as that does the same thing as far as I can tell, but after hooking into it I learned that it's only used when a new explorer window is opened.
Any ideas which function I should be hooking?
It sounds like the AppInit_DLLs registry key should be good enough.
Make a simple DLL and call the GetCommandLine() in your DllMain function to get the full command line to the application being executed.
There are the ShellExecute hooks, but now (after XP) are deprecated because everybody used them for the strangest purposes. Have a look at this for some more detail, and at this for some documentation.
If you want to intercept these things, just register yourself as the default verb for shell items. Here are some samples.
If you just want to know if someone has change some files you are interested in, you should register for change notifications via FindFirstChangeNotification() and related APIs.
Much simpler than writing a device driver ( but much less amusing ) is the MS research tool detours. Have fun!