| 1692 } |
1692 } |
| 1693 } |
1693 } |
| 1694 |
1694 |
| 1695 |
1695 |
| 1696 /*------------------------------------------------------------------------ |
1696 /*------------------------------------------------------------------------ |
| |
1697 * Parse the received mood value, and ensure that it is supported. |
| |
1698 * |
| |
1699 * @param value The received mood value. |
| |
1700 * @return A valid mood value. |
| |
1701 */ |
| |
1702 static short mxit_parse_mood( const char* value ) |
| |
1703 { |
| |
1704 short mood = atoi( value ); |
| |
1705 |
| |
1706 /* ensure that the mood value is valid */ |
| |
1707 if ( ( mood >= MXIT_MOOD_NONE ) && ( mood <= MXIT_MOOD_STRESSED ) ) |
| |
1708 return mood; |
| |
1709 |
| |
1710 return MXIT_MOOD_NONE; |
| |
1711 } |
| |
1712 |
| |
1713 |
| |
1714 /*------------------------------------------------------------------------ |
| 1697 * Process a received contact update packet. |
1715 * Process a received contact update packet. |
| 1698 * |
1716 * |
| 1699 * @param session The MXit session object |
1717 * @param session The MXit session object |
| 1700 * @param records The packet's data records |
1718 * @param records The packet's data records |
| 1701 * @param rcount The number of data records |
1719 * @param rcount The number of data records |
| 1724 mxit_strip_domain( contact->username ); /* remove dummy domain */ |
1742 mxit_strip_domain( contact->username ); /* remove dummy domain */ |
| 1725 g_strlcpy( contact->alias, rec->fields[2]->data, sizeof( contact->alias ) ); |
1743 g_strlcpy( contact->alias, rec->fields[2]->data, sizeof( contact->alias ) ); |
| 1726 |
1744 |
| 1727 contact->presence = mxit_parse_presence( rec->fields[3]->data ); |
1745 contact->presence = mxit_parse_presence( rec->fields[3]->data ); |
| 1728 contact->type = atoi( rec->fields[4]->data ); |
1746 contact->type = atoi( rec->fields[4]->data ); |
| 1729 contact->mood = atoi( rec->fields[5]->data ); |
1747 contact->mood = mxit_parse_mood( rec->fields[5]->data ); |
| 1730 |
1748 |
| 1731 if ( rec->fcount > 6 ) { |
1749 if ( rec->fcount > 6 ) { |
| 1732 /* added in protocol 5.9 - flags & subtype */ |
1750 /* added in protocol 5.9 - flags & subtype */ |
| 1733 contact->flags = atoi( rec->fields[6]->data ); |
1751 contact->flags = atoi( rec->fields[6]->data ); |
| 1734 contact->subtype = rec->fields[7]->data[0]; |
1752 contact->subtype = rec->fields[7]->data[0]; |
| 1781 mxit_strip_domain( rec->fields[0]->data ); /* contactAddress */ |
1799 mxit_strip_domain( rec->fields[0]->data ); /* contactAddress */ |
| 1782 |
1800 |
| 1783 if ( rec->fcount >= 7 ) /* flags field is included */ |
1801 if ( rec->fcount >= 7 ) /* flags field is included */ |
| 1784 flags = atoi( rec->fields[6]->data ); |
1802 flags = atoi( rec->fields[6]->data ); |
| 1785 |
1803 |
| 1786 mxit_update_buddy_presence( session, rec->fields[0]->data, mxit_parse_presence( rec->fields[1]->data ), atoi( rec->fields[2]->data ), |
1804 mxit_update_buddy_presence( session, rec->fields[0]->data, mxit_parse_presence( rec->fields[1]->data ), mxit_parse_mood( rec->fields[2]->data ), |
| 1787 rec->fields[3]->data, rec->fields[4]->data, flags ); |
1805 rec->fields[3]->data, rec->fields[4]->data, flags ); |
| 1788 mxit_update_buddy_avatar( session, rec->fields[0]->data, rec->fields[5]->data ); |
1806 mxit_update_buddy_avatar( session, rec->fields[0]->data, rec->fields[5]->data ); |
| 1789 } |
1807 } |
| 1790 } |
1808 } |
| 1791 |
1809 |