More bugs and debugging process
FossilOrigin-Name: c65b3c3f366134e2ca7b8e0b5da1c0c4f85444baa02dab24d9722ad68d821f05
This commit is contained in:
parent
f004d06316
commit
6360a8167e
3 changed files with 63 additions and 27 deletions
|
@ -96,13 +96,17 @@ int mstdnt_await(mastodont_t* mstdnt,
|
|||
* \remark Usually required if you want to interface Mastodont with
|
||||
* application event loops (i.e. GTK, QT, EFL)
|
||||
*
|
||||
* \param set Reference ptr to set
|
||||
* \param nfds Number of file descriptors to check for reading.
|
||||
* \param read Reference ptr to read set
|
||||
* \param write Reference ptr to write set
|
||||
* \param error Reference ptr to error set
|
||||
* \param nfds Number of file descriptors to check for reading.
|
||||
* \return 0 on success, 1 on error
|
||||
*/
|
||||
int
|
||||
mstdnt_get_fds(mastodont_t* mstdnt,
|
||||
fd_set* set,
|
||||
fd_set* read,
|
||||
fd_set* write,
|
||||
fd_set* error,
|
||||
int* nfds);
|
||||
|
||||
void mstdnt_request_cb_cleanup(mstdnt_request_cb_data* data);
|
||||
|
|
19
src/fetch.c
19
src/fetch.c
|
@ -104,9 +104,11 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt,
|
|||
printf("error %s\n", curl_multi_strerror(res));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* int running; */
|
||||
/* res = curl_multi_perform(mstdnt->curl, &running); */
|
||||
|
||||
// TODO add option to "queue" and not perform a request
|
||||
// Get her running...
|
||||
int running;
|
||||
res = curl_multi_perform(mstdnt->curl, &running);
|
||||
/* if (res != CURLM_OK) */
|
||||
/* { */
|
||||
/* printf("error %s\n", curl_multi_strerror(res)); */
|
||||
|
@ -118,15 +120,17 @@ int mstdnt_fetch_curl_async(mastodont_t* mstdnt,
|
|||
|
||||
int
|
||||
mstdnt_get_fds(mastodont_t* mstdnt,
|
||||
fd_set* set,
|
||||
fd_set* read_set,
|
||||
fd_set* write_set,
|
||||
fd_set* error_set,
|
||||
int* nfds)
|
||||
{
|
||||
assert(mstdnt && nfds);
|
||||
|
||||
return curl_multi_fdset(mstdnt->curl,
|
||||
set,
|
||||
NULL,
|
||||
NULL,
|
||||
read_set,
|
||||
write_set,
|
||||
error_set,
|
||||
nfds) != CURLM_OK;
|
||||
}
|
||||
|
||||
|
@ -160,6 +164,7 @@ int mstdnt_await(mastodont_t* mstdnt,
|
|||
mstdnt_request_cb_data* results = calloc(1, sizeof(mstdnt_request_cb_data));
|
||||
|
||||
// Check if our socket is done
|
||||
// BUG: Reusing data structures if multiple transfers in place
|
||||
do
|
||||
{
|
||||
// TODO error check
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
#include <Efl_Ui.h>
|
||||
|
||||
void update_mstdnt_fds(void);
|
||||
|
||||
Eo* textbox_instance;
|
||||
Eo* fd;
|
||||
Eo* posts;
|
||||
|
@ -18,11 +20,17 @@ mastodont_t mstdnt;
|
|||
static void
|
||||
gui_quit_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
|
||||
{
|
||||
mstdnt_cleanup(&data);
|
||||
mstdnt_cleanup(&mstdnt);
|
||||
mstdnt_global_curl_cleanup();
|
||||
efl_exit(0);
|
||||
}
|
||||
|
||||
static void
|
||||
gui_add_status(struct mstdnt_status* status)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
tl_callback(mstdnt_request_cb_data* cb_data, void* args)
|
||||
{
|
||||
|
@ -31,6 +39,7 @@ tl_callback(mstdnt_request_cb_data* cb_data, void* args)
|
|||
for (int i = 0; i < statuses->len; ++i)
|
||||
{
|
||||
struct mstdnt_status* status = statuses->statuses + i;
|
||||
|
||||
}
|
||||
|
||||
return MSTDNT_REQUEST_DONE;
|
||||
|
@ -39,36 +48,54 @@ tl_callback(mstdnt_request_cb_data* cb_data, void* args)
|
|||
static void
|
||||
gui_fetch_posts(void* data EINA_UNUSED, const Efl_Event* event EINA_UNUSED)
|
||||
{
|
||||
printf("Got %s...\n", efl_text_get(textbox_instance));
|
||||
|
||||
struct mstdnt_args m_args = {
|
||||
.url = NULL,
|
||||
.url = efl_text_get(textbox_instance),
|
||||
.token = NULL,
|
||||
.flags = 0,
|
||||
};
|
||||
|
||||
mstdnt_timeline_public(&mstdnt, &m_args, tl_callback, NULL, (struct mstdnt_timeline_args){.limit=20});
|
||||
mstdnt_timeline_public(&mstdnt, &m_args, tl_callback, NULL,
|
||||
(struct mstdnt_timeline_args){.limit=20});
|
||||
|
||||
mstdnt_await(&data, 0, NULL, 0);
|
||||
update_mstdnt_fds();
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
mstdnt_results_cb(void* data EINA_UNUSED, const Efl_Event* event EINA_UNUSED)
|
||||
{
|
||||
printf("Mastodont data ready to be read!\n");
|
||||
mstdnt_await(&mstdnt, 0, NULL, 0);
|
||||
}
|
||||
|
||||
void
|
||||
update_mstdnt_fds(void)
|
||||
{
|
||||
int nfds;
|
||||
// Get
|
||||
fd_set set;
|
||||
fd_set read;
|
||||
fd_set write;
|
||||
fd_set error;
|
||||
FD_ZERO(&read);
|
||||
FD_ZERO(&write);
|
||||
FD_ZERO(&error);
|
||||
|
||||
mstdnt_get_fds(&mstdnt, &set, &nfds);
|
||||
mstdnt_get_fds(&mstdnt, &read, &write, &error, &nfds);
|
||||
printf("%d\n", nfds);
|
||||
|
||||
for (int i = 0; i < nfds; ++i)
|
||||
{
|
||||
fd = efl_add(EFL_LOOP_FD_CLASS,
|
||||
efl_main_loop_get(),
|
||||
efl_loop_fd_set(efl_added, set.fd_array[i]),
|
||||
efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, _eo_read_cb, &set));
|
||||
if (FD_ISSET(i, &read))
|
||||
{
|
||||
printf("Added: %i\n", i);
|
||||
fd = efl_add(EFL_LOOP_FD_CLASS,
|
||||
efl_main_loop_get(),
|
||||
efl_loop_fd_set(efl_added, i),
|
||||
efl_event_callback_add(efl_added, EFL_LOOP_FD_EVENT_READ, mstdnt_results_cb, &i));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gui_setup(void)
|
||||
|
@ -78,7 +105,7 @@ gui_setup(void)
|
|||
win = efl_add(EFL_UI_WIN_CLASS,
|
||||
efl_main_loop_get(),
|
||||
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC),
|
||||
efl_text_set(efl_added, "Hello World"),
|
||||
efl_text_set(efl_added, "mastodont-c test"),
|
||||
efl_ui_win_autodel_set(efl_added, EINA_TRUE),
|
||||
efl_event_callback_add(efl_added,
|
||||
EFL_UI_WIN_EVENT_DELETE_REQUEST,
|
||||
|
@ -88,7 +115,7 @@ gui_setup(void)
|
|||
box = efl_add(EFL_UI_BOX_CLASS,
|
||||
win,
|
||||
efl_content_set(win, efl_added),
|
||||
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(460, 640)));
|
||||
efl_gfx_hint_size_min_set(efl_added, EINA_SIZE2D(360, 440)));
|
||||
|
||||
posts = efl_add(EFL_UI_LIST_CLASS,
|
||||
box,
|
||||
|
@ -99,16 +126,16 @@ gui_setup(void)
|
|||
|
||||
textbox_instance = efl_add(EFL_UI_TEXTBOX_CLASS,
|
||||
box,
|
||||
efl_gfx_hint_align_set(efl_added, 0.5, 0.5),
|
||||
efl_gfx_hint_weight_set(efl_added, 1.0, 0.1),
|
||||
efl_pack(box, efl_added));
|
||||
|
||||
efl_add(EFL_UI_BUTTON_CLASS,
|
||||
box,
|
||||
efl_text_set(efl_added, "Fetch posts asynchronously"),
|
||||
efl_gfx_hint_weight_set(efl_added, 1.0, 0.5),
|
||||
efl_gfx_hint_weight_set(efl_added, 1.0, 0.2),
|
||||
efl_pack(box, efl_added),
|
||||
efl_event_callback_add(efl_added, EFL_INPUT_EVENT_CLICKED,
|
||||
gui_fetch_posts, efl_added));
|
||||
gui_fetch_posts, NULL));
|
||||
}
|
||||
|
||||
EAPI_MAIN void
|
||||
|
|
Loading…
Reference in a new issue