aboutsummaryrefslogtreecommitdiff
path: root/Src/Wasabi/api/application/ipcs.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/application/ipcs.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Wasabi/api/application/ipcs.cpp')
-rw-r--r--Src/Wasabi/api/application/ipcs.cpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/Src/Wasabi/api/application/ipcs.cpp b/Src/Wasabi/api/application/ipcs.cpp
new file mode 100644
index 00000000..2320a4d8
--- /dev/null
+++ b/Src/Wasabi/api/application/ipcs.cpp
@@ -0,0 +1,97 @@
+#include <precomp.h>
+#ifdef WASABI_API_COMPONENT
+#include <api/wac/main.h> //CUT!!!
+#endif
+#include "ipcs.h"
+#ifdef LINUX
+#include <api/linux/linuxapi.h>
+#endif
+
+using namespace IpcsCommand;
+
+#ifdef WIN32
+IpcsPtr::IpcsPtr(HWND h) {
+ hwnd = h;
+}
+#else
+IpcsPtr::IpcsPtr(int q) {
+ qid = q;
+}
+#endif
+
+void IpcsPtr::moveToForeground() {
+#ifdef WIN32
+ if (IsIconic(hwnd)) ShowWindow(hwnd, SW_RESTORE);
+// ShowWindow(hwnd,SW_SHOW); //FG> SW_RESTORE should take care of it and is trapped for taskbar button hiding. Explicitly showing the window will make an iconless button reapear if studio is set to not have a taskbar button
+ SetForegroundWindow(hwnd);
+#else
+ DebugString( "portme -- IpcsPtr::moveToForeground\n" );
+#endif
+}
+
+void IpcsPtr::sendWasabiCommand(int command, void *param, int paramlen) {
+#ifdef WIN32
+ COPYDATASTRUCT cd;
+ cd.dwData=command;
+ cd.cbData=paramlen;
+ cd.lpData=param;
+ SendMessage(hwnd, WM_COPYDATA, NULL, (long)&cd);
+#else
+ wa_msgbuf msg;
+ msg.mtype = command;
+ ASSERT( paramlen < IPC_MSGMAX - 4 );
+ msg.paramlen = paramlen;
+ MEMCPY( msg.param, param, paramlen );
+
+ if ( msgsnd( qid , &msg, IPC_MSGMAX, 0 ) == 1 ) {
+ perror( "msgsnd" );
+ }
+#endif
+}
+
+void IpcsPtr::sendWasabiCommand(int command, const char *param) {
+ sendWasabiCommand(command, (void *)param, STRLEN(param)+1);
+}
+
+
+IpcsPtr *Ipcs::getOtherWasabiInstance() {
+ extern String ipcWindowClassName;
+
+#ifdef WIN32
+ HWND hwnd_instance=FindWindow(ipcWindowClassName,NULL);
+ if(!hwnd_instance) return NULL;
+
+ return(new IpcsPtr(hwnd_instance));
+#else
+ int key = ftok( ".", 'w' );
+
+ int qid = msgget( key, 0 );
+ if ( qid == -1 && errno == ENOENT ) {
+ qid = msgget( key, IPC_CREAT | IPC_EXCL | 0660 );
+
+ LinuxAPI::setIPCId( qid );
+
+ return NULL;
+ } else if ( qid == -1 ) {
+ return NULL;
+ } else {
+ return new IpcsPtr( qid );
+ }
+#endif
+}
+
+#pragma warning(push)
+#pragma warning(disable: 4060)
+
+int Ipcs::onIpcsMessage(int command, void *param, int paramlen) {
+ switch(command) {
+#ifdef WASABI_API_COMPONENT
+ case IPC_COMMANDLINE:
+ Main::processCommandLine((const char *)param);
+ return 0;
+#endif
+ }
+ return 0;
+}
+
+#pragma warning(pop)