diff options
-rw-r--r-- | src/application.h | 52 | ||||
-rw-r--r-- | src/chat/messenger.h | 9 | ||||
-rw-r--r-- | src/contact.h | 46 | ||||
-rw-r--r-- | src/event.h | 72 | ||||
-rw-r--r-- | src/file.h | 38 | ||||
-rw-r--r-- | src/resources.h | 6 | ||||
-rw-r--r-- | src/ui.h | 21 |
7 files changed, 244 insertions, 0 deletions
diff --git a/src/application.h b/src/application.h index 2c0972b..ab082a0 100644 --- a/src/application.h +++ b/src/application.h | |||
@@ -134,15 +134,38 @@ typedef struct MESSENGER_Application | |||
134 | } settings; | 134 | } settings; |
135 | } MESSENGER_Application; | 135 | } MESSENGER_Application; |
136 | 136 | ||
137 | /** | ||
138 | * Initializes the messenger application with | ||
139 | * startup arguments. | ||
140 | * | ||
141 | * @param app Messenger application | ||
142 | * @param argc Amount of arguments | ||
143 | * @param argv Arguments | ||
144 | */ | ||
137 | void | 145 | void |
138 | application_init(MESSENGER_Application *app, | 146 | application_init(MESSENGER_Application *app, |
139 | int argc, | 147 | int argc, |
140 | char **argv); | 148 | char **argv); |
141 | 149 | ||
150 | /** | ||
151 | * Returns the path from resources of the | ||
152 | * messenger application relative to its storage. | ||
153 | * | ||
154 | * @param app Messenger application | ||
155 | * @param path Path | ||
156 | * @return Resource path | ||
157 | */ | ||
142 | const gchar* | 158 | const gchar* |
143 | application_get_resource_path(MESSENGER_Application *app, | 159 | application_get_resource_path(MESSENGER_Application *app, |
144 | const char *path); | 160 | const char *path); |
145 | 161 | ||
162 | /** | ||
163 | * Runs the messenger application starting the | ||
164 | * second thread and waiting for the application | ||
165 | * to finish. | ||
166 | * | ||
167 | * @param app Messenger application | ||
168 | */ | ||
146 | void | 169 | void |
147 | application_run(MESSENGER_Application *app); | 170 | application_run(MESSENGER_Application *app); |
148 | 171 | ||
@@ -156,20 +179,49 @@ typedef void (*MESSENGER_ApplicationMessageEvent) ( | |||
156 | const struct GNUNET_CHAT_Message *msg | 179 | const struct GNUNET_CHAT_Message *msg |
157 | ); | 180 | ); |
158 | 181 | ||
182 | /** | ||
183 | * Calls a given event with the messenger application | ||
184 | * asyncronously but explicitly synchronized via mutex. | ||
185 | * | ||
186 | * @param app Messenger application | ||
187 | * @param event Event | ||
188 | */ | ||
159 | void | 189 | void |
160 | application_call_event(MESSENGER_Application *app, | 190 | application_call_event(MESSENGER_Application *app, |
161 | MESSENGER_ApplicationEvent event); | 191 | MESSENGER_ApplicationEvent event); |
162 | 192 | ||
193 | /** | ||
194 | * Calls a given message event with the messenger | ||
195 | * application asyncronously but explicitly synchronized | ||
196 | * via mutex. | ||
197 | * | ||
198 | * @param app Messenger application | ||
199 | * @param event Message event | ||
200 | * @param context Chat context | ||
201 | * @param message Message | ||
202 | */ | ||
163 | void | 203 | void |
164 | application_call_message_event(MESSENGER_Application *app, | 204 | application_call_message_event(MESSENGER_Application *app, |
165 | MESSENGER_ApplicationMessageEvent event, | 205 | MESSENGER_ApplicationMessageEvent event, |
166 | struct GNUNET_CHAT_Context *context, | 206 | struct GNUNET_CHAT_Context *context, |
167 | const struct GNUNET_CHAT_Message *message); | 207 | const struct GNUNET_CHAT_Message *message); |
168 | 208 | ||
209 | /** | ||
210 | * Signals the second thread to exit the application. | ||
211 | * | ||
212 | * @param app Messenger application | ||
213 | * @param signal Exit signal | ||
214 | */ | ||
169 | void | 215 | void |
170 | application_exit(MESSENGER_Application *app, | 216 | application_exit(MESSENGER_Application *app, |
171 | MESSENGER_ApplicationSignal signal); | 217 | MESSENGER_ApplicationSignal signal); |
172 | 218 | ||
219 | /** | ||
220 | * Returns the exit status of the messenger application. | ||
221 | * | ||
222 | * @param app Messenger application | ||
223 | * @return Exit status | ||
224 | */ | ||
173 | int | 225 | int |
174 | application_status(MESSENGER_Application *app); | 226 | application_status(MESSENGER_Application *app); |
175 | 227 | ||
diff --git a/src/chat/messenger.h b/src/chat/messenger.h index bc07119..4cceec7 100644 --- a/src/chat/messenger.h +++ b/src/chat/messenger.h | |||
@@ -39,6 +39,15 @@ typedef struct CHAT_MESSENGER_Handle | |||
39 | struct GNUNET_SCHEDULER_Task *idle; | 39 | struct GNUNET_SCHEDULER_Task *idle; |
40 | } CHAT_MESSENGER_Handle; | 40 | } CHAT_MESSENGER_Handle; |
41 | 41 | ||
42 | /** | ||
43 | * Startup event of the GNUnet scheduler thread to | ||
44 | * handle the messenger application startup. | ||
45 | * | ||
46 | * @param cls Closure | ||
47 | * @param args Arguments | ||
48 | * @param cfgfile Configuration file path | ||
49 | * @param cfg Configuration | ||
50 | */ | ||
42 | void | 51 | void |
43 | chat_messenger_run(void *cls, | 52 | chat_messenger_run(void *cls, |
44 | char *const *args, | 53 | char *const *args, |
diff --git a/src/contact.h b/src/contact.h index 8a6dd4c..61d41e7 100644 --- a/src/contact.h +++ b/src/contact.h | |||
@@ -35,27 +35,73 @@ typedef struct MESSENGER_ContactInfo | |||
35 | GList *name_avatars; | 35 | GList *name_avatars; |
36 | } MESSENGER_ContactInfo; | 36 | } MESSENGER_ContactInfo; |
37 | 37 | ||
38 | /** | ||
39 | * Creates a contact information struct to potentially | ||
40 | * update all GUI appearances of a specific contact at | ||
41 | * once. | ||
42 | * | ||
43 | * @param contact Chat contact | ||
44 | */ | ||
38 | void | 45 | void |
39 | contact_create_info(struct GNUNET_CHAT_Contact *contact); | 46 | contact_create_info(struct GNUNET_CHAT_Contact *contact); |
40 | 47 | ||
48 | /** | ||
49 | * Destroys and frees resources allocated for a given | ||
50 | * contact information struct. | ||
51 | * | ||
52 | * @param contact Chat contact | ||
53 | */ | ||
41 | void | 54 | void |
42 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact); | 55 | contact_destroy_info(struct GNUNET_CHAT_Contact *contact); |
43 | 56 | ||
57 | /** | ||
58 | * Sets the latest join/leave UI message handle so that | ||
59 | * the application can check whether a contact is available. | ||
60 | * | ||
61 | * @param contact Chat contact | ||
62 | * @param message Pointer to UI message handle | ||
63 | */ | ||
44 | void | 64 | void |
45 | contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, | 65 | contact_set_last_message_to_info(const struct GNUNET_CHAT_Contact *contact, |
46 | void *message); | 66 | void *message); |
47 | 67 | ||
68 | /** | ||
69 | * Returns the latest join/leave UI message handle of | ||
70 | * a specific contact. | ||
71 | * | ||
72 | * @param contact Chat contact | ||
73 | */ | ||
48 | void* | 74 | void* |
49 | contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact); | 75 | contact_get_last_message_from_info(const struct GNUNET_CHAT_Contact *contact); |
50 | 76 | ||
77 | /** | ||
78 | * Adds a GtkLabel to the list of labels | ||
79 | * which get updated by state changes. | ||
80 | * | ||
81 | * @param contact Chat contact | ||
82 | * @param label Label | ||
83 | */ | ||
51 | void | 84 | void |
52 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, | 85 | contact_add_name_label_to_info(const struct GNUNET_CHAT_Contact *contact, |
53 | GtkLabel *label); | 86 | GtkLabel *label); |
54 | 87 | ||
88 | /** | ||
89 | * Adds a HdyAvatar to the list of avatars | ||
90 | * which get updated by state changes. | ||
91 | * | ||
92 | * @param contact Chat contact | ||
93 | * @param avatar Avatar | ||
94 | */ | ||
55 | void | 95 | void |
56 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, | 96 | contact_add_name_avatar_to_info(const struct GNUNET_CHAT_Contact *contact, |
57 | HdyAvatar *avatar); | 97 | HdyAvatar *avatar); |
58 | 98 | ||
99 | /** | ||
100 | * Updates the connected UI elements for a given | ||
101 | * contact depending on the current state. | ||
102 | * | ||
103 | * @param contact Chat contact | ||
104 | */ | ||
59 | void | 105 | void |
60 | contact_update_info(const struct GNUNET_CHAT_Contact *contact); | 106 | contact_update_info(const struct GNUNET_CHAT_Contact *contact); |
61 | 107 | ||
diff --git a/src/event.h b/src/event.h index 505309c..d89e453 100644 --- a/src/event.h +++ b/src/event.h | |||
@@ -27,42 +27,114 @@ | |||
27 | 27 | ||
28 | #include "application.h" | 28 | #include "application.h" |
29 | 29 | ||
30 | /** | ||
31 | * Event for the UI to be called whenever the application | ||
32 | * causes any issue in back-end throwing a warning. This | ||
33 | * might be specific to a given context or none if its | ||
34 | * a general warning. | ||
35 | * | ||
36 | * @param app Messenger application | ||
37 | * @param context Chat context or NULL | ||
38 | * @param msg Warning message | ||
39 | */ | ||
30 | void | 40 | void |
31 | event_handle_warning(MESSENGER_Application *app, | 41 | event_handle_warning(MESSENGER_Application *app, |
32 | struct GNUNET_CHAT_Context *context, | 42 | struct GNUNET_CHAT_Context *context, |
33 | const struct GNUNET_CHAT_Message *msg); | 43 | const struct GNUNET_CHAT_Message *msg); |
34 | 44 | ||
45 | /** | ||
46 | * Event for the UI to be called whenever the accounts | ||
47 | * might add or remove an account from their list. | ||
48 | * | ||
49 | * @param app Messenger application | ||
50 | */ | ||
35 | void | 51 | void |
36 | event_refresh_accounts(MESSENGER_Application *app); | 52 | event_refresh_accounts(MESSENGER_Application *app); |
37 | 53 | ||
54 | /** | ||
55 | * Event for the UI to be called whenever the user | ||
56 | * updates their information. | ||
57 | * | ||
58 | * @param app Messenger application | ||
59 | */ | ||
38 | void | 60 | void |
39 | event_update_profile(MESSENGER_Application *app); | 61 | event_update_profile(MESSENGER_Application *app); |
40 | 62 | ||
63 | /** | ||
64 | * Event for the UI to be called whenever a the user | ||
65 | * joins or leaves a chat (context) via message. | ||
66 | * | ||
67 | * @param app Messenger application | ||
68 | * @param context Chat context | ||
69 | * @param msg Join/Leave message | ||
70 | */ | ||
41 | void | 71 | void |
42 | event_update_chats(MESSENGER_Application *app, | 72 | event_update_chats(MESSENGER_Application *app, |
43 | struct GNUNET_CHAT_Context *context, | 73 | struct GNUNET_CHAT_Context *context, |
44 | const struct GNUNET_CHAT_Message *msg); | 74 | const struct GNUNET_CHAT_Message *msg); |
45 | 75 | ||
76 | /** | ||
77 | * Event for the UI to be called whenever a contact | ||
78 | * joins or leaves a given context via message. | ||
79 | * | ||
80 | * @param app Messenger application | ||
81 | * @param context Chat context | ||
82 | * @param msg Join/Leave message | ||
83 | */ | ||
46 | void | 84 | void |
47 | event_presence_contact(MESSENGER_Application *app, | 85 | event_presence_contact(MESSENGER_Application *app, |
48 | struct GNUNET_CHAT_Context *context, | 86 | struct GNUNET_CHAT_Context *context, |
49 | const struct GNUNET_CHAT_Message *msg); | 87 | const struct GNUNET_CHAT_Message *msg); |
50 | 88 | ||
89 | /** | ||
90 | * Event for the UI to be called whenever a contact | ||
91 | * updates their information with a message in a | ||
92 | * given context. | ||
93 | * | ||
94 | * @param app Messenger application | ||
95 | * @param context Chat context | ||
96 | * @param msg Update message | ||
97 | */ | ||
51 | void | 98 | void |
52 | event_update_contacts(MESSENGER_Application *app, | 99 | event_update_contacts(MESSENGER_Application *app, |
53 | struct GNUNET_CHAT_Context *context, | 100 | struct GNUNET_CHAT_Context *context, |
54 | const struct GNUNET_CHAT_Message *msg); | 101 | const struct GNUNET_CHAT_Message *msg); |
55 | 102 | ||
103 | /** | ||
104 | * Event for the UI to be called whenever an invitation | ||
105 | * message gets received in a given context. | ||
106 | * | ||
107 | * @param app Messenger application | ||
108 | * @param context Chat context | ||
109 | * @param msg Invitation message | ||
110 | */ | ||
56 | void | 111 | void |
57 | event_invitation(MESSENGER_Application *app, | 112 | event_invitation(MESSENGER_Application *app, |
58 | struct GNUNET_CHAT_Context *context, | 113 | struct GNUNET_CHAT_Context *context, |
59 | const struct GNUNET_CHAT_Message *msg); | 114 | const struct GNUNET_CHAT_Message *msg); |
60 | 115 | ||
116 | /** | ||
117 | * Event for the UI to be called whenever a content | ||
118 | * message (text or file) gets received in a given | ||
119 | * context. | ||
120 | * | ||
121 | * @param app Messenger application | ||
122 | * @param context Chat context | ||
123 | * @param msg Message | ||
124 | */ | ||
61 | void | 125 | void |
62 | event_receive_message(MESSENGER_Application *app, | 126 | event_receive_message(MESSENGER_Application *app, |
63 | struct GNUNET_CHAT_Context *context, | 127 | struct GNUNET_CHAT_Context *context, |
64 | const struct GNUNET_CHAT_Message *msg); | 128 | const struct GNUNET_CHAT_Message *msg); |
65 | 129 | ||
130 | /** | ||
131 | * Event for the UI to be called whenever a message | ||
132 | * gets deleted in a given context. | ||
133 | * | ||
134 | * @param app Messenger application | ||
135 | * @param context Chat context | ||
136 | * @param msg Delete message | ||
137 | */ | ||
66 | void | 138 | void |
67 | event_delete_message(MESSENGER_Application *app, | 139 | event_delete_message(MESSENGER_Application *app, |
68 | struct GNUNET_CHAT_Context *context, | 140 | struct GNUNET_CHAT_Context *context, |
@@ -33,21 +33,59 @@ typedef struct MESSENGER_FileInfo | |||
33 | GList *file_messages; | 33 | GList *file_messages; |
34 | } MESSENGER_FileInfo; | 34 | } MESSENGER_FileInfo; |
35 | 35 | ||
36 | /** | ||
37 | * Creates a file information struct to potentially update | ||
38 | * all GUI appearances of a specific file at once. | ||
39 | * | ||
40 | * @param file Chat file | ||
41 | */ | ||
36 | void | 42 | void |
37 | file_create_info(struct GNUNET_CHAT_File *file); | 43 | file_create_info(struct GNUNET_CHAT_File *file); |
38 | 44 | ||
45 | /** | ||
46 | * Destroys and frees resources allocated for a given | ||
47 | * file information struct. | ||
48 | * | ||
49 | * @param file Chat file | ||
50 | */ | ||
39 | void | 51 | void |
40 | file_destroy_info(struct GNUNET_CHAT_File *file); | 52 | file_destroy_info(struct GNUNET_CHAT_File *file); |
41 | 53 | ||
54 | /** | ||
55 | * Adds a UI message handle to the list of handles | ||
56 | * which get updated by state changes. | ||
57 | * | ||
58 | * @param file Chat file | ||
59 | * @param message UI message handle | ||
60 | */ | ||
42 | void | 61 | void |
43 | file_add_ui_message_to_info(const struct GNUNET_CHAT_File *file, | 62 | file_add_ui_message_to_info(const struct GNUNET_CHAT_File *file, |
44 | UI_MESSAGE_Handle *message); | 63 | UI_MESSAGE_Handle *message); |
45 | 64 | ||
65 | /** | ||
66 | * Updates the connected UI elements for a given | ||
67 | * file depending on the current state of its upload | ||
68 | * process. | ||
69 | * | ||
70 | * @param file Chat file | ||
71 | * @param completed Amount of uploaded bytes | ||
72 | * @param size Size of the file in bytes | ||
73 | */ | ||
46 | void | 74 | void |
47 | file_update_upload_info(const struct GNUNET_CHAT_File *file, | 75 | file_update_upload_info(const struct GNUNET_CHAT_File *file, |
48 | uint64_t completed, | 76 | uint64_t completed, |
49 | uint64_t size); | 77 | uint64_t size); |
50 | 78 | ||
79 | /** | ||
80 | * Updates the connected UI elements for a given | ||
81 | * file depending on the current state of its download | ||
82 | * process. | ||
83 | * | ||
84 | * @param file Chat file | ||
85 | * @param app Messenger application | ||
86 | * @param completed Amount of downloaded bytes | ||
87 | * @param size Size of the file in bytes | ||
88 | */ | ||
51 | void | 89 | void |
52 | file_update_download_info(const struct GNUNET_CHAT_File *file, | 90 | file_update_download_info(const struct GNUNET_CHAT_File *file, |
53 | MESSENGER_Application *app, | 91 | MESSENGER_Application *app, |
diff --git a/src/resources.h b/src/resources.h index 82e8534..2080364 100644 --- a/src/resources.h +++ b/src/resources.h | |||
@@ -25,9 +25,15 @@ | |||
25 | #ifndef RESOURCES_H_ | 25 | #ifndef RESOURCES_H_ |
26 | #define RESOURCES_H_ | 26 | #define RESOURCES_H_ |
27 | 27 | ||
28 | /** | ||
29 | * Registers the CSS and UI components for the application. | ||
30 | */ | ||
28 | void | 31 | void |
29 | resources_register(); | 32 | resources_register(); |
30 | 33 | ||
34 | /** | ||
35 | * Unregisters the CSS and UI components for the application. | ||
36 | */ | ||
31 | void | 37 | void |
32 | resources_unregister(); | 38 | resources_unregister(); |
33 | 39 | ||
@@ -28,12 +28,33 @@ | |||
28 | #include <gtk-3.0/gtk/gtk.h> | 28 | #include <gtk-3.0/gtk/gtk.h> |
29 | #include <libhandy-1/handy.h> | 29 | #include <libhandy-1/handy.h> |
30 | 30 | ||
31 | /** | ||
32 | * Sets the text of a GtkLabel applying automatic utf8 | ||
33 | * conversion. | ||
34 | * | ||
35 | * @param label Label | ||
36 | * @param text Non-utf8 text | ||
37 | */ | ||
31 | void | 38 | void |
32 | ui_label_set_text(GtkLabel *label, const char *text); | 39 | ui_label_set_text(GtkLabel *label, const char *text); |
33 | 40 | ||
41 | /** | ||
42 | * Sets the text of a GtkEntry applying automatic utf8 | ||
43 | * conversion. | ||
44 | * | ||
45 | * @param entry Entry | ||
46 | * @param text Non-utf8 text | ||
47 | */ | ||
34 | void | 48 | void |
35 | ui_entry_set_text(GtkEntry *entry, const char *text); | 49 | ui_entry_set_text(GtkEntry *entry, const char *text); |
36 | 50 | ||
51 | /** | ||
52 | * Sets the text of a HdyAvatar applying automatic utf8 | ||
53 | * conversion. | ||
54 | * | ||
55 | * @param avatar Avatar | ||
56 | * @param text Non-utf8 text | ||
57 | */ | ||
37 | void | 58 | void |
38 | ui_avatar_set_text(HdyAvatar *avatar, const char *text); | 59 | ui_avatar_set_text(HdyAvatar *avatar, const char *text); |
39 | 60 | ||