summaryrefslogtreecommitdiff
path: root/core/Messenger.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/Messenger.h')
-rw-r--r--core/Messenger.h40
1 files changed, 24 insertions, 16 deletions
diff --git a/core/Messenger.h b/core/Messenger.h
index 36e24596..fa69d104 100644
--- a/core/Messenger.h
+++ b/core/Messenger.h
@@ -105,22 +105,30 @@ typedef struct Messenger {
105 Friend *friendlist; 105 Friend *friendlist;
106 uint32_t numfriends; 106 uint32_t numfriends;
107 107
108 void (*friend_message)(struct Messenger *m, int, uint8_t *, uint16_t); 108 void (*friend_message)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
109 uint8_t friend_message_isset; 109 uint8_t friend_message_isset;
110 void (*friend_action)(struct Messenger *m, int, uint8_t *, uint16_t); 110 void* friend_message_userdata;
111 void (*friend_action)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
111 uint8_t friend_action_isset; 112 uint8_t friend_action_isset;
112 void (*friend_namechange)(struct Messenger *m, int, uint8_t *, uint16_t); 113 void* friend_action_userdata;
114 void (*friend_namechange)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
113 uint8_t friend_namechange_isset; 115 uint8_t friend_namechange_isset;
114 void (*friend_statusmessagechange)(struct Messenger *m, int, uint8_t *, uint16_t); 116 void* friend_namechange_userdata;
117 void (*friend_statusmessagechange)(struct Messenger *m, int, uint8_t *, uint16_t, void*);
115 uint8_t friend_statusmessagechange_isset; 118 uint8_t friend_statusmessagechange_isset;
116 void (*friend_userstatuschange)(struct Messenger *m, int, USERSTATUS); 119 void* friend_statusmessagechange_userdata;
120 void (*friend_userstatuschange)(struct Messenger *m, int, USERSTATUS, void*);
117 uint8_t friend_userstatuschange_isset; 121 uint8_t friend_userstatuschange_isset;
118 void (*read_receipt)(struct Messenger *m, int, uint32_t); 122 void* friend_userstatuschange_userdata;
123 void (*read_receipt)(struct Messenger *m, int, uint32_t, void*);
119 uint8_t read_receipt_isset; 124 uint8_t read_receipt_isset;
120 void (*friend_statuschange)(struct Messenger *m, int, uint8_t); 125 void* read_receipt_userdata;
126 void (*friend_statuschange)(struct Messenger *m, int, uint8_t, void*);
121 uint8_t friend_statuschange_isset; 127 uint8_t friend_statuschange_isset;
122 void (*friend_connectionstatuschange)(struct Messenger *m, int, uint8_t); 128 void* friend_statuschange_userdata;
129 void (*friend_connectionstatuschange)(struct Messenger *m, int, uint8_t, void*);
123 uint8_t friend_connectionstatuschange_isset; 130 uint8_t friend_connectionstatuschange_isset;
131 void* friend_connectionstatuschange_userdata;
124 132
125 133
126} Messenger; 134} Messenger;
@@ -230,29 +238,29 @@ void m_set_sends_receipts(Messenger *m, int friendnumber, int yesno);
230 238
231/* set the function that will be executed when a friend request is received. 239/* set the function that will be executed when a friend request is received.
232 function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */ 240 function format is function(uint8_t * public_key, uint8_t * data, uint16_t length) */
233void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t)); 241void m_callback_friendrequest(Messenger *m, void (*function)(uint8_t *, uint8_t *, uint16_t, void*), void* userdata);
234 242
235/* set the function that will be executed when a message from a friend is received. 243/* set the function that will be executed when a message from a friend is received.
236 function format is: function(int friendnumber, uint8_t * message, uint32_t length) */ 244 function format is: function(int friendnumber, uint8_t * message, uint32_t length) */
237void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t)); 245void m_callback_friendmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata);
238 246
239/* set the function that will be executed when an action from a friend is received. 247/* set the function that will be executed when an action from a friend is received.
240 function format is: function(int friendnumber, uint8_t * action, uint32_t length) */ 248 function format is: function(int friendnumber, uint8_t * action, uint32_t length) */
241void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t)); 249void m_callback_action(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata);
242 250
243/* set the callback for name changes 251/* set the callback for name changes
244 function(int friendnumber, uint8_t *newname, uint16_t length) 252 function(int friendnumber, uint8_t *newname, uint16_t length)
245 you are not responsible for freeing newname */ 253 you are not responsible for freeing newname */
246void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t)); 254void m_callback_namechange(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata);
247 255
248/* set the callback for status message changes 256/* set the callback for status message changes
249 function(int friendnumber, uint8_t *newstatus, uint16_t length) 257 function(int friendnumber, uint8_t *newstatus, uint16_t length)
250 you are not responsible for freeing newstatus */ 258 you are not responsible for freeing newstatus */
251void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t)); 259void m_callback_statusmessage(Messenger *m, void (*function)(Messenger *m, int, uint8_t *, uint16_t, void*), void* userdata);
252 260
253/* set the callback for status type changes 261/* set the callback for status type changes
254 function(int friendnumber, USERSTATUS kind) */ 262 function(int friendnumber, USERSTATUS kind) */
255void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS)); 263void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USERSTATUS, void*), void* userdata);
256 264
257/* set the callback for read receipts 265/* set the callback for read receipts
258 function(int friendnumber, uint32_t receipt) 266 function(int friendnumber, uint32_t receipt)
@@ -261,7 +269,7 @@ void m_callback_userstatus(Messenger *m, void (*function)(Messenger *m, int, USE
261 has been received on the other side. since core doesn't 269 has been received on the other side. since core doesn't
262 track ids for you, receipt may not correspond to any message 270 track ids for you, receipt may not correspond to any message
263 in that case, you should discard it. */ 271 in that case, you should discard it. */
264void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t)); 272void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, uint32_t, void*), void* userdata);
265 273
266/* set the callback for connection status changes 274/* set the callback for connection status changes
267 function(int friendnumber, uint8_t status) 275 function(int friendnumber, uint8_t status)
@@ -271,7 +279,7 @@ void m_callback_read_receipt(Messenger *m, void (*function)(Messenger *m, int, u
271 note that this callback is not called when adding friends, thus the "after 279 note that this callback is not called when adding friends, thus the "after
272 being previously online" part. it's assumed that when adding friends, 280 being previously online" part. it's assumed that when adding friends,
273 their connection status is offline. */ 281 their connection status is offline. */
274void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t)); 282void m_callback_connectionstatus(Messenger *m, void (*function)(Messenger *m, int, uint8_t, void*), void* userdata);
275 283
276/* run this at startup 284/* run this at startup
277 * returns allocated instance of Messenger on success 285 * returns allocated instance of Messenger on success