summaryrefslogtreecommitdiff
path: root/core/Messenger.c
diff options
context:
space:
mode:
authorSebastian Stal <stal@pyboard.net>2013-07-18 13:58:03 -0700
committerSebastian Stal <stal@pyboard.net>2013-07-18 13:58:03 -0700
commit0de611627d7c5eb666e05d4cb2fd2de990e4d01b (patch)
tree096115b2fe9f31d44a3f2f4f593d3d448b29e62b /core/Messenger.c
parent01a9fb8f5bb46927cdf3cdd9fdf387d9013099d5 (diff)
Move packet IDs to Messenger.h.
Diffstat (limited to 'core/Messenger.c')
-rw-r--r--core/Messenger.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index 2b9644a3..09cd0e9f 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -223,7 +223,7 @@ int m_sendmessage(int friendnumber, uint8_t * message, uint32_t length)
223 return 0; 223 return 0;
224 } 224 }
225 uint8_t temp[MAX_DATA_SIZE]; 225 uint8_t temp[MAX_DATA_SIZE];
226 temp[0] = 64; 226 temp[0] = PACKET_ID_MESSAGE;
227 memcpy(temp + 1, message, length); 227 memcpy(temp + 1, message, length);
228 return write_cryptpacket(friendlist[friendnumber].crypt_connection_id, temp, length + 1); 228 return write_cryptpacket(friendlist[friendnumber].crypt_connection_id, temp, length + 1);
229} 229}
@@ -233,7 +233,7 @@ static int m_sendname(int friendnumber, uint8_t * name)
233{ 233{
234 uint8_t temp[MAX_NAME_LENGTH + 1]; 234 uint8_t temp[MAX_NAME_LENGTH + 1];
235 memcpy(temp + 1, name, MAX_NAME_LENGTH); 235 memcpy(temp + 1, name, MAX_NAME_LENGTH);
236 temp[0] = 48; 236 temp[0] = PACKET_ID_NICKNAME;
237 return write_cryptpacket(friendlist[friendnumber].crypt_connection_id, temp, MAX_NAME_LENGTH + 1); 237 return write_cryptpacket(friendlist[friendnumber].crypt_connection_id, temp, MAX_NAME_LENGTH + 1);
238} 238}
239 239
@@ -334,7 +334,7 @@ static int send_userstatus(int friendnumber, uint8_t * status, uint16_t length)
334{ 334{
335 uint8_t *thepacket = malloc(length + 1); 335 uint8_t *thepacket = malloc(length + 1);
336 memcpy(thepacket + 1, status, length); 336 memcpy(thepacket + 1, status, length);
337 thepacket[0] = 49; 337 thepacket[0] = PACKET_ID_USERSTATUS;
338 int written = write_cryptpacket(friendlist[friendnumber].crypt_connection_id, thepacket, length + 1); 338 int written = write_cryptpacket(friendlist[friendnumber].crypt_connection_id, thepacket, length + 1);
339 free(thepacket); 339 free(thepacket);
340 return written; 340 return written;
@@ -456,14 +456,14 @@ static void doFriends()
456 if(len > 0) 456 if(len > 0)
457 { 457 {
458 switch(temp[0]) { 458 switch(temp[0]) {
459 case 48: { 459 case PACKET_ID_NICKNAME: {
460 if (len != MAX_NAME_LENGTH + 1) break; 460 if (len != MAX_NAME_LENGTH + 1) break;
461 friend_namechange(i, temp + 1, MAX_NAME_LENGTH); // todo: use the actual length 461 friend_namechange(i, temp + 1, MAX_NAME_LENGTH); // todo: use the actual length
462 memcpy(friendlist[i].name, temp + 1, MAX_NAME_LENGTH); 462 memcpy(friendlist[i].name, temp + 1, MAX_NAME_LENGTH);
463 friendlist[i].name[MAX_NAME_LENGTH - 1] = 0;//make sure the NULL terminator is present. 463 friendlist[i].name[MAX_NAME_LENGTH - 1] = 0;//make sure the NULL terminator is present.
464 break; 464 break;
465 } 465 }
466 case 49: { 466 case PACKET_ID_USERSTATUS: {
467 uint8_t *status = calloc(MIN(len - 1, MAX_USERSTATUS_LENGTH), 1); 467 uint8_t *status = calloc(MIN(len - 1, MAX_USERSTATUS_LENGTH), 1);
468 memcpy(status, temp + 1, MIN(len - 1, MAX_USERSTATUS_LENGTH)); 468 memcpy(status, temp + 1, MIN(len - 1, MAX_USERSTATUS_LENGTH));
469 friend_statuschange(i, status, MIN(len - 1, MAX_USERSTATUS_LENGTH)); 469 friend_statuschange(i, status, MIN(len - 1, MAX_USERSTATUS_LENGTH));
@@ -471,7 +471,7 @@ static void doFriends()
471 free(status); 471 free(status);
472 break; 472 break;
473 } 473 }
474 case 64: { 474 case PACKET_ID_MESSAGE: {
475 (*friend_message)(i, temp + 1, len - 1); 475 (*friend_message)(i, temp + 1, len - 1);
476 break; 476 break;
477 } 477 }