]> git.lyx.org Git - lyx.git/blob - src/support/AppleScriptProxy.cpp
Remove non-copyable idioms
[lyx.git] / src / support / AppleScriptProxy.cpp
1 // -*- C++ -*-
2 /**
3  * \file AppleScriptProxy.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Benjamin Piwowarski
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11 #include <config.h>
12
13 #include "AppleScript.h"
14
15 #include "DispatchResult.h"
16 #include "FuncRequest.h"
17 #include "LyX.h"
18 #include "LyXAction.h"
19
20 #include "frontends/Application.h"
21
22 #include "support/docstring.h"
23 #include "support/debug.h"
24
25 using namespace std;
26 using namespace lyx;
27
28 extern "C" LyXFunctionResult applescript_execute_command(const char *cmd, const char *arg) {
29     LYXERR(Debug::ACTION, "Running command [" << cmd << "] with arguments [" << arg << "]");
30         FuncRequest fr(lyxaction.lookupFunc(cmd), arg);
31         fr.setOrigin(FuncRequest::LYXSERVER);
32         DispatchResult dr;
33         theApp()->dispatch(fr, dr);
34         
35     string const rval = to_utf8(dr.message());
36     char *cstr =(char*)  malloc((rval.size()+1)*sizeof(rval[0]));
37     strcpy (cstr, rval.c_str());
38     
39     // Returns the result
40     LyXFunctionResult result;
41     result.code = dr.error() ? -1 : 0;
42     result.message = cstr;
43     
44     return result;
45 }
46