32{
33 bool restored_json = false;
35
36
37
38 try {
39 json j_pre = json::parse(payload);
40 if (j_pre.empty()) {
41 return -1;
42 }
43
44 if (j_pre.contains("bind")) {
45 if (j_pre[
"bind"].
contains(
"command")) {
46
47
48 if (j_pre["bind"]["command"].get<std::string>() == "bind") {
49 std::string dev_id;
50 std::string result;
51
52 if (j_pre[
"bind"].
contains(
"dev_id")) {
53 dev_id = j_pre["bind"]["dev_id"].get<std::string>();
54 }
55
56 if (j_pre[
"bind"].
contains(
"result")) {
57 result = j_pre["bind"]["result"].get<std::string>();
58 }
59
60 if (result == "success") {
61 DeviceManager* dev = GUI::wxGetApp().getDeviceManager();
62 if (!dev) {return -1;}
63
64 if (GUI::wxGetApp().m_ping_code_binding_dialog && GUI::wxGetApp().m_ping_code_binding_dialog->IsShown()) {
65 GUI::wxGetApp().m_ping_code_binding_dialog->EndModal(wxCLOSE);
66 GUI::MessageDialog msgdialog(
nullptr,
_L(
"Log in successful."),
"", wxAPPLY | wxOK);
67 msgdialog.ShowModal();
68 }
69 dev->update_user_machine_list_info(GUI::wxGetApp().get_printer_cloud_provider());
70 dev->set_selected_machine(dev_id);
71 return 0;
72 }
73 }
74 }
75 }
76 }
77 catch (...){}
78
79 return -1;
80}
#define _L(s)
Definition OBJ.cpp:34
bool contains(const std::vector< T > &vector, const Point &point)
Definition Geometry.cpp:55
nlohmann::json json
Definition AssembleList.cpp:42