/* ** Copyright (C) 2003-2008 Teus Benschop and Dan Dennison (WIN32) ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #ifndef INCLUDED_IPC_H #define INCLUDED_IPC_H #include "libraries.h" #include #ifdef WIN32 #include #else #include #include #endif enum IPCSocketType {ipcstBibleditBin, ipcstBibleditBibletime, ipcstBibleditGit}; enum IPCCallType {ipcctBibleTimeReference, ipcctBibleTimeShutdown, ipcctBibleTimeConnected, ipcctBibleTimeGetModules, ipcctBibleTimeBibles, ipcctBibleTimeCommentaries, ipcctBibleTimeReloadModules, ipcctBibleTimeSearchCommand, ipcctBibleTimeSearchDone, ipcctBibleTimeSearchResults, ipcctGitJobDescription, ipcctGitTaskDone, ipcctGitShutdown, ipcctEnd}; class InterprocessCommunication { public: InterprocessCommunication (IPCSocketType name); ~InterprocessCommunication (); bool send (IPCSocketType name, IPCCallType method, const vector& payload); vector receive (IPCSocketType name, IPCCallType method, const vector& payload, int timeout = 5); vector get_payload (IPCCallType method); void erase_payload (IPCCallType method); void methodcall_add_signal (IPCCallType method); GtkWidget * method_called_signal; IPCCallType method_called_type; void methodcall_remove_all_signals (); private: #ifdef WIN32 // No UNIX sockets on pure Windows struct sockaddr_in address; #else struct sockaddr_un address; #endif int sock, conn; socklen_t addrLength; ustring socketname (IPCSocketType socket); IPCSocketType myname; static void listener_start (gpointer data); void listener_main (); bool listener_run; bool listener_running; void log (const ustring& message, bool critical); map > methodcalls; set signalling_methods; }; #endif