application.h (2614B)
1 /* 2 This file is part of GNUnet. 3 Copyright (C) 2022--2025 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 <stdlib.h> 29 #include <curses.h> 30 31 #include "chat.h" 32 33 #include "ui/accounts.h" 34 #include "ui/chat.h" 35 #include "ui/chats.h" 36 37 /** 38 * @struct MESSENGER_Application 39 */ 40 typedef struct MESSENGER_Application 41 { 42 char **argv; 43 int argc; 44 45 int status; 46 WINDOW *window; 47 48 struct { 49 WINDOW *logo; 50 WINDOW *main; 51 WINDOW *left; 52 WINDOW *right; 53 WINDOW *input; 54 } ui; 55 56 MESSENGER_Chat chat; 57 58 UI_ACCOUNTS_Handle accounts; 59 UI_CHATS_Handle chats; 60 UI_CHAT_Handle current; 61 } MESSENGER_Application; 62 63 /** 64 * Clears the application handle to reset all views 65 * which might have been in use. 66 * 67 * @param[out] app Application handle 68 */ 69 void 70 application_clear(MESSENGER_Application *app); 71 72 /** 73 * Initializes the application handle with the program 74 * arguments provided from the main function. 75 * 76 * @param[out] app Application handle 77 * @param[in] argc Argument count 78 * @param[in] argv Argument array 79 */ 80 void 81 application_init(MESSENGER_Application *app, 82 int argc, 83 char **argv); 84 85 /** 86 * Refreshes the application handle freeing all temporary 87 * WINDOW handles to manage the different views which 88 * were used. 89 * 90 * @param[out] app Application handle 91 */ 92 void 93 application_refresh(MESSENGER_Application *app); 94 95 /** 96 * Starts the main loop of the application which will 97 * be processed via GNUnet and its callback management. 98 * 99 * @param[in,out] app Application handle 100 */ 101 void 102 application_run(MESSENGER_Application *app); 103 104 /** 105 * Returns the status code by the given application 106 * at current state. 107 * 108 * @param[in] app Application handle 109 * @return #EXIT_FAILURE on failure, otherwise #EXIT_SUCCESS 110 */ 111 int 112 application_status(MESSENGER_Application *app); 113 114 #endif /* APPLICATION_H_ */