@@ -70,7 +70,7 @@ void log_write(Tox *tox, int fid, const uint8_t *message, uint16_t length, _Bool
70
70
} else {
71
71
namelen = tox_friend_get_name_size (tox , fid , 0 );
72
72
tox_friend_get_name (tox , fid , name , 0 );
73
-
73
+
74
74
}
75
75
76
76
if (namelen > TOX_MAX_NAME_LENGTH ) {
@@ -279,7 +279,6 @@ static void set_callbacks(Tox *tox)
279
279
{
280
280
tox_callback_friend_request (tox , callback_friend_request , NULL );
281
281
tox_callback_friend_message (tox , callback_friend_message , NULL );
282
- tox_callback_friend_action (tox , callback_friend_action , NULL );
283
282
tox_callback_friend_name (tox , callback_name_change , NULL );
284
283
tox_callback_friend_status_message (tox , callback_status_message , NULL );
285
284
tox_callback_friend_status (tox , callback_user_status , NULL );
@@ -789,46 +788,32 @@ static void tox_thread_message(Tox *tox, ToxAv *av, uint64_t time, uint8_t msg,
789
788
break ;
790
789
}
791
790
792
- case TOX_SENDMESSAGE : {
793
- /* param1: friend #
794
- * param2: message length
795
- * data: message
796
- */
797
-
798
- /* write message to friend to logfile */
799
- log_write (tox , param1 , data , param2 , 1 , LOG_FILE_MSG_TYPE_TEXT );
800
-
801
- void * p = data ;
802
- while (param2 > TOX_MAX_MESSAGE_LENGTH ) {
803
- uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen (p + TOX_MAX_MESSAGE_LENGTH );
804
- tox_friend_send_message (tox , param1 , p , len , 0 );
805
- param2 -= len ;
806
- p += len ;
807
- }
808
-
809
- tox_friend_send_message (tox , param1 , p , param2 , 0 );
810
- free (data );
811
- break ;
812
- }
813
-
791
+ case TOX_SENDMESSAGE :
814
792
case TOX_SENDACTION : {
815
793
/* param1: friend #
816
794
* param2: message length
817
795
* data: message
818
796
*/
819
797
820
- /* write action/emote to friend to logfile */
821
- log_write (tox , param1 , data , param2 , 1 , LOG_FILE_MSG_TYPE_ACTION );
822
-
823
798
void * p = data ;
799
+ TOX_MESSAGE_TYPE type ;
800
+ if (msg == TOX_SENDACTION ){
801
+ type = TOX_MESSAGE_TYPE_ACTION ;
802
+ } else {
803
+ type = TOX_MESSAGE_TYPE_NORMAL ;
804
+ }
824
805
while (param2 > TOX_MAX_MESSAGE_LENGTH ) {
825
806
uint16_t len = TOX_MAX_MESSAGE_LENGTH - utf8_unlen (p + TOX_MAX_MESSAGE_LENGTH );
826
- tox_friend_send_action (tox , param1 , p , len , 0 );
807
+ tox_friend_send_message (tox , param1 , type , p , len , 0 );
827
808
param2 -= len ;
828
809
p += len ;
829
810
}
811
+ // Send last or only message
812
+ tox_friend_send_message (tox , param1 , type , p , param2 , 0 );
813
+
814
+ /* write message to friend to logfile */
815
+ log_write (tox , param1 , data , param2 , 1 , LOG_FILE_MSG_TYPE_TEXT );
830
816
831
- tox_friend_send_action (tox , param1 , p , param2 , 0 );
832
817
free (data );
833
818
break ;
834
819
}
0 commit comments