aboutsummaryrefslogtreecommitdiff
path: root/src/ui/lobby_create_dialog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/lobby_create_dialog.c')
-rw-r--r--src/ui/lobby_create_dialog.c129
1 files changed, 112 insertions, 17 deletions
diff --git a/src/ui/lobby_create_dialog.c b/src/ui/lobby_create_dialog.c
index 9c80929..f294391 100644
--- a/src/ui/lobby_create_dialog.c
+++ b/src/ui/lobby_create_dialog.c
@@ -24,30 +24,125 @@
24 24
25#include "lobby_create_dialog.h" 25#include "lobby_create_dialog.h"
26 26
27#include "list_input.h"
28#include "../application.h"
29#include "../util.h"
30
31void
32_lobby_open_with_uri(void *cls,
33 const struct GNUNET_CHAT_Uri *uri)
34{
35 UI_LOBBY_CREATE_DIALOG_Handle *create_dialog = cls;
36
37 if (create_dialog->uri)
38 GNUNET_free(create_dialog->uri);
39
40 create_dialog->uri = GNUNET_CHAT_uri_to_string(uri);
41}
42
27void 43void
28lobby_create_dialog_event(UI_LOBBY_CREATE_DIALOG_Handle *create_dialog, 44lobby_create_dialog_event(UI_LOBBY_CREATE_DIALOG_Handle *create_dialog,
29 struct MESSENGER_Application *app, 45 UNUSED struct MESSENGER_Application *app,
30 int key) 46 int key)
31{ 47{
32 // TODO 48 create_dialog->window = *(create_dialog->win);
49
50 list_input_reset(create_dialog);
51
52 if (create_dialog->uri)
53 list_input_select(create_dialog, 1, 0)
54 else
55 {
56 list_input_select(create_dialog, 1, 30);
57 list_input_select(create_dialog, 1, 5 * 60);
58 list_input_select(create_dialog, 1, 60 * 60);
59 list_input_select(create_dialog, 1, 8 * 60 * 60);
60 list_input_select(create_dialog, 1, 24 * 60 * 60);
61 list_input_select(create_dialog, 1, 7 * 24 * 60 * 60);
62 list_input_select(create_dialog, 1, 4 * 7 * 60 * 60);
63 list_input_select(create_dialog, 1, 0);
64 }
65
66 switch (key)
67 {
68 case 27:
69 case KEY_EXIT:
70 if (create_dialog->lobby)
71 GNUNET_CHAT_lobby_close(create_dialog->lobby);
72
73 create_dialog->lobby = NULL;
74 create_dialog->win = NULL;
75 break;
76 case '\n':
77 case KEY_ENTER:
78 if (create_dialog->uri)
79 {
80 GNUNET_free(create_dialog->uri);
81
82 create_dialog->lobby = NULL;
83 create_dialog->win = NULL;
84 }
85 else if (!(create_dialog->lobby))
86 create_dialog->lobby = GNUNET_CHAT_lobby_open(
87 app->chat.handle,
88 GNUNET_TIME_relative_multiply(
89 GNUNET_TIME_relative_get_second_(),
90 create_dialog->selected
91 ),
92 _lobby_open_with_uri,
93 create_dialog
94 );
95
96 break;
97 default:
98 break;
99 }
100
101 if (!(create_dialog->lobby))
102 list_input_event(create_dialog, key)
103 else
104 list_input_event(create_dialog, KEY_RESIZE);
105}
106
107static void
108_lobby_iterate_print(UI_LOBBY_CREATE_DIALOG_Handle *create_dialog,
109 const char *label)
110{
111 list_input_print(create_dialog, 1);
112
113 const int attrs_select = A_BOLD;
114
115 if (selected) wattron(create_dialog->window, attrs_select);
116
117 wmove(create_dialog->window, y, 0);
118 wprintw(create_dialog->window, "%s", label);
119
120 if (selected) wattroff(create_dialog->window, attrs_select);
33} 121}
34 122
35void 123void
36lobby_create_dialog_print(UI_LOBBY_CREATE_DIALOG_Handle *create_dialog, 124lobby_create_dialog_print(UI_LOBBY_CREATE_DIALOG_Handle *create_dialog,
37 struct MESSENGER_Application *app) 125 UNUSED struct MESSENGER_Application *app)
38{ 126{
39 /* 127 if (!(create_dialog->win))
40 Delay until it expires: 128 return;
41 129
42 30 seconds 130 create_dialog->window = *(create_dialog->win);
43 5 minutes 131
44 1 hour 132 list_input_reset(create_dialog);
45 8 hours 133 werase(create_dialog->window);
46 1 day 134
47 1 week 135 if (create_dialog->uri)
48 4 weeks 136 _lobby_iterate_print(create_dialog, create_dialog->uri);
49 Off 137 else
50 */ 138 {
51 139 _lobby_iterate_print(create_dialog, "30 seconds");
52 // TODO 140 _lobby_iterate_print(create_dialog, "5 minutes");
141 _lobby_iterate_print(create_dialog, "1 hour");
142 _lobby_iterate_print(create_dialog, "8 hours");
143 _lobby_iterate_print(create_dialog, "1 day");
144 _lobby_iterate_print(create_dialog, "1 week");
145 _lobby_iterate_print(create_dialog, "4 weeks");
146 _lobby_iterate_print(create_dialog, "Off");
147 }
53} 148}