application.h (2594B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2022--2026 GNUnet e.V. 4 5 GNUnet is free software: you can redistribute it and/or modify it 6 under the terms of the GNU Affero General Public License as published 7 by the Free Software Foundation, either version 3 of the License, 8 or (at your option) any later version. 9 10 GNUnet is distributed in the hope that it will be useful, but 11 WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Affero General Public License for more details. 14 15 You should have received a copy of the GNU Affero General Public License 16 along with this program. If not, see <http://www.gnu.org/licenses/>. 17 18 SPDX-License-Identifier: AGPL3.0-or-later 19 */ 20 /* 21 * @author Tobias Frisch 22 * @file application.h 23 */ 24 25 #ifndef APPLICATION_H_ 26 #define APPLICATION_H_ 27 28 #include <curses.h> 29 30 #include "chat.h" 31 32 #include "ui/accounts.h" 33 #include "ui/chat.h" 34 #include "ui/chats.h" 35 36 /** 37 * @struct MESSENGER_Application 38 */ 39 typedef struct MESSENGER_Application 40 { 41 char **argv; 42 int argc; 43 44 int status; 45 WINDOW *window; 46 47 struct { 48 WINDOW *logo; 49 WINDOW *main; 50 WINDOW *left; 51 WINDOW *right; 52 WINDOW *input; 53 } ui; 54 55 MESSENGER_Chat chat; 56 57 UI_ACCOUNTS_Handle accounts; 58 UI_CHATS_Handle chats; 59 UI_CHAT_Handle current; 60 } MESSENGER_Application; 61 62 /** 63 * Clears the application handle to reset all views 64 * which might have been in use. 65 * 66 * @param[out] app Application handle 67 */ 68 void 69 application_clear(MESSENGER_Application *app); 70 71 /** 72 * Initializes the application handle with the program 73 * arguments provided from the main function. 74 * 75 * @param[out] app Application handle 76 * @param[in] argc Argument count 77 * @param[in] argv Argument array 78 */ 79 void 80 application_init(MESSENGER_Application *app, 81 int argc, 82 char **argv); 83 84 /** 85 * Refreshes the application handle freeing all temporary 86 * WINDOW handles to manage the different views which 87 * were used. 88 * 89 * @param[out] app Application handle 90 */ 91 void 92 application_refresh(MESSENGER_Application *app); 93 94 /** 95 * Starts the main loop of the application which will 96 * be processed via GNUnet and its callback management. 97 * 98 * @param[in,out] app Application handle 99 */ 100 void 101 application_run(MESSENGER_Application *app); 102 103 /** 104 * Returns the status code by the given application 105 * at current state. 106 * 107 * @param[in] app Application handle 108 * @return #EXIT_FAILURE on failure, otherwise #EXIT_SUCCESS 109 */ 110 int 111 application_status(MESSENGER_Application *app); 112 113 #endif /* APPLICATION_H_ */