-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcl_frontend.cpp
More file actions
106 lines (87 loc) · 2 KB
/
cl_frontend.cpp
File metadata and controls
106 lines (87 loc) · 2 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
97
98
99
100
101
102
103
104
105
106
#include <QMainWindow>
#include <QMessageBox>
#include <QTimer>
extern "C"
{
#include <cl_common.h>
#include <cl_main.h>
#include <cl_memory.h>
}
#include <cl_frontend.h>
#include <QRetroCommon.h>
#include <Pleasant.h>
#include "cls_network_manager.h"
#include "cls_thread.h"
static Pleasant* _plthis(void)
{
return reinterpret_cast<Pleasant*>(_qrthis());
}
void cl_fe_display_message(unsigned level, const char *msg)
{
QMessageBox msg_box;
msg_box.setText(msg);
switch (level)
{
case CL_MSG_DEBUG:
case CL_MSG_INFO:
msg_box.setIcon(QMessageBox::Information);
break;
case CL_MSG_WARN:
msg_box.setIcon(QMessageBox::Warning);
break;
case CL_MSG_ERROR:
msg_box.setIcon(QMessageBox::Critical);
break;
default:
msg_box.setIcon(QMessageBox::Question);
}
msg_box.exec();
}
bool cl_fe_install_membanks(void)
{
auto _this = _plthis();
return _this && _this->installMembanks();
}
const char* cl_fe_library_name(void)
{
auto _this = _plthis();
return _this ? _this->libraryName() : nullptr;
}
void cl_fe_pause(void)
{
auto _this = _plthis();
if (_this)
_this->pause();
}
void cl_fe_unpause(void)
{
auto _this = _plthis();
if (_this)
_this->unpause();
}
void cl_fe_network_post(const char *url, char *data, cl_network_cb_t callback,
void *userdata)
{
auto _this = _plthis();
if (_this)
{
cls_net_cb cb = { callback, userdata };
QString url_string = QString(url);
QString data_string = QString(data);
emit _this->networkManager()->request(url_string, data_string, cb);
}
}
void cl_fe_thread(cl_task_t *task)
{
auto *thread = new ClsThread(task);
thread->start();
}
bool cl_fe_user_data(cl_user_t *user, unsigned index)
{
CL_UNUSED(index);
snprintf(user->username, sizeof(user->username), "%s", "keith");
snprintf(user->token, sizeof(user->token), "%s", "#C5JOfzkl6rNnzFIKJ9IOsAFm4rvjbV");
snprintf(user->language, sizeof(user->language), "%s", "en_US");
user->password[0] = '\0';
return true;
}