comparison libpurple/protocols/silc/ops.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents f07501af8bae
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
70 70
71 if (client != NULL) 71 if (client != NULL)
72 gc = client->application; 72 gc = client->application;
73 73
74 if (gc != NULL) 74 if (gc != NULL)
75 purple_connection_error_reason(gc, reason, tmp); 75 purple_connection_error(gc, reason, tmp);
76 else 76 else
77 purple_notify_error(NULL, _("Error"), _("Error occurred"), tmp); 77 purple_notify_error(NULL, _("Error"), _("Error occurred"), tmp);
78 } 78 }
79 79
80 /* Processes incoming MIME message. Can be private message or channel 80 /* Processes incoming MIME message. Can be private message or channel
86 SilcMessagePayload payload, SilcChannelPrivateKey key, 86 SilcMessagePayload payload, SilcChannelPrivateKey key,
87 SilcMessageFlags flags, SilcMime mime, 87 SilcMessageFlags flags, SilcMime mime,
88 gboolean recursive) 88 gboolean recursive)
89 { 89 {
90 PurpleConnection *gc = client->application; 90 PurpleConnection *gc = client->application;
91 SilcPurple sg = gc->proto_data; 91 SilcPurple sg = purple_connection_get_protocol_data(gc);
92 const char *type; 92 const char *type;
93 const unsigned char *data; 93 const unsigned char *data;
94 SilcUInt32 data_len; 94 SilcUInt32 data_len;
95 PurpleMessageFlags cflags = 0; 95 PurpleMessageFlags cflags = 0;
96 PurpleConversation *convo = NULL; 96 PurpleConversation *convo = NULL;
222 serv_got_im(gc, sender->nickname ? 222 serv_got_im(gc, sender->nickname ?
223 sender->nickname : "<unknown>", 223 sender->nickname : "<unknown>",
224 tmp, cflags, time(NULL)); 224 tmp, cflags, time(NULL));
225 225
226 purple_imgstore_unref_by_id(imgid); 226 purple_imgstore_unref_by_id(imgid);
227 cflags = 0;
228 ret = TRUE; 227 ret = TRUE;
229 } 228 }
230 goto out; 229 goto out;
231 } 230 }
232 231
262 SilcChannelPrivateKey key, SilcMessageFlags flags, 261 SilcChannelPrivateKey key, SilcMessageFlags flags,
263 const unsigned char *message, 262 const unsigned char *message,
264 SilcUInt32 message_len) 263 SilcUInt32 message_len)
265 { 264 {
266 PurpleConnection *gc = client->application; 265 PurpleConnection *gc = client->application;
267 SilcPurple sg = gc->proto_data; 266 SilcPurple sg = purple_connection_get_protocol_data(gc);
268 PurpleConversation *convo = NULL; 267 PurpleConversation *convo = NULL;
269 char *msg, *tmp; 268 char *msg, *tmp;
270 269
271 if (!message) 270 if (!message)
272 return; 271 return;
359 SilcClientEntry sender, SilcMessagePayload payload, 358 SilcClientEntry sender, SilcMessagePayload payload,
360 SilcMessageFlags flags, const unsigned char *message, 359 SilcMessageFlags flags, const unsigned char *message,
361 SilcUInt32 message_len) 360 SilcUInt32 message_len)
362 { 361 {
363 PurpleConnection *gc = client->application; 362 PurpleConnection *gc = client->application;
364 SilcPurple sg = gc->proto_data; 363 SilcPurple sg = purple_connection_get_protocol_data(gc);
365 PurpleConversation *convo = NULL; 364 PurpleConversation *convo = NULL;
366 char *msg, *tmp; 365 char *msg, *tmp;
367 366
368 if (!message) 367 if (!message)
369 return; 368 return;
443 silc_notify(SilcClient client, SilcClientConnection conn, 442 silc_notify(SilcClient client, SilcClientConnection conn,
444 SilcNotifyType type, ...) 443 SilcNotifyType type, ...)
445 { 444 {
446 va_list va; 445 va_list va;
447 PurpleConnection *gc = client->application; 446 PurpleConnection *gc = client->application;
448 SilcPurple sg = gc->proto_data; 447 SilcPurple sg = purple_connection_get_protocol_data(gc);
449 PurpleAccount *account = purple_connection_get_account(gc); 448 PurpleAccount *account = purple_connection_get_account(gc);
450 PurpleConversation *convo; 449 PurpleConversation *convo;
451 SilcClientEntry client_entry, client_entry2; 450 SilcClientEntry client_entry, client_entry2;
452 SilcChannelEntry channel; 451 SilcChannelEntry channel;
453 SilcServerEntry server_entry; 452 SilcServerEntry server_entry;
953 silc_command(SilcClient client, SilcClientConnection conn, 952 silc_command(SilcClient client, SilcClientConnection conn,
954 SilcBool success, SilcCommand command, SilcStatus status, 953 SilcBool success, SilcCommand command, SilcStatus status,
955 SilcUInt32 argc, unsigned char **argv) 954 SilcUInt32 argc, unsigned char **argv)
956 { 955 {
957 PurpleConnection *gc = client->application; 956 PurpleConnection *gc = client->application;
958 SilcPurple sg = gc->proto_data; 957 SilcPurple sg = purple_connection_get_protocol_data(gc);
959 958
960 switch (command) { 959 switch (command) {
961 960
962 case SILC_COMMAND_CMODE: 961 case SILC_COMMAND_CMODE:
963 if (argc == 3 && !strcmp((char *)argv[2], "+C")) 962 if (argc == 3 && !strcmp((char *)argv[2], "+C"))
1090 silc_command_reply(SilcClient client, SilcClientConnection conn, 1089 silc_command_reply(SilcClient client, SilcClientConnection conn,
1091 SilcCommand command, SilcStatus status, 1090 SilcCommand command, SilcStatus status,
1092 SilcStatus error, va_list ap) 1091 SilcStatus error, va_list ap)
1093 { 1092 {
1094 PurpleConnection *gc = client->application; 1093 PurpleConnection *gc = client->application;
1095 SilcPurple sg = gc->proto_data; 1094 SilcPurple sg = purple_connection_get_protocol_data(gc);
1096 PurpleConversation *convo; 1095 PurpleConversation *convo;
1097 1096
1098 switch (command) { 1097 switch (command) {
1099 case SILC_COMMAND_JOIN: 1098 case SILC_COMMAND_JOIN:
1100 { 1099 {
1174 case SILC_COMMAND_WHOIS: 1173 case SILC_COMMAND_WHOIS:
1175 { 1174 {
1176 SilcUInt32 idle, *user_modes; 1175 SilcUInt32 idle, *user_modes;
1177 SilcDList channels; 1176 SilcDList channels;
1178 SilcClientEntry client_entry; 1177 SilcClientEntry client_entry;
1179 char tmp[1024], *tmp2; 1178 char tmp[1024];
1180 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; 1179 char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr;
1181 PurpleNotifyUserInfo *user_info; 1180 PurpleNotifyUserInfo *user_info;
1182 1181
1183 if (status != SILC_STATUS_OK) { 1182 if (status != SILC_STATUS_OK) {
1184 purple_notify_error(gc, _("User Information"), 1183 purple_notify_error(gc, _("User Information"),
1196 idle = va_arg(ap, SilcUInt32); 1195 idle = va_arg(ap, SilcUInt32);
1197 (void)va_arg(ap, unsigned char *); 1196 (void)va_arg(ap, unsigned char *);
1198 user_modes = va_arg(ap, SilcUInt32 *); 1197 user_modes = va_arg(ap, SilcUInt32 *);
1199 1198
1200 user_info = purple_notify_user_info_new(); 1199 user_info = purple_notify_user_info_new();
1201 tmp2 = g_markup_escape_text(client_entry->nickname, -1); 1200 purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), client_entry->nickname);
1202 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp2);
1203 g_free(tmp2);
1204 if (client_entry->realname) { 1201 if (client_entry->realname) {
1205 tmp2 = g_markup_escape_text(client_entry->realname, -1); 1202 purple_notify_user_info_add_pair_plaintext(user_info, _("Real Name"), client_entry->realname);
1206 purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp2); 1203 }
1204 if (*client_entry->hostname) {
1205 gchar *tmp2;
1206 tmp2 = g_strdup_printf("%s@%s", client_entry->username, client_entry->hostname);
1207 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), tmp2);
1207 g_free(tmp2); 1208 g_free(tmp2);
1208 }
1209 tmp2 = g_markup_escape_text(client_entry->username, -1);
1210 if (*client_entry->hostname) {
1211 gchar *tmp3;
1212 tmp3 = g_strdup_printf("%s@%s", tmp2, client_entry->hostname);
1213 purple_notify_user_info_add_pair(user_info, _("Username"), tmp3);
1214 g_free(tmp3);
1215 } else 1209 } else
1216 purple_notify_user_info_add_pair(user_info, _("Username"), tmp2); 1210 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), client_entry->username);
1217 g_free(tmp2);
1218 1211
1219 if (client_entry->mode) { 1212 if (client_entry->mode) {
1220 memset(tmp, 0, sizeof(tmp)); 1213 memset(tmp, 0, sizeof(tmp));
1221 silcpurple_get_umode_string(client_entry->mode, 1214 silcpurple_get_umode_string(client_entry->mode,
1222 tmp, sizeof(tmp) - strlen(tmp)); 1215 tmp, sizeof(tmp) - strlen(tmp));
1223 purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); 1216 /* TODO: Check whether it's correct to call add_pair_html,
1217 or if we should be using add_pair_plaintext */
1218 purple_notify_user_info_add_pair_html(user_info, _("User Modes"), tmp);
1224 } 1219 }
1225 1220
1226 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr); 1221 silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr);
1227 if (moodstr) { 1222 if (moodstr) {
1228 purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); 1223 /* TODO: Check whether it's correct to call add_pair_html,
1224 or if we should be using add_pair_plaintext */
1225 purple_notify_user_info_add_pair_html(user_info, _("Mood"), moodstr);
1229 g_free(moodstr); 1226 g_free(moodstr);
1230 } 1227 }
1231 1228
1232 if (statusstr) { 1229 if (statusstr) {
1233 tmp2 = g_markup_escape_text(statusstr, -1); 1230 purple_notify_user_info_add_pair_plaintext(user_info, _("Status Text"), statusstr);
1234 purple_notify_user_info_add_pair(user_info, _("Status Text"), tmp2);
1235 g_free(statusstr); 1231 g_free(statusstr);
1236 g_free(tmp2);
1237 } 1232 }
1238 1233
1239 if (contactstr) { 1234 if (contactstr) {
1240 purple_notify_user_info_add_pair(user_info, _("Preferred Contact"), contactstr); 1235 /* TODO: Check whether it's correct to call add_pair_html,
1236 or if we should be using add_pair_plaintext */
1237 purple_notify_user_info_add_pair_html(user_info, _("Preferred Contact"), contactstr);
1241 g_free(contactstr); 1238 g_free(contactstr);
1242 } 1239 }
1243 1240
1244 if (langstr) { 1241 if (langstr) {
1245 purple_notify_user_info_add_pair(user_info, _("Preferred Language"), langstr); 1242 /* TODO: Check whether it's correct to call add_pair_html,
1243 or if we should be using add_pair_plaintext */
1244 purple_notify_user_info_add_pair_html(user_info, _("Preferred Language"), langstr);
1246 g_free(langstr); 1245 g_free(langstr);
1247 } 1246 }
1248 1247
1249 if (devicestr) { 1248 if (devicestr) {
1250 purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); 1249 /* TODO: Check whether it's correct to call add_pair_html,
1250 or if we should be using add_pair_plaintext */
1251 purple_notify_user_info_add_pair_html(user_info, _("Device"), devicestr);
1251 g_free(devicestr); 1252 g_free(devicestr);
1252 } 1253 }
1253 1254
1254 if (tzstr) { 1255 if (tzstr) {
1255 purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); 1256 /* TODO: Check whether it's correct to call add_pair_html,
1257 or if we should be using add_pair_plaintext */
1258 purple_notify_user_info_add_pair_html(user_info, _("Timezone"), tzstr);
1256 g_free(tzstr); 1259 g_free(tzstr);
1257 } 1260 }
1258 1261
1259 if (geostr) { 1262 if (geostr) {
1260 purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); 1263 /* TODO: Check whether it's correct to call add_pair_html,
1264 or if we should be using add_pair_plaintext */
1265 purple_notify_user_info_add_pair_html(user_info, _("Geolocation"), geostr);
1261 g_free(geostr); 1266 g_free(geostr);
1262 } 1267 }
1263 1268
1264 if (*client_entry->server) 1269 if (*client_entry->server) {
1265 purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server); 1270 /* TODO: Check whether it's correct to call add_pair_html,
1271 or if we should be using add_pair_plaintext */
1272 purple_notify_user_info_add_pair_html(user_info, _("Server"), client_entry->server);
1273 }
1266 1274
1267 if (channels && user_modes) { 1275 if (channels && user_modes) {
1268 SilcChannelPayload entry; 1276 SilcChannelPayload entry;
1269 int i = 0; 1277 int i = 0;
1270 1278
1278 silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m)); 1286 silc_strncat(tmp, sizeof(tmp) - 1, m, strlen(m));
1279 silc_strncat(tmp, sizeof(tmp) - 1, name, name_len); 1287 silc_strncat(tmp, sizeof(tmp) - 1, name, name_len);
1280 silc_strncat(tmp, sizeof(tmp) - 1, " ", 1); 1288 silc_strncat(tmp, sizeof(tmp) - 1, " ", 1);
1281 silc_free(m); 1289 silc_free(m);
1282 } 1290 }
1283 tmp2 = g_markup_escape_text(tmp, -1); 1291 purple_notify_user_info_add_pair_plaintext(user_info, _("Currently on"), tmp);
1284 purple_notify_user_info_add_pair(user_info, _("Currently on"), tmp2);
1285 g_free(tmp2);
1286 } 1292 }
1287 1293
1288 if (client_entry->public_key) { 1294 if (client_entry->public_key) {
1289 char *fingerprint, *babbleprint; 1295 char *fingerprint, *babbleprint;
1290 unsigned char *pk; 1296 unsigned char *pk;
1291 SilcUInt32 pk_len; 1297 SilcUInt32 pk_len;
1292 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); 1298 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
1293 if (pk) { 1299 if (pk) {
1294 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); 1300 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
1295 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); 1301 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
1296 purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint); 1302 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Fingerprint"), fingerprint);
1297 purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint); 1303 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Babbleprint"), babbleprint);
1298 silc_free(fingerprint); 1304 silc_free(fingerprint);
1299 silc_free(babbleprint); 1305 silc_free(babbleprint);
1300 silc_free(pk); 1306 silc_free(pk);
1301 } 1307 }
1302 } 1308 }
1316 break; 1322 break;
1317 1323
1318 case SILC_COMMAND_WHOWAS: 1324 case SILC_COMMAND_WHOWAS:
1319 { 1325 {
1320 SilcClientEntry client_entry; 1326 SilcClientEntry client_entry;
1321 char *nickname, *realname, *username, *tmp; 1327 char *nickname, *realname, *username;
1322 PurpleNotifyUserInfo *user_info; 1328 PurpleNotifyUserInfo *user_info;
1323 1329
1324 if (status != SILC_STATUS_OK) { 1330 if (status != SILC_STATUS_OK) {
1325 purple_notify_error(gc, _("User Information"), 1331 purple_notify_error(gc, _("User Information"),
1326 _("Cannot get user information"), 1332 _("Cannot get user information"),
1334 realname = va_arg(ap, char *); 1340 realname = va_arg(ap, char *);
1335 if (!nickname) 1341 if (!nickname)
1336 break; 1342 break;
1337 1343
1338 user_info = purple_notify_user_info_new(); 1344 user_info = purple_notify_user_info_new();
1339 tmp = g_markup_escape_text(nickname, -1); 1345 purple_notify_user_info_add_pair_plaintext(user_info, _("Nickname"), nickname);
1340 purple_notify_user_info_add_pair(user_info, _("Nickname"), tmp); 1346 if (realname)
1341 g_free(tmp); 1347 purple_notify_user_info_add_pair_plaintext(user_info, _("Real Name"), realname);
1342 if (realname) {
1343 tmp = g_markup_escape_text(realname, -1);
1344 purple_notify_user_info_add_pair(user_info, _("Real Name"), tmp);
1345 g_free(tmp);
1346 }
1347 if (username) { 1348 if (username) {
1348 tmp = g_markup_escape_text(username, -1);
1349 if (client_entry && *client_entry->hostname) { 1349 if (client_entry && *client_entry->hostname) {
1350 gchar *tmp3; 1350 gchar *tmp;
1351 tmp3 = g_strdup_printf("%s@%s", tmp, client_entry->hostname); 1351 tmp = g_strdup_printf("%s@%s", username, client_entry->hostname);
1352 purple_notify_user_info_add_pair(user_info, _("Username"), tmp3); 1352 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), tmp);
1353 g_free(tmp3); 1353 g_free(tmp);
1354 } else 1354 } else
1355 purple_notify_user_info_add_pair(user_info, _("Username"), tmp); 1355 purple_notify_user_info_add_pair_plaintext(user_info, _("Username"), username);
1356 g_free(tmp); 1356 }
1357 } 1357 if (client_entry && *client_entry->server) {
1358 if (client_entry && *client_entry->server) 1358 /* TODO: Check whether it's correct to call add_pair_html,
1359 purple_notify_user_info_add_pair(user_info, _("Server"), client_entry->server); 1359 or if we should be using add_pair_plaintext */
1360 purple_notify_user_info_add_pair_html(user_info, _("Server"), client_entry->server);
1361 }
1360 1362
1361 1363
1362 if (client_entry && client_entry->public_key) { 1364 if (client_entry && client_entry->public_key) {
1363 char *fingerprint, *babbleprint; 1365 char *fingerprint, *babbleprint;
1364 unsigned char *pk; 1366 unsigned char *pk;
1365 SilcUInt32 pk_len; 1367 SilcUInt32 pk_len;
1366 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len); 1368 pk = silc_pkcs_public_key_encode(client_entry->public_key, &pk_len);
1367 if (pk) { 1369 if (pk) {
1368 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len); 1370 fingerprint = silc_hash_fingerprint(NULL, pk, pk_len);
1369 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len); 1371 babbleprint = silc_hash_babbleprint(NULL, pk, pk_len);
1370 purple_notify_user_info_add_pair(user_info, _("Public Key Fingerprint"), fingerprint); 1372 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Fingerprint"), fingerprint);
1371 purple_notify_user_info_add_pair(user_info, _("Public Key Babbleprint"), babbleprint); 1373 purple_notify_user_info_add_pair_plaintext(user_info, _("Public Key Babbleprint"), babbleprint);
1372 silc_free(fingerprint); 1374 silc_free(fingerprint);
1373 silc_free(babbleprint); 1375 silc_free(babbleprint);
1374 silc_free(pk); 1376 silc_free(pk);
1375 } 1377 }
1376 } 1378 }
1733 char *hostname, SilcUInt16 port, 1735 char *hostname, SilcUInt16 port,
1734 SilcAuthMethod auth_method, 1736 SilcAuthMethod auth_method,
1735 SilcGetAuthMeth completion, void *context) 1737 SilcGetAuthMeth completion, void *context)
1736 { 1738 {
1737 PurpleConnection *gc = client->application; 1739 PurpleConnection *gc = client->application;
1738 SilcPurple sg = gc->proto_data; 1740 SilcPurple sg = purple_connection_get_protocol_data(gc);
1739 SilcPurpleAskPassphrase internal; 1741 SilcPurpleAskPassphrase internal;
1740 const char *password; 1742 const char *password;
1741 1743
1742 /* Progress */ 1744 /* Progress */
1743 if (sg->resuming) 1745 if (sg->resuming)
1784 SilcConnectionType conn_type, 1786 SilcConnectionType conn_type,
1785 SilcPublicKey public_key, 1787 SilcPublicKey public_key,
1786 SilcVerifyPublicKey completion, void *context) 1788 SilcVerifyPublicKey completion, void *context)
1787 { 1789 {
1788 PurpleConnection *gc = client->application; 1790 PurpleConnection *gc = client->application;
1789 SilcPurple sg = gc->proto_data; 1791 SilcPurple sg = purple_connection_get_protocol_data(gc);
1790 1792
1791 if (!sg->conn && (conn_type == SILC_CONN_SERVER || 1793 if (!sg->conn && (conn_type == SILC_CONN_SERVER ||
1792 conn_type == SILC_CONN_ROUTER)) { 1794 conn_type == SILC_CONN_ROUTER)) {
1793 /* Progress */ 1795 /* Progress */
1794 if (sg->resuming) 1796 if (sg->resuming)