openEventsPlatformApp/plugins/ionic-plugin-keyboard/src/blackberry10/native/public/plugin.h
plugins/ionic-plugin-keyboard/src/blackberry10/native/public/plugin.hRaw
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
10using 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.
18extern "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
28extern 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/////////////////////////////////////////////////////////////////////////
43string& g_trim( string& str );
44void g_tokenize(const string& str,const string& delimiters, vector<string>& tokens);
45char* g_str2static( const string& strRetVal );
46void g_sleep( unsigned int mseconds );
47bool g_unregisterObject( const string& strObjId, void* pContext );
48
49
50/////////////////////////////////////////////////////////////////////////
51// Abstract extension object
52/////////////////////////////////////////////////////////////////////////
53class JSExt
54{
55public:
56 virtual ~JSExt() {};
57 virtual string InvokeMethod( const string& strCommand ) = 0;
58 virtual bool CanDelete( void ) = 0;
59 virtual void TryDelete( void ) {}
60public:
61 void* m_pContext;
62};
63
64/////////////////////////////////////////////////////////////////////////
65// Callback functions to be implemented by the plugin implementation
66/////////////////////////////////////////////////////////////////////////
67extern char* onGetObjList( void );
68extern JSExt* onCreateObject( const string& strClassName, const string& strObjId );
69
70#endif