implement send messages and notiseboard
This commit is contained in:
parent
fe9735fe58
commit
5173a05a09
@ -7,8 +7,6 @@
|
|||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <curses.h>
|
#include <curses.h>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <menu.h>
|
#include <menu.h>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -23,14 +21,18 @@ std::vector<allocation> komens_allocated;
|
|||||||
|
|
||||||
void insert_content(WINDOW *content_window, size_t i, json &resp_from_api);
|
void insert_content(WINDOW *content_window, size_t i, json &resp_from_api);
|
||||||
|
|
||||||
void komens_page() {
|
void komens_page(koment_type type) {
|
||||||
current_allocated = &komens_allocated;
|
current_allocated = &komens_allocated;
|
||||||
json resp_from_api;
|
json resp_from_api;
|
||||||
{
|
{
|
||||||
/*std::ifstream f("test-data/komens.json");
|
/*std::ifstream f("test-data/komens.json");
|
||||||
resp_from_api = json::parse(f);
|
resp_from_api = json::parse(f);
|
||||||
f.close();*/
|
f.close();*/
|
||||||
const std::string endpoint = "/api/3/komens/messages/received";
|
const char *types[] = {"/api/3/komens/messages/received",
|
||||||
|
"/api/3/komens/message",
|
||||||
|
"/api/3/komens/messages/noticeboard"};
|
||||||
|
|
||||||
|
const std::string endpoint = types[type];
|
||||||
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, POST);
|
resp_from_api = bakaapi::get_data_from_endpoint(endpoint, POST);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +96,7 @@ void komens_page() {
|
|||||||
|
|
||||||
komens_items[i] = new_item(title_bufs[i], name_bufs[i]);
|
komens_items[i] = new_item(title_bufs[i], name_bufs[i]);
|
||||||
}
|
}
|
||||||
max_item_lenght = max_title_lenght + max_name_lenght;
|
max_item_lenght = 3 + max_title_lenght + 1 + max_name_lenght;
|
||||||
}
|
}
|
||||||
komens_items[num_of_komens] = nullptr;
|
komens_items[num_of_komens] = nullptr;
|
||||||
|
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
#ifndef _ba_ko_hg_
|
#ifndef _ba_ko_hg_
|
||||||
#define _ba_ko_hg_
|
#define _ba_ko_hg_
|
||||||
void komens_page();
|
enum koment_type {
|
||||||
|
RECEIVED,
|
||||||
|
SEND,
|
||||||
|
NOTICEBOARD,
|
||||||
|
};
|
||||||
|
void komens_page(koment_type type);
|
||||||
#endif
|
#endif
|
@ -11,7 +11,6 @@ void komens_menu() {
|
|||||||
wchar_t *choices[] = {
|
wchar_t *choices[] = {
|
||||||
L"received", L"send", L"noticeboard", L"Exit", nullptr,
|
L"received", L"send", L"noticeboard", L"Exit", nullptr,
|
||||||
};
|
};
|
||||||
void (*choicesFuncs[])() = {komens_page, nullptr, nullptr, nullptr, nullptr};
|
|
||||||
|
|
||||||
ITEM **my_items;
|
ITEM **my_items;
|
||||||
int c;
|
int c;
|
||||||
@ -88,7 +87,7 @@ void komens_menu() {
|
|||||||
if (item_index(current_item(my_menu)) == n_choices - 1) {
|
if (item_index(current_item(my_menu)) == n_choices - 1) {
|
||||||
goto close_menu;
|
goto close_menu;
|
||||||
}
|
}
|
||||||
choicesFuncs[item_index(current_item(my_menu))]();
|
komens_page(static_cast<koment_type>(item_index(current_item(my_menu))));
|
||||||
pos_menu_cursor(my_menu);
|
pos_menu_cursor(my_menu);
|
||||||
refresh();
|
refresh();
|
||||||
wrefresh(my_menu_win);
|
wrefresh(my_menu_win);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user