process.h

Go to the documentation of this file.
00001 #ifndef __PROCESS_H__
00002 #define __PROCESS_H__
00003 
00004 /**
00005  * File Name  : process.h
00006  *
00007  * Description: Process handling functions
00008  */
00009 
00010 /*
00011  * This file is part of sysd.
00012  *
00013  * sysd is free software: you can redistribute it and/or modify
00014  * it under the terms of the GNU General Public License as published by
00015  * the Free Software Foundation, either version 2 of the License, or
00016  * (at your option) any later version.
00017  *
00018  * sysd is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00025  */
00026 
00027 /**
00028  * Copyright (C) 2008 iRex Technologies B.V.
00029  * All rights reserved.
00030  */
00031 
00032 
00033 //----------------------------------------------------------------------------
00034 // Include Files
00035 //----------------------------------------------------------------------------
00036 
00037 #include <glib.h>
00038 #include <gdk/gdk.h>
00039  
00040 G_BEGIN_DECLS
00041 
00042 
00043 //----------------------------------------------------------------------------
00044 // Definitions
00045 //---------------------------------------------------------------------------- 
00046 
00047 #define PS_WAIT_STARTED     (1 << 0)
00048 #define PS_WAIT_EXIT        (1 << 1)
00049 #define PS_RESPAWN          (1 << 2)
00050 
00051 
00052 //----------------------------------------------------------------------------
00053 // Forward Declarations
00054 //----------------------------------------------------------------------------
00055 
00056 
00057 //----------------------------------------------------------------------------
00058 // Type Declarations
00059 //----------------------------------------------------------------------------
00060 
00061 enum proc_state
00062 { 
00063     STATE_IDLE,
00064     STATE_STARTING,
00065     STATE_RUNNING,
00066     STATE_COMPLETED
00067 };
00068 
00069 typedef struct
00070 {
00071     gchar        *command;
00072     gchar        *working_dir;
00073     gchar        *ipc_service;
00074     gint         flags;
00075     gboolean     is_multidoc;
00076     GPid         pid;
00077     GCallback    startup_callback; /* not called when respawning */
00078     GCallback    exit_callback;    /* not called when respawning */
00079     enum proc_state state;
00080 } proc_t;
00081 
00082 
00083 //----------------------------------------------------------------------------
00084 // Global Constants
00085 //----------------------------------------------------------------------------
00086 
00087 
00088 //============================================================================
00089 // Public Functions
00090 //============================================================================
00091 
00092 /**---------------------------------------------------------------------------
00093  *
00094  * Name :  process_add
00095  *
00096  * @brief  Add a process to the queue. The queue is served First In First Out.
00097  *
00098  * @param  application          Full path of the application
00099  * @param  working_dir          Working directory, or NULL to inherit parent's
00100  * @param  startup_callback     Callback function when received startupCopmlete, or NULL
00101  * @param  exit_callback        Callback function when processes was terminated, or NULL
00102  * @param  flags                Bit field PS_WAIT_STARTED | PS_WAIT_EXIT | PS_RESPAWN
00103  *
00104  * @return Returns TRUE on success, FALSE on failure
00105  *
00106  *--------------------------------------------------------------------------*/
00107 gboolean process_add(const char* command, const char* working_dir, GCallback startup_callback, GCallback exit_callback, gint flags);
00108 
00109 /**---------------------------------------------------------------------------
00110  *
00111  * Name :  process_start
00112  *
00113  * @brief  Start a process without queuing
00114  *
00115  * @param  application          Full path of the application
00116  * @param  working_dir          Working directory, or NULL to inherit parent's
00117  * @param  startup_callback     Callback function when received startupCopmlete, or NULL
00118  * @param  exit_callback        Callback function when processes was terminated, or NULL
00119  * @param  flags                Bit field PS_WAIT_STARTED | PS_RESPAWN
00120  *
00121  * @return Process created and started, or NULL on error.
00122  *
00123  *--------------------------------------------------------------------------*/
00124 proc_t *process_start(const char* command, const char* working_dir, GCallback startup_callback, GCallback exit_callback, gint flags);
00125 
00126 /**---------------------------------------------------------------------------
00127  *
00128  * Name :  process_stop
00129  *
00130  * @brief  Stop a running process
00131  *
00132  * @param  process              The process to be stopped
00133  *
00134  * @return --
00135  *
00136  *--------------------------------------------------------------------------*/
00137 void process_stop(proc_t *proc);
00138 
00139 /**---------------------------------------------------------------------------
00140  *
00141  * Name :  process_activate
00142  *
00143  * @brief  Activate a running process  (set to top)
00144  *
00145  * @param  application Full path of the application
00146  *
00147  * @return Returns TRUE on success, FALSE on failure
00148  *
00149  *--------------------------------------------------------------------------*/
00150 gboolean process_activate(const char* application);
00151 
00152 /**---------------------------------------------------------------------------
00153  *
00154  * Name :  process_activate_ctb
00155  *
00156  * @brief  Activate content browser (set to top)
00157  *
00158  * @param  --
00159  *
00160  * @return Returns TRUE on success, FALSE on failure
00161  *
00162  *--------------------------------------------------------------------------*/
00163 gboolean process_activate_ctb(void);
00164 
00165 /**---------------------------------------------------------------------------
00166  *
00167  * Name :  process_startup_complete
00168  *
00169  * @brief  Call when application has finished starting
00170  *
00171  * @param  application Full path of the application
00172  * @param  pid         Process ud 
00173  * @param  is_multidoc TRUE if multiple documents are supported, FALSE otherwise 
00174  * @param  ipc_service IPC service
00175  * @param  window      Window id
00176  *
00177  * @return Returns TRUE on success, FALSE on failure
00178  *
00179  *--------------------------------------------------------------------------*/
00180 gboolean process_startup_complete(const char *application, gint pid, gboolean is_multidoc, 
00181                                   const char *ipc_service, gint window);
00182 
00183 proc_t *process_get_by_name(const char *application);
00184 
00185 proc_t *process_get_by_pid(GPid pid);
00186 
00187 #if (TESTING_ON)
00188 void print_process_list();
00189 #endif
00190 
00191 G_END_DECLS
00192 
00193 #endif /* __PROCESS_H__ */
Generated by  doxygen 1.6.2-20100208