comparison libpurple/protocols/bonjour/mdns_howl.c @ 17504:c921f901c7ea

Improve bonjour buddy TXT record parsing.
author Daniel Atallah <daniel.atallah@gmail.com>
date Tue, 05 Jun 2007 22:23:10 +0000
parents c96b085ddf5c
children bf45ab338124
comparison
equal deleted inserted replaced
17503:ba71c53186e9 17504:c921f901c7ea
53 sw_octets text_record, sw_ulong text_record_len, 53 sw_octets text_record, sw_ulong text_record_len,
54 sw_opaque extra) 54 sw_opaque extra)
55 { 55 {
56 BonjourBuddy *buddy; 56 BonjourBuddy *buddy;
57 PurpleAccount *account = (PurpleAccount*)extra; 57 PurpleAccount *account = (PurpleAccount*)extra;
58 /*gchar *txtvers = NULL;*/
59 /*gchar *version = NULL;*/
60 gint address_length = 16; 58 gint address_length = 16;
61 sw_text_record_iterator iterator; 59 sw_text_record_iterator iterator;
62 char key[SW_TEXT_RECORD_MAX_LEN]; 60 char key[SW_TEXT_RECORD_MAX_LEN];
63 char value[SW_TEXT_RECORD_MAX_LEN]; 61 char value[SW_TEXT_RECORD_MAX_LEN];
64 sw_uint32 value_length; 62 sw_uint32 value_length;
77 /* Obtain the parameters from the text_record */ 75 /* Obtain the parameters from the text_record */
78 if ((text_record_len > 0) && (text_record) && (*text_record != '\0')) 76 if ((text_record_len > 0) && (text_record) && (*text_record != '\0'))
79 { 77 {
80 sw_text_record_iterator_init(&iterator, text_record, text_record_len); 78 sw_text_record_iterator_init(&iterator, text_record, text_record_len);
81 while (sw_text_record_iterator_next(iterator, key, (sw_octet *)value, &value_length) == SW_OKAY) 79 while (sw_text_record_iterator_next(iterator, key, (sw_octet *)value, &value_length) == SW_OKAY)
82 { 80 set_bonjour_buddy_value(buddy, key, value, value_length);
83 /* Compare the keys with the possible ones and save them on */ 81
84 /* the appropiate place of the buddy_list */ 82 sw_text_record_iterator_fina(iterator);
85 if (strcmp(key, "txtvers") == 0) {
86 /*txtvers = g_strdup(value);*/
87 } else if (strcmp(key, "version") == 0) {
88 /*version = g_strdup(value);*/
89 } else if (strcmp(key, "1st") == 0) {
90 g_free(buddy->first);
91 buddy->first = g_strdup(value);
92 } else if (strcmp(key, "status") == 0) {
93 g_free(buddy->status);
94 buddy->status = g_strdup(value);
95 } else if (strcmp(key, "email") == 0) {
96 g_free(buddy->email);
97 buddy->email = g_strdup(value);
98 } else if (strcmp(key, "last") == 0) {
99 g_free(buddy->last);
100 buddy->last = g_strdup(value);
101 } else if (strcmp(key, "jid") == 0) {
102 g_free(buddy->jid);
103 buddy->jid = g_strdup(value);
104 } else if (strcmp(key, "AIM") == 0) {
105 g_free(buddy->AIM);
106 buddy->AIM = g_strdup(value);
107 } else if (strcmp(key, "vc") == 0) {
108 g_free(buddy->vc);
109 buddy->vc = g_strdup(value);
110 } else if (strcmp(key, "phsh") == 0) {
111 g_free(buddy->phsh);
112 buddy->phsh = g_strdup(value);
113 } else if (strcmp(key, "msg") == 0) {
114 g_free(buddy->msg);
115 buddy->msg = g_strdup(value);
116 }
117 }
118 } 83 }
119 84
120 if (!bonjour_buddy_check(buddy)) 85 if (!bonjour_buddy_check(buddy))
121 { 86 {
122 bonjour_buddy_delete(buddy); 87 bonjour_buddy_delete(buddy);
123 return SW_DISCOVERY_E_UNKNOWN; 88 return SW_DISCOVERY_E_UNKNOWN;
124 } 89 }
125 90
126 /* Add or update the buddy in our buddy list */ 91 /* Add or update the buddy in our buddy list */
127 bonjour_buddy_add_to_purple(buddy); 92 bonjour_buddy_add_to_purple(buddy);
128
129 /* Free all the temporal strings */
130 /*g_free(txtvers);*/
131 /*g_free(version);*/
132 93
133 return SW_OKAY; 94 return SW_OKAY;
134 } 95 }
135 96
136 sw_result HOWL_API 97 sw_result HOWL_API