How to notify OSX for an external file change - c++

I found a way to refresh the finder when a file is externally changed using:
[[NSWorkspace sharedWorkspace] noteFileSystemChanged: path];
But it looks like this does not notify the file system or any other apps about the change. What I'm trying to do is somehow broadcast a notification to every app using the file, or tell the OSX itself (and then the OSX to notify the apps) that it has changed.
I also tried using:
[[NSDistributedNotificationCenter defaultCenter] postNotificationName: NSWorkspaceDidPerformFileOperationNotification object: nil];
But it does not work (also this notification is deprecated). And I don't know if other apps actually use this kind of notification system (for example I think VS Code is using it).
If there is a solution in c++ will be better, but objective c++ is also okay.

Related

How to access frames of RTCVideoRenderer ? (ios)

I try to access frames of RTCVideoRenderer without success, can you help me please ?
I noticed that there is a "didCaptureVideoFrame" method in RTCVideoCapturerDelegate, but not in RTCVideoViewDelegate.
I have never done objc, I added a method in RTCVideoViewDelegate to get frames (bellow "didChangeVideoSize"), but it do not get fired, I guess it do not work like that.
I am able to access frames from the remote using Android using the "onFrame" of VideoSink, I thought it would be that easy using ios.
PS: To add the method, I took the framework from the pod and put it in the project, because I noticed that when you modify a pod, changes do not apply.
Here is the line I added :
- (void)videoView:(id<RTCVideoRenderer>)videoView didRenderVideoFrame:(RTCVideoFrame *)frame;
I will now try to compile the library with the changes I want.
EDIT:
I am now compiling the library, I noticed the need to change several files to be able to access frames, it will not be done just by adding 10 lines.
Solved thanks to this : How to get frame data in AppRTC iOS app for video modifications?
I used this line instead (because names changed since) :
#property(atomic, strong) RTCVideoFrame* videoFrame;
I wanted a "onFrame" like VideoSink on Android, but it will be ok for now.

Qt Console with Bash

I am writing a program using the Qt framework. I would like the user to be able to have access to a console/terminal from within the application itself.
In other words, the user should be greeted with a "BASH" prompt when they start the program.
I have looked into QTermWidget, but there doesn't seem to be too much documentation on it and it doesn't seem to be up to date either.
I've looked at QConsole, but it only seems to be able to run TCL/Python consoles.
How would I be able to embed a terminal into my application?
There is really not much tutorial needed for QTermWidget, although there is one here.
The purpose of the widget is that it does not require any complication. The code would be something like this without the extra settings:
QTermWidget *console = new QTermWidget();
QMainWindow *mainWindow = new QMainWindow();
mainWindow->setCentralWidget(console);
It is also not necessarily true that it is not up-to-date. It was recently updated to build against Qt 5 properly. If you lack anything, please use the issue tracker on github.
It should be more or less in mature and "complete" state, that is why you may not see heavy progress. It is just a widget after all, not a big framework.
You could try QProcess. This is not strictly "embedding" a terminal in your app, but it it really easy to use, you can kick off a terminal that is owned by your app. You can even connect (with signals / slots) to its output and interact with it in a limited fashion... depends on what you need.
Here is the doc with some simple examples: http://qt-project.org/doc/qt-5/QProcess.html
I am not at my Qt-PC today so I don't have an "interacting" example for you, but if you think this is a way for you to go then I can dig that out...

How to create a singleton Qt application on windows? [duplicate]

This question already has answers here:
Closed 10 years ago.
I wonder how to create an application that would be capable to have only one instance of it running on a host OS at a time.. so to say a singleton app. I wonder how to create such singleton C++ app in Qt?
You could use the QtSingleApplication class from Qt Solutions. Notice that this is not a standard Qt class. You should download it. The QtSingleApplication component provides support for applications
that can be only started once per user.
When the application starts, create a file. When the application ends, remove the file.
If the file exists, exit with an error message.
You don't really need Qt for this, it's a graphics library.
Just use some normal WINAPI method to do this.
You could either create files like suggested (but can get strange when your application will crash, or after a power outage), or use memory mapped files or some other global objects to check if your app is stil running.
You also could just check the process list to see if another copy is running.
Another thing is to do a FindWindow with your window class, that's pretty easy and will work well.
There are a lot of options, just search for this, it's a common question.
(you could use some libraries for this, but since you are only targetting windows, I'd go with FindWindow.)

Control multiple program instances - open multiple files problem

This shouldn't be an unusual problem, but I cannot find anything about it at google or at other search machine.
So, I've made an application using C++ and QtCreator. I 've made a new mime type for application's project files.
My system (ubuntu 10.10), when I right click a file and I choose "Open With 'Default Application'" the it runs
Code:
default_application path/to/the/selected/file1
So, if you select multiple files and select "Open With 'Default Application'" the system will call
Code:
default_application path/to/the/selected/file1
default_application path/to/the/selected/file2
default_application path/to/the/selected/file3
So, this is a big problem for me, because I handle the concurrent processes from inside the program, so when another instance of the program is running, a warning message is appeared. So, each application's call will recognize the others as currently running applications and so it'll show the message. I'll end up with 3 Messages saying that another process of the program is running --_--'
My application handles multiple URLs this way:
Code:
myapp path/to/the/selected/file1 path/to/the/selected/file2 path/to/the/selected/file3
How can I make my code handle all these multiple instances at the same time? Everything I've tried fails, because everything I've tried requires a check from the first instance called, which is too slow and other instances come app and all together are warning about concurrent processes of the same program
So, how can I fix this? is it system depended, or can I do something with the code?
The way is to make your application recognize that there is already an instance running and make the new instance just forward a request to the first instance before dying :)
EDIT:
The way to do that is to have your first application instance behave as a server. The pseudo algo is something like :
start();
try_to_contact_master_server_instance();
if(no_master())
{
I_am_master();
start_listening_server_that_wait_for_requests();
}
else
{
send_request_to_master("open file path/to/the/selected/file1");
send_request_to_master("open file path/to/the/selected/file2");
send_request_to_master("open file path/to/the/selected/file3");
die();
}
handle_incoming_requests();
I hope it's clearer ? Tell me if you need more precisions ...
For the server part, you can do your own or use some software bus provided by the OS like dbus or whatever, but it makes your application dependent, of course.
my2c

How do I check if a swf file loaded correctly since put_Movie always returns S_OK?

I am using the latest flash player and have a swf file served locally from my dev machine. In one container test app I am able to play the swf and make calls to it, but in my "Real" application the same code path results in com errors (basically it looks like the swf isn;' loading properly)
Additionally this is made more challenging because no matter what nonsense I put in the call to put_Movie() the return is ALWAYS S_OK. This is confusing.
How am I supposed to determine if the swf file loaded and is working?
As a follow-on, what would cause a swf file (the same one) not to load in a different app? The code paths are the same (from what I can tell).
Obviousl something is going on, but I am not sure what.
So, I guess 2 questions
How to know when swf file doesn't load right
Why might it fail in a different container application?
I am using ATL in Visual studio 2008, latest flash, MS Vista
Thanks
Hmm, it seems that if I listen for the DISPID_READYSTATECHANGE events then that helps me.
A value of '4' seems to indicate it is ready to accept method calls.