| 15747 |
anikendra |
1 |
#ifndef _PLUGIN_H
|
|
|
2 |
#define _PLUGIN_H
|
|
|
3 |
|
|
|
4 |
#include <map>
|
|
|
5 |
#include <string>
|
|
|
6 |
#include <vector>
|
|
|
7 |
#include <unistd.h>
|
|
|
8 |
//#include "tokenizer.h"
|
|
|
9 |
|
|
|
10 |
using namespace std;
|
|
|
11 |
|
|
|
12 |
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
13 |
//%% Functions exported by this DLL
|
|
|
14 |
//%% Should always be only SetEventFunc and InvokeFunction
|
|
|
15 |
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
16 |
// g++ requires extern "C" otherwise the names of SetEventFunc and InvokeFunction
|
|
|
17 |
// are mangled C++ style. MS Visual Studio doesn't seem to care though.
|
|
|
18 |
extern "C"
|
|
|
19 |
{
|
|
|
20 |
typedef void (*SendPluginEv)( const char* szEvent, void* pContext );
|
|
|
21 |
char* SetEventFunc(SendPluginEv funcPtr);
|
|
|
22 |
char* InvokeFunction( const char* szCommand, void* pContext );
|
|
|
23 |
}
|
|
|
24 |
|
|
|
25 |
// JNEXT Framework function of the form:
|
|
|
26 |
// typedef void (*SendPluginEv)( const char* szEvent );
|
|
|
27 |
// used to notify JavaScript of an asynchronous event
|
|
|
28 |
extern SendPluginEv SendPluginEvent;
|
|
|
29 |
|
|
|
30 |
/////////////////////////////////////////////////////////////////////////
|
|
|
31 |
// Constants and methods common to all JNEXT extensions types
|
|
|
32 |
/////////////////////////////////////////////////////////////////////////
|
|
|
33 |
#define szERROR "Error "
|
|
|
34 |
#define szOK "Ok "
|
|
|
35 |
|
|
|
36 |
#define szDISPOSE "Dispose"
|
|
|
37 |
#define szINVOKE "InvokeMethod"
|
|
|
38 |
#define szCREATE "CreateObj"
|
|
|
39 |
|
|
|
40 |
/////////////////////////////////////////////////////////////////////////
|
|
|
41 |
// Utility functions
|
|
|
42 |
/////////////////////////////////////////////////////////////////////////
|
|
|
43 |
string& g_trim( string& str );
|
|
|
44 |
void g_tokenize(const string& str,const string& delimiters, vector<string>& tokens);
|
|
|
45 |
char* g_str2static( const string& strRetVal );
|
|
|
46 |
void g_sleep( unsigned int mseconds );
|
|
|
47 |
bool g_unregisterObject( const string& strObjId, void* pContext );
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
/////////////////////////////////////////////////////////////////////////
|
|
|
51 |
// Abstract extension object
|
|
|
52 |
/////////////////////////////////////////////////////////////////////////
|
|
|
53 |
class JSExt
|
|
|
54 |
{
|
|
|
55 |
public:
|
|
|
56 |
virtual ~JSExt() {};
|
|
|
57 |
virtual string InvokeMethod( const string& strCommand ) = 0;
|
|
|
58 |
virtual bool CanDelete( void ) = 0;
|
|
|
59 |
virtual void TryDelete( void ) {}
|
|
|
60 |
public:
|
|
|
61 |
void* m_pContext;
|
|
|
62 |
};
|
|
|
63 |
|
|
|
64 |
/////////////////////////////////////////////////////////////////////////
|
|
|
65 |
// Callback functions to be implemented by the plugin implementation
|
|
|
66 |
/////////////////////////////////////////////////////////////////////////
|
|
|
67 |
extern char* onGetObjList( void );
|
|
|
68 |
extern JSExt* onCreateObject( const string& strClassName, const string& strObjId );
|
|
|
69 |
|
|
|
70 |
#endif
|