corePlugin.cpp
1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#if _MSC_VER
#define EXPORT_API __declspec(dllexport)
#else
#define EXPORT_API __declspec(dllimport)
#endif
#include "corePlugin.h"
#include <time.h>
using namespace std;
extern "C"
{
EXPORT_API int coreInitialize()
{
//Objeto usado para traduzir
tradutor = new PyTradutor();
update = new PyVlibrasUpdate();
//Objeto usado para copiar texto da área de transferência
clipboard.bdragOn();
return 1;
}
EXPORT_API char* coreExecute()
{
//Copia área de transferência para input
char *input = clipboard.clip();
//Retorna a tradução do texto para glosa
return tradutor->convertStringToGlosa(input);
}
EXPORT_API int coreUpdateInstall_player()
{
update->install("c:\\VLibras\\update\\bin\\PlayerUp.exe","NULL");
return 1;
}
EXPORT_API int coreUpdateInstall_dict()
{
update->install("c:\\VLibras\\update\\bin\\DicionarioUp.exe","NULL");
return 1;
}
EXPORT_API int coreUpdateCheck()
{
string line_in_str;
ifstream file_version;
int return_int = -1;
try
{
update->checkExe("c:\\VLibras\\update\\bin\\checkVersion.exe","check");
clock_t time_end;
time_end = clock() + 3000 * CLOCKS_PER_SEC/1000;
while (clock() < time_end);
file_version.open("c:\\VLibras\\update\\version\\version.txt");
getline(file_version, line_in_str);
file_version.close();
return_int = atoi(line_in_str.c_str());
return return_int;
}
catch (exception e)
{
return -1;
}
return return_int;
}
EXPORT_API int coreFinalize()
{
clipboard.bdragOff();
delete tradutor;
delete update;
return 1;
}
}