Mercurial > pidgin
comparison libpurple/protocols/mxit/protocol.c @ 31493:dde6f5770cd0
Searching.
author | andrew.victor@mxit.com |
---|---|
date | Mon, 28 Mar 2011 22:18:22 +0000 |
parents | 7c3b4002f46e |
children | acd92b7d8511 |
comparison
equal
deleted
inserted
replaced
31492:7c3b4002f46e | 31493:dde6f5770cd0 |
---|---|
533 purple_connection_error( session->con, _( "Timeout while waiting for a response from the MXit server." ) ); | 533 purple_connection_error( session->con, _( "Timeout while waiting for a response from the MXit server." ) ); |
534 } | 534 } |
535 return; | 535 return; |
536 } | 536 } |
537 | 537 |
538 /* | 538 /* |
539 * the mxit server has flood detection and it prevents you from sending messages to fast. | 539 * the mxit server has flood detection and it prevents you from sending messages to fast. |
540 * this is a self defense mechanism, a very annoying feature. so the client must ensure that | 540 * this is a self defense mechanism, a very annoying feature. so the client must ensure that |
541 * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds. | 541 * it does not send messages too fast otherwise mxit will ignore the user for 30 seconds. |
542 * this is what we are trying to avoid here.. | 542 * this is what we are trying to avoid here.. |
543 */ | 543 */ |
715 /* convert the packet to a byte stream */ | 715 /* convert the packet to a byte stream */ |
716 datalen = snprintf( data, sizeof( data ), | 716 datalen = snprintf( data, sizeof( data ), |
717 "ms=%s%c%s%c%i%c%s%c" /* "ms"=password\1version\1maxreplyLen\1name\1 */ | 717 "ms=%s%c%s%c%i%c%s%c" /* "ms"=password\1version\1maxreplyLen\1name\1 */ |
718 "%s%c%i%c%s%c%s%c" /* dateOfBirth\1gender\1location\1capabilities\1 */ | 718 "%s%c%i%c%s%c%s%c" /* dateOfBirth\1gender\1location\1capabilities\1 */ |
719 "%s%c%i%c%s%c%s" /* dc\1features\1dialingcode\1locale */ | 719 "%s%c%i%c%s%c%s" /* dc\1features\1dialingcode\1locale */ |
720 "%c%i%c%i", /* \1protocolVer\1lastRosterUpdate */ | 720 "%c%i%c%i", /* \1protocolVer\1lastRosterUpdate */ |
721 session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, CP_MAX_FILESIZE, CP_FLD_TERM, profile->nickname, CP_FLD_TERM, | 721 session->encpwd, CP_FLD_TERM, clientVersion, CP_FLD_TERM, CP_MAX_FILESIZE, CP_FLD_TERM, profile->nickname, CP_FLD_TERM, |
722 profile->birthday, CP_FLD_TERM, ( profile->male ) ? 1 : 0, CP_FLD_TERM, MXIT_DEFAULT_LOC, CP_FLD_TERM, MXIT_CP_CAP, CP_FLD_TERM, | 722 profile->birthday, CP_FLD_TERM, ( profile->male ) ? 1 : 0, CP_FLD_TERM, MXIT_DEFAULT_LOC, CP_FLD_TERM, MXIT_CP_CAP, CP_FLD_TERM, |
723 session->distcode, CP_FLD_TERM, features, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale, | 723 session->distcode, CP_FLD_TERM, features, CP_FLD_TERM, session->dialcode, CP_FLD_TERM, locale, |
724 CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0 | 724 CP_FLD_TERM, MXIT_CP_PROTO_VESION, CP_FLD_TERM, 0 |
725 ); | 725 ); |
882 * Send packet to request list of suggested friends. | 882 * Send packet to request list of suggested friends. |
883 * | 883 * |
884 * @param session The MXit session object | 884 * @param session The MXit session object |
885 * @param max Maximum number of results to return | 885 * @param max Maximum number of results to return |
886 * @param nr_attribs Number of attributes being requested | 886 * @param nr_attribs Number of attributes being requested |
887 * @param attribute The names of the attributes | 887 * @param attribute The names of the attributes |
888 */ | 888 */ |
889 void mxit_send_suggest_friends( struct MXitSession* session, int max, unsigned int nr_attrib, const char* attribute[] ) | 889 void mxit_send_suggest_friends( struct MXitSession* session, int max, unsigned int nr_attrib, const char* attribute[] ) |
890 { | 890 { |
891 char data[CP_MAX_PACKET]; | 891 char data[CP_MAX_PACKET]; |
892 int datalen; | 892 int datalen; |
1880 } | 1880 } |
1881 } | 1881 } |
1882 | 1882 |
1883 | 1883 |
1884 /*------------------------------------------------------------------------ | 1884 /*------------------------------------------------------------------------ |
1885 * Process a received suggest-contacts packet. | |
1886 * | |
1887 * @param session The MXit session object | |
1888 * @param records The packet's data records | |
1889 * @param rcount The number of data records | |
1890 */ | |
1891 static void mxit_parse_cmd_suggestcontacts( struct MXitSession* session, struct record** records, int rcount ) | |
1892 { | |
1893 int i; | |
1894 GList* entries = NULL; | |
1895 | |
1896 /* | |
1897 * searchType \1 numSuggestions \1 total \1 numAttributes \1 name0 \1 name1 \1 ... \1 nameN \0 | |
1898 * userid \1 contactType \1 value0 \1 value1 ... valueN \0 | |
1899 * ... | |
1900 * userid \1 contactType \1 value0 \1 value1 ... valueN | |
1901 */ | |
1902 | |
1903 for ( i = 1; i < rcount; i ++ ) { | |
1904 struct record* rec = records[i]; | |
1905 struct MXitProfile* profile = g_new0( struct MXitProfile, 1 ); | |
1906 | |
1907 g_strlcpy( profile->userid, rec->fields[0]->data, sizeof( profile->userid ) ); | |
1908 // TODO: Decoce other profile fields. | |
1909 | |
1910 entries = g_list_append( entries, profile ); | |
1911 } | |
1912 | |
1913 /* display */ | |
1914 mxit_show_search_results( session, entries ); | |
1915 | |
1916 /* cleanup */ | |
1917 g_list_foreach( entries, (GFunc)g_free, NULL ); | |
1918 } | |
1919 | |
1920 | |
1921 /*------------------------------------------------------------------------ | |
1885 * Return the length of a multimedia chunk | 1922 * Return the length of a multimedia chunk |
1886 * | 1923 * |
1887 * @return The actual chunk data length in bytes | 1924 * @return The actual chunk data length in bytes |
1888 */ | 1925 */ |
1889 static int get_chunk_len( const char* chunkdata ) | 1926 static int get_chunk_len( const char* chunkdata ) |
2128 break; | 2165 break; |
2129 | 2166 |
2130 case CP_CMD_EXTPROFILE_GET : | 2167 case CP_CMD_EXTPROFILE_GET : |
2131 /* profile update */ | 2168 /* profile update */ |
2132 mxit_parse_cmd_extprofile( session, &packet->records[2], packet->rcount - 2 ); | 2169 mxit_parse_cmd_extprofile( session, &packet->records[2], packet->rcount - 2 ); |
2170 break; | |
2171 | |
2172 case CP_CMD_SUGGESTCONTACTS : | |
2173 /* suggest contacts */ | |
2174 mxit_parse_cmd_suggestcontacts( session, &packet->records[2], packet->rcount - 2 ); | |
2133 break; | 2175 break; |
2134 | 2176 |
2135 case CP_CMD_MOOD : | 2177 case CP_CMD_MOOD : |
2136 /* mood update */ | 2178 /* mood update */ |
2137 case CP_CMD_UPDATE : | 2179 case CP_CMD_UPDATE : |