| 131 | #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: { VARS break; } |
| 132 | #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) command.Replace("%" VAR, CODE); |
| 133 | static void ExecuteCommand( |
| 134 | enum CUserEvents::EventType event, |
| 135 | const void* object, |
| 136 | const wxString& cmd) |
| 137 | { |
| 138 | // This variable is needed by the USEREVENTS_EVENTLIST macro. |
| 139 | wxString command = cmd; |
| 140 | switch (event) { |
| 141 | USEREVENTS_EVENTLIST() |
| 142 | /* This macro expands to handle all user event types. Example: |
| 143 | case CUserEvents::NewChatSession: { |
| 144 | command.Replace( "%SENDER", *((wxString*)object) ); |
| 145 | break; |
| 146 | } */ |
| 147 | } |
| 148 | if (!command.empty()) { |
| 149 | CTerminationProcess *p = new CTerminationProcess(cmd); |
| 150 | if (!wxExecute(command, wxEXEC_ASYNC, p)) { |
| 151 | // If wxExecute fails, we need to delete the CTerminationProcess |
| 152 | // otherwise it will leak. |
| 153 | delete p; |
| 154 | AddLogLineC(CFormat(_("Failed to execute command `%s' on `%s' event.")) % |
| 155 | command % s_EventList[event].name); |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | void CUserEvents::ProcessEvent(enum EventType event, const void* object) |
| 161 | { |
no test coverage detected