summaryrefslogtreecommitdiff
path: root/toxav/msi.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-08-19 13:07:45 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-08-27 01:16:14 +0100
commit13ae9e9a93a1c02fad9475002c0391b86b7ad7bb (patch)
treea9575d3582c4f40e051c93ae18dded03fdddc432 /toxav/msi.c
parent1f25fc0ae417bfc47dea4966cb5e43689aa88d5c (diff)
Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox was killed, so other toxes would then stop logging). Various bits of the code now carry a logger or pass it around. It's a bit less transparent now, but now there is no need to have a global logger, and clients can decide what to log and where.
Diffstat (limited to 'toxav/msi.c')
-rw-r--r--toxav/msi.c123
1 files changed, 64 insertions, 59 deletions
diff --git a/toxav/msi.c b/toxav/msi.c
index 2115a2d0..b98c58de 100644
--- a/toxav/msi.c
+++ b/toxav/msi.c
@@ -77,7 +77,7 @@ typedef struct {
77 77
78 78
79void msg_init (MSIMessage *dest, MSIRequest request); 79void msg_init (MSIMessage *dest, MSIRequest request);
80int msg_parse_in (MSIMessage *dest, const uint8_t *data, uint16_t length); 80int msg_parse_in (Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length);
81uint8_t *msg_parse_header_out (MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, uint16_t *length); 81uint8_t *msg_parse_header_out (MSIHeaderID id, uint8_t *dest, const void *value, uint8_t value_len, uint16_t *length);
82static int send_message (Messenger *m, uint32_t friend_number, const MSIMessage *msg); 82static int send_message (Messenger *m, uint32_t friend_number, const MSIMessage *msg);
83int send_error (Messenger *m, uint32_t friend_number, MSIError error); 83int send_error (Messenger *m, uint32_t friend_number, MSIError error);
@@ -107,19 +107,18 @@ void msi_register_callback (MSISession *session, msi_action_cb *callback, MSICal
107MSISession *msi_new (Messenger *m) 107MSISession *msi_new (Messenger *m)
108{ 108{
109 if (m == NULL) { 109 if (m == NULL) {
110 LOGGER_ERROR("Could not init session on empty messenger!");
111 return NULL; 110 return NULL;
112 } 111 }
113 112
114 MSISession *retu = calloc (sizeof (MSISession), 1); 113 MSISession *retu = calloc (sizeof (MSISession), 1);
115 114
116 if (retu == NULL) { 115 if (retu == NULL) {
117 LOGGER_ERROR("Allocation failed! Program might misbehave!"); 116 LOGGER_ERROR(m->log, "Allocation failed! Program might misbehave!");
118 return NULL; 117 return NULL;
119 } 118 }
120 119
121 if (create_recursive_mutex(retu->mutex) != 0) { 120 if (create_recursive_mutex(retu->mutex) != 0) {
122 LOGGER_ERROR("Failed to init mutex! Program might misbehave"); 121 LOGGER_ERROR(m->log, "Failed to init mutex! Program might misbehave");
123 free(retu); 122 free(retu);
124 return NULL; 123 return NULL;
125 } 124 }
@@ -131,20 +130,20 @@ MSISession *msi_new (Messenger *m)
131 /* This is called when remote terminates session */ 130 /* This is called when remote terminates session */
132 m_callback_connectionstatus_internal_av(m, on_peer_status, retu); 131 m_callback_connectionstatus_internal_av(m, on_peer_status, retu);
133 132
134 LOGGER_DEBUG("New msi session: %p ", retu); 133 LOGGER_DEBUG(m->log, "New msi session: %p ", retu);
135 return retu; 134 return retu;
136} 135}
137int msi_kill (MSISession *session) 136int msi_kill (MSISession *session)
138{ 137{
139 if (session == NULL) { 138 if (session == NULL) {
140 LOGGER_ERROR("Tried to terminate non-existing session"); 139 LOGGER_ERROR(session->messenger->log, "Tried to terminate non-existing session");
141 return -1; 140 return -1;
142 } 141 }
143 142
144 m_callback_msi_packet((struct Messenger *) session->messenger, NULL, NULL); 143 m_callback_msi_packet((struct Messenger *) session->messenger, NULL, NULL);
145 144
146 if (pthread_mutex_trylock(session->mutex) != 0) { 145 if (pthread_mutex_trylock(session->mutex) != 0) {
147 LOGGER_ERROR ("Failed to aquire lock on msi mutex"); 146 LOGGER_ERROR(session->messenger->log, "Failed to aquire lock on msi mutex");
148 return -1; 147 return -1;
149 } 148 }
150 149
@@ -165,7 +164,7 @@ int msi_kill (MSISession *session)
165 pthread_mutex_unlock(session->mutex); 164 pthread_mutex_unlock(session->mutex);
166 pthread_mutex_destroy(session->mutex); 165 pthread_mutex_destroy(session->mutex);
167 166
168 LOGGER_DEBUG("Terminated session: %p", session); 167 LOGGER_DEBUG(session->messenger->log, "Terminated session: %p", session);
169 free (session); 168 free (session);
170 return 0; 169 return 0;
171} 170}
@@ -174,15 +173,15 @@ int msi_invite (MSISession *session, MSICall **call, uint32_t friend_number, uin
174 if (!session) 173 if (!session)
175 return -1; 174 return -1;
176 175
177 LOGGER_DEBUG("Session: %p Inviting friend: %u", session, friend_number); 176 LOGGER_DEBUG(session->messenger->log, "Session: %p Inviting friend: %u", session, friend_number);
178 177
179 if (pthread_mutex_trylock(session->mutex) != 0) { 178 if (pthread_mutex_trylock(session->mutex) != 0) {
180 LOGGER_ERROR ("Failed to aquire lock on msi mutex"); 179 LOGGER_ERROR(session->messenger->log, "Failed to aquire lock on msi mutex");
181 return -1; 180 return -1;
182 } 181 }
183 182
184 if (get_call(session, friend_number) != NULL) { 183 if (get_call(session, friend_number) != NULL) {
185 LOGGER_ERROR("Already in a call"); 184 LOGGER_ERROR(session->messenger->log, "Already in a call");
186 pthread_mutex_unlock(session->mutex); 185 pthread_mutex_unlock(session->mutex);
187 return -1; 186 return -1;
188 } 187 }
@@ -206,7 +205,7 @@ int msi_invite (MSISession *session, MSICall **call, uint32_t friend_number, uin
206 205
207 (*call)->state = msi_CallRequesting; 206 (*call)->state = msi_CallRequesting;
208 207
209 LOGGER_DEBUG("Invite sent"); 208 LOGGER_DEBUG(session->messenger->log, "Invite sent");
210 pthread_mutex_unlock(session->mutex); 209 pthread_mutex_unlock(session->mutex);
211 return 0; 210 return 0;
212} 211}
@@ -215,17 +214,18 @@ int msi_hangup (MSICall *call)
215 if (!call || !call->session) 214 if (!call || !call->session)
216 return -1; 215 return -1;
217 216
218 LOGGER_DEBUG("Session: %p Hanging up call with friend: %u", call->session, call->friend_number);
219
220 MSISession *session = call->session; 217 MSISession *session = call->session;
221 218
219 LOGGER_DEBUG(session->messenger->log, "Session: %p Hanging up call with friend: %u", call->session,
220 call->friend_number);
221
222 if (pthread_mutex_trylock(session->mutex) != 0) { 222 if (pthread_mutex_trylock(session->mutex) != 0) {
223 LOGGER_ERROR ("Failed to aquire lock on msi mutex"); 223 LOGGER_ERROR(session->messenger->log, "Failed to aquire lock on msi mutex");
224 return -1; 224 return -1;
225 } 225 }
226 226
227 if (call->state == msi_CallInactive) { 227 if (call->state == msi_CallInactive) {
228 LOGGER_ERROR("Call is in invalid state!"); 228 LOGGER_ERROR(session->messenger->log, "Call is in invalid state!");
229 pthread_mutex_unlock(session->mutex); 229 pthread_mutex_unlock(session->mutex);
230 return -1; 230 return -1;
231 } 231 }
@@ -244,19 +244,19 @@ int msi_answer (MSICall *call, uint8_t capabilities)
244 if (!call || !call->session) 244 if (!call || !call->session)
245 return -1; 245 return -1;
246 246
247 LOGGER_DEBUG("Session: %p Answering call from: %u", call->session, call->friend_number);
248
249 MSISession *session = call->session; 247 MSISession *session = call->session;
250 248
249 LOGGER_DEBUG(session->messenger->log, "Session: %p Answering call from: %u", call->session, call->friend_number);
250
251 if (pthread_mutex_trylock(session->mutex) != 0) { 251 if (pthread_mutex_trylock(session->mutex) != 0) {
252 LOGGER_ERROR ("Failed to aquire lock on msi mutex"); 252 LOGGER_ERROR(session->messenger->log, "Failed to aquire lock on msi mutex");
253 return -1; 253 return -1;
254 } 254 }
255 255
256 if (call->state != msi_CallRequested) { 256 if (call->state != msi_CallRequested) {
257 /* Though sending in invalid state will not cause anything wierd 257 /* Though sending in invalid state will not cause anything wierd
258 * Its better to not do it like a maniac */ 258 * Its better to not do it like a maniac */
259 LOGGER_ERROR("Call is in invalid state!"); 259 LOGGER_ERROR(session->messenger->log, "Call is in invalid state!");
260 pthread_mutex_unlock(session->mutex); 260 pthread_mutex_unlock(session->mutex);
261 return -1; 261 return -1;
262 } 262 }
@@ -281,17 +281,18 @@ int msi_change_capabilities(MSICall *call, uint8_t capabilities)
281 if (!call || !call->session) 281 if (!call || !call->session)
282 return -1; 282 return -1;
283 283
284 LOGGER_DEBUG("Session: %p Trying to change capabilities to friend %u", call->session, call->friend_number);
285
286 MSISession *session = call->session; 284 MSISession *session = call->session;
287 285
286 LOGGER_DEBUG(session->messenger->log, "Session: %p Trying to change capabilities to friend %u", call->session,
287 call->friend_number);
288
288 if (pthread_mutex_trylock(session->mutex) != 0) { 289 if (pthread_mutex_trylock(session->mutex) != 0) {
289 LOGGER_ERROR ("Failed to aquire lock on msi mutex"); 290 LOGGER_ERROR(session->messenger->log, "Failed to aquire lock on msi mutex");
290 return -1; 291 return -1;
291 } 292 }
292 293
293 if (call->state != msi_CallActive) { 294 if (call->state != msi_CallActive) {
294 LOGGER_ERROR("Call is in invalid state!"); 295 LOGGER_ERROR(session->messenger->log, "Call is in invalid state!");
295 pthread_mutex_unlock(session->mutex); 296 pthread_mutex_unlock(session->mutex);
296 return -1; 297 return -1;
297 } 298 }
@@ -320,16 +321,16 @@ void msg_init(MSIMessage *dest, MSIRequest request)
320 dest->request.exists = true; 321 dest->request.exists = true;
321 dest->request.value = request; 322 dest->request.value = request;
322} 323}
323int msg_parse_in (MSIMessage *dest, const uint8_t *data, uint16_t length) 324int msg_parse_in (Logger *log, MSIMessage *dest, const uint8_t *data, uint16_t length)
324{ 325{
325 /* Parse raw data received from socket into MSIMessage struct */ 326 /* Parse raw data received from socket into MSIMessage struct */
326 327
327#define CHECK_SIZE(bytes, constraint, size) \ 328#define CHECK_SIZE(bytes, constraint, size) \
328 if ((constraint -= (2 + size)) < 1) { LOGGER_ERROR("Read over length!"); return -1; } \ 329 if ((constraint -= (2 + size)) < 1) { LOGGER_ERROR(log, "Read over length!"); return -1; } \
329 if (bytes[1] != size) { LOGGER_ERROR("Invalid data size!"); return -1; } 330 if (bytes[1] != size) { LOGGER_ERROR(log, "Invalid data size!"); return -1; }
330 331
331#define CHECK_ENUM_HIGH(bytes, enum_high) /* Assumes size == 1 */ \ 332#define CHECK_ENUM_HIGH(bytes, enum_high) /* Assumes size == 1 */ \
332 if (bytes[2] > enum_high) { LOGGER_ERROR("Failed enum high limit!"); return -1; } 333 if (bytes[2] > enum_high) { LOGGER_ERROR(log, "Failed enum high limit!"); return -1; }
333 334
334#define SET_UINT8(bytes, header) do { \ 335#define SET_UINT8(bytes, header) do { \
335 header.value = bytes[2]; \ 336 header.value = bytes[2]; \
@@ -347,7 +348,7 @@ int msg_parse_in (MSIMessage *dest, const uint8_t *data, uint16_t length)
347 assert(dest); 348 assert(dest);
348 349
349 if (length == 0 || data[length - 1]) { /* End byte must have value 0 */ 350 if (length == 0 || data[length - 1]) { /* End byte must have value 0 */
350 LOGGER_ERROR("Invalid end byte"); 351 LOGGER_ERROR(log, "Invalid end byte");
351 return -1; 352 return -1;
352 } 353 }
353 354
@@ -376,14 +377,14 @@ int msg_parse_in (MSIMessage *dest, const uint8_t *data, uint16_t length)
376 break; 377 break;
377 378
378 default: 379 default:
379 LOGGER_ERROR("Invalid id byte"); 380 LOGGER_ERROR(log, "Invalid id byte");
380 return -1; 381 return -1;
381 break; 382 break;
382 } 383 }
383 } 384 }
384 385
385 if (dest->request.exists == false) { 386 if (dest->request.exists == false) {
386 LOGGER_ERROR("Invalid request field!"); 387 LOGGER_ERROR(log, "Invalid request field!");
387 return -1; 388 return -1;
388 } 389 }
389 390
@@ -427,7 +428,7 @@ int send_message (Messenger *m, uint32_t friend_number, const MSIMessage *msg)
427 it = msg_parse_header_out(IDRequest, it, &cast, 428 it = msg_parse_header_out(IDRequest, it, &cast,
428 sizeof(cast), &size); 429 sizeof(cast), &size);
429 } else { 430 } else {
430 LOGGER_DEBUG("Must have request field"); 431 LOGGER_DEBUG(m->log, "Must have request field");
431 return -1; 432 return -1;
432 } 433 }
433 434
@@ -443,7 +444,7 @@ int send_message (Messenger *m, uint32_t friend_number, const MSIMessage *msg)
443 } 444 }
444 445
445 if (it == parsed) { 446 if (it == parsed) {
446 LOGGER_WARNING("Parsing message failed; empty message"); 447 LOGGER_WARNING(m->log, "Parsing message failed; empty message");
447 return -1; 448 return -1;
448 } 449 }
449 450
@@ -451,7 +452,7 @@ int send_message (Messenger *m, uint32_t friend_number, const MSIMessage *msg)
451 size ++; 452 size ++;
452 453
453 if (m_msi_packet(m, friend_number, parsed, size)) { 454 if (m_msi_packet(m, friend_number, parsed, size)) {
454 LOGGER_DEBUG("Sent message"); 455 LOGGER_DEBUG(m->log, "Sent message");
455 return 0; 456 return 0;
456 } 457 }
457 458
@@ -462,7 +463,7 @@ int send_error (Messenger *m, uint32_t friend_number, MSIError error)
462 /* Send error message */ 463 /* Send error message */
463 assert(m); 464 assert(m);
464 465
465 LOGGER_DEBUG("Sending error: %d to friend: %d", error, friend_number); 466 LOGGER_DEBUG(m->log, "Sending error: %d to friend: %d", error, friend_number);
466 467
467 MSIMessage msg; 468 MSIMessage msg;
468 msg_init(&msg, requ_pop); 469 msg_init(&msg, requ_pop);
@@ -478,10 +479,11 @@ int invoke_callback(MSICall *call, MSICallbackID cb)
478 assert(call); 479 assert(call);
479 480
480 if (call->session->callbacks[cb]) { 481 if (call->session->callbacks[cb]) {
481 LOGGER_DEBUG("Invoking callback function: %d", cb); 482 LOGGER_DEBUG(call->session->messenger->log, "Invoking callback function: %d", cb);
482 483
483 if (call->session->callbacks[cb] (call->session->av, call) != 0) { 484 if (call->session->callbacks[cb] (call->session->av, call) != 0) {
484 LOGGER_WARNING("Callback state handling failed, sending error"); 485 LOGGER_WARNING(call->session->messenger->log,
486 "Callback state handling failed, sending error");
485 goto FAILURE; 487 goto FAILURE;
486 } 488 }
487 489
@@ -565,10 +567,10 @@ void kill_call (MSICall *call)
565 if (call == NULL) 567 if (call == NULL)
566 return; 568 return;
567 569
568 LOGGER_DEBUG("Killing call: %p", call);
569
570 MSISession *session = call->session; 570 MSISession *session = call->session;
571 571
572 LOGGER_DEBUG(session->messenger->log, "Killing call: %p", call);
573
572 MSICall *prev = call->prev; 574 MSICall *prev = call->prev;
573 MSICall *next = call->next; 575 MSICall *next = call->next;
574 576
@@ -601,7 +603,7 @@ void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *
601 603
602 switch (status) { 604 switch (status) {
603 case 0: { /* Friend is now offline */ 605 case 0: { /* Friend is now offline */
604 LOGGER_DEBUG("Friend %d is now offline", friend_number); 606 LOGGER_DEBUG(m->log, "Friend %d is now offline", friend_number);
605 607
606 pthread_mutex_lock(session->mutex); 608 pthread_mutex_lock(session->mutex);
607 MSICall *call = get_call(session, friend_number); 609 MSICall *call = get_call(session, friend_number);
@@ -624,10 +626,11 @@ void on_peer_status(Messenger *m, uint32_t friend_number, uint8_t status, void *
624void handle_init (MSICall *call, const MSIMessage *msg) 626void handle_init (MSICall *call, const MSIMessage *msg)
625{ 627{
626 assert(call); 628 assert(call);
627 LOGGER_DEBUG("Session: %p Handling 'init' friend: %d", call->session, call->friend_number); 629 LOGGER_DEBUG(call->session->messenger->log,
630 "Session: %p Handling 'init' friend: %d", call->session, call->friend_number);
628 631
629 if (!msg->capabilities.exists) { 632 if (!msg->capabilities.exists) {
630 LOGGER_WARNING("Session: %p Invalid capabilities on 'init'"); 633 LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'init'");
631 call->error = msi_EInvalidMessage; 634 call->error = msi_EInvalidMessage;
632 goto FAILURE; 635 goto FAILURE;
633 } 636 }
@@ -651,7 +654,7 @@ void handle_init (MSICall *call, const MSIMessage *msg)
651 * we can automatically answer the re-call. 654 * we can automatically answer the re-call.
652 */ 655 */
653 656
654 LOGGER_INFO("Friend is recalling us"); 657 LOGGER_INFO(call->session->messenger->log, "Friend is recalling us");
655 658
656 MSIMessage msg; 659 MSIMessage msg;
657 msg_init(&msg, requ_push); 660 msg_init(&msg, requ_push);
@@ -668,7 +671,7 @@ void handle_init (MSICall *call, const MSIMessage *msg)
668 break; 671 break;
669 672
670 default: { 673 default: {
671 LOGGER_WARNING("Session: %p Invalid state on 'init'"); 674 LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid state on 'init'");
672 call->error = msi_EInvalidState; 675 call->error = msi_EInvalidState;
673 goto FAILURE; 676 goto FAILURE;
674 } 677 }
@@ -684,10 +687,11 @@ void handle_push (MSICall *call, const MSIMessage *msg)
684{ 687{
685 assert(call); 688 assert(call);
686 689
687 LOGGER_DEBUG("Session: %p Handling 'push' friend: %d", call->session, call->friend_number); 690 LOGGER_DEBUG(call->session->messenger->log, "Session: %p Handling 'push' friend: %d", call->session,
691 call->friend_number);
688 692
689 if (!msg->capabilities.exists) { 693 if (!msg->capabilities.exists) {
690 LOGGER_WARNING("Session: %p Invalid capabilities on 'push'"); 694 LOGGER_WARNING(call->session->messenger->log, "Session: %p Invalid capabilities on 'push'");
691 call->error = msi_EInvalidMessage; 695 call->error = msi_EInvalidMessage;
692 goto FAILURE; 696 goto FAILURE;
693 } 697 }
@@ -696,7 +700,7 @@ void handle_push (MSICall *call, const MSIMessage *msg)
696 case msi_CallActive: { 700 case msi_CallActive: {
697 /* Only act if capabilities changed */ 701 /* Only act if capabilities changed */
698 if (call->peer_capabilities != msg->capabilities.value) { 702 if (call->peer_capabilities != msg->capabilities.value) {
699 LOGGER_INFO("Friend is changing capabilities to: %u", msg->capabilities.value); 703 LOGGER_INFO(call->session->messenger->log, "Friend is changing capabilities to: %u", msg->capabilities.value);
700 704
701 call->peer_capabilities = msg->capabilities.value; 705 call->peer_capabilities = msg->capabilities.value;
702 706
@@ -707,7 +711,7 @@ void handle_push (MSICall *call, const MSIMessage *msg)
707 break; 711 break;
708 712
709 case msi_CallRequesting: { 713 case msi_CallRequesting: {
710 LOGGER_INFO("Friend answered our call"); 714 LOGGER_INFO(call->session->messenger->log, "Friend answered our call");
711 715
712 /* Call started */ 716 /* Call started */
713 call->peer_capabilities = msg->capabilities.value; 717 call->peer_capabilities = msg->capabilities.value;
@@ -722,7 +726,7 @@ void handle_push (MSICall *call, const MSIMessage *msg)
722 /* Pushes during initialization state are ignored */ 726 /* Pushes during initialization state are ignored */
723 case msi_CallInactive: 727 case msi_CallInactive:
724 case msi_CallRequested: { 728 case msi_CallRequested: {
725 LOGGER_WARNING("Ignoring invalid push"); 729 LOGGER_WARNING(call->session->messenger->log, "Ignoring invalid push");
726 } 730 }
727 break; 731 break;
728 } 732 }
@@ -737,39 +741,40 @@ void handle_pop (MSICall *call, const MSIMessage *msg)
737{ 741{
738 assert(call); 742 assert(call);
739 743
740 LOGGER_DEBUG("Session: %p Handling 'pop', friend id: %d", call->session, call->friend_number); 744 LOGGER_DEBUG(call->session->messenger->log, "Session: %p Handling 'pop', friend id: %d", call->session,
745 call->friend_number);
741 746
742 /* callback errors are ignored */ 747 /* callback errors are ignored */
743 748
744 if (msg->error.exists) { 749 if (msg->error.exists) {
745 LOGGER_WARNING("Friend detected an error: %d", msg->error.value); 750 LOGGER_WARNING(call->session->messenger->log, "Friend detected an error: %d", msg->error.value);
746 call->error = msg->error.value; 751 call->error = msg->error.value;
747 invoke_callback(call, msi_OnError); 752 invoke_callback(call, msi_OnError);
748 753
749 } else switch (call->state) { 754 } else switch (call->state) {
750 case msi_CallInactive: { 755 case msi_CallInactive: {
751 LOGGER_ERROR("Handling what should be impossible case"); 756 LOGGER_ERROR(call->session->messenger->log, "Handling what should be impossible case");
752 abort(); 757 abort();
753 } 758 }
754 break; 759 break;
755 760
756 case msi_CallActive: { 761 case msi_CallActive: {
757 /* Hangup */ 762 /* Hangup */
758 LOGGER_INFO("Friend hung up on us"); 763 LOGGER_INFO(call->session->messenger->log, "Friend hung up on us");
759 invoke_callback(call, msi_OnEnd); 764 invoke_callback(call, msi_OnEnd);
760 } 765 }
761 break; 766 break;
762 767
763 case msi_CallRequesting: { 768 case msi_CallRequesting: {
764 /* Reject */ 769 /* Reject */
765 LOGGER_INFO("Friend rejected our call"); 770 LOGGER_INFO(call->session->messenger->log, "Friend rejected our call");
766 invoke_callback(call, msi_OnEnd); 771 invoke_callback(call, msi_OnEnd);
767 } 772 }
768 break; 773 break;
769 774
770 case msi_CallRequested: { 775 case msi_CallRequested: {
771 /* Cancel */ 776 /* Cancel */
772 LOGGER_INFO("Friend canceled call invite"); 777 LOGGER_INFO(call->session->messenger->log, "Friend canceled call invite");
773 invoke_callback(call, msi_OnEnd); 778 invoke_callback(call, msi_OnEnd);
774 } 779 }
775 break; 780 break;
@@ -779,17 +784,17 @@ void handle_pop (MSICall *call, const MSIMessage *msg)
779} 784}
780void handle_msi_packet (Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object) 785void handle_msi_packet (Messenger *m, uint32_t friend_number, const uint8_t *data, uint16_t length, void *object)
781{ 786{
782 LOGGER_DEBUG("Got msi message"); 787 LOGGER_DEBUG(m->log, "Got msi message");
783 788
784 MSISession *session = object; 789 MSISession *session = object;
785 MSIMessage msg; 790 MSIMessage msg;
786 791
787 if (msg_parse_in (&msg, data, length) == -1) { 792 if (msg_parse_in (m->log, &msg, data, length) == -1) {
788 LOGGER_WARNING("Error parsing message"); 793 LOGGER_WARNING(m->log, "Error parsing message");
789 send_error(m, friend_number, msi_EInvalidMessage); 794 send_error(m, friend_number, msi_EInvalidMessage);
790 return; 795 return;
791 } else { 796 } else {
792 LOGGER_DEBUG("Successfully parsed message"); 797 LOGGER_DEBUG(m->log, "Successfully parsed message");
793 } 798 }
794 799
795 pthread_mutex_lock(session->mutex); 800 pthread_mutex_lock(session->mutex);